hanzi-browse 2.2.3 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -70,8 +70,12 @@ export async function runAgentLoop(params) {
70
70
  totalUsage.outputTokens += response.usage?.output_tokens || 0;
71
71
  if (response.model)
72
72
  lastModel = response.model;
73
- // Add assistant response to conversation
74
- messages.push({ role: "assistant", content: response.content });
73
+ // Add assistant response to conversation (preserve raw Gemini parts for thought signatures)
74
+ const assistantMsg = { role: "assistant", content: response.content };
75
+ if (response._rawGeminiParts) {
76
+ assistantMsg._rawGeminiParts = response._rawGeminiParts;
77
+ }
78
+ messages.push(assistantMsg);
75
79
  // Extract text and tool calls
76
80
  const textBlocks = response.content.filter((b) => b.type === "text");
77
81
  const toolUseBlocks = response.content.filter((b) => b.type === "tool_use");
@@ -13,7 +13,7 @@ Event: ${kt(t)}.
13
13
  Url: ${Er(t)}`),!0;if(!ef(t,e.allowUrls))return U&&L.warn(`Event dropped due to not being matched by \`allowUrls\` option.
14
14
  Event: ${kt(t)}.
15
15
  Url: ${Er(t)}`),!0}return!1}function Xp(t,e){return e!=null&&e.length?Cc(t).some(n=>Zr(n,e)):!1}function Zp(t,e){if(!(e!=null&&e.length))return!1;const n=t.transaction;return n?Zr(n,e):!1}function Qp(t,e){if(!(e!=null&&e.length))return!1;const n=Er(t);return n?Zr(n,e):!1}function ef(t,e){if(!(e!=null&&e.length))return!0;const n=Er(t);return n?Zr(n,e):!0}function tf(t=[]){for(let e=t.length-1;e>=0;e--){const n=t[e];if(n&&n.filename!=="<anonymous>"&&n.filename!=="[native code]")return n.filename||null}return null}function Er(t){var e,n;try{const r=[...((e=t.exception)==null?void 0:e.values)??[]].reverse().find(i=>{var o,a,l;return((o=i.mechanism)==null?void 0:o.parent_id)===void 0&&((l=(a=i.stacktrace)==null?void 0:a.frames)==null?void 0:l.length)}),s=(n=r==null?void 0:r.stacktrace)==null?void 0:n.frames;return s?tf(s):null}catch{return U&&L.error(`Cannot extract url for event ${kt(t)}`),null}}function nf(t){var e,n;return(n=(e=t.exception)==null?void 0:e.values)!=null&&n.length?!t.message&&!t.exception.values.some(r=>r.stacktrace||r.type&&r.type!=="Error"||r.value):!1}function rf(t,e,n,r,s,i){var a;if(!((a=s.exception)!=null&&a.values)||!i||!vt(i.originalException,Error))return;const o=s.exception.values.length>0?s.exception.values[s.exception.values.length-1]:void 0;o&&(s.exception.values=Js(t,e,r,i.originalException,n,s.exception.values,o,0))}function Js(t,e,n,r,s,i,o,a){if(i.length>=n+1)return i;let l=[...i];if(vt(r[s],Error)){ca(o,a,r);const c=t(e,r[s]),u=l.length;ua(c,s,u,a),l=Js(t,e,n,r[s],s,[c,...l],c,u)}return Fc(r)&&r.errors.forEach((c,u)=>{if(vt(c,Error)){ca(o,a,r);const d=t(e,c),p=l.length;ua(d,`errors[${u}]`,p,a),l=Js(t,e,n,c,s,[d,...l],d,p)}}),l}function Fc(t){return Array.isArray(t.errors)}function ca(t,e,n){t.mechanism={handled:!0,type:"auto.core.linked_errors",...Fc(n)&&{is_exception_group:!0},...t.mechanism,exception_id:e}}function ua(t,e,n,r){t.mechanism={handled:!0,...t.mechanism,type:"chained",source:e,exception_id:n,parent_id:r}}function sf(t){const e="console";Rt(e,t),Ot(e,of)}function of(){"console"in J&&cd.forEach(function(t){t in J.console&&$e(J.console,t,function(e){return yr[t]=e,function(...n){je("console",{args:n,level:t});const s=yr[t];s==null||s.apply(J.console,n)}})})}function af(t){return t==="warn"?"warning":["fatal","error","warning","log","info","debug"].includes(t)?t:"log"}const lf="Dedupe",cf=()=>{let t;return{name:lf,processEvent(e){if(e.type)return e;try{if(df(e,t))return U&&L.warn("Event dropped due to being a duplicate of previously captured event."),null}catch{}return t=e}}},uf=cf;function df(t,e){return e?!!(hf(t,e)||pf(t,e)):!1}function hf(t,e){const n=t.message,r=e.message;return!(!n&&!r||n&&!r||!n&&r||n!==r||!Mc(t,e)||!Nc(t,e))}function pf(t,e){const n=da(e),r=da(t);return!(!n||!r||n.type!==r.type||n.value!==r.value||!Mc(t,e)||!Nc(t,e))}function Nc(t,e){let n=wo(t),r=wo(e);if(!n&&!r)return!0;if(n&&!r||!n&&r||(n=n,r=r,r.length!==n.length))return!1;for(let s=0;s<r.length;s++){const i=r[s],o=n[s];if(i.filename!==o.filename||i.lineno!==o.lineno||i.colno!==o.colno||i.function!==o.function)return!1}return!0}function Mc(t,e){let n=t.fingerprint,r=e.fingerprint;if(!n&&!r)return!0;if(n&&!r||!n&&r)return!1;n=n,r=r;try{return n.join("")===r.join("")}catch{return!1}}function da(t){var e,n;return(n=(e=t.exception)==null?void 0:e.values)==null?void 0:n[0]}const ff="ConversationId",_f=()=>({name:ff,setup(t){t.on("spanStart",e=>{const n=nt().getScopeData(),r=At().getScopeData(),s=n.conversationId||r.conversationId;s&&e.setAttribute(eh,s)})}}),gf=_f;function Dc(t){if(t!==void 0)return t>=400&&t<500?"warning":t>=500?"error":void 0}const An=J;function vf(){return"history"in An&&!!An.history}function mf(){if(!("fetch"in An))return!1;try{return new Headers,new Request("data:,"),new Response,!0}catch{return!1}}function Xs(t){return t&&/^function\s+\w+\(\)\s+\{\s+\[native code\]\s+\}$/.test(t.toString())}function yf(){var n;if(typeof EdgeRuntime=="string")return!0;if(!mf())return!1;if(Xs(An.fetch))return!0;let t=!1;const e=An.document;if(e&&typeof e.createElement=="function")try{const r=e.createElement("iframe");r.hidden=!0,e.head.appendChild(r),(n=r.contentWindow)!=null&&n.fetch&&(t=Xs(r.contentWindow.fetch)),e.head.removeChild(r)}catch(r){U&&L.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",r)}return t}function bf(t,e){const n="fetch";Rt(n,t),Ot(n,()=>Ef(void 0,e))}function Ef(t,e=!1){e&&!yf()||$e(J,"fetch",function(n){return function(...r){const s=new Error,{method:i,url:o}=wf(r),a={args:r,fetchData:{method:i,url:o},startTimestamp:et()*1e3,virtualError:s,headers:Sf(r)};return je("fetch",{...a}),n.apply(J,r).then(async l=>(je("fetch",{...a,endTimestamp:et()*1e3,response:l}),l),l=>{je("fetch",{...a,endTimestamp:et()*1e3,error:l}),Vr(l)&&l.stack===void 0&&(l.stack=s.stack,mt(l,"framesToPop",1));const c=Ee(),u=(c==null?void 0:c.getOptions().enhanceFetchErrorMessages)??"always";if(u!==!1&&l instanceof TypeError&&(l.message==="Failed to fetch"||l.message==="Load failed"||l.message==="NetworkError when attempting to fetch resource."))try{const f=new URL(a.fetchData.url).host;u==="always"?l.message=`${l.message} (${f})`:mt(l,"__sentry_fetch_url_host__",f)}catch{}throw l})}})}function ur(t,e){return!!t&&typeof t=="object"&&!!t[e]}function ha(t){return typeof t=="string"?t:t?ur(t,"url")?t.url:t.toString?t.toString():"":""}function wf(t){if(t.length===0)return{method:"GET",url:""};if(t.length===2){const[n,r]=t;return{url:ha(n),method:ur(r,"method")?String(r.method).toUpperCase():tc(n)&&ur(n,"method")?String(n.method).toUpperCase():"GET"}}const e=t[0];return{url:ha(e),method:ur(e,"method")?String(e.method).toUpperCase():"GET"}}function Sf(t){const[e,n]=t;try{if(typeof n=="object"&&n!==null&&"headers"in n&&n.headers)return new Headers(n.headers);if(tc(e))return new Headers(e.headers)}catch{}}function kf(){return"npm"}const ae=J;let Zs=0;function Lc(){return Zs>0}function xf(){Zs++,setTimeout(()=>{Zs--})}function Xt(t,e={}){function n(s){return typeof s=="function"}if(!n(t))return t;try{const s=t.__sentry_wrapped__;if(s)return typeof s=="function"?s:t;if(Bi(t))return t}catch{return t}const r=function(...s){try{const i=s.map(o=>Xt(o,e));return t.apply(this,i)}catch(i){throw xf(),Vd(o=>{o.addEventProcessor(a=>(e.mechanism&&(Bs(a,void 0),Yt(a,e.mechanism)),a.extra={...a.extra,arguments:s},a)),op(i)}),i}};try{for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[s]=t[s])}catch{}rc(r,t),mt(t,"__sentry_wrapped__",r);try{Object.getOwnPropertyDescriptor(r,"name").configurable&&Object.defineProperty(r,"name",{get(){return t.name}})}catch{}return r}function If(){const t=Hi(),{referrer:e}=ae.document||{},{userAgent:n}=ae.navigator||{},r={...e&&{Referer:e},...n&&{"User-Agent":n}};return{url:t,headers:r}}function Ki(t,e){const n=Ji(t,e),r={type:Rf(e),value:Of(e)};return n.length&&(r.stacktrace={frames:n}),r.type===void 0&&r.value===""&&(r.value="Unrecoverable error caught"),r}function Tf(t,e,n,r){const s=Ee(),i=s==null?void 0:s.getOptions().normalizeDepth,o=Df(e),a={__serialized__:gc(e,i)};if(o)return{exception:{values:[Ki(t,o)]},extra:a};const l={exception:{values:[{type:Kr(e)?e.constructor.name:r?"UnhandledRejection":"Error",value:Nf(e,{isUnhandledRejection:r})}]},extra:a};if(n){const c=Ji(t,n);c.length&&(l.exception.values[0].stacktrace={frames:c})}return l}function fs(t,e){return{exception:{values:[Ki(t,e)]}}}function Ji(t,e){const n=e.stacktrace||e.stack||"",r=Cf(e),s=$f(e);try{return t(n,r,s)}catch{}return[]}const Pf=/Minified React error #\d+;/i;function Cf(t){return t&&Pf.test(t.message)?1:0}function $f(t){return typeof t.framesToPop=="number"?t.framesToPop:0}function jc(t){return typeof WebAssembly<"u"&&typeof WebAssembly.Exception<"u"?t instanceof WebAssembly.Exception:!1}function Rf(t){const e=t==null?void 0:t.name;return!e&&jc(t)?t.message&&Array.isArray(t.message)&&t.message.length==2?t.message[0]:"WebAssembly.Exception":e}function Of(t){const e=t==null?void 0:t.message;return jc(t)?Array.isArray(t.message)&&t.message.length==2?t.message[1]:"wasm exception":e?e.error&&typeof e.error.message=="string"?ia(e.error):ia(t):"No error message"}function Af(t,e,n,r){const s=(n==null?void 0:n.syntheticException)||void 0,i=Xi(t,e,s,r);return Yt(i),i.level="error",n!=null&&n.event_id&&(i.event_id=n.event_id),Wn(i)}function Ff(t,e,n="info",r,s){const i=(r==null?void 0:r.syntheticException)||void 0,o=Qs(t,e,i,s);return o.level=n,r!=null&&r.event_id&&(o.event_id=r.event_id),Wn(o)}function Xi(t,e,n,r,s){let i;if(Ql(e)&&e.error)return fs(t,e.error);if(ko(e)||wd(e)){const o=e;if("stack"in e)i=fs(t,e);else{const a=o.name||(ko(o)?"DOMError":"DOMException"),l=o.message?`${a}: ${o.message}`:a;i=Qs(t,l,n,r),Bs(i,l)}return"code"in o&&(i.tags={...i.tags,"DOMException.code":`${o.code}`}),i}return Vr(e)?fs(t,e):Rn(e)||Kr(e)?(i=Tf(t,e,n,s),Yt(i,{synthetic:!0}),i):(i=Qs(t,e,n,r),Bs(i,`${e}`),Yt(i,{synthetic:!0}),i)}function Qs(t,e,n,r){const s={};if(r&&n){const i=Ji(t,n);i.length&&(s.exception={values:[{value:e,stacktrace:{frames:i}}]}),Yt(s,{synthetic:!0})}if(ji(e)){const{__sentry_template_string__:i,__sentry_template_values__:o}=e;return s.logentry={message:i,params:o},s}return s.message=e,s}function Nf(t,{isUnhandledRejection:e}){const n=Cd(t),r=e?"promise rejection":"exception";return Ql(t)?`Event \`ErrorEvent\` captured as ${r} with message \`${t.message}\``:Kr(t)?`Event \`${Mf(t)}\` (type=${t.type}) captured as ${r}`:`Object captured as ${r} with keys: ${n}`}function Mf(t){try{const e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch{}}function Df(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)){const n=t[e];if(n instanceof Error)return n}}class Lf extends Rp{constructor(e){var u;const n=jf(e),r=ae.SENTRY_SDK_SOURCE||kf();Hp(n,"browser",["browser"],r),(u=n._metadata)!=null&&u.sdk&&(n._metadata.sdk.settings={infer_ip:n.sendDefaultPii?"auto":"never",...n._metadata.sdk.settings}),super(n);const{sendDefaultPii:s,sendClientReports:i,enableLogs:o,_experiments:a,enableMetrics:l}=this._options,c=l??(a==null?void 0:a.enableMetrics)??!0;ae.document&&(i||o||c)&&ae.document.addEventListener("visibilitychange",()=>{ae.document.visibilityState==="hidden"&&(i&&this._flushOutcomes(),o&&Ys(this),c&&xc(this))}),s&&this.on("beforeSendSession",Up)}eventFromException(e,n){return Af(this._options.stackParser,e,n,this._options.attachStacktrace)}eventFromMessage(e,n="info",r){return Ff(this._options.stackParser,e,n,r,this._options.attachStacktrace)}_prepareEvent(e,n,r,s){return e.platform=e.platform||"javascript",super._prepareEvent(e,n,r,s)}}function jf(t){var e;return{release:typeof __SENTRY_RELEASE__=="string"?__SENTRY_RELEASE__:(e=ae.SENTRY_RELEASE)==null?void 0:e.id,sendClientReports:!0,parentSpanIsAlwaysRootSpan:!0,...t}}const Uf=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,ke=J,Hf=1e3;let pa,ei,ti;function Bf(t){const e="dom";Rt(e,t),Ot(e,zf)}function zf(){if(!ke.document)return;const t=je.bind(null,"dom"),e=fa(t,!0);ke.document.addEventListener("click",e,!1),ke.document.addEventListener("keypress",e,!1),["EventTarget","Node"].forEach(n=>{var i,o;const s=(i=ke[n])==null?void 0:i.prototype;(o=s==null?void 0:s.hasOwnProperty)!=null&&o.call(s,"addEventListener")&&($e(s,"addEventListener",function(a){return function(l,c,u){if(l==="click"||l=="keypress")try{const d=this.__sentry_instrumentation_handlers__=this.__sentry_instrumentation_handlers__||{},p=d[l]=d[l]||{refCount:0};if(!p.handler){const f=fa(t);p.handler=f,a.call(this,l,f,u)}p.refCount++}catch{}return a.call(this,l,c,u)}}),$e(s,"removeEventListener",function(a){return function(l,c,u){if(l==="click"||l=="keypress")try{const d=this.__sentry_instrumentation_handlers__||{},p=d[l];p&&(p.refCount--,p.refCount<=0&&(a.call(this,l,p.handler,u),p.handler=void 0,delete d[l]),Object.keys(d).length===0&&delete this.__sentry_instrumentation_handlers__)}catch{}return a.call(this,l,c,u)}}))})}function Wf(t){if(t.type!==ei)return!1;try{if(!t.target||t.target._sentryId!==ti)return!1}catch{}return!0}function qf(t,e){return t!=="keypress"?!1:e!=null&&e.tagName?!(e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable):!0}function fa(t,e=!1){return n=>{if(!n||n._sentryCaptured)return;const r=Gf(n);if(qf(n.type,r))return;mt(n,"_sentryCaptured",!0),r&&!r._sentryId&&mt(r,"_sentryId",Fe());const s=n.type==="keypress"?"input":n.type;Wf(n)||(t({event:n,name:s,global:e}),ei=n.type,ti=r?r._sentryId:void 0),clearTimeout(pa),pa=ke.setTimeout(()=>{ti=void 0,ei=void 0},Hf)}}function Gf(t){try{return t.target}catch{return null}}let Yn;function Uc(t){const e="history";Rt(e,t),Ot(e,Vf)}function Vf(){if(ke.addEventListener("popstate",()=>{const e=ke.location.href,n=Yn;if(Yn=e,n===e)return;je("history",{from:n,to:e})}),!vf())return;function t(e){return function(...n){const r=n.length>2?n[2]:void 0;if(r){const s=Yn,i=Yf(String(r));if(Yn=i,s===i)return e.apply(this,n);je("history",{from:s,to:i})}return e.apply(this,n)}}$e(ke.history,"pushState",t),$e(ke.history,"replaceState",t)}function Yf(t){try{return new URL(t,ke.location.origin).toString()}catch{return t}}const dr={};function Kf(t){const e=dr[t];if(e)return e;let n=ke[t];if(Xs(n))return dr[t]=n.bind(ke);const r=ke.document;if(r&&typeof r.createElement=="function")try{const s=r.createElement("iframe");s.hidden=!0,r.head.appendChild(s);const i=s.contentWindow;i!=null&&i[t]&&(n=i[t]),r.head.removeChild(s)}catch(s){Uf&&L.warn(`Could not create sandbox iframe for ${t} check, bailing to window.${t}: `,s)}return n&&(dr[t]=n.bind(ke))}function Jf(t){dr[t]=void 0}const yn="__sentry_xhr_v3__";function Xf(t){const e="xhr";Rt(e,t),Ot(e,Zf)}function Zf(){if(!ke.XMLHttpRequest)return;const t=XMLHttpRequest.prototype;t.open=new Proxy(t.open,{apply(e,n,r){const s=new Error,i=et()*1e3,o=Qe(r[0])?r[0].toUpperCase():void 0,a=Qf(r[1]);if(!o||!a)return e.apply(n,r);n[yn]={method:o,url:a,request_headers:{}},o==="POST"&&a.match(/sentry_key/)&&(n.__sentry_own_request__=!0);const l=()=>{const c=n[yn];if(c&&n.readyState===4){try{c.status_code=n.status}catch{}const u={endTimestamp:et()*1e3,startTimestamp:i,xhr:n,virtualError:s};je("xhr",u)}};return"onreadystatechange"in n&&typeof n.onreadystatechange=="function"?n.onreadystatechange=new Proxy(n.onreadystatechange,{apply(c,u,d){return l(),c.apply(u,d)}}):n.addEventListener("readystatechange",l),n.setRequestHeader=new Proxy(n.setRequestHeader,{apply(c,u,d){const[p,f]=d,g=u[yn];return g&&Qe(p)&&Qe(f)&&(g.request_headers[p.toLowerCase()]=f),c.apply(u,d)}}),e.apply(n,r)}}),t.send=new Proxy(t.send,{apply(e,n,r){const s=n[yn];if(!s)return e.apply(n,r);r[0]!==void 0&&(s.body=r[0]);const i={startTimestamp:et()*1e3,xhr:n};return je("xhr",i),e.apply(n,r)}})}function Qf(t){if(Qe(t))return t;try{return t.toString()}catch{}}const e_=40;function t_(t,e=Kf("fetch")){let n=0,r=0;async function s(i){const o=i.body.length;n+=o,r++;const a={body:i.body,method:"POST",referrerPolicy:"strict-origin",headers:t.headers,keepalive:n<=6e4&&r<15,...t.fetchOptions};try{const l=await e(t.url,a);return{statusCode:l.status,headers:{"x-sentry-rate-limits":l.headers.get("X-Sentry-Rate-Limits"),"retry-after":l.headers.get("Retry-After")}}}catch(l){throw Jf("fetch"),l}finally{n-=o,r--}}return Ip(t,s,Yi(t.bufferSize||e_))}const Qr=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,n_=30,r_=50;function ni(t,e,n,r){const s={filename:t,function:e==="<anonymous>"?Pt:e,in_app:!0};return n!==void 0&&(s.lineno=n),r!==void 0&&(s.colno=r),s}const s_=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,i_=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,o_=/\((\S*)(?::(\d+))(?::(\d+))\)/,a_=/at (.+?) ?\(data:(.+?),/,l_=t=>{var s;const e=t.match(a_);if(e)return{filename:`<data:${e[2]}>`,function:e[1]};const n=s_.exec(t);if(n){const[,i,o,a]=n;return ni(i,Pt,+o,+a)}const r=i_.exec(t);if(r){if(((s=r[2])==null?void 0:s.indexOf("eval"))===0){const l=o_.exec(r[2]);l&&(r[2]=l[1],r[3]=l[2],r[4]=l[3])}const[o,a]=Hc(r[1]||Pt,r[2]);return ni(a,o,r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},c_=[n_,l_],u_=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,d_=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,h_=t=>{const e=u_.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const i=d_.exec(e[3]);i&&(e[1]=e[1]||"eval",e[3]=i[1],e[4]=i[2],e[5]="")}let r=e[3],s=e[1]||Pt;return[s,r]=Hc(s,r),ni(r,s,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},p_=[r_,h_],f_=[c_,p_],__=Jl(...f_),Hc=(t,e)=>{const n=t.indexOf("safari-extension")!==-1,r=t.indexOf("safari-web-extension")!==-1;return n||r?[t.indexOf("@")!==-1?t.split("@")[0]:Pt,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]},Kn=1024,g_="Breadcrumbs",v_=(t={})=>{const e={console:!0,dom:!0,fetch:!0,history:!0,sentry:!0,xhr:!0,...t};return{name:g_,setup(n){e.console&&sf(E_(n)),e.dom&&Bf(b_(n,e.dom)),e.xhr&&Xf(w_(n)),e.fetch&&bf(S_(n)),e.history&&Uc(k_(n)),e.sentry&&n.on("beforeSendEvent",y_(n))}}},m_=v_;function y_(t){return function(n){Ee()===t&&Ct({category:`sentry.${n.type==="transaction"?"transaction":"event"}`,event_id:n.event_id,level:n.level,message:kt(n)},{event:n})}}function b_(t,e){return function(r){if(Ee()!==t)return;let s,i,o=typeof e=="object"?e.serializeAttribute:void 0,a=typeof e=="object"&&typeof e.maxStringLength=="number"?e.maxStringLength:void 0;a&&a>Kn&&(Qr&&L.warn(`\`dom.maxStringLength\` cannot exceed ${Kn}, but a value of ${a} was configured. Sentry will use ${Kn} instead.`),a=Kn),typeof o=="string"&&(o=[o]);try{const c=r.event,u=x_(c)?c.target:c;s=nc(u,{keyAttrs:o,maxStringLength:a}),i=Pd(u)}catch{s="<unknown>"}if(s.length===0)return;const l={category:`ui.${r.name}`,message:s};i&&(l.data={"ui.component_name":i}),Ct(l,{event:r.event,name:r.name,global:r.global})}}function E_(t){return function(n){if(Ee()!==t)return;const r={category:"console",data:{arguments:n.args,logger:"console"},level:af(n.level),message:To(n.args," ")};if(n.level==="assert")if(n.args[0]===!1)r.message=`Assertion failed: ${To(n.args.slice(1)," ")||"console.assert"}`,r.data.arguments=n.args.slice(1);else return;Ct(r,{input:n.args,level:n.level})}}function w_(t){return function(n){if(Ee()!==t)return;const{startTimestamp:r,endTimestamp:s}=n,i=n.xhr[yn];if(!r||!s||!i)return;const{method:o,url:a,status_code:l,body:c}=i,u={method:o,url:a,status_code:l},d={xhr:n.xhr,input:c,startTimestamp:r,endTimestamp:s},p={category:"xhr",data:u,type:"http",level:Dc(l)};t.emit("beforeOutgoingRequestBreadcrumb",p,d),Ct(p,d)}}function S_(t){return function(n){if(Ee()!==t)return;const{startTimestamp:r,endTimestamp:s}=n;if(s&&!(n.fetchData.url.match(/sentry_key/)&&n.fetchData.method==="POST"))if(n.fetchData.method,n.fetchData.url,n.error){const i=n.fetchData,o={data:n.error,input:n.args,startTimestamp:r,endTimestamp:s},a={category:"fetch",data:i,level:"error",type:"http"};t.emit("beforeOutgoingRequestBreadcrumb",a,o),Ct(a,o)}else{const i=n.response,o={...n.fetchData,status_code:i==null?void 0:i.status};n.fetchData.request_body_size,n.fetchData.response_body_size,i==null||i.status;const a={input:n.args,response:i,startTimestamp:r,endTimestamp:s},l={category:"fetch",data:o,type:"http",level:Dc(o.status_code)};t.emit("beforeOutgoingRequestBreadcrumb",l,a),Ct(l,a)}}}function k_(t){return function(n){if(Ee()!==t)return;let r=n.from,s=n.to;const i=ps(ae.location.href);let o=r?ps(r):void 0;const a=ps(s);o!=null&&o.path||(o=i),i.protocol===a.protocol&&i.host===a.host&&(s=a.relative),i.protocol===o.protocol&&i.host===o.host&&(r=o.relative),Ct({category:"navigation",data:{from:r,to:s}})}}function x_(t){return!!t&&!!t.target}const I_=["EventTarget","Window","Node","ApplicationCache","AudioTrackList","BroadcastChannel","ChannelMergerNode","CryptoOperation","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","KeyOperation","MediaController","MessagePort","ModalWindow","Notification","SVGElementInstance","Screen","SharedWorker","TextTrack","TextTrackCue","TextTrackList","WebSocket","WebSocketWorker","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"],T_="BrowserApiErrors",P_=(t={})=>{const e={XMLHttpRequest:!0,eventTarget:!0,requestAnimationFrame:!0,setInterval:!0,setTimeout:!0,unregisterOriginalCallbacks:!1,...t};return{name:T_,setupOnce(){e.setTimeout&&$e(ae,"setTimeout",_a),e.setInterval&&$e(ae,"setInterval",_a),e.requestAnimationFrame&&$e(ae,"requestAnimationFrame",$_),e.XMLHttpRequest&&"XMLHttpRequest"in ae&&$e(XMLHttpRequest.prototype,"send",R_);const n=e.eventTarget;n&&(Array.isArray(n)?n:I_).forEach(s=>O_(s,e))}}},C_=P_;function _a(t){return function(...e){const n=e[0];return e[0]=Xt(n,{mechanism:{handled:!1,type:`auto.browser.browserapierrors.${gt(t)}`}}),t.apply(this,e)}}function $_(t){return function(e){return t.apply(this,[Xt(e,{mechanism:{data:{handler:gt(t)},handled:!1,type:"auto.browser.browserapierrors.requestAnimationFrame"}})])}}function R_(t){return function(...e){const n=this;return["onload","onerror","onprogress","onreadystatechange"].forEach(s=>{s in n&&typeof n[s]=="function"&&$e(n,s,function(i){const o={mechanism:{data:{handler:gt(i)},handled:!1,type:`auto.browser.browserapierrors.xhr.${s}`}},a=Bi(i);return a&&(o.mechanism.data.handler=gt(a)),Xt(i,o)})}),t.apply(this,e)}}function O_(t,e){var s,i;const r=(s=ae[t])==null?void 0:s.prototype;(i=r==null?void 0:r.hasOwnProperty)!=null&&i.call(r,"addEventListener")&&($e(r,"addEventListener",function(o){return function(a,l,c){try{A_(l)&&(l.handleEvent=Xt(l.handleEvent,{mechanism:{data:{handler:gt(l),target:t},handled:!1,type:"auto.browser.browserapierrors.handleEvent"}}))}catch{}return e.unregisterOriginalCallbacks&&F_(this,a,l),o.apply(this,[a,Xt(l,{mechanism:{data:{handler:gt(l),target:t},handled:!1,type:"auto.browser.browserapierrors.addEventListener"}}),c])}}),$e(r,"removeEventListener",function(o){return function(a,l,c){try{const u=l.__sentry_wrapped__;u&&o.call(this,a,u,c)}catch{}return o.call(this,a,l,c)}}))}function A_(t){return typeof t.handleEvent=="function"}function F_(t,e,n){t&&typeof t=="object"&&"removeEventListener"in t&&typeof t.removeEventListener=="function"&&t.removeEventListener(e,n)}const N_=(t={})=>{const e=t.lifecycle??"route";return{name:"BrowserSession",setupOnce(){if(typeof ae.document>"u"){Qr&&L.warn("Using the `browserSessionIntegration` in non-browser environments is not supported.");return}Ko({ignoreDuration:!0}),ds();const n=At();let r=n.getUser();n.addScopeListener(s=>{const i=s.getUser();((r==null?void 0:r.id)!==(i==null?void 0:i.id)||(r==null?void 0:r.ip_address)!==(i==null?void 0:i.ip_address))&&(ds(),r=i)}),e==="route"&&Uc(({from:s,to:i})=>{s!==i&&(Ko({ignoreDuration:!0}),ds())})}}},M_="CultureContext",D_=()=>({name:M_,preprocessEvent(t){var n;const e=j_();e&&(t.contexts={...t.contexts,culture:{...e,...(n=t.contexts)==null?void 0:n.culture}})}}),L_=D_;function j_(){try{const t=ae.Intl;if(!t)return;const e=t.DateTimeFormat().resolvedOptions();return{locale:e.locale,timezone:e.timeZone,calendar:e.calendar}}catch{return}}const U_="GlobalHandlers",H_=(t={})=>{const e={onerror:!0,onunhandledrejection:!0,...t};return{name:U_,setupOnce(){Error.stackTraceLimit=50},setup(n){e.onerror&&(z_(n),ga("onerror")),e.onunhandledrejection&&(W_(n),ga("onunhandledrejection"))}}},B_=H_;function z_(t){md(e=>{const{stackParser:n,attachStacktrace:r}=Bc();if(Ee()!==t||Lc())return;const{msg:s,url:i,line:o,column:a,error:l}=e,c=V_(Xi(n,l||s,void 0,r,!1),i,o,a);c.level="error",bc(c,{originalException:l,mechanism:{handled:!1,type:"auto.browser.global_handlers.onerror"}})})}function W_(t){bd(e=>{const{stackParser:n,attachStacktrace:r}=Bc();if(Ee()!==t||Lc())return;const s=q_(e),i=Yr(s)?G_(s):Xi(n,s,void 0,r,!0);i.level="error",bc(i,{originalException:s,mechanism:{handled:!1,type:"auto.browser.global_handlers.onunhandledrejection"}})})}function q_(t){if(Yr(t))return t;try{if("reason"in t)return t.reason;if("detail"in t&&"reason"in t.detail)return t.detail.reason}catch{}return t}function G_(t){return{exception:{values:[{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(t)}`}]}}}function V_(t,e,n,r){const s=t.exception=t.exception||{},i=s.values=s.values||[],o=i[0]=i[0]||{},a=o.stacktrace=o.stacktrace||{},l=a.frames=a.frames||[],c=r,u=n,d=Y_(e)??Hi();return l.length===0&&l.push({colno:c,filename:d,function:Pt,in_app:!0,lineno:u}),t}function ga(t){Qr&&L.log(`Global Handler attached: ${t}`)}function Bc(){const t=Ee();return(t==null?void 0:t.getOptions())||{stackParser:()=>[],attachStacktrace:!1}}function Y_(t){if(!(!Qe(t)||t.length===0))return t.startsWith("data:")?`<${jp(t,!1)}>`:t}const K_=()=>({name:"HttpContext",preprocessEvent(t){var r;if(!ae.navigator&&!ae.location&&!ae.document)return;const e=If(),n={...e.headers,...(r=t.request)==null?void 0:r.headers};t.request={...e,...t.request,headers:n}}}),J_="cause",X_=5,Z_="LinkedErrors",Q_=(t={})=>{const e=t.limit||X_,n=t.key||J_;return{name:Z_,preprocessEvent(r,s,i){const o=i.getOptions();rf(Ki,o.stackParser,n,e,r,s)}}},eg=Q_;function tg(){return ng()?(Qr&&on(()=>{console.error("[Sentry] You cannot use Sentry.init() in a browser extension, see: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/")}),!0):!1}function ng(){var i;if(typeof ae.window>"u")return!1;const t=ae;if(t.nw)return!1;const e=t.chrome||t.browser;if(!((i=e==null?void 0:e.runtime)!=null&&i.id))return!1;const n=Hi(),r=["chrome-extension","moz-extension","ms-browser-extension","safari-web-extension"];return!(ae===ae.top&&r.some(o=>n.startsWith(`${o}://`)))}function rg(t){return[Kp(),qp(),gf(),C_(),m_(),B_(),eg(),uf(),K_(),L_(),N_()]}function sg(t={}){const e=!t.skipBrowserExtensionCheck&&tg();let n=t.defaultIntegrations==null?rg():t.defaultIntegrations;const r={...t,enabled:e?!1:t.enabled,stackParser:gd(t.stackParser||__),integrations:pp({integrations:t.integrations,defaultIntegrations:n}),transport:t.transport||t_};return Dp(Lf,r)}var v=typeof window<"u"?window:void 0,ge=typeof globalThis<"u"?globalThis:v;typeof self>"u"&&(ge.self=ge),typeof File>"u"&&(ge.File=function(){});var Re=ge==null?void 0:ge.navigator,$=ge==null?void 0:ge.document,ve=ge==null?void 0:ge.location,ri=ge==null?void 0:ge.fetch,si=ge!=null&&ge.XMLHttpRequest&&"withCredentials"in new ge.XMLHttpRequest?ge.XMLHttpRequest:void 0,va=ge==null?void 0:ge.AbortController,ig=ge==null?void 0:ge.CompressionStream,Ie=Re==null?void 0:Re.userAgent,M=v??{},ma="1.364.1",Ce={DEBUG:!1,LIB_VERSION:ma,LIB_NAME:"web",JS_SDK_VERSION:ma};function ya(t,e,n,r,s,i,o){try{var a=t[i](o),l=a.value}catch(c){return void n(c)}a.done?e(l):Promise.resolve(l).then(r,s)}function De(t){return function(){var e=this,n=arguments;return new Promise(function(r,s){var i=t.apply(e,n);function o(l){ya(i,r,s,o,a,"next",l)}function a(l){ya(i,r,s,o,a,"throw",l)}o(void 0)})}}function T(){return T=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},T.apply(null,arguments)}function zc(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function Wc(){return(Wc=De(function*(t,e){e===void 0&&(e=!0);try{var n=new Blob([t],{type:"text/plain"}).stream().pipeThrough(new CompressionStream("gzip"));return yield new Response(n).blob()}catch(r){return e&&console.error("Failed to gzip compress data",r),null}})).apply(this,arguments)}var og=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"],ag=["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"],ba=function(t,e){if(e===void 0&&(e=[]),!t)return!1;var n=t.toLowerCase();return ag.concat(e).some(r=>{var s=r.toLowerCase();return n.indexOf(s)!==-1})};function q(t,e){return t.indexOf(e)!==-1}var es=function(t){return t.trim()},ii=function(t){return t.replace(/^\$/,"")},qc=Object.prototype,Gc=qc.hasOwnProperty,ts=qc.toString,Y=Array.isArray||function(t){return ts.call(t)==="[object Array]"},Ke=t=>typeof t=="function",_e=t=>t===Object(t)&&!Y(t),Bt=t=>{if(_e(t)){for(var e in t)if(Gc.call(t,e))return!1;return!0}return!1},O=t=>t===void 0,fe=t=>ts.call(t)=="[object String]",hr=t=>fe(t)&&t.trim().length===0,rt=t=>t===null,G=t=>O(t)||rt(t),We=t=>ts.call(t)=="[object Number]"&&t==t,jt=t=>We(t)&&t>0,Xe=t=>ts.call(t)==="[object Boolean]",lg=t=>t instanceof FormData,cg=t=>q(og,t);function Vc(t){return t===null||typeof t!="object"}function wr(t,e){return{}.toString.call(t)==="[object "+e+"]"}function Zi(t){return!O(Event)&&function(e,n){try{return e instanceof n}catch{return!1}}(t,Event)}var ug=[!0,"true",1,"1","yes"],_s=t=>q(ug,t),dg=[!1,"false",0,"0","no"];function ze(t,e,n,r,s){return e>n&&(r.warn("min cannot be greater than max."),e=n),We(t)?t>n?(r.warn(" cannot be greater than max: "+n+". Using max value instead."),n):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: "+n+", fallback: "+s),ze(s||n,e,n,r))}class hg{constructor(e){this.t={},this.i=e.i,this.o=ze(e.bucketSize,0,100,e.h),this.m=ze(e.refillRate,0,this.o,e.h),this.S=ze(e.refillInterval,0,864e5,e.h)}T(e,n){var r=Math.floor((n-e.lastAccess)/this.S);r>0&&(e.tokens=Math.min(e.tokens+r*this.m,this.o),e.lastAccess=e.lastAccess+r*this.S)}consumeRateLimit(e){var n,r=Date.now(),s=String(e),i=this.t[s];return i?this.T(i,r):this.t[s]=i={tokens:this.o,lastAccess:r},i.tokens===0||(i.tokens--,i.tokens===0&&((n=this.i)==null||n.call(this,e)),i.tokens===0)}stop(){this.t={}}}var Jn,Ea,gs,Oe="Mobile",Sr="iOS",Ze="Android",Zt="Tablet",Yc=Ze+" "+Zt,Kc="iPad",Jc="Apple",Xc=Jc+" Watch",In="Safari",Qt="BlackBerry",Zc="Samsung",Qc=Zc+"Browser",eu=Zc+" Internet",It="Chrome",pg=It+" OS",tu=It+" "+Sr,Qi="Internet Explorer",nu=Qi+" "+Oe,eo="Opera",fg=eo+" Mini",to="Edge",ru="Microsoft "+to,qt="Firefox",su=qt+" "+Sr,Fn="Nintendo",Nn="PlayStation",Gt="Xbox",iu=Ze+" "+Oe,ou=Oe+" "+In,bn="Windows",oi=bn+" Phone",wa="Nokia",ai="Ouya",au="Generic",_g=au+" "+Oe.toLowerCase(),lu=au+" "+Zt.toLowerCase(),li="Konqueror",Se="(\\d+(\\.\\d+)?)",vs=new RegExp("Version/"+Se),gg=new RegExp(Gt,"i"),vg=new RegExp(Nn+" \\w+","i"),mg=new RegExp(Fn+" \\w+","i"),no=new RegExp(Qt+"|PlayBook|BB10","i"),yg={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},cu=function(t,e){return e=e||"",q(t," OPR/")&&q(t,"Mini")?fg:q(t," OPR/")?eo:no.test(t)?Qt:q(t,"IE"+Oe)||q(t,"WPDesktop")?nu:q(t,Qc)?eu:q(t,to)||q(t,"Edg/")?ru:q(t,"FBIOS")?"Facebook "+Oe:q(t,"UCWEB")||q(t,"UCBrowser")?"UC Browser":q(t,"CriOS")?tu:q(t,"CrMo")||q(t,It)?It:q(t,Ze)&&q(t,In)?iu:q(t,"FxiOS")?su:q(t.toLowerCase(),li.toLowerCase())?li:((n,r)=>r&&q(r,Jc)||function(s){return q(s,In)&&!q(s,It)&&!q(s,Ze)}(n))(t,e)?q(t,Oe)?ou:In:q(t,qt)?qt:q(t,"MSIE")||q(t,"Trident/")?Qi:q(t,"Gecko")?qt:""},bg={[nu]:[new RegExp("rv:"+Se)],[ru]:[new RegExp(to+"?\\/"+Se)],[It]:[new RegExp("("+It+"|CrMo)\\/"+Se)],[tu]:[new RegExp("CriOS\\/"+Se)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Se)],[In]:[vs],[ou]:[vs],[eo]:[new RegExp("(Opera|OPR)\\/"+Se)],[qt]:[new RegExp(qt+"\\/"+Se)],[su]:[new RegExp("FxiOS\\/"+Se)],[li]:[new RegExp("Konqueror[:/]?"+Se,"i")],[Qt]:[new RegExp(Qt+" "+Se),vs],[iu]:[new RegExp("android\\s"+Se,"i")],[eu]:[new RegExp(Qc+"\\/"+Se)],[Qi]:[new RegExp("(rv:|MSIE )"+Se)],Mozilla:[new RegExp("rv:"+Se)]},Eg=function(t,e){var n=cu(t,e),r=bg[n];if(O(r))return null;for(var s=0;r.length>s;s++){var i=t.match(r[s]);if(i)return parseFloat(i[i.length-2])}return null},Sa=[[new RegExp(Gt+"; "+Gt+" (.*?)[);]","i"),t=>[Gt,t&&t[1]||""]],[new RegExp(Fn,"i"),[Fn,""]],[new RegExp(Nn,"i"),[Nn,""]],[no,[Qt,""]],[new RegExp(bn,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[oi,""];if(new RegExp(Oe).test(e)&&!/IEMobile\b/.test(e))return[bn+" "+Oe,""];var n=/Windows NT ([0-9.]+)/i.exec(e);if(n&&n[1]){var r=yg[n[1]]||"";return/arm/i.test(e)&&(r="RT"),[bn,r]}return[bn,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?[Sr,[t[3],t[4],t[5]||"0"].join(".")]:[Sr,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=O(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("("+Ze+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Ze+")","i"),t=>t&&t[2]?[Ze,[t[2],t[3],t[4]||"0"].join(".")]:[Ze,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];return t&&t[1]&&(e[1]=[t[1],t[2],t[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[pg,""]],[/Linux|debian/i,["Linux",""]]],ka=function(t){return mg.test(t)?Fn:vg.test(t)?Nn:gg.test(t)?Gt:new RegExp(ai,"i").test(t)?ai:new RegExp("("+oi+"|WPDesktop)","i").test(t)?oi:/iPad/.test(t)?Kc:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?Xc:no.test(t)?Qt:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(wa,"i").test(t)?wa:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(Oe).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?Ze:Yc:new RegExp("(pda|"+Oe+")","i").test(t)?_g:new RegExp(Zt,"i").test(t)&&!new RegExp(Zt+" pc","i").test(t)?lu:""},wg=t=>t instanceof Error;function Sg(t){var e=globalThis._posthogChunkIds;if(e){var n=Object.keys(e);return gs&&n.length===Ea||(Ea=n.length,gs=n.reduce((r,s)=>{Jn||(Jn={});var i=Jn[s];if(i)r[i[0]]=i[1];else for(var o=t(s),a=o.length-1;a>=0;a--){var l=o[a],c=l==null?void 0:l.filename,u=e[s];if(c&&u){r[c]=u,Jn[s]=[c,u];break}}return r},{})),gs}}class kg{constructor(e,n,r){r===void 0&&(r=[]),this.coercers=e,this.stackParser=n,this.modifiers=r}buildFromUnknown(e,n){n===void 0&&(n={});var r=n&&n.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(r,n,0).apply(e),i=this.buildParsingContext(n),o=this.parseStacktrace(s,i);return{$exception_list:this.convertToExceptionList(o,r),$exception_level:"error"}}modifyFrames(e){var n=this;return De(function*(){for(var r of e)r.stacktrace&&r.stacktrace.frames&&Y(r.stacktrace.frames)&&(r.stacktrace.frames=yield n.applyModifiers(r.stacktrace.frames));return e})()}coerceFallback(e){var n;return{type:"Error",value:"Unknown error",stack:(n=e.syntheticException)==null?void 0:n.stack,synthetic:!0}}parseStacktrace(e,n){var r,s;return e.cause!=null&&(r=this.parseStacktrace(e.cause,n)),e.stack!=""&&e.stack!=null&&(s=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?n.skipFirstLines:0),n.chunkIdMap)),T({},e,{cause:r,stack:s})}applyChunkIds(e,n){return e.map(r=>(r.filename&&n&&(r.chunk_id=n[r.filename]),r))}applyCoercers(e,n){for(var r of this.coercers)if(r.match(e))return r.coerce(e,n);return this.coerceFallback(n)}applyModifiers(e){var n=this;return De(function*(){var r=e;for(var s of n.modifiers)r=yield s(r);return r})()}convertToExceptionList(e,n){var r,s,i,o={type:e.type,value:e.value,mechanism:{type:(r=n.type)!==null&&r!==void 0?r:"generic",handled:(s=n.handled)===null||s===void 0||s,synthetic:(i=e.synthetic)!==null&&i!==void 0&&i}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,T({},n,{handled:!0}))),a}buildParsingContext(e){var n;return{chunkIdMap:Sg(this.stackParser),skipFirstLines:(n=e.skipFirstLines)!==null&&n!==void 0?n:1}}buildCoercingContext(e,n,r){r===void 0&&(r=0);var s=(i,o)=>{if(4>=o){var a=this.buildCoercingContext(e,n,o);return this.applyCoercers(i,a)}};return T({},n,{syntheticException:r==0?n.syntheticException:void 0,mechanism:e,apply:i=>s(i,r),next:i=>s(i,r+1)})}}var en="?";function ci(t,e,n,r,s){var i={platform:t,filename:e,function:n==="<anonymous>"?en:n,in_app:!0};return O(r)||(i.lineno=r),O(s)||(i.colno=s),i}var uu=(t,e)=>{var n=t.indexOf("safari-extension")!==-1,r=t.indexOf("safari-web-extension")!==-1;return n||r?[t.indexOf("@")!==-1?t.split("@")[0]:en,n?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},xg=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Ig=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Tg=/\((\S*)(?::(\d+))(?::(\d+))\)/,Pg=(t,e)=>{var n=xg.exec(t);if(n){var[,r,s,i]=n;return ci(e,r,en,+s,+i)}var o=Ig.exec(t);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=Tg.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=uu(o[1]||en,o[2]);return ci(e,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},Cg=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,$g=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Rg=(t,e)=>{var n=Cg.exec(t);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){var r=$g.exec(n[3]);r&&(n[1]=n[1]||"eval",n[3]=r[1],n[4]=r[2],n[5]="")}var s=n[3],i=n[1]||en;return[i,s]=uu(i,s),ci(e,s,i,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},xa=/\(error: (.*)\)/;class Og{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,n){var r=fe(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:r?e.stack:void 0,cause:e.cause?n.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var n=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?n+": "+e.message:n}isDOMException(e){return wr(e,"DOMException")}isDOMError(e){return wr(e,"DOMError")}}class Ag{match(e){return(n=>n instanceof Error)(e)}coerce(e,n){return{type:this.getType(e),value:this.getMessage(e,n),stack:this.getStack(e),cause:e.cause?n.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,n){var r=e.message;return String(r.error&&typeof r.error.message=="string"?r.error.message:r)}getStack(e){return e.stacktrace||e.stack||void 0}}class Fg{constructor(){}match(e){return wr(e,"ErrorEvent")&&e.error!=null}coerce(e,n){var r;return n.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}}var Ng=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class Mg{match(e){return typeof e=="string"}coerce(e,n){var r,[s,i]=this.getInfos(e);return{type:s??"Error",value:i??e,stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}getInfos(e){var n="Error",r=e,s=e.match(Ng);return s&&(n=s[1],r=s[2]),[n,r]}}var Dg=["fatal","error","warning","log","info","debug"];function du(t,e){e===void 0&&(e=40);var n=Object.keys(t);if(n.sort(),!n.length)return"[object has no keys]";for(var r=n.length;r>0;r--){var s=n.slice(0,r).join(", ");if(e>=s.length)return r===n.length?s:s.length>e?s.slice(0,e)+"...":s}return""}class Lg{match(e){return typeof e=="object"&&e!==null}coerce(e,n){var r,s=this.getErrorPropertyFromObject(e);return s?n.apply(s):{type:this.getType(e),value:this.getValue(e),stack:(r=n.syntheticException)==null?void 0:r.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return Zi(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var n="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(n+=" with message: '"+e.message+"'"),n}if("message"in e&&typeof e.message=="string")return e.message;var r=this.getObjectClassName(e);return(r&&r!=="Object"?"'"+r+"'":"Object")+" captured as exception with keys: "+du(e)}isSeverityLevel(e){return fe(e)&&!hr(e)&&Dg.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var n in e)if({}.hasOwnProperty.call(e,n)){var r=e[n];if(wg(r))return r}}getObjectClassName(e){try{var n=Object.getPrototypeOf(e);return n?n.constructor.name:void 0}catch{return}}}class jg{match(e){return Zi(e)}coerce(e,n){var r,s=e.constructor.name;return{type:s,value:s+" captured as exception with keys: "+du(e),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}}class Ug{match(e){return Vc(e)}coerce(e,n){var r;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}}class Hg{match(e){return wr(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Zi(e))return!1;try{var n=e.detail;return n!=null&&typeof n=="object"&&"reason"in n}catch{return!1}}coerce(e,n){var r,s=this.getUnhandledRejectionReason(e);return Vc(s)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(s),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}:n.apply(s)}getUnhandledRejectionReason(e){try{if("reason"in e)return e.reason;if("detail"in e&&e.detail!=null&&typeof e.detail=="object"&&"reason"in e.detail)return e.detail.reason}catch{}return e}}var hu=function(t,e){var{debugEnabled:n}=e===void 0?{}:e,r={$(s){if(v&&(Ce.DEBUG||M.POSTHOG_DEBUG||n)&&!O(v.console)&&v.console){for(var i=("__rrweb_original__"in v.console[s])?v.console[s].__rrweb_original__:v.console[s],o=arguments.length,a=new Array(o>1?o-1:0),l=1;o>l;l++)a[l-1]=arguments[l];i(t,...a)}},info(){for(var s=arguments.length,i=new Array(s),o=0;s>o;o++)i[o]=arguments[o];r.$("log",...i)},warn(){for(var s=arguments.length,i=new Array(s),o=0;s>o;o++)i[o]=arguments[o];r.$("warn",...i)},error(){for(var s=arguments.length,i=new Array(s),o=0;s>o;o++)i[o]=arguments[o];r.$("error",...i)},critical(){for(var s=arguments.length,i=new Array(s),o=0;s>o;o++)i[o]=arguments[o];console.error(t,...i)},uninitializedWarning(s){r.error("You must initialize PostHog before calling "+s)},createLogger:(s,i)=>hu(t+" "+s,i)};return r},R=hu("[PostHog.js]"),oe=R.createLogger,Bg=oe("[ExternalScriptsLoader]"),Ia=(t,e,n)=>{if(t.config.disable_external_dependency_loading)return Bg.warn(e+" was requested but loading of external scripts is disabled."),n("Loading of external scripts is disabled");var r=$==null?void 0:$.querySelectorAll("script");if(r){for(var s,i=function(){if(r[o].src===e){var l=r[o];return l.__posthog_loading_callback_fired?{v:n()}:(l.addEventListener("load",c=>{l.__posthog_loading_callback_fired=!0,n(void 0,c)}),l.onerror=c=>n(c),{v:void 0})}},o=0;r.length>o;o++)if(s=i())return s.v}var a=()=>{if(!$)return n("document not found");var l=$.createElement("script");if(l.type="text/javascript",l.crossOrigin="anonymous",l.src=e,l.onload=d=>{l.__posthog_loading_callback_fired=!0,n(void 0,d)},l.onerror=d=>n(d),t.config.prepare_external_dependency_script&&(l=t.config.prepare_external_dependency_script(l)),!l)return n("prepare_external_dependency_script returned null");if(t.config.external_scripts_inject_target==="head")$.head.appendChild(l);else{var c,u=$.querySelectorAll("body > script");u.length>0?(c=u[0].parentNode)==null||c.insertBefore(l,u[0]):$.body.appendChild(l)}};$!=null&&$.body?a():$==null||$.addEventListener("DOMContentLoaded",a)};M.__PosthogExtensions__=M.__PosthogExtensions__||{},M.__PosthogExtensions__.loadExternalDependency=(t,e,n)=>{var r="/static/"+e+".js?v="+t.version;if(e==="remote-config"&&(r="/array/"+t.config.token+"/config.js"),e==="toolbar"){var s=3e5;r=r+"&t="+Math.floor(Date.now()/s)*s}var i=t.requestRouter.endpointFor("assets",r);Ia(t,i,n)},M.__PosthogExtensions__.loadSiteApp=(t,e,n)=>{var r=t.requestRouter.endpointFor("api",e);Ia(t,r,n)};var pu="$people_distinct_id",kr="$device_id",En="__alias",wn="__timers",Ta="$autocapture_disabled_server_side",ui="$heatmaps_enabled_server_side",Pa="$exception_capture_enabled_server_side",di="$error_tracking_suppression_rules",Ca="$error_tracking_capture_extension_exceptions",$a="$web_vitals_enabled_server_side",fu="$dead_clicks_enabled_server_side",Ra="$product_tours_enabled_server_side",Oa="$web_vitals_allowed_metrics",Xn="$session_recording_remote_config",xr="$sesid",_u="$session_is_sampled",zt="$enabled_feature_flags",Sn="$early_access_features",hi="$feature_flag_details",kn="$stored_person_properties",St="$stored_group_properties",pi="$surveys",Tn="$flag_call_reported",fi="$flag_call_reported_session_id",_i="$feature_flag_errors",Ir="$feature_flag_evaluated_at",Me="$user_state",gi="$client_session_props",vi="$capture_rate_limit",mi="$initial_campaign_params",yi="$initial_referrer_info",Tr="$initial_person_info",Pr="$epp",gu="__POSTHOG_TOOLBAR__",Zn="$posthog_cookieless",zg=[pu,En,"__cmpns",wn,"$session_recording_enabled_server_side",ui,xr,zt,di,Me,Sn,hi,St,kn,pi,Tn,fi,_i,Ir,gi,vi,mi,yi,Pr,Tr],ro="PostHog loadExternalDependency extension not found.",Ve="on_reject",Le="always",Nt="anonymous",Mt="identified",bi="identified_only",Cr="visibilitychange",$r="beforeunload",Ut="$pageview",ms="$pageleave",ys="$identify",Aa="$groupidentify";function Qn(t,e){Y(t)&&t.forEach(e)}function te(t,e){if(!G(t))if(Y(t))t.forEach(e);else if(lg(t))t.forEach((r,s)=>e(r,s));else for(var n in t)Gc.call(t,n)&&e(t[n],n)}var ce=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;e>r;r++)n[r-1]=arguments[r];for(var s of n)for(var i in s)s[i]!==void 0&&(t[i]=s[i]);return t};function pr(t){for(var e=Object.keys(t),n=e.length,r=new Array(n);n--;)r[n]=[e[n],t[e[n]]];return r}var Fa=function(t){try{return t()}catch{return}},Wg=function(t){return function(){try{for(var e=arguments.length,n=new Array(e),r=0;e>r;r++)n[r]=arguments[r];return t.apply(this,n)}catch(s){R.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),R.critical(s)}}},so=function(t){var e={};return te(t,function(n,r){(fe(n)&&n.length>0||We(n))&&(e[r]=n)}),e},qg=["herokuapp.com","vercel.app","netlify.app"];function Gg(t){var e=t==null?void 0:t.hostname;if(!fe(e))return!1;var n=e.split(".").slice(-2).join(".");for(var r of qg)if(n===r)return!1;return!0}function he(t,e,n,r){var{capture:s=!1,passive:i=!0}=r??{};t==null||t.addEventListener(e,n,{capture:s,passive:i})}function vu(t){return t.name==="ph_toolbar_internal"}Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return We(t)&&isFinite(t)&&Math.floor(t)===t});class Rr{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,n,r,s){if(!Number.isInteger(e)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(s)||0>e||0>n||0>r||0>s||e>0xffffffffffff||n>4095||r>1073741823||s>4294967295)throw new RangeError("invalid field value");var i=new Uint8Array(16);return i[0]=e/Math.pow(2,40),i[1]=e/Math.pow(2,32),i[2]=e/Math.pow(2,24),i[3]=e/Math.pow(2,16),i[4]=e/Math.pow(2,8),i[5]=e,i[6]=112|n>>>8,i[7]=n,i[8]=128|r>>>24,i[9]=r>>>16,i[10]=r>>>8,i[11]=r,i[12]=s>>>24,i[13]=s>>>16,i[14]=s>>>8,i[15]=s,new Rr(i)}toString(){for(var e="",n=0;this.bytes.length>n;n++)e=e+(this.bytes[n]>>>4).toString(16)+(15&this.bytes[n]).toString(16),n!==3&&n!==5&&n!==7&&n!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new Rr(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var n=0;16>n;n++){var r=this.bytes[n]-e.bytes[n];if(r!==0)return Math.sign(r)}return 0}}class Vg{constructor(){this.k=0,this.R=0,this.P=new Yg}generate(){var e=this.generateOrAbort();if(O(e)){this.k=0;var n=this.generateOrAbort();if(O(n))throw new Error("Could not generate UUID after timestamp reset");return n}return e}generateOrAbort(){var e=Date.now();if(e>this.k)this.k=e,this.O();else{if(this.k>=e+1e4)return;this.R++,this.R>4398046511103&&(this.k++,this.O())}return Rr.fromFieldsV7(this.k,Math.trunc(this.R/Math.pow(2,30)),this.R&Math.pow(2,30)-1,this.P.nextUint32())}O(){this.R=1024*this.P.nextUint32()+(1023&this.P.nextUint32())}}var Na,mu=t=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&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};v&&!O(v.crypto)&&crypto.getRandomValues&&(mu=t=>crypto.getRandomValues(t));class Yg{constructor(){this.I=new Uint32Array(8),this.C=1/0}nextUint32(){return this.I.length>this.C||(mu(this.I),this.C=0),this.I[this.C++]}}var ht=()=>Kg().toString(),Kg=()=>(Na||(Na=new Vg)).generate(),un="",Jg=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,He={F:()=>!!$,A(t){R.error("cookieStore error: "+t)},M(t){if($){try{for(var e=t+"=",n=$.cookie.split(";").filter(i=>i.length),r=0;n.length>r;r++){for(var s=n[r];s.charAt(0)==" ";)s=s.substring(1,s.length);if(s.indexOf(e)===0)return decodeURIComponent(s.substring(e.length,s.length))}}catch{}return null}},D(t){var e;try{e=JSON.parse(He.M(t))||{}}catch{}return e},L(t,e,n,r,s){if($)try{var i="",o="",a=function(u,d){if(d){var p=function(g,_){if(_===void 0&&(_=$),un)return un;if(!_||["localhost","127.0.0.1"].includes(g))return"";for(var P=g.split("."),m=Math.min(P.length,8),b="dmn_chk_"+ht();!un&&m--;){var C=P.slice(m).join("."),x=b+"=1;domain=."+C+";path=/";_.cookie=x+";max-age=3",_.cookie.includes(b)&&(_.cookie=x+";max-age=0",un=C)}return un}(u);if(!p){var f=(g=>{var _=g.match(Jg);return _?_[0]:""})(u);f!==p&&R.info("Warning: cookie subdomain discovery mismatch",f,p),p=f}return p?"; domain=."+p:""}return""}($.location.hostname,r);if(n){var l=new Date;l.setTime(l.getTime()+864e5*n),i="; expires="+l.toUTCString()}s&&(o="; secure");var c=t+"="+encodeURIComponent(JSON.stringify(e))+i+"; SameSite=Lax; path=/"+a+o;return c.length>3686.4&&R.warn("cookieStore warning: large cookie, len="+c.length),$.cookie=c,c}catch{return}},U(t,e){if($!=null&&$.cookie)try{He.L(t,"",-1,e)}catch{return}}},bs=null,se={F(){if(!rt(bs))return bs;var t=!0;if(O(v))t=!1;else try{var e="__mplssupport__";se.L(e,"xyz"),se.M(e)!=='"xyz"'&&(t=!1),se.U(e)}catch{t=!1}return t||R.error("localStorage unsupported; falling back to cookie store"),bs=t,t},A(t){R.error("localStorage error: "+t)},M(t){try{return v==null?void 0:v.localStorage.getItem(t)}catch(e){se.A(e)}return null},D(t){try{return JSON.parse(se.M(t))||{}}catch{}return null},L(t,e){try{v==null||v.localStorage.setItem(t,JSON.stringify(e))}catch(n){se.A(n)}},U(t){try{v==null||v.localStorage.removeItem(t)}catch(e){se.A(e)}}},Xg=[kr,"distinct_id",xr,_u,Pr,Tr,Me],er={},Zg={F:()=>!0,A(t){R.error("memoryStorage error: "+t)},M:t=>er[t]||null,D:t=>er[t]||null,L(t,e){er[t]=e},U(t){delete er[t]}},bt=null,me={F(){if(!rt(bt))return bt;if(bt=!0,O(v))bt=!1;else try{var t="__support__";me.L(t,"xyz"),me.M(t)!=='"xyz"'&&(bt=!1),me.U(t)}catch{bt=!1}return bt},A(t){R.error("sessionStorage error: ",t)},M(t){try{return v==null?void 0:v.sessionStorage.getItem(t)}catch(e){me.A(e)}return null},D(t){try{return JSON.parse(me.M(t))||null}catch{}return null},L(t,e){try{v==null||v.sessionStorage.setItem(t,JSON.stringify(e))}catch(n){me.A(n)}},U(t){try{v==null||v.sessionStorage.removeItem(t)}catch(e){me.A(e)}}};class Qg{constructor(e){this._instance=e}get N(){return this._instance.config}get consent(){return this.j()?0:this.B}isOptedOut(){return this.N.cookieless_mode===Le||this.consent===0||this.consent===-1&&(this.N.opt_out_capturing_by_default||this.N.cookieless_mode===Ve)}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}optInOut(e){this.H.L(this.q,e?1:0,this.N.cookie_expiration,this.N.cross_subdomain_cookie,this.N.secure_cookie)}reset(){this.H.U(this.q,this.N.cross_subdomain_cookie)}get q(){var{token:e,opt_out_capturing_cookie_prefix:n,consent_persistence_name:r}=this._instance.config;return r||(n?n+e:"__ph_opt_in_out_"+e)}get B(){var e=this.H.M(this.q);return _s(e)?1:q(dg,e)?0:-1}get H(){if(!this.W){var e=this.N.opt_out_capturing_persistence_type;this.W=e==="localStorage"?se:He;var n=e==="localStorage"?He:se;n.M(this.q)&&(this.W.M(this.q)||this.optInOut(_s(n.M(this.q))),n.U(this.q,this.N.cross_subdomain_cookie))}return this.W}j(){return!!this.N.respect_dnt&&[Re==null?void 0:Re.doNotTrack,Re==null?void 0:Re.msDoNotTrack,M.doNotTrack].some(e=>_s(e))}}var tr=oe("[Dead Clicks]"),ev=()=>!0,tv=t=>{var e,n=!((e=t.instance.persistence)==null||!e.get_property(fu)),r=t.instance.config.capture_dead_clicks;return Xe(r)?r:!!_e(r)||n};class Ma{get lazyLoadedDeadClicksAutocapture(){return this.V}constructor(e,n,r){this.instance=e,this.isEnabled=n,this.onCapture=r,this.startIfEnabledOrStop()}onRemoteConfig(e){"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[fu]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.Y(()=>{this.G()}):this.stop()}Y(e){var n,r;(n=M.__PosthogExtensions__)!=null&&n.initDeadClicksAutocapture&&e(),(r=M.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"dead-clicks-autocapture",s=>{s?tr.error("failed to load script",s):e()})}G(){var e;if($){if(!this.V&&(e=M.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var n=_e(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};n.__onCapture=this.onCapture,this.V=M.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this.V.start($),tr.info("starting...")}}else tr.error("`document` not found. Cannot start.")}stop(){this.V&&(this.V.stop(),this.V=void 0,tr.info("stopping..."))}}var Es=oe("[SegmentIntegration]"),yu="posthog-js";function bu(t,e){var{organization:n,projectId:r,prefix:s,severityAllowList:i=["error"],sendExceptionsToPostHog:o=!0}=e===void 0?{}:e;return a=>{var l,c,u,d,p;if(i!=="*"&&!i.includes(a.level)||!t.__loaded)return a;a.tags||(a.tags={});var f=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());a.tags["PostHog Person URL"]=f,t.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var g,_=((l=a.exception)==null?void 0:l.values)||[],P=_.map(b=>T({},b,{stacktrace:b.stacktrace?T({},b.stacktrace,{type:"raw",frames:(b.stacktrace.frames||[]).map(C=>T({},C,{platform:"web:javascript"}))}):void 0})),m={$exception_message:((c=_[0])==null?void 0:c.value)||a.message,$exception_type:(u=_[0])==null?void 0:u.type,$exception_level:a.level,$exception_list:P,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((d=_[0])==null?void 0:d.value)||a.message,$sentry_exception_type:(p=_[0])==null?void 0:p.type,$sentry_tags:a.tags};return n&&r&&(m.$sentry_url=(s||"https://sentry.io/organizations/")+n+"/issues/?project="+r+"&query="+a.event_id),o&&((g=t.exceptions)==null||g.sendExceptionEvent(m)),a}}class nv{constructor(e,n,r,s,i,o){this.name=yu,this.setupOnce=function(a){a(bu(e,{organization:n,projectId:r,prefix:s,severityAllowList:i,sendExceptionsToPostHog:o==null||o}))}}}class Da{constructor(e){this.J=(n,r,s)=>{s&&(s.noSessionId||s.activityTimeout||s.sessionPastMaximumLength)&&(R.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:n,changeReason:s}),this.K=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.X()}X(){var e;this.Z=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.J)}destroy(){var e;(e=this.Z)==null||e.call(this),this.Z=void 0}doPageView(e,n){var r,s=this.tt(e,n);return this.K={pathname:(r=v==null?void 0:v.location.pathname)!==null&&r!==void 0?r:"",pageViewId:n,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var n;return this.tt(e,(n=this.K)==null?void 0:n.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.K)==null?void 0:e.pageViewId}}tt(e,n){var r=this.K;if(!r)return{$pageview_id:n};var s={$pageview_id:n,$prev_pageview_id:r.pageViewId},i=this._instance.scrollManager.getContext();if(i&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:o,lastScrollY:a,maxScrollY:l,maxContentHeight:c,lastContentY:u,maxContentY:d}=i;if(!(O(o)||O(a)||O(l)||O(c)||O(u)||O(d))){o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u),d=Math.ceil(d);var p=o>1?ze(a/o,0,1,R):1,f=o>1?ze(l/o,0,1,R):1,g=c>1?ze(u/c,0,1,R):1,_=c>1?ze(d/c,0,1,R):1;s=ce(s,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:p,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:f,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:g,$prev_pageview_max_content:d,$prev_pageview_max_content_percentage:_})}}return r.pathname&&(s.$prev_pageview_pathname=r.pathname),r.timestamp&&(s.$prev_pageview_duration=(e.getTime()-r.timestamp.getTime())/1e3),s}}var Or=t=>{var e=$==null?void 0:$.createElement("a");return O(e)?null:(e.href=t,e)},Ar=function(t,e){for(var n,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var i=r[s].split("=");if(i[0]===e){n=i;break}}if(!Y(n)||2>n.length)return"";var o=n[1];try{o=decodeURIComponent(o)}catch{R.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Mn=function(t,e,n){if(!t||!e||!e.length)return t;for(var r=t.split("#"),s=r[1],i=(r[0]||"").split("?"),o=i[1],a=i[0],l=(o||"").split("&"),c=[],u=0;l.length>u;u++){var d=l[u].split("=");Y(d)&&(e.includes(d[0])?c.push(d[0]+"="+n):c.push(l[u]))}var p=a;return o!=null&&(p+="?"+c.join("&")),s!=null&&(p+="#"+s),p},Fr=function(t,e){var n=t.match(new RegExp(e+"=([^&]*)"));return n?n[1]:null},nr="https?://(.*)",tn=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],rv=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...tn],Dn="<masked>",sv=["li_fat_id"];function Eu(t,e,n){if(!$)return{};var r,s=e?[...tn,...n||[]]:[],i=wu(Mn($.URL,s,Dn),t),o=(r={},te(sv,function(a){var l=He.M(a);r[a]=l||null}),r);return ce(o,i)}function wu(t,e){var n=rv.concat(e||[]),r={};return te(n,function(s){var i=Ar(t,s);r[s]=i||null}),r}function Su(t){var e=function(i){return i?i.search(nr+"google.([^/?]*)")===0?"google":i.search(nr+"bing.com")===0?"bing":i.search(nr+"yahoo.com")===0?"yahoo":i.search(nr+"duckduckgo.com")===0?"duckduckgo":null:null}(t),n=e!="yahoo"?"q":"p",r={};if(!rt(e)){r.$search_engine=e;var s=$?Ar($.referrer,n):"";s.length&&(r.ph_keyword=s)}return r}function La(){return navigator.language||navigator.userLanguage}var Nr="$direct";function ku(){return($==null?void 0:$.referrer)||Nr}function xu(t,e){var n=t?[...tn,...e||[]]:[],r=ve==null?void 0:ve.href.substring(0,1e3);return{r:ku().substring(0,1e3),u:r?Mn(r,n,Dn):void 0}}function Iu(t){var e,{r:n,u:r}=t,s={$referrer:n,$referring_domain:n==null?void 0:n==Nr?Nr:(e=Or(n))==null?void 0:e.host};if(r){s.$current_url=r;var i=Or(r);s.$host=i==null?void 0:i.host,s.$pathname=i==null?void 0:i.pathname;var o=wu(r);ce(s,o)}if(n){var a=Su(n);ce(s,a)}return s}function Tu(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function iv(){try{return new Date().getTimezoneOffset()}catch{return}}var ov=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class ws{constructor(e,n){this.N=e,this.props={},this.it=!1,this.et=(r=>{var s="";return r.token&&(s=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),r.persistence_name?"ph_"+r.persistence_name:"ph_"+s+"_posthog"})(e),this.H=this.rt(e),this.load(),e.debug&&R.info("Persistence loaded",e.persistence,T({},this.props)),this.update_config(e,e,n),this.save()}isDisabled(){return!!this.st}rt(e){ov.indexOf(e.persistence.toLowerCase())===-1&&(R.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var n=function(s){s===void 0&&(s=[]);var i=[...Xg,...s];return T({},se,{D(o){try{var a={};try{a=He.D(o)||{}}catch{}var l=ce(a,JSON.parse(se.M(o)||"{}"));return se.L(o,l),l}catch{}return null},L(o,a,l,c,u,d){try{se.L(o,a,void 0,void 0,d);var p={};i.forEach(f=>{a[f]&&(p[f]=a[f])}),Object.keys(p).length&&He.L(o,p,l,c,u,d)}catch(f){se.A(f)}},U(o,a){try{v==null||v.localStorage.removeItem(o),He.U(o,a)}catch(l){se.A(l)}}})}(e.cookie_persisted_properties||[]),r=e.persistence.toLowerCase();return r==="localstorage"&&se.F()?se:r==="localstorage+cookie"&&n.F()?n:r==="sessionstorage"&&me.F()?me:r==="memory"?Zg:r==="cookie"?He:n.F()?n:He}nt(e){var n=e??this.N.feature_flag_cache_ttl_ms;if(!n||0>=n)return!1;var r=this.props[Ir];return!r||typeof r!="number"||Date.now()-r>n}properties(){var e={};return te(this.props,(n,r)=>{if(r===zt&&_e(n)){if(!this.nt())for(var s=Object.keys(n),i=0;s.length>i;i++)e["$feature/"+s[i]]=n[s[i]]}else zg.indexOf(r)===-1&&(e[r]=n)}),e}load(){if(!this.st){var e=this.H.D(this.et);e&&(this.props=ce({},e))}}save(){this.st||this.H.L(this.et,this.props,this.ot,this.ut,this.ht,this.N.debug)}remove(){this.H.U(this.et,!1),this.H.U(this.et,!0)}clear(){this.remove(),this.props={}}register_once(e,n,r){if(_e(e)){O(n)&&(n="None"),this.ot=O(r)?this.dt:r;var s=!1;if(te(e,(i,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==n||(this.props[o]=i,s=!0)}),s)return this.save(),!0}return!1}register(e,n){if(_e(e)){this.ot=O(n)?this.dt:n;var r=!1;if(te(e,(s,i)=>{e.hasOwnProperty(i)&&this.props[i]!==s&&(this.props[i]=s,r=!0)}),r)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.it){var e=Eu(this.N.custom_campaign_params,this.N.mask_personal_data_properties,this.N.custom_personal_data_properties);Bt(so(e))||this.register(e),this.it=!0}}update_search_keyword(){var e;this.register((e=$==null?void 0:$.referrer)?Su(e):{})}update_referrer_info(){var e;this.register_once({$referrer:ku(),$referring_domain:$!=null&&$.referrer&&((e=Or($.referrer))==null?void 0:e.host)||Nr},void 0)}set_initial_person_info(){this.props[mi]||this.props[yi]||this.register_once({[Tr]:xu(this.N.mask_personal_data_properties,this.N.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};te([yi,mi],o=>{var a=this.props[o];a&&te(a,function(l,c){e["$initial_"+ii(c)]=l})});var n,r,s=this.props[Tr];if(s){var i=(n=Iu(s),r={},te(n,function(o,a){r["$initial_"+ii(a)]=o}),r);ce(e,i)}return e}safe_merge(e){return te(this.props,function(n,r){r in e||(e[r]=n)}),e}update_config(e,n,r){if(this.dt=this.ot=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!r),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==n.persistence||!((o,a)=>{if(o.length!==a.length)return!1;var l=[...o].sort(),c=[...a].sort();return l.every((u,d)=>u===c[d])})(e.cookie_persisted_properties||[],n.cookie_persisted_properties||[])){var s=this.rt(e),i=this.props;this.clear(),this.H=s,this.props=i,this.save()}}set_disabled(e){this.st=e,this.st?this.remove():this.save()}set_cross_subdomain(e){e!==this.ut&&(this.ut=e,this.remove(),this.save())}set_secure(e){e!==this.ht&&(this.ht=e,this.remove(),this.save())}set_event_timer(e,n){var r=this.props[wn]||{};r[e]=n,this.props[wn]=r,this.save()}remove_event_timer(e){var n=(this.props[wn]||{})[e];return O(n)||(delete this.props[wn][e],this.save()),n}get_property(e){return this.props[e]}set_property(e,n){this.props[e]=n,this.save()}}var dn={Activation:"events",Cancellation:"cancelEvents"},Ss={Popover:"popover",API:"api",Widget:"widget"},xn={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},ks={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},Ei={Popover:"popover",Inline:"inline"},av={SHOWN:"product tour shown"},ja={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},Ua=oe("[RateLimiter]");class lv{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=n=>{var r=n.text;if(r&&r.length)try{(JSON.parse(r).quota_limited||[]).forEach(s=>{Ua.info((s||"events")+" is quota limited."),this.serverLimits[s]=new Date().getTime()+6e4})}catch(s){return void Ua.warn('could not rate limit - continuing. Error: "'+(s==null?void 0:s.message)+'"',{text:r})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var n,r,s;e===void 0&&(e=!1);var{captureEventsBurstLimit:i,captureEventsPerSecond:o}=this,a=new Date().getTime(),l=(n=(r=this.instance.persistence)==null?void 0:r.get_property(vi))!==null&&n!==void 0?n:{tokens:i,last:a};l.tokens+=(a-l.last)/1e3*o,l.last=a,l.tokens>i&&(l.tokens=i);var c=1>l.tokens;return c||e||(l.tokens=Math.max(0,l.tokens-1)),!c||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+o+" events per second and "+i+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=c,(s=this.instance.persistence)==null||s.set_property(vi,l),{isRateLimited:c,remainingTokens:l.tokens}}isServerRateLimited(e){var n=this.serverLimits[e||"events"]||!1;return n!==!1&&new Date().getTime()<n}}var hn=oe("[RemoteConfig]");class Pu{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=M._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}vt(e){var n,r;(n=M.__PosthogExtensions__)!=null&&n.loadExternalDependency?(r=M.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"remote-config",()=>e(this.remoteConfig)):e()}ct(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback(n){e(n.json)}})}load(){try{if(this.remoteConfig)return hn.info("Using preloaded remote config",this.remoteConfig),this.ft(this.remoteConfig),void this._t();if(this._instance.bt())return void hn.warn("Remote config is disabled. Falling back to local config.");this.vt(e=>{if(!e)return hn.info("No config found after loading remote JS config. Falling back to JSON."),void this.ct(n=>{this.ft(n),this._t()});this.ft(e),this._t()})}catch(e){hn.error("Error loading remote config",e)}}stop(){this.yt&&(clearInterval(this.yt),this.yt=void 0)}refresh(){this._instance.bt()||($==null?void 0:$.visibilityState)==="hidden"||this._instance.reloadFeatureFlags()}_t(){var e;if(!this.yt){var n=(e=this._instance.config.remote_config_refresh_interval_ms)!==null&&e!==void 0?e:3e5;n!==0&&(this.yt=setInterval(()=>{this.refresh()},n))}}ft(e){var n;e||hn.error("Failed to fetch remote config from PostHog."),this._instance.ft(e??{}),(e==null?void 0:e.hasFeatureFlags)!==!1&&(this._instance.config.advanced_disable_feature_flags_on_first_load||(n=this._instance.featureFlags)==null||n.ensureFlagsLoaded())}}var Ue={GZipJS:"gzip-js",Base64:"base64"},Ne=Uint8Array,Te=Uint16Array,nn=Uint32Array,io=new Ne([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),oo=new Ne([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ha=new Ne([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Cu=function(t,e){for(var n=new Te(31),r=0;31>r;++r)n[r]=e+=1<<t[r-1];var s=new nn(n[30]);for(r=1;30>r;++r)for(var i=n[r];n[r+1]>i;++i)s[i]=i-n[r]<<5|r;return[n,s]},$u=Cu(io,2),wi=$u[1];$u[0][28]=258,wi[258]=28;for(var Ba=Cu(oo,0)[1],Ru=new Te(32768),ne=0;32768>ne;++ne){var Dt=(43690&ne)>>>1|(21845&ne)<<1;Ru[ne]=((65280&(Dt=(61680&(Dt=(52428&Dt)>>>2|(13107&Dt)<<2))>>>4|(3855&Dt)<<4))>>>8|(255&Dt)<<8)>>>1}var Pn=function(t,e,n){for(var r=t.length,s=0,i=new Te(e);r>s;++s)++i[t[s]-1];var o,a=new Te(e);for(s=0;e>s;++s)a[s]=a[s-1]+i[s-1]<<1;for(o=new Te(r),s=0;r>s;++s)o[s]=Ru[a[t[s]-1]++]>>>15-t[s];return o},$t=new Ne(288);for(ne=0;144>ne;++ne)$t[ne]=8;for(ne=144;256>ne;++ne)$t[ne]=9;for(ne=256;280>ne;++ne)$t[ne]=7;for(ne=280;288>ne;++ne)$t[ne]=8;var Mr=new Ne(32);for(ne=0;32>ne;++ne)Mr[ne]=5;var cv=Pn($t,9),uv=Pn(Mr,5),Ou=function(t){return(t/8>>0)+(7&t&&1)},Au=function(t,e,n){(n==null||n>t.length)&&(n=t.length);var r=new(t instanceof Te?Te:t instanceof nn?nn:Ne)(n-e);return r.set(t.subarray(e,n)),r},Ge=function(t,e,n){var r=e/8>>0;t[r]|=n<<=7&e,t[r+1]|=n>>>8},pn=function(t,e,n){var r=e/8>>0;t[r]|=n<<=7&e,t[r+1]|=n>>>8,t[r+2]|=n>>>16},xs=function(t,e){for(var n=[],r=0;t.length>r;++r)t[r]&&n.push({s:r,f:t[r]});var s=n.length,i=n.slice();if(!s)return[new Ne(0),0];if(s==1){var o=new Ne(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort(function(S,k){return S.f-k.f}),n.push({s:-1,f:25001});var a=n[0],l=n[1],c=0,u=1,d=2;for(n[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=s-1;)a=n[n[d].f>n[c].f?c++:d++],l=n[c!=u&&n[d].f>n[c].f?c++:d++],n[u++]={s:-1,f:a.f+l.f,l:a,r:l};var p=i[0].s;for(r=1;s>r;++r)i[r].s>p&&(p=i[r].s);var f=new Te(p+1),g=Si(n[u-1],f,0);if(g>e){r=0;var _=0,P=g-e,m=1<<P;for(i.sort(function(S,k){return f[k.s]-f[S.s]||S.f-k.f});s>r;++r){var b=i[r].s;if(e>=f[b])break;_+=m-(1<<g-f[b]),f[b]=e}for(_>>>=P;_>0;){var C=i[r].s;e>f[C]?_-=1<<e-f[C]++-1:++r}for(;r>=0&&_;--r){var x=i[r].s;f[x]==e&&(--f[x],++_)}g=e}return[new Ne(f),g]},Si=function(t,e,n){return t.s==-1?Math.max(Si(t.l,e,n+1),Si(t.r,e,n+1)):e[t.s]=n},za=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new Te(++e),r=0,s=t[0],i=1,o=function(l){n[r++]=l},a=1;e>=a;++a)if(t[a]==s&&a!=e)++i;else{if(!s&&i>2){for(;i>138;i-=138)o(32754);i>2&&(o(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(o(s),--i;i>6;i-=6)o(8304);i>2&&(o(i-3<<5|8208),i=0)}for(;i--;)o(s);i=1,s=t[a]}return[n.subarray(0,r),e]},fn=function(t,e){for(var n=0,r=0;e.length>r;++r)n+=t[r]*e[r];return n},ki=function(t,e,n){var r=n.length,s=Ou(e+2);t[s]=255&r,t[s+1]=r>>>8,t[s+2]=255^t[s],t[s+3]=255^t[s+1];for(var i=0;r>i;++i)t[s+i+4]=n[i];return 8*(s+4+r)},Wa=function(t,e,n,r,s,i,o,a,l,c,u){Ge(e,u++,n),++s[256];for(var d=xs(s,15),p=d[0],f=d[1],g=xs(i,15),_=g[0],P=g[1],m=za(p),b=m[0],C=m[1],x=za(_),S=x[0],k=x[1],w=new Te(19),E=0;b.length>E;++E)w[31&b[E]]++;for(E=0;S.length>E;++E)w[31&S[E]]++;for(var I=xs(w,7),A=I[0],j=I[1],F=19;F>4&&!A[Ha[F-1]];--F);var H,B,K,Z,N=c+5<<3,z=fn(s,$t)+fn(i,Mr)+o,ee=fn(s,p)+fn(i,_)+o+14+3*F+fn(w,A)+(2*w[16]+3*w[17]+7*w[18]);if(z>=N&&ee>=N)return ki(e,u,t.subarray(l,l+c));if(Ge(e,u,1+(z>ee)),u+=2,z>ee){H=Pn(p,f),B=p,K=Pn(_,P),Z=_;var V=Pn(A,j);for(Ge(e,u,C-257),Ge(e,u+5,k-1),Ge(e,u+10,F-4),u+=14,E=0;F>E;++E)Ge(e,u+3*E,A[Ha[E]]);u+=3*F;for(var le=[b,S],D=0;2>D;++D){var y=le[D];for(E=0;y.length>E;++E)Ge(e,u,V[X=31&y[E]]),u+=A[X],X>15&&(Ge(e,u,y[E]>>>5&127),u+=y[E]>>>12)}}else H=cv,B=$t,K=uv,Z=Mr;for(E=0;a>E;++E)if(r[E]>255){var X;pn(e,u,H[257+(X=r[E]>>>18&31)]),u+=B[X+257],X>7&&(Ge(e,u,r[E]>>>23&31),u+=io[X]);var de=31&r[E];pn(e,u,K[de]),u+=Z[de],de>3&&(pn(e,u,r[E]>>>5&8191),u+=oo[de])}else pn(e,u,H[r[E]]),u+=B[r[E]];return pn(e,u,H[256]),u+B[256]},dv=new nn([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),hv=function(){for(var t=new nn(256),e=0;256>e;++e){for(var n=e,r=9;--r;)n=(1&n&&3988292384)^n>>>1;t[e]=n}return t}(),Is=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8};function pv(t,e){e===void 0&&(e={});var n=function(){var d=4294967295;return{p(p){for(var f=d,g=0;p.length>g;++g)f=hv[255&f^p[g]]^f>>>8;d=f},d(){return 4294967295^d}}}(),r=t.length;n.p(t);var s,i,o,a,l,c=(a=10+((s=e).filename&&s.filename.length+1||0),l=8,function(d,p,f,g,_,P){var m=d.length,b=new Ne(g+m+5*(1+Math.floor(m/7e3))+_),C=b.subarray(g,b.length-_),x=0;if(!p||8>m)for(var S=0;m>=S;S+=65535){var k=S+65535;m>k?x=ki(C,x,d.subarray(S,k)):(C[S]=!0,x=ki(C,x,d.subarray(S,m)))}else{for(var w=dv[p-1],E=w>>>13,I=8191&w,A=(1<<f)-1,j=new Te(32768),F=new Te(A+1),H=Math.ceil(f/3),B=2*H,K=function(is){return(d[is]^d[is+1]<<H^d[is+2]<<B)&A},Z=new nn(25e3),N=new Te(288),z=new Te(32),ee=0,V=0,le=(S=0,0),D=0,y=0;m>S;++S){var X=K(S),de=32767&S,ye=F[X];if(j[de]=ye,F[X]=de,S>=D){var xe=m-S;if((ee>7e3||le>24576)&&xe>423){x=Wa(d,C,0,Z,N,z,V,le,y,S-y,x),le=ee=V=0,y=S;for(var Pe=0;286>Pe;++Pe)N[Pe]=0;for(Pe=0;30>Pe;++Pe)z[Pe]=0}var yt=2,qn=0,Xu=I,st=de-ye&32767;if(xe>2&&X==K(S-st))for(var Zu=Math.min(E,xe)-1,Qu=Math.min(32767,S),ed=Math.min(258,xe);Qu>=st&&--Xu&&de!=ye;){if(d[S+yt]==d[S+yt-st]){for(var it=0;ed>it&&d[S+it]==d[S+it-st];++it);if(it>yt){if(yt=it,qn=st,it>Zu)break;var td=Math.min(st,it-2),ho=0;for(Pe=0;td>Pe;++Pe){var ss=S-st+Pe+32768&32767,po=ss-j[ss]+32768&32767;po>ho&&(ho=po,ye=ss)}}}st+=(de=ye)-(ye=j[de])+32768&32767}if(qn){Z[le++]=268435456|wi[yt]<<18|Ba[qn];var fo=31&wi[yt],_o=31&Ba[qn];V+=io[fo]+oo[_o],++N[257+fo],++z[_o],D=S+yt,++ee}else Z[le++]=d[S],++N[d[S]]}}x=Wa(d,C,!0,Z,N,z,V,le,y,S-y,x)}return Au(b,0,g+Ou(x)+_)}(i=t,(o=e).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(i.length)))):12+o.mem,a,l)),u=c.length;return function(d,p){var f=p.filename;if(d[0]=31,d[1]=139,d[2]=8,d[8]=2>p.level?4:p.level==9?2:0,d[9]=3,p.mtime!=0&&Is(d,4,Math.floor(new Date(p.mtime||Date.now())/1e3)),f){d[3]=8;for(var g=0;f.length>=g;++g)d[g+10]=f.charCodeAt(g)}}(c,e),Is(c,u-8,n.d()),Is(c,u-4,r),c}var fv=!!si||!!ri,Fu="text/plain",Dr=function(t,e,n){var r;n===void 0&&(n=!0);var[s,i]=t.split("?"),o=T({},e),a=(r=i==null?void 0:i.split("&").map(c=>{var u,[d,p]=c.split("="),f=n&&(u=o[d])!==null&&u!==void 0?u:p;return delete o[d],d+"="+f}))!==null&&r!==void 0?r:[],l=function(c,u){var d,p;u===void 0&&(u="&");var f=[];return te(c,function(g,_){O(g)||O(_)||_==="undefined"||(d=encodeURIComponent((P=>P instanceof File)(g)?g.name:g.toString()),p=encodeURIComponent(_),f[f.length]=p+"="+d)}),f.join(u)}(o);return l&&a.push(l),s+"?"+a.join("&")},Wt=(t,e)=>JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r,e),Ts=t=>{if(t.wt)return t.wt;var{data:e,compression:n}=t;if(e){if(n===Ue.GZipJS){var r=pv(function(a,l){var c=a.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(a);for(var u=new Ne(a.length+(a.length>>>1)),d=0,p=function(P){u[d++]=P},f=0;c>f;++f){if(d+5>u.length){var g=new Ne(d+8+(c-f<<1));g.set(u),u=g}var _=a.charCodeAt(f);128>_?p(_):2048>_?(p(192|_>>>6),p(128|63&_)):_>55295&&57344>_?(p(240|(_=65536+(1047552&_)|1023&a.charCodeAt(++f))>>>18),p(128|_>>>12&63),p(128|_>>>6&63),p(128|63&_)):(p(224|_>>>12),p(128|_>>>6&63),p(128|63&_))}return Au(u,0,d)}(Wt(e)),{mtime:0});return{contentType:Fu,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(n===Ue.Base64){var s=function(a){return a&&btoa(encodeURIComponent(a).replace(/%([0-9A-F]{2})/g,(l,c)=>String.fromCharCode(parseInt(c,16))))}(Wt(e)),i=(a=>"data="+encodeURIComponent(typeof a=="string"?a:Wt(a)))(s);return{contentType:"application/x-www-form-urlencoded",body:i,estimatedSize:new Blob([i]).size}}var o=Wt(e);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},_v=function(){var t=De(function*(e){var n=Wt(e.data),r=yield function(i,o){return Wc.apply(this,arguments)}(n,Ce.DEBUG);if(!r)return e;var s=yield r.arrayBuffer();return T({},e,{wt:{contentType:Fu,body:s,estimatedSize:s.byteLength}})});return function(e){return t.apply(this,arguments)}}(),fr=[];ri&&fr.push({transport:"fetch",method(t){var e,n,{contentType:r,body:s,estimatedSize:i}=(e=Ts(t))!==null&&e!==void 0?e:{},o=new Headers;te(t.headers,function(u,d){o.append(d,u)}),r&&o.append("Content-Type",r);var a=t.url,l=null;if(va){var c=new va;l={signal:c.signal,timeout:setTimeout(()=>c.abort(),t.timeout)}}ri(a,T({method:(t==null?void 0:t.method)||"GET",headers:o,keepalive:t.method==="POST"&&52428.8>(i||0),body:s,signal:(n=l)==null?void 0:n.signal},t.fetchOptions)).then(u=>u.text().then(d=>{var p={statusCode:u.status,text:d};if(u.status===200)try{p.json=JSON.parse(d)}catch(f){R.error(f)}t.callback==null||t.callback(p)})).catch(u=>{R.error(u),t.callback==null||t.callback({statusCode:0,error:u})}).finally(()=>l?clearTimeout(l.timeout):null)}}),si&&fr.push({transport:"XHR",method(t){var e,n=new si;n.open(t.method||"GET",t.url,!0);var{contentType:r,body:s}=(e=Ts(t))!==null&&e!==void 0?e:{};te(t.headers,function(i,o){n.setRequestHeader(o,i)}),r&&n.setRequestHeader("Content-Type",r),t.timeout&&(n.timeout=t.timeout),t.disableXHRCredentials||(n.withCredentials=!0),n.onreadystatechange=()=>{if(n.readyState===4){var i={statusCode:n.status,text:n.responseText};if(n.status===200)try{i.json=JSON.parse(n.responseText)}catch{}t.callback==null||t.callback(i)}},n.send(s)}}),Re!=null&&Re.sendBeacon&&fr.push({transport:"sendBeacon",method(t){var e=Dr(t.url,{beacon:"1"});try{var n,{contentType:r,body:s}=(n=Ts(t))!==null&&n!==void 0?n:{},i=typeof s=="string"?new Blob([s],{type:r}):s;Re.sendBeacon(e,i)}catch{}}});var xi=3e3;class gv{constructor(e,n){this.Et=!0,this.St=[],this.xt=ze((n==null?void 0:n.flush_interval_ms)||xi,250,5e3,R.createLogger("flush interval"),xi),this.Tt=e}enqueue(e){this.St.push(e),this.$t||this.kt()}unload(){this.Rt();var e=this.St.length>0?this.Pt():{},n=Object.values(e);[...n.filter(r=>r.url.indexOf("/e")===0),...n.filter(r=>r.url.indexOf("/e")!==0)].map(r=>{this.Tt(T({},r,{transport:"sendBeacon"}))})}enable(){this.Et=!1,this.kt()}kt(){var e=this;this.Et||(this.$t=setTimeout(()=>{if(this.Rt(),this.St.length>0){var n=this.Pt(),r=function(){var i=n[s],o=new Date().getTime();i.data&&Y(i.data)&&te(i.data,a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp}),e.Tt(i)};for(var s in n)r()}},this.xt))}Rt(){clearTimeout(this.$t),this.$t=void 0}Pt(){var e={};return te(this.St,n=>{var r,s=n,i=(s?s.batchKey:null)||s.url;O(e[i])&&(e[i]=T({},s,{data:[]})),(r=e[i].data)==null||r.push(s.data)}),this.St=[],e}}var vv=["retriesPerformedSoFar"];class mv{constructor(e){this.Ot=!1,this.It=3e3,this.St=[],this._instance=e,this.St=[],this.Ct=!0,!O(v)&&"onLine"in v.navigator&&(this.Ct=v.navigator.onLine,this.Ft=()=>{this.Ct=!0,this.At()},this.Mt=()=>{this.Ct=!1},he(v,"online",this.Ft),he(v,"offline",this.Mt))}get length(){return this.St.length}retriableRequest(e){var{retriesPerformedSoFar:n}=e,r=zc(e,vv);jt(n)&&(r.url=Dr(r.url,{retry_count:n})),this._instance._send_request(T({},r,{callback:s=>{s.statusCode===200||s.statusCode>=400&&500>s.statusCode||(n??0)>=10?r.callback==null||r.callback(s):this.Dt(T({retriesPerformedSoFar:n},r))}}))}Dt(e){var n=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=n+1;var r=function(o){var a=3e3*Math.pow(2,o),l=a/2,c=Math.min(18e5,a),u=Math.random()-.5;return Math.ceil(c+u*(c-l))}(n),s=Date.now()+r;this.St.push({retryAt:s,requestOptions:e});var i="Enqueued failed request for retry in "+r;navigator.onLine||(i+=" (Browser is offline)"),R.warn(i),this.Ot||(this.Ot=!0,this.Lt())}Lt(){if(this.Ut&&clearTimeout(this.Ut),this.St.length===0)return this.Ot=!1,void(this.Ut=void 0);this.Ut=setTimeout(()=>{this.Ct&&this.St.length>0&&this.At(),this.Lt()},this.It)}At(){var e=Date.now(),n=[],r=this.St.filter(i=>e>i.retryAt||(n.push(i),!1));if(this.St=n,r.length>0)for(var{requestOptions:s}of r)this.retriableRequest(s)}unload(){for(var{requestOptions:e}of(this.Ut&&(clearTimeout(this.Ut),this.Ut=void 0),this.Ot=!1,O(v)||(this.Ft&&(v.removeEventListener("online",this.Ft),this.Ft=void 0),this.Mt&&(v.removeEventListener("offline",this.Mt),this.Mt=void 0)),this.St))try{this._instance._send_request(T({},e,{transport:"sendBeacon"}))}catch(n){R.error(n)}this.St=[]}}class yv{constructor(e){this.Nt=()=>{var n,r,s,i;this.jt||(this.jt={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,c=a+((o==null?void 0:o.clientHeight)||0),u=(o==null?void 0:o.scrollHeight)||0;this.jt.lastScrollY=Math.ceil(a),this.jt.maxScrollY=Math.max(a,(n=this.jt.maxScrollY)!==null&&n!==void 0?n:0),this.jt.maxScrollHeight=Math.max(l,(r=this.jt.maxScrollHeight)!==null&&r!==void 0?r:0),this.jt.lastContentY=c,this.jt.maxContentY=Math.max(c,(s=this.jt.maxContentY)!==null&&s!==void 0?s:0),this.jt.maxContentHeight=Math.max(u,(i=this.jt.maxContentHeight)!==null&&i!==void 0?i:0)},this._instance=e}get zt(){return this._instance.config.scroll_root_selector}getContext(){return this.jt}resetContext(){var e=this.jt;return setTimeout(this.Nt,0),e}startMeasuringScrollPosition(){he(v,"scroll",this.Nt,{capture:!0}),he(v,"scrollend",this.Nt,{capture:!0}),he(v,"resize",this.Nt)}scrollElement(){if(!this.zt)return v==null?void 0:v.document.documentElement;var e=Y(this.zt)?this.zt:[this.zt];for(var n of e){var r=v==null?void 0:v.document.querySelector(n);if(r)return r}}scrollY(){if(this.zt){var e=this.scrollElement();return e&&e.scrollTop||0}return v&&(v.scrollY||v.pageYOffset||v.document.documentElement.scrollTop)||0}scrollX(){if(this.zt){var e=this.scrollElement();return e&&e.scrollLeft||0}return v&&(v.scrollX||v.pageXOffset||v.document.documentElement.scrollLeft)||0}}var bv=t=>xu(t==null?void 0:t.config.mask_personal_data_properties,t==null?void 0:t.config.custom_personal_data_properties);class qa{constructor(e,n,r,s){this.Bt=i=>{var o=this.Ht();if(!o||o.sessionId!==i){var a={sessionId:i,props:this.qt(this._instance)};this.Wt.register({[gi]:a})}},this._instance=e,this.Vt=n,this.Wt=r,this.qt=s||bv,this.Vt.onSessionId(this.Bt)}Ht(){return this.Wt.props[gi]}getSetOnceProps(){var e,n=(e=this.Ht())==null?void 0:e.props;return n?"r"in n?Iu(n):{$referring_domain:n.referringDomain,$pathname:n.initialPathName,utm_source:n.utm_source,utm_campaign:n.utm_campaign,utm_medium:n.utm_medium,utm_content:n.utm_content,utm_term:n.utm_term}:{}}getSessionProps(){var e={};return te(so(this.getSetOnceProps()),(n,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+ii(r)]=n}),e}}class ao{constructor(){this.Yt={}}on(e,n){return this.Yt[e]||(this.Yt[e]=[]),this.Yt[e].push(n),()=>{this.Yt[e]=this.Yt[e].filter(r=>r!==n)}}emit(e,n){for(var r of this.Yt[e]||[])r(n);for(var s of this.Yt["*"]||[])s(e,n)}}var Ps=oe("[SessionId]");class Ga{on(e,n){return this.Gt.on(e,n)}constructor(e,n,r){var s;if(this.Jt=[],this.Kt=void 0,this.Gt=new ao,this.Xt=(c,u)=>!(!jt(c)||!jt(u))&&Math.abs(c-u)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===Le)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.N=e.config,this.Wt=e.persistence,this.Qt=void 0,this.Zt=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.ti=n||ht,this.ii=r||ht;var i=this.N.persistence_name||this.N.token;if(this._sessionTimeoutMs=1e3*ze(this.N.session_idle_timeout_seconds||1800,60,36e3,Ps.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.ei(),this.ri="ph_"+i+"_window_id",this.si="ph_"+i+"_primary_window_exists",this.ni()){var o=me.D(this.ri),a=me.D(this.si);o&&!a?this.Qt=o:me.U(this.ri),me.L(this.si,!0)}if((s=this.N.bootstrap)!=null&&s.sessionID)try{var l=(c=>{var u=this.N.bootstrap.sessionID.replace(/-/g,"");if(u.length!==32)throw new Error("Not a valid UUID");if(u[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(u.substring(0,12),16)})();this.oi(this.N.bootstrap.sessionID,new Date().getTime(),l)}catch(c){Ps.error("Invalid sessionID in bootstrap",c)}this.ai()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return O(this.Jt)&&(this.Jt=[]),this.Jt.push(e),this.Zt&&e(this.Zt,this.Qt),()=>{this.Jt=this.Jt.filter(n=>n!==e)}}ni(){return this.N.persistence!=="memory"&&!this.Wt.st&&me.F()}li(e){e!==this.Qt&&(this.Qt=e,this.ni()&&me.L(this.ri,e))}ui(){return this.Qt?this.Qt:this.ni()?me.D(this.ri):null}oi(e,n,r){e===this.Zt&&n===this._sessionActivityTimestamp&&r===this._sessionStartTimestamp||(this._sessionStartTimestamp=r,this._sessionActivityTimestamp=n,this.Zt=e,this.Wt.register({[xr]:[n,e,r]}))}hi(){var e=this.Wt.props[xr];return Y(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.oi(null,null,null)}destroy(){clearTimeout(this.di),this.di=void 0,this.Kt&&v&&(v.removeEventListener($r,this.Kt,{capture:!1}),this.Kt=void 0),this.Jt=[]}ai(){this.Kt=()=>{this.ni()&&me.U(this.si)},he(v,$r,this.Kt,{capture:!1})}checkAndGetSessionAndWindowId(e,n){if(e===void 0&&(e=!1),n===void 0&&(n=null),this.N.cookieless_mode===Le)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=n||new Date().getTime(),[s,i,o]=this.hi(),a=this.ui(),l=jt(o)&&Math.abs(r-o)>864e5,c=!1,u=!i,d=!u&&!e&&this.Xt(r,s);u||d||l?(i=this.ti(),a=this.ii(),Ps.info("new session ID generated",{sessionId:i,windowId:a,changeReason:{noSessionId:u,activityTimeout:d,sessionPastMaximumLength:l}}),o=r,c=!0):a||(a=this.ii(),c=!0);var p=jt(s)&&e&&!l?s:r,f=jt(o)?o:new Date().getTime();return this.li(a),this.oi(i,p,f),e||this.ei(),c&&this.Jt.forEach(g=>g(i,a,c?{noSessionId:u,activityTimeout:d,sessionPastMaximumLength:l}:void 0)),{sessionId:i,windowId:a,sessionStartTimestamp:f,changeReason:c?{noSessionId:u,activityTimeout:d,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:s}}ei(){clearTimeout(this.di),this.di=setTimeout(()=>{var[e]=this.hi();if(this.Xt(new Date().getTime(),e)){var n=this.Zt;this.resetSessionId(),this.Gt.emit("forcedIdleReset",{idleSessionId:n})}},1.1*this.sessionTimeoutMs)}}var Nu=function(t,e){if(!t)return!1;var n=t.userAgent;if(n&&ba(n,e))return!0;try{var r=t==null?void 0:t.userAgentData;if(r!=null&&r.brands&&r.brands.some(s=>ba(s==null?void 0:s.brand,e)))return!0}catch{}return!!t.webdriver},Lr=function(t,e){if(!function(n){try{new RegExp(n)}catch{return!1}return!0}(e))return!1;try{return new RegExp(e).test(t)}catch{return!1}};function Va(t,e,n){return Wt({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:n})}var Mu={exact:(t,e)=>e.some(n=>t.some(r=>n===r)),is_not:(t,e)=>e.every(n=>t.every(r=>n!==r)),regex:(t,e)=>e.some(n=>t.some(r=>Lr(n,r))),not_regex:(t,e)=>e.every(n=>t.every(r=>!Lr(n,r))),icontains:(t,e)=>e.map(rr).some(n=>t.map(rr).some(r=>n.includes(r))),not_icontains:(t,e)=>e.map(rr).every(n=>t.map(rr).every(r=>!n.includes(r))),gt:(t,e)=>e.some(n=>{var r=parseFloat(n);return!isNaN(r)&&t.some(s=>r>parseFloat(s))}),lt:(t,e)=>e.some(n=>{var r=parseFloat(n);return!isNaN(r)&&t.some(s=>r<parseFloat(s))})},rr=t=>t.toLowerCase();function Du(t,e){return!t||Object.entries(t).every(n=>{var[r,s]=n,i=e==null?void 0:e[r];if(O(i)||rt(i))return!1;var o=[String(i)],a=Mu[s.operator];return!!a&&a(s.values,o)})}var Ii="custom",Ya="i.posthog.com";class Ev{constructor(e){this.vi={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,n=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return n||(n=this.apiHost.replace("."+Ya,".posthog.com")),n==="https://app.posthog.com"?"https://us.posthog.com":n}get region(){return this.vi[this.apiHost]||(this.vi[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"us":/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"eu":Ii),this.vi[this.apiHost]}endpointFor(e,n){if(n===void 0&&(n=""),n&&(n=n[0]==="/"?n:"/"+n),e==="ui")return this.uiHost+n;if(e==="flags")return this.flagsApiHost+n;if(this.region===Ii)return this.apiHost+n;var r=Ya+n;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}}var Q=oe("[Surveys]"),Ti="seenSurvey_",wv=(t,e)=>{var n="$survey_"+e+"/"+t.id;return t.current_iteration&&t.current_iteration>0&&(n="$survey_"+e+"/"+t.id+"/"+t.current_iteration),n},Ka=t=>((e,n)=>{var r=""+Ti+n.id;return n.current_iteration&&n.current_iteration>0&&(r=""+Ti+n.id+"_"+n.current_iteration),r})(0,t),Sv=[Ss.Popover,Ss.Widget,Ss.API],kv={ignoreConditions:!1,ignoreDelay:!1,displayType:Ei.Popover},xv=oe("[PostHog ExternalIntegrations]"),Iv={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class Tv{constructor(e){this._instance=e}Y(e,n){var r;(r=M.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,e,s=>{if(s)return xv.error("failed to load script",s);n()})}startIfEnabledOrStop(){var e=this,n=function(o){var a,l,c;!s||(a=M.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.Y(Iv[o],()=>{var u;(u=M.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.start(e._instance)}),!s&&(l=M.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((c=M.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.stop())};for(var[r,s]of Object.entries((i=this._instance.config.integrations)!==null&&i!==void 0?i:{})){var i;n(r)}}}var Cn={},Cs=0,Pi=()=>{},Ja='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',_n="Surveys module not available",Xa="sanitize_properties is deprecated. Use before_send instead",Lu="Invalid value for property_denylist config: ",Ht="posthog",ju=!fv&&(Ie==null?void 0:Ie.indexOf("MSIE"))===-1&&(Ie==null?void 0:Ie.indexOf("Mozilla"))===-1,Za=t=>{var e;return T({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Gg($==null?void 0:$.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Pi,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:t??"unset",__preview_deferred_init_extensions:!1,debug:ve&&fe(ve==null?void 0:ve.search)&&ve.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(v==null||(e=v.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(n){R.error("Bad HTTP status: "+n.statusCode+" "+n.text)},get_device_id:n=>n,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:bi,before_send:void 0,request_queue_config:{flush_interval_ms:xi},error_tracking:{},_onCapture:Pi,__preview_eager_load_replay:!1},(n=>({rageclick:!n||"2025-11-30">n||{content_ignorelist:!0},capture_pageview:!n||"2025-05-24">n||"history_change",session_recording:n&&n>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:n&&n>="2026-01-30"?"head":"body",internal_or_test_user_hostname:n&&n>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(t))},Pv=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["store_google","save_campaign_params"],["verbose","debug"]],Qa=t=>{var e={};for(var[n,r]of Pv)O(t[n])||(e[r]=t[n]);var s=ce({},e,t);return Y(t.property_blacklist)&&(O(t.property_denylist)?s.property_denylist=t.property_blacklist:Y(t.property_denylist)?s.property_denylist=[...t.property_blacklist,...t.property_denylist]:R.error(Lu+t.property_denylist)),s};class Cv{constructor(){this.__forceAllowLocalhost=!1}get ci(){return this.__forceAllowLocalhost}set ci(e){R.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class Be{fi(e,n){if(e){var r=this.pi.indexOf(e);r!==-1&&this.pi.splice(r,1)}return this.pi.push(n),n.initialize==null||n.initialize(),n}get decideEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){var e;this.webPerformance=new Cv,this.gi=!1,this.version=Ce.LIB_VERSION,this.mi=new ao,this.pi=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Za(),this.SentryIntegration=nv,this.sentryIntegration=r=>function(s,i){var o=bu(s,i);return{name:yu,processEvent:a=>o(a)}}(this,r),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.bi=!1,this.yi=null,this.wi=null,this.Ei=null,this.scrollManager=new yv(this),this.pageViewManager=new Da(this),this.rateLimiter=new lv(this),this.requestRouter=new Ev(this),this.consent=new Qg(this),this.externalIntegrations=new Tv(this);var n=(e=Be.__defaultExtensionClasses)!==null&&e!==void 0?e:{};this.featureFlags=n.featureFlags&&new n.featureFlags(this),this.toolbar=n.toolbar&&new n.toolbar(this),this.surveys=n.surveys&&new n.surveys(this),this.conversations=n.conversations&&new n.conversations(this),this.logs=n.logs&&new n.logs(this),this.experiments=n.experiments&&new n.experiments(this),this.exceptions=n.exceptions&&new n.exceptions(this),this.people={set:(r,s,i)=>{var o=fe(r)?{[r]:s}:r;this.setPersonProperties(o),i==null||i({})},set_once:(r,s,i)=>{var o=fe(r)?{[r]:s}:r;this.setPersonProperties(void 0,o),i==null||i({})}},this.on("eventCaptured",r=>R.info('send "'+(r==null?void 0:r.event)+'"',r))}init(e,n,r){if(r&&r!==Ht){var s,i=(s=Cn[r])!==null&&s!==void 0?s:new Be;return i._init(e,n,r),Cn[r]=i,Cn[Ht][r]=i,i}return this._init(e,n,r)}_init(e,n,r){var s;if(n===void 0&&(n={}),O(e)||hr(e))return R.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},n.debug=this.Si(n.debug),this.xi=n,this.Ti=[],n.person_profiles?this.wi=n.person_profiles:n.process_person&&(this.wi=n.process_person),this.set_config(ce({},Za(n.defaults),Qa(n),{name:r,token:e})),this.config.on_xhr_error&&R.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:Ue.GZipJS;var i=this.$i();this.persistence=new ws(this.config,i),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new ws(T({},this.config,{persistence:"sessionStorage"}),i);var o=T({},this.persistence.props),a=T({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.ki=new gv(_=>this.Ri(_),this.config.request_queue_config),this.Pi=new mv(this),this.__request_queue=[];var l=this.config.cookieless_mode===Le||this.config.cookieless_mode===Ve&&this.consent.isExplicitlyOptedOut();if(l||(this.sessionManager=new Ga(this),this.sessionPropsManager=new qa(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(R.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.Oi(l)},0)):(R.info("Initializing extensions synchronously"),this.Oi(l)),Ce.DEBUG=Ce.DEBUG||this.config.debug,Ce.DEBUG&&R.info("Starting in debug mode",{this:this,config:n,thisC:T({},this.config),p:o,s:a}),((s=n.bootstrap)==null?void 0:s.distinctID)!==void 0){var c=n.bootstrap.distinctID,u=this.get_distinct_id(),d=this.persistence.get_property(Me);if(n.bootstrap.isIdentifiedID&&u!=null&&u!==c&&d===Nt)this.identify(c);else if(n.bootstrap.isIdentifiedID&&u!=null&&u!==c&&d===Mt)R.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{var p=this.config.get_device_id(ht()),f=n.bootstrap.isIdentifiedID?p:c;this.persistence.set_property(Me,n.bootstrap.isIdentifiedID?Mt:Nt),this.register({distinct_id:c,$device_id:f})}}if(l)this.register_once({distinct_id:Zn,$device_id:null},"");else if(!this.get_distinct_id()){var g=this.config.get_device_id(ht());this.register_once({distinct_id:g,$device_id:g},""),this.persistence.set_property(Me,Nt)}return he(v,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),n.segment?function(_,P){var m=_.config.segment;if(!m)return P();(function(b,C){var x=b.config.segment;if(!x)return C();var S=w=>{var E=()=>w.anonymousId()||ht();b.config.get_device_id=E,w.id()&&(b.register({distinct_id:w.id(),$device_id:E()}),b.persistence.set_property(Me,Mt)),C()},k=x.user();"then"in k&&Ke(k.then)?k.then(S):S(k)})(_,()=>{m.register((b=>{Promise&&Promise.resolve||Es.warn("This browser does not have Promise support, and can not use the segment integration");var C=(x,S)=>{if(!S)return x;x.event.userId||x.event.anonymousId===b.get_distinct_id()||(Es.info("No userId set, resetting PostHog"),b.reset()),x.event.userId&&x.event.userId!==b.get_distinct_id()&&(Es.info("UserId set, identifying with PostHog"),b.identify(x.event.userId));var k=b.calculateEventProperties(S,x.event.properties);return x.event.properties=Object.assign({},k,x.event.properties),x};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:x=>C(x,x.event.event),page:x=>C(x,Ut),identify:x=>C(x,ys),screen:x=>C(x,"$screen")}})(_)).then(()=>{P()})})}(this,()=>this.Ii()):this.Ii(),Ke(this.config._onCapture)&&this.config._onCapture!==Pi&&(R.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",_=>this.config._onCapture(_.event,_))),this.config.ip&&R.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}Oi(e){var n,r,s,i,o,a,l,c=performance.now(),u=T({},Be.__defaultExtensionClasses,this.config.__extensionClasses),d=[];u.featureFlags&&this.pi.push(this.featureFlags=(n=this.featureFlags)!==null&&n!==void 0?n:new u.featureFlags(this)),u.exceptions&&this.pi.push(this.exceptions=(r=this.exceptions)!==null&&r!==void 0?r:new u.exceptions(this)),u.historyAutocapture&&this.pi.push(this.historyAutocapture=new u.historyAutocapture(this)),u.tracingHeaders&&this.pi.push(new u.tracingHeaders(this)),u.siteApps&&this.pi.push(this.siteApps=new u.siteApps(this)),u.sessionRecording&&!e&&this.pi.push(this.sessionRecording=new u.sessionRecording(this)),this.config.disable_scroll_properties||d.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),u.autocapture&&this.pi.push(this.autocapture=new u.autocapture(this)),u.surveys&&this.pi.push(this.surveys=(s=this.surveys)!==null&&s!==void 0?s:new u.surveys(this)),u.logs&&this.pi.push(this.logs=(i=this.logs)!==null&&i!==void 0?i:new u.logs(this)),u.conversations&&this.pi.push(this.conversations=(o=this.conversations)!==null&&o!==void 0?o:new u.conversations(this)),u.productTours&&this.pi.push(this.productTours=new u.productTours(this)),u.heatmaps&&this.pi.push(this.heatmaps=new u.heatmaps(this)),u.webVitalsAutocapture&&this.pi.push(this.webVitalsAutocapture=new u.webVitalsAutocapture(this)),u.exceptionObserver&&this.pi.push(this.exceptionObserver=new u.exceptionObserver(this)),u.deadClicksAutocapture&&this.pi.push(this.deadClicksAutocapture=new u.deadClicksAutocapture(this,tv)),u.toolbar&&this.pi.push(this.toolbar=(a=this.toolbar)!==null&&a!==void 0?a:new u.toolbar(this)),u.experiments&&this.pi.push(this.experiments=(l=this.experiments)!==null&&l!==void 0?l:new u.experiments(this)),this.pi.forEach(p=>{p.initialize&&d.push(()=>{p.initialize==null||p.initialize()})}),d.push(()=>{if(this.Ci){var p=this.Ci;this.Ci=void 0,this.ft(p)}}),this.Fi(d,c)}Fi(e,n){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-n>=30&&e.length>0)return void setTimeout(()=>{this.Fi(e,n)},0);var r=e.shift();if(r)try{r()}catch(i){R.error("Error initializing extension:",i)}}var s=Math.round(performance.now()-n);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:s}),this.config.__preview_deferred_init_extensions&&R.info("PostHog extensions initialized ("+s+"ms)")}ft(e){var n;if(!$||!$.body)return R.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.ft(e)},500);this.config.__preview_deferred_init_extensions&&(this.Ci=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=q(e.supportedCompression,Ue.GZipJS)?Ue.GZipJS:q(e.supportedCompression,Ue.Base64)?Ue.Base64:void 0),(n=e.analytics)!=null&&n.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.wi?this.wi:bi}),this.pi.forEach(r=>r.onRemoteConfig==null?void 0:r.onRemoteConfig(e))}Ii(){try{this.config.loaded(this)}catch(r){R.critical("`loaded` function failed",r)}if(this.Ai(),this.config.internal_or_test_user_hostname&&ve!=null&&ve.hostname){var e=ve.hostname,n=this.config.internal_or_test_user_hostname;(typeof n=="string"?e===n:n.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.config.cookieless_mode===Le)&&this.Mi()},1),this.Di=new Pu(this),this.Di.load()}Ai(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.ki)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Qn(this.__request_queue,e=>this.Ri(e)),this.__request_queue=[],this.Ai()}_handle_unload(){var e,n,r;(e=this.surveys)==null||e.handlePageUnload(),this.config.request_batching?(this.Li()&&this.capture(ms),(n=this.ki)==null||n.unload(),(r=this.Pi)==null||r.unload()):this.Li()&&this.capture(ms,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(ju?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Dr(e.url,{ip:this.config.ip?1:0}),e.headers=T({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(n=>{var r,s,i,o=T({},n);o.timeout=o.timeout||6e4,o.url=Dr(o.url,{_:new Date().getTime().toString(),ver:Ce.JS_SDK_VERSION,compression:o.compression});var a=(r=o.transport)!==null&&r!==void 0?r:"fetch",l=fr.filter(u=>!o.disableTransport||!u.transport||!o.disableTransport.includes(u.transport)),c=(s=(i=function(u,d){for(var p=0;u.length>p;p++)if(u[p].transport===a)return u[p]}(l))==null?void 0:i.method)!==null&&s!==void 0?s:l[0].method;if(!c)throw new Error("No available transport method");a!=="sendBeacon"&&o.data&&o.compression===Ue.GZipJS&&ig?_v(o).then(u=>{c(u)}).catch(()=>{c(o)}):c(o)})(T({},e,{callback:n=>{var r,s;this.rateLimiter.checkForLimiting(n),400>n.statusCode||(r=(s=this.config).on_request_error)==null||r.call(s,n),e.callback==null||e.callback(n)}}))))}Ri(e){this.Pi?this.Pi.retriableRequest(e):this._send_request(e)}_execute_array(e){Cs++;try{var n,r=[],s=[],i=[];Qn(e,a=>{a&&(Y(n=a[0])?i.push(a):Ke(a)?a.call(this):Y(a)&&n==="alias"?r.push(a):Y(a)&&n.indexOf("capture")!==-1&&Ke(this[n])?i.push(a):s.push(a))});var o=function(a,l){Qn(a,function(c){if(Y(c[0])){var u=l;te(c,function(d){u=u[d[0]].apply(u,d.slice(1))})}else l[c[0]].apply(l,c.slice(1))})};o(r,this),o(s,this),o(i,this)}finally{Cs--}}push(e){if(Cs>0&&Y(e)&&fe(e[0])){var n=Be.prototype[e[0]];Ke(n)&&n.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,n,r){var s,i,o,a,l,c;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.ki){if(this.is_capturing())if(!O(e)&&fe(e)){var u=!this.config.opt_out_useragent_filter&&this._is_bot();if(!u||this.config.__preview_capture_bot_pageviews){var d=r!=null&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(d==null||!d.isRateLimited){n!=null&&n.$current_url&&!fe(n==null?void 0:n.$current_url)&&(R.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),n==null||delete n.$current_url),e!=="$exception"||r!=null&&r.Ui||R.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var p=new Date,f=(r==null?void 0:r.timestamp)||p,g=ht(),_={uuid:g,event:e,properties:this.calculateEventProperties(e,n||{},f,g)};e===Ut&&this.config.__preview_capture_bot_pageviews&&u&&(_.event="$bot_pageview",_.properties.$browser_type="bot"),d&&(_.properties.$lib_rate_limit_remaining_tokens=d.remainingTokens),r!=null&&r.$set&&(_.$set=r==null?void 0:r.$set);var P,m=this.Ni(r==null?void 0:r.$set_once,e!==Aa,e===ys);if(m&&(_.$set_once=m),(i=_,o=r!=null&&r._noTruncate?null:this.config.properties_string_max_length,a=i,l=E=>fe(E)&&!rt(o)?E.slice(0,o):E,c=new Set,_=function E(I,A){return I!==Object(I)?l?l(I):I:c.has(I)?void 0:(c.add(I),Y(I)?(j=[],Qn(I,F=>{j.push(E(F))})):(j={},te(I,(F,H)=>{c.has(F)||(j[H]=E(F))})),j);var j}(a)).timestamp=f,O(r==null?void 0:r.timestamp)||(_.properties.$event_time_override_provided=!0,_.properties.$event_time_override_system_time=p),e===xn.DISMISSED||e===xn.SENT){var b=n==null?void 0:n[ks.SURVEY_ID],C=n==null?void 0:n[ks.SURVEY_ITERATION];P={id:b,current_iteration:C},localStorage.getItem(Ka(P))||localStorage.setItem(Ka(P),"true"),_.$set=T({},_.$set,{[wv({id:b,current_iteration:C},e===xn.SENT?"responded":"dismissed")]:!0})}else e===xn.SHOWN&&(_.$set=T({},_.$set,{[ks.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===av.SHOWN){var x=n==null?void 0:n[ja.TOUR_TYPE];x&&(_.$set=T({},_.$set,{[ja.TOUR_LAST_SEEN_DATE+"/"+x]:new Date().toISOString()}))}var S=T({},_.properties.$set,_.$set);if(Bt(S)||this.setPersonPropertiesForFlags(S),!G(this.config.before_send)){var k=this.ji(_);if(!k)return;_=k}this.mi.emit("eventCaptured",_);var w={method:"POST",url:(s=r==null?void 0:r._url)!==null&&s!==void 0?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:_,compression:"best-available",batchKey:r==null?void 0:r._batchKey};return!this.config.request_batching||r&&(r==null||!r._batchKey)||r!=null&&r.send_instantly?this.Ri(w):this.ki.enqueue(w),_}R.critical("This capture call is ignored due to client rate limiting.")}}else R.error("No event name provided to posthog.capture")}else R.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",n=>e(n.event,n))}calculateEventProperties(e,n,r,s,i){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return n;var o=i?void 0:this.persistence.remove_event_timer(e),a=T({},n);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,(this.config.cookieless_mode==Le||this.config.cookieless_mode==Ve&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),e==="$snapshot"){var l=T({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!fe(a.distinct_id)&&!We(a.distinct_id)||hr(a.distinct_id))&&R.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=function(m,b){var C,x,S,k;if(!Ie)return{};var w,E,I,A,j,F,H,B,K=m?[...tn,...b||[]]:[],[Z,N]=function(z){for(var ee=0;Sa.length>ee;ee++){var[V,le]=Sa[ee],D=V.exec(z),y=D&&(Ke(le)?le(D,z):le);if(y)return y}return["",""]}(Ie);return ce(so({$os:Z,$os_version:N,$browser:cu(Ie,navigator.vendor),$device:ka(Ie),$device_type:(E=Ie,I={userAgentDataPlatform:(C=navigator)==null||(C=C.userAgentData)==null?void 0:C.platform,maxTouchPoints:(x=navigator)==null?void 0:x.maxTouchPoints,screenWidth:v==null||(S=v.screen)==null?void 0:S.width,screenHeight:v==null||(k=v.screen)==null?void 0:k.height,devicePixelRatio:v==null?void 0:v.devicePixelRatio},B=ka(E),B===Kc||B===Yc||B==="Kobo"||B==="Kindle Fire"||B===lu?Zt:B===Fn||B===Gt||B===Nn||B===ai?"Console":B===Xc?"Wearable":B?Oe:(I==null?void 0:I.userAgentDataPlatform)==="Android"&&((A=I==null?void 0:I.maxTouchPoints)!==null&&A!==void 0?A:0)>0?600>Math.min((j=I==null?void 0:I.screenWidth)!==null&&j!==void 0?j:0,(F=I==null?void 0:I.screenHeight)!==null&&F!==void 0?F:0)/((H=I==null?void 0:I.devicePixelRatio)!==null&&H!==void 0?H:1)?Oe:Zt:"Desktop"),$timezone:Tu(),$timezone_offset:iv()}),{$current_url:Mn(ve==null?void 0:ve.href,K,Dn),$host:ve==null?void 0:ve.host,$pathname:ve==null?void 0:ve.pathname,$raw_user_agent:Ie.length>1e3?Ie.substring(0,997)+"...":Ie,$browser_version:Eg(Ie,navigator.vendor),$browser_language:La(),$browser_language_prefix:(w=La(),typeof w=="string"?w.split("-")[0]:void 0),$screen_height:v==null?void 0:v.screen.height,$screen_width:v==null?void 0:v.screen.width,$viewport_height:v==null?void 0:v.innerHeight,$viewport_width:v==null?void 0:v.innerWidth,$lib:Ce.LIB_NAME,$lib_version:Ce.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:d,windowId:p}=this.sessionManager.checkAndGetSessionAndWindowId(i,r.getTime());a.$session_id=d,a.$window_id=p}this.sessionPropsManager&&ce(a,this.sessionPropsManager.getSessionProps());try{var f;this.sessionRecording&&ce(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(f=this.Pi)==null?void 0:f.length}catch(m){a.$sdk_debug_error_capturing_properties=String(m)}if(this.requestRouter.region===Ii&&(a.$lib_custom_api_host=this.config.api_host),c=e!==Ut||i?e!==ms||i?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,s),a=ce(a,c),e===Ut&&$&&(a.title=$.title),!O(o)){var g=r.getTime()-o;a.$duration=parseFloat((g/1e3).toFixed(3))}Ie&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=ce({},u,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),Y(this.config.property_denylist)?te(this.config.property_denylist,function(m){delete a[m]}):R.error(Lu+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var _=this.config.sanitize_properties;_&&(R.error(Xa),a=_(a,e));var P=this.zi();return a.$process_person_profile=P,P&&!i&&this.Bi("_calculate_event_properties"),a}Ni(e,n,r){var s;if(n===void 0&&(n=!0),r===void 0&&(r=!1),!this.persistence||!this.zi()||this.gi&&!r)return e;var i=this.persistence.get_initial_props(),o=(s=this.sessionPropsManager)==null?void 0:s.getSetOnceProps(),a=ce({},i,o||{},e||{}),l=this.config.sanitize_properties;return l&&(R.error(Xa),a=l(a,"$set_once")),n&&(this.gi=!0),Bt(a)?void 0:a}register(e,n){var r;(r=this.persistence)==null||r.register(e,n)}register_once(e,n,r){var s;(s=this.persistence)==null||s.register_once(e,n,r)}register_for_session(e){var n;(n=this.sessionPersistence)==null||n.register(e)}unregister(e){var n;(n=this.persistence)==null||n.unregister(e)}unregister_for_session(e){var n;(n=this.sessionPersistence)==null||n.unregister(e)}Hi(e,n){this.register({[e]:n})}getFeatureFlag(e,n){var r;return(r=this.featureFlags)==null?void 0:r.getFeatureFlag(e,n)}getFeatureFlagPayload(e){var n;return(n=this.featureFlags)==null?void 0:n.getFeatureFlagPayload(e)}getFeatureFlagResult(e,n){var r;return(r=this.featureFlags)==null?void 0:r.getFeatureFlagResult(e,n)}isFeatureEnabled(e,n){var r;return(r=this.featureFlags)==null?void 0:r.isFeatureEnabled(e,n)}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,n,r){var s;(s=this.featureFlags)==null||s.updateFlags(e,n,r)}updateEarlyAccessFeatureEnrollment(e,n,r){var s;(s=this.featureFlags)==null||s.updateEarlyAccessFeatureEnrollment(e,n,r)}getEarlyAccessFeatures(e,n,r){var s;return n===void 0&&(n=!1),(s=this.featureFlags)==null?void 0:s.getEarlyAccessFeatures(e,n,r)}on(e,n){return this.mi.on(e,n)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:_n}),()=>{})}onSessionId(e){var n,r;return(n=(r=this.sessionManager)==null?void 0:r.onSessionId(e))!==null&&n!==void 0?n:()=>{}}getSurveys(e,n){n===void 0&&(n=!1),this.surveys?this.surveys.getSurveys(e,n):e([],{isLoaded:!1,error:_n})}getActiveMatchingSurveys(e,n){n===void 0&&(n=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,n):e([],{isLoaded:!1,error:_n})}renderSurvey(e,n){var r;(r=this.surveys)==null||r.renderSurvey(e,n)}displaySurvey(e,n){var r;n===void 0&&(n=kv),(r=this.surveys)==null||r.displaySurvey(e,n)}cancelPendingSurvey(e){var n;(n=this.surveys)==null||n.cancelPendingSurvey(e)}canRenderSurvey(e){var n,r;return(n=(r=this.surveys)==null?void 0:r.canRenderSurvey(e))!==null&&n!==void 0?n:{visible:!1,disabledReason:_n}}canRenderSurveyAsync(e,n){var r,s;return n===void 0&&(n=!1),(r=(s=this.surveys)==null?void 0:s.canRenderSurveyAsync(e,n))!==null&&r!==void 0?r:Promise.resolve({visible:!1,disabledReason:_n})}qi(e){return!e||hr(e)?(R.critical("Unique user id has not been set in posthog.identify"),!1):e===Zn?(R.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(e.toLowerCase())&&!["undefined","null"].includes(e.toLowerCase())||(R.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(e,n,r){if(!this.__loaded||!this.persistence)return R.uninitializedWarning("posthog.identify");if(We(e)&&(e=e.toString(),R.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.qi(e)&&this.Bi("posthog.identify")){var s=this.get_distinct_id();this.register({$user_id:e}),this.get_property(kr)||this.register_once({$had_persisted_distinct_id:!0,$device_id:s},""),e!==s&&e!==this.get_property(En)&&(this.unregister(En),this.register({distinct_id:e}));var i,o=(this.persistence.get_property(Me)||Nt)===Nt;e!==s&&o?(this.persistence.set_property(Me,Mt),this.setPersonPropertiesForFlags(T({},r||{},n||{}),!1),this.capture(ys,{distinct_id:e,$anon_distinct_id:s},{$set:n||{},$set_once:r||{}}),this.Ei=Va(e,n,r),(i=this.featureFlags)==null||i.setAnonymousDistinctId(s)):(n||r)&&this.setPersonProperties(n,r),e!==s&&(this.reloadFeatureFlags(),this.unregister(Tn))}}setPersonProperties(e,n){if((e||n)&&this.Bi("posthog.setPersonProperties")){var r=Va(this.get_distinct_id(),e,n);this.Ei!==r?(this.setPersonPropertiesForFlags(T({},n||{},e||{})),this.capture("$set",{$set:e||{},$set_once:n||{}}),this.Ei=r):R.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,n,r){if(e&&n){var s=this.getGroups();s[e]!==n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:T({},s,{[e]:n})}),r&&(this.capture(Aa,{$group_type:e,$group_key:n,$group_set:r}),this.setGroupPropertiesForFlags({[e]:r})),s[e]===n||r||this.reloadFeatureFlags()}else R.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,n){var r;n===void 0&&(n=!0),(r=this.featureFlags)==null||r.setPersonPropertiesForFlags(e,n)}resetPersonPropertiesForFlags(){var e;(e=this.featureFlags)==null||e.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,n){var r;n===void 0&&(n=!0),this.Bi("posthog.setGroupPropertiesForFlags")&&((r=this.featureFlags)==null||r.setGroupPropertiesForFlags(e,n))}resetGroupPropertiesForFlags(e){var n;(n=this.featureFlags)==null||n.resetGroupPropertiesForFlags(e)}reset(e){var n,r,s,i,o,a,l;if(R.info("reset"),!this.__loaded)return R.uninitializedWarning("posthog.reset");var c=this.get_property(kr);if(this.consent.reset(),(n=this.persistence)==null||n.clear(),(r=this.sessionPersistence)==null||r.clear(),(s=this.surveys)==null||s.reset(),(i=this.Di)==null||i.stop(),(o=this.featureFlags)==null||o.reset(),(a=this.persistence)==null||a.set_property(Me,Nt),(l=this.sessionManager)==null||l.resetSessionId(),this.Ei=null,this.config.cookieless_mode===Le)this.register_once({distinct_id:Zn,$device_id:null},"");else{var u=this.config.get_device_id(ht());this.register_once({distinct_id:u,$device_id:e?u:c},"")}this.register({$last_posthog_reset:new Date().toISOString()},1),this.reloadFeatureFlags()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,n;return(e=(n=this.sessionManager)==null?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:n,sessionStartTimestamp:r}=this.sessionManager.checkAndGetSessionAndWindowId(!0),s=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+n);if(e!=null&&e.withTimestamp&&r){var i,o=(i=e.timestampLookBack)!==null&&i!==void 0?i:10;if(!r)return s;s+="?t="+Math.max(Math.floor((new Date().getTime()-r)/1e3)-o,0)}return s}alias(e,n){return e===this.get_property(pu)?(R.critical("Attempting to create alias for existing People user - aborting."),-2):this.Bi("posthog.alias")?(O(n)&&(n=this.get_distinct_id()),e!==n?(this.Hi(En,e),this.capture("$create_alias",{alias:e,distinct_id:n})):(R.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var n=T({},this.config);if(_e(e)){var r,s,i,o,a,l,c,u,d;ce(this.config,Qa(e));var p=this.$i();(r=this.persistence)==null||r.update_config(this.config,n,p),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new ws(T({},this.config,{persistence:"sessionStorage"}),p);var f=this.Si(this.config.debug);Xe(f)&&(this.config.debug=f),Xe(this.config.debug)&&(this.config.debug?(Ce.DEBUG=!0,se.F()&&se.L("ph_debug",!0),R.info("set_config",{config:e,oldConfig:n,newConfig:T({},this.config)})):(Ce.DEBUG=!1,se.F()&&se.U("ph_debug"))),(s=this.exceptionObserver)==null||s.onConfigChange(),(i=this.sessionRecording)==null||i.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(a=this.heatmaps)==null||a.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),(c=this.deadClicksAutocapture)==null||c.startIfEnabledOrStop(),(u=this.surveys)==null||u.loadIfEnabled(),this.Wi(),(d=this.externalIntegrations)==null||d.startIfEnabledOrStop()}}_overrideSDKInfo(e,n){Ce.LIB_NAME=e,Ce.LIB_VERSION=n}startSessionRecording(e){var n,r,s,i,o,a=e===!0,l={sampling:a||!(e==null||!e.sampling),linked_flag:a||!(e==null||!e.linked_flag),url_trigger:a||!(e==null||!e.url_trigger),event_trigger:a||!(e==null||!e.event_trigger)};Object.values(l).some(Boolean)&&((n=this.sessionManager)==null||n.checkAndGetSessionAndWindowId(),l.sampling&&((r=this.sessionRecording)==null||r.overrideSampling()),l.linked_flag&&((s=this.sessionRecording)==null||s.overrideLinkedFlag()),l.url_trigger&&((i=this.sessionRecording)==null||i.overrideTrigger("url")),l.event_trigger&&((o=this.sessionRecording)==null||o.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,n){if(this.exceptions){var r=new Error("PostHog syntheticException"),s=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(T({},s,n))}}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var n,r;return(n=(r=this.toolbar)==null?void 0:r.loadToolbar(e))!==null&&n!==void 0&&n}get_property(e){var n;return(n=this.persistence)==null?void 0:n.props[e]}getSessionProperty(e){var n;return(n=this.sessionPersistence)==null?void 0:n.props[e]}toString(){var e,n=(e=this.config.name)!==null&&e!==void 0?e:Ht;return n!==Ht&&(n=Ht+"."+n),n}_isIdentified(){var e,n;return((e=this.persistence)==null?void 0:e.get_property(Me))===Mt||((n=this.sessionPersistence)==null?void 0:n.get_property(Me))===Mt}zi(){var e,n;return!(this.config.person_profiles==="never"||this.config.person_profiles===bi&&!this._isIdentified()&&Bt(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[En])&&((n=this.persistence)==null||(n=n.props)==null||!n[Pr]))}Li(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.zi()||this.Bi("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Bi("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Bi(e){return this.config.person_profiles==="never"?(R.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Hi(Pr,!0),!0)}$i(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==Ve)}Wi(){var e,n,r,s,i=this.$i();return((e=this.persistence)==null?void 0:e.st)!==i&&((r=this.persistence)==null||r.set_disabled(i)),((n=this.sessionPersistence)==null?void 0:n.st)!==i&&((s=this.sessionPersistence)==null||s.set_disabled(i)),i}opt_in_capturing(e){var n;if(this.config.cookieless_mode!==Le){if(this.config.cookieless_mode===Ve&&this.consent.isExplicitlyOptedOut()){var r,s,i,o,a;this.reset(!0),(r=this.sessionManager)==null||r.destroy(),(s=this.pageViewManager)==null||s.destroy(),this.sessionManager=new Ga(this),this.pageViewManager=new Da(this),this.persistence&&(this.sessionPropsManager=new qa(this,this.sessionManager,this.persistence));var l=(i=(o=this.config.__extensionClasses)==null?void 0:o.sessionRecording)!==null&&i!==void 0?i:(a=Be.__defaultExtensionClasses)==null?void 0:a.sessionRecording;l&&(this.sessionRecording=this.fi(this.sessionRecording,new l(this)))}var c,u;this.consent.optInOut(!0),this.Wi(),this.Ai(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==Ve&&((c=this.surveys)==null||c.loadIfEnabled()),(O(e==null?void 0:e.captureEventName)||e!=null&&e.captureEventName)&&this.capture((u=e==null?void 0:e.captureEventName)!==null&&u!==void 0?u:"$opt_in",e==null?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Mi()}else R.warn(Ja)}opt_out_capturing(){var e,n,r;this.config.cookieless_mode!==Le?(this.config.cookieless_mode===Ve&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.Wi(),this.config.cookieless_mode===Ve&&(this.register({distinct_id:Zn,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(n=this.pageViewManager)==null||n.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(r=this.sessionRecording)==null||r.stopRecording(),this.sessionRecording=void 0,this.Mi())):R.warn(Ja)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===1?"granted":e===0?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===Le||(this.config.cookieless_mode===Ve?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.Wi()}_is_bot(){return Re?Nu(Re,this.config.custom_blocked_useragents):void 0}Mi(){$&&($.visibilityState==="visible"?this.bi||(this.bi=!0,this.capture(Ut,{title:$.title},{send_instantly:!0}),this.yi&&($.removeEventListener(Cr,this.yi),this.yi=null)):this.yi||(this.yi=this.Mi.bind(this),he($,Cr,this.yi)))}debug(e){e===!1?(v==null||v.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(v==null||v.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}bt(){var e,n,r,s,i,o,a=this.xi||{};return"advanced_disable_flags"in a?!!a.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(R.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(r="advanced_disable_decide",s=R,i=(n="advanced_disable_flags")in(e=a)&&!G(e[n]),o=r in e&&!G(e[r]),i?e[n]:!!o&&(s&&s.warn("Config field '"+r+"' is deprecated. Please use '"+n+"' instead. The old field will be removed in a future major version."),e[r]))}ji(e){if(G(this.config.before_send))return e;var n=Y(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var s of n){if(r=s(r),G(r)){var i="Event '"+e.event+"' was rejected in beforeSend function";return cg(e.event)?R.warn(i+". This can cause unexpected behavior."):R.info(i),null}r.properties&&!Bt(r.properties)||R.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return r}getPageViewId(){var e;return(e=this.pageViewManager.K)==null?void 0:e.pageViewId}captureTraceFeedback(e,n){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:n})}captureTraceMetric(e,n,r){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:n,$ai_metric_value:String(r)})}Si(e){var n=Xe(e)&&!e,r=se.F()&&se.M("ph_debug")==="true";return!n&&(!!r||e)}}function el(t){return t instanceof Element&&(t.id===gu||!(t.closest==null||!t.closest(".toolbar-global-fade-container")))}function ns(t){return!!t&&t.nodeType===1}function ft(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function Uu(t){return!!t&&t.nodeType===3}function Hu(t){return!!t&&t.nodeType===11}function lo(t){return t?es(t).split(/\s+/):[]}function tl(t){var e=v==null?void 0:v.location.href;return!!(e&&t&&t.some(n=>e.match(n)))}function jr(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 lo(e)}function Bu(t){return G(t)?null:es(t).split(/(\s+)/).filter(e=>$n(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ln(t){var e="";return $i(t)&&!Wu(t)&&t.childNodes&&t.childNodes.length&&te(t.childNodes,function(n){var r;Uu(n)&&n.textContent&&(e+=(r=Bu(n.textContent))!==null&&r!==void 0?r:"")}),es(e)}function nl(t){return O(t.target)?t.srcElement||null:(e=t.target)!=null&&e.shadowRoot?t.composedPath()[0]||null:t.target||null;var e}Be.__defaultExtensionClasses={},function(t,e){for(var n=0;e.length>n;n++)t.prototype[e[n]]=Wg(t.prototype[e[n]])}(Be,["identify"]);var co=["a","button","form","input","select","textarea","label"];function rl(t,e){if(O(e))return!0;var n,r=function(i){if(e.some(o=>i.matches(o)))return{v:!0}};for(var s of t)if(n=r(s))return n.v;return!1}function zu(t){var e=t.parentNode;return!(!e||!ns(e))&&e}var $v=["next","previous","prev",">","<"],sl=[".ph-no-rageclick",".ph-no-capture"],Ci=t=>!t||ft(t,"html")||!ns(t),il=(t,e)=>{if(!v||Ci(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var n=!1,r=[t],s=t;s.parentNode&&!ft(s,"body");)if(Hu(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var i=zu(s);if(!i)break;if(e||co.indexOf(i.tagName.toLowerCase())>-1)n=!0;else{var o=v.getComputedStyle(i);o&&o.getPropertyValue("cursor")==="pointer"&&(n=!0)}r.push(i),s=i}return{parentIsUsefulElement:n,targetElementList:r}};function $i(t){for(var e=t;e.parentNode&&!ft(e,"body");e=e.parentNode){var n=jr(e);if(q(n,"ph-sensitive")||q(n,"ph-no-capture"))return!1}if(q(jr(t),"ph-include"))return!0;var r=t.type||"";if(fe(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=t.name||t.id||"";return!fe(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 Wu(t){return!!(ft(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||ft(t,"select")||ft(t,"textarea")||t.getAttribute("contenteditable")==="true")}var qu="(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})",Rv=new RegExp("^(?:"+qu+")$"),Ov=new RegExp(qu),Gu="\\d{3}-?\\d{2}-?\\d{4}",Av=new RegExp("^("+Gu+")$"),Fv=new RegExp("("+Gu+")");function $n(t,e){return e===void 0&&(e=!0),!(G(t)||fe(t)&&(t=es(t),(e?Rv:Ov).test((t||"").replace(/[- ]/g,""))||(e?Av:Fv).test(t)))}function ol(t){var e=Ln(t);return $n(e=(e+" "+Vu(t)).trim())?e:""}function Vu(t){var e="";return t&&t.childNodes&&t.childNodes.length&&te(t.childNodes,function(n){var r;if(n&&((r=n.tagName)==null?void 0:r.toLowerCase())==="span")try{var s=Ln(n);e=(e+" "+s).trim(),n.childNodes&&n.childNodes.length&&(e=(e+" "+Vu(n)).trim())}catch(i){R.error("[AutoCapture]",i)}}),e}function al(t){return t.replace(/"|\\"/g,'\\"')}function Nv(t){var e=t.attr__class;return e?Y(e)?e:lo(e):void 0}class ll{constructor(e){this.disabled=e===!1;var n=_e(e)?e:{};this.thresholdPx=n.threshold_px||30,this.timeoutMs=n.timeout_ms||1e3,this.clickCount=n.click_count||3,this.clicks=[]}isRageClick(e,n,r){if(this.disabled)return!1;var s=this.clicks[this.clicks.length-1];if(s&&Math.abs(e-s.x)+Math.abs(n-s.y)<this.thresholdPx&&this.timeoutMs>r-s.timestamp){if(this.clicks.push({x:e,y:n,timestamp:r}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:n,timestamp:r}];return!1}}var $s="$copy_autocapture",cl=oe("[AutoCapture]");function Rs(t,e){return e.length>t?e.slice(0,t)+"...":e}function Mv(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do e=e.previousSibling;while(e&&!ns(e));return e}function Dv(t,e){for(var n,r,{e:s,maskAllElementAttributes:i,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e,c=[t],u=t;u.parentNode&&!ft(u,"body");)Hu(u.parentNode)?(c.push(u.parentNode.host),u=u.parentNode.host):(c.push(u.parentNode),u=u.parentNode);var d,p,f=[],g={},_=!1,P=!1;if(te(c,S=>{var k=$i(S);S.tagName.toLowerCase()==="a"&&(_=S.getAttribute("href"),_=k&&_&&$n(_)&&_),q(jr(S),"ph-no-capture")&&(P=!0),f.push(function(E,I,A,j){var F=E.tagName.toLowerCase(),H={tag_name:F};co.indexOf(F)>-1&&!A&&(H.$el_text=F.toLowerCase()==="a"||F.toLowerCase()==="button"?Rs(1024,ol(E)):Rs(1024,Ln(E)));var B=jr(E);B.length>0&&(H.classes=B.filter(function(z){return z!==""})),te(E.attributes,function(z){var ee;if((!Wu(E)||["name","id","class","aria-label"].indexOf(z.name)!==-1)&&(j==null||!j.includes(z.name))&&!I&&$n(z.value)&&(!fe(ee=z.name)||ee.substring(0,10)!=="_ngcontent"&&ee.substring(0,7)!=="_nghost")){var V=z.value;z.name==="class"&&(V=lo(V).join(" ")),H["attr__"+z.name]=Rs(1024,V)}});for(var K=1,Z=1,N=E;N=Mv(N);)K++,N.tagName===E.tagName&&Z++;return H.nth_child=K,H.nth_of_type=Z,H}(S,i,o,a));var w=function(E){if(!$i(E))return{};var I={};return te(E.attributes,function(A){if(A.name&&A.name.indexOf("data-ph-capture-attribute")===0){var j=A.name.replace("data-ph-capture-attribute-",""),F=A.value;j&&F&&$n(F)&&(I[j]=F)}}),I}(S);ce(g,w)}),P)return{props:{},explicitNoCapture:P};if(o||(f[0].$el_text=t.tagName.toLowerCase()==="a"||t.tagName.toLowerCase()==="button"?ol(t):Ln(t)),_){var m,b;f[0].attr__href=_;var C=(m=Or(_))==null?void 0:m.host,x=v==null||(b=v.location)==null?void 0:b.host;C&&x&&C!==x&&(d=_)}return{props:ce({$event_type:s.type,$ce_version:1},l?{}:{$elements:f},{$elements_chain:(p=f,function(S){return S.map(k=>{var w,E,I="";if(k.tag_name&&(I+=k.tag_name),k.attr_class)for(var A of(k.attr_class.sort(),k.attr_class))I+="."+A.replace(/"/g,"");var j=T({},k.text?{text:k.text}:{},{"nth-child":(w=k.nth_child)!==null&&w!==void 0?w:0,"nth-of-type":(E=k.nth_of_type)!==null&&E!==void 0?E:0},k.href?{href:k.href}:{},k.attr_id?{attr_id:k.attr_id}:{},k.attributes),F={};return pr(j).sort((H,B)=>{var[K]=H,[Z]=B;return K.localeCompare(Z)}).forEach(H=>{var[B,K]=H;return F[al(B.toString())]=al(K.toString())}),(I+=":")+pr(F).map(H=>{var[B,K]=H;return B+'="'+K+'"'}).join("")}).join(";")}(function(S){return S.map(k=>{var w,E,I={text:(w=k.$el_text)==null?void 0:w.slice(0,400),tag_name:k.tag_name,href:(E=k.attr__href)==null?void 0:E.slice(0,2048),attr_class:Nv(k),attr_id:k.attr__id,nth_child:k.nth_child,nth_of_type:k.nth_of_type,attributes:{}};return pr(k).filter(A=>{var[j]=A;return j.indexOf("attr__")===0}).forEach(A=>{var[j,F]=A;return I.attributes[j]=F}),I})}(p)))},(n=f[0])!=null&&n.$el_text?{$el_text:(r=f[0])==null?void 0:r.$el_text}:{},d&&s.type==="click"?{$external_click_url:d}:{},g)}}var gn=oe("[ExceptionAutocapture]");function ul(t,e,n){try{if(!(e in t))return()=>{};var r=t[e],s=n(r);return Ke(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0}})),t[e]=s,()=>{t[e]=r}}catch{return()=>{}}}var Lv=oe("[TracingHeaders]"),at=oe("[Web Vitals]"),dl=9e5,hl="disabled",pl="lazy_loading",vn="awaiting_config",sr="missing_config";oe("[SessionRecording]");var Ri="[SessionRecording]",lt=oe(Ri),jv=oe("[Heatmaps]");function fl(t){return _e(t)&&"clientX"in t&&"clientY"in t&&We(t.clientX)&&We(t.clientY)}var _l=oe("[Product Tours]"),Os="ph_product_tours",Uv=["$set_once","$set"],ct=oe("[SiteApps]"),gl="Error while initializing PostHog app with config id ";function Lt(t,e,n){if(G(t))return!1;switch(n){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{return!1}default:return!1}}class Hv{constructor(e){this.Vi=new ao,this.Yi=(n,r)=>this.Gi(n,r)&&this.Ji(n,r)&&this.Ki(n,r)&&this.Xi(n,r),this.Gi=(n,r)=>r==null||!r.event||(n==null?void 0:n.event)===(r==null?void 0:r.event),this._instance=e,this.Qi=new Set,this.Zi=new Set}init(){var e,n;O((e=this._instance)==null?void 0:e._addCaptureHook)||(n=this._instance)==null||n._addCaptureHook((r,s)=>{this.on(r,s)})}register(e){var n,r;if(!O((n=this._instance)==null?void 0:n._addCaptureHook)&&(e.forEach(o=>{var a,l;(a=this.Zi)==null||a.add(o),(l=o.steps)==null||l.forEach(c=>{var u;(u=this.Qi)==null||u.add((c==null?void 0:c.event)||"")})}),(r=this._instance)!=null&&r.autocapture)){var s,i=new Set;e.forEach(o=>{var a;(a=o.steps)==null||a.forEach(l=>{l!=null&&l.selector&&i.add(l==null?void 0:l.selector)})}),(s=this._instance)==null||s.autocapture.setElementSelectors(i)}}on(e,n){var r;n!=null&&e.length!=0&&(this.Qi.has(e)||this.Qi.has(n==null?void 0:n.event))&&this.Zi&&((r=this.Zi)==null?void 0:r.size)>0&&this.Zi.forEach(s=>{this.te(n,s)&&this.Vi.emit("actionCaptured",s.name)})}ie(e){this.onAction("actionCaptured",n=>e(n))}te(e,n){if((n==null?void 0:n.steps)==null)return!1;for(var r of n.steps)if(this.Yi(e,r))return!0;return!1}onAction(e,n){return this.Vi.on(e,n)}Ji(e,n){if(n!=null&&n.url){var r,s=e==null||(r=e.properties)==null?void 0:r.$current_url;if(!s||typeof s!="string"||!Lt(s,n.url,n.url_matching||"contains"))return!1}return!0}Ki(e,n){return!!this.ee(e,n)&&!!this.re(e,n)&&!!this.se(e,n)}ee(e,n){var r;if(n==null||!n.href)return!0;var s=this.ne(e);if(s.length>0)return s.some(a=>Lt(a.href,n.href,n.href_matching||"exact"));var i,o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!o&&Lt((i=o.match(/(?::|")href="(.*?)"/))?i[1]:"",n.href,n.href_matching||"exact")}re(e,n){var r;if(n==null||!n.text)return!0;var s=this.ne(e);if(s.length>0)return s.some(c=>Lt(c.text,n.text,n.text_matching||"exact")||Lt(c.$el_text,n.text,n.text_matching||"exact"));var i,o,a,l=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!l&&(i=function(c){for(var u,d=[],p=/(?::|")text="(.*?)"/g;!G(u=p.exec(c));)d.includes(u[1])||d.push(u[1]);return d}(l),o=n.text,a=n.text_matching||"exact",i.some(c=>Lt(c,o,a)))}se(e,n){var r,s;if(n==null||!n.selector)return!0;var i=e==null||(r=e.properties)==null?void 0:r.$element_selectors;if(i!=null&&i.includes(n.selector))return!0;var o=(e==null||(s=e.properties)==null?void 0:s.$elements_chain)||"";if(n.selector_regex&&o)try{return new RegExp(n.selector_regex).test(o)}catch{return!1}return!1}ne(e){var n;return(e==null||(n=e.properties)==null?void 0:n.$elements)==null?[]:e==null?void 0:e.properties.$elements}Xi(e,n){return n==null||!n.properties||n.properties.length===0||Du(n.properties.reduce((r,s)=>{var i=Y(s.value)?s.value.map(String):s.value!=null?[String(s.value)]:[];return r[s.key]={values:i,operator:s.operator||"exact"},r},{}),e==null?void 0:e.properties)}}class Bv{constructor(e){this._instance=e,this.oe=new Map,this.ae=new Map,this.le=new Map}ue(e,n){return!!e&&Du(e.propertyFilters,n==null?void 0:n.properties)}he(e,n){var r=new Map;return e.forEach(s=>{var i;(i=s.conditions)==null||(i=i[n])==null||(i=i.values)==null||i.forEach(o=>{if(o!=null&&o.name){var a=r.get(o.name)||[];a.push(s.id),r.set(o.name,a)}})}),r}de(e,n,r){var s=(r===dn.Activation?this.oe:this.ae).get(e),i=[];return this.ve(o=>{i=o.filter(a=>s==null?void 0:s.includes(a.id))}),i.filter(o=>{var a,l=(a=o.conditions)==null||(a=a[r])==null||(a=a.values)==null?void 0:a.find(c=>c.name===e);return this.ue(l,n)})}register(e){var n;O((n=this._instance)==null?void 0:n._addCaptureHook)||(this.ce(e),this.fe(e))}fe(e){var n=e.filter(r=>{var s,i;return((s=r.conditions)==null?void 0:s.actions)&&((i=r.conditions)==null||(i=i.actions)==null||(i=i.values)==null?void 0:i.length)>0});n.length!==0&&(this.pe==null&&(this.pe=new Hv(this._instance),this.pe.init(),this.pe.ie(r=>{this.onAction(r)})),n.forEach(r=>{var s,i,o,a,l;r.conditions&&(s=r.conditions)!=null&&s.actions&&(i=r.conditions)!=null&&(i=i.actions)!=null&&i.values&&((o=r.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((a=this.pe)==null||a.register(r.conditions.actions.values),(l=r.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach(c=>{if(c&&c.name){var u=this.le.get(c.name);u&&u.push(r.id),this.le.set(c.name,u||[r.id])}}))}))}ce(e){var n,r=e.filter(i=>{var o,a;return((o=i.conditions)==null?void 0:o.events)&&((a=i.conditions)==null||(a=a.events)==null||(a=a.values)==null?void 0:a.length)>0}),s=e.filter(i=>{var o,a;return((o=i.conditions)==null?void 0:o.cancelEvents)&&((a=i.conditions)==null||(a=a.cancelEvents)==null||(a=a.values)==null?void 0:a.length)>0});r.length===0&&s.length===0||((n=this._instance)==null||n._addCaptureHook((i,o)=>{this.onEvent(i,o)}),this.oe=this.he(e,dn.Activation),this.ae=this.he(e,dn.Cancellation))}onEvent(e,n){var r,s=this._e(),i=this.ge(),o=this.me(),a=((r=this._instance)==null||(r=r.persistence)==null?void 0:r.props[i])||[];if(o===e&&n&&a.length>0){var l,c;s.info("event matched, removing item from activated items",{event:e,eventPayload:n,existingActivatedItems:a});var u=(n==null||(l=n.properties)==null?void 0:l.$survey_id)||(n==null||(c=n.properties)==null?void 0:c.$product_tour_id);if(u){var d=a.indexOf(u);0>d||(a.splice(d,1),this.be(a))}}else{if(this.ae.has(e)){var p=this.de(e,n,dn.Cancellation);p.length>0&&(s.info("cancel event matched, cancelling items",{event:e,itemsToCancel:p.map(g=>g.id)}),p.forEach(g=>{var _=a.indexOf(g.id);0>_||a.splice(_,1),this.ye(g.id)}),this.be(a))}if(this.oe.has(e)){s.info("event name matched",{event:e,eventPayload:n,items:this.oe.get(e)});var f=this.de(e,n,dn.Activation);this.be(a.concat(f.map(g=>g.id)||[]))}}}onAction(e){var n,r=this.ge(),s=((n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[r])||[];this.le.has(e)&&this.be(s.concat(this.le.get(e)||[]))}be(e){var n,r=this._e(),s=this.ge(),i=[...new Set(e)].filter(o=>!this.we(o));r.info("updating activated items",{activatedItems:i}),(n=this._instance)==null||(n=n.persistence)==null||n.register({[s]:i})}getActivatedIds(){var e,n=this.ge();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[n])||[]}getEventToItemsMap(){return this.oe}Ee(){return this.pe}}class zv extends Bv{constructor(e){super(e)}ge(){return"$surveys_activated"}me(){return xn.SHOWN}ve(e){var n;(n=this._instance)==null||n.getSurveys(e)}ye(e){var n;(n=this._instance)==null||n.cancelPendingSurvey(e)}_e(){return Q}we(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var As="SDK is not enabled or survey functionality is not yet loaded",vl="Disabled. Not loading surveys.",Wv=v!=null&&v.location?Fr(v.location.hash,"__posthog")||Fr(location.hash,"state"):null,ml="_postHogToolbarParams",yl=oe("[Toolbar]"),we=oe("[FeatureFlags]"),Et=oe("[FeatureFlags]",{debugEnabled:!0}),Fs=`" failed. Feature flags didn't load in time.`,Ns="$active_feature_flags",ut="$override_feature_flags",bl="$feature_flag_payloads",mn="$override_feature_flag_payloads",El="$feature_flag_request_id",wl=t=>{for(var e={},n=0;t.length>n;n++)e[t[n]]=!0;return e},Sl=t=>{var e={};for(var[n,r]of pr(t||{}))r&&(e[n]=r);return e},Ms=oe("[Error tracking]"),kl="Refusing to render web experiment since the viewer is a likely bot",qv={icontains:(t,e)=>!!v&&e.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>!!v&&e.href.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>!!v&&Lr(e.href,t),not_regex:(t,e)=>!!v&&!Lr(e.href,t),exact:(t,e)=>e.href===t,is_not:(t,e)=>e.href!==t};class be{get N(){return this._instance.config}constructor(e){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(r){r===void 0&&(r=!1),n.getWebExperiments(s=>{be.Se("retrieved web experiments from the server"),n.xe=new Map,s.forEach(i=>{if(i.feature_flag_key){var o;n.xe&&(be.Se("setting flag key ",i.feature_flag_key," to web experiment ",i),(o=n.xe)==null||o.set(i.feature_flag_key,i));var a=n._instance.getFeatureFlag(i.feature_flag_key);fe(a)&&i.variants[a]&&n.Te(i.name,a,i.variants[a].transforms)}else if(i.variants)for(var l in i.variants){var c=i.variants[l];be.$e(c)&&n.Te(i.name,l,c.transforms)}})},r)},this._instance=e,this._instance.onFeatureFlags(r=>{this.onFeatureFlags(r)})}initialize(){}onFeatureFlags(e){if(this._is_bot())be.Se(kl);else if(!this.N.disable_web_experiments){if(G(this.xe))return this.xe=new Map,this.loadIfEnabled(),void this.previewWebExperiment();be.Se("applying feature flags",e),e.forEach(n=>{var r;if(this.xe&&(r=this.xe)!=null&&r.has(n)){var s,i=this._instance.getFeatureFlag(n),o=(s=this.xe)==null?void 0:s.get(n);i&&o!=null&&o.variants[i]&&this.Te(o.name,i,o.variants[i].transforms)}})}}previewWebExperiment(){var e=be.getWindowLocation();if(e!=null&&e.search){var n=Ar(e==null?void 0:e.search,"__experiment_id"),r=Ar(e==null?void 0:e.search,"__experiment_variant");n&&r&&(be.Se("previewing web experiments "+n+" && "+r),this.getWebExperiments(s=>{this.ke(parseInt(n),r,s)},!1,!0))}}loadIfEnabled(){this.N.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,n,r){if(this.N.disable_web_experiments&&!r)return e([]);var s=this._instance.get_property("$web_experiments");if(s&&!n)return e(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.N.token),method:"GET",callback:i=>e(i.statusCode===200&&i.json&&i.json.experiments||[])})}ke(e,n,r){var s=r.filter(i=>i.id===e);s&&s.length>0&&(be.Se("Previewing web experiment ["+s[0].name+"] with variant ["+n+"]"),this.Te(s[0].name,n,s[0].variants[n].transforms))}static $e(e){return!G(e.conditions)&&be.Re(e)&&be.Pe(e)}static Re(e){var n;if(G(e.conditions)||G((n=e.conditions)==null?void 0:n.url))return!0;var r,s,i,o=be.getWindowLocation();return!!o&&((r=e.conditions)==null||!r.url||qv[(s=(i=e.conditions)==null?void 0:i.urlMatchType)!==null&&s!==void 0?s:"icontains"](e.conditions.url,o))}static getWindowLocation(){return v==null?void 0:v.location}static Pe(e){var n;if(G(e.conditions)||G((n=e.conditions)==null?void 0:n.utm))return!0;var r=Eu();if(r.utm_source){var s,i,o,a,l,c,u,d,p=(s=e.conditions)==null||(s=s.utm)==null||!s.utm_campaign||((i=e.conditions)==null||(i=i.utm)==null?void 0:i.utm_campaign)==r.utm_campaign,f=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==r.utm_source,g=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==r.utm_medium,_=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_term||((d=e.conditions)==null||(d=d.utm)==null?void 0:d.utm_term)==r.utm_term;return p&&g&&_&&f}return!1}static Se(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;n>s;s++)r[s-1]=arguments[s];R.info("[WebExperiments] "+e,r)}Te(e,n,r){this._is_bot()?be.Se(kl):n!=="control"?r.forEach(s=>{if(s.selector){var i;be.Se("applying transform of variant "+n+" for experiment "+e+" ",s);var o=(i=document)==null?void 0:i.querySelectorAll(s.selector);o==null||o.forEach(a=>{var l=a;s.html&&(l.innerHTML=s.html),s.css&&l.setAttribute("style",s.css)})}}):be.Se("Control variants leave the page unmodified.")}_is_bot(){return Re&&this._instance?Nu(Re,this.N.custom_blocked_useragents):void 0}}var Ae=oe("[Conversations]"),wt="Conversations not available yet.",rs={featureFlags:class{constructor(t){this.Oe=!1,this.Ie=!1,this.Ce=!1,this.Fe=!1,this.Ae=!1,this.Me=!1,this.De=!1,this.Le=!1,this._instance=t,this.featureFlagEventHandlers=[]}get N(){return this._instance.config}get Wt(){return this._instance.persistence}Ue(t){return this._instance.get_property(t)}Ne(){var t,e;return(t=(e=this.Wt)==null?void 0:e.nt(this.N.feature_flag_cache_ttl_ms))!==null&&t!==void 0&&t}je(){return!!this.Ne()&&(this.Le||this.Ce||(this.Le=!0,we.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}ze(){var t,e=(t=this.N.evaluation_contexts)!==null&&t!==void 0?t:this.N.evaluation_environments;return!this.N.evaluation_environments||this.N.evaluation_contexts||this.De||(we.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.De=!0),e!=null&&e.length?e.filter(n=>{var r=n&&typeof n=="string"&&n.trim().length>0;return r||we.error("Invalid evaluation context found:",n,"Expected non-empty string"),r}):[]}Be(){return this.ze().length>0}initialize(){var t,e,{config:n}=this._instance,r=(t=(e=n.bootstrap)==null?void 0:e.featureFlags)!==null&&t!==void 0?t:{};if(Object.keys(r).length){var s,i,o=(s=(i=n.bootstrap)==null?void 0:i.featureFlagPayloads)!==null&&s!==void 0?s:{},a=Object.keys(r).filter(c=>!!r[c]).reduce((c,u)=>(c[u]=r[u]||!1,c),{}),l=Object.keys(o).filter(c=>a[c]).reduce((c,u)=>(o[u]&&(c[u]=o[u]),c),{});this.receivedFeatureFlags({featureFlags:a,featureFlagPayloads:l})}}updateFlags(t,e,n){var r=n!=null&&n.merge?this.getFlagVariants():{},s=n!=null&&n.merge?this.getFlagPayloads():{},i=T({},r,t),o=T({},s,e),a={};for(var[l,c]of Object.entries(i)){var u=typeof c=="string";a[l]={key:l,enabled:!!u||!!c,variant:u?c:void 0,reason:void 0,metadata:O(o==null?void 0:o[l])?void 0:{id:0,version:void 0,description:void 0,payload:o[l]}}}this.receivedFeatureFlags({flags:a})}get hasLoadedFlags(){return this.Ie}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.Ue(hi),e=this.Ue(ut),n=this.Ue(mn);if(!n&&!e)return t||{};var r=ce({},t||{}),s=[...new Set([...Object.keys(n||{}),...Object.keys(e||{})])];for(var i of s){var o,a,l=r[i],c=e==null?void 0:e[i],u=O(c)?(o=l==null?void 0:l.enabled)!==null&&o!==void 0&&o:!!c,d=O(c)?l.variant:typeof c=="string"?c:void 0,p=n==null?void 0:n[i],f=T({},l,{enabled:u,variant:u?d??(l==null?void 0:l.variant):void 0});u!==(l==null?void 0:l.enabled)&&(f.original_enabled=l==null?void 0:l.enabled),d!==(l==null?void 0:l.variant)&&(f.original_variant=l==null?void 0:l.variant),p&&(f.metadata=T({},l==null?void 0:l.metadata,{payload:p,original_payload:l==null||(a=l.metadata)==null?void 0:a.payload})),r[i]=f}return this.Oe||(we.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:n,finalDetails:r}),this.Oe=!0),r}getFlagVariants(){var t=this.Ue(zt),e=this.Ue(ut);if(!e)return t||{};for(var n=ce({},t),r=Object.keys(e),s=0;r.length>s;s++)n[r[s]]=e[r[s]];return this.Oe||(we.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:n}),this.Oe=!0),n}getFlagPayloads(){var t=this.Ue(bl),e=this.Ue(mn);if(!e)return t||{};for(var n=ce({},t||{}),r=Object.keys(e),s=0;r.length>s;s++)n[r[s]]=e[r[s]];return this.Oe||(we.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:n}),this.Oe=!0),n}reloadFeatureFlags(){this.Fe||this.N.advanced_disable_feature_flags||this.He||(this._instance.mi.emit("featureFlagsReloading",!0),this.He=setTimeout(()=>{this.qe()},5))}We(){clearTimeout(this.He),this.He=void 0}ensureFlagsLoaded(){this.Ie||this.Ce||this.He||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.Fe=t}qe(t){var e;if(this.We(),!this._instance.bt())if(this.Ce)this.Ae=!0;else{var n=this.N.token,r=this.Ue(kr),s={token:n,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:T({},((e=this.Wt)==null?void 0:e.get_initial_props())||{},this.Ue(kn)||{}),group_properties:this.Ue(St),timezone:Tu()};rt(r)||O(r)||(s.$device_id=r),(t!=null&&t.disableFlags||this.N.advanced_disable_feature_flags)&&(s.disable_flags=!0),this.Be()&&(s.evaluation_contexts=this.ze());var i=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.N.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.Ce=!0,this._instance._send_request({method:"POST",url:i,data:s,compression:this.N.disable_compression?void 0:Ue.Base64,timeout:this.N.feature_flag_request_timeout_ms,callback:o=>{var a,l,c,u=!0;if(o.statusCode===200&&(this.Ae||(this.$anon_distinct_id=void 0),u=!1),this.Ce=!1,!s.disable_flags||this.Ae){this.Me=!u;var d=[];o.error?o.error instanceof Error?d.push(o.error.name==="AbortError"?"timeout":"connection_error"):d.push("unknown_error"):o.statusCode!==200&&d.push("api_error_"+o.statusCode),(a=o.json)!=null&&a.errorsWhileComputingFlags&&d.push("errors_while_computing_flags");var p,f=!((l=o.json)==null||(l=l.quotaLimited)==null||!l.includes("feature_flags"));f&&d.push("quota_limited"),(c=this.Wt)==null||c.register({[_i]:d}),f?we.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."):(s.disable_flags||this.receivedFeatureFlags((p=o.json)!==null&&p!==void 0?p:{},u),this.Ae&&(this.Ae=!1,this.qe()))}}})}}getFeatureFlag(t,e){var n;if(e===void 0&&(e={}),!e.fresh||this.Me)if(this.Ie||this.getFlags()&&this.getFlags().length>0){if(!this.je()){var r=this.getFeatureFlagResult(t,e);return(n=r==null?void 0:r.variant)!==null&&n!==void 0?n:r==null?void 0:r.enabled}}else we.warn('getFeatureFlag for key "'+t+Fs)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var e=this.getFeatureFlagResult(t,{send_event:!1});return e==null?void 0:e.payload}getFeatureFlagResult(t,e){if(e===void 0&&(e={}),!e.fresh||this.Me)if(this.Ie||this.getFlags()&&this.getFlags().length>0){if(!this.je()){var n=this.getFlagVariants(),r=t in n,s=n[t],i=this.getFlagPayloads()[t],o=String(s),a=this.Ue(El)||void 0,l=this.Ue(Ir)||void 0,c=this.Ue(Tn)||{};if(this.N.advanced_feature_flags_dedup_per_session){var u,d=this._instance.get_session_id(),p=this.Ue(fi);d&&d!==p&&(c={},(u=this.Wt)==null||u.register({[Tn]:c,[fi]:d}))}if((e.send_event||!("send_event"in e))&&(!(t in c)||!c[t].includes(o))){var f,g,_,P,m,b,C,x,S,k;Y(c[t])?c[t].push(o):c[t]=[o],(f=this.Wt)==null||f.register({[Tn]:c});var w=this.getFeatureFlagDetails(t),E=[...(g=this.Ue(_i))!==null&&g!==void 0?g:[]];O(s)&&E.push("flag_missing");var I={$feature_flag:t,$feature_flag_response:s,$feature_flag_payload:i||null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:((_=this.N.bootstrap)==null||(_=_.featureFlags)==null?void 0:_[t])||null,$feature_flag_bootstrapped_payload:((P=this.N.bootstrap)==null||(P=P.featureFlagPayloads)==null?void 0:P[t])||null,$used_bootstrap_value:!this.Me};O(w==null||(m=w.metadata)==null?void 0:m.version)||(I.$feature_flag_version=w.metadata.version);var A,j=(b=w==null||(C=w.reason)==null?void 0:C.description)!==null&&b!==void 0?b:w==null||(x=w.reason)==null?void 0:x.code;j&&(I.$feature_flag_reason=j),w!=null&&(S=w.metadata)!=null&&S.id&&(I.$feature_flag_id=w.metadata.id),O(w==null?void 0:w.original_variant)&&O(w==null?void 0:w.original_enabled)||(I.$feature_flag_original_response=O(w.original_variant)?w.original_enabled:w.original_variant),w!=null&&(k=w.metadata)!=null&&k.original_payload&&(I.$feature_flag_original_payload=w==null||(A=w.metadata)==null?void 0:A.original_payload),E.length&&(I.$feature_flag_error=E.join(",")),this._instance.capture("$feature_flag_called",I)}if(r){var F=i;if(!O(i))try{F=JSON.parse(i)}catch{}return{key:t,enabled:!!s,variant:typeof s=="string"?s:void 0,payload:F}}}}else we.warn('getFeatureFlagResult for key "'+t+Fs)}getRemoteConfigPayload(t,e){var n=this.N.token,r={distinct_id:this._instance.get_distinct_id(),token:n};this.Be()&&(r.evaluation_contexts=this.ze()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this.N.disable_compression?void 0:Ue.Base64,timeout:this.N.feature_flag_request_timeout_ms,callback(s){var i,o=(i=s.json)==null?void 0:i.featureFlagPayloads;e((o==null?void 0:o[t])||void 0)}})}isFeatureEnabled(t,e){if(e===void 0&&(e={}),!e.fresh||this.Me){if(this.Ie||this.getFlags()&&this.getFlags().length>0){var n=this.getFeatureFlag(t,e);return O(n)?void 0:!!n}we.warn('isFeatureEnabled for key "'+t+Fs)}}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(e=>e!==t)}receivedFeatureFlags(t,e){if(this.Wt){this.Ie=!0;var n=this.getFlagVariants(),r=this.getFlagPayloads(),s=this.getFlagsWithDetails();(function(i,o,a,l,c){a===void 0&&(a={}),l===void 0&&(l={}),c===void 0&&(c={});var u=(k=>{var w=k.flags;return w?(k.featureFlags=Object.fromEntries(Object.keys(w).map(E=>{var I;return[E,(I=w[E].variant)!==null&&I!==void 0?I:w[E].enabled]})),k.featureFlagPayloads=Object.fromEntries(Object.keys(w).filter(E=>w[E].enabled).filter(E=>{var I;return(I=w[E].metadata)==null?void 0:I.payload}).map(E=>{var I;return[E,(I=w[E].metadata)==null?void 0:I.payload]}))):we.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),k})(i),d=u.flags,p=u.featureFlags,f=u.featureFlagPayloads;if(p){var g=i.requestId,_=i.evaluatedAt;if(Y(p)){we.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var P={};if(p)for(var m=0;p.length>m;m++)P[p[m]]=!0;o&&o.register({[Ns]:p,[zt]:P})}else{var b=p,C=f,x=d;if(i.errorsWhileComputingFlags)if(d){var S=new Set(Object.keys(d).filter(k=>{var w;return!((w=d[k])!=null&&w.failed)}));b=T({},a,Object.fromEntries(Object.entries(b).filter(k=>{var[w]=k;return S.has(w)}))),C=T({},l,Object.fromEntries(Object.entries(C||{}).filter(k=>{var[w]=k;return S.has(w)}))),x=T({},c,Object.fromEntries(Object.entries(x||{}).filter(k=>{var[w]=k;return S.has(w)})))}else b=T({},a,b),C=T({},l,C),x=T({},c,x);o&&o.register(T({[Ns]:Object.keys(Sl(b)),[zt]:b||{},[bl]:C||{},[hi]:x||{}},g?{[El]:g}:{},_?{[Ir]:_}:{}))}}})(t,this.Wt,n,r,s),e||(this.Le=!1),this.Ve(e)}}override(t,e){e===void 0&&(e=!1),we.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.Wt)return we.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(t===!1)return this.Wt.unregister(ut),this.Wt.unregister(mn),this.Ve(),Et.info("All overrides cleared");if(Y(t)){var e=wl(t);return this.Wt.register({[ut]:e}),this.Ve(),Et.info("Flag overrides set",{flags:t})}if(t&&typeof t=="object"&&("flags"in t||"payloads"in t)){var n,r=t;if(this.Oe=!!((n=r.suppressWarning)!==null&&n!==void 0&&n),"flags"in r){if(r.flags===!1)this.Wt.unregister(ut),Et.info("Flag overrides cleared");else if(r.flags){if(Y(r.flags)){var s=wl(r.flags);this.Wt.register({[ut]:s})}else this.Wt.register({[ut]:r.flags});Et.info("Flag overrides set",{flags:r.flags})}}return"payloads"in r&&(r.payloads===!1?(this.Wt.unregister(mn),Et.info("Payload overrides cleared")):r.payloads&&(this.Wt.register({[mn]:r.payloads}),Et.info("Payload overrides set",{payloads:r.payloads}))),void this.Ve()}if(t&&typeof t=="object")return this.Wt.register({[ut]:t}),this.Ve(),Et.info("Flag overrides set",{flags:t});we.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.Ie){var{flags:e,flagVariants:n}=this.Ye();t(e,n)}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,n){var r,s=(this.Ue(Sn)||[]).find(l=>l.flagKey===t),i={["$feature_enrollment/"+t]:e},o={$feature_flag:t,$feature_enrollment:e,$set:i};s&&(o.$early_access_feature_name=s.name),n&&(o.$feature_enrollment_stage=n),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(i,!1);var a=T({},this.getFlagVariants(),{[t]:e});(r=this.Wt)==null||r.register({[Ns]:Object.keys(Sl(a)),[zt]:a}),this.Ve()}getEarlyAccessFeatures(t,e,n){e===void 0&&(e=!1);var r=this.Ue(Sn),s=n?"&"+n.map(i=>"stage="+i).join("&"):"";if(r&&!e)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.N.token+s),method:"GET",callback:i=>{var o,a;if(i.json){var l=i.json.earlyAccessFeatures;return(o=this.Wt)==null||o.unregister(Sn),(a=this.Wt)==null||a.register({[Sn]:l}),t(l)}}})}Ye(){var t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter(n=>e[n]),flagVariants:Object.keys(e).filter(n=>e[n]).reduce((n,r)=>(n[r]=e[r],n),{})}}Ve(t){var{flags:e,flagVariants:n}=this.Ye();this.featureFlagEventHandlers.forEach(r=>r(e,n,{errorsLoading:t}))}setPersonPropertiesForFlags(t,e){e===void 0&&(e=!0);var n=this.Ue(kn)||{};this._instance.register({[kn]:T({},n,t)}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(kn)}setGroupPropertiesForFlags(t,e){e===void 0&&(e=!0);var n=this.Ue(St)||{};Object.keys(n).length!==0&&Object.keys(n).forEach(r=>{n[r]=T({},n[r],t[r]),delete t[r]}),this._instance.register({[St]:T({},n,t)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.Ue(St)||{};this._instance.register({[St]:T({},e,{[t]:{}})})}else this._instance.unregister(St)}reset(){this.Ie=!1,this.Ce=!1,this.Fe=!1,this.Ae=!1,this.Me=!1,this.$anon_distinct_id=void 0,this.We(),this.Oe=!1}}},Gv={sessionRecording:class{get N(){return this._instance.config}get Wt(){return this._instance.persistence}get started(){var t;return!((t=this.Ge)==null||!t.isStarted)}get status(){var t,e;return this.Je===vn||this.Je===sr?this.Je:(t=(e=this.Ge)==null?void 0:e.status)!==null&&t!==void 0?t:this.Je}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.Je=hl,this.Ke=void 0,this._instance=t,!this._instance.sessionManager)throw lt.error("started without valid sessionManager"),new Error(Ri+" started without valid sessionManager. This is a bug.");if(this.N.cookieless_mode===Le)throw new Error(Ri+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get Xe(){var t,e=!((t=this._instance.get_property(Xn))==null||!t.enabled),n=!this.N.disable_session_recording,r=this.N.disable_session_recording||this._instance.consent.isOptedOut();return v&&e&&n&&!r}startIfEnabledOrStop(t){var e;if(!this.Xe||(e=this.Ge)==null||!e.isStarted){var n=!O(Object.assign)&&!O(Array.from);this.Xe&&n?(this.Qe(t),lt.info("starting")):(this.Je=hl,this.stopRecording())}}Qe(t){var e,n,r;this.Xe&&(this.Je!==vn&&this.Je!==sr&&(this.Je=pl),M!=null&&(e=M.__PosthogExtensions__)!=null&&(e=e.rrweb)!=null&&e.record&&(n=M.__PosthogExtensions__)!=null&&n.initSessionRecording?this.Ze(t):(r=M.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,this.tr,s=>{if(s)return lt.error("could not load recorder",s);this.Ze(t)}))}stopRecording(){var t,e;(t=this.Ke)==null||t.call(this),this.Ke=void 0,(e=this.Ge)==null||e.stop()}ir(){var t,e;(t=this.Ke)==null||t.call(this),this.Ke=void 0,(e=this.Ge)==null||e.discard()}er(){var t;(t=this.Wt)==null||t.unregister(_u)}rr(t,e){if(G(t))return null;var n,r=We(t)?t:parseFloat(t);return typeof(n=r)!="number"||!Number.isFinite(n)||0>n||n>1?(lt.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}sr(t){if(this.Wt){var e,n,r=this.Wt,s=()=>{var i,o=t.sessionRecording===!1?void 0:t.sessionRecording,a=this.rr((i=this.N.session_recording)==null?void 0:i.sampleRate,"session_recording.sampleRate"),l=this.rr(o==null?void 0:o.sampleRate,"remote config sampleRate"),c=a??l;G(c)&&this.er();var u=o==null?void 0:o.minimumDurationMilliseconds;r.register({[Xn]:T({cache_timestamp:Date.now(),enabled:!!o},o,{networkPayloadCapture:T({capturePerformance:t.capturePerformance},o==null?void 0:o.networkPayloadCapture),canvasRecording:{enabled:o==null?void 0:o.recordCanvas,fps:o==null?void 0:o.canvasFps,quality:o==null?void 0:o.canvasQuality},sampleRate:c,minimumDurationMilliseconds:O(u)?null:u,endpoint:o==null?void 0:o.endpoint,triggerMatchType:o==null?void 0:o.triggerMatchType,masking:o==null?void 0:o.masking,urlTriggers:o==null?void 0:o.urlTriggers})})};s(),(e=this.Ke)==null||e.call(this),this.Ke=(n=this._instance.sessionManager)==null?void 0:n.onSessionId(s)}}onRemoteConfig(t){return"sessionRecording"in t?t.sessionRecording===!1?(this.sr(t),void this.ir()):(this.sr(t),void this.startIfEnabledOrStop()):(this.Je===vn&&(this.Je=sr,lt.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e){var n;e===void 0&&(e="log"),(n=this.Ge)!=null&&n.log?this.Ge.log(t,e):lt.warn("log called before recorder was ready")}get tr(){var t,e,n=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.get_property(Xn);return(n==null||(e=n.scriptConfig)==null?void 0:e.script)||"lazy-recorder"}nr(){var t,e=this._instance.get_property(Xn);if(!e)return!1;var n=(t=(typeof e=="object"?e:JSON.parse(e)).cache_timestamp)!==null&&t!==void 0?t:Date.now();return 36e5>=Date.now()-n}Ze(t){var e,n;if((e=M.__PosthogExtensions__)==null||!e.initSessionRecording)return lt.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.Ge||(this.Ge=(n=M.__PosthogExtensions__)==null?void 0:n.initSessionRecording(this._instance),this.Ge._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.nr())return this.Je===sr||this.Je===vn?void 0:(this.Je=vn,lt.info("persisted remote config is stale, requesting fresh config before starting"),void new Pu(this._instance).load());this.Je=pl,this.Ge.start(t)}onRRwebEmit(t){var e;(e=this.Ge)==null||e.onRRwebEmit==null||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.Ge||(e=this.Wt)==null||e.register({$replay_override_linked_flag:!0}),(t=this.Ge)==null||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.Ge||(e=this.Wt)==null||e.register({$replay_override_sampling:!0}),(t=this.Ge)==null||t.overrideSampling()}overrideTrigger(t){var e,n;this.Ge||(n=this.Wt)==null||n.register({[t==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(e=this.Ge)==null||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return((t=this.Ge)==null?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var n;return!((n=this.Ge)==null||!n.tryAddCustomEvent(t,e))}}},Vv={autocapture:class{constructor(t){this.ar=!1,this.lr=null,this.ur=!1,this.instance=t,this.rageclicks=new ll(t.config.rageclick),this.hr=null}initialize(){this.startIfEnabled()}get N(){var t,e,n=_e(this.instance.config.autocapture)?this.instance.config.autocapture:{};return n.url_allowlist=(t=n.url_allowlist)==null?void 0:t.map(r=>new RegExp(r)),n.url_ignorelist=(e=n.url_ignorelist)==null?void 0:e.map(r=>new RegExp(r)),n}dr(){if(this.isBrowserSupported()){if(v&&$){var t=n=>{n=n||(v==null?void 0:v.event);try{this.vr(n)}catch(r){cl.error("Failed to capture event",r)}};if(he($,"submit",t,{capture:!0}),he($,"change",t,{capture:!0}),he($,"click",t,{capture:!0}),this.N.capture_copied_text){var e=n=>{this.vr(n=n||(v==null?void 0:v.event),$s)};he($,"copy",e,{capture:!0}),he($,"cut",e,{capture:!0})}}}else cl.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.ar&&(this.dr(),this.ar=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this.ur=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Ta]:!!t.autocapture_opt_out}),this.lr=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this.hr=t}getElementSelectors(t){var e,n=[];return(e=this.hr)==null||e.forEach(r=>{var s=$==null?void 0:$.querySelectorAll(r);s==null||s.forEach(i=>{t===i&&n.push(r)})}),n}get isEnabled(){var t,e,n=(t=this.instance.persistence)==null?void 0:t.props[Ta];if(rt(this.lr)&&!Xe(n)&&!this.instance.bt())return!1;var r=(e=this.lr)!==null&&e!==void 0?e:!!n;return!!this.instance.config.autocapture&&!r}vr(t,e){if(e===void 0&&(e="$autocapture"),this.isEnabled){var n,r=nl(t);Uu(r)&&(r=r.parentNode||null),e==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&this.instance.config.rageclick&&(n=this.rageclicks)!=null&&n.isRageClick(t.clientX,t.clientY,t.timeStamp||new Date().getTime())&&function(d,p){if(!v||Ci(d))return!1;var f,g,_;if(Xe(p)?(f=!!p&&sl,g=void 0):(f=(_=p==null?void 0:p.css_selector_ignorelist)!==null&&_!==void 0?_:sl,g=p==null?void 0:p.content_ignorelist),f===!1)return!1;var{targetElementList:P}=il(d,!1);return!function(m,b){if(m===!1||O(m))return!1;var C;if(m===!0)C=$v;else{if(!Y(m))return!1;if(m.length>10)return R.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;C=m.map(x=>x.toLowerCase())}return b.some(x=>{var{safeText:S,ariaLabel:k}=x;return C.some(w=>S.includes(w)||k.includes(w))})}(g,P.map(m=>{var b;return{safeText:Ln(m).toLowerCase(),ariaLabel:((b=m.getAttribute("aria-label"))==null?void 0:b.toLowerCase().trim())||""}}))&&!rl(P,f)}(r,this.instance.config.rageclick)&&this.vr(t,"$rageclick");var s=e===$s;if(r&&function(d,p,f,g,_){var P,m,b,C;if(f===void 0&&(f=void 0),!v||Ci(d)||(P=f)!=null&&P.url_allowlist&&!tl(f.url_allowlist)||(m=f)!=null&&m.url_ignorelist&&tl(f.url_ignorelist))return!1;if((b=f)!=null&&b.dom_event_allowlist){var x=f.dom_event_allowlist;if(x&&!x.some(I=>p.type===I))return!1}var{parentIsUsefulElement:S,targetElementList:k}=il(d,g);if(!function(I,A){var j=A==null?void 0:A.element_allowlist;if(O(j))return!0;var F,H=function(K){if(j.some(Z=>K.tagName.toLowerCase()===Z))return{v:!0}};for(var B of I)if(F=H(B))return F.v;return!1}(k,f)||!rl(k,(C=f)==null?void 0:C.css_selector_allowlist))return!1;var w=v.getComputedStyle(d);if(w&&w.getPropertyValue("cursor")==="pointer"&&p.type==="click")return!0;var E=d.tagName.toLowerCase();switch(E){case"html":return!1;case"form":return(_||["submit"]).indexOf(p.type)>=0;case"input":case"select":case"textarea":return(_||["change","click"]).indexOf(p.type)>=0;default:return S?(_||["click"]).indexOf(p.type)>=0:(_||["click"]).indexOf(p.type)>=0&&(co.indexOf(E)>-1||d.getAttribute("contenteditable")==="true")}}(r,t,this.N,s,s?["copy","cut"]:void 0)){var{props:i,explicitNoCapture:o}=Dv(r,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.N.element_attribute_ignorelist,elementsChainAsString:this.ur});if(o)return!1;var a=this.getElementSelectors(r);if(a&&a.length>0&&(i.$element_selectors=a),e===$s){var l,c=Bu(v==null||(l=v.getSelection())==null?void 0:l.toString()),u=t.type||"clipboard";if(!c)return!1;i.$selected_content=c,i.$copy_type=u}return this.instance.capture(e,i),!0}}}isBrowserSupported(){return Ke($==null?void 0:$.querySelectorAll)}},historyAutocapture:class{constructor(t){var e;this._instance=t,this.cr=(v==null||(e=v.location)==null?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(R.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.pr&&this.pr(),this.pr=void 0,R.info("History API monitoring stopped")}monitorHistoryChanges(){var t,e;if(v&&v.history){var n=this;(t=v.history.pushState)!=null&&t.__posthog_wrapped__||ul(v.history,"pushState",r=>function(s,i,o){r.call(this,s,i,o),n._r("pushState")}),(e=v.history.replaceState)!=null&&e.__posthog_wrapped__||ul(v.history,"replaceState",r=>function(s,i,o){r.call(this,s,i,o),n._r("replaceState")}),this.gr()}}_r(t){try{var e,n=v==null||(e=v.location)==null?void 0:e.pathname;if(!n)return;n!==this.cr&&this.isEnabled&&this._instance.capture(Ut,{navigation_type:t}),this.cr=n}catch(r){R.error("Error capturing "+t+" pageview",r)}}gr(){if(!this.pr){var t=()=>{this._r("popstate")};he(v,"popstate",t),this.pr=()=>{v&&v.removeEventListener("popstate",t)}}}},heatmaps:class{get N(){return this.instance.config}constructor(t){var e;this.mr=!1,this.ar=!1,this.br=null,this.instance=t,this.mr=!((e=this.instance.persistence)==null||!e.props[ui]),this.rageclicks=new ll(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return _e(this.N.capture_heatmaps)&&this.N.capture_heatmaps.flush_interval_milliseconds&&(t=this.N.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return G(this.N.capture_heatmaps)?G(this.N.enable_heatmaps)?this.mr:this.N.enable_heatmaps:this.N.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.ar)return;jv.info("starting..."),this.yr(),this.wr()}else{var t;clearInterval((t=this.br)!==null&&t!==void 0?t:void 0),this.Er(),this.getAndClearBuffer()}}onRemoteConfig(t){if("heatmaps"in t){var e=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[ui]:e}),this.mr=e,this.startIfEnabled()}}getAndClearBuffer(){var t=this.I;return this.I=void 0,t}Sr(t){this.Tr(t.originalEvent,"deadclick")}wr(){this.br&&clearInterval(this.br),this.br=($==null?void 0:$.visibilityState)==="visible"?setInterval(this.At.bind(this),this.flushIntervalMilliseconds):null}yr(){v&&$&&(this.$r=this.At.bind(this),he(v,$r,this.$r),this.kr=t=>this.Tr(t||(v==null?void 0:v.event)),he($,"click",this.kr,{capture:!0}),this.Rr=t=>this.Pr(t||(v==null?void 0:v.event)),he($,"mousemove",this.Rr,{capture:!0}),this.Or=new Ma(this.instance,ev,this.Sr.bind(this)),this.Or.startIfEnabledOrStop(),this.Ir=this.wr.bind(this),he($,Cr,this.Ir),this.ar=!0)}Er(){var t;v&&$&&(this.$r&&v.removeEventListener($r,this.$r),this.kr&&$.removeEventListener("click",this.kr,{capture:!0}),this.Rr&&$.removeEventListener("mousemove",this.Rr,{capture:!0}),this.Ir&&$.removeEventListener(Cr,this.Ir),clearTimeout(this.Cr),(t=this.Or)==null||t.stop(),this.ar=!1)}Fr(t,e){var n=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),i=function(o,a,l){for(var c=o;c&&ns(c)&&!ft(c,"body");){if(c===l)return!1;if(q(a,v==null?void 0:v.getComputedStyle(c).position))return!0;c=zu(c)}return!1}(nl(t),["fixed","sticky"],s);return{x:t.clientX+(i?0:r),y:t.clientY+(i?0:n),target_fixed:i,type:e}}Tr(t,e){var n;if(e===void 0&&(e="click"),!el(t.target)&&fl(t)){var r=this.Fr(t,e);(n=this.rageclicks)!=null&&n.isRageClick(t.clientX,t.clientY,new Date().getTime())&&this.Ar(T({},r,{type:"rageclick"})),this.Ar(r)}}Pr(t){!el(t.target)&&fl(t)&&(clearTimeout(this.Cr),this.Cr=setTimeout(()=>{this.Ar(this.Fr(t,"mousemove"))},500))}Ar(t){if(v){var e=v.location.href,n=this.N.custom_personal_data_properties,r=this.N.mask_personal_data_properties?[...tn,...n||[]]:[],s=Mn(e,r,Dn);this.I=this.I||{},this.I[s]||(this.I[s]=[]),this.I[s].push(t)}}At(){this.I&&!Bt(this.I)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Ma,webVitalsAutocapture:class{constructor(t){var e;this.mr=!1,this.ar=!1,this.I={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Mr=()=>{clearTimeout(this.Dr),this.I.metrics.length!==0&&(this._instance.capture("$web_vitals",this.I.metrics.reduce((n,r)=>T({},n,{["$web_vitals_"+r.name+"_event"]:T({},r),["$web_vitals_"+r.name+"_value"]:r.value}),{})),this.I={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Lr=n=>{var r,s=(r=this._instance.sessionManager)==null?void 0:r.checkAndGetSessionAndWindowId(!0);if(O(s))at.error("Could not read session ID. Dropping metrics!");else{this.I=this.I||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var i=this.Ur();O(i)||(G(n==null?void 0:n.name)||G(n==null?void 0:n.value)?at.error("Invalid metric received",n):!this.Nr||this.Nr>n.value?(this.I.url!==i&&(this.Mr(),this.Dr=setTimeout(this.Mr,this.flushToCaptureTimeoutMs)),O(this.I.url)&&(this.I.url=i),this.I.firstMetricTimestamp=O(this.I.firstMetricTimestamp)?Date.now():this.I.firstMetricTimestamp,n.attribution&&n.attribution.interactionTargetElement&&(n.attribution.interactionTargetElement=void 0),this.I.metrics.push(T({},n,{$current_url:i,$session_id:s.sessionId,$window_id:s.windowId,timestamp:Date.now()})),this.I.metrics.length===this.allowedMetrics.length&&this.Mr()):at.error("Ignoring metric with value >= "+this.Nr,n))}},this.jr=()=>{if(!this.ar){var n,r,s,i,o=M.__PosthogExtensions__;O(o)||O(o.postHogWebVitalsCallbacks)||({onLCP:n,onCLS:r,onFCP:s,onINP:i}=o.postHogWebVitalsCallbacks),n&&r&&s&&i?(this.allowedMetrics.indexOf("LCP")>-1&&n(this.Lr.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&r(this.Lr.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&s(this.Lr.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&i(this.Lr.bind(this)),this.ar=!0):at.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.mr=!((e=this._instance.persistence)==null||!e.props[$a]),this.startIfEnabled()}get zr(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,n=_e(this.zr)?(t=this.zr)==null?void 0:t.web_vitals_allowed_metrics:void 0;return G(n)?((e=this._instance.persistence)==null?void 0:e.props[Oa])||["CLS","FCP","INP","LCP"]:n}get flushToCaptureTimeoutMs(){return(_e(this.zr)?this.zr.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=_e(this.zr)?this.zr.web_vitals_attribution:void 0;return t!=null&&t}get Nr(){var t=_e(this.zr)&&We(this.zr.__web_vitals_max_value)?this.zr.__web_vitals_max_value:dl;return t>0&&6e4>=t?dl:t}get isEnabled(){var t=ve==null?void 0:ve.protocol;if(t!=="http:"&&t!=="https:")return at.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=_e(this.zr)?this.zr.web_vitals:Xe(this.zr)?this.zr:void 0;return Xe(e)?e:this.mr}startIfEnabled(){this.isEnabled&&!this.ar&&(at.info("enabled, starting..."),this.Y(this.jr))}onRemoteConfig(t){if("capturePerformance"in t){var e=_e(t.capturePerformance)&&!!t.capturePerformance.web_vitals,n=_e(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[$a]:e}),this._instance.persistence.register({[Oa]:n})),this.mr=e,this.startIfEnabled()}}Y(t){var e,n;(e=M.__PosthogExtensions__)!=null&&e.postHogWebVitalsCallbacks?t():(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",r=>{r?at.error("failed to load script",r):t()})}Ur(){var t=v?v.location.href:void 0;if(t){var e=this._instance.config.custom_personal_data_properties,n=this._instance.config.mask_personal_data_properties?[...tn,...e||[]]:[];return Mn(t,n,Dn)}at.error("Could not determine current URL")}}},Yv={exceptionObserver:class{constructor(t){var e,n,r;this.jr=()=>{var s;if(v&&this.isEnabled&&(s=M.__PosthogExtensions__)!=null&&s.errorWrappingFunctions){var i=M.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,o=M.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,a=M.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Br&&this.N.capture_unhandled_errors&&(this.Br=i(this.captureException.bind(this))),!this.Hr&&this.N.capture_unhandled_rejections&&(this.Hr=o(this.captureException.bind(this))),!this.qr&&this.N.capture_console_errors&&(this.qr=a(this.captureException.bind(this)))}catch(l){gn.error("failed to start",l),this.Wr()}}},this._instance=t,this.Vr=!((e=this._instance.persistence)==null||!e.props[Pa]),this.Yr=new hg({refillRate:(n=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&n!==void 0?n:1,bucketSize:(r=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&r!==void 0?r:10,refillInterval:1e4,h:gn}),this.N=this.Gr(),this.startIfEnabledOrStop()}Gr(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return _e(t)?e=T({},e,t):(O(t)?this.Vr:t)&&(e=T({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.N.capture_console_errors||this.N.capture_unhandled_errors||this.N.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(gn.info("enabled"),this.Wr(),this.Y(this.jr)):this.Wr()}Y(t){var e,n;(e=M.__PosthogExtensions__)!=null&&e.errorWrappingFunctions&&t(),(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"exception-autocapture",r=>{if(r)return gn.error("failed to load script",r);t()})}Wr(){var t,e,n;(t=this.Br)==null||t.call(this),this.Br=void 0,(e=this.Hr)==null||e.call(this),this.Hr=void 0,(n=this.qr)==null||n.call(this),this.qr=void 0}onRemoteConfig(t){"autocaptureExceptions"in t&&(this.Vr=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Pa]:this.Vr}),this.N=this.Gr(),this.startIfEnabledOrStop())}onConfigChange(){this.N=this.Gr()}captureException(t){var e,n,r,s=(e=t==null||(n=t.$exception_list)==null||(n=n[0])==null?void 0:n.type)!==null&&e!==void 0?e:"Exception";this.Yr.consumeRateLimit(s)?gn.info("Skipping exception capture because of client rate limiting.",{exception:s}):(r=this._instance.exceptions)==null||r.sendExceptionEvent(t)}},exceptions:class{constructor(t){var e,n;this.Jr=[],this.Kr=new kg([new Og,new Hg,new Fg,new Ag,new jg,new Lg,new Mg,new Ug],function(r){for(var s=arguments.length,i=new Array(s>1?s-1:0),o=1;s>o;o++)i[o-1]=arguments[o];return function(a,l){l===void 0&&(l=0);for(var c=[],u=a.split(`
16
- `),d=l;u.length>d;d++){var p=u[d];if(1024>=p.length){var f=xa.test(p)?p.replace(xa,"$1"):p;if(!f.match(/\S*Error: /)){for(var g of i){var _=g(f,r);if(_){c.push(_);break}}if(c.length>=50)break}}}return function(P){if(!P.length)return[];var m=Array.from(P);return m.reverse(),m.slice(0,50).map(b=>{return T({},b,{filename:b.filename||(C=m,C[C.length-1]||{}).filename,function:b.function||en});var C})}(c)}}("web:javascript",Pg,Rg)),this._instance=t,this.Jr=(e=(n=this._instance.persistence)==null?void 0:n.get_property(di))!==null&&e!==void 0?e:[]}onRemoteConfig(t){var e,n,r;if("errorTracking"in t){var s=(e=(n=t.errorTracking)==null?void 0:n.suppressionRules)!==null&&e!==void 0?e:[],i=(r=t.errorTracking)==null?void 0:r.captureExtensionExceptions;this.Jr=s,this._instance.persistence&&this._instance.persistence.register({[di]:this.Jr,[Ca]:i})}}get Xr(){var t,e=!!this._instance.get_property(Ca),n=this._instance.config.error_tracking.captureExtensionExceptions;return(t=n??e)!==null&&t!==void 0&&t}buildProperties(t,e){return this.Kr.buildFromUnknown(t,{syntheticException:e==null?void 0:e.syntheticException,mechanism:{handled:e==null?void 0:e.handled}})}sendExceptionEvent(t){var e=t.$exception_list;if(this.Qr(e)){if(this.Zr(e))return void Ms.info("Skipping exception capture because a suppression rule matched");if(!this.Xr&&this.ts(e))return void Ms.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.es(e))return void Ms.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",t,{_noTruncate:!0,_batchKey:"exceptionEvent",Ui:!0})}Zr(t){if(t.length===0)return!1;var e=t.reduce((n,r)=>{var{type:s,value:i}=r;return fe(s)&&s.length>0&&n.$exception_types.push(s),fe(i)&&i.length>0&&n.$exception_values.push(i),n},{$exception_types:[],$exception_values:[]});return this.Jr.some(n=>{var r=n.values.map(s=>{var i,o=Mu[s.operator],a=Y(s.value)?s.value:[s.value],l=(i=e[s.key])!==null&&i!==void 0?i:[];return a.length>0&&o(a,l)});return n.type==="OR"?r.some(Boolean):r.every(Boolean)})}ts(t){return t.flatMap(e=>{var n,r;return(n=(r=e.stacktrace)==null?void 0:r.frames)!==null&&n!==void 0?n:[]}).some(e=>e.filename&&e.filename.startsWith("chrome-extension://"))}es(t){if(t.length>0){var e,n,r,s,i=(e=(n=t[0].stacktrace)==null?void 0:n.frames)!==null&&e!==void 0?e:[],o=i[i.length-1];return(r=o==null||(s=o.filename)==null?void 0:s.includes("posthog.com/static"))!==null&&r!==void 0&&r}return!1}Qr(t){return!G(t)&&Y(t)}}},Kv=T({productTours:class{get Wt(){return this._instance.persistence}constructor(t){this.rs=null,this.ss=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){"productTours"in t&&(this.Wt&&this.Wt.register({[Ra]:!!t.productTours}),this.loadIfEnabled())}loadIfEnabled(){var t,e;this.rs||(t=this._instance).config.disable_product_tours||(e=t.persistence)==null||!e.get_property(Ra)||this.Y(()=>this.ns())}Y(t){var e,n;(e=M.__PosthogExtensions__)!=null&&e.generateProductTours?t():(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"product-tours",r=>{r?_l.error("Could not load product tours script",r):t()})}ns(){var t;!this.rs&&(t=M.__PosthogExtensions__)!=null&&t.generateProductTours&&(this.rs=M.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(e===void 0&&(e=!1),!Y(this.ss)||e){var n=this.Wt;if(n){var r=n.props[Os];if(Y(r)&&!e)return this.ss=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:s=>{var i=s.statusCode;if(i!==200||!s.json){var o="Product Tours API could not be loaded, status: "+i;return _l.error(o),void t([],{isLoaded:!1,error:o})}var a=Y(s.json.product_tours)?s.json.product_tours:[];this.ss=a,n&&n.register({[Os]:a}),t(a,{isLoaded:!0})}})}else t(this.ss,{isLoaded:!0})}getActiveProductTours(t){G(this.rs)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.rs.getActiveProductTours(t)}showProductTour(t){var e;(e=this.rs)==null||e.showTourById(t)}previewTour(t){this.rs?this.rs.previewTour(t):this.Y(()=>{var e;this.ns(),(e=this.rs)==null||e.previewTour(t)})}dismissProductTour(){var t;(t=this.rs)==null||t.dismissTour("user_clicked_skip")}nextStep(){var t;(t=this.rs)==null||t.nextStep()}previousStep(){var t;(t=this.rs)==null||t.previousStep()}clearCache(){var t;this.ss=null,(t=this.Wt)==null||t.unregister(Os)}resetTour(t){var e;(e=this.rs)==null||e.resetTour(t)}resetAllTours(){var t;(t=this.rs)==null||t.resetAllTours()}cancelPendingTour(t){var e;(e=this.rs)==null||e.cancelPendingTour(t)}}},rs),Jv={siteApps:class{constructor(t){this._instance=t,this.os=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}ls(t,e){if(e){var n=this.globalsForEvent(e);this.os.push(n),this.os.length>1e3&&(this.os=this.os.slice(10))}}get siteAppLoaders(){var t;return(t=M._POSTHOG_REMOTE_CONFIG)==null||(t=t[this._instance.config.token])==null?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.ls.bind(this));this.us=()=>{t(),this.os=[],this.us=void 0}}}globalsForEvent(t){var e,n,r,s,i,o,a;if(!t)throw new Error("Event payload is required");var l={},c=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(var[d,p]of Object.entries(u))l[d]={id:c[d],type:d,properties:p};var{$set_once:f,$set:g}=t;return{event:T({},zc(t,Uv),{properties:T({},t.properties,g?{$set:T({},(e=(n=t.properties)==null?void 0:n.$set)!==null&&e!==void 0?e:{},g)}:{},f?{$set_once:T({},(r=(s=t.properties)==null?void 0:s.$set_once)!==null&&r!==void 0?r:{},f)}:{}),elements_chain:(i=(o=t.properties)==null?void 0:o.$elements_chain)!==null&&i!==void 0?i:"",distinct_id:(a=t.properties)==null?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(t){var e=this.apps[t.id],n=()=>{var o;!e.errored&&this.os.length&&(ct.info("Processing "+this.os.length+" events for site app with id "+t.id),this.os.forEach(a=>e.processEvent==null?void 0:e.processEvent(a)),e.processedBuffer=!0),Object.values(this.apps).every(a=>a.processedBuffer||a.errored)&&((o=this.us)==null||o.call(this))},r=!1,s=o=>{e.errored=!o,e.loaded=!0,ct.info("Site app with id "+t.id+" "+(o?"loaded":"errored")),r&&n()};try{var{processEvent:i}=t.init({posthog:this._instance,callback(o){s(o)}});i&&(e.processEvent=i),r=!0}catch(o){ct.error(gl+t.id,o),s(!1)}if(r&&e.loaded)try{n()}catch(o){ct.error("Error while processing buffered events PostHog app with config id "+t.id,o),e.errored=!0}}hs(){var t=this.siteAppLoaders||[];for(var e of t)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var n of t)this.setupSiteApp(n)}ds(t){if(Object.keys(this.apps).length!==0){var e=this.globalsForEvent(t);for(var n of Object.values(this.apps))try{n.processEvent==null||n.processEvent(e)}catch(r){ct.error("Error while processing event "+t.event+" for site app "+n.id,r)}}}onRemoteConfig(t){var e,n,r,s=this;if((e=this.siteAppLoaders)!=null&&e.length)return this.isEnabled?(this.hs(),void this._instance.on("eventCaptured",l=>this.ds(l))):void ct.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((n=this.us)==null||n.call(this),(r=t.siteApps)!=null&&r.length)if(this.isEnabled){var i=function(l){var c;M["__$$ph_site_app_"+l]=s._instance,(c=M.__PosthogExtensions__)==null||c.loadSiteApp==null||c.loadSiteApp(s._instance,a,u=>{if(u)return ct.error(gl+l,u)})};for(var{id:o,url:a}of t.siteApps)i(o)}else ct.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},Xv={tracingHeaders:class{constructor(t){this.vs=void 0,this.cs=void 0,this.jr=()=>{var e,n;O(this.vs)&&((e=M.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),O(this.cs)&&((n=M.__PosthogExtensions__)==null||(n=n.tracingHeadersPatchFns)==null||n._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=t}initialize(){this.startIfEnabledOrStop()}Y(t){var e,n;(e=M.__PosthogExtensions__)!=null&&e.tracingHeadersPatchFns&&t(),(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"tracing-headers",r=>{if(r)return Lv.error("failed to load script",r);t()})}startIfEnabledOrStop(){var t,e;this._instance.config.__add_tracing_headers?this.Y(this.jr):((t=this.vs)==null||t.call(this),(e=this.cs)==null||e.call(this),this.vs=void 0,this.cs=void 0)}}},Zv=T({surveys:class{get N(){return this._instance.config}constructor(t){this.fs=void 0,this._surveyManager=null,this.ps=!1,this._s=[],this.gs=null,this._instance=t,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this.N.disable_surveys){var e=t.surveys;if(G(e))return Q.warn("Flags not loaded yet. Not loading surveys.");var n=Y(e);this.fs=n?e.length>0:e,Q.info("flags response received, isSurveysEnabled: "+this.fs),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var t=[],e=0;e<localStorage.length;e++){var n=localStorage.key(e);(n!=null&&n.startsWith(Ti)||n!=null&&n.startsWith("inProgressSurvey_"))&&t.push(n)}t.forEach(r=>localStorage.removeItem(r))}loadIfEnabled(){if(!this._surveyManager)if(this.ps)Q.info("Already initializing surveys, skipping...");else if(this.N.disable_surveys)Q.info(vl);else if(this.N.cookieless_mode&&this._instance.consent.isOptedOut())Q.info("Not loading surveys in cookieless mode without consent.");else{var t=M==null?void 0:M.__PosthogExtensions__;if(t){if(!O(this.fs)||this.N.advanced_enable_surveys){var e=this.fs||this.N.advanced_enable_surveys;this.ps=!0;try{var n=t.generateSurveys;if(n)return void this.bs(n,e);var r=t.loadExternalDependency;if(!r)return void this.ys(ro);r(this._instance,"surveys",s=>{s||!t.generateSurveys?this.ys("Could not load surveys script",s):this.bs(t.generateSurveys,e)})}catch(s){throw this.ys("Error initializing surveys",s),s}finally{this.ps=!1}}}else Q.error("PostHog Extensions not found.")}}bs(t,e){this._surveyManager=t(this._instance,e),this._surveyEventReceiver=new zv(this._instance),Q.info("Surveys loaded successfully"),this.ws({isLoaded:!0})}ys(t,e){Q.error(t,e),this.ws({isLoaded:!1,error:t})}onSurveysLoaded(t){return this._s.push(t),this._surveyManager&&this.ws({isLoaded:!0}),()=>{this._s=this._s.filter(e=>e!==t)}}getSurveys(t,e){if(e===void 0&&(e=!1),this.N.disable_surveys)return Q.info(vl),t([]);var n,r=this._instance.get_property(pi);if(r&&!e)return t(r,{isLoaded:!0});typeof Promise<"u"&&this.gs?this.gs.then(s=>{var{surveys:i,context:o}=s;return t(i,o)}):(typeof Promise<"u"&&(this.gs=new Promise(s=>{n=s})),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.N.token),method:"GET",timeout:this.N.surveys_request_timeout_ms,callback:s=>{var i;this.gs=null;var o=s.statusCode;if(o!==200||!s.json){var a="Surveys API could not be loaded, status: "+o;Q.error(a);var l={isLoaded:!1,error:a};return t([],l),void(n==null||n({surveys:[],context:l}))}var c,u=s.json.surveys||[],d=u.filter(f=>function(g){return!(!g.start_date||g.end_date)}(f)&&(function(g){var _;return!((_=g.conditions)==null||(_=_.events)==null||(_=_.values)==null||!_.length)}(f)||function(g){var _;return!((_=g.conditions)==null||(_=_.actions)==null||(_=_.values)==null||!_.length)}(f)));d.length>0&&((c=this._surveyEventReceiver)==null||c.register(d)),(i=this._instance.persistence)==null||i.register({[pi]:u});var p={isLoaded:!0};t(u,p),n==null||n({surveys:u,context:p})}}))}ws(t){for(var e of this._s)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(n){Q.error("Error in survey callback",n)}}getActiveMatchingSurveys(t,e){if(e===void 0&&(e=!1),!G(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);Q.warn("init was not called")}Es(t){var e=null;return this.getSurveys(n=>{var r;e=(r=n.find(s=>s.id===t))!==null&&r!==void 0?r:null}),e}Ss(t){if(G(this._surveyManager))return{eligible:!1,reason:As};var e=typeof t=="string"?this.Es(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(G(this._surveyManager))return Q.warn("init was not called"),{visible:!1,disabledReason:As};var e=this.Ss(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return G(this._surveyManager)?(Q.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:As})):new Promise(n=>{this.getSurveys(r=>{var s,i=(s=r.find(a=>a.id===t))!==null&&s!==void 0?s:null;if(i){var o=this.Ss(i);n({visible:o.eligible,disabledReason:o.reason})}else n({visible:!1,disabledReason:"Survey not found"})},e)})}renderSurvey(t,e,n){var r;if(G(this._surveyManager))Q.warn("init was not called");else{var s=typeof t=="string"?this.Es(t):t;if(s!=null&&s.id)if(Sv.includes(s.type)){var i=$==null?void 0:$.querySelector(e);if(i)return(r=s.appearance)!=null&&r.surveyPopupDelaySeconds?(Q.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout(()=>{var o,a;Q.info("Rendering survey "+s.id+" with delay of "+((o=s.appearance)==null?void 0:o.surveyPopupDelaySeconds)+" seconds"),(a=this._surveyManager)==null||a.renderSurvey(s,i,n),Q.info("Survey "+s.id+" rendered")},1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,i,n);Q.warn("Survey element not found")}else Q.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Q.warn("Survey not found")}}displaySurvey(t,e){var n;if(G(this._surveyManager))Q.warn("init was not called");else{var r=this.Es(t);if(r){var s=r;if((n=r.appearance)!=null&&n.surveyPopupDelaySeconds&&e.ignoreDelay&&(s=T({},r,{appearance:T({},r.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==Ei.Popover&&e.initialResponses&&Q.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),e.ignoreConditions===!1){var i=this.canRenderSurvey(r);if(!i.visible)return void Q.warn("Survey is not eligible to be displayed: ",i.disabledReason)}e.displayType!==Ei.Inline?this._surveyManager.handlePopoverSurvey(s,e):this.renderSurvey(s,e.selector,e.properties)}else Q.warn("Survey not found")}}cancelPendingSurvey(t){G(this._surveyManager)?Q.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;(t=this._surveyManager)==null||t.handlePageUnload()}}},rs),Qv={toolbar:class{constructor(t){this.instance=t}xs(t){M.ph_toolbar_state=t}Ts(){var t;return(t=M.ph_toolbar_state)!==null&&t!==void 0?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,e,n){if(t===void 0&&(t=void 0),e===void 0&&(e=void 0),n===void 0&&(n=void 0),vu(this.instance.config)||!v||!$)return!1;t=t??v.location,n=n??v.history;try{if(!e){try{v.localStorage.setItem("test","test"),v.localStorage.removeItem("test")}catch{return!1}e=v==null?void 0:v.localStorage}var r,s=Wv||Fr(t.hash,"__posthog")||Fr(t.hash,"state"),i=s?Fa(()=>JSON.parse(atob(decodeURIComponent(s))))||Fa(()=>JSON.parse(decodeURIComponent(s))):null;return i&&i.action==="ph_authorize"?((r=i).source="url",r&&Object.keys(r).length>0&&(i.desiredHash?t.hash=i.desiredHash:n?n.replaceState(n.state,"",t.pathname+t.search):t.hash="")):((r=JSON.parse(e.getItem(ml)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch{return!1}}$s(t){var e=M.ph_load_toolbar||M.ph_load_editor;!G(e)&&Ke(e)?e(t,this.instance):yl.warn("No toolbar load function found")}loadToolbar(t){var e=!($==null||!$.getElementById(gu));if(!v||e)return!1;var n=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,r=T({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},n?{instrument:!1}:{});if(v.localStorage.setItem(ml,JSON.stringify(T({},r,{source:void 0}))),this.Ts()===2)this.$s(r);else if(this.Ts()===0){var s;this.xs(1),(s=M.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this.instance,"toolbar",i=>{if(i)return yl.error("[Toolbar] Failed to load",i),void this.xs(0);this.xs(2),this.$s(r)}),he(v,"turbolinks:load",()=>{this.xs(0),this.loadToolbar(r)})}return!0}ks(t){return this.loadToolbar(t)}maybeLoadEditor(t,e,n){return t===void 0&&(t=void 0),e===void 0&&(e=void 0),n===void 0&&(n=void 0),this.maybeLoadToolbar(t,e,n)}}},em=T({experiments:be},rs),tm={conversations:class{constructor(t){this.Rs=void 0,this._conversationsManager=null,this.Ps=!1,this.Os=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations){var e=t.conversations;G(e)||(Xe(e)?this.Rs=e:(this.Rs=e.enabled,this.Os=e),this.loadIfEnabled())}}reset(){var t;(t=this._conversationsManager)==null||t.reset(),this._conversationsManager=null,this.Rs=void 0,this.Os=null}loadIfEnabled(){if(!(this._conversationsManager||this.Ps||this._instance.config.disable_conversations||vu(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=M==null?void 0:M.__PosthogExtensions__;if(t&&!O(this.Rs)&&this.Rs)if(this.Os&&this.Os.token){this.Ps=!0;try{var e=t.initConversations;if(e)return this.Is(e),void(this.Ps=!1);var n=t.loadExternalDependency;if(!n)return void this.Cs(ro);n(this._instance,"conversations",r=>{r||!t.initConversations?this.Cs("Could not load conversations script",r):this.Is(t.initConversations),this.Ps=!1})}catch(r){this.Cs("Error initializing conversations",r),this.Ps=!1}}else Ae.error("Conversations enabled but missing token in remote config.")}}Is(t){if(this.Os)try{this._conversationsManager=t(this.Os,this._instance),Ae.info("Conversations loaded successfully")}catch(e){this.Cs("Error completing conversations initialization",e)}else Ae.error("Cannot complete initialization: remote config is null")}Cs(t,e){Ae.error(t,e),this._conversationsManager=null,this.Ps=!1}show(){this._conversationsManager?this._conversationsManager.show():Ae.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Rs===!0&&!rt(this._conversationsManager)}isVisible(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.isVisible())!==null&&t!==void 0&&t}sendMessage(t,e,n){var r=this;return De(function*(){return r._conversationsManager?r._conversationsManager.sendMessage(t,e,n):(Ae.warn(wt),null)})()}getMessages(t,e){var n=this;return De(function*(){return n._conversationsManager?n._conversationsManager.getMessages(t,e):(Ae.warn(wt),null)})()}markAsRead(t){var e=this;return De(function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(Ae.warn(wt),null)})()}getTickets(t){var e=this;return De(function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(Ae.warn(wt),null)})()}requestRestoreLink(t){var e=this;return De(function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(Ae.warn(wt),null)})()}restoreFromToken(t){var e=this;return De(function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(Ae.warn(wt),null)})()}restoreFromUrlToken(){var t=this;return De(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Ae.warn(wt),null)})()}getCurrentTicketId(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.getCurrentTicketId())!==null&&t!==void 0?t:null}getWidgetSessionId(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.getWidgetSessionId())!==null&&t!==void 0?t:null}}},nm={logs:class{constructor(t){var e;this.Fs=!1,this.As=!1,this._instance=t,this._instance&&(e=this._instance.config.logs)!=null&&e.captureConsoleLogs&&(this.Fs=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var e,n=(e=t.logs)==null?void 0:e.captureConsoleLogs;!G(n)&&n&&(this.Fs=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.Fs&&!this.As){var t=oe("[logs]"),e=M==null?void 0:M.__PosthogExtensions__;if(e){var n=e.loadExternalDependency;n?n(this._instance,"logs",r=>{var s;r||(s=e.logs)==null||!s.initializeLogs?t.error("Could not load logs script",r):(e.logs.initializeLogs(this._instance),this.As=!0)}):t.error(ro)}else t.error("PostHog Extensions not found.")}}}},rm=T({},rs,Gv,Vv,Yv,Kv,Jv,Zv,Xv,Qv,em,tm,nm);Be.__defaultExtensionClasses=T({},rm);var xl,_t=(xl=Cn[Ht]=new Be,function(){function t(){t.done||(t.done=!0,ju=!1,te(Cn,function(e){e._dom_loaded()}))}$!=null&&$.addEventListener?$.readyState==="complete"?t():he($,"DOMContentLoaded",t,{capture:!1}):v&&R.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),xl),jn,ue,Ds,Il,Ur=0,Yu=[],pe=re,Tl=pe.__b,Pl=pe.__r,Cl=pe.diffed,$l=pe.__c,Rl=pe.unmount,Ol=pe.__;function uo(t,e){pe.__h&&pe.__h(ue,t,Ur||e),Ur=0;var n=ue.__H||(ue.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function W(t){return Ur=1,sm(Ju,t)}function sm(t,e,n){var r=uo(jn++,2);if(r.t=t,!r.__c&&(r.__=[Ju(void 0,e),function(a){var l=r.__N?r.__N[0]:r.__[0],c=r.t(l,a);l!==c&&(r.__N=[c,r.__[1]],r.__c.setState({}))}],r.__c=ue,!ue.__f)){var s=function(a,l,c){if(!r.__c.__H)return!0;var u=r.__c.__H.__.filter(function(p){return p.__c});if(u.every(function(p){return!p.__N}))return!i||i.call(this,a,l,c);var d=r.__c.props!==a;return u.some(function(p){if(p.__N){var f=p.__[0];p.__=p.__N,p.__N=void 0,f!==p.__[0]&&(d=!0)}}),i&&i.call(this,a,l,c)||d};ue.__f=!0;var i=ue.shouldComponentUpdate,o=ue.componentWillUpdate;ue.componentWillUpdate=function(a,l,c){if(this.__e){var u=i;i=void 0,s(a,l,c),i=u}o&&o.call(this,a,l,c)},ue.shouldComponentUpdate=s}return r.__N||r.__}function rn(t,e){var n=uo(jn++,3);!pe.__s&&Ku(n.__H,e)&&(n.__=t,n.u=e,ue.__H.__h.push(n))}function im(t,e){var n=uo(jn++,7);return Ku(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function pt(t,e){return Ur=8,im(function(){return t},e)}function om(){for(var t;t=Yu.shift();){var e=t.__H;if(t.__P&&e)try{e.__h.some(_r),e.__h.some(Oi),e.__h=[]}catch(n){e.__h=[],pe.__e(n,t.__v)}}}pe.__b=function(t){ue=null,Tl&&Tl(t)},pe.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Ol&&Ol(t,e)},pe.__r=function(t){Pl&&Pl(t),jn=0;var e=(ue=t.__c).__H;e&&(Ds===ue?(e.__h=[],ue.__h=[],e.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.some(_r),e.__h.some(Oi),e.__h=[],jn=0)),Ds=ue},pe.diffed=function(t){Cl&&Cl(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Yu.push(e)!==1&&Il===pe.requestAnimationFrame||((Il=pe.requestAnimationFrame)||am)(om)),e.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Ds=ue=null},pe.__c=function(t,e){e.some(function(n){try{n.__h.some(_r),n.__h=n.__h.filter(function(r){return!r.__||Oi(r)})}catch(r){e.some(function(s){s.__h&&(s.__h=[])}),e=[],pe.__e(r,n.__v)}}),$l&&$l(t,e)},pe.unmount=function(t){Rl&&Rl(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.some(function(r){try{_r(r)}catch(s){e=s}}),n.__H=void 0,e&&pe.__e(e,n.__v))};var Al=typeof requestAnimationFrame=="function";function am(t){var e,n=function(){clearTimeout(r),Al&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,35);Al&&(e=requestAnimationFrame(n))}function _r(t){var e=ue,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),ue=e}function Oi(t){var e=ue;t.__c=t.__(),ue=e}function Ku(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function Ju(t,e){return typeof e=="function"?e(t):e}const lm="";async function ie(t,e,n){const r={method:t,headers:{"Content-Type":"application/json"},credentials:"include"};n&&(r.body=JSON.stringify(n));const s=await fetch(lm+e,r);if(s.status===401)return{status:401,data:null,unauthorized:!0};const i=await s.json().catch(()=>null);return{status:s.status,data:i}}async function cm(){try{const e=await(await fetch("/api/auth/sign-in/social",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({provider:"google",callbackURL:"/dashboard"})})).json().catch(()=>null);if(e!=null&&e.url){window.location.href=e.url;return}}catch{}window.location.href="/api/auth/sign-in/social?provider=google&callbackURL=/dashboard"}function Hr({text:t,label:e="Copy"}){const[n,r]=W(!1);return h("button",{class:"btn-copy",onClick:()=>{navigator.clipboard.writeText(t),r(!0),setTimeout(()=>r(!1),2e3)}},n?"✓ Copied!":e)}function Br(t){if(!t)return"never";const e=Math.floor((Date.now()-t)/1e3);return e<60?`${e}s ago`:e<3600?`${Math.floor(e/60)}m ago`:e<86400?`${Math.floor(e/3600)}h ago`:`${Math.floor(e/86400)}d ago`}function um(){var z,ee,V,le;const[t,e]=W(!0),[n,r]=W(null),[s,i]=W([]),[o,a]=W([]),[l,c]=W(null),[u,d]=W(null),[p,f]=W(null),[g,_]=W("start"),[P,m]=W(!1),[b,C]=W(!1),[x,S]=W(!1),[k,w]=W(!1),E=pt(async()=>{var y;const D=await ie("GET","/v1/me");if(D!=null&&D.unauthorized){w(!0);return}D!=null&&D.data&&(r(D.data),(y=D.data.user)!=null&&y.email&&(_t.identify(D.data.user.id||D.data.user.email,{email:D.data.user.email,name:D.data.user.name}),_t.capture("dashboard_sign_in")))},[]),I=pt(async()=>{var y;const D=await ie("GET","/v1/api-keys");D&&i(((y=D.data)==null?void 0:y.api_keys)||[])},[]),A=pt(async()=>{var y;const D=await ie("GET","/v1/browser-sessions");D&&a(((y=D.data)==null?void 0:y.sessions)||[])},[]),j=pt(async()=>{const D=await ie("GET","/v1/usage");D&&c(D.data)},[]),F=pt(async()=>{const D=await ie("GET","/v1/billing/credits");D&&d(D.data)},[]);if(rn(()=>{Promise.all([E(),I(),A(),j(),F()]).then(()=>e(!1));const D=setInterval(A,5e3);return()=>clearInterval(D)},[]),rn(()=>{const D=y=>{var X,de;((X=y.data)==null?void 0:X.type)==="HANZI_EXTENSION_READY"&&m(!0),((de=y.data)==null?void 0:de.type)==="HANZI_PAIR_RESULT"&&(C(!1),y.data.success?(S(!0),A()):f("Pairing failed: "+(y.data.error||"unknown")))};return window.addEventListener("message",D),window.postMessage({type:"HANZI_PING"},"*"),()=>window.removeEventListener("message",D)},[]),t)return h(Nl,null);if(k)return cm(),h(Nl,null);const H=((ee=(z=n==null?void 0:n.user)==null?void 0:z.name)==null?void 0:ee.split(" ")[0])||"there",B=(V=n==null?void 0:n.user)!=null&&V.name?`${n.user.name}'s workspace`:"Your workspace",K=s.length>0,Z=o.find(D=>D.status==="connected"),N=!!Z||x;return h("div",{class:"page"},h("div",{class:"header"},h("div",null,h("h1",null,B),h("div",{class:"subtitle"},"Hi, ",H)),h("div",{style:{display:"flex",alignItems:"center",gap:12}},u&&h("div",{style:{textAlign:"right",fontSize:13,color:"var(--muted)"}},h("div",null,h("strong",{style:{color:"var(--ink)",fontSize:16}},(u.free_remaining||0)+(u.credit_balance||0))," tasks left"),h("div",null,u.free_remaining||0," free + ",u.credit_balance||0," credits")),h("button",{class:"signout",onClick:vm},"Sign out"))),h("div",{class:"tabs"},h("button",{class:`tab ${g==="start"?"active":""}`,onClick:()=>_("start")},"Getting Started"),h("button",{class:`tab ${g==="sessions"?"active":""}`,onClick:()=>_("sessions")},"Sessions",o.length>0&&h("span",{class:"tab-count"},o.filter(D=>D.status==="connected").length)),h("button",{class:`tab ${g==="settings"?"active":""}`,onClick:()=>_("settings")},"Settings"),h("button",{class:`tab ${g==="automations"?"active":""}`,onClick:()=>_("automations")},"Automations")),g==="start"&&h(dm,{keys:s,loadKeys:I,setError:f,extensionReady:P,pairing:b,paired:x,setPairing:C,setPaired:S,hasKeys:K,hasConnected:N,connectedSession:Z,sessions:o,loadSessions:A,loadUsage:j,setTab:_}),g==="sessions"&&h(pm,{sessions:o,onRefresh:A,usage:l}),g==="settings"&&h(fm,{keys:s,loadKeys:I,setError:f,profile:n,credits:u,loadCredits:F}),g==="automations"&&h(gm,{sessions:o,workspaceId:(le=n==null?void 0:n.workspace)==null?void 0:le.id,setError:f}),p&&h("div",{class:"error-toast",onClick:()=>f(null)},p))}function dm({keys:t,loadKeys:e,setError:n,extensionReady:r,pairing:s,paired:i,setPairing:o,setPaired:a,hasKeys:l,hasConnected:c,connectedSession:u,sessions:d,loadSessions:p,loadUsage:f,setTab:g}){var Z;const[_,P]=W(""),[m,b]=W(null),[C,x]=W("Go to example.com and tell me the page title"),[S,k]=W(null),[w,E]=W(""),[I,A]=W(0),j=S==="complete",F=async()=>{var z;if(!_.trim())return;const N=await ie("POST","/v1/api-keys",{name:_.trim()});(N==null?void 0:N.status)===201?(b(N.data.key),P(""),await e()):n(((z=N==null?void 0:N.data)==null?void 0:z.error)||"Failed")},H=async()=>{var z;o(!0),_t.capture("connect_browser_clicked");const N=await ie("POST","/v1/browser-sessions/pair",{label:"Developer testing"});if(!N||N.status!==201){o(!1),n(((z=N==null?void 0:N.data)==null?void 0:z.error)||"Failed");return}window.postMessage({type:"HANZI_PAIR",token:N.data.pairing_token,apiUrl:location.origin},"*"),setTimeout(()=>o(ee=>ee&&(n("Extension did not respond."),!1)),5e3)},B=async()=>{var le,D,y,X,de,ye;const N=(u==null?void 0:u.id)||((le=d.find(xe=>xe.status==="connected"))==null?void 0:le.id);if(!C.trim())return;if(!N){k("error"),E("No connected browser session found. Try refreshing the page.");return}k("running"),E(""),A(0),_t.capture("test_task_run");const z=await ie("POST","/v1/tasks",{task:C.trim(),browser_session_id:N});if(!z||z.status!==201){k("error"),E(((D=z==null?void 0:z.data)==null?void 0:D.error)||"Failed");return}const ee=z.data.id,V=Date.now()+3*60*1e3;for(;Date.now()<V;){await new Promise(Pe=>setTimeout(Pe,2e3));const xe=await ie("GET",`/v1/tasks/${ee}`);if(!xe)break;if(A(((y=xe.data)==null?void 0:y.steps)||0),((X=xe.data)==null?void 0:X.status)!=="running"){k(((de=xe.data)==null?void 0:de.status)||"error"),E(((ye=xe.data)==null?void 0:ye.answer)||"No answer."),f();return}}k("error"),E("Timed out after 3 minutes.")},K=`Add browser automation to this project using the Hanzi API. Read the codebase first, then ask me:
16
+ `),d=l;u.length>d;d++){var p=u[d];if(1024>=p.length){var f=xa.test(p)?p.replace(xa,"$1"):p;if(!f.match(/\S*Error: /)){for(var g of i){var _=g(f,r);if(_){c.push(_);break}}if(c.length>=50)break}}}return function(P){if(!P.length)return[];var m=Array.from(P);return m.reverse(),m.slice(0,50).map(b=>{return T({},b,{filename:b.filename||(C=m,C[C.length-1]||{}).filename,function:b.function||en});var C})}(c)}}("web:javascript",Pg,Rg)),this._instance=t,this.Jr=(e=(n=this._instance.persistence)==null?void 0:n.get_property(di))!==null&&e!==void 0?e:[]}onRemoteConfig(t){var e,n,r;if("errorTracking"in t){var s=(e=(n=t.errorTracking)==null?void 0:n.suppressionRules)!==null&&e!==void 0?e:[],i=(r=t.errorTracking)==null?void 0:r.captureExtensionExceptions;this.Jr=s,this._instance.persistence&&this._instance.persistence.register({[di]:this.Jr,[Ca]:i})}}get Xr(){var t,e=!!this._instance.get_property(Ca),n=this._instance.config.error_tracking.captureExtensionExceptions;return(t=n??e)!==null&&t!==void 0&&t}buildProperties(t,e){return this.Kr.buildFromUnknown(t,{syntheticException:e==null?void 0:e.syntheticException,mechanism:{handled:e==null?void 0:e.handled}})}sendExceptionEvent(t){var e=t.$exception_list;if(this.Qr(e)){if(this.Zr(e))return void Ms.info("Skipping exception capture because a suppression rule matched");if(!this.Xr&&this.ts(e))return void Ms.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.es(e))return void Ms.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",t,{_noTruncate:!0,_batchKey:"exceptionEvent",Ui:!0})}Zr(t){if(t.length===0)return!1;var e=t.reduce((n,r)=>{var{type:s,value:i}=r;return fe(s)&&s.length>0&&n.$exception_types.push(s),fe(i)&&i.length>0&&n.$exception_values.push(i),n},{$exception_types:[],$exception_values:[]});return this.Jr.some(n=>{var r=n.values.map(s=>{var i,o=Mu[s.operator],a=Y(s.value)?s.value:[s.value],l=(i=e[s.key])!==null&&i!==void 0?i:[];return a.length>0&&o(a,l)});return n.type==="OR"?r.some(Boolean):r.every(Boolean)})}ts(t){return t.flatMap(e=>{var n,r;return(n=(r=e.stacktrace)==null?void 0:r.frames)!==null&&n!==void 0?n:[]}).some(e=>e.filename&&e.filename.startsWith("chrome-extension://"))}es(t){if(t.length>0){var e,n,r,s,i=(e=(n=t[0].stacktrace)==null?void 0:n.frames)!==null&&e!==void 0?e:[],o=i[i.length-1];return(r=o==null||(s=o.filename)==null?void 0:s.includes("posthog.com/static"))!==null&&r!==void 0&&r}return!1}Qr(t){return!G(t)&&Y(t)}}},Kv=T({productTours:class{get Wt(){return this._instance.persistence}constructor(t){this.rs=null,this.ss=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){"productTours"in t&&(this.Wt&&this.Wt.register({[Ra]:!!t.productTours}),this.loadIfEnabled())}loadIfEnabled(){var t,e;this.rs||(t=this._instance).config.disable_product_tours||(e=t.persistence)==null||!e.get_property(Ra)||this.Y(()=>this.ns())}Y(t){var e,n;(e=M.__PosthogExtensions__)!=null&&e.generateProductTours?t():(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"product-tours",r=>{r?_l.error("Could not load product tours script",r):t()})}ns(){var t;!this.rs&&(t=M.__PosthogExtensions__)!=null&&t.generateProductTours&&(this.rs=M.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(e===void 0&&(e=!1),!Y(this.ss)||e){var n=this.Wt;if(n){var r=n.props[Os];if(Y(r)&&!e)return this.ss=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:s=>{var i=s.statusCode;if(i!==200||!s.json){var o="Product Tours API could not be loaded, status: "+i;return _l.error(o),void t([],{isLoaded:!1,error:o})}var a=Y(s.json.product_tours)?s.json.product_tours:[];this.ss=a,n&&n.register({[Os]:a}),t(a,{isLoaded:!0})}})}else t(this.ss,{isLoaded:!0})}getActiveProductTours(t){G(this.rs)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.rs.getActiveProductTours(t)}showProductTour(t){var e;(e=this.rs)==null||e.showTourById(t)}previewTour(t){this.rs?this.rs.previewTour(t):this.Y(()=>{var e;this.ns(),(e=this.rs)==null||e.previewTour(t)})}dismissProductTour(){var t;(t=this.rs)==null||t.dismissTour("user_clicked_skip")}nextStep(){var t;(t=this.rs)==null||t.nextStep()}previousStep(){var t;(t=this.rs)==null||t.previousStep()}clearCache(){var t;this.ss=null,(t=this.Wt)==null||t.unregister(Os)}resetTour(t){var e;(e=this.rs)==null||e.resetTour(t)}resetAllTours(){var t;(t=this.rs)==null||t.resetAllTours()}cancelPendingTour(t){var e;(e=this.rs)==null||e.cancelPendingTour(t)}}},rs),Jv={siteApps:class{constructor(t){this._instance=t,this.os=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}ls(t,e){if(e){var n=this.globalsForEvent(e);this.os.push(n),this.os.length>1e3&&(this.os=this.os.slice(10))}}get siteAppLoaders(){var t;return(t=M._POSTHOG_REMOTE_CONFIG)==null||(t=t[this._instance.config.token])==null?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.ls.bind(this));this.us=()=>{t(),this.os=[],this.us=void 0}}}globalsForEvent(t){var e,n,r,s,i,o,a;if(!t)throw new Error("Event payload is required");var l={},c=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(var[d,p]of Object.entries(u))l[d]={id:c[d],type:d,properties:p};var{$set_once:f,$set:g}=t;return{event:T({},zc(t,Uv),{properties:T({},t.properties,g?{$set:T({},(e=(n=t.properties)==null?void 0:n.$set)!==null&&e!==void 0?e:{},g)}:{},f?{$set_once:T({},(r=(s=t.properties)==null?void 0:s.$set_once)!==null&&r!==void 0?r:{},f)}:{}),elements_chain:(i=(o=t.properties)==null?void 0:o.$elements_chain)!==null&&i!==void 0?i:"",distinct_id:(a=t.properties)==null?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(t){var e=this.apps[t.id],n=()=>{var o;!e.errored&&this.os.length&&(ct.info("Processing "+this.os.length+" events for site app with id "+t.id),this.os.forEach(a=>e.processEvent==null?void 0:e.processEvent(a)),e.processedBuffer=!0),Object.values(this.apps).every(a=>a.processedBuffer||a.errored)&&((o=this.us)==null||o.call(this))},r=!1,s=o=>{e.errored=!o,e.loaded=!0,ct.info("Site app with id "+t.id+" "+(o?"loaded":"errored")),r&&n()};try{var{processEvent:i}=t.init({posthog:this._instance,callback(o){s(o)}});i&&(e.processEvent=i),r=!0}catch(o){ct.error(gl+t.id,o),s(!1)}if(r&&e.loaded)try{n()}catch(o){ct.error("Error while processing buffered events PostHog app with config id "+t.id,o),e.errored=!0}}hs(){var t=this.siteAppLoaders||[];for(var e of t)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var n of t)this.setupSiteApp(n)}ds(t){if(Object.keys(this.apps).length!==0){var e=this.globalsForEvent(t);for(var n of Object.values(this.apps))try{n.processEvent==null||n.processEvent(e)}catch(r){ct.error("Error while processing event "+t.event+" for site app "+n.id,r)}}}onRemoteConfig(t){var e,n,r,s=this;if((e=this.siteAppLoaders)!=null&&e.length)return this.isEnabled?(this.hs(),void this._instance.on("eventCaptured",l=>this.ds(l))):void ct.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((n=this.us)==null||n.call(this),(r=t.siteApps)!=null&&r.length)if(this.isEnabled){var i=function(l){var c;M["__$$ph_site_app_"+l]=s._instance,(c=M.__PosthogExtensions__)==null||c.loadSiteApp==null||c.loadSiteApp(s._instance,a,u=>{if(u)return ct.error(gl+l,u)})};for(var{id:o,url:a}of t.siteApps)i(o)}else ct.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},Xv={tracingHeaders:class{constructor(t){this.vs=void 0,this.cs=void 0,this.jr=()=>{var e,n;O(this.vs)&&((e=M.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),O(this.cs)&&((n=M.__PosthogExtensions__)==null||(n=n.tracingHeadersPatchFns)==null||n._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=t}initialize(){this.startIfEnabledOrStop()}Y(t){var e,n;(e=M.__PosthogExtensions__)!=null&&e.tracingHeadersPatchFns&&t(),(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"tracing-headers",r=>{if(r)return Lv.error("failed to load script",r);t()})}startIfEnabledOrStop(){var t,e;this._instance.config.__add_tracing_headers?this.Y(this.jr):((t=this.vs)==null||t.call(this),(e=this.cs)==null||e.call(this),this.vs=void 0,this.cs=void 0)}}},Zv=T({surveys:class{get N(){return this._instance.config}constructor(t){this.fs=void 0,this._surveyManager=null,this.ps=!1,this._s=[],this.gs=null,this._instance=t,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this.N.disable_surveys){var e=t.surveys;if(G(e))return Q.warn("Flags not loaded yet. Not loading surveys.");var n=Y(e);this.fs=n?e.length>0:e,Q.info("flags response received, isSurveysEnabled: "+this.fs),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var t=[],e=0;e<localStorage.length;e++){var n=localStorage.key(e);(n!=null&&n.startsWith(Ti)||n!=null&&n.startsWith("inProgressSurvey_"))&&t.push(n)}t.forEach(r=>localStorage.removeItem(r))}loadIfEnabled(){if(!this._surveyManager)if(this.ps)Q.info("Already initializing surveys, skipping...");else if(this.N.disable_surveys)Q.info(vl);else if(this.N.cookieless_mode&&this._instance.consent.isOptedOut())Q.info("Not loading surveys in cookieless mode without consent.");else{var t=M==null?void 0:M.__PosthogExtensions__;if(t){if(!O(this.fs)||this.N.advanced_enable_surveys){var e=this.fs||this.N.advanced_enable_surveys;this.ps=!0;try{var n=t.generateSurveys;if(n)return void this.bs(n,e);var r=t.loadExternalDependency;if(!r)return void this.ys(ro);r(this._instance,"surveys",s=>{s||!t.generateSurveys?this.ys("Could not load surveys script",s):this.bs(t.generateSurveys,e)})}catch(s){throw this.ys("Error initializing surveys",s),s}finally{this.ps=!1}}}else Q.error("PostHog Extensions not found.")}}bs(t,e){this._surveyManager=t(this._instance,e),this._surveyEventReceiver=new zv(this._instance),Q.info("Surveys loaded successfully"),this.ws({isLoaded:!0})}ys(t,e){Q.error(t,e),this.ws({isLoaded:!1,error:t})}onSurveysLoaded(t){return this._s.push(t),this._surveyManager&&this.ws({isLoaded:!0}),()=>{this._s=this._s.filter(e=>e!==t)}}getSurveys(t,e){if(e===void 0&&(e=!1),this.N.disable_surveys)return Q.info(vl),t([]);var n,r=this._instance.get_property(pi);if(r&&!e)return t(r,{isLoaded:!0});typeof Promise<"u"&&this.gs?this.gs.then(s=>{var{surveys:i,context:o}=s;return t(i,o)}):(typeof Promise<"u"&&(this.gs=new Promise(s=>{n=s})),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.N.token),method:"GET",timeout:this.N.surveys_request_timeout_ms,callback:s=>{var i;this.gs=null;var o=s.statusCode;if(o!==200||!s.json){var a="Surveys API could not be loaded, status: "+o;Q.error(a);var l={isLoaded:!1,error:a};return t([],l),void(n==null||n({surveys:[],context:l}))}var c,u=s.json.surveys||[],d=u.filter(f=>function(g){return!(!g.start_date||g.end_date)}(f)&&(function(g){var _;return!((_=g.conditions)==null||(_=_.events)==null||(_=_.values)==null||!_.length)}(f)||function(g){var _;return!((_=g.conditions)==null||(_=_.actions)==null||(_=_.values)==null||!_.length)}(f)));d.length>0&&((c=this._surveyEventReceiver)==null||c.register(d)),(i=this._instance.persistence)==null||i.register({[pi]:u});var p={isLoaded:!0};t(u,p),n==null||n({surveys:u,context:p})}}))}ws(t){for(var e of this._s)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(n){Q.error("Error in survey callback",n)}}getActiveMatchingSurveys(t,e){if(e===void 0&&(e=!1),!G(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);Q.warn("init was not called")}Es(t){var e=null;return this.getSurveys(n=>{var r;e=(r=n.find(s=>s.id===t))!==null&&r!==void 0?r:null}),e}Ss(t){if(G(this._surveyManager))return{eligible:!1,reason:As};var e=typeof t=="string"?this.Es(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(G(this._surveyManager))return Q.warn("init was not called"),{visible:!1,disabledReason:As};var e=this.Ss(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return G(this._surveyManager)?(Q.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:As})):new Promise(n=>{this.getSurveys(r=>{var s,i=(s=r.find(a=>a.id===t))!==null&&s!==void 0?s:null;if(i){var o=this.Ss(i);n({visible:o.eligible,disabledReason:o.reason})}else n({visible:!1,disabledReason:"Survey not found"})},e)})}renderSurvey(t,e,n){var r;if(G(this._surveyManager))Q.warn("init was not called");else{var s=typeof t=="string"?this.Es(t):t;if(s!=null&&s.id)if(Sv.includes(s.type)){var i=$==null?void 0:$.querySelector(e);if(i)return(r=s.appearance)!=null&&r.surveyPopupDelaySeconds?(Q.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout(()=>{var o,a;Q.info("Rendering survey "+s.id+" with delay of "+((o=s.appearance)==null?void 0:o.surveyPopupDelaySeconds)+" seconds"),(a=this._surveyManager)==null||a.renderSurvey(s,i,n),Q.info("Survey "+s.id+" rendered")},1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,i,n);Q.warn("Survey element not found")}else Q.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Q.warn("Survey not found")}}displaySurvey(t,e){var n;if(G(this._surveyManager))Q.warn("init was not called");else{var r=this.Es(t);if(r){var s=r;if((n=r.appearance)!=null&&n.surveyPopupDelaySeconds&&e.ignoreDelay&&(s=T({},r,{appearance:T({},r.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==Ei.Popover&&e.initialResponses&&Q.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),e.ignoreConditions===!1){var i=this.canRenderSurvey(r);if(!i.visible)return void Q.warn("Survey is not eligible to be displayed: ",i.disabledReason)}e.displayType!==Ei.Inline?this._surveyManager.handlePopoverSurvey(s,e):this.renderSurvey(s,e.selector,e.properties)}else Q.warn("Survey not found")}}cancelPendingSurvey(t){G(this._surveyManager)?Q.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;(t=this._surveyManager)==null||t.handlePageUnload()}}},rs),Qv={toolbar:class{constructor(t){this.instance=t}xs(t){M.ph_toolbar_state=t}Ts(){var t;return(t=M.ph_toolbar_state)!==null&&t!==void 0?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,e,n){if(t===void 0&&(t=void 0),e===void 0&&(e=void 0),n===void 0&&(n=void 0),vu(this.instance.config)||!v||!$)return!1;t=t??v.location,n=n??v.history;try{if(!e){try{v.localStorage.setItem("test","test"),v.localStorage.removeItem("test")}catch{return!1}e=v==null?void 0:v.localStorage}var r,s=Wv||Fr(t.hash,"__posthog")||Fr(t.hash,"state"),i=s?Fa(()=>JSON.parse(atob(decodeURIComponent(s))))||Fa(()=>JSON.parse(decodeURIComponent(s))):null;return i&&i.action==="ph_authorize"?((r=i).source="url",r&&Object.keys(r).length>0&&(i.desiredHash?t.hash=i.desiredHash:n?n.replaceState(n.state,"",t.pathname+t.search):t.hash="")):((r=JSON.parse(e.getItem(ml)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch{return!1}}$s(t){var e=M.ph_load_toolbar||M.ph_load_editor;!G(e)&&Ke(e)?e(t,this.instance):yl.warn("No toolbar load function found")}loadToolbar(t){var e=!($==null||!$.getElementById(gu));if(!v||e)return!1;var n=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,r=T({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},n?{instrument:!1}:{});if(v.localStorage.setItem(ml,JSON.stringify(T({},r,{source:void 0}))),this.Ts()===2)this.$s(r);else if(this.Ts()===0){var s;this.xs(1),(s=M.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this.instance,"toolbar",i=>{if(i)return yl.error("[Toolbar] Failed to load",i),void this.xs(0);this.xs(2),this.$s(r)}),he(v,"turbolinks:load",()=>{this.xs(0),this.loadToolbar(r)})}return!0}ks(t){return this.loadToolbar(t)}maybeLoadEditor(t,e,n){return t===void 0&&(t=void 0),e===void 0&&(e=void 0),n===void 0&&(n=void 0),this.maybeLoadToolbar(t,e,n)}}},em=T({experiments:be},rs),tm={conversations:class{constructor(t){this.Rs=void 0,this._conversationsManager=null,this.Ps=!1,this.Os=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations){var e=t.conversations;G(e)||(Xe(e)?this.Rs=e:(this.Rs=e.enabled,this.Os=e),this.loadIfEnabled())}}reset(){var t;(t=this._conversationsManager)==null||t.reset(),this._conversationsManager=null,this.Rs=void 0,this.Os=null}loadIfEnabled(){if(!(this._conversationsManager||this.Ps||this._instance.config.disable_conversations||vu(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=M==null?void 0:M.__PosthogExtensions__;if(t&&!O(this.Rs)&&this.Rs)if(this.Os&&this.Os.token){this.Ps=!0;try{var e=t.initConversations;if(e)return this.Is(e),void(this.Ps=!1);var n=t.loadExternalDependency;if(!n)return void this.Cs(ro);n(this._instance,"conversations",r=>{r||!t.initConversations?this.Cs("Could not load conversations script",r):this.Is(t.initConversations),this.Ps=!1})}catch(r){this.Cs("Error initializing conversations",r),this.Ps=!1}}else Ae.error("Conversations enabled but missing token in remote config.")}}Is(t){if(this.Os)try{this._conversationsManager=t(this.Os,this._instance),Ae.info("Conversations loaded successfully")}catch(e){this.Cs("Error completing conversations initialization",e)}else Ae.error("Cannot complete initialization: remote config is null")}Cs(t,e){Ae.error(t,e),this._conversationsManager=null,this.Ps=!1}show(){this._conversationsManager?this._conversationsManager.show():Ae.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Rs===!0&&!rt(this._conversationsManager)}isVisible(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.isVisible())!==null&&t!==void 0&&t}sendMessage(t,e,n){var r=this;return De(function*(){return r._conversationsManager?r._conversationsManager.sendMessage(t,e,n):(Ae.warn(wt),null)})()}getMessages(t,e){var n=this;return De(function*(){return n._conversationsManager?n._conversationsManager.getMessages(t,e):(Ae.warn(wt),null)})()}markAsRead(t){var e=this;return De(function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(Ae.warn(wt),null)})()}getTickets(t){var e=this;return De(function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(Ae.warn(wt),null)})()}requestRestoreLink(t){var e=this;return De(function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(Ae.warn(wt),null)})()}restoreFromToken(t){var e=this;return De(function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(Ae.warn(wt),null)})()}restoreFromUrlToken(){var t=this;return De(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Ae.warn(wt),null)})()}getCurrentTicketId(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.getCurrentTicketId())!==null&&t!==void 0?t:null}getWidgetSessionId(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.getWidgetSessionId())!==null&&t!==void 0?t:null}}},nm={logs:class{constructor(t){var e;this.Fs=!1,this.As=!1,this._instance=t,this._instance&&(e=this._instance.config.logs)!=null&&e.captureConsoleLogs&&(this.Fs=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var e,n=(e=t.logs)==null?void 0:e.captureConsoleLogs;!G(n)&&n&&(this.Fs=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.Fs&&!this.As){var t=oe("[logs]"),e=M==null?void 0:M.__PosthogExtensions__;if(e){var n=e.loadExternalDependency;n?n(this._instance,"logs",r=>{var s;r||(s=e.logs)==null||!s.initializeLogs?t.error("Could not load logs script",r):(e.logs.initializeLogs(this._instance),this.As=!0)}):t.error(ro)}else t.error("PostHog Extensions not found.")}}}},rm=T({},rs,Gv,Vv,Yv,Kv,Jv,Zv,Xv,Qv,em,tm,nm);Be.__defaultExtensionClasses=T({},rm);var xl,_t=(xl=Cn[Ht]=new Be,function(){function t(){t.done||(t.done=!0,ju=!1,te(Cn,function(e){e._dom_loaded()}))}$!=null&&$.addEventListener?$.readyState==="complete"?t():he($,"DOMContentLoaded",t,{capture:!1}):v&&R.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),xl),jn,ue,Ds,Il,Ur=0,Yu=[],pe=re,Tl=pe.__b,Pl=pe.__r,Cl=pe.diffed,$l=pe.__c,Rl=pe.unmount,Ol=pe.__;function uo(t,e){pe.__h&&pe.__h(ue,t,Ur||e),Ur=0;var n=ue.__H||(ue.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function W(t){return Ur=1,sm(Ju,t)}function sm(t,e,n){var r=uo(jn++,2);if(r.t=t,!r.__c&&(r.__=[Ju(void 0,e),function(a){var l=r.__N?r.__N[0]:r.__[0],c=r.t(l,a);l!==c&&(r.__N=[c,r.__[1]],r.__c.setState({}))}],r.__c=ue,!ue.__f)){var s=function(a,l,c){if(!r.__c.__H)return!0;var u=r.__c.__H.__.filter(function(p){return p.__c});if(u.every(function(p){return!p.__N}))return!i||i.call(this,a,l,c);var d=r.__c.props!==a;return u.some(function(p){if(p.__N){var f=p.__[0];p.__=p.__N,p.__N=void 0,f!==p.__[0]&&(d=!0)}}),i&&i.call(this,a,l,c)||d};ue.__f=!0;var i=ue.shouldComponentUpdate,o=ue.componentWillUpdate;ue.componentWillUpdate=function(a,l,c){if(this.__e){var u=i;i=void 0,s(a,l,c),i=u}o&&o.call(this,a,l,c)},ue.shouldComponentUpdate=s}return r.__N||r.__}function rn(t,e){var n=uo(jn++,3);!pe.__s&&Ku(n.__H,e)&&(n.__=t,n.u=e,ue.__H.__h.push(n))}function im(t,e){var n=uo(jn++,7);return Ku(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function pt(t,e){return Ur=8,im(function(){return t},e)}function om(){for(var t;t=Yu.shift();){var e=t.__H;if(t.__P&&e)try{e.__h.some(_r),e.__h.some(Oi),e.__h=[]}catch(n){e.__h=[],pe.__e(n,t.__v)}}}pe.__b=function(t){ue=null,Tl&&Tl(t)},pe.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Ol&&Ol(t,e)},pe.__r=function(t){Pl&&Pl(t),jn=0;var e=(ue=t.__c).__H;e&&(Ds===ue?(e.__h=[],ue.__h=[],e.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.some(_r),e.__h.some(Oi),e.__h=[],jn=0)),Ds=ue},pe.diffed=function(t){Cl&&Cl(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Yu.push(e)!==1&&Il===pe.requestAnimationFrame||((Il=pe.requestAnimationFrame)||am)(om)),e.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Ds=ue=null},pe.__c=function(t,e){e.some(function(n){try{n.__h.some(_r),n.__h=n.__h.filter(function(r){return!r.__||Oi(r)})}catch(r){e.some(function(s){s.__h&&(s.__h=[])}),e=[],pe.__e(r,n.__v)}}),$l&&$l(t,e)},pe.unmount=function(t){Rl&&Rl(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.some(function(r){try{_r(r)}catch(s){e=s}}),n.__H=void 0,e&&pe.__e(e,n.__v))};var Al=typeof requestAnimationFrame=="function";function am(t){var e,n=function(){clearTimeout(r),Al&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,35);Al&&(e=requestAnimationFrame(n))}function _r(t){var e=ue,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),ue=e}function Oi(t){var e=ue;t.__c=t.__(),ue=e}function Ku(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function Ju(t,e){return typeof e=="function"?e(t):e}const lm="";async function ie(t,e,n){const r={method:t,headers:{"Content-Type":"application/json"},credentials:"include"};n&&(r.body=JSON.stringify(n));const s=await fetch(lm+e,r);if(s.status===401)return{status:401,data:null,unauthorized:!0};const i=await s.json().catch(()=>null);return{status:s.status,data:i}}async function cm(){try{const e=await(await fetch("/api/auth/sign-in/social",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({provider:"google",callbackURL:"/dashboard"})})).json().catch(()=>null);if(e!=null&&e.url){window.location.href=e.url;return}}catch{}window.location.href="/api/auth/sign-in/social?provider=google&callbackURL=/dashboard"}function Hr({text:t,label:e="Copy"}){const[n,r]=W(!1);return h("button",{class:"btn-copy",onClick:()=>{navigator.clipboard.writeText(t),r(!0),setTimeout(()=>r(!1),2e3)}},n?"✓ Copied!":e)}function Br(t){if(!t)return"never";const e=Math.floor((Date.now()-t)/1e3);return e<60?`${e}s ago`:e<3600?`${Math.floor(e/60)}m ago`:e<86400?`${Math.floor(e/3600)}h ago`:`${Math.floor(e/86400)}d ago`}function um(){var z,ee,V,le;const[t,e]=W(!0),[n,r]=W(null),[s,i]=W([]),[o,a]=W([]),[l,c]=W(null),[u,d]=W(null),[p,f]=W(null),[g,_]=W("start"),[P,m]=W(!1),[b,C]=W(!1),[x,S]=W(!1),[k,w]=W(!1),E=pt(async()=>{var y;const D=await ie("GET","/v1/me");if(D!=null&&D.unauthorized){w(!0);return}D!=null&&D.data&&(r(D.data),(y=D.data.user)!=null&&y.email&&(_t.identify(D.data.user.id||D.data.user.email,{email:D.data.user.email,name:D.data.user.name}),_t.capture("dashboard_sign_in")))},[]),I=pt(async()=>{var y;const D=await ie("GET","/v1/api-keys");D&&i(((y=D.data)==null?void 0:y.api_keys)||[])},[]),A=pt(async()=>{var y;const D=await ie("GET","/v1/browser-sessions");D&&a(((y=D.data)==null?void 0:y.sessions)||[])},[]),j=pt(async()=>{const D=await ie("GET","/v1/usage");D&&c(D.data)},[]),F=pt(async()=>{const D=await ie("GET","/v1/billing/credits");D&&d(D.data)},[]);if(rn(()=>{Promise.all([E(),I(),A(),j(),F()]).then(()=>e(!1));const D=setInterval(A,5e3);return()=>clearInterval(D)},[]),rn(()=>{const D=y=>{var X,de;((X=y.data)==null?void 0:X.type)==="HANZI_EXTENSION_READY"&&m(!0),((de=y.data)==null?void 0:de.type)==="HANZI_PAIR_RESULT"&&(C(!1),y.data.success?(S(!0),A()):f("Pairing failed: "+(y.data.error||"unknown")))};return window.addEventListener("message",D),window.postMessage({type:"HANZI_PING"},"*"),()=>window.removeEventListener("message",D)},[]),t)return h(Nl,null);if(k)return cm(),h(Nl,null);const H=((ee=(z=n==null?void 0:n.user)==null?void 0:z.name)==null?void 0:ee.split(" ")[0])||"there",B=(V=n==null?void 0:n.user)!=null&&V.name?`${n.user.name}'s workspace`:"Your workspace",K=s.length>0,Z=o.find(D=>D.status==="connected"),N=!!Z||x;return h("div",{class:"page"},h("div",{class:"header"},h("div",null,h("h1",null,B),h("div",{class:"subtitle"},"Hi, ",H)),h("div",{style:{display:"flex",alignItems:"center",gap:12}},u&&h("div",{style:{textAlign:"right",fontSize:13,color:"var(--muted)"}},h("div",null,h("strong",{style:{color:"var(--ink)",fontSize:16}},(u.free_remaining||0)+(u.credit_balance||0))," tasks left"),h("div",null,u.free_remaining||0," free + ",u.credit_balance||0," credits")),h("button",{class:"signout",onClick:vm},"Sign out"))),h("div",{class:"tabs"},h("button",{class:`tab ${g==="start"?"active":""}`,onClick:()=>_("start")},"Getting Started"),h("button",{class:`tab ${g==="sessions"?"active":""}`,onClick:()=>_("sessions")},"Sessions",o.length>0&&h("span",{class:"tab-count"},o.filter(D=>D.status==="connected").length)),h("button",{class:`tab ${g==="settings"?"active":""}`,onClick:()=>_("settings")},"Settings")),g==="start"&&h(dm,{keys:s,loadKeys:I,setError:f,extensionReady:P,pairing:b,paired:x,setPairing:C,setPaired:S,hasKeys:K,hasConnected:N,connectedSession:Z,sessions:o,loadSessions:A,loadUsage:j,setTab:_}),g==="sessions"&&h(pm,{sessions:o,onRefresh:A,usage:l}),g==="settings"&&h(fm,{keys:s,loadKeys:I,setError:f,profile:n,credits:u,loadCredits:F}),g==="automations"&&h(gm,{sessions:o,workspaceId:(le=n==null?void 0:n.workspace)==null?void 0:le.id,setError:f}),p&&h("div",{class:"error-toast",onClick:()=>f(null)},p))}function dm({keys:t,loadKeys:e,setError:n,extensionReady:r,pairing:s,paired:i,setPairing:o,setPaired:a,hasKeys:l,hasConnected:c,connectedSession:u,sessions:d,loadSessions:p,loadUsage:f,setTab:g}){var Z;const[_,P]=W(""),[m,b]=W(null),[C,x]=W("Go to example.com and tell me the page title"),[S,k]=W(null),[w,E]=W(""),[I,A]=W(0),j=S==="complete",F=async()=>{var z;if(!_.trim())return;const N=await ie("POST","/v1/api-keys",{name:_.trim()});(N==null?void 0:N.status)===201?(b(N.data.key),P(""),await e()):n(((z=N==null?void 0:N.data)==null?void 0:z.error)||"Failed")},H=async()=>{var z;o(!0),_t.capture("connect_browser_clicked");const N=await ie("POST","/v1/browser-sessions/pair",{label:"Developer testing"});if(!N||N.status!==201){o(!1),n(((z=N==null?void 0:N.data)==null?void 0:z.error)||"Failed");return}window.postMessage({type:"HANZI_PAIR",token:N.data.pairing_token,apiUrl:location.origin},"*"),setTimeout(()=>o(ee=>ee&&(n("Extension did not respond."),!1)),5e3)},B=async()=>{var le,D,y,X,de,ye;const N=(u==null?void 0:u.id)||((le=d.find(xe=>xe.status==="connected"))==null?void 0:le.id);if(!C.trim())return;if(!N){k("error"),E("No connected browser session found. Try refreshing the page.");return}k("running"),E(""),A(0),_t.capture("test_task_run");const z=await ie("POST","/v1/tasks",{task:C.trim(),browser_session_id:N});if(!z||z.status!==201){k("error"),E(((D=z==null?void 0:z.data)==null?void 0:D.error)||"Failed");return}const ee=z.data.id,V=Date.now()+3*60*1e3;for(;Date.now()<V;){await new Promise(Pe=>setTimeout(Pe,2e3));const xe=await ie("GET",`/v1/tasks/${ee}`);if(!xe)break;if(A(((y=xe.data)==null?void 0:y.steps)||0),((X=xe.data)==null?void 0:X.status)!=="running"){k(((de=xe.data)==null?void 0:de.status)||"error"),E(((ye=xe.data)==null?void 0:ye.answer)||"No answer."),f();return}}k("error"),E("Timed out after 3 minutes.")},K=`Add browser automation to this project using the Hanzi API. Read the codebase first, then ask me:
17
17
 
18
18
  1. What browser task should Hanzi automate? (e.g. "read patient chart", "fill out a form", "extract data from a web portal")
19
19
  2. Where in the UI should the browser pairing flow go? (e.g. settings page, onboarding, a dedicated page)
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Hanzi Developer Console</title>
7
- <script type="module" crossorigin src="/dashboard/assets/index-wVMUNuBA.js"></script>
7
+ <script type="module" crossorigin src="/dashboard/assets/index-dnFOSpJs.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/dashboard/assets/index-vMQ9aDcG.css">
9
9
  </head>
10
10
  <body>
@@ -50,6 +50,8 @@ export interface LLMResponse {
50
50
  };
51
51
  /** The model that produced this response (for billing attribution) */
52
52
  model?: string;
53
+ /** Raw Gemini response parts — preserves thought signatures for Gemini 3+ */
54
+ _rawGeminiParts?: any[];
53
55
  }
54
56
  export interface CallLLMParams {
55
57
  messages: Message[];
@@ -107,9 +107,15 @@ function convertMessages(messages) {
107
107
  else if (block.type === "tool_use") {
108
108
  const tu = block;
109
109
  toolUseIdToName[tu.id] = tu.name;
110
- parts.push({
111
- functionCall: { name: tu.name, args: tu.input },
112
- });
110
+ // If raw Gemini parts are available (with thought signatures), use them
111
+ if (msg._rawGeminiParts) {
112
+ // Raw parts already added below — skip individual conversion
113
+ }
114
+ else {
115
+ parts.push({
116
+ functionCall: { name: tu.name, args: tu.input },
117
+ });
118
+ }
113
119
  }
114
120
  else if (block.type === "tool_result") {
115
121
  const tr = block;
@@ -141,7 +147,12 @@ function convertMessages(messages) {
141
147
  }
142
148
  }
143
149
  }
144
- if (parts.length > 0) {
150
+ // Gemini 3+: if raw parts with thought signatures are available, use them directly
151
+ // for the model turn (preserves thought_signature fields that Gemini 3 requires)
152
+ if (role === "model" && msg._rawGeminiParts) {
153
+ geminiMessages.push({ role, parts: msg._rawGeminiParts });
154
+ }
155
+ else if (parts.length > 0) {
145
156
  geminiMessages.push({ role, parts });
146
157
  }
147
158
  }
@@ -208,6 +219,7 @@ async function parseGeminiStream(response, onText, signal) {
208
219
  const toolCalls = [];
209
220
  let stopReason = "end_turn";
210
221
  let usage = { input_tokens: 0, output_tokens: 0 };
222
+ let rawModelParts = null; // Gemini 3: preserve thought signatures
211
223
  try {
212
224
  while (true) {
213
225
  if (signal?.aborted) {
@@ -235,6 +247,10 @@ async function parseGeminiStream(response, onText, signal) {
235
247
  if (!candidate)
236
248
  continue;
237
249
  const parts = candidate.content?.parts || [];
250
+ // Capture raw parts for thought signature passthrough (Gemini 3+)
251
+ if (!rawModelParts)
252
+ rawModelParts = [];
253
+ rawModelParts.push(...parts);
238
254
  for (const part of parts) {
239
255
  if (part.text) {
240
256
  currentText += part.text;
@@ -276,7 +292,7 @@ async function parseGeminiStream(response, onText, signal) {
276
292
  if (toolCalls.length > 0) {
277
293
  stopReason = "tool_use";
278
294
  }
279
- return { content, stop_reason: stopReason, usage };
295
+ return { content, stop_reason: stopReason, usage, _rawGeminiParts: rawModelParts || undefined };
280
296
  }
281
297
  // --- Main Call ---
282
298
  /**
@@ -289,7 +305,7 @@ export async function callVertexLLM(params) {
289
305
  if (!vertexConfig) {
290
306
  throw new Error("Vertex AI not initialized. Call initVertex() first.");
291
307
  }
292
- const { messages, system, tools, model = "gemini-2.5-flash", maxTokens = 16384, signal, onText, } = params;
308
+ const { messages, system, tools, model = "gemini-3-flash-preview", maxTokens = 16384, signal, onText, } = params;
293
309
  const { projectId } = vertexConfig;
294
310
  // Use global endpoint — Google routes to whichever region has capacity,
295
311
  // reducing 429s compared to pinning to a single region.
@@ -644,7 +644,23 @@ async function handleCreateTask(body, apiKey, requestId) {
644
644
  executeTool: async (toolName, toolInput) => {
645
645
  const startMs = Date.now();
646
646
  const result = await executeToolViaRelay(toolName, toolInput, browser_session_id);
647
- // Save screenshot from tool result (best-effort)
647
+ const durationMs = Date.now() - startMs;
648
+ // Save tool result content (best-effort) — enables browsing log access via GET /v1/tasks/:id/steps
649
+ const rawOutput = result.output;
650
+ const toolOutput = typeof rawOutput === "string" ? rawOutput
651
+ : rawOutput ? JSON.stringify(rawOutput).slice(0, 50000)
652
+ : "";
653
+ if (toolOutput) {
654
+ S.insertTaskStep({
655
+ taskRunId: taskRun.id,
656
+ step: currentStep,
657
+ status: "tool_output",
658
+ toolName,
659
+ output: toolOutput.slice(0, 50000), // cap at 50KB per step
660
+ durationMs,
661
+ }).catch(() => { });
662
+ }
663
+ // Save screenshot from tool result
648
664
  if (result.screenshot?.data) {
649
665
  S.insertTaskStep({
650
666
  taskRunId: taskRun.id,
@@ -652,7 +668,7 @@ async function handleCreateTask(body, apiKey, requestId) {
652
668
  status: "screenshot",
653
669
  toolName,
654
670
  screenshot: result.screenshot.data,
655
- durationMs: Date.now() - startMs,
671
+ durationMs,
656
672
  }).catch(() => { });
657
673
  }
658
674
  return result;
@@ -737,6 +753,15 @@ async function handleCreateTask(body, apiKey, requestId) {
737
753
  }
738
754
  }
739
755
  if (updated) {
756
+ // Send task_complete to extension so overlay hides
757
+ if (relayConnection) {
758
+ relayConnection.send({
759
+ type: "task_complete",
760
+ targetSessionId: browser_session_id,
761
+ taskId: taskRun.id,
762
+ answer: result.answer,
763
+ });
764
+ }
740
765
  trackManagedEvent("task_completed", apiKey.workspaceId, {
741
766
  steps: result.steps,
742
767
  duration_ms: Date.now() - taskStartedAt,
@@ -969,7 +994,24 @@ async function handleRequest(req, res) {
969
994
  return;
970
995
  }
971
996
  }
972
- // --- Embeddable pairing snippet ---
997
+ // --- Embeddable pairing component (Stripe Elements-style) ---
998
+ if (method === "GET" && url === "/embed.js") {
999
+ const embedPath = join(process.cwd(), "landing/embed.js");
1000
+ if (existsSync(embedPath)) {
1001
+ res.writeHead(200, {
1002
+ "Content-Type": "application/javascript",
1003
+ "Access-Control-Allow-Origin": "*",
1004
+ "Cache-Control": "public, max-age=3600",
1005
+ });
1006
+ res.end(readFileSync(embedPath));
1007
+ }
1008
+ else {
1009
+ res.writeHead(404);
1010
+ res.end("Not found");
1011
+ }
1012
+ return;
1013
+ }
1014
+ // --- Legacy pairing snippet ---
973
1015
  if (method === "GET" && url === "/hanzi-pair.js") {
974
1016
  const snippetPath = join(process.cwd(), "sdk/hanzi-pair.js");
975
1017
  if (existsSync(snippetPath)) {
@@ -1532,7 +1574,16 @@ export async function runInternalTask(params) {
1532
1574
  task,
1533
1575
  url,
1534
1576
  executeTool: async (toolName, toolInput) => {
1535
- return executeToolViaRelay(toolName, toolInput, browserSessionId);
1577
+ const result = await executeToolViaRelay(toolName, toolInput, browserSessionId);
1578
+ // Save tool output for browsing log
1579
+ const rawOutput = result.output;
1580
+ const toolOutput = typeof rawOutput === "string" ? rawOutput
1581
+ : rawOutput ? JSON.stringify(rawOutput).slice(0, 50000)
1582
+ : "";
1583
+ if (toolOutput) {
1584
+ S.insertTaskStep({ taskRunId: taskRun.id, step: currentStep, status: "tool_output", toolName, output: toolOutput.slice(0, 50000) }).catch(() => { });
1585
+ }
1586
+ return result;
1536
1587
  },
1537
1588
  onStep: (step) => {
1538
1589
  currentStep = step.step;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hanzi-browse",
3
- "version": "2.2.3",
3
+ "version": "2.3.0",
4
4
  "description": "Give your AI agent a real browser — click, type, fill forms, test workflows, post content, and read authenticated pages",
5
5
  "license": "PolyForm-Noncommercial-1.0.0",
6
6
  "author": "hanzili",