@hellcoder/companion 0.115.1-preview.20260810022508.26d89b3 → 0.116.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.
- package/dist/assets/{AgentsPage-CF3SGtxh.js → AgentsPage-BBi92OuO.js} +1 -1
- package/dist/assets/{CronManager-Bd7Y5oVN.js → CronManager-DxLaNh9T.js} +1 -1
- package/dist/assets/{DashboardPage-DExUR_C4.js → DashboardPage-BvuDoRlp.js} +1 -1
- package/dist/assets/{IntegrationsPage-qtFQh0W4.js → IntegrationsPage-CK_ThzWg.js} +1 -1
- package/dist/assets/{LinearOAuthSettingsPage-BQI6rpIY.js → LinearOAuthSettingsPage-InTf-E7u.js} +1 -1
- package/dist/assets/{LinearSettingsPage-xRA0eYZu.js → LinearSettingsPage-BwjC9Vd-.js} +1 -1
- package/dist/assets/{Playground-D4grJraF.js → Playground-DlzomEOu.js} +1 -1
- package/dist/assets/{PromptsPage-HjtFVFMk.js → PromptsPage-hRZhLUYR.js} +1 -1
- package/dist/assets/{RunsPage-BRn8vlFq.js → RunsPage-zsVmbFoi.js} +1 -1
- package/dist/assets/{SandboxManager-CzLhWS6u.js → SandboxManager-Bq_aXA1z.js} +1 -1
- package/dist/assets/{SettingsPage-BqgHW-iW.js → SettingsPage-BvrrlEKj.js} +1 -1
- package/dist/assets/{TailscalePage-Bwn1jXsi.js → TailscalePage-fE7Z9uiF.js} +1 -1
- package/dist/assets/{index-DMY5BpXd.js → index--SnXduR0.js} +3 -3
- package/dist/assets/{sw-register-CtxuO43W.js → sw-register-Cjt2BQTW.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/sw.js +1 -1
- package/package.json +1 -1
|
@@ -63,7 +63,7 @@ Error generating stack: `+d.message+`
|
|
|
63
63
|
|
|
64
64
|
Details: ${t}`:`Error: ${t}`}function _C(e,t){const n=vc.get(e)||[];n.push(t),vc.set(e,n)}function wC(e,t){const n=vc.get(e);if(!(!(n!=null&&n.length)||t.readyState!==WebSocket.OPEN)){vc.delete(e);for(const i of n)t.send(JSON.stringify(i))}}const Di=new Map;function $b(e,t,n){const i=X.getState(),a=i.messages.get(e)||[],o=ac.get(e);let u=a.filter(h=>!h.isStreaming||h.id===o),f=-1;if(o&&(f=u.findIndex(h=>h.id===o),f===-1&&ac.delete(e)),f===-1){const h=`stream-${e}-${oi()}`;ac.set(e,h),u=[...u,{id:h,role:"assistant",content:t,timestamp:Date.now(),isStreaming:!0,streamingPhase:n}]}else{u=[...u];const h=u[f];u[f]={...h,role:"assistant",content:t,isStreaming:!0,streamingPhase:n}}i.setMessages(e,u)}function Ss(e){ac.delete(e);const t=X.getState(),n=t.messages.get(e)||[],i=n.filter(a=>!a.isStreaming);return i.length!==n.length?(t.setMessages(e,i),!0):!1}const Fb=new Map,SC=8e3;function dl(e,t,n={}){if(console.warn(`[companion:session-event] ${t}`,{sessionId:e,...n.detail??{}}),!n.userText)return;const i=Date.now(),a=Fb.get(e);a&&a.code===t&&i-a.at<SC||(Fb.set(e,{code:t,at:i}),X.getState().appendMessage(e,{id:`companion-notice-${t}-${i}`,role:"system",content:n.userText,timestamp:i,meta:!0,metaCode:t}))}function E5(){return`cmsg-${Date.now()}-${++yC}`}function $m(){return E5()}const kC=new Set(["user_message","permission_response","interrupt","set_model","set_permission_mode","mcp_get_status","mcp_toggle","mcp_reconnect","mcp_set_servers","set_ai_validation"]);function jC(e){const t=location.protocol==="https:"?"wss:":"ws:",n=localStorage.getItem("companion_auth_token")||"";return`${t}//${location.host}/ws/browser/${e}?token=${encodeURIComponent(n)}`}function T5(e){return`companion:last-seq:${e}`}function Fm(e){const t=zd.get(e);if(typeof t=="number")return t;try{const n=localStorage.getItem(T5(e)),i=n?Number(n):0,a=Number.isFinite(i)?Math.max(0,Math.floor(i)):0;return zd.set(e,a),a}catch{return 0}}function Ub(e,t){const n=Math.max(0,Math.floor(t));zd.set(e,n);try{localStorage.setItem(T5(e),String(n))}catch{}}function Ib(e,t){Fn(e,{type:"session_ack",last_seq:t})}function jd(e){return e.map(t=>t.type==="text"?t.text:t.type==="thinking"?t.thinking:"").filter(Boolean).join(`
|
|
65
65
|
`)}function Op(e){return e.type==="thinking"?`thinking:${e.thinking}`:e.type==="text"?`text:${e.text}`:e.type==="tool_use"?`tool_use:${e.id}`:e.type==="tool_result"?`tool_result:${e.tool_use_id}`:JSON.stringify(e)}function NC(e,t){const n=e||[],i=t||[];if(n.length===0&&i.length===0)return;const a=new Map;for(const f of i)a.set(Op(f),f);const o=[],u=new Set;for(const f of n){const h=Op(f);u.has(h)||(u.add(h),o.push(a.get(h)||f))}for(const f of i){const h=Op(f);u.has(h)||(u.add(h),o.push(f))}return o}function Hb(e,t,n,i,a){return{toolUseId:e,toolName:t,preview:xc(t,n),startedAt:i,elapsedSeconds:0,isError:!1,parentToolUseId:a||void 0}}function Um(e,t){const n=NC(e.contentBlocks,t.contentBlocks),i=n&&n.length>0?jd(n):t.content||e.content;return{...e,...t,content:i,contentBlocks:n,timestamp:e.timestamp??t.timestamp,isStreaming:t.isStreaming}}function CC(e,t){const n=X.getState(),i=n.messages.get(e)||[],a=i.findIndex(u=>u.role==="assistant"&&u.id===t.id);if(a===-1){n.appendMessage(e,t);return}const o=[...i];o[a]=Um(o[a],t),n.setMessages(e,o)}function EC(e,t){var a,o;let n;try{n=JSON.parse(t.data)}catch{console.warn(`[ws] Failed to parse incoming message for session ${e}:`,(o=(a=t.data)==null?void 0:a.substring)==null?void 0:o.call(a,0,120));return}const i=X.getState();i.connectionStatus.get(e)==="connecting"&&i.setConnectionStatus(e,"connected"),A5(e,n)}function A5(e,t,n={}){var u,f,h,p,g,x;const{processSeq:i=!0,ackSeqMessage:a=!0}=n,o=X.getState();if(i&&typeof t.seq=="number"){const b=Fm(e);if(t.seq<=b)return;Ub(e,t.seq),a&&Ib(e,t.seq)}switch(hC.has(t.type)&&o.setLastActivity(e,Date.now()),t.type){case"session_init":{const b=o.sessions.get(e);if(o.addSession(t.session),o.setCliConnected(e,!0),o.setCliReconnecting(e,!1),b||o.setSessionStatus(e,"idle"),!o.sessionNames.has(e)){const y=new Set(o.sessionNames.values()),_=y5(y);o.setSessionName(e,_)}break}case"session_update":{o.updateSession(e,t.session);break}case"assistant":{const b=t.message;if(b.model==="<synthetic>"){Ss(e),o.setStreaming(e,null),dl(e,"synthetic_noop",{detail:{stopReason:b.stop_reason,text:jd(b.content).slice(0,120)},userText:"The session resumed without generating a new response. If it seems stuck, resend your last message."});break}const y=jd(b.content),_={id:b.id,role:"assistant",content:y,contentBlocks:b.content,timestamp:t.timestamp||Date.now(),parentToolUseId:t.parent_tool_use_id,model:b.model,stopReason:b.stop_reason};if(Ss(e),CC(e,_),o.setStreaming(e,null),Ns.delete(e),Di.delete(e),(u=b.content)!=null&&u.length)for(const j of b.content)j.type==="tool_result"&&o.clearToolProgress(e,j.tool_use_id);if(o.setSessionStatus(e,"running"),o.streamingStartedAt.has(e)||o.setStreamingStats(e,{startedAt:Date.now()}),(f=b.content)!=null&&f.length)for(const j of b.content){if(j.type==="tool_use"){const C=j.input||{};o.addToolActivity(e,Hb(j.id,j.name,C,t.timestamp||Date.now(),t.parent_tool_use_id))}j.type==="tool_result"&&o.updateToolActivity(e,j.tool_use_id,{completedAt:Date.now(),isError:!!j.is_error})}(h=b.content)!=null&&h.length&&(Rp(e,b.content),Lp(e,b.content),Dp(e,b.content),zp(e,b.content));break}case"stream_event":{const b=t.event;if(b&&typeof b=="object"){if(b.type==="message_start"&&(Ns.delete(e),Di.delete(e),Ss(e),o.setSessionStatus(e,"running"),o.streamingStartedAt.has(e)||o.setStreamingStats(e,{startedAt:Date.now(),outputTokens:0})),b.type==="content_block_delta"){const y=b.delta;if((y==null?void 0:y.type)==="text_delta"&&typeof y.text=="string"){const _=Di.get(e)||{thinking:"",text:""};Ns.get(e)==="thinking"&&(_.thinking=""),_.text+=y.text,Di.set(e,_),Ns.set(e,"text"),o.setStreaming(e,_.text),$b(e,_.text,"text")}if((y==null?void 0:y.type)==="thinking_delta"&&typeof y.thinking=="string"){const _=Di.get(e)||{thinking:"",text:""};_.thinking+=y.thinking,Di.set(e,_),Ns.set(e,"thinking"),o.setStreaming(e,_.thinking),$b(e,_.thinking,"thinking")}}if(b.type==="message_delta"){const y=b.usage;y!=null&&y.output_tokens&&o.setStreamingStats(e,{outputTokens:y.output_tokens})}}break}case"result":{Od.delete(e),Bd.delete(e);const b=t.data,y={total_cost_usd:b.total_cost_usd,num_turns:b.num_turns};if(typeof b.total_lines_added=="number"&&(y.total_lines_added=b.total_lines_added),typeof b.total_lines_removed=="number"&&(y.total_lines_removed=b.total_lines_removed),b.modelUsage){for(const _ of Object.values(b.modelUsage))if(_.contextWindow>0){const j=Math.round((_.inputTokens+_.outputTokens)/_.contextWindow*100);y.context_used_percent=Math.max(0,Math.min(j,100))}}o.updateSession(e,y),Ss(e),o.setStreaming(e,null),Ns.delete(e),Di.delete(e),o.setStreamingStats(e,null),o.clearToolProgress(e),o.setSessionStatus(e,"idle"),!document.hasFocus()&&o.notificationSound&&LN(),!document.hasFocus()&&o.notificationDesktop&&Ob("Session completed","Claude finished the task",e),b.is_error&&o.appendMessage(e,{id:oi(),role:"system",content:Pb(b),timestamp:Date.now()});break}case"permission_request":{if(o.addPermission(e,t.request),!document.hasFocus()&&o.notificationDesktop){const y=t.request;Ob("Permission needed",`${y.tool_name}: approve or deny`,y.request_id)}const b=t.request;if(b.tool_name&&b.input){const y=[{type:"tool_use",id:b.tool_use_id,name:b.tool_name,input:b.input}];Rp(e,y),Lp(e,y),Dp(e,y),zp(e,y)}break}case"permission_cancelled":{o.removePermission(e,t.request_id);break}case"permission_auto_resolved":{o.addAiResolvedPermission(e,{request:t.request,behavior:t.behavior,reason:t.reason,timestamp:Date.now()});break}case"tool_progress":{o.setToolProgress(e,t.tool_use_id,{toolName:t.tool_name,elapsedSeconds:t.elapsed_time_seconds}),o.updateToolActivity(e,t.tool_use_id,{elapsedSeconds:t.elapsed_time_seconds});break}case"tool_use_summary":{((p=o.sdkSessions.find(y=>y.sessionId===e))==null?void 0:p.backendType)==="codex"&&o.appendMessage(e,{id:oi(),role:"system",content:t.summary,timestamp:Date.now()});break}case"user_message":{o.appendMessage(e,{id:t.id||oi(),role:"user",content:t.content,timestamp:t.timestamp||Date.now()}),o.clearPromptSuggestions(e);break}case"system_event":{if(((g=t.event)==null?void 0:g.subtype)==="task_notification"){const{task_id:y,status:_,summary:j}=t.event;y&&_&&o.updateProcess(e,y,{status:_,completedAt:Date.now(),summary:j||void 0})}const b=Bb(t.event);if(!b)break;o.appendMessage(e,{id:oi(),role:"system",content:b,timestamp:t.timestamp||Date.now()});break}case"status_change":{t.status==="compacting"?o.setSessionStatus(e,"compacting"):o.setSessionStatus(e,t.status);break}case"auth_status":{t.error&&o.appendMessage(e,{id:oi(),role:"system",content:`Auth error: ${t.error}`,timestamp:Date.now()});break}case"error":{o.appendMessage(e,{id:oi(),role:"system",content:t.message,timestamp:Date.now()});break}case"session_phase":{const b=t.phase;b==="terminated"?(o.setCliConnected(e,!1),o.setCliReconnecting(e,!1),o.setSessionStatus(e,null),o.setStreaming(e,null),o.setStreamingStats(e,null),Ss(e)?dl(e,"interrupted_mid_stream",{detail:{trigger:"session_phase:terminated",previousPhase:t.previousPhase},userText:"Response interrupted — the session ended before the reply finished. It will resume automatically."}):dl(e,"session_terminated",{detail:{trigger:"session_phase:terminated",previousPhase:t.previousPhase,hadDraft:!1}})):b==="reconnecting"?(o.setCliConnected(e,!1),o.setCliReconnecting(e,!0),o.setSessionStatus(e,null),o.setStreaming(e,null),o.setStreamingStats(e,null),Ss(e)&&dl(e,"interrupted_mid_stream",{detail:{trigger:"session_phase:reconnecting",previousPhase:t.previousPhase},userText:"Response interrupted — reconnecting to the backend…"})):b==="starting"||b==="initializing"?(o.setCliConnected(e,!1),o.setCliReconnecting(e,!0)):(o.setCliConnected(e,!0),o.setCliReconnecting(e,!1),b==="ready"?o.setSessionStatus(e,"idle"):b==="streaming"?o.setSessionStatus(e,"running"):b==="compacting"?o.setSessionStatus(e,"compacting"):b==="awaiting_permission"&&o.setSessionStatus(e,"running"));break}case"cli_disconnected":{o.setCliConnected(e,!1),o.setCliReconnecting(e,!1),o.setSessionStatus(e,null),o.setStreaming(e,null),o.setStreamingStats(e,null),Ss(e)?dl(e,"interrupted_mid_stream",{detail:{trigger:"cli_disconnected"},userText:"Response interrupted — the backend disconnected before finishing. Trying to reconnect…"}):dl(e,"cli_disconnected",{detail:{trigger:"cli_disconnected",hadDraft:!1}});break}case"cli_connected":{o.setCliConnected(e,!0),o.setCliReconnecting(e,!1);break}case"session_name_update":{const b=o.sessionNames.get(e),y=b&&/^[A-Z][a-z]+ [A-Z][a-z]+$/.test(b);(!b||y)&&(o.setSessionName(e,t.name),o.markRecentlyRenamed(e));break}case"pr_status_update":{o.setPRStatus(e,{available:t.available,pr:t.pr});break}case"mcp_status":{o.setMcpServers(e,t.servers);break}case"rate_limit":{o.setRateLimit(e,t.info);break}case"message_history":{const b=[],y=new Map;for(let j=0;j<t.messages.length;j++){const C=t.messages[j];if(C.type==="user_message")b.push({id:C.id||oi(),role:"user",content:C.content,timestamp:C.timestamp});else if(C.type==="assistant"){const k=C.message,E=jd(k.content),N={id:k.id,role:"assistant",content:E,contentBlocks:k.content,timestamp:C.timestamp||Date.now(),parentToolUseId:C.parent_tool_use_id,model:k.model,stopReason:k.stop_reason},D=b.findIndex(O=>O.role==="assistant"&&O.id===N.id);if(D===-1?b.push(N):b[D]=Um(b[D],N),(x=k.content)!=null&&x.length){Rp(e,k.content),Lp(e,k.content),Dp(e,k.content),zp(e,k.content);const O=C.timestamp||Date.now();for(const L of k.content){if(L.type==="tool_use"){const G=L.input||{},P=y.get(L.id);y.set(L.id,P??Hb(L.id,L.name,G,O,C.parent_tool_use_id))}if(L.type==="tool_result"){const G=y.get(L.tool_use_id);G&&y.set(L.tool_use_id,{...G,completedAt:O,isError:G.isError||!!L.is_error,elapsedSeconds:Math.max(G.elapsedSeconds,G.completedAt?G.elapsedSeconds:Math.max(0,(O-G.startedAt)/1e3))})}}}}else if(C.type==="result"){const k=C.data;k.is_error&&b.push({id:`hist-error-${j}`,role:"system",content:Pb(k),timestamp:Date.now()});const E={total_cost_usd:k.total_cost_usd,num_turns:k.num_turns};if(typeof k.total_lines_added=="number"&&(E.total_lines_added=k.total_lines_added),typeof k.total_lines_removed=="number"&&(E.total_lines_removed=k.total_lines_removed),k.modelUsage){for(const N of Object.values(k.modelUsage))if(N.contextWindow>0){const D=N,O=Math.round((D.inputTokens+D.outputTokens)/D.contextWindow*100);E.context_used_percent=Math.max(0,Math.min(O,100))}}o.updateSession(e,E)}else if(C.type==="system_event"){const k=Bb(C.event);if(!k)continue;b.push({id:`hist-system-event-${j}`,role:"system",content:k,timestamp:C.timestamp||Date.now()})}}if(b.length>0){const j=o.messages.get(e)||[];if(j.length===0)o.setMessages(e,b);else{const C=[...j];for(const k of b){const E=C.findIndex(D=>D.id===k.id);if(E===-1){C.push(k);continue}const N=C[E];N.role==="assistant"&&k.role==="assistant"?C[E]=Um(N,k):C[E]=k}C.sort((k,E)=>(k.timestamp??0)-(E.timestamp??0)),o.setMessages(e,C)}}o.setToolActivity(e,Array.from(y.values()).sort((j,C)=>j.startedAt-C.startedAt));const _=t.messages[t.messages.length-1];(_==null?void 0:_.type)==="result"&&(Ss(e),o.setStreaming(e,null),Ns.delete(e),Di.delete(e),o.setStreamingStats(e,null),o.clearToolProgress(e),o.setSessionStatus(e,"idle"));break}case"event_replay":{let b;for(const y of t.events){const _=Fm(e);y.seq<=_||(Ub(e,y.seq),b=y.seq,A5(e,y.message,{processSeq:!1,ackSeqMessage:!1}))}typeof b=="number"&&Ib(e,b);break}case"prompt_suggestion":{const b=t.suggestions;o.setPromptSuggestions(e,b);break}case"streamlined_text":{o.appendMessage(e,{id:oi(),role:"assistant",content:t.text,timestamp:Date.now()});break}case"streamlined_tool_use_summary":{o.appendMessage(e,{id:oi(),role:"system",content:t.tool_summary,timestamp:Date.now()});break}default:{console.debug("[ws] Unhandled message type:",t.type);break}}}function Rc(e){const t=Yr.get(e);if(N5(t))return;if(t){try{t.close()}catch{}Yr.delete(e)}X.getState().setConnectionStatus(e,"connecting");const i=new WebSocket(jC(e));Yr.set(e,i),i.onopen=()=>{const a=Fm(e);i.send(JSON.stringify({type:"session_subscribe",last_seq:a})),wC(e,i);const o=qi.get(e);o&&(clearTimeout(o),qi.delete(e))},i.onmessage=a=>EC(e,a),i.onclose=()=>{Yr.get(e)===i&&(Yr.delete(e),X.getState().setConnectionStatus(e,"disconnected"),TC(e))},i.onerror=()=>{i.close()}}function TC(e){if(qi.has(e)||bc)return;const t=setTimeout(()=>{qi.delete(e),!bc&&C5(e)&&Rc(e)},fC);qi.set(e,t)}function Im(e){const t=qi.get(e);t&&(clearTimeout(t),qi.delete(e));const n=Yr.get(e);n&&(n.close(),Yr.delete(e)),X.getState().setConnectionStatus(e,"disconnected"),Od.delete(e),Bd.delete(e),Zo.delete(e),Sd.delete(e),Ns.delete(e),ac.delete(e),Di.delete(e),zd.delete(e),vc.delete(e)}function AC(e){if(!bc)for(const t of e)t.archived||Rc(t.sessionId)}function MC(e){return new Promise((t,n)=>{const i=setInterval(()=>{const o=Yr.get(e);(o==null?void 0:o.readyState)===WebSocket.OPEN&&(clearInterval(i),clearTimeout(a),t())},50),a=setTimeout(()=>{clearInterval(i),n(new Error("Connection timeout"))},1e4)})}function Fn(e,t){const n=Yr.get(e);let i=t;const a=kC.has(t.type);if(a)switch(t.type){case"user_message":case"permission_response":case"interrupt":case"set_model":case"set_permission_mode":case"mcp_get_status":case"mcp_toggle":case"mcp_reconnect":case"mcp_set_servers":case"set_ai_validation":t.client_msg_id||(i={...t,client_msg_id:E5()});break}if((n==null?void 0:n.readyState)===WebSocket.OPEN){n.send(JSON.stringify(i));return}a&&_C(e,i)}function qb(e){Fn(e,{type:"mcp_get_status"})}function RC(e,t,n){Fn(e,{type:"mcp_toggle",serverName:t,enabled:n})}function LC(e,t){Fn(e,{type:"mcp_reconnect",serverName:t})}function DC(e,t){Fn(e,{type:"mcp_set_servers",servers:t})}function zC(e,t){Fn(e,{type:"set_ai_validation",...t})}var ie=typeof window<"u"?window:void 0,Rn=typeof globalThis<"u"?globalThis:ie,In=Rn==null?void 0:Rn.navigator,ke=Rn==null?void 0:Rn.document,Vt=Rn==null?void 0:Rn.location,Gg=Rn==null?void 0:Rn.fetch,Hm=Rn!=null&&Rn.XMLHttpRequest&&"withCredentials"in new Rn.XMLHttpRequest?Rn.XMLHttpRequest:void 0,Vb=Rn==null?void 0:Rn.AbortController,OC=Rn==null?void 0:Rn.CompressionStream,er=In==null?void 0:In.userAgent;function M5(){return!(!ie||ie.navigator.onLine===!1)}var Bo=typeof globalThis<"u"?globalThis:ie;Bo&&typeof self>"u"&&(Bo.self=Bo),Bo&&typeof File>"u"&&(Bo.File=function(){});var Oe=ie??{},jt={DEBUG:!1,LIB_VERSION:"0.4.0",LIB_NAME:"browser-common"};function Gb(e,t,n,i,a,o,u){try{var f=e[o](u),h=f.value}catch(p){return void n(p)}f.done?t(h):Promise.resolve(h).then(i,a)}function Ut(e){return function(){var t=this,n=arguments;return new Promise((function(i,a){var o=e.apply(t,n);function u(h){Gb(o,i,a,u,f,"next",h)}function f(h){Gb(o,i,a,u,f,"throw",h)}u(void 0)}))}}function he(){return he=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},he.apply(null,arguments)}function R5(e,t){if(e==null)return{};var n={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(t.indexOf(i)!==-1)continue;n[i]=e[i]}return n}var Yb=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}};function Wb(e){return typeof e=="string"||e}function Qb(e){return typeof e=="string"?e:void 0}var Po,BC=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],Bi=(function(e){return e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.EnablePersonProcessing="enable_person_processing",e.PersonMode="person_mode",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.AiQueue="ai_queue",e.LogsQueue="logs_queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.PushRegistered="push_registered",e.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e.DeviceId="device_id",e})({}),Xb=(function(e){return e.GZipJS="gzip-js",e.Base64="base64",e})({}),PC=["$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"],$C=["token"],L5="NativeGzipValidationError",qm=e=>e.length>=2&&e[0]===31&&e[1]===139,Kb=(e,t)=>e===Xb.GZipJS||t===Xb.GZipJS||t==="gzip",Zb=e=>!(!e||typeof e!="object")&&("name"in e?String(e.name):"")==="NotReadableError",id=e=>{var t=new Error("Native gzip produced invalid output: "+e);throw t.name=L5,t},FC=(function(){var e=Ut((function*(t,n){18>t.size&&id("too-short");var i=new Uint8Array(yield t.slice(0,10).arrayBuffer());qm(i)&&i[2]===8||id("invalid-header");var a=new DataView(yield t.slice(t.size-8).arrayBuffer());a.getUint32(0,!0)!==(u=>{for(var f=(()=>{if(Po)return Po;Po=[];for(var g=0;256>g;g++){for(var x=g,b=0;8>b;b++)x=1&x?3988292384^x>>>1:x>>>1;Po[g]=x>>>0}return Po})(),h=4294967295,p=0;u.length>p;p++)h=f[255&(h^u[p])]^h>>>8;return(4294967295^h)>>>0})(n)&&id("invalid-crc");var o=n.length>>>0;a.getUint32(4,!0)!==o&&id("invalid-size")}));return function(t,n){return e.apply(this,arguments)}})();function Vm(){return Vm=Ut((function*(e,t,n){t===void 0&&(t=!0);try{var i=new TextEncoder().encode(e),a=new globalThis.CompressionStream("gzip"),o=a.writable.getWriter(),u=o.write(i).then((()=>o.close())).catch((function(){var p=Ut((function*(g){try{yield o.abort(g)}catch{}throw g}));return function(g){return p.apply(this,arguments)}})()),f=new Response(a.readable).blob(),h=(yield Promise.all([f,u]))[0];return yield FC(h,i),h}catch(p){if(n!=null&&n.rethrow)throw p;return t&&console.error("Failed to gzip compress data",p),null}})),Vm.apply(this,arguments)}var UC=["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"],Jb=function(e,t){if(t===void 0&&(t=[]),!e)return!1;var n=e.toLowerCase();return UC.concat(t).some((i=>{var a=i.toLowerCase();return n.indexOf(a)!==-1}))};function qe(e,t){return e.indexOf(t)!==-1}var gf=function(e){return e.trim()},Gm=function(e){return e.replace(/^\$/,"")};function D5(e){var t,n=[];return(t=JSON.stringify(e,(function(i,a){if(typeof a=="bigint")return a.toString();if(typeof a!="function"&&typeof a!="symbol"){if(a instanceof Error)return{name:a.name,message:a.message,stack:a.stack};if(a&&typeof a=="object"){for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(n.includes(a))return"[Circular]";n.push(a)}return a}})))!==null&&t!==void 0?t:"null"}var z5=Object.prototype,O5=z5.hasOwnProperty,xf=z5.toString,Ve=Array.isArray||function(e){return xf.call(e)==="[object Array]"},pr=e=>typeof e=="function",Bt=e=>e===Object(e)&&!Ve(e),Ii=e=>{if(Bt(e)){for(var t in e)if(O5.call(e,t))return!1;return!0}return!1},ye=e=>e===void 0,vt=e=>xf.call(e)=="[object String]",Ym=e=>vt(e)&&e.trim().length===0,Hn=e=>e===null,Ye=e=>ye(e)||Hn(e),sn=e=>xf.call(e)=="[object Number]"&&e==e,zi=e=>sn(e)&&e>0,Wr=e=>xf.call(e)==="[object Boolean]",IC=e=>e instanceof FormData,HC=e=>qe(PC,e),qC=e=>qe($C,e);function B5(e){return e===null||typeof e!="object"}function Pd(e,t){return{}.toString.call(e)==="[object "+t+"]"}function Yg(e){return typeof Event<"u"&&P5(e,Event)}function P5(e,t){try{return e instanceof t}catch{return!1}}var VC=[!0,"true",1,"1","yes"],Bp=e=>qe(VC,e),GC=[!1,"false",0,"0","no"];function ui(e,t,n,i,a){return t>n&&(i.warn("min cannot be greater than max."),t=n),sn(e)?e>n?(i.warn(" cannot be greater than max: "+n+". Using max value instead."),n):t>e?(i.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(i.warn(" must be a number. using max or fallback. max: "+n+", fallback: "+a),ui(a||n,t,n,i))}class YC{constructor(t){this.tt={},this.et=t.et,this.it=ui(t.bucketSize,0,100,t.rt),this.nt=ui(t.refillRate,0,this.it,t.rt),this.st=ui(t.refillInterval,0,864e5,t.rt)}ot(t,n){var i=Math.floor((n-t.lastAccess)/this.st);i>0&&(t.tokens=Math.min(t.tokens+i*this.nt,this.it),t.lastAccess=t.lastAccess+i*this.st)}consumeRateLimit(t){var n,i=Date.now(),a=String(t),o=this.tt[a];return o?this.ot(o,i):this.tt[a]=o={tokens:this.it,lastAccess:i},o.tokens===0||(o.tokens--,o.tokens===0&&((n=this.et)==null||n.call(this,t)),o.tokens===0)}stop(){this.tt={}}}var gr="Mobile",$d="iOS",Hi="Android",Cl="Tablet",$5=Hi+" "+Cl,F5="iPad",U5="Apple",I5=U5+" Watch",lc="Safari",El="BlackBerry",H5="Samsung",q5=H5+"Browser",V5=H5+" Internet",va="Chrome",WC=va+" OS",G5=va+" "+$d,Wg="Internet Explorer",Y5=Wg+" "+gr,Qg="Opera",QC=Qg+" Mini",Xg="Edge",W5="Microsoft "+Xg,kl="Firefox",Q5=kl+" "+$d,yc="Nintendo",_c="PlayStation",jl="Xbox",X5=Hi+" "+gr,K5=gr+" "+lc,Jo="Windows",Wm=Jo+" Phone",ey="Nokia",Qm="Ouya",Z5="Generic",XC=Z5+" "+gr.toLowerCase(),J5=Z5+" "+Cl.toLowerCase(),Xm="Konqueror",ew="Oculus Browser",Fd="Vivaldi",tw="Yandex",Ud="Whale",Km="DuckDuckGo",nw="Pale Moon",Id="Waterfox",oc="Brave",rw="Google Search App",Kt="(\\d+(\\.\\d+)?)",Pp=new RegExp("Version/"+Kt),KC=new RegExp(jl,"i"),ZC=new RegExp(_c+" \\w+","i"),JC=new RegExp(yc+" \\w+","i"),Kg=new RegExp(El+"|PlayBook|BB10","i"),e3={"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"},iw=function(e,t,n,i){t=t||"";var a=(function(o){return o!=null&&o.brave?oc:null})(n);return a||(i!=null&&i.detectGoogleSearchApp&&qe(e,"GSA/")?rw:qe(e," OPR/")&&qe(e,"Mini")?QC:qe(e," OPR/")?Qg:Kg.test(e)?El:qe(e,"IE"+gr)||qe(e,"WPDesktop")?Y5:qe(e,"OculusBrowser")?ew:qe(e,q5)?V5:qe(e,Xg)||qe(e,"Edg/")?W5:qe(e,Fd+"/")?Fd:qe(e,"YaBrowser/")?tw:qe(e,Ud+"/")?Ud:qe(e,Km+"/")||qe(e,"Ddg/")?Km:qe(e,"FBIOS")?"Facebook "+gr:qe(e,"UCWEB")||qe(e,"UCBrowser")?"UC Browser":qe(e,"CriOS")?G5:qe(e,"CrMo")||qe(e,va)?va:qe(e,Hi)&&qe(e,lc)?X5:qe(e,"FxiOS")?Q5:qe(e.toLowerCase(),Xm.toLowerCase())?Xm:qe(e,oc+"/")?oc:((o,u)=>u&&qe(u,U5)||(function(f){return qe(f,lc)&&!qe(f,va)&&!qe(f,Hi)})(o))(e,t)?qe(e,gr)?K5:lc:qe(e,"PaleMoon/")?nw:qe(e,Id+"/")?Id:qe(e,kl)?kl:qe(e,"MSIE")||qe(e,"Trident/")?Wg:qe(e,"Gecko")?kl:"")},t3={[Y5]:[new RegExp("rv:"+Kt)],[W5]:[new RegExp(Xg+"?\\/"+Kt)],[va]:[new RegExp("("+va+"|CrMo)\\/"+Kt)],[G5]:[new RegExp("CriOS\\/"+Kt)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Kt)],[lc]:[Pp],[K5]:[Pp],[Qg]:[new RegExp("(Opera|OPR)\\/"+Kt)],[kl]:[new RegExp(kl+"\\/"+Kt)],[Q5]:[new RegExp("FxiOS\\/"+Kt)],[Xm]:[new RegExp("Konqueror[:/]?"+Kt,"i")],[El]:[new RegExp(El+" "+Kt),Pp],[X5]:[new RegExp("android\\s"+Kt,"i")],[V5]:[new RegExp(q5+"\\/"+Kt)],[ew]:[new RegExp("OculusBrowser\\/"+Kt)],[Fd]:[new RegExp(Fd+"\\/"+Kt)],[tw]:[new RegExp("YaBrowser\\/"+Kt)],[Ud]:[new RegExp(Ud+"\\/"+Kt)],[oc]:[new RegExp(oc+"\\/"+Kt)],[Km]:[new RegExp("(DuckDuckGo|Ddg)\\/"+Kt)],[nw]:[new RegExp("PaleMoon\\/"+Kt)],[Id]:[new RegExp(Id+"\\/"+Kt)],[rw]:[new RegExp("GSA\\/"+Kt)],[Wg]:[new RegExp("(rv:|MSIE )"+Kt)],Mozilla:[new RegExp("rv:"+Kt)]},n3=function(e,t,n,i){var a=iw(e,t,n,i),o=t3[a];if(ye(o))return null;for(var u=0;o.length>u;u++){var f=e.match(o[u]);if(f)return parseFloat(f[f.length-2])}return null},ty=[[new RegExp(jl+"; "+jl+" (.*?)[);]","i"),e=>[jl,e&&e[1]||""]],[new RegExp(yc,"i"),[yc,""]],[new RegExp(_c,"i"),[_c,""]],[Kg,[El,""]],[new RegExp(Jo,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Wm,""];if(new RegExp(gr).test(t)&&!/IEMobile\b/.test(t))return[Jo+" "+gr,""];var n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){var i=e3[n[1]]||"";return/arm/i.test(t)&&(i="RT"),[Jo,i]}return[Jo,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[$d,[e[3],e[4],e[5]||"0"].join(".")]:[$d,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=ye(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+Hi+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Hi+")","i"),e=>e&&e[2]?[Hi,[e[2],e[3],e[4]||"0"].join(".")]:[Hi,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||"0"].join(".")),t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[WC,""]],[/Linux|debian/i,["Linux",""]]],ny=function(e){return JC.test(e)?yc:ZC.test(e)?_c:KC.test(e)?jl:new RegExp(Qm,"i").test(e)?Qm:new RegExp("("+Wm+"|WPDesktop)","i").test(e)?Wm:/iPad/.test(e)?F5:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?I5:Kg.test(e)?El:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(ey,"i").test(e)?ey:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(gr).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?Hi:$5:new RegExp("(pda|"+gr+")","i").test(e)?XC:new RegExp(Cl,"i").test(e)&&!new RegExp(Cl+" pc","i").test(e)?J5:""},r3=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function ry(e,t){return typeof(n=e)=="string"&&r3.test(n)?e:t();var n}function Ts(e){return e&&e.split("#")[0]}function Zg(e,t){var n=setTimeout(e,t);return n!=null&&n.unref&&(n==null||n.unref()),n}function iy(e,t,n){return sw.apply(this,arguments)}function sw(){return(sw=Ut((function*(e,t,n){var i;try{return yield Promise.race([e,new Promise(((a,o)=>{i=Zg((()=>{try{n==null||n(),a()}catch(u){o(u)}}),t)}))])}finally{clearTimeout(i)}}))).apply(this,arguments)}var i3=e=>e instanceof Error,aw={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},s3=aw.info;function lw(e){if(Wr(e))return{boolValue:e};if(typeof e=="number")return Number.isFinite(e)?Number.isInteger(e)?{intValue:e}:{doubleValue:e}:{stringValue:String(e)};if(typeof e=="string")return{stringValue:e};if(Ve(e))return{arrayValue:{values:e.map((t=>lw(t)))}};try{return{stringValue:JSON.stringify(e)}}catch{return{stringValue:String(e)}}}function Hd(e){var t=[];for(var n in e){var i=e[n];Hn(i)||ye(i)||t.push({key:n,value:lw(i)})}return t}function a3(e,t){var n=aw[e.level||"info"]||s3,i=n.text,a=n.number,o=String(Date.now())+"000000",u={};t.distinctId&&(u.posthogDistinctId=t.distinctId),t.sessionId&&(u.sessionId=t.sessionId),t.windowId&&(u["window.id"]=t.windowId),Ye(t.sessionStartTimestamp)||(u.sessionStartTimestamp=String(t.sessionStartTimestamp)),Ye(t.lastActivityTimestamp)||(u.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(u["url.full"]=t.currentUrl),t.screenName&&(u["screen.name"]=t.screenName),t.appState&&(u["app.state"]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(u.feature_flags=t.activeFeatureFlags);var f=he({},u,e.attributes||{}),h={timeUnixNano:o,observedTimeUnixNano:o,severityNumber:a,severityText:i,body:{stringValue:e.body},attributes:Hd(f)};return e.trace_id&&(h.traceId=e.trace_id),e.span_id&&(h.spanId=e.span_id),ye(e.trace_flags)||(h.flags=e.trace_flags),h}function ow(e,t,n){return he({},e.resourceAttributes,{"service.name":e.serviceName||"unknown_service"},e.environment&&{"deployment.environment":e.environment},e.serviceVersion&&{"service.version":e.serviceVersion},{"telemetry.sdk.name":t,"telemetry.sdk.version":n})}function cw(e,t,n,i){return{resourceLogs:[{resource:{attributes:Hd(t)},scopeLogs:[{scope:{name:n,version:i},logRecords:e}]}]}}let l3=class{constructor(e,t,n,i,a,o,u){var f;o===void 0&&(o=()=>Promise.resolve()),this._instance=e,this.Ne=t,this.rt=n,this.ut=i,this.ht=a,this.dt=o,this.vt=u,this.ct=null,this.ft=0,this.yt=0,this.bt=0,this._t=0,this.wt=!1,this.kt=t.maxBufferSize,this.xt=Math.max((f=t.maxQueueSize)!==null&&f!==void 0?f:t.maxBufferSize,t.maxBufferSize),this.St=t.flushIntervalMs,this.Ct=t.maxBatchRecordsPerPost,this.Mt=t.rateCapWindowMs,this.Tt=t.maxLogsPerInterval}reset(){this.Et(),this.ct=null,this.bt=0,this._t=0,this.wt=!1,this.ft=0,this.yt=0,this.Ct=this.Ne.maxBatchRecordsPerPost}onReconnect(){this.yt=0,this.It()}captureLog(e){if(!this._instance.isDisabled&&!this._instance.optedOut&&e!=null&&e.body){var t=this.Pt(e);if(t!==null)if(t.body){if(this.Rt()){var n={record:a3(t,this.ut())};this.ht((()=>this.At(n)))}}else this.rt.info("Log was rejected in beforeSend function")}}Pt(e){var t=this.Ne.beforeSend;if(!t)return e;var n=Ve(t)?t:[t],i=e;for(var a of n)try{var o=a(i);if(!o)return this.rt.info("Log was rejected in beforeSend function"),null;i=o}catch(u){return this.rt.error("Error in beforeSend function for log:",u),null}return i}Rt(){if(this.Tt===void 0)return!0;var e=Date.now(),t=e-this.bt;return this.Mt>t&&t>=0||(this.bt=e,this._t=0,this.wt=!1),this.Tt>this._t?(this._t++,!0):(this.wt||(this.rt.warn("captureLog dropping logs: exceeded "+this.Tt+" logs per "+this.Mt+"ms"),this.wt=!0),!1)}flush(){var e=this;return Ut((function*(){if(!e._instance.isDisabled)return e.ct||(e.ct=e.Ft().finally((()=>{e.ct=null}))),e.ct}))()}Ft(){var e=this;return Ut((function*(){var t;e.Et();var n=(t=e._instance.getPersistedProperty(Bi.LogsQueue))!==null&&t!==void 0?t:[];if(n.length!==0)for(var i=n.length,a=0;n.length>0&&i>a;){var o,u;e.ft=0;var f=Math.min(n.length,e.Ct),h=n.slice(0,f),p=cw(h.map((x=>x.record)),e.Lt(),(o=e.vt)!==null&&o!==void 0?o:e._instance.getLibraryId(),e._instance.getLibraryVersion()),g=yield e._instance.Ot(p);if(g.kind==="too-large"&&h.length>1)e.Ct=Math.max(1,Math.floor(h.length/2)),e.rt.warn("Received 413 when sending logs batch of size "+h.length+", reducing batch size to "+e.Ct);else if(g.kind==="retry-later"||(g.kind==="too-large"?e.rt.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):g.kind==="ok"&&e.Ne.maxBatchRecordsPerPost>e.Ct&&(e.Ct=Math.min(e.Ne.maxBatchRecordsPerPost,e.Ct+1)),yield e.Dt(h.length),n=(u=e._instance.getPersistedProperty(Bi.LogsQueue))!==null&&u!==void 0?u:[],a+=h.length,g.kind==="fatal"))throw g.error}}))()}Dt(e){var t=this;return Ut((function*(){var n,i=Math.max(0,e-t.ft),a=(n=t._instance.getPersistedProperty(Bi.LogsQueue))!==null&&n!==void 0?n:[];t._instance.setPersistedProperty(Bi.LogsQueue,a.slice(i)),yield t.dt()}))()}Lt(){return ow(this.Ne,this._instance.getLibraryId(),this._instance.getLibraryVersion())}At(e){var t;if(!this._instance.optedOut){var n=(t=this._instance.getPersistedProperty(Bi.LogsQueue))!==null&&t!==void 0?t:[];this.xt>n.length||(n.shift(),this.ft++,this.rt.info("Logs queue is full, dropping oldest record.")),n.push(e),this._instance.setPersistedProperty(Bi.LogsQueue,n),this.kt>n.length?this.$t():this.It()}}$t(e){e===void 0&&(e=this.St),this.Nt||(this.Nt=Zg((()=>{this.Nt=void 0,this.It()}),e))}qt(){var e=Math.min(Math.max(0,this.yt-1),6);return this.St*Math.pow(2,e)}jt(){var e=this._instance.getPersistedProperty(Bi.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return Ut((function*(){t.Et();var n=t.flush().catch((()=>{}));e!==void 0?yield iy(n,e):yield n}))()}flushWithTimeout(e){var t=this;return Ut((function*(){var n=t.flush();yield iy(n,e,(()=>{n.catch((()=>{}))}))}))()}It(){this.flush().then((()=>{this.yt=0}),(e=>{this.yt++,this.rt.error("PostHog logs flush failed:",e)})).finally((()=>{!this._instance.isDisabled&&this.jt()&&this.$t(this.qt())}))}Et(){this.Nt&&(clearTimeout(this.Nt),this.Nt=void 0)}};var $p=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function sy(e){return String(e)+"000000"}function ay(e,t,n,i){var a="";return i&&(a=Object.keys(i).sort().map((o=>JSON.stringify(o)+":"+JSON.stringify(i[o]))).join(",")),e+"\0"+t+"\0"+(n??"")+"\0"+a}let o3=class{constructor(e,t,n){this._instance=e,this.Ne=t,this.rt=n,this.Bt=new Map,this.ct=null,this.Ht=!1,this.Ut=new Map,this.zt=new Set,this.Wt=0}count(e,t,n){t===void 0&&(t=1),this.Vt({name:e,type:"count",value:t,unit:n==null?void 0:n.unit,attributes:n==null?void 0:n.attributes})}gauge(e,t,n){this.Vt({name:e,type:"gauge",value:t,unit:n==null?void 0:n.unit,attributes:n==null?void 0:n.attributes})}histogram(e,t,n){this.Vt({name:e,type:"histogram",value:t,unit:n==null?void 0:n.unit,attributes:n==null?void 0:n.attributes})}flush(){var e=this,t=this.ct,n=(function(){var a=Ut((function*(){t&&(yield t.catch((()=>{}))),yield e.Zt()}));return function(){return a.apply(this,arguments)}})(),i=n().finally((()=>{this.ct===i&&(this.ct=null)}));return this.ct=i,i}drainWindow(){if(this.Bt.size===0)return null;var e=this.Bt;return this.Bt=new Map,this.Ht=!1,this.Ut=new Map,this.zt=new Set,this.Gt(e)}reset(){this.Wt++,this.Et(),this.Bt=new Map,this.ct=null,this.Ht=!1,this.Ut=new Map,this.zt=new Set}Vt(e){if(!this._instance.isDisabled&&!this._instance.optedOut){var t=this.Pt(e);if(t!==null)if(t.name&&typeof t.name=="string")if(typeof t.value=="number"&&Number.isFinite(t.value))if(t.type==="count"&&0>t.value)this.rt.warn("Dropping count '"+t.name+"': counters are monotonic, value must be >= 0");else{var n,i;try{n=t.attributes?he({},t.attributes):void 0,i=ay(t.type,t.name,t.unit,n)}catch(u){return void this.rt.warn("Dropping metric '"+t.name+"': attributes could not be serialized",u)}var a=this.Bt.get(i);if(!a){if(!this.Qt())return;a={name:t.name,type:t.type,unit:t.unit,attributes:n,windowStartMs:Date.now()},this.Bt.set(i,a)}var o=this.Ut.get(t.name);o===void 0?this.Ut.set(t.name,t.type):o===t.type||this.zt.has(t.name)||(this.zt.add(t.name),this.rt.warn("Metric name '"+t.name+"' is already used as a "+o+"; recording it as a "+t.type+" too will blend both series in charts. Use a distinct name.")),this.Kt(a,t.value),this.$t()}else this.rt.warn("Dropping metric '"+t.name+"': value must be a finite number");else this.rt.warn("Dropping metric with empty name")}}Qt(){return this.Ne.maxSeriesPerFlush>this.Bt.size||(this.Ht||(this.Ht=!0,this.rt.warn("Metric series cap reached ("+this.Ne.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Kt(e,t){var n;switch(e.type){case"count":e.total=((n=e.total)!==null&&n!==void 0?n:0)+t;break;case"gauge":e.last=t;break;case"histogram":e.hist||(e.hist={count:0,sum:0,min:t,max:t,bucketCounts:new Array($p.length+1).fill(0)});var i=e.hist;i.count+=1,i.sum+=t,i.min=Math.min(i.min,t),i.max=Math.max(i.max,t),i.bucketCounts[(function(a,o){for(var u=0;o.length>u;u++)if(o[u]>=a)return u;return o.length})(t,$p)]+=1}}Pt(e){var t=this.Ne.beforeSend;if(!t)return e;var n=Ve(t)?t:[t],i=e;for(var a of n)try{var o=a(i);if(!o)return this.rt.info("Metric was rejected in beforeSend function"),null;i=o}catch(u){return this.rt.error("Error in beforeSend function for metric:",u),null}return i}$t(){this.Nt||(this.Nt=Zg((()=>{this.Nt=void 0,this.flush().catch((e=>{this.rt.error("Metrics flush failed:",e)}))}),this.Ne.flushIntervalMs))}Et(){this.Nt&&(clearTimeout(this.Nt),this.Nt=void 0)}Zt(){var e=this;return Ut((function*(){if(e.Bt.size!==0){var t=e.Bt;e.Bt=new Map,e.Ht=!1,e.Ut=new Map,e.zt=new Set;var n=e.Wt,i=yield e._instance.Jt(e.Gt(t));if(n===e.Wt)switch(i.kind){case"ok":return;case"retry-later":return e.Yt(t),void e.$t();case"too-large":return void e.rt.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e.rt.error("Failed to send metrics batch:",i.error)}}}))()}Gt(e){return t=this.Xt(e),n=(function(o,u,f){return he({},o.resourceAttributes,{"service.name":o.serviceName||"unknown_service"},o.environment&&{"deployment.environment":o.environment},o.serviceVersion&&{"service.version":o.serviceVersion},{"telemetry.sdk.name":u,"telemetry.sdk.version":f})})(this.Ne,this._instance.getLibraryId(),this._instance.getLibraryVersion()),i=this._instance.getLibraryId(),a=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Hd(n)},scopeMetrics:[{scope:{name:i,version:a},metrics:t}]}]};var t,n,i,a}Xt(e){var t=sy(Date.now()),n=new Map;for(var i of e.values()){var a,o=ay(i.type,i.name,i.unit,void 0),u=n.get(o);u||(u=he({name:i.name},i.unit&&{unit:i.unit}),i.type==="count"?u.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:i.type==="gauge"?u.gauge={dataPoints:[]}:u.histogram={aggregationTemporality:1,dataPoints:[]},n.set(o,u));var f=Hd((a=i.attributes)!==null&&a!==void 0?a:{}),h=sy(i.windowStartMs);if(i.type==="count"){var p,g={attributes:f,startTimeUnixNano:h,timeUnixNano:t,asDouble:(p=i.total)!==null&&p!==void 0?p:0};u.sum.dataPoints.push(g)}else if(i.type==="gauge"){var x,b={attributes:f,timeUnixNano:t,asDouble:(x=i.last)!==null&&x!==void 0?x:0};u.gauge.dataPoints.push(b)}else i.hist&&u.histogram.dataPoints.push({attributes:f,startTimeUnixNano:h,timeUnixNano:t,count:i.hist.count,sum:i.hist.sum,min:i.hist.min,max:i.hist.max,bucketCounts:i.hist.bucketCounts,explicitBounds:$p})}return Array.from(n.values())}Yt(e){var t,n;for(var i of e){var a=i[0],o=i[1],u=this.Bt.get(a);if(u)switch(u.windowStartMs=Math.min(u.windowStartMs,o.windowStartMs),u.type){case"count":u.total=((t=u.total)!==null&&t!==void 0?t:0)+((n=o.total)!==null&&n!==void 0?n:0);break;case"gauge":break;case"histogram":if(o.hist)if(u.hist){u.hist.count+=o.hist.count,u.hist.sum+=o.hist.sum,u.hist.min=Math.min(u.hist.min,o.hist.min),u.hist.max=Math.max(u.hist.max,o.hist.max);for(var f=0;u.hist.bucketCounts.length>f;f++)u.hist.bucketCounts[f]+=o.hist.bucketCounts[f]}else u.hist=o.hist}else this.Qt()&&this.Bt.set(a,o)}}};var sd,ly,Fp;function c3(e){var t=globalThis._posthogChunkIds;if(t){var n=Object.keys(t);return Fp&&n.length===ly||(ly=n.length,Fp=n.reduce(((i,a)=>{sd||(sd={});var o=sd[a];if(o)i[o[0]]=o[1];else for(var u=e(a),f=u.length-1;f>=0;f--){var h=u[f],p=h==null?void 0:h.filename,g=t[a];if(p&&g){i[p]=g,sd[a]=[p,g];break}}return i}),{})),Fp}}class u3{constructor(t,n,i){i===void 0&&(i=[]),this.coercers=t,this.stackParser=n,this.modifiers=i}buildFromUnknown(t,n){n===void 0&&(n={});var i=n&&n.mechanism||{handled:!0,type:"generic"},a=this.buildCoercingContext(i,n,0).apply(t),o=this.buildParsingContext(n),u=this.parseStacktrace(a,o);return{$exception_list:this.convertToExceptionList(u,i),$exception_level:"error"}}modifyFrames(t){var n=this;return Ut((function*(){for(var i of t)i.stacktrace&&i.stacktrace.frames&&Ve(i.stacktrace.frames)&&(i.stacktrace.frames=yield n.applyModifiers(i.stacktrace.frames));return t}))()}coerceFallback(t){var n;return{type:"Error",value:"Unknown error",stack:(n=t.syntheticException)==null?void 0:n.stack,synthetic:!0}}parseStacktrace(t,n){var i,a;return t.cause!=null&&(i=this.parseStacktrace(t.cause,n)),t.stack!=""&&t.stack!=null&&(a=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?n.skipFirstLines:0),n.chunkIdMap)),he({},t,{cause:i,stack:a})}applyChunkIds(t,n){return t.map((i=>(i.filename&&n&&(i.chunk_id=n[i.filename]),i)))}applyCoercers(t,n){for(var i of this.coercers)if(i.match(t))return i.coerce(t,n);return this.coerceFallback(n)}applyModifiers(t){var n=this;return Ut((function*(){var i=t;for(var a of n.modifiers)i=yield a(i);return i}))()}convertToExceptionList(t,n){var i,a,o,u={type:t.type,value:t.value,mechanism:{type:(i=n.type)!==null&&i!==void 0?i:"generic",handled:(a=n.handled)===null||a===void 0||a,synthetic:(o=t.synthetic)!==null&&o!==void 0&&o}};t.stack&&(u.stacktrace={type:"raw",frames:t.stack});var f=[u];return t.cause!=null&&f.push(...this.convertToExceptionList(t.cause,he({},n,{handled:!0}))),f}buildParsingContext(t){var n;return{chunkIdMap:c3(this.stackParser),skipFirstLines:(n=t.skipFirstLines)!==null&&n!==void 0?n:1}}buildCoercingContext(t,n,i){i===void 0&&(i=0);var a=(o,u)=>{if(4>=u){var f=this.buildCoercingContext(t,n,u);return this.applyCoercers(o,f)}};return he({},n,{syntheticException:i==0?n.syntheticException:void 0,mechanism:t,apply:o=>a(o,i),next:o=>a(o,i+1)})}}var Tl="?";function Zm(e,t,n,i,a){var o={platform:e,filename:t,function:n==="<anonymous>"?Tl:n,in_app:!0};return ye(i)||(o.lineno=i),ye(a)||(o.colno=a),o}var uw=(e,t)=>{var n=e.indexOf("safari-extension")!==-1,i=e.indexOf("safari-web-extension")!==-1;return n||i?[e.indexOf("@")!==-1?e.split("@")[0]:Tl,n?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},d3=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,f3=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,h3=/\((\S*)(?::(\d+))(?::(\d+))\)/,p3=(e,t)=>{var n=d3.exec(e);if(n)return Zm(t,n[1],Tl,+n[2],+n[3]);var i=f3.exec(e);if(i){if(i[2]&&i[2].indexOf("eval")===0){var a=h3.exec(i[2]);a&&(i[2]=a[1],i[3]=a[2],i[4]=a[3])}var o=uw(i[1]||Tl,i[2]);return Zm(t,o[1],o[0],i[3]?+i[3]:void 0,i[4]?+i[4]:void 0)}},m3=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,g3=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,x3=(e,t)=>{var n=m3.exec(e);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){var i=g3.exec(n[3]);i&&(n[1]=n[1]||"eval",n[3]=i[1],n[4]=i[2],n[5]="")}var a=n[3],o=n[1]||Tl,u=uw(o,a);return Zm(t,a=u[1],o=u[0],n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},oy=/\(error: (.*)\)/;class v3{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,n){var i=vt(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:i?t.stack:void 0,cause:t.cause?n.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var n=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?n+": "+t.message:n}isDOMException(t){return Pd(t,"DOMException")}isDOMError(t){return Pd(t,"DOMError")}}class b3{match(t){return(function(n){switch({}.toString.call(n)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return P5(n,Error)}})(t)}coerce(t,n){return{type:this.getType(t),value:this.getMessage(t,n),stack:this.getStack(t),cause:t.cause?n.next(t.cause):void 0,synthetic:!1}}getType(t){return t.name||t.constructor.name}getMessage(t,n){var i=t.message;return String(i.error&&typeof i.error.message=="string"?i.error.message:i)}getStack(t){return t.stacktrace||t.stack||void 0}}class y3{constructor(){}match(t){return!!Pd(t,"ErrorEvent")&&(t.error!=null||this.fe(t))}coerce(t,n){var i;if(t.error!=null)return n.apply(t.error);var a=n.apply(t.message);return he({},a,{stack:(i=this.pe(t))!==null&&i!==void 0?i:a.stack,synthetic:!0})}fe(t){return vt(t.message)&&t.message.length>0}pe(t){var n=t;if(vt(n.filename)&&n.filename.length>0){var i,a,o=(i=n.lineno)!==null&&i!==void 0?i:0,u=(a=n.colno)!==null&&a!==void 0?a:0;return`Error
|
|
66
|
-
at `+n.filename+":"+o+":"+u}}}var _3=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class w3{match(t){return typeof t=="string"}coerce(t,n){var i,a=this.getInfos(t),o=a[0],u=a[1];return{type:o??"Error",value:u??t,stack:(i=n.syntheticException)==null?void 0:i.stack,synthetic:!0}}getInfos(t){var n="Error",i=t,a=t.match(_3);return a&&(n=a[1],i=a[2]),[n,i]}}var S3=["fatal","error","warning","log","info","debug"];function dw(e,t){t===void 0&&(t=40);var n=Object.keys(e);if(n.sort(),!n.length)return"[object has no keys]";for(var i=n.length;i>0;i--){var a=n.slice(0,i).join(", ");if(t>=a.length)return i===n.length?a:a.length>t?a.slice(0,t)+"...":a}return""}class k3{match(t){return typeof t=="object"&&t!==null}coerce(t,n){var i,a,o=this.getErrorPropertyFromObject(t);return o?n.apply(o):{type:this.getType(t),value:this.getValue(t),stack:(i=this.getStack(t))!==null&&i!==void 0?i:(a=n.syntheticException)==null?void 0:a.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){return Yg(t)?t.constructor.name:"Error"}getValue(t){if("name"in t&&typeof t.name=="string"){var n="'"+t.name+"' captured as exception";return"message"in t&&typeof t.message=="string"&&(n+=" with message: '"+t.message+"'"),n}if("message"in t&&typeof t.message=="string")return t.message;var i=this.getObjectClassName(t);return(i&&i!=="Object"?"'"+i+"'":"Object")+" captured as exception with keys: "+dw(t)}isSeverityLevel(t){return vt(t)&&!Ym(t)&&S3.indexOf(t)>=0}getStack(t){try{return vt(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:vt(t.stack)&&t.stack.length>0?t.stack:void 0}catch{return}}getErrorPropertyFromObject(t){for(var n in t)if({}.hasOwnProperty.call(t,n)){var i=t[n];if(i3(i))return i}}getObjectClassName(t){try{var n=Object.getPrototypeOf(t);return n?n.constructor.name:void 0}catch{return}}}class j3{match(t){return Yg(t)}coerce(t,n){var i,a=t.constructor.name;return{type:a,value:a+" captured as exception with keys: "+dw(t),stack:(i=n.syntheticException)==null?void 0:i.stack,synthetic:!0}}}class N3{match(t){return B5(t)}coerce(t,n){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:(i=n.syntheticException)==null?void 0:i.stack,synthetic:!0}}}class C3{match(t){return Pd(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!Yg(t))return!1;try{var n=t.detail;return n!=null&&typeof n=="object"&&"reason"in n}catch{return!1}}coerce(t,n){var i,a=this.getUnhandledRejectionReason(t);return B5(a)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(a),stack:(i=n.syntheticException)==null?void 0:i.stack,synthetic:!0}:n.apply(a)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&t.detail!=null&&typeof t.detail=="object"&&"reason"in t.detail)return t.detail.reason}catch{}return t}}var qd="$message",Vd="$timestamp",E3=new Set([qd,Vd]),Up={enabled:!0,max_bytes:32768};function Gd(e){var t;return e?{enabled:(t=e.enabled)!==null&&t!==void 0?t:Up.enabled,max_bytes:A3(e.max_bytes,Up.max_bytes)}:he({},Up)}class T3{constructor(t){this.Ke=[],this.Je=0,this.Ne=Gd(t)}setConfig(t){this.Ne=Gd(t),this.Xe()}add(t){var n=(function(a){var o;try{o=D5(a)}catch{return}try{var u=JSON.parse(o);if(!Bt(u))return;var f=u,h=f[qd],p=f[Vd];return!vt(h)||h.trim().length===0||!vt(p)&&!sn(p)?void 0:{step:f,json:o}}catch{return}})(t);if(n){var i=(function(a){if(typeof TextEncoder<"u")return new TextEncoder().encode(a).length;for(var o=encodeURIComponent(a),u=0,f=0;o.length>f;f++)o[f]==="%"?(u+=1,f+=2):u+=1;return u})(n.json);i>this.Ne.max_bytes||(this.Ke.push({step:n.step,bytes:i}),this.Je+=i,this.Xe())}}getAttachable(){return this.Ke.map((t=>t.step))}clear(){this.Ke=[],this.Je=0}size(){return this.Ke.length}Xe(){for(;this.Je>this.Ne.max_bytes&&this.Ke.length>0;){var t=this.Ke.shift();t&&(this.Je-=t.bytes)}}}function A3(e,t){if(!sn(e)||e===1/0||e===-1/0)return t;var n=Math.floor(e);return 0>n?t:n}var fw=function(e,t){var n=(t===void 0?{}:t).debugEnabled,i={k(a){if(ie&&(jt.DEBUG||ie.POSTHOG_DEBUG||n)&&!ye(ie.console)&&ie.console){for(var o=("__rrweb_original__"in ie.console[a])?ie.console[a].__rrweb_original__:ie.console[a],u=arguments.length,f=new Array(u>1?u-1:0),h=1;u>h;h++)f[h-1]=arguments[h];o(e,...f)}},debug(){for(var a=arguments.length,o=new Array(a),u=0;a>u;u++)o[u]=arguments[u];i.k("debug",...o)},info(){for(var a=arguments.length,o=new Array(a),u=0;a>u;u++)o[u]=arguments[u];i.k("log",...o)},warn(){for(var a=arguments.length,o=new Array(a),u=0;a>u;u++)o[u]=arguments[u];i.k("warn",...o)},error(){for(var a=arguments.length,o=new Array(a),u=0;a>u;u++)o[u]=arguments[u];i.k("error",...o)},critical(){for(var a=arguments.length,o=new Array(a),u=0;a>u;u++)o[u]=arguments[u];console.error(e,...o)},uninitializedWarning(a){i.error("You must initialize PostHog before calling "+a)},createLogger:(a,o)=>fw(e+" "+a,o)};return i},we=fw("[PostHog.js]"),Wt=we.createLogger,M3=Wt("[ExternalScriptsLoader]"),Ip=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return M3.warn(t+" was requested but loading of external scripts is disabled."),n("Loading of external scripts is disabled");var i=ke==null?void 0:ke.querySelectorAll("script");if(i){for(var a,o=function(){if(i[u].src===t){var h=i[u];return h.__posthog_loading_callback_fired?{v:n()}:(h.addEventListener("load",(p=>{h.__posthog_loading_callback_fired=!0,n(void 0,p)})),h.onerror=p=>n(p),{v:void 0})}},u=0;i.length>u;u++)if(a=o())return a.v}var f=()=>{if(!ke)return n("document not found");var h=ke.createElement("script");if(h.type="text/javascript",h.crossOrigin="anonymous",h.src=t,h.onload=x=>{h.__posthog_loading_callback_fired=!0,n(void 0,x)},h.onerror=x=>n(x),e.config.prepare_external_dependency_script&&(h=e.config.prepare_external_dependency_script(h)),!h)return n("prepare_external_dependency_script returned null");if(e.config.external_scripts_inject_target==="head")ke.head.appendChild(h);else{var p,g=ke.querySelectorAll("body > script");g.length>0?(p=g[0].parentNode)==null||p.insertBefore(h,g[0]):ke.body.appendChild(h)}};ke!=null&&ke.body?f():ke==null||ke.addEventListener("DOMContentLoaded",f)};Oe.__PosthogExtensions__=Oe.__PosthogExtensions__||{},Oe.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{if(t!=="remote-config"){var i;if(e.config.strict_script_versioning)i=e.requestRouter.endpointFor("assets","/static/"+e.version+"/"+t+".js");else{var a="/static/"+t+".js?v="+e.version;if(t==="toolbar"){var o=3e5;a=a+"&t="+Math.floor(Date.now()/o)*o}i=e.requestRouter.endpointFor("assets",a)}Ip(e,i,n)}else{var u=e.requestRouter.endpointFor("assets","/array/"+e.config.token+"/config.js");Ip(e,u,n)}},Oe.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{var i=e.requestRouter.endpointFor("api",t);Ip(e,i,n)};jt.DEBUG=!1,jt.LIB_VERSION="1.414.0",jt.LIB_NAME="web";var hw="$people_distinct_id",wc="$device_id",Hp="$device_model",ec="__alias",tc="__timers",Jm="$autocapture_disabled_server_side",eg="$heatmaps_enabled_server_side",tg="$exception_capture_enabled_server_side",ng="$error_tracking_suppression_rules",rg="$error_tracking_capture_extension_exceptions",ig="$web_vitals_enabled_server_side",Jg="$dead_clicks_enabled_server_side",ex="$product_tours_enabled_server_side",sg="$web_vitals_allowed_metrics",xa="$session_recording_remote_config",pw="$replay_sample_rate",mw="$replay_override_sampling",gw="$replay_override_linked_flag",xw="$replay_override_url_trigger",vw="$replay_override_event_trigger",wl="$sesid",tx="$session_is_sampled",ga="$enabled_feature_flags",Nd="$active_feature_flags",nc="$early_access_features",ag="$feature_flag_details",Cd="$feature_flag_payloads",lg="$feature_flag_request_id",Yd="$minimal_flag_called_events",Oi="$override_feature_flags",vl="$override_feature_flag_payloads",fa="$stored_person_properties",ha="$stored_group_properties",og="$surveys",Wd="$surveys_loaded_at",cg="$surveys_activated",Ed="$surveys_activated_session",Td="$surveys_activated_timestamps",rc="ph_product_tours",cc="$flag_call_reported",ug="$flag_call_reported_session_id",dg="$feature_flag_errors",Sc="$feature_flag_evaluated_at",zr="$user_state",fg="$client_session_props",hg="$capture_rate_limit",pg="$initial_campaign_params",mg="$initial_referrer_info",Qd="$initial_person_info",Xd="$epp",ad="$posthog_cookieless",bw="$cookieless_mode",yw="$sdk_debug_extensions_init_method",_w="$sdk_debug_extensions_init_time_ms",ww="$sdk_debug_recording_script_not_loaded",nx="PostHog loadExternalDependency extension not found.",pa="on_reject",$i="always",fl="anonymous",ia="identified",gg="identified_only",Kd="visibilitychange",Zd="beforeunload",bl="$pageview",qp="$pageleave",Vp="$identify",cy="$groupidentify";function ld(e,t){Ve(e)&&e.forEach(t)}function Rt(e,t){if(!Ye(e))if(Ve(e))e.forEach(t);else if(IC(e))e.forEach(((i,a)=>t(i,a)));else for(var n in e)O5.call(e,n)&&t(e[n],n)}var Ot=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;t>i;i++)n[i-1]=arguments[i];for(var a of n)for(var o in a)a[o]!==void 0&&(e[o]=a[o]);return e};function Ad(e){for(var t=Object.keys(e),n=t.length,i=new Array(n);n--;)i[n]=[t[n],e[t[n]]];return i}var uy=function(e){try{return e()}catch{return}},R3=function(e){return function(){try{for(var t=arguments.length,n=new Array(t),i=0;t>i;i++)n[i]=arguments[i];return e.apply(this,n)}catch(a){we.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),we.critical(a)}}},rx=function(e){var t={};return Rt(e,(function(n,i){(vt(n)&&n.length>0||sn(n))&&(t[i]=n)})),t},L3=["herokuapp.com","vercel.app","netlify.app"];function D3(e){var t=e==null?void 0:e.hostname;if(!vt(t))return!1;var n=t.split(".").slice(-2).join(".");for(var i of L3)if(n===i)return!1;return!0}function Gt(e,t,n,i){var a=i??{},o=a.capture,u=a.passive;e==null||e.addEventListener(t,n,{capture:o!==void 0&&o,passive:u===void 0||u})}function xg(e){return e.name==="ph_toolbar_internal"}var Sw=e=>{if(ke){try{for(var t=e+"=",n=ke.cookie.split(";").filter((o=>o.length)),i=0;n.length>i;i++){for(var a=n[i];a.charAt(0)==" ";)a=a.substring(1,a.length);if(a.indexOf(t)===0)return decodeURIComponent(a.substring(t.length,a.length))}}catch{}return null}};Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return sn(e)&&isFinite(e)&&Math.floor(e)===e});class Jd{constructor(t){if(this.bytes=t,t.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,n,i,a){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(i)||!Number.isInteger(a)||0>t||0>n||0>i||0>a||t>0xffffffffffff||n>4095||i>1073741823||a>4294967295)throw new RangeError("invalid field value");var o=new Uint8Array(16);return o[0]=t/Math.pow(2,40),o[1]=t/Math.pow(2,32),o[2]=t/Math.pow(2,24),o[3]=t/Math.pow(2,16),o[4]=t/256,o[5]=t,o[6]=112|n>>>8,o[7]=n,o[8]=128|i>>>24,o[9]=i>>>16,o[10]=i>>>8,o[11]=i,o[12]=a>>>24,o[13]=a>>>16,o[14]=a>>>8,o[15]=a,new Jd(o)}toString(){for(var t="",n=0;this.bytes.length>n;n++)t=t+(this.bytes[n]>>>4).toString(16)+(15&this.bytes[n]).toString(16),n!==3&&n!==5&&n!==7&&n!==9||(t+="-");if(t.length!==36)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new Jd(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(var n=0;16>n;n++){var i=this.bytes[n]-t.bytes[n];if(i!==0)return Math.sign(i)}return 0}}class z3{generate(){var t=this.generateOrAbort();if(!ye(t))return t;this.S=0;var n=this.generateOrAbort();if(ye(n))throw new Error("Could not generate UUID after timestamp reset");return n}generateOrAbort(){var t=Date.now();if(t>this.S)this.S=t,this.C();else{if(this.S>=t+1e4)return;this.I++,this.I>4398046511103&&(this.S++,this.C())}return Jd.fromFieldsV7(this.S,Math.trunc(this.I/Math.pow(2,30)),this.I&Math.pow(2,30)-1,this.A.nextUint32())}C(){this.I=1024*this.A.nextUint32()+(1023&this.A.nextUint32())}constructor(){this.S=0,this.I=0,this.A=new O3}}var dy,kw=e=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};ie&&!ye(ie.crypto)&&crypto.getRandomValues&&(kw=e=>crypto.getRandomValues(e));class O3{nextUint32(){return this.R.length>this.O||(kw(this.R),this.O=0),this.R[this.O++]}constructor(){this.R=new Uint32Array(8),this.O=1/0}}var Pi=()=>B3().toString(),B3=()=>(dy||(dy=new z3)).generate(),$o="",P3=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,Fi={N:()=>!!ke,j(e){we.error("cookieStore error: "+e)},P:Sw,H(e){var t;try{t=JSON.parse(Fi.P(e))||{}}catch{}return t},F(e,t,n,i,a){if(!ke)return!1;try{var o="",u="",f=(function(g,x){if(x){var b=(function(_,j){if(j===void 0&&(j=ke),$o)return $o;if(!j||["localhost","127.0.0.1"].includes(_))return"";for(var C=_.split("."),k=Math.min(C.length,8),E="dmn_chk_"+Pi();!$o&&k--;){var N=C.slice(k).join("."),D=E+"=1;domain=."+N+";path=/";j.cookie=D+";max-age=3",j.cookie.includes(E)&&(j.cookie=D+";max-age=0",$o=N)}return $o})(g);if(!b){var y=(_=>{var j=_.match(P3);return j?j[0]:""})(g);y!==b&&we.info("Warning: cookie subdomain discovery mismatch",y,b),b=y}return b?"; domain=."+b:""}return""})(ke.location.hostname,i);if(n){var h=new Date;h.setTime(h.getTime()+864e5*n),o="; expires="+h.toUTCString()}a&&(u="; secure");var p=e+"="+encodeURIComponent(JSON.stringify(t))+o+"; SameSite=Lax; path=/"+f+u;return p.length>3686.4&&we.warn("cookieStore warning: large cookie, len="+p.length),ke.cookie=p,!0}catch{return!1}},q(e,t){if(ke!=null&&ke.cookie)try{Fi.F(e,"",-1,t)}catch{return}}},Gp=null,zt={N(){if(!Hn(Gp))return Gp;var e=!0;if(ye(ie))e=!1;else try{var t="__mplssupport__";zt.F(t,"xyz"),zt.P(t)!=='"xyz"'&&(e=!1),zt.q(t)}catch{e=!1}return e||we.error("localStorage unsupported; falling back to cookie store"),Gp=e,e},j(e){we.error("localStorage error: "+e)},P(e){try{return ie==null?void 0:ie.localStorage.getItem(e)}catch(t){zt.j(t)}return null},H(e){try{return JSON.parse(zt.P(e))||{}}catch{}return null},F(e,t){try{return ie==null||ie.localStorage.setItem(e,JSON.stringify(t)),!0}catch(n){zt.j(n)}return!1},q(e){try{ie==null||ie.localStorage.removeItem(e)}catch(t){zt.j(t)}}},$3=[wc,"distinct_id",wl,tx,Xd,Qd,zr],od={},F3={N:()=>!0,j(e){we.error("memoryStorage error: "+e)},P:e=>od[e]||null,H:e=>od[e]||null,F:(e,t)=>(od[e]=t,!0),q(e){delete od[e]}},sa=null,Zt={N(){if(!Hn(sa))return sa;if(sa=!0,ye(ie))sa=!1;else try{var e="__support__";Zt.F(e,"xyz"),Zt.P(e)!=='"xyz"'&&(sa=!1),Zt.q(e)}catch{sa=!1}return sa},j(e){we.error("sessionStorage error: ",e)},P(e){try{return ie==null?void 0:ie.sessionStorage.getItem(e)}catch(t){Zt.j(t)}return null},H(e){try{return JSON.parse(Zt.P(e))||null}catch{}return null},F(e,t){try{return ie==null||ie.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(n){Zt.j(n)}return!1},q(e){try{ie==null||ie.sessionStorage.removeItem(e)}catch(t){Zt.j(t)}}};class U3{constructor(t){this._instance=t}get Ne(){return this._instance.config}get consent(){return this.ti()?0:this.ei}isOptedOut(){return this.Ne.cookieless_mode===$i||this.isRejected()||this.consent===-1&&this.Ne.cookieless_mode===pa}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Ne.opt_out_capturing_by_default}optInOut(t){this.ii.F(this.ri,t?1:0,this.Ne.cookie_expiration,this.Ne.cross_subdomain_cookie,this.Ne.secure_cookie)}reset(){this.ii.q(this.ri,this.Ne.cross_subdomain_cookie)}get ri(){var t=this._instance.config,n=t.token,i=t.opt_out_capturing_cookie_prefix;return t.consent_persistence_name||(i?i+n:"__ph_opt_in_out_"+n)}get ei(){var t=this.ii.P(this.ri);return Bp(t)?1:qe(GC,t)?0:-1}get ii(){var t=this.Ne.opt_out_capturing_persistence_type,n=t==="localStorage"?zt:Fi;if(!this.ni||this.ni!==n){this.ni=n;var i=t==="localStorage"?Fi:zt;i.P(this.ri)&&(this.ni.P(this.ri)||this.optInOut(Bp(i.P(this.ri))),i.q(this.ri,this.Ne.cross_subdomain_cookie))}return this.ni}ti(){return!!this.Ne.respect_dnt&&[In==null?void 0:In.doNotTrack,In==null?void 0:In.msDoNotTrack,Oe.doNotTrack].some((t=>Bp(t)))}}function jw(e,t){var n,i=e==null||(n=e.config)==null?void 0:n.get_current_url;if(!pr(i))return t;try{var a=i(t);return vt(a)&&a?a:t}catch(o){return we.error("Error in get_current_url, falling back to window.location.href",o),t}}var Nw="__POSTHOG_TOOLBAR__",I3=1,H3=3,q3=11;function fy(e){return e instanceof Element&&(e.id===Nw||!(e.closest==null||!e.closest(".toolbar-global-fade-container")))}function As(e){return!!e&&e.nodeType===I3}function mr(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Cw(e){return!!e&&e.nodeType===H3}function Ew(e){return!!e&&e.nodeType===q3&&As(e.host)}var Tw=1e3;function ix(e){return e?gf(e).split(/\s+/):[]}function hy(e,t){var n=(function(i){var a,o=ie==null||(a=ie.location)==null?void 0:a.href;return ye(o)?void 0:jw(i,o)})(t);return!!(n&&e&&e.some((i=>n.match(i))))}function ef(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return ix(t)}function Aw(e){return Ye(e)?null:gf(e).split(/(\s+)/).filter((t=>uc(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function kc(e){var t="";return bg(e)&&!Dw(e)&&e.childNodes&&e.childNodes.length&&Rt(e.childNodes,(function(n){var i;Cw(n)&&n.textContent&&(t+=(i=Aw(n.textContent))!==null&&i!==void 0?i:"")})),gf(t)}function Yp(e){var t;return ye(e.target)?e.srcElement||null:(t=e.target)!=null&&t.shadowRoot?e.composedPath()[0]||null:e.target||null}var sx=["a","button","form","input","select","textarea","label"];function vg(e,t){if(ye(t))return!0;var n,i=function(o){if(t.some((u=>(function(f,h){var p=f.matches||f.matchesSelector||f.msMatchesSelector||f.mozMatchesSelector||f.webkitMatchesSelector||f.oMatchesSelector;try{return!!p&&p.call(f,h)}catch{return!1}})(o,u))))return{v:!0}};for(var a of e)if(n=i(a))return n.v;return!1}function Mw(e){var t=e.parentNode;return!(!t||!As(t))&&t}var V3=[".ph-no-autocapture","[data-ph-no-autocapture]"],Rw=["next","previous","prev",">","<"],G3=[...Rw,"+","-","−","–"],py=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,my=[".ph-no-rageclick",".ph-no-capture"],Y3=["","text","search","email","password","url","tel","number"];function gy(e,t){if(!ie||ax(e))return!1;var n,i,a,o,u;if(Wr(t)?(n=!!t&&my,i=void 0,a=!1):(n=(o=t==null?void 0:t.css_selector_ignorelist)!==null&&o!==void 0?o:my,i=t==null?void 0:t.content_ignorelist,a=(u=t==null?void 0:t.ignore_text_selection)!==null&&u!==void 0&&u),n===!1||a&&(function(h){return!(!h||!As(h))&&(!!mr(h,"textarea")||(mr(h,"input")?qe(Y3,(h.getAttribute("type")||"").toLowerCase()):(function(p){if(p.isContentEditable)return!0;var g=p.getAttribute==null?void 0:p.getAttribute("contenteditable");return g==="true"||g===""})(h)))})(e))return!1;var f=Lw(e,!1).targetElementList;return!(function(h,p){if(h===!1||ye(h))return!1;var g;if(h===!0)g=Rw;else{if(!Ve(h))return!1;if(h.length>10)return we.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;g=h.map((x=>x.toLowerCase()))}return p.some((x=>{var b=x.safeText,y=x.ariaLabel;return g.some((_=>py(b,_)||py(y,_)))}))})(i,f.map((h=>{var p;return{safeText:kc(h).toLowerCase(),ariaLabel:((p=h.getAttribute("aria-label"))==null?void 0:p.toLowerCase().trim())||""}})))&&!vg(f,n)}var ax=e=>!e||mr(e,"html")||!As(e),Lw=(e,t)=>{if(!ie||ax(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var n=!1,i=[e],a=e;a.parentNode&&!mr(a,"body");)if(Ew(a.parentNode))i.push(a.parentNode.host),a=a.parentNode.host;else{var o=Mw(a);if(!o)break;if(t||sx.indexOf(o.tagName.toLowerCase())>-1)n=!0;else try{var u=ie.getComputedStyle(o);u&&u.getPropertyValue("cursor")==="pointer"&&(n=!0)}catch{}i.push(o),a=o}return{parentIsUsefulElement:n,targetElementList:i}};function bg(e){for(var t=new Set,n=0,i=e;i.parentNode&&!mr(i,"body");i=i.parentNode){if(n++>=Tw||t.has(i))return!1;t.add(i);var a=ef(i);if(qe(a,"ph-sensitive")||qe(a,"ph-no-capture"))return!1}if(qe(ef(e),"ph-include"))return!0;var o=e.type||"";if(vt(o))switch(o.toLowerCase()){case"hidden":case"password":return!1}var u=e.name||e.id||"";return!vt(u)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(u.replace(/[^a-zA-Z0-9]/g,""))}function Dw(e){return!!(mr(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||mr(e,"select")||mr(e,"textarea")||e.getAttribute("contenteditable")==="true")}var xy=new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),vy=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,W3=[16,15,14,13],Q3=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),by=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),yy=/[0-9A-Za-z_]/;function X3(e){for(var t=0,n=!1,i=e.length-1;i>=0;i--){var a=e.charCodeAt(i)-48;n&&(a*=2)>9&&(a-=9),t+=a,n=!n}return t%10==0}function uc(e,t){if(t===void 0&&(t=!0),Ye(e))return!1;if(vt(e)){e=gf(e);var n=t?xy.test((e||"").replace(/[- ]/g,"")):(function(a){var o;for(vy.lastIndex=0;o=vy.exec(a);){var u=o[2];if(u)for(var f=u.replace(/[- ]/g,""),h=0;f.length>h;h++)for(var p of W3){var g=h+p;if(f.length>=g){var x=f.slice(h,g);if(xy.test(x)&&X3(x))return!0}}}return!1})(e);if(n)return!1;var i=t?Q3.test(e):(function(a){var o;for(by.lastIndex=0;o=by.exec(a);){var u=o[1],f=o[3];if(!(u&&f&&yy.test(u)&&yy.test(f)))return!0}return!1})(e);if(i)return!1}return!0}function _y(e){var t=kc(e);return uc(t=(t+" "+zw(e)).trim())?t:""}function zw(e){var t="";return e&&e.childNodes&&e.childNodes.length&&Rt(e.childNodes,(function(n){var i;if(n&&((i=n.tagName)==null?void 0:i.toLowerCase())==="span")try{var a=kc(n);t=(t+" "+a).trim(),n.childNodes&&n.childNodes.length&&(t=(t+" "+zw(n)).trim())}catch(o){we.error("[AutoCapture]",o)}})),t}function wy(e){return e.replace(/"|\\"/g,'\\"')}function K3(e){var t=e.attr__class;if(t)return Ve(t)?t:ix(t)}var cd=Wt("[Dead Clicks]"),Z3=()=>!0,J3=e=>{var t,n=!((t=e.instance.persistence)==null||!t.get_property(Jg)),i=e.instance.config.capture_dead_clicks;return Wr(i)?i:!!Bt(i)||n};class Sy{get lazyLoadedDeadClicksAutocapture(){return this.si}constructor(t,n,i){this.instance=t,this.isEnabled=n,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var n=t.config;"captureDeadClicks"in n&&(this.instance.persistence&&this.instance.persistence.register({[Jg]:n.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.ai((()=>{this.oi()})):this.stop()}ai(t){var n,i;(n=Oe.__PosthogExtensions__)!=null&&n.initDeadClicksAutocapture?t():(i=Oe.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(a=>{a?cd.error("failed to load script",a):t()}))}oi(){var t;if(ke){if(!this.si&&(t=Oe.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture){var n=Bt(this.instance.config.capture_dead_clicks)?he({},this.instance.config.capture_dead_clicks):{};n.__onCapture=this.onCapture,this.onCapture&&(n.capture_dead_swipes=!1),this.si=Oe.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this.si.start(ke),cd.info("starting...")}}else cd.error("`document` not found. Cannot start.")}stop(){this.si&&(this.si.stop(),this.si=void 0,cd.info("stopping..."))}}var Wp=Wt("[SegmentIntegration]"),Ow="posthog-js";function Bw(e,t){var n=t===void 0?{}:t,i=n.organization,a=n.projectId,o=n.prefix,u=n.severityAllowList,f=u===void 0?["error"]:u,h=n.sendExceptionsToPostHog,p=h===void 0||h;return g=>{var x,b,y,_,j;if(f!=="*"&&!f.includes(g.level)||!e.__loaded)return g;g.tags||(g.tags={});var C=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());g.tags["PostHog Person URL"]=C,e.sessionRecordingStarted()&&(g.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var k,E=((x=g.exception)==null?void 0:x.values)||[],N=E.map((O=>he({},O,{stacktrace:O.stacktrace?he({},O.stacktrace,{type:"raw",frames:(O.stacktrace.frames||[]).map((L=>he({},L,{platform:"web:javascript"})))}):void 0}))),D={$exception_message:((b=E[0])==null?void 0:b.value)||g.message,$exception_type:(y=E[0])==null?void 0:y.type,$exception_level:g.level,$exception_list:N,$sentry_event_id:g.event_id,$sentry_exception:g.exception,$sentry_exception_message:((_=E[0])==null?void 0:_.value)||g.message,$sentry_exception_type:(j=E[0])==null?void 0:j.type,$sentry_tags:g.tags};return i&&a&&(D.$sentry_url=(o||"https://sentry.io/organizations/")+i+"/issues/?project="+a+"&query="+g.event_id),p&&((k=e.exceptions)==null||k.sendExceptionEvent(D)),g}}class e4{constructor(t,n,i,a,o,u){this.name=Ow,this.setupOnce=function(f){f(Bw(t,{organization:n,projectId:i,prefix:a,severityAllowList:o,sendExceptionsToPostHog:u==null||u}))}}}class ky{constructor(t){this.li=(n,i,a)=>{a&&(a.noSessionId||a.activityTimeout||a.sessionPastMaximumLength||a.crossTabAdoption)&&(we.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:n,changeReason:a}),this.ui=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.hi()}hi(){var t;this.di=(t=this._instance.sessionManager)==null?void 0:t.onSessionId(this.li)}destroy(){var t;(t=this.di)==null||t.call(this),this.di=void 0}doPageView(t,n){var i,a=this.vi(t,n);return this.ui={pathname:(i=ie==null?void 0:ie.location.pathname)!==null&&i!==void 0?i:"",pageViewId:n,timestamp:t},this._instance.scrollManager.resetContext(),a}doPageLeave(t){var n;return this.vi(t,(n=this.ui)==null?void 0:n.pageViewId)}doEvent(){var t;return{$pageview_id:(t=this.ui)==null?void 0:t.pageViewId}}vi(t,n){var i=this.ui;if(!i)return{$pageview_id:n};var a={$pageview_id:n,$prev_pageview_id:i.pageViewId},o=this._instance.scrollManager.getContext();if(o&&!this._instance.config.disable_scroll_properties){var u=o.maxScrollHeight,f=o.lastScrollY,h=o.maxScrollY,p=o.maxContentHeight,g=o.lastContentY,x=o.maxContentY;if(!(ye(u)||ye(f)||ye(h)||ye(p)||ye(g)||ye(x))){u=Math.ceil(u),f=Math.ceil(f),h=Math.ceil(h),p=Math.ceil(p),g=Math.ceil(g),x=Math.ceil(x);var b=u>1?ui(f/u,0,1,we):1,y=u>1?ui(h/u,0,1,we):1,_=p>1?ui(g/p,0,1,we):1,j=p>1?ui(x/p,0,1,we):1;a=Ot(a,{$prev_pageview_last_scroll:f,$prev_pageview_last_scroll_percentage:b,$prev_pageview_max_scroll:h,$prev_pageview_max_scroll_percentage:y,$prev_pageview_last_content:g,$prev_pageview_last_content_percentage:_,$prev_pageview_max_content:x,$prev_pageview_max_content_percentage:j})}}return i.pathname&&(a.$prev_pageview_pathname=i.pathname),i.timestamp&&(a.$prev_pageview_duration=(t.getTime()-i.timestamp.getTime())/1e3),a}}var Qp=["flags","surveys"],t4={[hw]:{exposure:"hidden"},[ec]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[tc]:{exposure:"hidden"},[Jm]:{exposure:"event"},[eg]:{exposure:"hidden"},[tg]:{exposure:"event"},[ng]:{exposure:"hidden"},[rg]:{exposure:"event"},[ig]:{exposure:"event"},[Jg]:{exposure:"event"},[ex]:{exposure:"hidden"},[sg]:{exposure:"event"},[xa]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[wl]:{exposure:"hidden"},[tx]:{exposure:"event"},[pw]:{exposure:"event",shouldSkipFromEventProperties:e=>Hn(e)},$session_past_minimum_duration:{exposure:"event"},$session_recording_url_trigger_activated_session:{exposure:"event"},$session_recording_event_trigger_activated_session:{exposure:"event"},$debug_first_full_snapshot_timestamp:{exposure:"event"},$sess_rec_flush_size:{exposure:"hidden"},[ga]:{exposure:"derived",storageGroup:"flags",shouldSkipFromEventProperties:(e,t)=>t(),transformToEventProperties(e){if(!Bt(e))return{};for(var t={},n=Object.keys(e),i=0;n.length>i;i++)t["$feature/"+n[i]]=e[n[i]];return t}},[Nd]:{exposure:"event",storageGroup:"flags"},[nc]:{exposure:"hidden"},[ag]:{exposure:"hidden",storageGroup:"flags"},[Cd]:{exposure:"event",storageGroup:"flags"},[lg]:{exposure:"event",storageGroup:"flags",volatile:!0},[Yd]:{exposure:"hidden",storageGroup:"flags"},[Oi]:{exposure:"event"},[vl]:{exposure:"hidden"},[fa]:{exposure:"hidden"},[ha]:{exposure:"hidden"},[og]:{exposure:"hidden",storageGroup:"surveys"},[Wd]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[cg]:{exposure:"event"},[Ed]:{exposure:"hidden"},[Td]:{exposure:"hidden"},[rc]:{exposure:"hidden"},$product_tours_activated:{exposure:"hidden"},$product_tours_activated_session:{exposure:"hidden"},$conversations_widget_session_id:{exposure:"event"},$conversations_ticket_id:{exposure:"event"},$conversations_widget_state:{exposure:"event"},$conversations_user_traits:{exposure:"event"},[cc]:{exposure:"hidden"},[ug]:{exposure:"hidden"},[dg]:{exposure:"hidden"},[Sc]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[zr]:{exposure:"hidden"},[fg]:{exposure:"hidden"},[hg]:{exposure:"hidden"},[pg]:{exposure:"hidden"},[mg]:{exposure:"hidden"},[Qd]:{exposure:"hidden"},[Xd]:{exposure:"hidden"},[mw]:{exposure:"event"},[gw]:{exposure:"event"},[xw]:{exposure:"event"},[vw]:{exposure:"event"},[yw]:{exposure:"event"},[_w]:{exposure:"event"},[ww]:{exposure:"event"},$sdk_debug_replay_event_trigger_status:{exposure:"event"},$sdk_debug_replay_linked_flag_trigger_status:{exposure:"event"},$sdk_debug_replay_matched_recording_trigger_groups:{exposure:"event"},$sdk_debug_replay_remote_trigger_matching_config:{exposure:"event"},$sdk_debug_replay_trigger_groups_count:{exposure:"event"},$sdk_debug_replay_url_trigger_status:{exposure:"event"},$session_recording_start_reason:{exposure:"event"}},n4=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],aa=e=>{var t=t4[e];if(t)return t;for(var n of n4){var i=n[1];if(e.indexOf(n[0])===0)return i}},Sl=(e,t)=>{try{return JSON.stringify(e,((n,i)=>typeof i=="bigint"?i.toString():i),t)}catch{return D5(e)}},tf=e=>{var t=ke==null?void 0:ke.createElement("a");return ye(t)?null:(t.href=e,t)},Al=function(e,t){for(var n,i=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),a=0;i.length>a;a++){var o=i[a].split("=");if(o[0]===t){n=o;break}}if(!Ve(n)||2>n.length)return"";var u=n[1];try{u=decodeURIComponent(u)}catch{we.error("Skipping decoding for malformed query param: "+u)}return u.replace(/\+/g," ")},jc=function(e,t,n){if(!e||!t||!t.length)return e;for(var i=e.split("#"),a=i[1],o=(i[0]||"").split("?"),u=o[1],f=o[0],h=(u||"").split("&"),p=[],g=0;h.length>g;g++){var x=h[g].split("=");Ve(x)&&(t.includes(x[0])?p.push(x[0]+"="+n):p.push(h[g]))}var b=f;return u!=null&&(b+="?"+p.join("&")),a!=null&&(b+="#"+a),b},nf=function(e,t){var n=e.match(new RegExp(t+"=([^&]*)"));return n?n[1]:null},Pw=(e,t)=>e>=t&&M5(),$w=(e,t,n,i)=>{if(e===0){if(M5()){var a=t+1;return a===n&&i(),a}return t}return 0},ud="https?://(.*)",Ml=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],r4=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Ml],Nc="<masked>",i4=["li_fat_id"];function Fw(e,t,n){if(!ke)return{};var i,a=t?[...Ml,...n||[]]:[],o=Uw(jc(ke.URL,a,Nc),e),u=(i={},Rt(i4,(function(f){var h=Sw(f);i[f]=h||null})),i);return Ot(u,o)}function Uw(e,t){var n=r4.concat(t||[]),i={};return Rt(n,(function(a){var o=Al(e,a);i[a]=o||null})),i}function Iw(e){var t=(function(o){return o?o.search(ud+"google.([^/?]*)")===0?"google":o.search(ud+"bing.com")===0?"bing":o.search(ud+"yahoo.com")===0?"yahoo":o.search(ud+"duckduckgo.com")===0?"duckduckgo":null:null})(e),n=t!="yahoo"?"q":"p",i={};if(!Hn(t)){i.$search_engine=t;var a=ke?Al(ke.referrer,n):"";a.length&&(i.ph_keyword=a)}return i}function jy(){return navigator.language||navigator.userLanguage}var rf="$direct";function Hw(){return(ke==null?void 0:ke.referrer)||rf}function qw(e,t,n){n===void 0&&(n=!1);var i=e?[...Ml,...t||[]]:[],a=n?Ts(Vt==null?void 0:Vt.href):Vt==null?void 0:Vt.href,o=a==null?void 0:a.substring(0,1e3);return{r:Hw().substring(0,1e3),u:o?jc(o,i,Nc):void 0}}function Vw(e,t){var n;t===void 0&&(t=!1);var i=e.r,a=e.u,o=t?Ts(a):a,u={$referrer:i,$referring_domain:i==null?void 0:i==rf?rf:(n=tf(i))==null?void 0:n.host};if(o){u.$current_url=o;var f=tf(o);u.$host=f==null?void 0:f.host,u.$pathname=f==null?void 0:f.pathname;var h=Uw(o);Ot(u,h)}if(i){var p=Iw(i);Ot(u,p)}return u}function Gw(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function s4(){try{return new Date().getTimezoneOffset()}catch{return}}var a4={flags:Sc,surveys:Wd},l4=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],hl="main";class Xp{constructor(t,n,i){if(i===void 0&&(i=!0),this.ci={},this.fi=!1,this.pi=!1,this.Ne=t,this.gi=i,this.props={},this.mi=void 0,this.yi=(o=>{var u="";return o.token&&(u=o.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),o.persistence_name?"ph_"+o.persistence_name:"ph_"+u+"_posthog"})(t),this.ii=this.bi(t),this.pi=this.wi(t),this.load(),t.debug&&we.info("Persistence loaded",t.persistence,he({},this.props)),this.update_config(t,t,n),this.save(),ie){var a=()=>this.flush();Gt(ie,"beforeunload",a,{capture:!1}),Gt(ie,"pagehide",a,{capture:!1})}}ki(){var t,n=(t=this.Ne)==null?void 0:t.persistence_save_debounce_ms;return sn(n)&&n>0?n:0}isDisabled(){return!!this.xi}bi(t){l4.indexOf(t.persistence.toLowerCase())===-1&&(we.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");var n,i=(function(u,f){u===void 0&&(u=[]),f===void 0&&(f=!1);var h=[...$3,...u];return he({},zt,{H(p){try{var g={};try{g=Fi.H(p)||{}}catch{}var x,b=JSON.parse(zt.P(p)||"{}");if(f){var y={};for(var _ in g){var j=g[_];Hn(j)||j===""||(y[_]=j)}x=Ot(b,y)}else x=Ot(g,b);return zt.F(p,x),x}catch{}return null},F(p,g,x,b,y,_){var j=zt.F(p,g,void 0,void 0,_);try{var C={};h.forEach((k=>{g[k]&&(C[k]=g[k])})),Object.keys(C).length&&Fi.F(p,C,x,b,y,_)}catch(k){zt.j(k)}return j},q(p,g){try{ie==null||ie.localStorage.removeItem(p),Fi.q(p,g)}catch(x){zt.j(x)}}})})(t.cookie_persisted_properties||[],t.__preview_cookie_wins_on_conflict||!1),a=!1,o=t.persistence.toLowerCase();return o==="localstorage"&&zt.N()?(n=zt,a=!0):o==="localstorage+cookie"&&i.N()?(n=i,a=!0):o==="sessionstorage"&&Zt.N()?n=Zt:o==="memory"?n=F3:o==="cookie"?n=Fi:i.N()?(n=i,a=!0):n=Fi,this.fi=a,n}Si(t){return this.yi+"__"+t}wi(t){return this.fi&&!!t.split_storage}Ci(t){var n=t??this.Ne.feature_flag_cache_ttl_ms;if(!n||0>=n)return!1;var i=this.props[Sc];return!i||typeof i!="number"||Date.now()-i>n}properties(){var t={};return Rt(this.props,((n,i)=>{var a=aa(i);if((a==null?void 0:a.exposure)==="derived"){if(a.shouldSkipFromEventProperties!=null&&a.shouldSkipFromEventProperties(n,i===ga?()=>this.Ci():()=>!1))return;a.transformToEventProperties&&Ot(t,a.transformToEventProperties(n))}else if(!a||a.exposure==="event"){if(a!=null&&a.shouldSkipFromEventProperties!=null&&a.shouldSkipFromEventProperties(n,(()=>!1)))return;t[i]=n}})),t}load(){if(!this.xi){var t=this.ii.H(this.yi);t&&(this.props=Ot({},t)),this.pi&&this.Mi()}}Mi(){for(var t of Qp){var n=zt.H(this.Si(t));if(n&&!Ii(n)){var i=this.Ti(t);i.persisted=!0,this.Ei(t)||(i.fingerprint=this.Ii(n,t)),this.Pi(t,n)||Ot(this.props,n)}}}Ei(t){return Object.keys(this.props).some((n=>{var i;return((i=aa(n))==null?void 0:i.storageGroup)===t}))}Pi(t,n){var i=a4[t];if(!i)return!1;var a=n[i],o=this.props[i];return sn(a)&&sn(o)&&o>a}refreshKey(t){var n;if(!this.xi){var i=this.pi?(n=aa(t))==null?void 0:n.storageGroup:void 0,a=i?zt.H(this.Si(i)):this.ii.H(this.yi);if(a&&t in a)this.Ri(t,a[t]);else{if(i){var o=this.ii.H(this.yi);if(o&&t in o)return void this.Ri(t,o[t])}this.Ai(t)}}}save(){if(!this.xi){var t=this.ki();t>0?ye(this.Fi)&&(this.Fi=setTimeout((()=>{this.Fi=void 0,this.Li()}),t)):this.Li()}}flush(){ye(this.Fi)||(clearTimeout(this.Fi),this.Fi=void 0,this.Li())}Li(){this.xi||(this.pi?this.Oi():this.Di(this.ii,this.yi,this.props,hl))}Oi(){var t=this.$i(),n=t.main,i=t.groups;for(var a of(this.Di(this.ii,this.yi,n,hl),Qp)){var o,u=i[a];(!Ii(u)||(o=this.ci[a])!=null&&o.persisted)&&this.Di(zt,this.Si(a),u,a)}}$i(){var t={},n={flags:{},surveys:{}};return Rt(this.props,((i,a)=>{var o,u=(o=aa(a))==null?void 0:o.storageGroup;u?n[u][a]=i:t[a]=i})),{main:t,groups:n}}Ii(t,n){if(n===hl)return JSON.stringify(t)+"|"+this.Ni+"|"+this.qi+"|"+this.ji;var i={};return Rt(t,((a,o)=>{var u;i[o]=(u=aa(o))!=null&&u.volatile?"__volatile__":a})),JSON.stringify(i)}Di(t,n,i,a){var o=this.Ti(a);if(a===hl||o.dirty||ye(o.fingerprint)){var u;try{if((u=this.Ii(i,a))===o.fingerprint)return void(o.dirty=!1)}catch{u=void 0}t.F(n,i,this.Ni,this.qi,this.ji,this.Ne.debug)?(o.dirty=!1,a!==hl&&(o.persisted=!0),ye(u)||(o.fingerprint=u)):this.Ne.debug&&we.warn('failed to persist storage entry "'+n+'"; will retry on next save')}}remove(t){var n=(t===void 0?{}:t).keepGroupEntries,i=n!==void 0&&n;if(ye(this.Fi)||(clearTimeout(this.Fi),this.Fi=void 0),this.ii.q(this.yi,!1),this.ii.q(this.yi,!0),!i&&this.gi)for(var a of Qp)zt.q(this.Si(a));i?delete this.ci[hl]:this.ci={}}clear(){this.remove(),this.props={}}register_once(t,n,i){if(Bt(t)){ye(n)&&(n="None"),this.Ni=ye(i)?this.Bi:i;var a=!1;if(Rt(t,((o,u)=>{this.props.hasOwnProperty(u)&&this.props[u]!==n||(this.Ri(u,o),a=!0)})),a)return this.save(),!0}return!1}register(t,n){if(Bt(t)){this.Ni=ye(n)?this.Bi:n;var i=!1;if(Rt(t,((a,o)=>{t.hasOwnProperty(o)&&(this.props[o]!==a||Bt(a)||Ve(a))&&(this.Ri(o,a),i=!0)})),i)return this.save(),!0}return!1}unregister(t){t in this.props&&(this.Ai(t),this.save())}update_campaign_params(){var t=ke==null?void 0:ke.URL;if(t!==this.mi){var n=Fw(this.Ne.custom_campaign_params,this.Ne.mask_personal_data_properties,this.Ne.custom_personal_data_properties);Ii(rx(n))||this.register(n),this.mi=t}}update_search_keyword(){var t;this.register((t=ke==null?void 0:ke.referrer)?Iw(t):{})}update_referrer_info(){var t;this.register_once({$referrer:Hw(),$referring_domain:ke!=null&&ke.referrer&&((t=tf(ke.referrer))==null?void 0:t.host)||rf},void 0)}set_initial_person_info(){this.props[pg]||this.props[mg]||this.register_once({[Qd]:qw(this.Ne.mask_personal_data_properties,this.Ne.custom_personal_data_properties,this.Ne.disable_capture_url_hashes)},void 0)}get_initial_props(){var t={};Rt([mg,pg],(a=>{var o=this.props[a];o&&Rt(o,(function(u,f){t["$initial_"+Gm(f)]=u}))}));var n=this.props[Qd];if(n){var i=(function(a,o){o===void 0&&(o=!1);var u=Vw(a,o),f={};return Rt(u,(function(h,p){f["$initial_"+Gm(p)]=h})),f})(n,this.Ne.disable_capture_url_hashes);Ot(t,i)}return t}safe_merge(t){return Rt(this.props,(function(n,i){i in t||(t[i]=n)})),t}update_config(t,n,i){this.Bi=this.Ni=t.cookie_expiration,this.set_disabled(t.disable_persistence||!!i),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie);var a=t.persistence!==n.persistence||!((h,p)=>{if(h.length!==p.length)return!1;var g=[...h].sort(),x=[...p].sort();return g.every(((b,y)=>b===x[y]))})(t.cookie_persisted_properties||[],n.cookie_persisted_properties||[]),o=a?this.bi(t):this.ii,u=this.wi(t);if(a||u!==this.pi){var f=this.props;this.clear(),this.ii=o,this.pi=u,this.props=f,this.save()}}set_disabled(t){this.xi=t,this.xi?this.remove():this.save()}set_cross_subdomain(t){t!==this.qi&&(this.qi=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.ji&&(this.ji=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,n){var i=this.props[tc]||{};i[t]=n,this.Ri(tc,i),this.save()}remove_event_timer(t){var n=this.props[tc]||{},i=n[t];return ye(i)||(delete n[t],this.Ri(tc,n),this.save()),i}get_property(t){return this.props[t]}set_property(t,n){this.Ri(t,n),this.save()}Ri(t,n){var i;this.props[t]=n,(i=aa(t))!=null&&i.volatile||this.Hi(t)}Ai(t){delete this.props[t],this.Hi(t)}Hi(t){var n,i=(n=aa(t))==null?void 0:n.storageGroup;i&&(this.Ti(i).dirty=!0)}Ti(t){return this.ci[t]||(this.ci[t]={})}}function dd(e){var t=!0;return{dispose(){if(t){t=!1;var n=e();n&&pr(n.then)&&n.then(void 0,(()=>{}))}}}}var $n={GZipJS:"gzip-js",Base64:"base64"},Fo={Activation:"events",Cancellation:"cancelEvents"},Kp={Popover:"popover",API:"api",Widget:"widget"},Ui={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},Zp={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},yg={Popover:"popover",Inline:"inline"},o4={SHOWN:"product tour shown"},Ny={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},Cy=Wt("[RateLimiter]");class c4{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=n=>{var i=n.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach((a=>{Cy.info((a||"events")+" is quota limited."),this.serverLimits[a]=new Date().getTime()+6e4}))}catch(a){return void Cy.warn('could not rate limit - continuing. Error: "'+(a==null?void 0:a.message)+'"',{text:i})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return((t=this.instance.config.rate_limiting)==null?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max(((t=this.instance.config.rate_limiting)==null?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t){var n,i,a;t===void 0&&(t=!1);var o=this.captureEventsBurstLimit,u=this.captureEventsPerSecond,f=new Date().getTime(),h=(n=(i=this.instance.persistence)==null?void 0:i.get_property(hg))!==null&&n!==void 0?n:{tokens:o,last:f};h.tokens+=(f-h.last)/1e3*u,h.last=f,h.tokens>o&&(h.tokens=o);var p=1>h.tokens;if(p||t||(h.tokens=Math.max(0,h.tokens-1)),p&&!t){var g=(sn(h.dropped)?h.dropped:0)+1;h.dropped=g,!this.lastEventRateLimited&&this.Ui(g)&&(h.dropped=0)}return this.lastEventRateLimited=p,(a=this.instance.persistence)==null||a.set_property(hg,h),{isRateLimited:p,remainingTokens:h.tokens}}zi(t){var n=this.instance.config.property_denylist;return!Ve(n)||!n.includes(t)}Wi(){var t;if(this.zi("$current_url")&&this.zi("$pathname")&&Vt!=null&&Vt.pathname)return""+((t=Vt.origin)!==null&&t!==void 0?t:"")+Vt.pathname}Ui(t){var n,i,a=this.captureEventsBurstLimit,o=this.captureEventsPerSecond,u=this.Wi(),f=this.zi("$session_id")?(n=(i=this.instance).get_session_id)==null?void 0:n.call(i):void 0,h=[t+" event(s) dropped since the last warning",u?"triggered on "+u:void 0,f?"session "+f:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited: "+h+". Config is set to "+o+" events per second and "+a+" events burst limit."},{skip_client_rate_limiting:!0})}isServerRateLimited(t){var n=this.serverLimits[t||"events"]||!1;return n!==!1&&new Date().getTime()<n}}var ks=Wt("[RemoteConfig]");class Yw{constructor(t){this._instance=t}get remoteConfig(){var t;return(t=Oe._POSTHOG_REMOTE_CONFIG)==null||(t=t[this._instance.config.token])==null?void 0:t.config}Vi(t){var n,i;(n=Oe.__PosthogExtensions__)!=null&&n.loadExternalDependency?(i=Oe.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):t()}Zi(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return ks.info("Using preloaded remote config",this.remoteConfig),this.Gi(this.remoteConfig),void this.Qi();if(this._instance.Ki())return void ks.warn("Remote config is disabled. Falling back to local config.");this.Vi((t=>{if(!t)return ks.info("No config found after loading remote JS config. Falling back to JSON."),void this.Zi((n=>{this.Gi(n.json,n),this.Qi()}));this.Gi(t),this.Qi()}))}catch(t){ks.error("Error loading remote config",t),this.Gi()}}stop(){this.Ji&&(clearInterval(this.Ji),this.Ji=void 0)}refresh(){!this._instance.Ki()&&ke&&ke.visibilityState!=="hidden"&&this._instance.reloadFeatureFlags()}Qi(){var t;if(!this.Ji){var n=(t=this._instance.config.remote_config_refresh_interval_ms)!==null&&t!==void 0?t:3e5;n!==0&&(this.Ji=setInterval((()=>{this.refresh()}),n))}}Gi(t,n){!t&&n&&(n.statusCode===0?n.error||ks.warn("Failed to fetch remote config from PostHog."):ks.error("Failed to fetch remote config from PostHog."));try{this._instance.Gi(t?{ok:!0,config:t}:{ok:!1})}catch(a){ks.error("Error applying remote config",a)}if((t==null?void 0:t.hasFeatureFlags)!==!1&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var i;(i=this._instance.featureFlags)==null||i.ensureFlagsLoaded()}catch(a){ks.error("Error loading feature flags",a)}}}var Pr=Uint8Array,tr=Uint16Array,Rl=Uint32Array,lx=new Pr([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]),ox=new Pr([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]),Ey=new Pr([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ww=function(e,t){for(var n=new tr(31),i=0;31>i;++i)n[i]=t+=1<<e[i-1];var a=new Rl(n[30]);for(i=1;30>i;++i)for(var o=n[i];n[i+1]>o;++o)a[o]=o-n[i]<<5|i;return[n,a]},Qw=Ww(lx,2),_g=Qw[1];Qw[0][28]=258,_g[258]=28;for(var Ty=Ww(ox,0)[1],Xw=new tr(32768),Yt=0;32768>Yt;++Yt){var pl=(43690&Yt)>>>1|(21845&Yt)<<1;Xw[Yt]=((65280&(pl=(61680&(pl=(52428&pl)>>>2|(13107&pl)<<2))>>>4|(3855&pl)<<4))>>>8|(255&pl)<<8)>>>1}var dc=function(e,t,n){for(var i=e.length,a=0,o=new tr(t);i>a;++a)++o[e[a]-1];var u,f=new tr(t);for(a=0;t>a;++a)f[a]=f[a-1]+o[a-1]<<1;for(u=new tr(i),a=0;i>a;++a)u[a]=Xw[f[e[a]-1]++]>>>15-e[a];return u},ya=new Pr(288);for(Yt=0;144>Yt;++Yt)ya[Yt]=8;for(Yt=144;256>Yt;++Yt)ya[Yt]=9;for(Yt=256;280>Yt;++Yt)ya[Yt]=7;for(Yt=280;288>Yt;++Yt)ya[Yt]=8;var sf=new Pr(32);for(Yt=0;32>Yt;++Yt)sf[Yt]=5;var u4=dc(ya,9),d4=dc(sf,5),Kw=function(e){return(e/8>>0)+(7&e&&1)},Zw=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var i=new(e instanceof tr?tr:e instanceof Rl?Rl:Pr)(n-t);return i.set(e.subarray(t,n)),i},Mi=function(e,t,n){var i=t/8>>0;e[i]|=n<<=7&t,e[i+1]|=n>>>8},Uo=function(e,t,n){var i=t/8>>0;e[i]|=n<<=7&t,e[i+1]|=n>>>8,e[i+2]|=n>>>16},Jp=function(e,t){for(var n=[],i=0;e.length>i;++i)e[i]&&n.push({s:i,f:e[i]});var a=n.length,o=n.slice();if(!a)return[new Pr(0),0];if(a==1){var u=new Pr(n[0].s+1);return u[n[0].s]=1,[u,1]}n.sort((function(O,L){return O.f-L.f})),n.push({s:-1,f:25001});var f=n[0],h=n[1],p=0,g=1,x=2;for(n[0]={s:-1,f:f.f+h.f,l:f,r:h};g!=a-1;)f=n[n[x].f>n[p].f?p++:x++],h=n[p!=g&&n[x].f>n[p].f?p++:x++],n[g++]={s:-1,f:f.f+h.f,l:f,r:h};var b=o[0].s;for(i=1;a>i;++i)o[i].s>b&&(b=o[i].s);var y=new tr(b+1),_=wg(n[g-1],y,0);if(_>t){i=0;var j=0,C=_-t,k=1<<C;for(o.sort((function(O,L){return y[L.s]-y[O.s]||O.f-L.f}));a>i;++i){var E=o[i].s;if(t>=y[E])break;j+=k-(1<<_-y[E]),y[E]=t}for(j>>>=C;j>0;){var N=o[i].s;t>y[N]?j-=1<<t-y[N]++-1:++i}for(;i>=0&&j;--i){var D=o[i].s;y[D]==t&&(--y[D],++j)}_=t}return[new Pr(y),_]},wg=function(e,t,n){return e.s==-1?Math.max(wg(e.l,t,n+1),wg(e.r,t,n+1)):t[e.s]=n},Ay=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new tr(++t),i=0,a=e[0],o=1,u=function(h){n[i++]=h},f=1;t>=f;++f)if(e[f]==a&&f!=t)++o;else{if(!a&&o>2){for(;o>138;o-=138)u(32754);o>2&&(u(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(u(a),--o;o>6;o-=6)u(8304);o>2&&(u(o-3<<5|8208),o=0)}for(;o--;)u(a);o=1,a=e[f]}return[n.subarray(0,i),t]},Io=function(e,t){for(var n=0,i=0;t.length>i;++i)n+=e[i]*t[i];return n},Sg=function(e,t,n){var i=n.length,a=Kw(t+2);e[a]=255&i,e[a+1]=i>>>8,e[a+2]=255^e[a],e[a+3]=255^e[a+1];for(var o=0;i>o;++o)e[a+o+4]=n[o];return 8*(a+4+i)},My=function(e,t,n,i,a,o,u,f,h,p,g){Mi(t,g++,n),++a[256];for(var x=Jp(a,15),b=x[0],y=x[1],_=Jp(o,15),j=_[0],C=_[1],k=Ay(b),E=k[0],N=k[1],D=Ay(j),O=D[0],L=D[1],G=new tr(19),P=0;E.length>P;++P)G[31&E[P]]++;for(P=0;O.length>P;++P)G[31&O[P]]++;for(var Q=Jp(G,7),B=Q[0],I=Q[1],M=19;M>4&&!B[Ey[M-1]];--M);var le,J,Y,$,F=p+5<<3,V=Io(a,ya)+Io(o,sf)+u,ge=Io(a,b)+Io(o,j)+u+14+3*M+Io(G,B)+(2*G[16]+3*G[17]+7*G[18]);if(V>=F&&ge>=F)return Sg(t,g,e.subarray(h,h+p));if(Mi(t,g,1+(V>ge)),g+=2,V>ge){le=dc(b,y),J=b,Y=dc(j,C),$=j;var R=dc(B,I);for(Mi(t,g,N-257),Mi(t,g+5,L-1),Mi(t,g+10,M-4),g+=14,P=0;M>P;++P)Mi(t,g+3*P,B[Ey[P]]);g+=3*M;for(var z=[E,O],Z=0;2>Z;++Z){var A=z[Z];for(P=0;A.length>P;++P)Mi(t,g,R[ue=31&A[P]]),g+=B[ue],ue>15&&(Mi(t,g,A[P]>>>5&127),g+=A[P]>>>12)}}else le=u4,J=ya,Y=d4,$=sf;for(P=0;f>P;++P)if(i[P]>255){var ue;Uo(t,g,le[257+(ue=i[P]>>>18&31)]),g+=J[ue+257],ue>7&&(Mi(t,g,i[P]>>>23&31),g+=lx[ue]);var xe=31&i[P];Uo(t,g,Y[xe]),g+=$[xe],xe>3&&(Uo(t,g,i[P]>>>5&8191),g+=ox[xe])}else Uo(t,g,le[i[P]]),g+=J[i[P]];return Uo(t,g,le[256]),g+J[256]},f4=new Rl([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),h4=(function(){for(var e=new Rl(256),t=0;256>t;++t){for(var n=t,i=9;--i;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e})(),em=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function p4(e,t){t===void 0&&(t={});var n=(function(){var x=4294967295;return{p(b){for(var y=x,_=0;b.length>_;++_)y=h4[255&y^b[_]]^y>>>8;x=y},d(){return 4294967295^x}}})(),i=e.length;n.p(e);var a,o,u,f,h,p=(f=10+((a=t).filename&&a.filename.length+1||0),h=8,(function(x,b,y,_,j,C){var k=x.length,E=new Pr(_+k+5*(1+Math.floor(k/7e3))+j),N=E.subarray(_,E.length-j),D=0;if(!b||8>k)for(var O=0;k>=O;O+=65535){var L=O+65535;k>L?D=Sg(N,D,x.subarray(O,L)):(N[O]=!0,D=Sg(N,D,x.subarray(O,k)))}else{for(var G=f4[b-1],P=G>>>13,Q=8191&G,B=(1<<y)-1,I=new tr(32768),M=new tr(B+1),le=Math.ceil(y/3),J=2*le,Y=function(mt){return(x[mt]^x[mt+1]<<le^x[mt+2]<<J)&B},$=new Rl(25e3),F=new tr(288),V=new tr(32),ge=0,R=0,z=(O=0,0),Z=0,A=0;k>O;++O){var ue=Y(O),xe=32767&O,je=M[ue];if(I[xe]=je,M[ue]=xe,O>=Z){var Re=k-O;if((ge>7e3||z>24576)&&Re>423){D=My(x,N,0,$,F,V,R,z,A,O-A,D),z=ge=R=0,A=O;for(var Le=0;286>Le;++Le)F[Le]=0;for(Le=0;30>Le;++Le)V[Le]=0}var Be=2,Je=0,it=Q,ht=xe-je&32767;if(Re>2&&ue==Y(O-ht))for(var Jt=Math.min(P,Re)-1,pt=Math.min(32767,O),_t=Math.min(258,Re);pt>=ht&&--it&&xe!=je;){if(x[O+Be]==x[O+Be-ht]){for(var Nt=0;_t>Nt&&x[O+Nt]==x[O+Nt-ht];++Nt);if(Nt>Be){if(Be=Nt,Je=ht,Nt>Jt)break;var ve=Math.min(ht,Nt-2),Fe=0;for(Le=0;ve>Le;++Le){var ct=O-ht+Le+32768&32767,xn=ct-I[ct]+32768&32767;xn>Fe&&(Fe=xn,je=ct)}}}ht+=(xe=je)-(je=I[xe])+32768&32767}if(Je){$[z++]=268435456|_g[Be]<<18|Ty[Je];var Ne=31&_g[Be],ze=31&Ty[Je];R+=lx[Ne]+ox[ze],++F[257+Ne],++V[ze],Z=O+Be,++ge}else $[z++]=x[O],++F[x[O]]}}D=My(x,N,!0,$,F,V,R,z,A,O-A,D)}return Zw(E,0,_+Kw(D)+j)})(o=e,(u=t).level==null?6:u.level,u.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(o.length)))):12+u.mem,f,h)),g=p.length;return(function(x,b){var y=b.filename;if(x[0]=31,x[1]=139,x[2]=8,x[8]=2>b.level?4:b.level==9?2:0,x[9]=3,b.mtime!=0&&em(x,4,Math.floor(new Date(b.mtime||Date.now())/1e3)),y){x[3]=8;for(var _=0;y.length>=_;++_)x[_+10]=y.charCodeAt(_)}})(p,t),em(p,g-8,n.d()),em(p,g-4,i),p}var m4=!!Hm||!!Gg,Jw="text/plain",Md=!1,e2=(e,t)=>{var n=e.split("#"),i=n[1],a=n[0].split("?"),o=a[0],u=a[1];if(!u)return e;var f=u.split("&").filter((h=>h.split("=")[0]!==t)).join("&");return o+(f?"?"+f:"")+(i?"#"+i:"")},vf=function(e,t,n){var i;n===void 0&&(n=!0);var a=e.split("?"),o=a[0],u=a[1],f=he({},t),h=(i=u==null?void 0:u.split("&").map((g=>{var x,b=g.split("="),y=b[0],_=n&&(x=f[y])!==null&&x!==void 0?x:b[1];return delete f[y],y+"="+_})))!==null&&i!==void 0?i:[],p=(function(g,x){var b,y;x===void 0&&(x="&");var _=[];return Rt(g,(function(j,C){ye(j)||ye(C)||C==="undefined"||(b=encodeURIComponent((k=>k instanceof File)(j)?j.name:j.toString()),y=encodeURIComponent(C),_[_.length]=y+"="+b)})),_.join(x)})(f);return p&&h.push(p),h.length>0?o+"?"+h.join("&"):o},tm=e=>{if(e.Yi)return e.Yi;var t=e.data,n=e.compression;if(t){if(n===$n.GZipJS){var i=p4((function(f,h){var p=f.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(f);for(var g=new Pr(f.length+(f.length>>>1)),x=0,b=function(C){g[x++]=C},y=0;p>y;++y){if(x+5>g.length){var _=new Pr(x+8+(p-y<<1));_.set(g),g=_}var j=f.charCodeAt(y);128>j?b(j):2048>j?(b(192|j>>>6),b(128|63&j)):j>55295&&57344>j?(b(240|(j=65536+(1047552&j)|1023&f.charCodeAt(++y))>>>18),b(128|j>>>12&63),b(128|j>>>6&63),b(128|63&j)):(b(224|j>>>12),b(128|j>>>6&63),b(128|63&j))}return Zw(g,0,x)})(Sl(t)),{mtime:0});return{contentType:Jw,body:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),estimatedSize:i.byteLength}}if(n===$n.Base64){var a=(function(f){return f&&btoa(encodeURIComponent(f).replace(/%([0-9A-F]{2})/g,((h,p)=>String.fromCharCode(parseInt(p,16)))))})(Sl(t)),o=(f=>"data="+encodeURIComponent(typeof f=="string"?f:Sl(f)))(a);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var u=Sl(t);return{contentType:"application/json",body:u,estimatedSize:new Blob([u]).size}}},t2=e=>{var t,n,i=()=>e.transport==="sendBeacon"?{url:vf(e.url,{compression:$n.Base64}),encodedBody:tm(he({},e,{compression:$n.Base64,Yi:void 0}))}:{url:e2(e.url,"compression"),encodedBody:tm(he({},e,{compression:void 0,Yi:void 0}))};try{t=tm(e)}catch(a){if(Kb(e.compression,Al(e.url,"compression")))return we.error("Failed to gzip request body, sending uncompressed payload",a),i();throw a}return t&&Kb(e.compression,Al(e.url,"compression"))&&!((n=t.body)instanceof ArrayBuffer?qm(new Uint8Array(n)):ArrayBuffer.isView(n)&&qm(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)))?(Md=!0,i()):{url:e.url,encodedBody:t}},n2=e=>{try{return t2(e)}catch(t){return we.error(t),void(e.callback==null||e.callback({statusCode:0,error:t}))}},g4=(function(){var e=Ut((function*(t){var n=Sl(t.data),i=yield(function(o,u,f){return Vm.apply(this,arguments)})(n,jt.DEBUG,{rethrow:!0});if(!i)return t;var a=yield i.arrayBuffer();return he({},t,{Yi:{contentType:Jw,body:a,estimatedSize:a.byteLength}})}));return function(t){return e.apply(this,arguments)}})(),x4=/Failed to fetch|NetworkError|Load failed/i,r2=e=>(e==null?void 0:e.name)==="TypeError"&&x4.test((e==null?void 0:e.message)||""),i2=e=>{var t=n2(e);if(t){var n=t.url,i=t.encodedBody,a=i??{},o=a.contentType,u=a.body,f=a.estimatedSize,h=new Headers;Rt(e.headers,(function(_,j){h.append(j,_)})),o&&h.append("Content-Type",o);var p=null,g=!1;if(Vb){var x=new Vb;p={signal:x.signal,timeout:setTimeout((()=>{var _,j;g=!0,x.abort((_=e.timeout,(j=new Error("PostHog request timed out"+(_?" after "+_+"ms":""))).name="AbortError",j))}),e.timeout)}}var b=_=>{g&&(_==null?void 0:_.name)==="AbortError"||r2(_)?we.warn(_):we.error(_),e.callback==null||e.callback({statusCode:0,error:_})};try{var y;Gg(n,he({method:(e==null?void 0:e.method)||"GET",headers:h,keepalive:e.method==="POST"&&!e.Xi&&52428.8>(f||0),body:u,signal:(y=p)==null?void 0:y.signal},e.fetchOptions)).then((_=>_.text().then((j=>{var C={statusCode:_.status,text:j};if(_.status===200)try{C.json=JSON.parse(j)}catch(k){we.error(k)}e.callback==null||e.callback(C)})))).catch(b).finally((()=>p?clearTimeout(p.timeout):null))}catch(_){p&&clearTimeout(p.timeout),b(_)}}},kg=e=>{try{var t,n=t2(e),i=n.url,a=n.encodedBody,o=a??{},u=o.body,f=o.estimatedSize;if(!u)return;var h=u instanceof Blob?u:new Blob([u],{type:o.contentType});if(In.sendBeacon(i,h))return;var p=Ve(e.data)?e.data:(t=e.data)==null?void 0:t.batch;if(Ve(p)&&p.length>1&&(f??0)>16384){var g=Math.ceil(p.length/2),x=b=>Ve(e.data)?b:he({},e.data,{batch:b});return kg(he({},e,{data:x(p.slice(0,g))})),void kg(he({},e,{data:x(p.slice(g))}))}we.warn("Beacon of ~"+(f??0)+" bytes was rejected by the browser, falling back to fetch"),i2(he({},e,{Xi:!0}))}catch(b){we.warn("Beacon send failed",b)}},Ry=(e,t,n,i)=>{var a=i==="query"?t==="POST"?"sent_at":"_":void 0;return vf(n===$n.GZipJS?e2(e,"compression"):e,he({},a?{[a]:Date.now().toString()}:{},n===$n.GZipJS?{}:{compression:n}))},Rd=[];Gg&&Rd.push({transport:"fetch",method:i2}),Hm&&Rd.push({transport:"XHR",method(e){var t=n2(e);if(t){var n=new Hm,i=t.encodedBody;n.open(e.method||"GET",t.url,!0);var a=i??{},o=a.contentType,u=a.body;Rt(e.headers,(function(f,h){n.setRequestHeader(h,f)})),o&&n.setRequestHeader("Content-Type",o),e.timeout&&(n.timeout=e.timeout),n.onreadystatechange=()=>{if(n.readyState===4){var f={statusCode:n.status,text:n.responseText};if(n.status===200)try{f.json=JSON.parse(n.responseText)}catch{}e.callback==null||e.callback(f)}},n.send(u)}}}),In!=null&&In.sendBeacon&&Rd.push({transport:"sendBeacon",method:kg});var jg=3e3;class v4{constructor(t,n){this.tr=!0,this.er=[],this.ir=ui((n==null?void 0:n.flush_interval_ms)||jg,250,5e3,we.createLogger("flush interval"),jg),this.rr=t}enqueue(t){this.er.push(t),this.nr||this.sr()}unload(){this.ar();var t=this.er.length>0?this.lr():{},n=Object.values(t);[...n.filter((i=>i.url.indexOf("/e")===0)),...n.filter((i=>i.url.indexOf("/e")!==0))].map((i=>{this.ur(he({},i,{transport:"sendBeacon"}))}))}enable(){this.tr=!1,this.sr()}sr(){var t=this;this.tr||(this.nr=setTimeout((()=>{if(this.ar(),this.er.length>0){var n=this.lr(),i=function(){var o=n[a],u=new Date().getTime();o.data&&Ve(o.data)&&Rt(o.data,(f=>{f.offset=Math.abs(f.timestamp-u),delete f.timestamp})),t.ur(o)};for(var a in n)i()}}),this.ir))}ur(t){try{this.rr(t)}catch(n){we.error(n)}}ar(){clearTimeout(this.nr),this.nr=void 0}lr(){var t={};return Rt(this.er,(n=>{var i,a=n,o=(a?a.batchKey:null)||a.url;ye(t[o])&&(t[o]=he({},a,{data:[]})),(i=t[o].data)==null||i.push(a.data)})),this.er=[],t}}var b4=["retriesPerformedSoFar"];class y4{constructor(t){this.hr=!1,this.dr=3e3,this.er=[],this._instance=t,this.er=[],this.vr=!0,!ye(ie)&&"onLine"in ie.navigator&&(this.vr=ie.navigator.onLine,this.cr=()=>{this.vr=!0,this.pr()},this.gr=()=>{this.vr=!1},Gt(ie,"online",this.cr),Gt(ie,"offline",this.gr))}get length(){return this.er.length}retriableRequest(t){var n=t.retriesPerformedSoFar,i=R5(t,b4);zi(n)&&(i.url=vf(i.url,{retry_count:n})),this._instance._send_request(he({},i,{callback:a=>{if(a.statusCode!==200&&(400>a.statusCode||a.statusCode>=500)){if((a.statusCode===0?3:10)>(n??0))return void this.At(he({retriesPerformedSoFar:n},i));a.statusCode===0&&we.warn("Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after "+(n??0)+" retries.")}i.callback==null||i.callback(a)}}))}At(t){var n=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=n+1;var i=(function(u){var f=3e3*Math.pow(2,u),h=f/2,p=Math.min(18e5,f),g=Math.random()-.5;return Math.ceil(p+g*(p-h))})(n),a=Date.now()+i;this.er.push({retryAt:a,requestOptions:t});var o="Enqueued failed request for retry in "+i;navigator.onLine||(o+=" (Browser is offline)"),we.warn(o),this.hr||(this.hr=!0,this.mr())}mr(){if(this.yr&&clearTimeout(this.yr),this.er.length===0)return this.hr=!1,void(this.yr=void 0);this.yr=setTimeout((()=>{this.vr&&this.er.length>0&&this.pr(),this.mr()}),this.dr)}pr(){var t=Date.now(),n=[],i=this.er.filter((o=>t>o.retryAt||(n.push(o),!1)));if(this.er=n,i.length>0)for(var a of i)this.retriableRequest(a.requestOptions)}unload(){for(var t of(this.yr&&(clearTimeout(this.yr),this.yr=void 0),this.hr=!1,ye(ie)||(this.cr&&(ie.removeEventListener("online",this.cr),this.cr=void 0),this.gr&&(ie.removeEventListener("offline",this.gr),this.gr=void 0)),this.er)){var n=t.requestOptions;try{this._instance._send_request(he({},n,{transport:"sendBeacon"}))}catch(i){we.error(i)}}this.er=[]}}class _4{constructor(t){this.br=()=>{var n,i,a,o;this._r||(this._r={});var u=this.scrollElement(),f=this.scrollY(),h=u?Math.max(0,u.scrollHeight-u.clientHeight):0,p=f+((u==null?void 0:u.clientHeight)||0),g=(u==null?void 0:u.scrollHeight)||0;this._r.lastScrollY=Math.ceil(f),this._r.maxScrollY=Math.max(f,(n=this._r.maxScrollY)!==null&&n!==void 0?n:0),this._r.maxScrollHeight=Math.max(h,(i=this._r.maxScrollHeight)!==null&&i!==void 0?i:0),this._r.lastContentY=p,this._r.maxContentY=Math.max(p,(a=this._r.maxContentY)!==null&&a!==void 0?a:0),this._r.maxContentHeight=Math.max(g,(o=this._r.maxContentHeight)!==null&&o!==void 0?o:0)},this._instance=t}get wr(){return this._instance.config.scroll_root_selector}getContext(){return this._r}resetContext(){var t=this._r;return setTimeout(this.br,0),t}startMeasuringScrollPosition(){Gt(ie,"scroll",this.br,{capture:!0}),Gt(ie,"scrollend",this.br,{capture:!0}),Gt(ie,"resize",this.br)}scrollElement(){if(!this.wr)return ie==null?void 0:ie.document.documentElement;var t=Ve(this.wr)?this.wr:[this.wr];for(var n of t){var i=ie==null?void 0:ie.document.querySelector(n);if(i)return i}}kr(t){var n=t==="y"?"scrollTop":"scrollLeft";if(this.wr){var i=this.scrollElement();return i&&i[n]||0}return ie?t==="y"?ie.scrollY||ie.pageYOffset||ie.document.documentElement.scrollTop||0:ie.scrollX||ie.pageXOffset||ie.document.documentElement.scrollLeft||0:0}scrollY(){return this.kr("y")}scrollX(){return this.kr("x")}}var w4=e=>qw(e==null?void 0:e.config.mask_personal_data_properties,e==null?void 0:e.config.custom_personal_data_properties,e==null?void 0:e.config.disable_capture_url_hashes);class Ly{constructor(t,n,i,a){this.Sr=o=>{var u=this.Cr();if(!u||u.sessionId!==o){var f={sessionId:o,props:this.Mr(this._instance)};this.Tr.register({[fg]:f})}},this._instance=t,this.Er=n,this.Tr=i,this.Mr=a||w4,this.Er.onSessionId(this.Sr)}Cr(){return this.Tr.props[fg]}getSetOnceProps(){var t,n=(t=this.Cr())==null?void 0:t.props;return n?"r"in n?Vw(n,this._instance.config.disable_capture_url_hashes):{$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 t={};return Rt(rx(this.getSetOnceProps()),((n,i)=>{i==="$current_url"&&(i="url"),t["$session_entry_"+Gm(i)]=n})),t}}class cx{on(t,n){return this.Ir[t]||(this.Ir[t]=[]),this.Ir[t].push(n),()=>{this.Ir[t]=this.Ir[t].filter((i=>i!==n))}}emit(t,n){for(var i of this.Ir[t]||[])i(n);for(var a of this.Ir["*"]||[])a(t,n)}constructor(){this.Ir={}}}var Ho=Wt("[SessionId]");class Dy{on(t,n){return this.Pr.on(t,n)}constructor(t,n,i){var a;if(this.Rr=null,this.Ar=[],this.Fr=void 0,this.Lr=!1,this.Pr=new cx,this.Or=(p,g)=>!(!zi(p)||!zi(g))&&Math.abs(p-g)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(t.config.cookieless_mode===$i)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Ne=t.config,this.Tr=t.persistence,this.Dr=void 0,this.$r=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.Nr=n||Pi,this.qr=i||Pi;var o=this.Ne.persistence_name||this.Ne.token;if(this._sessionTimeoutMs=1e3*ui(this.Ne.session_idle_timeout_seconds||1800,60,36e3,Ho.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.jr(),this.Br="ph_"+o+"_window_id",this.Hr="ph_"+o+"_primary_window_exists",this.Ur()){var u=Zt.H(this.Br),f=Zt.H(this.Hr);u&&!f?this.Dr=u:Zt.q(this.Br),Zt.F(this.Hr,!0)}if((a=this.Ne.bootstrap)!=null&&a.sessionID)try{var h=(p=>{var g=this.Ne.bootstrap.sessionID.replace(/-/g,"");if(g.length!==32)throw new Error("Not a valid UUID");if(g[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(g.substring(0,12),16)})();this.zr(this.Ne.bootstrap.sessionID,new Date().getTime(),h)}catch(p){Ho.error("Invalid sessionID in bootstrap",p)}this.Wr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return ye(this.Ar)&&(this.Ar=[]),this.Ar.push(t),this.$r&&t(this.$r,this.Dr),()=>{this.Ar=this.Ar.filter((n=>n!==t))}}Ur(){return this.Ne.persistence!=="memory"&&!this.Tr.xi&&Zt.N()}Vr(t){t!==this.Dr&&(this.Dr=t,this.Ur()&&Zt.F(this.Br,t))}Zr(){return this.Dr?this.Dr:this.Ur()?Zt.H(this.Br):null}Gr(t){var n=this.Rr;return!Hn(n)&&!Hn(t)&&5e3>Math.abs(t-n)}zr(t,n,i){var a=n!==this._sessionActivityTimestamp,o=!(t!==this.$r||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=n,this.$r=t,o&&!a||o&&this.Gr(n)||(this.Rr=n,this.Tr.register({[wl]:[n,t,i]}))}Qr(){var t,n=(t=this.Ne)==null?void 0:t.persistence_save_debounce_ms;return zi(n)&&n>0}Kr(){this.Qr()?this.Tr.refreshKey(wl):(this.Tr.flush(),this.Tr.load())}Jr(){var t;if(!Hn(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.Rr){this.Kr();var n=this.Yr();n[1]===this.$r&&n[2]===this._sessionStartTimestamp&&(this.Rr=this._sessionActivityTimestamp,this.Tr.register({[wl]:[this._sessionActivityTimestamp,(t=this.$r)!==null&&t!==void 0?t:null,this._sessionStartTimestamp]}),this.Tr.flush())}}Xr(){var t=this.Yr()[0],n=zi(t)?t:0,i=zi(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(n,i)}tn(t){return this.Kr(),this.Or(t,this.Xr())}Yr(){var t=this.Tr.props[wl];return Ve(t)&&t.length===2&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.Rr=null,clearTimeout(this.en),this.en=void 0,this.zr(null,null,null)}destroy(){this.Lr=!0,this.Jr(),clearTimeout(this.en),this.en=void 0,this.Fr&&ie&&(ie.removeEventListener(Zd,this.Fr,{capture:!1}),this.Fr=void 0),this.Ar=[]}Wr(){this.Fr=()=>{this.Jr(),this.Ur()&&Zt.q(this.Hr)},Gt(ie,Zd,this.Fr,{capture:!1})}checkAndGetSessionAndWindowId(t,n){if(t===void 0&&(t=!1),n===void 0&&(n=null),this.Ne.cookieless_mode===$i)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=n||new Date().getTime(),a=this.Yr(),o=a[1],u=a[2],f=this.Xr(),h=this.Zr(),p=zi(u)&&Math.abs(i-u)>864e5,g=!1,x=!1,b=!o,y=o,_=!b&&!t&&this.Or(i,f);if(_){(_=this.tn(i))||Ho.info("cross-tab refresh kept the session alive",{sessionId:o});var j=this.Yr();o=j[1],u=j[2]}b||_||p?(o=this.Nr(),h=this.qr(),Ho.info("new session ID generated",{sessionId:o,windowId:h,changeReason:{noSessionId:b,activityTimeout:_,sessionPastMaximumLength:p}}),u=i,g=!0):(h||(h=this.qr(),g=!0),(x=o!==y)&&(Ho.info("adopted cross-tab session id",{sessionId:o,windowId:h}),g=!0));var C=zi(f)&&t&&!p?f:i,k=zi(u)?u:new Date().getTime();this.Vr(h),this.zr(o,C,k),t||this.jr();var E={noSessionId:b,activityTimeout:_,sessionPastMaximumLength:p,crossTabAdoption:x};return g&&this.Ar.forEach((N=>N(o,h,E))),{sessionId:o,windowId:h,sessionStartTimestamp:k,changeReason:g?E:void 0,lastActivityTimestamp:f}}jr(){this.Lr||(clearTimeout(this.en),this.en=setTimeout((()=>{if(!this.Lr)if(this.tn(new Date().getTime())){var t=this.$r;this.resetSessionId(),this.Pr.emit("forcedIdleReset",{idleSessionId:t})}else this.jr()}),1.1*this.sessionTimeoutMs))}}var s2=function(e,t){if(!e)return!1;var n=e.userAgent;if(n&&Jb(n,t))return!0;try{var i=e==null?void 0:e.userAgentData;if(i!=null&&i.brands&&i.brands.some((a=>Jb(a==null?void 0:a.brand,t))))return!0}catch{}return!!e.webdriver};function a2(){return(a2=Ut((function*(){var e=In==null?void 0:In.userAgentData;if(e!=null&&e.getHighEntropyValues)try{var t=yield e.getHighEntropyValues(["model"]),n=t==null?void 0:t.model;return vt(n)&&n.length>0?n:void 0}catch(i){return void we.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",i)}}))).apply(this,arguments)}var af=function(e,t){if(!(function(n){try{new RegExp(n)}catch{return!1}return!0})(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}};function nm(e,t,n){return Sl({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}var l2={exact:(e,t)=>t.some((n=>e.some((i=>n===i)))),is_not:(e,t)=>t.every((n=>e.every((i=>n!==i)))),regex:(e,t)=>t.some((n=>e.some((i=>af(n,i))))),not_regex:(e,t)=>t.every((n=>e.every((i=>!af(n,i))))),icontains:(e,t)=>t.map(fd).some((n=>e.map(fd).some((i=>n.includes(i))))),not_icontains:(e,t)=>t.map(fd).every((n=>e.map(fd).every((i=>!n.includes(i))))),gt:(e,t)=>t.some((n=>{var i=parseFloat(n);return!isNaN(i)&&e.some((a=>i>parseFloat(a)))})),lt:(e,t)=>t.some((n=>{var i=parseFloat(n);return!isNaN(i)&&e.some((a=>i<parseFloat(a)))}))},fd=e=>e.toLowerCase();function o2(e,t){return!e||Object.entries(e).every((n=>{var i=n[1],a=t==null?void 0:t[n[0]];if(ye(a)||Hn(a))return!1;var o=[String(a)],u=l2[i.operator];return!!u&&u(i.values,o)}))}var Ng="custom",zy="i.posthog.com",S4=/^\/static\//;class k4{constructor(t){this.rn={},this.instance=t}get apiHost(){var t=this.instance.config.api_host.trim().replace(/\/$/,"");return t==="https://app.posthog.com"?"https://us.i.posthog.com":t}get flagsApiHost(){var t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t,n=(t=this.instance.config.ui_host)==null?void 0:t.replace(/\/$/,"");return n||(n=this.apiHost.replace("."+zy,".posthog.com")),n==="https://app.posthog.com"?"https://us.posthog.com":n}get region(){return this.rn[this.apiHost]||(this.rn[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"us":/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"eu":Ng),this.rn[this.apiHost]}nn(t){if(S4.test(t)){var n=this.instance.config.asset_host;if(typeof n=="string")return n.trim().replace(/\/$/,"")||void 0}}endpointFor(t,n){if(n===void 0&&(n=""),n&&(n=n[0]==="/"?n:"/"+n),t==="ui")return this.uiHost+n;if(t==="flags")return this.flagsApiHost+n;if(t==="assets"){var i=this.nn(n);if(i)return""+i+n}if(this.region===Ng)return this.apiHost+n;var a=zy+n;switch(t){case"assets":return"https://"+this.region+"-assets."+a;case"api":return"https://"+this.region+"."+a}}}function c2(e){var t;return!((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null||!t.length)}var kt=Wt("[Surveys]"),u2="seenSurvey_",d2=e=>{try{var t=(n=>((i,a)=>""+u2+(function(o){return o.current_iteration&&o.current_iteration>0?o.id+"_"+o.current_iteration:o.id})(a))(0,n))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(n){kt.error("Failed to persist survey seen state",n)}},j4=[Kp.Popover,Kp.Widget,Kp.API],N4={ignoreConditions:!1,ignoreDelay:!1,displayType:yg.Popover},C4=Wt("[PostHog ExternalIntegrations]"),E4={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class T4{constructor(t){this._instance=t}ai(t,n){var i;(i=Oe.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,t,(a=>{if(a)return C4.error("failed to load script",a);n()}))}startIfEnabledOrStop(){var t=this,n=function(){var o,u,f,h=i[0],p=i[1];!p||(o=Oe.__PosthogExtensions__)!=null&&(o=o.integrations)!=null&&o[h]||t.ai(E4[h],(()=>{var g;(g=Oe.__PosthogExtensions__)==null||(g=g.integrations)==null||(g=g[h])==null||g.start(t._instance)})),!p&&(u=Oe.__PosthogExtensions__)!=null&&(u=u.integrations)!=null&&u[h]&&((f=Oe.__PosthogExtensions__)==null||(f=f.integrations)==null||(f=f[h])==null||f.stop())};for(var i of Object.entries((a=this._instance.config.integrations)!==null&&a!==void 0?a:{})){var a;n()}}}class A4{constructor(t,n){this.rt=t,this.sn=n,this.an=new Map,this.ln=!1}add(t){var n=this;return Ut((function*(){if(n.ln)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(n.an.has(t.name))throw new Error('Browser extension "'+t.name+'" is already registered');n.an.set(t.name,t);try{var i=t.setup(n.sn);i&&(yield i)}catch(o){var a=n.an.get(t.name)===t;a&&n.an.delete(t.name),n.rt.error('Failed to set up browser extension "'+t.name+'"',o),a&&n.un(t)}}))()}dispose(){if(!this.ln){this.ln=!0;var t=Array.from(this.an.values()).reverse();for(var n of(this.an.clear(),t))this.un(n)}}un(t){try{var n=t.dispose==null?void 0:t.dispose();n&&pr(n.then)&&n.then(void 0,(i=>{this.rt.error('Failed to dispose browser extension "'+t.name+'"',i)}))}catch(i){this.rt.error('Failed to dispose browser extension "'+t.name+'"',i)}}}class M4{constructor(t){this._instance=t}get(t){var n;return(n=this._instance.persistence)==null?void 0:n.get_property(t)}set(t,n){var i;(i=this._instance.persistence)==null||i.set_property(t,n)}remove(t){var n;(n=this._instance.persistence)==null||n.unregister(t)}}var Oy="extensionsRemoteConfig";class R4{constructor(t){this.ln=!1,this.instance=t,this.rt=we.createLogger("[BrowserExtensions]"),this.hn=t.dn,this.kv=new M4(t),this.onEvent=n=>dd(this.instance.on("eventCaptured",(i=>{try{n({event:i.event,properties:i.properties})}catch(a){this.rt.error("Browser extension event listener failed",a)}}))),this.onRemoteConfig=n=>{if(this.ln)return dd((()=>{}));var i=o=>{try{n(o)}catch(u){this.rt.error("Browser extension remote config listener failed",u)}},a=this.instance.vn.on(Oy,i);return this.hn&&i(this.hn),dd(a)},this.cn=new A4(this.rt,this)}get logger(){return this.rt}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return(t=this.instance.get_property(wc))!==null&&t!==void 0?t:this.distinctId}get groups(){return this.instance.getGroups()}get session(){try{var t,n,i,a,o=(t=this.instance.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0);return{sessionId:(n=o==null?void 0:o.sessionId)!==null&&n!==void 0?n:"",windowId:(i=o==null?void 0:o.windowId)!==null&&i!==void 0?i:"",sessionStartTimestamp:(a=o==null?void 0:o.sessionStartTimestamp)!==null&&a!==void 0?a:0}}catch{return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get projectToken(){return this.instance.config.token}add(t){return this.cn.add(t)}capture(t,n,i){var a=this;return Ut((function*(){i?a.instance.capture(t,n,{timestamp:i.timestamp,uuid:i.uuid,$set:i.set,$set_once:i.setOnce}):a.instance.capture(t,n)}))()}registerDynamicEventProperties(t){return dd(this.instance.fn(t))}handleRemoteConfig(t){this.ln||(this.hn=t,this.instance.vn.emit(Oy,t))}sendRequest(t,n){var i=this;return Ut((function*(){var a;n===void 0&&(n={});var o=i.instance.requestRouter.endpointFor((a=n.target)!==null&&a!==void 0?a:"api",t),u={method:n.method,url:n.query?vf(o,n.query):o,data:n.body,headers:n.headers,timeout:n.timeoutMs,fireCallbackOnDrop:!0,transport:n.transport};return n.transport==="sendBeacon"?(i.instance._send_request(u),{statusCode:202}):new Promise((f=>{u.callback=f,i.instance._send_request(u)}))}))()}dispose(){this.ln||(this.ln=!0,this.cn.dispose())}}var fc={},rm=0,lf=()=>{},By='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',qo="Surveys module not available",Py="sanitize_properties is deprecated. Use before_send instead",f2="Invalid value for property_denylist config: ",L4=["token","distinct_id",bw],yl="posthog",h2=!m4&&(er==null?void 0:er.indexOf("MSIE"))===-1&&(er==null?void 0:er.indexOf("Mozilla"))===-1,im=e=>{var t;return he({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:D3(ke==null?void 0:ke.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:lf,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:e??"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:Vt&&vt(Vt==null?void 0:Vt.search)&&Vt.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,disableDeviceModel:!1,disable_external_dependency_loading:!1,strict_script_versioning:!1,enable_recording_console_log:void 0,secure_cookie:(ie==null||(t=ie.location)==null?void 0:t.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){we.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:gg,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:jg},error_tracking:{},_onCapture:lf},(n=>({rageclick:n&&n>="2026-05-30"?{content_ignorelist:G3,ignore_text_selection:!0}:!n||"2025-11-30">n||{content_ignorelist:!0},capture_pageview:!n||"2025-05-24">n||"history_change",session_recording:n&&n>="2026-06-25"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6},streamNetworkBody:!0}:n&&n>="2026-05-30"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6}}: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,persistence_save_debounce_ms:n&&n>="2026-05-30"?250:0,split_storage:!(!n||"2026-05-30">n),detect_google_search_app:!(!n||"2026-05-30">n),disable_capture_url_hashes:!(!n||"2026-06-25">n)}))(e))},D4=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["__preview_disable_beacon","disable_beacon"],["store_google","save_campaign_params"],["verbose","debug"]],$y=e=>{var t={};for(var n of D4){var i=n[0],a=n[1];ye(e[i])||(t[a]=e[i])}var o=Ot({},t,e),u=e.__preview_external_dependency_versioned_paths;return ye(u)||(ye(e.strict_script_versioning)&&(o.strict_script_versioning=!!u),vt(u)&&ye(e.asset_host)&&(o.asset_host=u)),Ve(e.property_blacklist)&&(ye(e.property_denylist)?o.property_denylist=e.property_blacklist:Ve(e.property_denylist)?o.property_denylist=[...e.property_blacklist,...e.property_denylist]:we.error(f2+e.property_denylist)),o};class z4{constructor(){this.__forceAllowLocalhost=!1}get pn(){return this.__forceAllowLocalhost}set pn(t){we.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}}class Or{gn(t,n){if(t){var i=this.an.indexOf(t);i!==-1&&this.an.splice(i,1)}return this.an.push(n),n.initialize==null||n.initialize(),n}mn(){return this.config.cookieless_mode===$i||this.config.cookieless_mode===pa&&this.consent.isRejected()}get decideEndpointWasHit(){var t,n;return(t=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&t!==void 0&&t}get flagsEndpointWasHit(){var t,n;return(t=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&t!==void 0&&t}constructor(){var t;this.webPerformance=new z4,this.yn=!1,this.version=jt.LIB_VERSION,this.bn=new Set,this._n="",this.vn=new cx,this.an=[],this.wn=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=im(),this.SentryIntegration=e4,this.sentryIntegration=i=>(function(a,o){var u=Bw(a,o);return{name:Ow,processEvent:f=>u(f)}})(this,i),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.kn=!1,this.xn=null,this.Sn=null,this.Cn=null,this.scrollManager=new _4(this),this.pageViewManager=new ky(this),this.rateLimiter=new c4(this),this.requestRouter=new k4(this),this.consent=new U3(this),this.externalIntegrations=new T4(this);var n=(t=Or.__defaultExtensionClasses)!==null&&t!==void 0?t:{};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.metrics=n.metrics&&new n.metrics(this),this.experiments=n.experiments&&new n.experiments(this),this.exceptions=n.exceptions&&new n.exceptions(this),this.people={set:(i,a,o)=>{var u=vt(i)?{[i]:a}:i;this.setPersonProperties(u),o==null||o({})},set_once:(i,a,o)=>{var u=vt(i)?{[i]:a}:i;this.setPersonProperties(void 0,u),o==null||o({})}},this.on("eventCaptured",(i=>we.info('send "'+(i==null?void 0:i.event)+'"',i)))}init(t,n,i){if(i&&i!==yl){var a,o=(a=fc[i])!==null&&a!==void 0?a:new Or;return o._init(t,n,i),fc[i]=o,fc[yl][i]=o,o}return this._init(t,n,i)}_init(t,n,i){var a,o;n===void 0&&(n={});var u,f=vt(t)?t.trim():"";if(!f)return we.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 f!==((u=this.config)==null?void 0:u.token)?console.warn("[PostHog.js]","You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('"+f+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=im(n.defaults),n.debug=this.Mn(n.debug),this.Tn=n,this.En=[],n.person_profiles?this.Sn=n.person_profiles:n.process_person&&(this.Sn=n.process_person);var h=im(n.defaults),p=$y(n),g=Ot({},h,p,{name:i,token:f});Bt(h.rageclick)&&Bt(p.rageclick)&&(g.rageclick=Ot({},h.rageclick,p.rageclick)),Bt(h.session_recording)&&Bt(p.session_recording)&&(g.session_recording=Ot({},h.session_recording,p.session_recording)),this.set_config(g),this.config.on_xhr_error&&we.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:$n.GZipJS;var x=this.In();if(this.persistence=new Xp(this.config,x),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Xp(he({},this.config,{persistence:"sessionStorage"}),x,!1),this._n="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!x&&Zt.N()){var b=Zt.H(this._n);Ve(b)&&b.forEach((L=>{vt(L)&&this.bn.add(L)}))}else Zt.q(this._n);var y=he({},this.persistence.props),_=he({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Pn=new v4((L=>this.Rn(L)),this.config.request_queue_config),this.An=new y4(this),this.__request_queue=[];var j=this.mn();if(j||(this.sessionManager=new Dy(this),this.sessionPropsManager=new Ly(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId(((L,G,P)=>{(P!=null&&P.activityTimeout||P!=null&&P.sessionPastMaximumLength||P!=null&&P.crossTabAdoption)&&this.Fn()}))),this.config.__preview_deferred_init_extensions?(we.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.Ln(j)}),0)):(we.info("Initializing extensions synchronously"),this.Ln(j)),jt.DEBUG=jt.DEBUG||this.config.debug,jt.DEBUG&&we.info("Starting in debug mode",{this:this,config:n,thisC:he({},this.config),p:y,s:_}),!this.config.identity_distinct_id||(a=n.bootstrap)!=null&&a.distinctID||(n.bootstrap=he({},n.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),((o=n.bootstrap)==null?void 0:o.distinctID)!==void 0){var C=n.bootstrap.distinctID,k=this.get_distinct_id(),E=this.persistence.get_property(zr);if(n.bootstrap.isIdentifiedID&&k!=null&&k!==C&&E===fl)this.identify(C);else if(n.bootstrap.isIdentifiedID&&k!=null&&k!==C&&E===ia)we.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 N=this.config.get_device_id(Pi()),D=n.bootstrap.isIdentifiedID?N:C;this.persistence.set_property(zr,n.bootstrap.isIdentifiedID?ia:fl),this.register({distinct_id:C,$device_id:D})}}if(j)this.register_once({distinct_id:ad,$device_id:null},"");else if(!this.get_distinct_id()){var O=this.config.get_device_id(Pi());this.register_once({distinct_id:O,$device_id:O},""),this.persistence.set_property(zr,fl)}return Gt(ie,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),n.segment?(function(L,G){var P=L.config.segment;if(!P)return G();(function(Q,B){var I=Q.config.segment;if(!I)return B();var M=J=>{var Y=()=>J.anonymousId()||Pi();Q.config.get_device_id=Y,J.id()&&(Q.register({distinct_id:J.id(),$device_id:Y()}),Q.persistence.set_property(zr,ia)),B()},le=I.user();"then"in le&&pr(le.then)?le.then(M):M(le)})(L,(()=>{P.register((Q=>{typeof Promise<"u"&&Promise.resolve||Wp.warn("This browser does not have Promise support, and can not use the segment integration");var B=(I,M)=>{if(!M)return I;I.event.userId||I.event.anonymousId===Q.get_distinct_id()||(Wp.info("No userId set, resetting PostHog"),Q.reset()),I.event.userId&&I.event.userId!==Q.get_distinct_id()&&(Wp.info("UserId set, identifying with PostHog"),Q.identify(I.event.userId));var le=Q.calculateEventProperties(M,I.event.properties);return I.event.properties=Object.assign({},le,I.event.properties),I};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:I=>B(I,I.event.event),page:I=>B(I,bl),identify:I=>B(I,Vp),screen:I=>B(I,"$screen")}})(L)).then((()=>{G()}))}))})(this,(()=>this.On())):this.On(),pr(this.config._onCapture)&&this.config._onCapture!==lf&&(we.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(L=>this.config._onCapture(L.event,L)))),this.config.ip&&we.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this.config.disableDeviceModel||(function(){return a2.apply(this,arguments)})().then((L=>{L&&this.register({[Hp]:L})})).catch(lf),this}Ln(t){var n,i,a,o,u,f,h,p,g=performance.now(),x=he({},Or.__defaultExtensionClasses,this.config.__extensionClasses),b=[];x.featureFlags&&this.an.push(this.featureFlags=(n=this.featureFlags)!==null&&n!==void 0?n:new x.featureFlags(this)),x.exceptions&&this.an.push(this.exceptions=(i=this.exceptions)!==null&&i!==void 0?i:new x.exceptions(this)),x.historyAutocapture&&this.an.push(this.historyAutocapture=new x.historyAutocapture(this)),x.tracingHeaders&&this.an.push(this.tracingHeaders=new x.tracingHeaders(this)),x.siteApps&&this.an.push(this.siteApps=new x.siteApps(this)),x.sessionRecording&&!t&&this.an.push(this.sessionRecording=new x.sessionRecording(this)),this.config.disable_scroll_properties||b.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),x.autocapture&&this.an.push(this.autocapture=new x.autocapture(this)),x.surveys&&this.an.push(this.surveys=(a=this.surveys)!==null&&a!==void 0?a:new x.surveys(this)),x.logs&&this.an.push(this.logs=(o=this.logs)!==null&&o!==void 0?o:new x.logs(this)),x.metrics&&this.an.push(this.metrics=(u=this.metrics)!==null&&u!==void 0?u:new x.metrics(this)),x.conversations&&this.an.push(this.conversations=(f=this.conversations)!==null&&f!==void 0?f:new x.conversations(this)),x.productTours&&this.an.push(this.productTours=new x.productTours(this)),x.heatmaps&&this.an.push(this.heatmaps=new x.heatmaps(this)),x.webVitalsAutocapture&&this.an.push(this.webVitalsAutocapture=new x.webVitalsAutocapture(this)),x.exceptionObserver&&this.an.push(this.exceptionObserver=new x.exceptionObserver(this)),x.deadClicksAutocapture&&this.an.push(this.deadClicksAutocapture=new x.deadClicksAutocapture(this,J3)),x.toolbar&&this.an.push(this.toolbar=(h=this.toolbar)!==null&&h!==void 0?h:new x.toolbar(this)),x.experiments&&this.an.push(this.experiments=(p=this.experiments)!==null&&p!==void 0?p:new x.experiments(this)),this.an.forEach((y=>{y.initialize&&b.push((()=>{y.initialize==null||y.initialize()}))})),b.push((()=>{if(this.Dn){var y=this.Dn;this.Dn=void 0,this.an.forEach((_=>_.onRemoteConfig==null?void 0:_.onRemoteConfig(y)))}})),this.$n(b,g)}$n(t,n){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-n>=30&&t.length>0)return void setTimeout((()=>{this.$n(t,n)}),0);var i=t.shift();if(i)try{i()}catch(o){we.error("Error initializing extension:",o)}}var a=Math.round(performance.now()-n);this.register_for_session({[yw]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[_w]:a}),this.config.__preview_deferred_init_extensions&&we.info("PostHog extensions initialized ("+a+"ms)")}Gi(t){var n;if(!ke||!ke.body)return we.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Gi(t)}),500);if(this.config.__preview_deferred_init_extensions&&(this.Dn=t),this.dn=t,this.compression=void 0,t.ok){var i,a=t.config;a.supportedCompression&&!this.config.disable_compression&&(this.compression=qe(a.supportedCompression,$n.GZipJS)?$n.GZipJS:qe(a.supportedCompression,$n.Base64)?$n.Base64:void 0),(i=a.analytics)!=null&&i.endpoint&&(this.analyticsDefaultEndpoint=a.analytics.endpoint)}this.set_config({person_profiles:this.Sn?this.Sn:gg}),(n=this.Nn)==null||n.handleRemoteConfig(t),this.an.forEach((o=>o.onRemoteConfig==null?void 0:o.onRemoteConfig(t)))}On(){try{this.config.loaded(this)}catch(i){we.critical("`loaded` function failed",i)}if(this.qn(),this.config.internal_or_test_user_hostname&&Vt!=null&&Vt.hostname){var t=Vt.hostname,n=this.config.internal_or_test_user_hostname;(typeof n=="string"?t===n:n.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.mn())&&this.jn()}),1),this.Bn=new Yw(this),this.Bn.load()}qn(){var t;this.is_capturing()&&this.config.request_batching&&((t=this.Pn)==null||t.enable())}_dom_loaded(){this.is_capturing()&&ld(this.__request_queue,(t=>this.Rn(t))),this.__request_queue=[],this.qn()}_handle_unload(){var t,n,i,a,o;(t=this.surveys)==null||t.handlePageUnload==null||t.handlePageUnload(),(n=this.metrics)==null||n.flush("sendBeacon"),this.config.request_batching?(this.Hn()&&this.capture(qp),(i=this.logs)==null||i.flushLogs("sendBeacon"),(a=this.Pn)==null||a.unload(),(o=this.An)==null||o.unload()):this.Hn()&&this.capture(qp,null,{transport:"sendBeacon"})}_send_request(t){this.__loaded?h2?this.__request_queue.push(t):this.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(t.callback==null||t.callback({statusCode:429})):(t.transport=t.transport||this.config.api_transport,t.headers=he({},this.config.request_headers,t.headers),t.compression=t.compression==="best-available"?this.compression:t.compression,(ye(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||this.config.fetch_options,(n=>{var i,a,o,u=he({},n);u.timeout=u.timeout||6e4;var f,h,p,g,x,b=(i=u.transport)!==null&&i!==void 0?i:"fetch";b==="sendBeacon"&&ye(u.compression)&&u.data&&(u.compression=$n.Base64),u.method==="POST"&&u.data&&(u.timestampMode==="capture-body"?u.data={api_key:(h=(x=(g=Ve(f=u.data)?f:[f])[0])==null||(p=x.properties)==null?void 0:p.token)!==null&&h!==void 0?h:x==null?void 0:x.token,batch:g,sent_at:new Date().toISOString()}:u.timestampMode==="body"&&(u.data=(function(C,k){return k===void 0&&(k=new Date().toISOString()),Ve(C)?C.map((E=>he({},E,{sent_at:k}))):he({},C,{sent_at:k})})(u.data))),u.url=Ry(u.url,u.method,u.compression,u.timestampMode);var y=Rd.filter((C=>!u.disableTransport||!C.transport||!u.disableTransport.includes(C.transport))),_=(a=(o=(function(C,k){for(var E=0;C.length>E;E++)if(C[E].transport===b)return C[E]})(y))==null?void 0:o.method)!==null&&a!==void 0?a:y[0].method;if(!_)throw new Error("No available transport method");var j=C=>{try{_(C)}catch(k){r2(k)?we.warn(k):we.error(k),u.callback==null||u.callback({statusCode:0,error:k})}};b!=="sendBeacon"&&u.data&&u.compression===$n.GZipJS&&OC&&typeof Promise<"u"&&!Md?g4(u).then((C=>{j(C)})).catch((C=>{if(Zb(C))return Md=!0,void j(he({},u,{compression:void 0,url:Ry(n.url,n.method,void 0,n.timestampMode)}));(k=>{if(!k||typeof k!="object")return!1;var E="name"in k?String(k.name):"";return Zb(k)||E===L5})(C)&&(Md=!0),j(u)})):_(u)})(he({},t,{callback:n=>{var i,a;this.rateLimiter.checkForLimiting(n),400>n.statusCode||(i=(a=this.config).on_request_error)==null||i.call(a,n),t.callback==null||t.callback(n)}}))):t.fireCallbackOnDrop&&(t.callback==null||t.callback({statusCode:0}))}Rn(t){this.An?this.An.retriableRequest(t):this._send_request(t)}_execute_array(t){rm++;try{var n,i=[],a=[],o=[];ld(t,(f=>{if(f)if(Ve(n=f[0]))o.push(f);else if(pr(f))try{f.call(this)}catch(h){we.error("Error executing queued PostHog call",f,h)}else Ve(f)&&n==="alias"?i.push(f):Ve(f)&&n.indexOf("capture")!==-1&&pr(this[n])?o.push(f):a.push(f)}));var u=function(f,h){ld(f,(function(p){try{if(Ve(p[0])){var g=h;Rt(p,(function(x){g=g[x[0]].apply(g,x.slice(1))}))}else h[p[0]].apply(h,p.slice(1))}catch(x){we.error("Error executing queued PostHog call",p,x)}}))};u(i,this),u(a,this),u(o,this)}finally{rm--}}push(t){if(rm>0&&Ve(t)&&vt(t[0])){var n=Or.prototype[t[0]];pr(n)&&n.apply(this,t.slice(1))}else this._execute_array([t])}capture(t,n,i){var a,o,u,f,h,p,g;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Pn){if(this.is_capturing())if(!ye(t)&&vt(t)){var x=!this.config.opt_out_useragent_filter&&this._is_bot();if(!x||this.config.__preview_capture_bot_pageviews){var b=i!=null&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(b==null||!b.isRateLimited){if(this.wn.length>0){var y={};for(var _ of this.wn.slice())try{Ot(y,_())}catch(R){we.error("Failed to produce browser extension event properties",R)}n=he({},y,n??{})}var j;(a=n)!=null&&a.$current_url&&!vt((o=n)==null?void 0:o.$current_url)&&(we.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),(j=n)==null||delete j.$current_url),t!=="$exception"||i!=null&&i.Un||we.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 C=new Date,k=(i==null?void 0:i.timestamp)||C,E=ry(i==null?void 0:i.uuid,Pi),N={uuid:E,event:t,properties:this.calculateEventProperties(t,n||{},k,E)};t===bl&&this.config.__preview_capture_bot_pageviews&&x&&(N.event="$bot_pageview",N.properties.$browser_type="bot"),b&&(N.properties.$lib_rate_limit_remaining_tokens=b.remainingTokens);var D=t==="$feature_flag_called"&&N.properties.$feature_flag_has_experiment===!1&&this.get_property(Yd)===!0;i!=null&&i.$set&&!D&&(N.$set=i==null?void 0:i.$set);var O=i==null?void 0:i.$unset;O&&(N.$unset=O);var L,G,P,Q=D?void 0:this.zn(i==null?void 0:i.$set_once,t!==cy,t===Vp);if(Q&&(N.$set_once=Q),i!=null&&i._noTruncate||(f=this.config.properties_string_max_length,h=N,p=R=>vt(R)?R.slice(0,f):R,g=new Set,N=(function R(z,Z){if(z!==Object(z))return p?p(z):z;if(!g.has(z)){var A;if(g.add(z),Ve(z))A=[],ld(z,(xe=>{A.push(R(xe))}));else{var ue={};Rt(z,((xe,je)=>{g.has(xe)||(ue[je]=R(xe))})),A=ue}return A}})(h)),N.timestamp=k,ye(i==null?void 0:i.timestamp)||(N.properties.$event_time_override_provided=!0,N.properties.$event_time_override_system_time=C),D&&(N.properties=(function(R,z){z===void 0&&(z=[]);var Z={},A=ue=>{R[ue]!==void 0&&(Z[ue]=R[ue])};return BC.forEach(A),z.forEach(A),Z})(N.properties,L4)),t===Ui.DISMISSED||t===Ui.SENT){var B,I,M=(B=n)==null?void 0:B[Zp.SURVEY_ID],le=(I=n)==null?void 0:I[Zp.SURVEY_ITERATION];d2({id:M,current_iteration:le}),N.$set=he({},N.$set,{[(L={id:M,current_iteration:le},G=t===Ui.SENT?"responded":"dismissed",P="$survey_"+G+"/"+L.id,L.current_iteration&&L.current_iteration>0&&(P="$survey_"+G+"/"+L.id+"/"+L.current_iteration),P)]:!0})}else t===Ui.SHOWN&&(N.$set=he({},N.$set,{[Zp.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(t===o4.SHOWN){var J,Y=(J=n)==null?void 0:J[Ny.TOUR_TYPE];Y&&(N.$set=he({},N.$set,{[Ny.TOUR_LAST_SEEN_DATE+"/"+Y]:new Date().toISOString()}))}var $=he({},N.properties.$set,N.$set);if(Ii($)||this.setPersonPropertiesForFlags($),!Ye(this.config.before_send)){var F=this.Pt(N);if(!F)return;(N=F).uuid=ry(N.uuid,Pi)}this.vn.emit("eventCaptured",N);var V=(u=i==null?void 0:i._url)!==null&&u!==void 0?u:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),ge={method:"POST",url:V,data:N,compression:"best-available",timestampMode:(i==null?void 0:i._batchKey)==="recordings"||/\/s\/(?:\?|$)/.test(V)?"body":"capture-body",batchKey:i==null?void 0:i._batchKey,transport:i==null?void 0:i.transport};return!this.config.request_batching||i&&(i==null||!i._batchKey)||i!=null&&i.send_instantly?this.Rn(ge):this.Pn.enqueue(ge),N}we.critical("This capture call is ignored due to client rate limiting.")}}else we.error("No event name provided to posthog.capture")}else we.uninitializedWarning("posthog.capture")}_addCaptureHook(t){return this.on("eventCaptured",(n=>t(n.event,n)))}Wn(){var t;return(t=this.Nn)!==null&&t!==void 0?t:this.Nn=new R4(this)}fn(t){this.wn.push(t);var n=!0;return()=>{if(n){n=!1;var i=this.wn.indexOf(t);i!==-1&&this.wn.splice(i,1)}}}calculateEventProperties(t,n,i,a,o){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return n;var u=o?void 0:this.persistence.remove_event_timer(t),f=he({},n);if(f.token=this.config.token,f.$config_defaults=this.config.defaults,this.mn()&&(f[bw]=!0),t==="$snapshot"){var h=he({},this.persistence.properties(),this.sessionPersistence.properties());return f.distinct_id=h.distinct_id,(!vt(f.distinct_id)&&!sn(f.distinct_id)||Ym(f.distinct_id))&&we.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),f}var p,g=(function(N,D,O,L){var G,P,Q,B;if(L===void 0&&(L=!1),!er)return{};var I,M=N?[...Ml,...D||[]]:[],le=(function(Jt){for(var pt=0;ty.length>pt;pt++){var _t=ty[pt],Nt=_t[1],ve=_t[0].exec(Jt),Fe=ve&&(pr(Nt)?Nt(ve,Jt):Nt);if(Fe)return Fe}return["",""]})(er),J=le[0],Y=le[1],$=(I=typeof navigator<"u"?navigator:void 0)!=null&&I.brave?{brave:!0}:{},F={};ye(O)||(F.detectGoogleSearchApp=O);var V={},ge=(G=navigator)==null||(G=G.userAgentData)==null?void 0:G.platform,R=(P=navigator)==null?void 0:P.maxTouchPoints,z=ie==null||(Q=ie.screen)==null?void 0:Q.width,Z=ie==null||(B=ie.screen)==null?void 0:B.height,A=ie==null?void 0:ie.devicePixelRatio;ye(ge)||(V.userAgentDataPlatform=ge),ye(R)||(V.maxTouchPoints=R),ye(z)||(V.screenWidth=z),ye(Z)||(V.screenHeight=Z),ye(A)||(V.devicePixelRatio=A);var ue,xe,je,Re,Le,Be,Je,it,ht=Ot(rx({$os:J,$os_version:Y,$browser:iw(er,navigator.vendor,$,F),$device:ny(er),$device_type:(xe=er,je=V,it=ny(xe),it===F5||it===$5||it==="Kobo"||it==="Kindle Fire"||it===J5?Cl:it===yc||it===jl||it===_c||it===Qm?"Console":it===I5?"Wearable":it?gr:(je==null?void 0:je.userAgentDataPlatform)==="Android"&&((Re=je==null?void 0:je.maxTouchPoints)!==null&&Re!==void 0?Re:0)>0?600>Math.min((Le=je==null?void 0:je.screenWidth)!==null&&Le!==void 0?Le:0,(Be=je==null?void 0:je.screenHeight)!==null&&Be!==void 0?Be:0)/((Je=je==null?void 0:je.devicePixelRatio)!==null&&Je!==void 0?Je:1)?gr:Cl:"Desktop"),$timezone:Gw(),$timezone_offset:s4()}),{$current_url:jc(L?Ts(Vt==null?void 0:Vt.href):Vt==null?void 0:Vt.href,M,Nc),$host:Vt==null?void 0:Vt.host,$pathname:Vt==null?void 0:Vt.pathname,$raw_user_agent:er.length>1e3?er.substring(0,997)+"...":er,$browser_version:n3(er,navigator.vendor,$,F),$browser_language:jy(),$browser_language_prefix:(ue=jy(),typeof ue=="string"?ue.split("-")[0]:void 0),$screen_height:ie==null?void 0:ie.screen.height,$screen_width:ie==null?void 0:ie.screen.width,$viewport_height:ie==null?void 0:ie.innerHeight,$viewport_width:ie==null?void 0:ie.innerWidth,$lib:jt.LIB_NAME,$lib_version:jt.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return jt.SDK_DIST_CHANNEL&&(ht.$sdk_dist_channel=jt.SDK_DIST_CHANNEL),ht})(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){var x=this.sessionManager.checkAndGetSessionAndWindowId(o,i.getTime()),b=x.windowId;f.$session_id=x.sessionId,f.$window_id=b}this.sessionPropsManager&&Ot(f,this.sessionPropsManager.getSessionProps());try{var y;this.sessionRecording&&Ot(f,this.sessionRecording.sdkDebugProperties),f.$sdk_debug_retry_queue_size=(y=this.An)==null?void 0:y.length}catch(N){f.$sdk_debug_error_capturing_properties=String(N)}if(this.requestRouter.region===Ng&&(f.$lib_custom_api_host=this.config.api_host),p=t!==bl||o?t!==qp||o?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,a),f=Ot(f,p),t===bl&&ke&&(f.title=ke.title),!ye(u)){var _=i.getTime()-u;f.$duration=parseFloat((_/1e3).toFixed(3))}er&&this.config.opt_out_useragent_filter&&(f.$browser_type=this._is_bot()?"bot":"browser");var j=this.persistence.properties(),C=this.sessionPersistence.properties();Rt(["$referrer","$referring_domain"],(N=>{N in j&&delete C[N]})),(f=Ot({},g,j,C,f)).$is_identified=this._isIdentified(),Ve(this.config.property_denylist)?Rt(this.config.property_denylist,(function(N){delete f[N]})):we.error(f2+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var k=this.config.sanitize_properties;k&&(we.error(Py),f=k(f,t));var E=this.Vn();return f.$process_person_profile=E,E&&!o&&this.Zn("_calculate_event_properties"),f}zn(t,n,i){var a;if(n===void 0&&(n=!0),i===void 0&&(i=!1),!this.persistence||!this.Vn()||this.yn&&!i)return t;var o=this.persistence.get_initial_props(),u=(a=this.sessionPropsManager)==null?void 0:a.getSetOnceProps(),f=Ot({},o,u||{},t||{}),h=this.config.sanitize_properties;return h&&(we.error(Py),f=h(f,"$set_once")),n&&(this.yn=!0),Ii(f)?void 0:f}register(t,n){var i;(i=this.persistence)==null||i.register(t,n)}register_once(t,n,i){var a;(a=this.persistence)==null||a.register_once(t,n,i)}register_for_session(t){var n;(n=this.sessionPersistence)==null||n.register(t),Object.keys(t).forEach((i=>this.bn.add(i))),this.Gn()}unregister(t){var n;(n=this.persistence)==null||n.unregister(t)}unregister_for_session(t){var n;(n=this.sessionPersistence)==null||n.unregister(t),this.bn.delete(t),this.Gn()}Qn(t,n){this.register({[t]:n})}Fn(){this.bn.forEach((t=>{var n;(n=this.sessionPersistence)==null||n.unregister(t)})),this.bn.clear(),this.Gn()}Gn(){var t;if(this._n)if(this.config.persistence==="memory"||(t=this.sessionPersistence)!=null&&t.xi||!Zt.N())Zt.q(this._n);else{var n=[];this.bn.forEach((i=>n.push(i))),n.length>0?Zt.F(this._n,n):Zt.q(this._n)}}getFeatureFlag(t,n){var i;return(i=this.featureFlags)==null?void 0:i.getFeatureFlag(t,n)}getFeatureFlagPayload(t){var n;return(n=this.featureFlags)==null?void 0:n.getFeatureFlagPayload(t)}getFeatureFlagResult(t,n){var i;return(i=this.featureFlags)==null?void 0:i.getFeatureFlagResult(t,n)}getAllFeatureFlags(){var t,n;return(t=(n=this.featureFlags)==null?void 0:n.getAllFeatureFlags())!==null&&t!==void 0?t:[]}isFeatureEnabled(t,n){var i,a;return(i=(a=this.featureFlags)==null?void 0:a.isFeatureEnabled(t,n))!==null&&i!==void 0?i:n==null?void 0:n.defaultValue}reloadFeatureFlags(){var t;(t=this.featureFlags)==null||t.reloadFeatureFlags()}updateFlags(t,n,i){var a;(a=this.featureFlags)==null||a.updateFlags(t,n,i)}updateEarlyAccessFeatureEnrollment(t,n,i){var a;(a=this.featureFlags)==null||a.updateEarlyAccessFeatureEnrollment(t,n,i)}getEarlyAccessFeatures(t,n,i){var a;return n===void 0&&(n=!1),(a=this.featureFlags)==null?void 0:a.getEarlyAccessFeatures(t,n,i)}on(t,n){return this.vn.on(t,n)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:qo}),()=>{})}onSessionId(t){var n,i;return(n=(i=this.sessionManager)==null?void 0:i.onSessionId(t))!==null&&n!==void 0?n:()=>{}}getSurveys(t,n){n===void 0&&(n=!1),this.surveys?this.surveys.getSurveys(t,n):t([],{isLoaded:!1,error:qo})}getActiveMatchingSurveys(t,n){n===void 0&&(n=!1),this.surveys?this.surveys.getActiveMatchingSurveys(t,n):t([],{isLoaded:!1,error:qo})}renderSurvey(t,n){var i;(i=this.surveys)==null||i.renderSurvey(t,n)}displaySurvey(t,n){var i;n===void 0&&(n=N4),(i=this.surveys)==null||i.displaySurvey(t,n)}cancelPendingSurvey(t){var n;(n=this.surveys)==null||n.cancelPendingSurvey(t)}canRenderSurvey(t){var n,i;return(n=(i=this.surveys)==null?void 0:i.canRenderSurvey(t))!==null&&n!==void 0?n:{visible:!1,disabledReason:qo}}canRenderSurveyAsync(t,n){var i,a;return n===void 0&&(n=!1),(i=(a=this.surveys)==null?void 0:a.canRenderSurveyAsync(t,n))!==null&&i!==void 0?i:Promise.resolve({visible:!1,disabledReason:qo})}Kn(t){return!t||Ym(t)?(we.critical("Unique user id has not been set in posthog.identify"),!1):t===ad?(we.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(we.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(t,n,i){if(!this.__loaded||!this.persistence)return we.uninitializedWarning("posthog.identify");if(sn(t)&&(t=t.toString(),we.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.Kn(t)&&this.Zn("posthog.identify")){var a=this.get_distinct_id();this.register({$user_id:t}),this.get_property(wc)||this.register_once({$had_persisted_distinct_id:!0,$device_id:a},""),t!==a&&t!==this.get_property(ec)&&(this.unregister(ec),this.register({distinct_id:t}));var o,u=(this.persistence.get_property(zr)||fl)===fl,f=t!==a,h=!f&&u;if(f&&u)this.persistence.set_property(zr,ia),this.setPersonPropertiesForFlags({$set:n||{},$set_once:i||{}},!1),this.capture(Vp,{distinct_id:t,$anon_distinct_id:a},{$set:n||{},$set_once:i||{}}),this.Cn=nm(t,n,i),(o=this.featureFlags)==null||o.setAnonymousDistinctId(a);else if(h){this.persistence.set_property(zr,ia);var p=n||{},g=i||{};this.setPersonPropertiesForFlags({$set:p,$set_once:g},!1),this.capture("$set",{$set:p,$set_once:g}),this.Cn=nm(t,n,i)}else(n||i)&&this.setPersonProperties(n,i);f?(this.reloadFeatureFlags(),this.unregister(cc)):h&&(n||i)&&this.reloadFeatureFlags()}}setPersonProperties(t,n){if((t||n)&&this.Zn("posthog.setPersonProperties")){var i=nm(this.get_distinct_id(),t,n);this.Cn!==i?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:n||{}},!0),this.capture("$set",{$set:t||{},$set_once:n||{}}),this.Cn=i):we.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(t){var n,i=(Ve(t)?t:[t]).filter((a=>vt(a)&&a.length>0));i.length!==0&&this.Zn("posthog.unsetPersonProperties")&&((n=this.featureFlags)==null||n.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this.Cn=null)}group(t,n,i){if(t&&n){var a=this.getGroups(),o=a[t]!==n;if(o&&this.resetGroupPropertiesForFlags(t),this.register({$groups:he({},a,{[t]:n})}),o||i){var u={$group_type:t,$group_key:n};i&&(u.$group_set=i),this.capture(cy,u)}i&&this.setGroupPropertiesForFlags({[t]:i}),o&&!i&&this.reloadFeatureFlags()}else we.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,n){var i;n===void 0&&(n=!0),(i=this.featureFlags)==null||i.setPersonPropertiesForFlags(t,n)}resetPersonPropertiesForFlags(t){var n;t===void 0&&(t=!0),(n=this.featureFlags)==null||n.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,n){var i;n===void 0&&(n=!0),this.Zn("posthog.setGroupPropertiesForFlags")&&((i=this.featureFlags)==null||i.setGroupPropertiesForFlags(t,n))}resetGroupPropertiesForFlags(t){var n;(n=this.featureFlags)==null||n.resetGroupPropertiesForFlags(t)}reset(t){this.Jn(t)}Jn(t,n){var i,a,o,u,f,h,p,g,x,b;if(n===void 0&&(n=!1),we.info("reset"),!this.__loaded)return we.uninitializedWarning("posthog.reset");var y,_=this.get_property(wc),j=this.get_property(Hp),C=this.get_property(xa),k=this.is_capturing();if(this.consent.reset(),n||!k||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after."),(i=this.persistence)==null||i.clear(),(a=this.sessionPersistence)==null||a.clear(),this.bn.clear(),this.Gn(),ye(C)||(y=this.persistence)==null||y.register({[xa]:C}),(o=this.surveys)==null||o.reset(),(u=this.Bn)==null||u.stop(),(f=this.featureFlags)==null||f.reset(),(h=this.conversations)==null||h.reset(),(p=this.logs)==null||p.reset(),(g=this.metrics)==null||g.reset(),(x=this.persistence)==null||x.set_property(zr,fl),(b=this.sessionManager)==null||b.resetSessionId(),this.Cn=null,this.config.cookieless_mode===$i)this.register_once({distinct_id:ad,$device_id:null},"");else{var E=this.config.get_device_id(Pi());this.register_once({distinct_id:E,$device_id:t?E:_},""),t||ye(j)||this.register({[Hp]:j})}this.register({$last_posthog_reset:new Date().toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}shutdown(t){var n=this;return Ut((function*(){var i,a,o,u,f,h,p,g;n.__loaded?((i=n.Bn)==null||i.stop(),(a=n.Nn)==null||a.dispose(),(o=n.sessionRecording)==null||o.dispose(),(u=n.logs)==null||u.flushLogs("sendBeacon"),(f=n.metrics)==null||f.flush("sendBeacon"),(h=n.Pn)==null||h.unload(),(p=n.An)==null||p.unload(),(g=n.featureFlags)==null||g.destroy()):we.uninitializedWarning("posthog.shutdown")}))()}setIdentity(t,n){var i;this.config.identity_distinct_id=t,this.config.identity_hash=n,this.alias(t),(i=this.conversations)==null||i.Yn()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,(t=this.conversations)==null||t.Xn()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,n;return(t=(n=this.sessionManager)==null?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&t!==void 0?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";var n=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=n.sessionStartTimestamp,a=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+n.sessionId);if(t!=null&&t.withTimestamp&&i){var o,u=(o=t.timestampLookBack)!==null&&o!==void 0?o:10;if(!i)return a;a+="?t="+Math.max(Math.floor((new Date().getTime()-i)/1e3)-u,0)}return a}alias(t,n){return t===this.get_property(hw)?(we.critical("Attempting to create alias for existing People user - aborting."),-2):this.Zn("posthog.alias")?(ye(n)&&(n=this.get_distinct_id()),t!==n?(this.Qn(ec,t),this.capture("$create_alias",{alias:t,distinct_id:n})):(we.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){var n=he({},this.config);if(Bt(t)){var i,a,o,u,f,h,p,g,x,b,y;Ot(this.config,$y(t));var _=this.In();(i=this.persistence)==null||i.update_config(this.config,n,_),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Xp(he({},this.config,{persistence:"sessionStorage"}),_,!1);var j=this.Mn(this.config.debug);Wr(j)&&(this.config.debug=j),Wr(this.config.debug)&&(this.config.debug?(jt.DEBUG=!0,zt.N()&&zt.F("ph_debug",!0),we.info("set_config",{config:t,oldConfig:n,newConfig:he({},this.config)})):(jt.DEBUG=!1,zt.N()&&zt.q("ph_debug"))),(a=this.exceptionObserver)==null||a.onConfigChange(),(o=this.exceptions)==null||o.onConfigChange(),(u=this.sessionRecording)==null||u.startIfEnabledOrStop(),(f=this.tracingHeaders)==null||f.startIfEnabledOrStop(),(h=this.autocapture)==null||h.startIfEnabled(),(p=this.heatmaps)==null||p.startIfEnabled(),(g=this.exceptionObserver)==null||g.startIfEnabledOrStop(),(x=this.deadClicksAutocapture)==null||x.startIfEnabledOrStop(),(b=this.surveys)==null||b.loadIfEnabled(),this.ts(),(y=this.externalIntegrations)==null||y.startIfEnabledOrStop()}}_overrideSDKInfo(t,n){jt.LIB_NAME=t,jt.LIB_VERSION=n}startSessionRecording(t){var n,i,a,o,u,f=t===!0,h={sampling:f||!(t==null||!t.sampling),linked_flag:f||!(t==null||!t.linked_flag),url_trigger:f||!(t==null||!t.url_trigger),event_trigger:f||!(t==null||!t.event_trigger)};Object.values(h).some(Boolean)&&((n=this.sessionManager)==null||n.checkAndGetSessionAndWindowId(),h.sampling&&((i=this.sessionRecording)==null||i.overrideSampling()),h.linked_flag&&((a=this.sessionRecording)==null||a.overrideLinkedFlag()),h.url_trigger&&((o=this.sessionRecording)==null||o.overrideTrigger("url")),h.event_trigger&&((u=this.sessionRecording)==null||u.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var t;return!((t=this.sessionRecording)==null||!t.started)}captureException(t,n){if(this.exceptions){var i=new Error("PostHog syntheticException"),a=this.exceptions.buildProperties(t,{handled:!0,syntheticException:i});return this.exceptions.sendExceptionEvent(he({},a,n))}}addExceptionStep(t,n){var i;(i=this.exceptions)==null||i.addExceptionStep(t,n)}captureLog(t){var n;(n=this.logs)==null||n.captureLog(t)}get logger(){var t,n;return(t=(n=this.logs)==null?void 0:n.logger)!==null&&t!==void 0?t:Or.es}startExceptionAutocapture(t){this.set_config({capture_exceptions:t==null||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var n,i;return(n=(i=this.toolbar)==null?void 0:i.loadToolbar(t))!==null&&n!==void 0&&n}get_property(t){var n;return(n=this.persistence)==null?void 0:n.props[t]}getSessionProperty(t){var n;return(n=this.sessionPersistence)==null?void 0:n.props[t]}toString(){var t,n=(t=this.config.name)!==null&&t!==void 0?t:yl;return n!==yl&&(n=yl+"."+n),n}_isIdentified(){var t,n;return((t=this.persistence)==null?void 0:t.get_property(zr))===ia||((n=this.sessionPersistence)==null?void 0:n.get_property(zr))===ia}Vn(){var t,n;return!(this.config.person_profiles==="never"||this.config.person_profiles===gg&&!this._isIdentified()&&Ii(this.getGroups())&&((t=this.persistence)==null||(t=t.props)==null||!t[ec])&&((n=this.persistence)==null||(n=n.props)==null||!n[Xd]))}Hn(){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.Vn()||this.Zn("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Zn("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Zn(t){return this.config.person_profiles==="never"?(we.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Qn(Xd,!0),!0)}In(){if(this.config.cookieless_mode==="always")return!0;var t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==pa)}ts(){var t,n,i,a,o=this.In();return((t=this.persistence)==null?void 0:t.xi)!==o&&((i=this.persistence)==null||i.set_disabled(o)),((n=this.sessionPersistence)==null?void 0:n.xi)!==o&&((a=this.sessionPersistence)==null||a.set_disabled(o)),o&&(this.bn.clear(),this.Gn()),o}opt_in_capturing(t){var n;if(this.config.cookieless_mode!==$i){if(this.mn()){var i,a,o,u,f;this.Jn(!0,!0),(i=this.sessionManager)==null||i.destroy(),(a=this.pageViewManager)==null||a.destroy(),this.sessionManager=new Dy(this),this.pageViewManager=new ky(this),this.persistence&&(this.sessionPropsManager=new Ly(this,this.sessionManager,this.persistence));var h,p=(o=(u=this.config.__extensionClasses)==null?void 0:u.sessionRecording)!==null&&o!==void 0?o:(f=Or.__defaultExtensionClasses)==null?void 0:f.sessionRecording;p&&(this.sessionRecording=this.gn(this.sessionRecording,new p(this)),this.dn&&((h=this.sessionRecording)==null||h.onRemoteConfig==null||h.onRemoteConfig(this.dn)))}var g,x;this.consent.optInOut(!0),this.ts(),this.qn(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==pa&&((g=this.surveys)==null||g.loadIfEnabled()),(ye(t==null?void 0:t.captureEventName)||t!=null&&t.captureEventName)&&this.capture((x=t==null?void 0:t.captureEventName)!==null&&x!==void 0?x:"$opt_in",t==null?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.jn()}else we.warn(By)}opt_out_capturing(){var t,n,i;this.config.cookieless_mode!==$i?(this.config.cookieless_mode===pa&&this.consent.isOptedIn()&&this.Jn(!0,!0),this.consent.optInOut(!1),this.ts(),this.config.cookieless_mode===pa&&(this.register({distinct_id:ad,$device_id:null}),(t=this.sessionRecording)==null||t.stopRecording(),this.sessionRecording=void 0,(n=this.sessionManager)==null||n.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.jn(),this.qn())):we.warn(By)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var t=this.consent.consent;return t===1?"granted":t===0?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===$i||(this.config.cookieless_mode===pa?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.ts()}_is_bot(){return In?s2(In,this.config.custom_blocked_useragents):void 0}jn(){ke&&(ke.visibilityState==="visible"?this.kn||(this.kn=!0,this.capture(bl,{title:ke.title},{send_instantly:!0}),this.xn&&(ke.removeEventListener(Kd,this.xn),this.xn=null)):this.xn||(this.xn=this.jn.bind(this),Gt(ke,Kd,this.xn)))}debug(t){t===!1?(ie==null||ie.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(ie==null||ie.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}))}Ki(){var t=this.Tn||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(we.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(function(n,i,a,o,u){var f=i in n&&!Ye(n[i]),h=a in n&&!Ye(n[a]);return f?n[i]:!!h&&(u&&u.warn("Config field '"+a+"' is deprecated. Please use '"+i+"' instead. The old field will be removed in a future major version."),n[a])})(t,"advanced_disable_flags","advanced_disable_decide",0,we)}Pt(t){var n;if(Ye(this.config.before_send))return t;var i=Object.keys((n=t.properties)!==null&&n!==void 0?n:{}).filter(qC),a=Ve(this.config.before_send)?this.config.before_send:[this.config.before_send],o=t;for(var u of a){if(o=u(o),Ye(o)){var f="Event '"+t.event+"' was rejected in beforeSend function";return HC(t.event)?we.warn(f+". This can cause unexpected behavior."):we.info(f),null}o.properties&&!Ii(o.properties)||we.warn("Event '"+t.event+"' has no properties after beforeSend function, this is likely an error.")}for(var h of i)if(o.properties&&Ye(o.properties[h]))return we.warn("Event '"+t.event+"' had its '"+h+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return o}getPageViewId(){var t;return(t=this.pageViewManager.ui)==null?void 0:t.pageViewId}captureTraceFeedback(t,n){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:n})}captureTraceMetric(t,n,i){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:n,$ai_metric_value:String(i)})}Mn(t){var n=Wr(t)&&!t,i=zt.N()&&zt.P("ph_debug")==="true";return!n&&(!!i||t)}}Or.__defaultExtensionClasses={},Or.es=(()=>{var e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),(function(e,t){for(var n=0;t.length>n;n++)e.prototype[t[n]]=R3(e.prototype[t[n]])})(Or,["identify"]);class Fy{constructor(t){this.disabled=t===!1;var n=Bt(t)?t:{};this.thresholdPx=n.threshold_px||30,this.timeoutMs=n.timeout_ms||1e3,this.clickCount=n.click_count||3,this.clicks=[]}isRageClick(t,n,i){if(this.disabled)return!1;var a=this.clicks[this.clicks.length-1];if(a&&Math.abs(t-a.x)+Math.abs(n-a.y)<this.thresholdPx&&this.timeoutMs>i-a.timestamp){if(this.clicks.push({x:t,y:n,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:n,timestamp:i}];return!1}}var sm="$copy_autocapture",am=Wt("[AutoCapture]");function lm(e,t){return t.length>e?t.slice(0,e)+"...":t}function O4(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!As(t));return t}function B4(e,t){var n,i,a=t.e,o=t.maskAllElementAttributes,u=t.maskAllText,f=t.elementAttributeIgnoreList,h=t.elementsChainAsString,p=t.disableCaptureUrlHashes;if(!As(e))return{props:{}};for(var g=[e],x=new Set([e]),b=e;b.parentNode&&!mr(b,"body")&&Tw>g.length;)if(Ew(b.parentNode)){var y=b.parentNode.host;if(x.has(y))break;x.add(y),g.push(y),b=y}else{if(!As(b.parentNode)||x.has(b.parentNode))break;x.add(b.parentNode),g.push(b.parentNode),b=b.parentNode}var _,j,C=[],k={},E=!1,N=!1;if(Rt(g,(P=>{var Q=bg(P);if(mr(P,"a")){var B=P.getAttribute("href");E=!!(Q&&B&&uc(B))&&(p?Ts(B):B)}qe(ef(P),"ph-no-capture")&&(N=!0),C.push((function(M,le,J,Y,$){$===void 0&&($=!1);var F=M.tagName.toLowerCase(),V={tag_name:F};sx.indexOf(F)>-1&&!J&&(V.$el_text=F.toLowerCase()==="a"||F.toLowerCase()==="button"?lm(1024,_y(M)):lm(1024,kc(M)));var ge=ef(M);ge.length>0&&(V.classes=ge.filter((function(A){return A!==""}))),Rt(M.attributes,(function(A){var ue;if((!Dw(M)||["name","id","class","aria-label"].indexOf(A.name)!==-1)&&(Y==null||!Y.includes(A.name))&&!le&&uc(A.value)&&(!vt(ue=A.name)||ue.substring(0,10)!=="_ngcontent"&&ue.substring(0,7)!=="_nghost")){var xe=A.value;A.name==="class"&&(xe=ix(xe).join(" ")),V["attr__"+A.name]=lm(1024,A.name==="href"&&$?Ts(xe):xe)}}));for(var R=1,z=1,Z=M;Z=O4(Z);)R++,Z.tagName===M.tagName&&z++;return V.nth_child=R,V.nth_of_type=z,V})(P,o,u,f,p));var I=(function(M){if(!bg(M))return{};var le={};return Rt(M.attributes,(function(J){if(J.name&&J.name.indexOf("data-ph-capture-attribute")===0){var Y=J.name.replace("data-ph-capture-attribute-",""),$=J.value;Y&&$&&uc($)&&(le[Y]=$)}})),le})(P);Ot(k,I)})),N)return{props:{},explicitNoCapture:N};if(u||(C[0].$el_text=mr(e,"a")||mr(e,"button")?_y(e):kc(e)),E){var D,O;C[0].attr__href=E;var L=(D=tf(E))==null?void 0:D.host,G=ie==null||(O=ie.location)==null?void 0:O.host;L&&G&&L!==G&&(_=E)}return{props:Ot({$event_type:a.type,$ce_version:1},h?{}:{$elements:C},{$elements_chain:(j=C,(function(P){return P.map((Q=>{var B,I,M="";if(Q.tag_name&&(M+=Q.tag_name),Q.attr_class)for(var le of(Q.attr_class.sort(),Q.attr_class))M+="."+le.replace(/"/g,"");var J=he({},Q.text?{text:Q.text}:{},{"nth-child":(B=Q.nth_child)!==null&&B!==void 0?B:0,"nth-of-type":(I=Q.nth_of_type)!==null&&I!==void 0?I:0},Q.href?{href:Q.href}:{},Q.attr_id?{attr_id:Q.attr_id}:{},Q.attributes),Y={};return Ad(J).sort((($,F)=>$[0].localeCompare(F[0]))).forEach(($=>{var F=$[1];return Y[wy($[0].toString())]=wy(F.toString())})),(M+=":")+Ad(Y).map(($=>$[0]+'="'+$[1]+'"')).join("")})).join(";")})((function(P){return P.map((Q=>{var B,I,M={text:(B=Q.$el_text)==null?void 0:B.slice(0,400),tag_name:Q.tag_name,href:(I=Q.attr__href)==null?void 0:I.slice(0,2048),attr_class:K3(Q),attr_id:Q.attr__id,nth_child:Q.nth_child,nth_of_type:Q.nth_of_type,attributes:{}};return Ad(Q).filter((le=>le[0].indexOf("attr__")===0)).forEach((le=>M.attributes[le[0]]=le[1])),M}))})(j)))},(n=C[0])!=null&&n.$el_text?{$el_text:(i=C[0])==null?void 0:i.$el_text}:{},_&&a.type==="click"?{$external_click_url:_}:{},k)}}var Vo=Wt("[ExceptionAutocapture]"),Uy=()=>{},P4=Wt("[TracingHeaders]"),la=Wt("[Web Vitals]"),Iy=9e5,Hy="disabled",qy="lazy_loading",Go="awaiting_config",hd="missing_config";Wt("[SessionRecording]"),Wt("[SessionRecording]");var Cg="[SessionRecording]",Ri=Wt(Cg),$4=Wt("[Heatmaps]");function om(e){return Bt(e)&&"clientX"in e&&"clientY"in e&&sn(e.clientX)&&sn(e.clientY)}var pd=Wt("[Product Tours]"),cm=e=>{var t;return!e.config.disable_product_tours&&!((t=e.persistence)==null||!t.get_property(ex))},F4=["$set_once","$set"],ai=Wt("[SiteApps]"),Vy="Error while initializing PostHog app with config id ";function ml(e,t,n){if(Ye(e))return!1;switch(n){case"exact":return e===t;case"contains":var i=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(e);case"regex":try{return new RegExp(t).test(e)}catch{return!1}default:return!1}}class U4{constructor(t){this.rs=new cx,this.ns=(n,i)=>this.ss(n,i)&&this.os(n,i)&&this.ls(n,i)&&this.us(n,i),this.ss=(n,i)=>i==null||!i.event||(n==null?void 0:n.event)===(i==null?void 0:i.event),this._instance=t,this.hs=new Set,this.ds=new Set}init(){var t,n;ye((t=this._instance)==null?void 0:t._addCaptureHook)||(n=this._instance)==null||n._addCaptureHook(((i,a)=>{this.on(i,a)}))}register(t){var n,i;if(!ye((n=this._instance)==null?void 0:n._addCaptureHook)&&(t.forEach((u=>{var f,h;(f=this.ds)==null||f.add(u),(h=u.steps)==null||h.forEach((p=>{var g;(g=this.hs)==null||g.add((p==null?void 0:p.event)||"")}))})),(i=this._instance)!=null&&i.autocapture)){var a,o=new Set;t.forEach((u=>{var f;(f=u.steps)==null||f.forEach((h=>{h!=null&&h.selector&&o.add(h==null?void 0:h.selector)}))})),(a=this._instance)==null||a.autocapture.setElementSelectors(o)}}on(t,n){var i;n!=null&&t.length!=0&&(this.hs.has(t)||this.hs.has(n.event))&&this.ds&&((i=this.ds)==null?void 0:i.size)>0&&this.ds.forEach((a=>{this.vs(n,a)&&this.rs.emit("actionCaptured",a.name)}))}cs(t){this.onAction("actionCaptured",(n=>t(n)))}vs(t,n){if((n==null?void 0:n.steps)==null)return!1;for(var i of n.steps)if(this.ns(t,i))return!0;return!1}onAction(t,n){return this.rs.on(t,n)}os(t,n){if(n!=null&&n.url){var i,a=t==null||(i=t.properties)==null?void 0:i.$current_url;if(!a||typeof a!="string"||!ml(a,n.url,n.url_matching||"contains"))return!1}return!0}ls(t,n){return!!this.fs(t,n)&&!!this.ps(t,n)&&!!this.gs(t,n)}fs(t,n){var i;if(n==null||!n.href)return!0;var a=this.ys(t);if(a.length>0)return a.some((f=>ml(f.href,n.href,n.href_matching||"exact")));var o,u=(t==null||(i=t.properties)==null?void 0:i.$elements_chain)||"";return!!u&&ml((o=u.match(/(?::|")href="(.*?)"/))?o[1]:"",n.href,n.href_matching||"exact")}ps(t,n){var i;if(n==null||!n.text)return!0;var a=this.ys(t);if(a.length>0)return a.some((p=>ml(p.text,n.text,n.text_matching||"exact")||ml(p.$el_text,n.text,n.text_matching||"exact")));var o,u,f,h=(t==null||(i=t.properties)==null?void 0:i.$elements_chain)||"";return!!h&&(o=(function(p){for(var g,x=[],b=/(?::|")text="(.*?)"/g;!Ye(g=b.exec(p));)x.includes(g[1])||x.push(g[1]);return x})(h),u=n.text,f=n.text_matching||"exact",o.some((p=>ml(p,u,f))))}gs(t,n){var i,a;if(n==null||!n.selector)return!0;var o=t==null||(i=t.properties)==null?void 0:i.$element_selectors;if(o!=null&&o.includes(n.selector))return!0;var u=(t==null||(a=t.properties)==null?void 0:a.$elements_chain)||"";if(n.selector_regex&&u)try{return new RegExp(n.selector_regex).test(u)}catch{return!1}return!1}ys(t){var n;return(t==null||(n=t.properties)==null?void 0:n.$elements)==null?[]:t==null?void 0:t.properties.$elements}us(t,n){return n==null||!n.properties||n.properties.length===0||o2(n.properties.reduce(((i,a)=>{var o=Ve(a.value)?a.value.map(String):a.value!=null?[String(a.value)]:[];return i[a.key]={values:o,operator:a.operator||"exact"},i}),{}),t==null?void 0:t.properties)}}class I4{constructor(t){var n;this.bs=[],this._instance=t,this._s=new Map,this.ws=new Map,this.ks=new Map,(n=this._instance)==null||n.onSessionId==null||n.onSessionId((i=>this.xs(i)))}Ss(t){return!1}Cs(){return null}Ms(t){}Ts(){}Es(t,n){return!!t&&o2(t.propertyFilters,n==null?void 0:n.properties)}Is(t,n){var i=new Map;return t.forEach((a=>{var o;(o=a.conditions)==null||(o=o[n])==null||(o=o.values)==null||o.forEach((u=>{if(u!=null&&u.name){var f=i.get(u.name)||[];f.push(a.id),i.set(u.name,f)}}))})),i}Ps(t,n,i){var a=(i===Fo.Activation?this._s:this.ws).get(t),o=[];return this.Rs((u=>{o=u.filter((f=>a==null?void 0:a.includes(f.id)))})),o.filter((u=>{var f,h=(f=u.conditions)==null||(f=f[i])==null||(f=f.values)==null?void 0:f.find((p=>p.name===t));return this.Es(h,n)}))}register(t){var n;ye((n=this._instance)==null?void 0:n._addCaptureHook)||(this.As(t),this.Fs(t))}Fs(t){var n=t.filter((i=>{var a,o;return((a=i.conditions)==null?void 0:a.actions)&&((o=i.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0}));n.length!==0&&(this.Ls==null&&(this.Ls=new U4(this._instance),this.Ls.init(),this.Ls.cs((i=>{this.onAction(i)}))),n.forEach((i=>{var a,o,u,f,h;i.conditions&&(a=i.conditions)!=null&&a.actions&&(o=i.conditions)!=null&&(o=o.actions)!=null&&o.values&&((u=i.conditions)==null||(u=u.actions)==null||(u=u.values)==null?void 0:u.length)>0&&((f=this.Ls)==null||f.register(i.conditions.actions.values),(h=i.conditions)==null||(h=h.actions)==null||(h=h.values)==null||h.forEach((p=>{if(p&&p.name){var g=this.ks.get(p.name);g&&g.push(i.id),this.ks.set(p.name,g||[i.id])}})))})))}As(t){var n,i=t.filter((o=>{var u,f;return((u=o.conditions)==null?void 0:u.events)&&((f=o.conditions)==null||(f=f.events)==null||(f=f.values)==null?void 0:f.length)>0})),a=t.filter((o=>{var u,f;return((u=o.conditions)==null?void 0:u.cancelEvents)&&((f=o.conditions)==null||(f=f.cancelEvents)==null||(f=f.values)==null?void 0:f.length)>0}));i.length===0&&a.length===0||((n=this._instance)==null||n._addCaptureHook(((o,u)=>{this.onEvent(o,u)})),this._s=this.Is(t,Fo.Activation),this.ws=this.Is(t,Fo.Cancellation))}onEvent(t,n){var i,a,o=this.Os(),u=(n==null||(i=n.properties)==null?void 0:i.$survey_id)||(n==null||(a=n.properties)==null?void 0:a.$product_tour_id);if(u&&this.getActivatedIds().includes(u)){var f=this.Ds(t,u);if(f==="consume")return o.info("event consumed activated item, removing it",{event:t,itemId:u}),void this.$s([u]);if(f==="persist")return o.info("shown item promoted to persisted activation",{event:t,itemId:u}),this.Ns(u),void this.qs([u])}if(this.ws.has(t)){var h=this.Ps(t,n,Fo.Cancellation);h.length>0&&(o.info("cancel event matched, cancelling items",{event:t,itemsToCancel:h.map((g=>g.id))}),this.$s(h.map((g=>g.id))),h.forEach((g=>this.js(g.id))))}if(this._s.has(t)){o.info("event name matched",{event:t,eventPayload:n,items:this._s.get(t)});var p=this.Ps(t,n,Fo.Activation);this.Bs(p.map((g=>g.id)))}}onAction(t){this.ks.has(t)&&this.Bs(this.ks.get(t)||[])}Bs(t){var n;if(t.length!==0){var i=!((n=this._instance)==null||n.get_session_id==null||!n.get_session_id()),a=[];for(var o of t)i&&this.Ss(o)?this.Ns(o)&&this.Hs(o):a.push(o);a.length>0&&(this.bs=[...new Set([...this.bs,...a])]),this.Os().info("updating activated items",{activatedItems:this.getActivatedIds()})}}Ns(t){this.bs=this.bs.filter((i=>i!==t));var n=this.Us();return!n.includes(t)&&(this.zs([...n,t]),this.Ws(),!0)}$s(t){var n=new Set(t);this.bs=this.bs.filter((o=>!n.has(o)));var i=this.Vs(),a=i.filter((o=>!n.has(o)));a.length!==i.length&&(this.zs(a),a.length===0&&this.Zs()),this.qs(t)}Gs(){var t,n=this.Cs();if(!n)return{};var i=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[n];return i&&typeof i=="object"?i:{}}Hs(t){if(this.Cs()){var n=this.Gs();this.Ms(he({},n,{[t]:Date.now()}))}}qs(t){if(this.Cs()){var n=this.Gs(),i={},a=!1;for(var o of Object.entries(n)){var u=o[0],f=o[1];t.includes(u)?a=!0:i[u]=f}a&&(Ii(i)?this.Ts():this.Ms(i))}}Qs(){this.Cs()&&this.Ts()}getActivationTimestamp(t){if(this.Us().includes(t)){var n=this.Gs()[t];return sn(n)?n:void 0}}Vs(){var t,n=this.Ks();return((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[n])||[]}Us(){var t,n,i=this.Vs();if(i.length===0)return[];var a=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[this.Js()],o=(n=this._instance)==null||n.get_session_id==null?void 0:n.get_session_id();return o&&a===o?i:[]}Ws(){var t,n=(t=this._instance)==null||t.get_session_id==null?void 0:t.get_session_id();n&&this.Ys(n)}Zs(){this.Xs()}xs(t){var n,i=(n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[this.Js()];if(i&&i!==t){var a=this.Vs(),o=this.Gs();a.length>0&&(this.zs([]),a.filter((u=>sn(o[u]))).forEach((u=>this.js(u)))),this.Zs(),this.Qs()}}getActivatedIds(){return[...new Set([...this.Us(),...this.bs])].filter((t=>!this.ta(t)))}reset(){this.bs=[],this.Vs().length>0&&this.zs([]),this.Zs(),this.Qs()}getEventToItemsMap(){return this._s}ea(){return this.Ls}}class H4 extends I4{constructor(t){super(t)}Ks(){return cg}Js(){return Ed}Cs(){return Td}Ms(t){var n;(n=this._instance)==null||(n=n.persistence)==null||n.register({[Td]:t})}Ts(){var t;(t=this._instance)==null||(t=t.persistence)==null||t.unregister(Td)}Ss(t){var n,i;this.Rs((o=>{i=o.find((u=>u.id===t))}));var a=(n=i)==null||(n=n.appearance)==null?void 0:n.surveyPopupDelaySeconds;return sn(a)&&a>0}ia(){return Ui.SHOWN}Rs(t){var n;(n=this._instance)==null||n.getSurveys(t)}js(t){var n;(n=this._instance)==null||n.cancelPendingSurvey(t)}Os(){return kt}zs(t){var n;(n=this._instance)==null||(n=n.persistence)==null||n.register({[cg]:t})}Ys(t){var n;(n=this._instance)==null||(n=n.persistence)==null||n.register({[Ed]:t})}Xs(){var t;(t=this._instance)==null||(t=t.persistence)==null||t.unregister(Ed)}ta(){return!1}Ds(t,n){var i;this.Rs((o=>{i=o.find((u=>u.id===n))}));var a=!i||(function(o){var u;return c2(o)&&!((u=o.conditions)==null||(u=u.events)==null||!u.repeatedActivation)||o.schedule==="always"})(i);return a?t===Ui.SHOWN?"consume":"ignore":t===Ui.SHOWN?"persist":t===Ui.DISMISSED||t===Ui.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var md="SDK is not enabled or survey functionality is not yet loaded",Gy="Disabled. Not loading surveys.",q4=ie!=null&&ie.location?nf(ie.location.hash,"__posthog")||nf(location.hash,"state"):null,Yy="_postHogToolbarParams",Wy=Wt("[Toolbar]"),pn=Wt("[FeatureFlags]"),oa=Wt("[FeatureFlags]",{debugEnabled:!0}),um=`" failed. Feature flags didn't load in time.`,Qy=e=>{for(var t={},n=0;e.length>n;n++)t[e[n]]=!0;return t},Xy=e=>{var t={};for(var n of Ad(e||{})){var i=n[1];i&&(t[n[0]]=i)}return t},li=Wt("[Error tracking]"),Ky="Refusing to render web experiment since the viewer is a likely bot",V4={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>af(t,e),not_regex:(e,t)=>!af(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e};class Mn{get Ne(){return this._instance.config}constructor(t){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(i){i===void 0&&(i=!1),n.getWebExperiments((a=>{Mn.ra("retrieved web experiments from the server"),n.na=new Map,a.forEach((o=>{if(o.feature_flag_key){var u;n.na&&(Mn.ra("setting flag key ",o.feature_flag_key," to web experiment ",o),(u=n.na)==null||u.set(o.feature_flag_key,o));var f=n._instance.getFeatureFlag(o.feature_flag_key);vt(f)&&o.variants[f]&&n.sa(o.name,f,o.variants[f].transforms)}else if(o.variants)for(var h in o.variants){var p=o.variants[h];Mn.aa(p,n._instance)&&n.sa(o.name,h,p.transforms)}}))}),i)},this._instance=t,this._instance.onFeatureFlags((i=>{this.onFeatureFlags(i)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())Mn.ra(Ky);else if(!this.Ne.disable_web_experiments){if(Ye(this.na))return this.na=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Mn.ra("applying feature flags",t),t.forEach((n=>{var i;if(this.na&&(i=this.na)!=null&&i.has(n)){var a,o=this._instance.getFeatureFlag(n),u=(a=this.na)==null?void 0:a.get(n);o&&u!=null&&u.variants[o]&&this.sa(u.name,o,u.variants[o].transforms)}}))}}previewWebExperiment(){var t=Mn.getWindowLocation();if(t!=null&&t.search){var n=Al(t==null?void 0:t.search,"__experiment_id"),i=Al(t==null?void 0:t.search,"__experiment_variant");n&&i&&(Mn.ra("previewing web experiments "+n+" && "+i),this.getWebExperiments((a=>{this.oa(parseInt(n),i,a)}),!1,!0))}}loadIfEnabled(){this.Ne.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,n,i){if(this.Ne.disable_web_experiments&&!i)return t([]);var a=this._instance.get_property("$web_experiments");if(a&&!n)return t(a);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Ne.token),method:"GET",timestampMode:"query",callback:o=>t(o.statusCode===200&&o.json&&o.json.experiments||[])})}oa(t,n,i){var a=i.filter((o=>o.id===t));a&&a.length>0&&(Mn.ra("Previewing web experiment ["+a[0].name+"] with variant ["+n+"]"),this.sa(a[0].name,n,a[0].variants[n].transforms))}static aa(t,n){return!Ye(t.conditions)&&Mn.la(t,n)&&Mn.ua(t)}static la(t,n){var i;if(Ye(t.conditions)||Ye((i=t.conditions)==null?void 0:i.url))return!0;var a=Mn.getWindowLocation();if(a){var o,u,f,h=jw(n,a.href);return(o=t.conditions)==null||!o.url||V4[(u=(f=t.conditions)==null?void 0:f.urlMatchType)!==null&&u!==void 0?u:"icontains"](t.conditions.url,h)}return!1}static getWindowLocation(){return ie==null?void 0:ie.location}static ua(t){var n;if(Ye(t.conditions)||Ye((n=t.conditions)==null?void 0:n.utm))return!0;var i=Fw();if(i.utm_source){var a,o,u,f,h,p,g,x,b=(a=t.conditions)==null||(a=a.utm)==null||!a.utm_campaign||((o=t.conditions)==null||(o=o.utm)==null?void 0:o.utm_campaign)==i.utm_campaign,y=(u=t.conditions)==null||(u=u.utm)==null||!u.utm_source||((f=t.conditions)==null||(f=f.utm)==null?void 0:f.utm_source)==i.utm_source,_=(h=t.conditions)==null||(h=h.utm)==null||!h.utm_medium||((p=t.conditions)==null||(p=p.utm)==null?void 0:p.utm_medium)==i.utm_medium,j=(g=t.conditions)==null||(g=g.utm)==null||!g.utm_term||((x=t.conditions)==null||(x=x.utm)==null?void 0:x.utm_term)==i.utm_term;return b&&_&&j&&y}return!1}static ra(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),a=1;n>a;a++)i[a-1]=arguments[a];we.info("[WebExperiments] "+t,i)}sa(t,n,i){this._is_bot()?Mn.ra(Ky):n!=="control"?i.forEach((a=>{if(a.selector){var o;Mn.ra("applying transform of variant "+n+" for experiment "+t+" ",a);var u=(o=document)==null?void 0:o.querySelectorAll(a.selector);u==null||u.forEach((f=>{var h=f;a.html&&(h.innerHTML=a.html),a.css&&h.setAttribute("style",a.css)}))}})):Mn.ra("Control variants leave the page unmodified.")}_is_bot(){return In&&this._instance?s2(In,this.Ne.custom_blocked_useragents):void 0}}var Rr=Wt("[Conversations]"),ca="Conversations not available yet.",Zy="console",p2="__posthogHandledLogsRequestError",dm=(e,t)=>{var n=e instanceof Error?e:new Error(t);return n[p2]=!0,n},Jy=e=>!!e&&typeof e=="object"&&e[p2]===!0,bf={featureFlags:class{constructor(e){this.ha=!1,this.da=!1,this.va=!1,this.ca=!1,this.fa=!1,this.pa=!1,this.ga=!1,this.ma=!1,this.ya=0,this.ba=()=>{var t=this._a();this.ya=0,t&&this.reloadFeatureFlags()},this._instance=e,this.featureFlagEventHandlers=[],ie&&Gt(ie,"online",this.ba)}destroy(){ie==null||ie.removeEventListener("online",this.ba)}get Ne(){return this._instance.config}get Tr(){return this._instance.persistence}wa(e){return this._instance.get_property(e)}ka(){var e,t;return(e=(t=this.Tr)==null?void 0:t.Ci(this.Ne.feature_flag_cache_ttl_ms))!==null&&e!==void 0&&e}xa(){return!!this.ka()&&(this.ma||this.va||(this.ma=!0,pn.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Sa(){var e,t=(e=this.Ne.evaluation_contexts)!==null&&e!==void 0?e:this.Ne.evaluation_environments;return!this.Ne.evaluation_environments||this.Ne.evaluation_contexts||this.ga||(pn.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ga=!0),t!=null&&t.length?t.filter((n=>{var i=n&&typeof n=="string"&&n.trim().length>0;return i||pn.error("Invalid evaluation context found:",n,"Expected non-empty string"),i})):[]}Ca(){return this.Sa().length>0}Ma(){var e=this.Ne.flag_keys;if(!ye(e)){if(Ve(e))return e.filter((t=>{var n=t&&typeof t=="string"&&t.trim().length>0;return n||pn.error("Invalid flag key found:",t,"Expected non-empty string"),n}));pn.error("Invalid flag_keys found:",e,"Expected array of non-empty strings")}}initialize(){var e,t,n=this._instance.config,i=(e=(t=n.bootstrap)==null?void 0:t.featureFlags)!==null&&e!==void 0?e:{};if(Object.keys(i).length){var a,o,u=(a=(o=n.bootstrap)==null?void 0:o.featureFlagPayloads)!==null&&a!==void 0?a:{},f=Object.keys(i).filter((p=>!!i[p])).reduce(((p,g)=>(p[g]=i[g]||!1,p)),{}),h=Object.keys(u).filter((p=>f[p])).reduce(((p,g)=>(u[g]&&(p[g]=u[g]),p)),{});this.receivedFeatureFlags({featureFlags:f,featureFlagPayloads:h})}}updateFlags(e,t,n){var i,a,o=n!=null&&n.merge&&(i=this.wa(ga))!==null&&i!==void 0?i:{},u=n!=null&&n.merge&&(a=this.wa(Cd))!==null&&a!==void 0?a:{},f=he({},o,e),h=he({},u,t),p={};for(var g of Object.entries(f)){var x=g[0],b=g[1];p[x]={key:x,enabled:Wb(b),variant:Qb(b),reason:void 0,metadata:ye(h==null?void 0:h[x])?void 0:{id:0,version:void 0,description:void 0,payload:h[x]}}}this.receivedFeatureFlags({flags:p})}get hasLoadedFlags(){return this.da}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this.wa(ag),t=this.wa(Oi),n=this.wa(vl);if(!n&&!t)return e||{};var i=Ot({},e||{}),a=[...new Set([...Object.keys(n||{}),...Object.keys(t||{})])];for(var o of a){var u,f,h=i[o],p=t==null?void 0:t[o],g=ye(p)?(u=h==null?void 0:h.enabled)!==null&&u!==void 0&&u:!!p,x=ye(p)?h.variant:typeof p=="string"?p:void 0,b=n==null?void 0:n[o],y=he({},h,{enabled:g,variant:g?x??(h==null?void 0:h.variant):void 0});g!==(h==null?void 0:h.enabled)&&(y.original_enabled=h==null?void 0:h.enabled),x!==(h==null?void 0:h.variant)&&(y.original_variant=h==null?void 0:h.variant),b&&(y.metadata=he({},h==null?void 0:h.metadata,{payload:b,original_payload:h==null||(f=h.metadata)==null?void 0:f.payload})),i[o]=y}return this.ha||(pn.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:n,finalDetails:i}),this.ha=!0),i}getAllFeatureFlags(){var e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map((n=>{var i=e[n];return{key:n,enabled:Wb(i),variant:Qb(i),payload:Yb(t[n])}}))}getFlagVariants(){var e=this.wa(ga),t=this.wa(Oi);if(!t)return e||{};for(var n=Ot({},e),i=Object.keys(t),a=0;i.length>a;a++)n[i[a]]=t[i[a]];return this.ha||(pn.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:n}),this.ha=!0),n}getFlagPayloads(){var e=this.wa(Cd),t=this.wa(vl);if(!t)return e||{};for(var n=Ot({},e||{}),i=Object.keys(t),a=0;i.length>a;a++)n[i[a]]=t[i[a]];return this.ha||(pn.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:n}),this.ha=!0),n}reloadFeatureFlags(){this.ca||this.Ne.advanced_disable_feature_flags||this._a()||this.Ta||(this._instance.vn.emit("featureFlagsReloading",!0),this.Ta=setTimeout((()=>{this.Ea()}),5))}Ia(){clearTimeout(this.Ta),this.Ta=void 0}ensureFlagsLoaded(){this.da||this.va||this.Ta||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.ca=e}Ea(e){var t;if(this.Ia(),!this._instance.Ki()&&!this._a())if(this.va)this.fa=!0;else{var n=this.Ne.token,i=this.wa(wc),a={token:n,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:he({},((t=this.Tr)==null?void 0:t.get_initial_props())||{},this.wa(fa)||{},{$lib:jt.LIB_NAME,$lib_version:jt.LIB_VERSION}),group_properties:this.wa(ha),timezone:Gw()};Hn(i)||ye(i)||(a.$device_id=i),(e!=null&&e.disableFlags||this.Ne.advanced_disable_feature_flags)&&(a.disable_flags=!0),this.Ca()&&(a.evaluation_contexts=this.Sa());var o=this.Ma();ye(o)||(a.flag_keys=o);var u=!!this.Ne.advanced_only_evaluate_survey_feature_flags,f=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.Ne.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.va=!0,this._instance._send_request({method:"POST",url:f,data:a,compression:this.Ne.disable_compression?void 0:$n.Base64,timestampMode:"body",timeout:this.Ne.feature_flag_request_timeout_ms,callback:h=>{var p,g,x,b=!0;if(this.Pa(h.statusCode),h.statusCode===200&&(this.fa||(this.$anon_distinct_id=void 0),b=!1),this.va=!1,!a.disable_flags||this.fa){this.pa=!b;var y=[];h.error?h.error instanceof Error?y.push(h.error.name==="AbortError"?"timeout":"connection_error"):y.push("unknown_error"):h.statusCode!==200&&y.push("api_error_"+h.statusCode),(p=h.json)!=null&&p.errorsWhileComputingFlags&&y.push("errors_while_computing_flags");var _,j=!((g=h.json)==null||(g=g.quotaLimited)==null||!g.includes("feature_flags"));j&&y.push("quota_limited"),(x=this.Tr)==null||x.register({[dg]:y}),j?pn.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."):(a.disable_flags||this.receivedFeatureFlags((_=h.json)!==null&&_!==void 0?_:{},b,{partialResponse:u}),this.fa&&(this.fa=!1,this.Ea()))}}})}}_a(){return Pw(this.ya,3)}Pa(e){this.ya=$w(e,this.ya,3,(()=>pn.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes.")))}getFeatureFlag(e,t){var n;if(t===void 0&&(t={}),!t.fresh||this.pa)if(this.da||this.getFlags()&&this.getFlags().length>0){if(!this.xa()){var i=this.getFeatureFlagResult(e,t);return(n=i==null?void 0:i.variant)!==null&&n!==void 0?n:i==null?void 0:i.enabled}}else pn.warn('getFeatureFlag for key "'+e+um)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return t==null?void 0:t.payload}getFeatureFlagResult(e,t){if(t===void 0&&(t={}),!t.fresh||this.pa)if(this.da||this.getFlags()&&this.getFlags().length>0){if(!this.xa()){var n=this.getFlagVariants(),i=e in n,a=n[e],o=this.getFlagPayloads()[e],u=String(a),f=this.wa(lg)||void 0,h=this.wa(Sc)||void 0,p=this.wa(cc)||{};if(this.Ne.advanced_feature_flags_dedup_per_session){var g,x=this._instance.get_session_id(),b=this.wa(ug);x&&x!==b&&(p={},(g=this.Tr)==null||g.register({[cc]:p,[ug]:x}))}if((t.send_event||!("send_event"in t))&&(!(e in p)||!p[e].includes(u))){var y,_,j,C,k,E,N,D,O,L,G;Ve(p[e])?p[e].push(u):p[e]=[u],(y=this.Tr)==null||y.register({[cc]:p});var P=this.getFeatureFlagDetails(e),Q=[...(_=this.wa(dg))!==null&&_!==void 0?_:[]];ye(a)&&Q.push("flag_missing");var B={$feature_flag:e,$feature_flag_response:a,$feature_flag_payload:o||null,$feature_flag_request_id:f,$feature_flag_evaluated_at:h,$feature_flag_bootstrapped_response:((j=this.Ne.bootstrap)==null||(j=j.featureFlags)==null?void 0:j[e])||null,$feature_flag_bootstrapped_payload:((C=this.Ne.bootstrap)==null||(C=C.featureFlagPayloads)==null?void 0:C[e])||null,$used_bootstrap_value:!this.pa};ye(P==null||(k=P.metadata)==null?void 0:k.has_experiment)||(B.$feature_flag_has_experiment=P.metadata.has_experiment),ye(P==null||(E=P.metadata)==null?void 0:E.version)||(B.$feature_flag_version=P.metadata.version);var I,M=(N=P==null||(D=P.reason)==null?void 0:D.description)!==null&&N!==void 0?N:P==null||(O=P.reason)==null?void 0:O.code;M&&(B.$feature_flag_reason=M),P!=null&&(L=P.metadata)!=null&&L.id&&(B.$feature_flag_id=P.metadata.id),ye(P==null?void 0:P.original_variant)&&ye(P==null?void 0:P.original_enabled)||(B.$feature_flag_original_response=ye(P.original_variant)?P.original_enabled:P.original_variant),P!=null&&(G=P.metadata)!=null&&G.original_payload&&(B.$feature_flag_original_payload=P==null||(I=P.metadata)==null?void 0:I.original_payload),Q.length&&(B.$feature_flag_error=Q.join(",")),this._instance.capture("$feature_flag_called",B)}if(i)return{key:e,enabled:!!a,variant:typeof a=="string"?a:void 0,payload:Yb(o)}}}else pn.warn('getFeatureFlagResult for key "'+e+um)}getRemoteConfigPayload(e,t){var n=this.Ne.token,i={distinct_id:this._instance.get_distinct_id(),token:n,person_properties:{$lib:jt.LIB_NAME,$lib_version:jt.LIB_VERSION}};this.Ca()&&(i.evaluation_contexts=this.Sa());var a=this.Ma();ye(a)||(i.flag_keys=a),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:i,compression:this.Ne.disable_compression?void 0:$n.Base64,timestampMode:"body",timeout:this.Ne.feature_flag_request_timeout_ms,callback(o){var u,f=(u=o.json)==null?void 0:u.featureFlagPayloads;t((f==null?void 0:f[e])||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),t.fresh&&!this.pa)return t.defaultValue;if(!(this.da||this.getFlags()&&this.getFlags().length>0))return pn.warn('isFeatureEnabled for key "'+e+um),t.defaultValue;var n=this.getFeatureFlag(e,t);return ye(n)?t.defaultValue:!!n}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t,n){if(this.Tr){this.da=!0;var i=this.getFlagVariants(),a=this.getFlagPayloads(),o=this.getFlagsWithDetails();(function(u,f,h,p,g,x){h===void 0&&(h={}),p===void 0&&(p={}),g===void 0&&(g={});var b=(P=>{var Q=P.flags;return Q?(P.featureFlags=Object.fromEntries(Object.keys(Q).map((B=>{var I;return[B,(I=Q[B].variant)!==null&&I!==void 0?I:Q[B].enabled]}))),P.featureFlagPayloads=Object.fromEntries(Object.keys(Q).filter((B=>Q[B].enabled)).filter((B=>{var I;return(I=Q[B].metadata)==null?void 0:I.payload})).map((B=>{var I;return[B,(I=Q[B].metadata)==null?void 0:I.payload]})))):P.featureFlags&&pn.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),P})(u),y=b.flags,_=b.featureFlags,j=b.featureFlagPayloads;if(_){var C=u.requestId,k=u.evaluatedAt;if(Ve(_)){pn.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var E={};if(_)for(var N=0;_.length>N;N++)E[_[N]]=!0;f&&f.register({[Nd]:_,[ga]:E,[Yd]:!1})}else{var D=_,O=j,L=y;if(x!=null&&x.partialResponse)D=he({},h,D),O=he({},p,O),L=he({},g,L);else if(u.errorsWhileComputingFlags)if(y){var G=new Set(Object.keys(y).filter((P=>{var Q;return!((Q=y[P])!=null&&Q.failed)})));D=he({},h,Object.fromEntries(Object.entries(D).filter((P=>G.has(P[0]))))),O=he({},p,Object.fromEntries(Object.entries(O||{}).filter((P=>G.has(P[0]))))),L=he({},g,Object.fromEntries(Object.entries(L||{}).filter((P=>G.has(P[0])))))}else D=he({},h,D),O=he({},p,O),L=he({},g,L);f&&f.register(he({[Nd]:Object.keys(Xy(D)),[ga]:D||{},[Cd]:O||{},[ag]:L||{},[Yd]:u.minimalFlagCalledEvents===!0},C?{[lg]:C}:{},k?{[Sc]:k}:{}))}}})(e,this.Tr,i,a,o,n),t||(this.ma=!1),this.Ra(t)}}override(e,t){t===void 0&&(t=!1),pn.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this.Tr)return pn.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this.Tr.unregister(Oi),this.Tr.unregister(vl),this.Ra(),oa.info("All overrides cleared");if(Ve(e)){var t=Qy(e);return this.Tr.register({[Oi]:t}),this.Ra(),oa.info("Flag overrides set",{flags:e})}if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var n,i=e;if(this.ha=!!((n=i.suppressWarning)!==null&&n!==void 0&&n),"flags"in i){if(i.flags===!1)this.Tr.unregister(Oi),oa.info("Flag overrides cleared");else if(i.flags){if(Ve(i.flags)){var a=Qy(i.flags);this.Tr.register({[Oi]:a})}else this.Tr.register({[Oi]:i.flags});oa.info("Flag overrides set",{flags:i.flags})}}return"payloads"in i&&(i.payloads===!1?(this.Tr.unregister(vl),oa.info("Payload overrides cleared")):i.payloads&&(this.Tr.register({[vl]:i.payloads}),oa.info("Payload overrides set",{payloads:i.payloads}))),void this.Ra()}if(e&&typeof e=="object")return this.Tr.register({[Oi]:e}),this.Ra(),oa.info("Flag overrides set",{flags:e});pn.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.da){var t=this.Aa(),n=t.flags,i=t.flagVariants;try{e(n,i)}catch(a){pn.error("Error while running feature flags callback",a)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,n){var i,a=(this.wa(nc)||[]).find((h=>h.flagKey===e)),o={["$feature_enrollment/"+e]:t},u={$feature_flag:e,$feature_enrollment:t,$set:o};a&&(u.$early_access_feature_name=a.name),n&&(u.$feature_enrollment_stage=n),this._instance.capture("$feature_enrollment_update",u),this.setPersonPropertiesForFlags(o,!1);var f=he({},this.getFlagVariants(),{[e]:t});(i=this.Tr)==null||i.register({[Nd]:Object.keys(Xy(f)),[ga]:f}),this.Ra()}getEarlyAccessFeatures(e,t,n){t===void 0&&(t=!1);var i=this.wa(nc),a=n?"&"+n.map((o=>"stage="+o)).join("&"):"";if(i&&!t)return e(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.Ne.token+a),method:"GET",timestampMode:"query",callback:o=>{var u,f;if(o.json){var h=o.json.earlyAccessFeatures;return(u=this.Tr)==null||u.unregister(nc),(f=this.Tr)==null||f.register({[nc]:h}),e(h)}}})}Aa(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((n=>t[n])),flagVariants:Object.keys(t).filter((n=>t[n])).reduce(((n,i)=>(n[i]=t[i],n)),{})}}Ra(e){var t=this.Aa(),n=t.flags,i=t.flagVariants;this.featureFlagEventHandlers.forEach((a=>{try{a(n,i,{errorsLoading:e})}catch(o){pn.error("Error while running feature flags callback",o)}}))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.wa(fa)||{},i=(e==null?void 0:e.$set)||(e!=null&&e.$set_once?{}:e),a=e==null?void 0:e.$set_once,o={};if(a)for(var u in a)({}).hasOwnProperty.call(a,u)&&(u in n||(o[u]=a[u]));this._instance.register({[fa]:he({},n,o,i)}),t&&this._instance.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=he({},this.wa(fa)||{});e.forEach((i=>{delete n[i]})),this._instance.register({[fa]:n}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(e){e===void 0&&(e=!0),this._instance.unregister(fa),e&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.wa(ha)||{};Object.keys(n).length!==0&&Object.keys(n).forEach((i=>{n[i]=he({},n[i],e[i]),delete e[i]})),this._instance.register({[ha]:he({},n,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this.wa(ha)||{};this._instance.register({[ha]:he({},t,{[e]:{}})})}else this._instance.unregister(ha)}reset(){this.da=!1,this.va=!1,this.ca=!1,this.fa=!1,this.pa=!1,this.$anon_distinct_id=void 0,this.Ia(),this.ha=!1,this.ya=0}}},G4={sessionRecording:class{get Ne(){return this._instance.config}get Tr(){return this._instance.persistence}get started(){var e;return!((e=this.Fa)==null||!e.isStarted)}get status(){var e,t;return this.La===Go||this.La===hd?this.La:(e=(t=this.Fa)==null?void 0:t.status)!==null&&e!==void 0?e:this.La}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.La=Hy,this.Oa=void 0,this.Da=!1,this.$a=(()=>{var t;if(ke==null||!ke.visibilityState||ke.visibilityState==="visible")return!0;var n=ie==null||(t=ie.performance)==null||t.getEntriesByType==null?void 0:t.getEntriesByType("visibility-state");return!(n!=null&&n.length)||n.some((i=>i.name==="visible"))})(),this.Ie=()=>{var t;(ke==null?void 0:ke.visibilityState)==="visible"&&(this.$a=!0,(t=this.Fa)==null||t.setDocumentWasEverVisible==null||t.setDocumentWasEverVisible(!0))},this._instance=e,!this._instance.sessionManager)throw Ri.error("started without valid sessionManager"),new Error(Cg+" started without valid sessionManager. This is a bug.");if(this.Ne.cookieless_mode===$i)throw new Error(Cg+' cannot be used with cookieless_mode="always"');ke!=null&&ke.addEventListener&&Gt(ke,"visibilitychange",this.Ie)}initialize(){this.startIfEnabledOrStop()}dispose(){this.Da=!0,ke==null||ke.removeEventListener==null||ke.removeEventListener("visibilitychange",this.Ie),this.stopRecording()}get Na(){var e,t=!((e=this._instance.get_property(xa))==null||!e.enabled),n=!this.Ne.disable_session_recording,i=this.Ne.disable_session_recording||this._instance.consent.isOptedOut();return ie&&t&&n&&!i}startIfEnabledOrStop(e){var t;if(!(this.Da||this.Na&&(t=this.Fa)!=null&&t.isStarted)){var n=!ye(Object.assign)&&!ye(Array.from);this.Na&&n?(this.qa(e),Ri.info("starting")):(this.La=Hy,this.stopRecording())}}qa(e){var t,n,i;this.Na&&(this.La!==Go&&this.La!==hd&&(this.La=qy),Oe!=null&&(t=Oe.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(n=Oe.__PosthogExtensions__)!=null&&n.initSessionRecording?this.ja(e):(i=Oe.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.Ba,(a=>{if(a)return Ri.error("could not load recorder",a);this.ja(e)})))}stopRecording(){var e,t;(e=this.Oa)==null||e.call(this),this.Oa=void 0,(t=this.Fa)==null||t.stop()}Ha(){var e,t;(e=this.Oa)==null||e.call(this),this.Oa=void 0,(t=this.Fa)==null||t.discard()}Ua(){var e,t;(e=this.Tr)==null||e.unregister(tx),(t=this.Tr)==null||t.unregister(pw)}za(e,t){if(Ye(e))return null;var n,i=sn(e)?e:parseFloat(e);return typeof(n=i)!="number"||!Number.isFinite(n)||0>n||n>1?(Ri.warn(t+" must be between 0 and 1. Ignoring invalid value:",e),null):i}Wa(e){if(this.Tr){var t,n,i=this.Tr,a=()=>{var o,u=e.sessionRecording===!1?void 0:e.sessionRecording,f=this.za((o=this.Ne.session_recording)==null?void 0:o.sampleRate,"session_recording.sampleRate"),h=this.za(u==null?void 0:u.sampleRate,"remote config sampleRate"),p=f??h;Ye(p)&&this.Ua();var g=u==null?void 0:u.minimumDurationMilliseconds;i.register({[xa]:he({cache_timestamp:Date.now(),enabled:!!u},u,{networkPayloadCapture:he({capturePerformance:e.capturePerformance},u==null?void 0:u.networkPayloadCapture),canvasRecording:{enabled:u==null?void 0:u.recordCanvas,fps:u==null?void 0:u.canvasFps,quality:u==null?void 0:u.canvasQuality},sampleRate:p,minimumDurationMilliseconds:ye(g)?null:g,endpoint:u==null?void 0:u.endpoint,triggerMatchType:u==null?void 0:u.triggerMatchType,masking:u==null?void 0:u.masking,urlTriggers:u==null?void 0:u.urlTriggers,version:u==null?void 0:u.version,triggerGroups:u==null?void 0:u.triggerGroups})})};a(),(t=this.Oa)==null||t.call(this),this.Oa=(n=this._instance.sessionManager)==null?void 0:n.onSessionId(a)}}onRemoteConfig(e){var t=e.ok?e.config:void 0;return t&&"sessionRecording"in t?t.sessionRecording===!1?(this.Wa(t),void this.Ha()):(this.Wa(t),void this.startIfEnabledOrStop()):(this.La===Go&&(this.La=hd,Ri.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t){var n;t===void 0&&(t="log"),(n=this.Fa)!=null&&n.log?this.Fa.log(e,t):Ri.warn("log called before recorder was ready")}get Ba(){var e,t,n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(xa);return(n==null||(t=n.scriptConfig)==null?void 0:t.script)||"lazy-recorder"}Va(){var e,t,n=this._instance.get_property(xa);if(!n)return!1;try{t=typeof n=="object"?n:JSON.parse(n)}catch(a){return Ri.warn("persisted remote config for session recording is invalid and will be ignored",a),!1}var i=(e=t.cache_timestamp)!==null&&e!==void 0?e:Date.now();return 36e5>=Date.now()-i}ja(e){var t,n,i;if(!this.Da){if((t=Oe.__PosthogExtensions__)==null||!t.initSessionRecording)return Ri.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[ww]:!0});var a;if(this.Fa||(this.Fa=(a=Oe.__PosthogExtensions__)==null?void 0:a.initSessionRecording(this._instance,this.$a),this.Fa._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Va())return this.La===hd||this.La===Go?void 0:(this.La=Go,Ri.info("persisted remote config is stale, requesting fresh config before starting"),void new Yw(this._instance).load());this.La=qy,(n=(i=this.Fa).setDocumentWasEverVisible)==null||n.call(i,this.$a),this.Fa.start(e)}}onRRwebEmit(e){var t;(t=this.Fa)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.Fa||(t=this.Tr)==null||t.register({[gw]:!0}),(e=this.Fa)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Fa||(t=this.Tr)==null||t.register({[mw]:!0}),(e=this.Fa)==null||e.overrideSampling()}overrideTrigger(e){var t,n;this.Fa||(n=this.Tr)==null||n.register({[e==="url"?xw:vw]:!0}),(t=this.Fa)==null||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.Fa)==null?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var n;return!((n=this.Fa)==null||!n.tryAddCustomEvent(e,t))}}},Y4={autocapture:class{constructor(e){this.Za=!1,this.Ga=null,this.Qa=!1,this.Ka=!1,this.instance=e,this.rageclicks=new Fy(e.config.rageclick),this.Ja=null}initialize(){this.startIfEnabled()}get Ne(){var e,t,n=Bt(this.instance.config.autocapture)?this.instance.config.autocapture:{};return n.url_allowlist=(e=n.url_allowlist)==null?void 0:e.map((i=>new RegExp(i))),n.url_ignorelist=(t=n.url_ignorelist)==null?void 0:t.map((i=>new RegExp(i))),n}Ya(){if(this.isBrowserSupported()){if(ie&&ke){var e=n=>{n=n||(ie==null?void 0:ie.event);try{this.Xa(n)}catch(i){am.error("Failed to capture event",i)}};if(Gt(ke,"submit",e,{capture:!0}),Gt(ke,"change",e,{capture:!0}),Gt(ke,"click",e,{capture:!0}),this.Ne.capture_copied_text){var t=n=>{n=n||(ie==null?void 0:ie.event);try{this.Xa(n,sm)}catch(i){am.error("Failed to capture copy/cut event",i)}};Gt(ke,"copy",t,{capture:!0}),Gt(ke,"cut",t,{capture:!0})}}}else am.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.Za&&(this.Ya(),this.Za=!0)}onRemoteConfig(e){if(this.Qa=!0,e.ok){var t=e.config;t.elementsChainAsString&&(this.Ka=t.elementsChainAsString);var n=t.autocapture_opt_out;Wr(n)&&(this.instance.persistence&&this.instance.persistence.register({[Jm]:n}),this.Ga=n),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(e){this.Ja=e}getElementSelectors(e){var t,n=[];return(t=this.Ja)==null||t.forEach((i=>{var a=ke==null?void 0:ke.querySelectorAll(i);a==null||a.forEach((o=>{e===o&&n.push(i)}))})),n}get isEnabled(){var e,t,n=(e=this.instance.persistence)==null?void 0:e.props[Jm],i=this.Ga,a=this.instance.Ki()&&!this.Qa;if(Hn(i)&&!Wr(n)&&!a)return!1;var o=(t=this.Ga)!==null&&t!==void 0?t:!!n;return!!this.instance.config.autocapture&&!o}Xa(e,t){if(t===void 0&&(t="$autocapture"),this.isEnabled){var n,i=Yp(e);Cw(i)&&(i=i.parentNode||null),t==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&this.instance.config.rageclick&&(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime())&&gy(i,this.instance.config.rageclick)&&this.Xa(e,"$rageclick");var a=t===sm;if(i&&(function(x,b,y,_,j,C){var k;if(!ie||ax(x)||y!=null&&y.url_allowlist&&!hy(y.url_allowlist,C)||y!=null&&y.url_ignorelist&&hy(y.url_ignorelist,C))return!1;if(y!=null&&y.dom_event_allowlist){var E=y.dom_event_allowlist;if(E&&!E.some((P=>b.type===P)))return!1}var N=Lw(x,_),D=N.parentIsUsefulElement,O=N.targetElementList;if(!(function(P,Q){var B=Q==null?void 0:Q.element_allowlist;if(ye(B))return!0;var I,M=function(J){if(B.some((Y=>J.tagName.toLowerCase()===Y)))return{v:!0}};for(var le of P)if(I=M(le))return I.v;return!1})(O,y)||!vg(O,y==null?void 0:y.css_selector_allowlist)||vg(O,(k=y==null?void 0:y.css_selector_ignorelist)!==null&&k!==void 0?k:V3))return!1;try{var L=ie.getComputedStyle(x);if(L&&L.getPropertyValue("cursor")==="pointer"&&b.type==="click")return!0}catch{}var G=x.tagName.toLowerCase();switch(G){case"html":return!1;case"form":return(j||["submit"]).indexOf(b.type)>=0;case"input":case"select":case"textarea":return(j||["change","click"]).indexOf(b.type)>=0;default:return D?(j||["click"]).indexOf(b.type)>=0:(j||["click"]).indexOf(b.type)>=0&&(sx.indexOf(G)>-1||x.getAttribute("contenteditable")==="true")}})(i,e,this.Ne,a,a?["copy","cut"]:void 0,this.instance)){var o=B4(i,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Ne.element_attribute_ignorelist,elementsChainAsString:this.Ka,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes}),u=o.props;if(o.explicitNoCapture)return!1;var f=this.getElementSelectors(i);if(f&&f.length>0&&(u.$element_selectors=f),t===sm){var h,p=Aw(ie==null||(h=ie.getSelection())==null?void 0:h.toString()),g=e.type||"clipboard";if(!p)return!1;u.$selected_content=p,u.$copy_type=g}return this.instance.capture(t,u),!0}}}isBrowserSupported(){return pr(ke==null?void 0:ke.querySelectorAll)}},historyAutocapture:class{constructor(e){var t;this._instance=e,this.eo=(ie==null||(t=ie.location)==null?void 0:t.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(we.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.io&&this.io(),this.io=void 0,we.info("History API monitoring stopped")}monitorHistoryChanges(){ie&&ie.history&&(this.ro("pushState"),this.ro("replaceState"),this.no())}ro(e){var t;if(ie&&((t=ie.history[e])==null||!t.__posthog_wrapped__)){var n=this;(function(i,a,o){try{if(!(a in i))return Uy;var u={next:i[a]},f=o((function(){for(var h=arguments.length,p=new Array(h),g=0;h>g;g++)p[g]=arguments[g];return u.next.apply(this,p)}));return pr(f)&&(f.prototype=f.prototype||{},Object.defineProperties(f,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:u}})),i[a]=f,()=>{if(i[a]!==f)for(var h=i[a];pr(h)&&h.__posthog_layer__;){var p=h.__posthog_layer__;if(p.next===f)return void(p.next=u.next);h=p.next}else i[a]=u.next}}catch{return Uy}})(ie.history,e,(i=>function(a,o,u){i.call(this,a,o,u),n.so(e)}))}}so(e){try{var t,n=ie==null||(t=ie.location)==null?void 0:t.pathname;if(!n)return;n!==this.eo&&this.isEnabled&&this._instance.capture(bl,{navigation_type:e}),this.eo=n}catch(i){we.error("Error capturing "+e+" pageview",i)}}no(){if(!this.io){var e=()=>{this.so("popstate")};Gt(ie,"popstate",e),this.io=()=>{ie&&ie.removeEventListener("popstate",e)}}}},heatmaps:class{get Ne(){return this.instance.config}constructor(e){var t;this.ao=!1,this.Za=!1,this.oo=null,this.instance=e,this.ao=!((t=this.instance.persistence)==null||!t.props[eg]),this.rageclicks=new Fy(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return Bt(this.Ne.capture_heatmaps)&&this.Ne.capture_heatmaps.flush_interval_milliseconds&&(e=this.Ne.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return Ye(this.Ne.capture_heatmaps)?Ye(this.Ne.enable_heatmaps)?this.ao:this.Ne.enable_heatmaps:this.Ne.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.Za)return;$4.info("starting..."),this.lo(),this.Ie()}else{var e;clearInterval((e=this.oo)!==null&&e!==void 0?e:void 0),this.uo(),this.getAndClearBuffer()}}onRemoteConfig(e){if(e.ok){var t=e.config;if("heatmaps"in t){var n=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[eg]:n}),this.ao=n,this.startIfEnabled()}}}getAndClearBuffer(){var e=this.R;return this.R=void 0,e}ho(e){om(e.originalEvent)&&this.ke(e.originalEvent,"deadclick")}Ie(){this.oo&&clearInterval(this.oo),this.oo=(ke==null?void 0:ke.visibilityState)==="visible"?setInterval(this.pr.bind(this),this.flushIntervalMilliseconds):null}lo(){ie&&ke&&(this.do=this.pr.bind(this),Gt(ie,Zd,this.do),this.vo=e=>this.ke(e||(ie==null?void 0:ie.event)),Gt(ke,"click",this.vo,{capture:!0}),this.co=e=>this.fo(e||(ie==null?void 0:ie.event)),Gt(ke,"mousemove",this.co,{capture:!0}),this.po=new Sy(this.instance,Z3,this.ho.bind(this)),this.po.startIfEnabledOrStop(),this.mo=this.Ie.bind(this),Gt(ke,Kd,this.mo),this.Za=!0)}uo(){var e;ie&&ke&&(this.do&&ie.removeEventListener(Zd,this.do),this.vo&&ke.removeEventListener("click",this.vo,{capture:!0}),this.co&&ke.removeEventListener("mousemove",this.co,{capture:!0}),this.mo&&ke.removeEventListener(Kd,this.mo),clearTimeout(this.yo),(e=this.po)==null||e.stop(),this.Za=!1)}bo(e,t){var n=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),a=this.instance.scrollManager.scrollElement(),o=(function(u,f,h){for(var p=u;p&&As(p)&&!mr(p,"body");){if(p===h)return!1;var g=void 0;try{var x,b,y;g=(x=(b=(y=p.ownerDocument)==null?void 0:y.defaultView)!==null&&b!==void 0?b:ie)==null?void 0:x.getComputedStyle(p).position}catch{return!1}if(qe(f,g))return!0;p=Mw(p)}return!1})(Yp(e),["fixed","sticky"],a);return{x:e.clientX+(o?0:i),y:e.clientY+(o?0:n),target_fixed:o,type:t}}ke(e,t){var n;if(t===void 0&&(t="click"),!fy(e.target)&&om(e)){var i=this.bo(e,t);(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,new Date().getTime())&&gy(Yp(e),this.instance.config.rageclick)&&this.Vt(he({},i,{type:"rageclick"})),this.Vt(i)}}fo(e){!fy(e.target)&&om(e)&&(clearTimeout(this.yo),this.yo=setTimeout((()=>{this.Vt(this.bo(e,"mousemove"))}),500))}Vt(e){if(ie){var t=this.Ne.disable_capture_url_hashes?Ts(ie.location.href):ie.location.href,n=this.Ne.custom_personal_data_properties,i=this.Ne.mask_personal_data_properties?[...Ml,...n||[]]:[],a=jc(t,i,Nc);this.R=this.R||{},this.R[a]||(this.R[a]=[]),this.R[a].push(e)}}pr(){this.R&&!Ii(this.R)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Sy,webVitalsAutocapture:class{constructor(e){var t;this.ao=!1,this.Za=!1,this.R={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this._o=()=>{clearTimeout(this.wo),this.wo=void 0,this.R.metrics.length!==0&&(this._instance.capture("$web_vitals",he({$current_url:this.R.url},this.R.metrics.reduce(((n,i)=>he({},n,{["$web_vitals_"+i.name+"_event"]:he({},i),["$web_vitals_"+i.name+"_value"]:i.value})),{}))),this.R={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.ko=n=>{var i;if(this.R=this.R||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},Ye(n==null?void 0:n.name)||Ye(n==null?void 0:n.value))la.error("Invalid metric received",n);else{var a=typeof n.navigationURL=="string"?n.navigationURL:void 0,o=this.xo(a);if(!ye(o)){var u=sn(n.navigationId)||typeof n.navigationId=="string"?"navigation:"+n.navigationId:"url:"+o;if(!this.So||this.So>n.value){this.R.navigationKey!==u&&(this._o(),this.wo=setTimeout(this._o,this.flushToCaptureTimeoutMs)),ye(this.R.navigationKey)&&(this.R.navigationKey=u,this.R.url=o),this.R.firstMetricTimestamp=ye(this.R.firstMetricTimestamp)?Date.now():this.R.firstMetricTimestamp,n.attribution&&n.attribution.interactionTargetElement&&(n.attribution.interactionTargetElement=void 0);var f=(i=this._instance.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0),h=he({},n,a?{navigationURL:o}:{},{$current_url:o,timestamp:Date.now()});ye(f)||(h.$session_id=f.sessionId,h.$window_id=f.windowId),this.R.metrics.push(h),this.R.metrics.length===this.allowedMetrics.length&&this._o()}else la.error("Ignoring metric with value >= "+this.So,n)}}},this.Co=()=>{if(!this.Za){var n,i,a,o,u=Oe.__PosthogExtensions__,f=u==null?void 0:u.postHogWebVitalsCallbacksByFlavor,h=(f==null?void 0:f[this.Mo])||(this.Mo==="web-vitals"&&ye(f)?u==null?void 0:u.postHogWebVitalsCallbacks:void 0);if(ye(h)||(n=h.onLCP,i=h.onCLS,a=h.onFCP,o=h.onINP),n&&i&&a&&o){var p={reportSoftNavs:this.useSoftNavs};this.allowedMetrics.indexOf("LCP")>-1&&n(this.ko.bind(this),p),this.allowedMetrics.indexOf("CLS")>-1&&i(this.ko.bind(this),p),this.allowedMetrics.indexOf("FCP")>-1&&a(this.ko.bind(this),p),this.allowedMetrics.indexOf("INP")>-1&&o(this.ko.bind(this),p),this.Za=!0}else la.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this.ao=!((t=this._instance.persistence)==null||!t.props[ig]),this.startIfEnabled()}get To(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t,n=Bt(this.To)?(e=this.To)==null?void 0:e.web_vitals_allowed_metrics:void 0;return Ye(n)?((t=this._instance.persistence)==null?void 0:t.props[sg])||["CLS","FCP","INP","LCP"]:n}get flushToCaptureTimeoutMs(){return(Bt(this.To)?this.To.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=Bt(this.To)?this.To.web_vitals_attribution:void 0;return e!=null&&e}get useSoftNavs(){var e=Bt(this.To)?this.To.__preview_web_vitals_soft_navs:void 0;return e!=null&&e}get So(){var e=Bt(this.To)&&sn(this.To.__web_vitals_max_value)?this.To.__web_vitals_max_value:Iy;return e>0&&6e4>=e?Iy:e}get isEnabled(){var e=Vt==null?void 0:Vt.protocol;if(e!=="http:"&&e!=="https:")return la.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=Bt(this.To)?this.To.web_vitals:Wr(this.To)?this.To:void 0;return Wr(t)?t:this.ao}startIfEnabled(){this.isEnabled&&!this.Za&&(la.info("enabled, starting..."),this.ai(this.Co))}onRemoteConfig(e){if(e.ok){var t=e.config;if("capturePerformance"in t){var n=Bt(t.capturePerformance)&&!!t.capturePerformance.web_vitals,i=Bt(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[ig]:n}),this._instance.persistence.register({[sg]:i})),this.ao=n,this.startIfEnabled()}}}get Mo(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}ai(e){var t=Oe.__PosthogExtensions__,n=this.Mo,i=t==null?void 0:t.postHogWebVitalsCallbacksByFlavor;i!=null&&i[n]||n==="web-vitals"&&ye(i)&&t!=null&&t.postHogWebVitalsCallbacks?e():t==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,n,(a=>{a?la.error("failed to load script",a):e()}))}xo(e){var t=e||(ie==null?void 0:ie.location.href);if(t){var n=this._instance.config.disable_capture_url_hashes?Ts(t):t,i=this._instance.config.custom_personal_data_properties,a=this._instance.config.mask_personal_data_properties?[...Ml,...i||[]]:[];return jc(n,a,Nc)}la.error("Could not determine current URL")}}},W4={exceptionObserver:class{constructor(e){var t;this.Co=()=>{var n;if(ie&&this.isEnabled&&(n=Oe.__PosthogExtensions__)!=null&&n.errorWrappingFunctions){var i=Oe.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,a=Oe.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,o=Oe.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Eo&&this.Ne.capture_unhandled_errors&&(this.Eo=i(this.captureException.bind(this))),!this.Io&&this.Ne.capture_unhandled_rejections&&(this.Io=a(this.captureException.bind(this))),!this.Po&&this.Ne.capture_console_errors&&(this.Po=o(this.captureException.bind(this)))}catch(u){Vo.error("failed to start",u),this.Ro()}}},this._instance=e,this.Ao=!((t=this._instance.persistence)==null||!t.props[tg]),this.Fo=new YC(he({},(function(n){var i,a,o,u;return n===void 0&&(n={}),{refillRate:(i=(a=n.exceptionRateLimiterRefillRate)!==null&&a!==void 0?a:n.__exceptionRateLimiterRefillRate)!==null&&i!==void 0?i:1,bucketSize:(o=(u=n.exceptionRateLimiterBucketSize)!==null&&u!==void 0?u:n.__exceptionRateLimiterBucketSize)!==null&&o!==void 0?o:10}})(this._instance.config.error_tracking),{refillInterval:1e4,rt:Vo})),this.Ne=this.Lo(),this.startIfEnabledOrStop()}Lo(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Bt(e)?t=he({},t,e):(ye(e)?this.Ao:e)&&(t=he({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Ne.capture_console_errors||this.Ne.capture_unhandled_errors||this.Ne.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Vo.info("enabled"),this.Ro(),this.ai(this.Co)):this.Ro()}ai(e){var t,n;(t=Oe.__PosthogExtensions__)!=null&&t.errorWrappingFunctions?e():(n=Oe.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"exception-autocapture",(i=>{if(i)return Vo.error("failed to load script",i);e()}))}Ro(){var e,t,n;(e=this.Eo)==null||e.call(this),this.Eo=void 0,(t=this.Io)==null||t.call(this),this.Io=void 0,(n=this.Po)==null||n.call(this),this.Po=void 0}onRemoteConfig(e){if(e.ok){var t=e.config;"autocaptureExceptions"in t&&(this.Ao=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[tg]:this.Ao}),this.Ne=this.Lo(),this.startIfEnabledOrStop())}}onConfigChange(){this.Ne=this.Lo()}captureException(e){var t,n,i,a=(t=e==null||(n=e.$exception_list)==null||(n=n[0])==null?void 0:n.type)!==null&&t!==void 0?t:"Exception";this.Fo.consumeRateLimit(a)?Vo.info("Skipping exception capture because of client rate limiting.",{exception:a}):(i=this._instance.exceptions)==null||i.sendExceptionEvent(e)}},exceptions:class{constructor(e){var t,n;this.Oo=[],this.Do=new u3([new v3,new C3,new y3,new b3,new j3,new k3,new w3,new N3],(function(i){for(var a=arguments.length,o=new Array(a>1?a-1:0),u=1;a>u;u++)o[u-1]=arguments[u];return function(f,h){h===void 0&&(h=0);for(var p=[],g=f.split(`
|
|
66
|
+
at `+n.filename+":"+o+":"+u}}}var _3=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class w3{match(t){return typeof t=="string"}coerce(t,n){var i,a=this.getInfos(t),o=a[0],u=a[1];return{type:o??"Error",value:u??t,stack:(i=n.syntheticException)==null?void 0:i.stack,synthetic:!0}}getInfos(t){var n="Error",i=t,a=t.match(_3);return a&&(n=a[1],i=a[2]),[n,i]}}var S3=["fatal","error","warning","log","info","debug"];function dw(e,t){t===void 0&&(t=40);var n=Object.keys(e);if(n.sort(),!n.length)return"[object has no keys]";for(var i=n.length;i>0;i--){var a=n.slice(0,i).join(", ");if(t>=a.length)return i===n.length?a:a.length>t?a.slice(0,t)+"...":a}return""}class k3{match(t){return typeof t=="object"&&t!==null}coerce(t,n){var i,a,o=this.getErrorPropertyFromObject(t);return o?n.apply(o):{type:this.getType(t),value:this.getValue(t),stack:(i=this.getStack(t))!==null&&i!==void 0?i:(a=n.syntheticException)==null?void 0:a.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){return Yg(t)?t.constructor.name:"Error"}getValue(t){if("name"in t&&typeof t.name=="string"){var n="'"+t.name+"' captured as exception";return"message"in t&&typeof t.message=="string"&&(n+=" with message: '"+t.message+"'"),n}if("message"in t&&typeof t.message=="string")return t.message;var i=this.getObjectClassName(t);return(i&&i!=="Object"?"'"+i+"'":"Object")+" captured as exception with keys: "+dw(t)}isSeverityLevel(t){return vt(t)&&!Ym(t)&&S3.indexOf(t)>=0}getStack(t){try{return vt(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:vt(t.stack)&&t.stack.length>0?t.stack:void 0}catch{return}}getErrorPropertyFromObject(t){for(var n in t)if({}.hasOwnProperty.call(t,n)){var i=t[n];if(i3(i))return i}}getObjectClassName(t){try{var n=Object.getPrototypeOf(t);return n?n.constructor.name:void 0}catch{return}}}class j3{match(t){return Yg(t)}coerce(t,n){var i,a=t.constructor.name;return{type:a,value:a+" captured as exception with keys: "+dw(t),stack:(i=n.syntheticException)==null?void 0:i.stack,synthetic:!0}}}class N3{match(t){return B5(t)}coerce(t,n){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:(i=n.syntheticException)==null?void 0:i.stack,synthetic:!0}}}class C3{match(t){return Pd(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!Yg(t))return!1;try{var n=t.detail;return n!=null&&typeof n=="object"&&"reason"in n}catch{return!1}}coerce(t,n){var i,a=this.getUnhandledRejectionReason(t);return B5(a)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(a),stack:(i=n.syntheticException)==null?void 0:i.stack,synthetic:!0}:n.apply(a)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&t.detail!=null&&typeof t.detail=="object"&&"reason"in t.detail)return t.detail.reason}catch{}return t}}var qd="$message",Vd="$timestamp",E3=new Set([qd,Vd]),Up={enabled:!0,max_bytes:32768};function Gd(e){var t;return e?{enabled:(t=e.enabled)!==null&&t!==void 0?t:Up.enabled,max_bytes:A3(e.max_bytes,Up.max_bytes)}:he({},Up)}class T3{constructor(t){this.Ke=[],this.Je=0,this.Ne=Gd(t)}setConfig(t){this.Ne=Gd(t),this.Xe()}add(t){var n=(function(a){var o;try{o=D5(a)}catch{return}try{var u=JSON.parse(o);if(!Bt(u))return;var f=u,h=f[qd],p=f[Vd];return!vt(h)||h.trim().length===0||!vt(p)&&!sn(p)?void 0:{step:f,json:o}}catch{return}})(t);if(n){var i=(function(a){if(typeof TextEncoder<"u")return new TextEncoder().encode(a).length;for(var o=encodeURIComponent(a),u=0,f=0;o.length>f;f++)o[f]==="%"?(u+=1,f+=2):u+=1;return u})(n.json);i>this.Ne.max_bytes||(this.Ke.push({step:n.step,bytes:i}),this.Je+=i,this.Xe())}}getAttachable(){return this.Ke.map((t=>t.step))}clear(){this.Ke=[],this.Je=0}size(){return this.Ke.length}Xe(){for(;this.Je>this.Ne.max_bytes&&this.Ke.length>0;){var t=this.Ke.shift();t&&(this.Je-=t.bytes)}}}function A3(e,t){if(!sn(e)||e===1/0||e===-1/0)return t;var n=Math.floor(e);return 0>n?t:n}var fw=function(e,t){var n=(t===void 0?{}:t).debugEnabled,i={k(a){if(ie&&(jt.DEBUG||ie.POSTHOG_DEBUG||n)&&!ye(ie.console)&&ie.console){for(var o=("__rrweb_original__"in ie.console[a])?ie.console[a].__rrweb_original__:ie.console[a],u=arguments.length,f=new Array(u>1?u-1:0),h=1;u>h;h++)f[h-1]=arguments[h];o(e,...f)}},debug(){for(var a=arguments.length,o=new Array(a),u=0;a>u;u++)o[u]=arguments[u];i.k("debug",...o)},info(){for(var a=arguments.length,o=new Array(a),u=0;a>u;u++)o[u]=arguments[u];i.k("log",...o)},warn(){for(var a=arguments.length,o=new Array(a),u=0;a>u;u++)o[u]=arguments[u];i.k("warn",...o)},error(){for(var a=arguments.length,o=new Array(a),u=0;a>u;u++)o[u]=arguments[u];i.k("error",...o)},critical(){for(var a=arguments.length,o=new Array(a),u=0;a>u;u++)o[u]=arguments[u];console.error(e,...o)},uninitializedWarning(a){i.error("You must initialize PostHog before calling "+a)},createLogger:(a,o)=>fw(e+" "+a,o)};return i},we=fw("[PostHog.js]"),Wt=we.createLogger,M3=Wt("[ExternalScriptsLoader]"),Ip=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return M3.warn(t+" was requested but loading of external scripts is disabled."),n("Loading of external scripts is disabled");var i=ke==null?void 0:ke.querySelectorAll("script");if(i){for(var a,o=function(){if(i[u].src===t){var h=i[u];return h.__posthog_loading_callback_fired?{v:n()}:(h.addEventListener("load",(p=>{h.__posthog_loading_callback_fired=!0,n(void 0,p)})),h.onerror=p=>n(p),{v:void 0})}},u=0;i.length>u;u++)if(a=o())return a.v}var f=()=>{if(!ke)return n("document not found");var h=ke.createElement("script");if(h.type="text/javascript",h.crossOrigin="anonymous",h.src=t,h.onload=x=>{h.__posthog_loading_callback_fired=!0,n(void 0,x)},h.onerror=x=>n(x),e.config.prepare_external_dependency_script&&(h=e.config.prepare_external_dependency_script(h)),!h)return n("prepare_external_dependency_script returned null");if(e.config.external_scripts_inject_target==="head")ke.head.appendChild(h);else{var p,g=ke.querySelectorAll("body > script");g.length>0?(p=g[0].parentNode)==null||p.insertBefore(h,g[0]):ke.body.appendChild(h)}};ke!=null&&ke.body?f():ke==null||ke.addEventListener("DOMContentLoaded",f)};Oe.__PosthogExtensions__=Oe.__PosthogExtensions__||{},Oe.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{if(t!=="remote-config"){var i;if(e.config.strict_script_versioning)i=e.requestRouter.endpointFor("assets","/static/"+e.version+"/"+t+".js");else{var a="/static/"+t+".js?v="+e.version;if(t==="toolbar"){var o=3e5;a=a+"&t="+Math.floor(Date.now()/o)*o}i=e.requestRouter.endpointFor("assets",a)}Ip(e,i,n)}else{var u=e.requestRouter.endpointFor("assets","/array/"+e.config.token+"/config.js");Ip(e,u,n)}},Oe.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{var i=e.requestRouter.endpointFor("api",t);Ip(e,i,n)};jt.DEBUG=!1,jt.LIB_VERSION="1.415.1",jt.LIB_NAME="web";var hw="$people_distinct_id",wc="$device_id",Hp="$device_model",ec="__alias",tc="__timers",Jm="$autocapture_disabled_server_side",eg="$heatmaps_enabled_server_side",tg="$exception_capture_enabled_server_side",ng="$error_tracking_suppression_rules",rg="$error_tracking_capture_extension_exceptions",ig="$web_vitals_enabled_server_side",Jg="$dead_clicks_enabled_server_side",ex="$product_tours_enabled_server_side",sg="$web_vitals_allowed_metrics",xa="$session_recording_remote_config",pw="$replay_sample_rate",mw="$replay_override_sampling",gw="$replay_override_linked_flag",xw="$replay_override_url_trigger",vw="$replay_override_event_trigger",wl="$sesid",tx="$session_is_sampled",ga="$enabled_feature_flags",Nd="$active_feature_flags",nc="$early_access_features",ag="$feature_flag_details",Cd="$feature_flag_payloads",lg="$feature_flag_request_id",Yd="$minimal_flag_called_events",Oi="$override_feature_flags",vl="$override_feature_flag_payloads",fa="$stored_person_properties",ha="$stored_group_properties",og="$surveys",Wd="$surveys_loaded_at",cg="$surveys_activated",Ed="$surveys_activated_session",Td="$surveys_activated_timestamps",rc="ph_product_tours",cc="$flag_call_reported",ug="$flag_call_reported_session_id",dg="$feature_flag_errors",Sc="$feature_flag_evaluated_at",zr="$user_state",fg="$client_session_props",hg="$capture_rate_limit",pg="$initial_campaign_params",mg="$initial_referrer_info",Qd="$initial_person_info",Xd="$epp",ad="$posthog_cookieless",bw="$cookieless_mode",yw="$sdk_debug_extensions_init_method",_w="$sdk_debug_extensions_init_time_ms",ww="$sdk_debug_recording_script_not_loaded",nx="PostHog loadExternalDependency extension not found.",pa="on_reject",$i="always",fl="anonymous",ia="identified",gg="identified_only",Kd="visibilitychange",Zd="beforeunload",bl="$pageview",qp="$pageleave",Vp="$identify",cy="$groupidentify";function ld(e,t){Ve(e)&&e.forEach(t)}function Rt(e,t){if(!Ye(e))if(Ve(e))e.forEach(t);else if(IC(e))e.forEach(((i,a)=>t(i,a)));else for(var n in e)O5.call(e,n)&&t(e[n],n)}var Ot=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;t>i;i++)n[i-1]=arguments[i];for(var a of n)for(var o in a)a[o]!==void 0&&(e[o]=a[o]);return e};function Ad(e){for(var t=Object.keys(e),n=t.length,i=new Array(n);n--;)i[n]=[t[n],e[t[n]]];return i}var uy=function(e){try{return e()}catch{return}},R3=function(e){return function(){try{for(var t=arguments.length,n=new Array(t),i=0;t>i;i++)n[i]=arguments[i];return e.apply(this,n)}catch(a){we.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),we.critical(a)}}},rx=function(e){var t={};return Rt(e,(function(n,i){(vt(n)&&n.length>0||sn(n))&&(t[i]=n)})),t},L3=["herokuapp.com","vercel.app","netlify.app"];function D3(e){var t=e==null?void 0:e.hostname;if(!vt(t))return!1;var n=t.split(".").slice(-2).join(".");for(var i of L3)if(n===i)return!1;return!0}function Gt(e,t,n,i){var a=i??{},o=a.capture,u=a.passive;e==null||e.addEventListener(t,n,{capture:o!==void 0&&o,passive:u===void 0||u})}function xg(e){return e.name==="ph_toolbar_internal"}var Sw=e=>{if(ke){try{for(var t=e+"=",n=ke.cookie.split(";").filter((o=>o.length)),i=0;n.length>i;i++){for(var a=n[i];a.charAt(0)==" ";)a=a.substring(1,a.length);if(a.indexOf(t)===0)return decodeURIComponent(a.substring(t.length,a.length))}}catch{}return null}};Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return sn(e)&&isFinite(e)&&Math.floor(e)===e});class Jd{constructor(t){if(this.bytes=t,t.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,n,i,a){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(i)||!Number.isInteger(a)||0>t||0>n||0>i||0>a||t>0xffffffffffff||n>4095||i>1073741823||a>4294967295)throw new RangeError("invalid field value");var o=new Uint8Array(16);return o[0]=t/Math.pow(2,40),o[1]=t/Math.pow(2,32),o[2]=t/Math.pow(2,24),o[3]=t/Math.pow(2,16),o[4]=t/256,o[5]=t,o[6]=112|n>>>8,o[7]=n,o[8]=128|i>>>24,o[9]=i>>>16,o[10]=i>>>8,o[11]=i,o[12]=a>>>24,o[13]=a>>>16,o[14]=a>>>8,o[15]=a,new Jd(o)}toString(){for(var t="",n=0;this.bytes.length>n;n++)t=t+(this.bytes[n]>>>4).toString(16)+(15&this.bytes[n]).toString(16),n!==3&&n!==5&&n!==7&&n!==9||(t+="-");if(t.length!==36)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new Jd(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(var n=0;16>n;n++){var i=this.bytes[n]-t.bytes[n];if(i!==0)return Math.sign(i)}return 0}}class z3{generate(){var t=this.generateOrAbort();if(!ye(t))return t;this.S=0;var n=this.generateOrAbort();if(ye(n))throw new Error("Could not generate UUID after timestamp reset");return n}generateOrAbort(){var t=Date.now();if(t>this.S)this.S=t,this.C();else{if(this.S>=t+1e4)return;this.I++,this.I>4398046511103&&(this.S++,this.C())}return Jd.fromFieldsV7(this.S,Math.trunc(this.I/Math.pow(2,30)),this.I&Math.pow(2,30)-1,this.A.nextUint32())}C(){this.I=1024*this.A.nextUint32()+(1023&this.A.nextUint32())}constructor(){this.S=0,this.I=0,this.A=new O3}}var dy,kw=e=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};ie&&!ye(ie.crypto)&&crypto.getRandomValues&&(kw=e=>crypto.getRandomValues(e));class O3{nextUint32(){return this.R.length>this.O||(kw(this.R),this.O=0),this.R[this.O++]}constructor(){this.R=new Uint32Array(8),this.O=1/0}}var Pi=()=>B3().toString(),B3=()=>(dy||(dy=new z3)).generate(),$o="",P3=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,Fi={N:()=>!!ke,j(e){we.error("cookieStore error: "+e)},P:Sw,H(e){var t;try{t=JSON.parse(Fi.P(e))||{}}catch{}return t},F(e,t,n,i,a){if(!ke)return!1;try{var o="",u="",f=(function(g,x){if(x){var b=(function(_,j){if(j===void 0&&(j=ke),$o)return $o;if(!j||["localhost","127.0.0.1"].includes(_))return"";for(var C=_.split("."),k=Math.min(C.length,8),E="dmn_chk_"+Pi();!$o&&k--;){var N=C.slice(k).join("."),D=E+"=1;domain=."+N+";path=/";j.cookie=D+";max-age=3",j.cookie.includes(E)&&(j.cookie=D+";max-age=0",$o=N)}return $o})(g);if(!b){var y=(_=>{var j=_.match(P3);return j?j[0]:""})(g);y!==b&&we.info("Warning: cookie subdomain discovery mismatch",y,b),b=y}return b?"; domain=."+b:""}return""})(ke.location.hostname,i);if(n){var h=new Date;h.setTime(h.getTime()+864e5*n),o="; expires="+h.toUTCString()}a&&(u="; secure");var p=e+"="+encodeURIComponent(JSON.stringify(t))+o+"; SameSite=Lax; path=/"+f+u;return p.length>3686.4&&we.warn("cookieStore warning: large cookie, len="+p.length),ke.cookie=p,!0}catch{return!1}},q(e,t){if(ke!=null&&ke.cookie)try{Fi.F(e,"",-1,t)}catch{return}}},Gp=null,zt={N(){if(!Hn(Gp))return Gp;var e=!0;if(ye(ie))e=!1;else try{var t="__mplssupport__";zt.F(t,"xyz"),zt.P(t)!=='"xyz"'&&(e=!1),zt.q(t)}catch{e=!1}return e||we.error("localStorage unsupported; falling back to cookie store"),Gp=e,e},j(e){we.error("localStorage error: "+e)},P(e){try{return ie==null?void 0:ie.localStorage.getItem(e)}catch(t){zt.j(t)}return null},H(e){try{return JSON.parse(zt.P(e))||{}}catch{}return null},F(e,t){try{return ie==null||ie.localStorage.setItem(e,JSON.stringify(t)),!0}catch(n){zt.j(n)}return!1},q(e){try{ie==null||ie.localStorage.removeItem(e)}catch(t){zt.j(t)}}},$3=[wc,"distinct_id",wl,tx,Xd,Qd,zr],od={},F3={N:()=>!0,j(e){we.error("memoryStorage error: "+e)},P:e=>od[e]||null,H:e=>od[e]||null,F:(e,t)=>(od[e]=t,!0),q(e){delete od[e]}},sa=null,Zt={N(){if(!Hn(sa))return sa;if(sa=!0,ye(ie))sa=!1;else try{var e="__support__";Zt.F(e,"xyz"),Zt.P(e)!=='"xyz"'&&(sa=!1),Zt.q(e)}catch{sa=!1}return sa},j(e){we.error("sessionStorage error: ",e)},P(e){try{return ie==null?void 0:ie.sessionStorage.getItem(e)}catch(t){Zt.j(t)}return null},H(e){try{return JSON.parse(Zt.P(e))||null}catch{}return null},F(e,t){try{return ie==null||ie.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(n){Zt.j(n)}return!1},q(e){try{ie==null||ie.sessionStorage.removeItem(e)}catch(t){Zt.j(t)}}};class U3{constructor(t){this._instance=t}get Ne(){return this._instance.config}get consent(){return this.ti()?0:this.ei}isOptedOut(){return this.Ne.cookieless_mode===$i||this.isRejected()||this.consent===-1&&this.Ne.cookieless_mode===pa}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Ne.opt_out_capturing_by_default}optInOut(t){this.ii.F(this.ri,t?1:0,this.Ne.cookie_expiration,this.Ne.cross_subdomain_cookie,this.Ne.secure_cookie)}reset(){this.ii.q(this.ri,this.Ne.cross_subdomain_cookie)}get ri(){var t=this._instance.config,n=t.token,i=t.opt_out_capturing_cookie_prefix;return t.consent_persistence_name||(i?i+n:"__ph_opt_in_out_"+n)}get ei(){var t=this.ii.P(this.ri);return Bp(t)?1:qe(GC,t)?0:-1}get ii(){var t=this.Ne.opt_out_capturing_persistence_type,n=t==="localStorage"?zt:Fi;if(!this.ni||this.ni!==n){this.ni=n;var i=t==="localStorage"?Fi:zt;i.P(this.ri)&&(this.ni.P(this.ri)||this.optInOut(Bp(i.P(this.ri))),i.q(this.ri,this.Ne.cross_subdomain_cookie))}return this.ni}ti(){return!!this.Ne.respect_dnt&&[In==null?void 0:In.doNotTrack,In==null?void 0:In.msDoNotTrack,Oe.doNotTrack].some((t=>Bp(t)))}}function jw(e,t){var n,i=e==null||(n=e.config)==null?void 0:n.get_current_url;if(!pr(i))return t;try{var a=i(t);return vt(a)&&a?a:t}catch(o){return we.error("Error in get_current_url, falling back to window.location.href",o),t}}var Nw="__POSTHOG_TOOLBAR__",I3=1,H3=3,q3=11;function fy(e){return e instanceof Element&&(e.id===Nw||!(e.closest==null||!e.closest(".toolbar-global-fade-container")))}function As(e){return!!e&&e.nodeType===I3}function mr(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Cw(e){return!!e&&e.nodeType===H3}function Ew(e){return!!e&&e.nodeType===q3&&As(e.host)}var Tw=1e3;function ix(e){return e?gf(e).split(/\s+/):[]}function hy(e,t){var n=(function(i){var a,o=ie==null||(a=ie.location)==null?void 0:a.href;return ye(o)?void 0:jw(i,o)})(t);return!!(n&&e&&e.some((i=>n.match(i))))}function ef(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return ix(t)}function Aw(e){return Ye(e)?null:gf(e).split(/(\s+)/).filter((t=>uc(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function kc(e){var t="";return bg(e)&&!Dw(e)&&e.childNodes&&e.childNodes.length&&Rt(e.childNodes,(function(n){var i;Cw(n)&&n.textContent&&(t+=(i=Aw(n.textContent))!==null&&i!==void 0?i:"")})),gf(t)}function Yp(e){var t;return ye(e.target)?e.srcElement||null:(t=e.target)!=null&&t.shadowRoot?e.composedPath()[0]||null:e.target||null}var sx=["a","button","form","input","select","textarea","label"];function vg(e,t){if(ye(t))return!0;var n,i=function(o){if(t.some((u=>(function(f,h){var p=f.matches||f.matchesSelector||f.msMatchesSelector||f.mozMatchesSelector||f.webkitMatchesSelector||f.oMatchesSelector;try{return!!p&&p.call(f,h)}catch{return!1}})(o,u))))return{v:!0}};for(var a of e)if(n=i(a))return n.v;return!1}function Mw(e){var t=e.parentNode;return!(!t||!As(t))&&t}var V3=[".ph-no-autocapture","[data-ph-no-autocapture]"],Rw=["next","previous","prev",">","<"],G3=[...Rw,"+","-","−","–"],py=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,my=[".ph-no-rageclick",".ph-no-capture"],Y3=["","text","search","email","password","url","tel","number"];function gy(e,t){if(!ie||ax(e))return!1;var n,i,a,o,u;if(Wr(t)?(n=!!t&&my,i=void 0,a=!1):(n=(o=t==null?void 0:t.css_selector_ignorelist)!==null&&o!==void 0?o:my,i=t==null?void 0:t.content_ignorelist,a=(u=t==null?void 0:t.ignore_text_selection)!==null&&u!==void 0&&u),n===!1||a&&(function(h){return!(!h||!As(h))&&(!!mr(h,"textarea")||(mr(h,"input")?qe(Y3,(h.getAttribute("type")||"").toLowerCase()):(function(p){if(p.isContentEditable)return!0;var g=p.getAttribute==null?void 0:p.getAttribute("contenteditable");return g==="true"||g===""})(h)))})(e))return!1;var f=Lw(e,!1).targetElementList;return!(function(h,p){if(h===!1||ye(h))return!1;var g;if(h===!0)g=Rw;else{if(!Ve(h))return!1;if(h.length>10)return we.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;g=h.map((x=>x.toLowerCase()))}return p.some((x=>{var b=x.safeText,y=x.ariaLabel;return g.some((_=>py(b,_)||py(y,_)))}))})(i,f.map((h=>{var p;return{safeText:kc(h).toLowerCase(),ariaLabel:((p=h.getAttribute("aria-label"))==null?void 0:p.toLowerCase().trim())||""}})))&&!vg(f,n)}var ax=e=>!e||mr(e,"html")||!As(e),Lw=(e,t)=>{if(!ie||ax(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var n=!1,i=[e],a=e;a.parentNode&&!mr(a,"body");)if(Ew(a.parentNode))i.push(a.parentNode.host),a=a.parentNode.host;else{var o=Mw(a);if(!o)break;if(t||sx.indexOf(o.tagName.toLowerCase())>-1)n=!0;else try{var u=ie.getComputedStyle(o);u&&u.getPropertyValue("cursor")==="pointer"&&(n=!0)}catch{}i.push(o),a=o}return{parentIsUsefulElement:n,targetElementList:i}};function bg(e){for(var t=new Set,n=0,i=e;i.parentNode&&!mr(i,"body");i=i.parentNode){if(n++>=Tw||t.has(i))return!1;t.add(i);var a=ef(i);if(qe(a,"ph-sensitive")||qe(a,"ph-no-capture"))return!1}if(qe(ef(e),"ph-include"))return!0;var o=e.type||"";if(vt(o))switch(o.toLowerCase()){case"hidden":case"password":return!1}var u=e.name||e.id||"";return!vt(u)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(u.replace(/[^a-zA-Z0-9]/g,""))}function Dw(e){return!!(mr(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||mr(e,"select")||mr(e,"textarea")||e.getAttribute("contenteditable")==="true")}var xy=new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),vy=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,W3=[16,15,14,13],Q3=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),by=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),yy=/[0-9A-Za-z_]/;function X3(e){for(var t=0,n=!1,i=e.length-1;i>=0;i--){var a=e.charCodeAt(i)-48;n&&(a*=2)>9&&(a-=9),t+=a,n=!n}return t%10==0}function uc(e,t){if(t===void 0&&(t=!0),Ye(e))return!1;if(vt(e)){e=gf(e);var n=t?xy.test((e||"").replace(/[- ]/g,"")):(function(a){var o;for(vy.lastIndex=0;o=vy.exec(a);){var u=o[2];if(u)for(var f=u.replace(/[- ]/g,""),h=0;f.length>h;h++)for(var p of W3){var g=h+p;if(f.length>=g){var x=f.slice(h,g);if(xy.test(x)&&X3(x))return!0}}}return!1})(e);if(n)return!1;var i=t?Q3.test(e):(function(a){var o;for(by.lastIndex=0;o=by.exec(a);){var u=o[1],f=o[3];if(!(u&&f&&yy.test(u)&&yy.test(f)))return!0}return!1})(e);if(i)return!1}return!0}function _y(e){var t=kc(e);return uc(t=(t+" "+zw(e)).trim())?t:""}function zw(e){var t="";return e&&e.childNodes&&e.childNodes.length&&Rt(e.childNodes,(function(n){var i;if(n&&((i=n.tagName)==null?void 0:i.toLowerCase())==="span")try{var a=kc(n);t=(t+" "+a).trim(),n.childNodes&&n.childNodes.length&&(t=(t+" "+zw(n)).trim())}catch(o){we.error("[AutoCapture]",o)}})),t}function wy(e){return e.replace(/"|\\"/g,'\\"')}function K3(e){var t=e.attr__class;if(t)return Ve(t)?t:ix(t)}var cd=Wt("[Dead Clicks]"),Z3=()=>!0,J3=e=>{var t,n=!((t=e.instance.persistence)==null||!t.get_property(Jg)),i=e.instance.config.capture_dead_clicks;return Wr(i)?i:!!Bt(i)||n};class Sy{get lazyLoadedDeadClicksAutocapture(){return this.si}constructor(t,n,i){this.instance=t,this.isEnabled=n,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var n=t.config;"captureDeadClicks"in n&&(this.instance.persistence&&this.instance.persistence.register({[Jg]:n.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.ai((()=>{this.oi()})):this.stop()}ai(t){var n,i;(n=Oe.__PosthogExtensions__)!=null&&n.initDeadClicksAutocapture?t():(i=Oe.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(a=>{a?cd.error("failed to load script",a):t()}))}oi(){var t;if(ke){if(!this.si&&(t=Oe.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture){var n=Bt(this.instance.config.capture_dead_clicks)?he({},this.instance.config.capture_dead_clicks):{};n.__onCapture=this.onCapture,this.onCapture&&(n.capture_dead_swipes=!1),this.si=Oe.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this.si.start(ke),cd.info("starting...")}}else cd.error("`document` not found. Cannot start.")}stop(){this.si&&(this.si.stop(),this.si=void 0,cd.info("stopping..."))}}var Wp=Wt("[SegmentIntegration]"),Ow="posthog-js";function Bw(e,t){var n=t===void 0?{}:t,i=n.organization,a=n.projectId,o=n.prefix,u=n.severityAllowList,f=u===void 0?["error"]:u,h=n.sendExceptionsToPostHog,p=h===void 0||h;return g=>{var x,b,y,_,j;if(f!=="*"&&!f.includes(g.level)||!e.__loaded)return g;g.tags||(g.tags={});var C=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());g.tags["PostHog Person URL"]=C,e.sessionRecordingStarted()&&(g.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var k,E=((x=g.exception)==null?void 0:x.values)||[],N=E.map((O=>he({},O,{stacktrace:O.stacktrace?he({},O.stacktrace,{type:"raw",frames:(O.stacktrace.frames||[]).map((L=>he({},L,{platform:"web:javascript"})))}):void 0}))),D={$exception_message:((b=E[0])==null?void 0:b.value)||g.message,$exception_type:(y=E[0])==null?void 0:y.type,$exception_level:g.level,$exception_list:N,$sentry_event_id:g.event_id,$sentry_exception:g.exception,$sentry_exception_message:((_=E[0])==null?void 0:_.value)||g.message,$sentry_exception_type:(j=E[0])==null?void 0:j.type,$sentry_tags:g.tags};return i&&a&&(D.$sentry_url=(o||"https://sentry.io/organizations/")+i+"/issues/?project="+a+"&query="+g.event_id),p&&((k=e.exceptions)==null||k.sendExceptionEvent(D)),g}}class e4{constructor(t,n,i,a,o,u){this.name=Ow,this.setupOnce=function(f){f(Bw(t,{organization:n,projectId:i,prefix:a,severityAllowList:o,sendExceptionsToPostHog:u==null||u}))}}}class ky{constructor(t){this.li=(n,i,a)=>{a&&(a.noSessionId||a.activityTimeout||a.sessionPastMaximumLength||a.crossTabAdoption)&&(we.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:n,changeReason:a}),this.ui=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.hi()}hi(){var t;this.di=(t=this._instance.sessionManager)==null?void 0:t.onSessionId(this.li)}destroy(){var t;(t=this.di)==null||t.call(this),this.di=void 0}doPageView(t,n){var i,a=this.vi(t,n);return this.ui={pathname:(i=ie==null?void 0:ie.location.pathname)!==null&&i!==void 0?i:"",pageViewId:n,timestamp:t},this._instance.scrollManager.resetContext(),a}doPageLeave(t){var n;return this.vi(t,(n=this.ui)==null?void 0:n.pageViewId)}doEvent(){var t;return{$pageview_id:(t=this.ui)==null?void 0:t.pageViewId}}vi(t,n){var i=this.ui;if(!i)return{$pageview_id:n};var a={$pageview_id:n,$prev_pageview_id:i.pageViewId},o=this._instance.scrollManager.getContext();if(o&&!this._instance.config.disable_scroll_properties){var u=o.maxScrollHeight,f=o.lastScrollY,h=o.maxScrollY,p=o.maxContentHeight,g=o.lastContentY,x=o.maxContentY;if(!(ye(u)||ye(f)||ye(h)||ye(p)||ye(g)||ye(x))){u=Math.ceil(u),f=Math.ceil(f),h=Math.ceil(h),p=Math.ceil(p),g=Math.ceil(g),x=Math.ceil(x);var b=u>1?ui(f/u,0,1,we):1,y=u>1?ui(h/u,0,1,we):1,_=p>1?ui(g/p,0,1,we):1,j=p>1?ui(x/p,0,1,we):1;a=Ot(a,{$prev_pageview_last_scroll:f,$prev_pageview_last_scroll_percentage:b,$prev_pageview_max_scroll:h,$prev_pageview_max_scroll_percentage:y,$prev_pageview_last_content:g,$prev_pageview_last_content_percentage:_,$prev_pageview_max_content:x,$prev_pageview_max_content_percentage:j})}}return i.pathname&&(a.$prev_pageview_pathname=i.pathname),i.timestamp&&(a.$prev_pageview_duration=(t.getTime()-i.timestamp.getTime())/1e3),a}}var Qp=["flags","surveys"],t4={[hw]:{exposure:"hidden"},[ec]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[tc]:{exposure:"hidden"},[Jm]:{exposure:"event"},[eg]:{exposure:"hidden"},[tg]:{exposure:"event"},[ng]:{exposure:"hidden"},[rg]:{exposure:"event"},[ig]:{exposure:"event"},[Jg]:{exposure:"event"},[ex]:{exposure:"hidden"},[sg]:{exposure:"event"},[xa]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[wl]:{exposure:"hidden"},[tx]:{exposure:"event"},[pw]:{exposure:"event",shouldSkipFromEventProperties:e=>Hn(e)},$session_past_minimum_duration:{exposure:"event"},$session_recording_url_trigger_activated_session:{exposure:"event"},$session_recording_event_trigger_activated_session:{exposure:"event"},$debug_first_full_snapshot_timestamp:{exposure:"event"},$sess_rec_flush_size:{exposure:"hidden"},[ga]:{exposure:"derived",storageGroup:"flags",shouldSkipFromEventProperties:(e,t)=>t(),transformToEventProperties(e){if(!Bt(e))return{};for(var t={},n=Object.keys(e),i=0;n.length>i;i++)t["$feature/"+n[i]]=e[n[i]];return t}},[Nd]:{exposure:"event",storageGroup:"flags"},[nc]:{exposure:"hidden"},[ag]:{exposure:"hidden",storageGroup:"flags"},[Cd]:{exposure:"event",storageGroup:"flags"},[lg]:{exposure:"event",storageGroup:"flags",volatile:!0},[Yd]:{exposure:"hidden",storageGroup:"flags"},[Oi]:{exposure:"event"},[vl]:{exposure:"hidden"},[fa]:{exposure:"hidden"},[ha]:{exposure:"hidden"},[og]:{exposure:"hidden",storageGroup:"surveys"},[Wd]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[cg]:{exposure:"event"},[Ed]:{exposure:"hidden"},[Td]:{exposure:"hidden"},[rc]:{exposure:"hidden"},$product_tours_activated:{exposure:"hidden"},$product_tours_activated_session:{exposure:"hidden"},$conversations_widget_session_id:{exposure:"event"},$conversations_ticket_id:{exposure:"event"},$conversations_widget_state:{exposure:"event"},$conversations_user_traits:{exposure:"event"},[cc]:{exposure:"hidden"},[ug]:{exposure:"hidden"},[dg]:{exposure:"hidden"},[Sc]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[zr]:{exposure:"hidden"},[fg]:{exposure:"hidden"},[hg]:{exposure:"hidden"},[pg]:{exposure:"hidden"},[mg]:{exposure:"hidden"},[Qd]:{exposure:"hidden"},[Xd]:{exposure:"hidden"},[mw]:{exposure:"event"},[gw]:{exposure:"event"},[xw]:{exposure:"event"},[vw]:{exposure:"event"},[yw]:{exposure:"event"},[_w]:{exposure:"event"},[ww]:{exposure:"event"},$sdk_debug_replay_event_trigger_status:{exposure:"event"},$sdk_debug_replay_linked_flag_trigger_status:{exposure:"event"},$sdk_debug_replay_matched_recording_trigger_groups:{exposure:"event"},$sdk_debug_replay_remote_trigger_matching_config:{exposure:"event"},$sdk_debug_replay_trigger_groups_count:{exposure:"event"},$sdk_debug_replay_url_trigger_status:{exposure:"event"},$session_recording_start_reason:{exposure:"event"}},n4=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],aa=e=>{var t=t4[e];if(t)return t;for(var n of n4){var i=n[1];if(e.indexOf(n[0])===0)return i}},Sl=(e,t)=>{try{return JSON.stringify(e,((n,i)=>typeof i=="bigint"?i.toString():i),t)}catch{return D5(e)}},tf=e=>{var t=ke==null?void 0:ke.createElement("a");return ye(t)?null:(t.href=e,t)},Al=function(e,t){for(var n,i=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),a=0;i.length>a;a++){var o=i[a].split("=");if(o[0]===t){n=o;break}}if(!Ve(n)||2>n.length)return"";var u=n[1];try{u=decodeURIComponent(u)}catch{we.error("Skipping decoding for malformed query param: "+u)}return u.replace(/\+/g," ")},jc=function(e,t,n){if(!e||!t||!t.length)return e;for(var i=e.split("#"),a=i[1],o=(i[0]||"").split("?"),u=o[1],f=o[0],h=(u||"").split("&"),p=[],g=0;h.length>g;g++){var x=h[g].split("=");Ve(x)&&(t.includes(x[0])?p.push(x[0]+"="+n):p.push(h[g]))}var b=f;return u!=null&&(b+="?"+p.join("&")),a!=null&&(b+="#"+a),b},nf=function(e,t){var n=e.match(new RegExp(t+"=([^&]*)"));return n?n[1]:null},Pw=(e,t)=>e>=t&&M5(),$w=(e,t,n,i)=>{if(e===0){if(M5()){var a=t+1;return a===n&&i(),a}return t}return 0},ud="https?://(.*)",Ml=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],r4=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Ml],Nc="<masked>",i4=["li_fat_id"];function Fw(e,t,n){if(!ke)return{};var i,a=t?[...Ml,...n||[]]:[],o=Uw(jc(ke.URL,a,Nc),e),u=(i={},Rt(i4,(function(f){var h=Sw(f);i[f]=h||null})),i);return Ot(u,o)}function Uw(e,t){var n=r4.concat(t||[]),i={};return Rt(n,(function(a){var o=Al(e,a);i[a]=o||null})),i}function Iw(e){var t=(function(o){return o?o.search(ud+"google.([^/?]*)")===0?"google":o.search(ud+"bing.com")===0?"bing":o.search(ud+"yahoo.com")===0?"yahoo":o.search(ud+"duckduckgo.com")===0?"duckduckgo":null:null})(e),n=t!="yahoo"?"q":"p",i={};if(!Hn(t)){i.$search_engine=t;var a=ke?Al(ke.referrer,n):"";a.length&&(i.ph_keyword=a)}return i}function jy(){return navigator.language||navigator.userLanguage}var rf="$direct";function Hw(){return(ke==null?void 0:ke.referrer)||rf}function qw(e,t,n){n===void 0&&(n=!1);var i=e?[...Ml,...t||[]]:[],a=n?Ts(Vt==null?void 0:Vt.href):Vt==null?void 0:Vt.href,o=a==null?void 0:a.substring(0,1e3);return{r:Hw().substring(0,1e3),u:o?jc(o,i,Nc):void 0}}function Vw(e,t){var n;t===void 0&&(t=!1);var i=e.r,a=e.u,o=t?Ts(a):a,u={$referrer:i,$referring_domain:i==null?void 0:i==rf?rf:(n=tf(i))==null?void 0:n.host};if(o){u.$current_url=o;var f=tf(o);u.$host=f==null?void 0:f.host,u.$pathname=f==null?void 0:f.pathname;var h=Uw(o);Ot(u,h)}if(i){var p=Iw(i);Ot(u,p)}return u}function Gw(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function s4(){try{return new Date().getTimezoneOffset()}catch{return}}var a4={flags:Sc,surveys:Wd},l4=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],hl="main";class Xp{constructor(t,n,i){if(i===void 0&&(i=!0),this.ci={},this.fi=!1,this.pi=!1,this.Ne=t,this.gi=i,this.props={},this.mi=void 0,this.yi=(o=>{var u="";return o.token&&(u=o.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),o.persistence_name?"ph_"+o.persistence_name:"ph_"+u+"_posthog"})(t),this.ii=this.bi(t),this.pi=this.wi(t),this.load(),t.debug&&we.info("Persistence loaded",t.persistence,he({},this.props)),this.update_config(t,t,n),this.save(),ie){var a=()=>this.flush();Gt(ie,"beforeunload",a,{capture:!1}),Gt(ie,"pagehide",a,{capture:!1})}}ki(){var t,n=(t=this.Ne)==null?void 0:t.persistence_save_debounce_ms;return sn(n)&&n>0?n:0}isDisabled(){return!!this.xi}bi(t){l4.indexOf(t.persistence.toLowerCase())===-1&&(we.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");var n,i=(function(u,f){u===void 0&&(u=[]),f===void 0&&(f=!1);var h=[...$3,...u];return he({},zt,{H(p){try{var g={};try{g=Fi.H(p)||{}}catch{}var x,b=JSON.parse(zt.P(p)||"{}");if(f){var y={};for(var _ in g){var j=g[_];Hn(j)||j===""||(y[_]=j)}x=Ot(b,y)}else x=Ot(g,b);return zt.F(p,x),x}catch{}return null},F(p,g,x,b,y,_){var j=zt.F(p,g,void 0,void 0,_);try{var C={};h.forEach((k=>{g[k]&&(C[k]=g[k])})),Object.keys(C).length&&Fi.F(p,C,x,b,y,_)}catch(k){zt.j(k)}return j},q(p,g){try{ie==null||ie.localStorage.removeItem(p),Fi.q(p,g)}catch(x){zt.j(x)}}})})(t.cookie_persisted_properties||[],t.__preview_cookie_wins_on_conflict||!1),a=!1,o=t.persistence.toLowerCase();return o==="localstorage"&&zt.N()?(n=zt,a=!0):o==="localstorage+cookie"&&i.N()?(n=i,a=!0):o==="sessionstorage"&&Zt.N()?n=Zt:o==="memory"?n=F3:o==="cookie"?n=Fi:i.N()?(n=i,a=!0):n=Fi,this.fi=a,n}Si(t){return this.yi+"__"+t}wi(t){return this.fi&&!!t.split_storage}Ci(t){var n=t??this.Ne.feature_flag_cache_ttl_ms;if(!n||0>=n)return!1;var i=this.props[Sc];return!i||typeof i!="number"||Date.now()-i>n}properties(){var t={};return Rt(this.props,((n,i)=>{var a=aa(i);if((a==null?void 0:a.exposure)==="derived"){if(a.shouldSkipFromEventProperties!=null&&a.shouldSkipFromEventProperties(n,i===ga?()=>this.Ci():()=>!1))return;a.transformToEventProperties&&Ot(t,a.transformToEventProperties(n))}else if(!a||a.exposure==="event"){if(a!=null&&a.shouldSkipFromEventProperties!=null&&a.shouldSkipFromEventProperties(n,(()=>!1)))return;t[i]=n}})),t}load(){if(!this.xi){var t=this.ii.H(this.yi);t&&(this.props=Ot({},t)),this.pi&&this.Mi()}}Mi(){for(var t of Qp){var n=zt.H(this.Si(t));if(n&&!Ii(n)){var i=this.Ti(t);i.persisted=!0,this.Ei(t)||(i.fingerprint=this.Ii(n,t)),this.Pi(t,n)||Ot(this.props,n)}}}Ei(t){return Object.keys(this.props).some((n=>{var i;return((i=aa(n))==null?void 0:i.storageGroup)===t}))}Pi(t,n){var i=a4[t];if(!i)return!1;var a=n[i],o=this.props[i];return sn(a)&&sn(o)&&o>a}refreshKey(t){var n;if(!this.xi){var i=this.pi?(n=aa(t))==null?void 0:n.storageGroup:void 0,a=i?zt.H(this.Si(i)):this.ii.H(this.yi);if(a&&t in a)this.Ri(t,a[t]);else{if(i){var o=this.ii.H(this.yi);if(o&&t in o)return void this.Ri(t,o[t])}this.Ai(t)}}}save(){if(!this.xi){var t=this.ki();t>0?ye(this.Fi)&&(this.Fi=setTimeout((()=>{this.Fi=void 0,this.Li()}),t)):this.Li()}}flush(){ye(this.Fi)||(clearTimeout(this.Fi),this.Fi=void 0,this.Li())}Li(){this.xi||(this.pi?this.Oi():this.Di(this.ii,this.yi,this.props,hl))}Oi(){var t=this.$i(),n=t.main,i=t.groups;for(var a of(this.Di(this.ii,this.yi,n,hl),Qp)){var o,u=i[a];(!Ii(u)||(o=this.ci[a])!=null&&o.persisted)&&this.Di(zt,this.Si(a),u,a)}}$i(){var t={},n={flags:{},surveys:{}};return Rt(this.props,((i,a)=>{var o,u=(o=aa(a))==null?void 0:o.storageGroup;u?n[u][a]=i:t[a]=i})),{main:t,groups:n}}Ii(t,n){if(n===hl)return JSON.stringify(t)+"|"+this.Ni+"|"+this.qi+"|"+this.ji;var i={};return Rt(t,((a,o)=>{var u;i[o]=(u=aa(o))!=null&&u.volatile?"__volatile__":a})),JSON.stringify(i)}Di(t,n,i,a){var o=this.Ti(a);if(a===hl||o.dirty||ye(o.fingerprint)){var u;try{if((u=this.Ii(i,a))===o.fingerprint)return void(o.dirty=!1)}catch{u=void 0}t.F(n,i,this.Ni,this.qi,this.ji,this.Ne.debug)?(o.dirty=!1,a!==hl&&(o.persisted=!0),ye(u)||(o.fingerprint=u)):this.Ne.debug&&we.warn('failed to persist storage entry "'+n+'"; will retry on next save')}}remove(t){var n=(t===void 0?{}:t).keepGroupEntries,i=n!==void 0&&n;if(ye(this.Fi)||(clearTimeout(this.Fi),this.Fi=void 0),this.ii.q(this.yi,!1),this.ii.q(this.yi,!0),!i&&this.gi)for(var a of Qp)zt.q(this.Si(a));i?delete this.ci[hl]:this.ci={}}clear(){this.remove(),this.props={}}register_once(t,n,i){if(Bt(t)){ye(n)&&(n="None"),this.Ni=ye(i)?this.Bi:i;var a=!1;if(Rt(t,((o,u)=>{this.props.hasOwnProperty(u)&&this.props[u]!==n||(this.Ri(u,o),a=!0)})),a)return this.save(),!0}return!1}register(t,n){if(Bt(t)){this.Ni=ye(n)?this.Bi:n;var i=!1;if(Rt(t,((a,o)=>{t.hasOwnProperty(o)&&(this.props[o]!==a||Bt(a)||Ve(a))&&(this.Ri(o,a),i=!0)})),i)return this.save(),!0}return!1}unregister(t){t in this.props&&(this.Ai(t),this.save())}update_campaign_params(){var t=ke==null?void 0:ke.URL;if(t!==this.mi){var n=Fw(this.Ne.custom_campaign_params,this.Ne.mask_personal_data_properties,this.Ne.custom_personal_data_properties);Ii(rx(n))||this.register(n),this.mi=t}}update_search_keyword(){var t;this.register((t=ke==null?void 0:ke.referrer)?Iw(t):{})}update_referrer_info(){var t;this.register_once({$referrer:Hw(),$referring_domain:ke!=null&&ke.referrer&&((t=tf(ke.referrer))==null?void 0:t.host)||rf},void 0)}set_initial_person_info(){this.props[pg]||this.props[mg]||this.register_once({[Qd]:qw(this.Ne.mask_personal_data_properties,this.Ne.custom_personal_data_properties,this.Ne.disable_capture_url_hashes)},void 0)}get_initial_props(){var t={};Rt([mg,pg],(a=>{var o=this.props[a];o&&Rt(o,(function(u,f){t["$initial_"+Gm(f)]=u}))}));var n=this.props[Qd];if(n){var i=(function(a,o){o===void 0&&(o=!1);var u=Vw(a,o),f={};return Rt(u,(function(h,p){f["$initial_"+Gm(p)]=h})),f})(n,this.Ne.disable_capture_url_hashes);Ot(t,i)}return t}safe_merge(t){return Rt(this.props,(function(n,i){i in t||(t[i]=n)})),t}update_config(t,n,i){this.Bi=this.Ni=t.cookie_expiration,this.set_disabled(t.disable_persistence||!!i),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie);var a=t.persistence!==n.persistence||!((h,p)=>{if(h.length!==p.length)return!1;var g=[...h].sort(),x=[...p].sort();return g.every(((b,y)=>b===x[y]))})(t.cookie_persisted_properties||[],n.cookie_persisted_properties||[]),o=a?this.bi(t):this.ii,u=this.wi(t);if(a||u!==this.pi){var f=this.props;this.clear(),this.ii=o,this.pi=u,this.props=f,this.save()}}set_disabled(t){this.xi=t,this.xi?this.remove():this.save()}set_cross_subdomain(t){t!==this.qi&&(this.qi=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.ji&&(this.ji=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,n){var i=this.props[tc]||{};i[t]=n,this.Ri(tc,i),this.save()}remove_event_timer(t){var n=this.props[tc]||{},i=n[t];return ye(i)||(delete n[t],this.Ri(tc,n),this.save()),i}get_property(t){return this.props[t]}set_property(t,n){this.Ri(t,n),this.save()}Ri(t,n){var i;this.props[t]=n,(i=aa(t))!=null&&i.volatile||this.Hi(t)}Ai(t){delete this.props[t],this.Hi(t)}Hi(t){var n,i=(n=aa(t))==null?void 0:n.storageGroup;i&&(this.Ti(i).dirty=!0)}Ti(t){return this.ci[t]||(this.ci[t]={})}}function dd(e){var t=!0;return{dispose(){if(t){t=!1;var n=e();n&&pr(n.then)&&n.then(void 0,(()=>{}))}}}}var $n={GZipJS:"gzip-js",Base64:"base64"},Fo={Activation:"events",Cancellation:"cancelEvents"},Kp={Popover:"popover",API:"api",Widget:"widget"},Ui={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},Zp={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},yg={Popover:"popover",Inline:"inline"},o4={SHOWN:"product tour shown"},Ny={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},Cy=Wt("[RateLimiter]");class c4{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=n=>{var i=n.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach((a=>{Cy.info((a||"events")+" is quota limited."),this.serverLimits[a]=new Date().getTime()+6e4}))}catch(a){return void Cy.warn('could not rate limit - continuing. Error: "'+(a==null?void 0:a.message)+'"',{text:i})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return((t=this.instance.config.rate_limiting)==null?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max(((t=this.instance.config.rate_limiting)==null?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t){var n,i,a;t===void 0&&(t=!1);var o=this.captureEventsBurstLimit,u=this.captureEventsPerSecond,f=new Date().getTime(),h=(n=(i=this.instance.persistence)==null?void 0:i.get_property(hg))!==null&&n!==void 0?n:{tokens:o,last:f};h.tokens+=(f-h.last)/1e3*u,h.last=f,h.tokens>o&&(h.tokens=o);var p=1>h.tokens;if(p||t||(h.tokens=Math.max(0,h.tokens-1)),p&&!t){var g=(sn(h.dropped)?h.dropped:0)+1;h.dropped=g,!this.lastEventRateLimited&&this.Ui(g)&&(h.dropped=0)}return this.lastEventRateLimited=p,(a=this.instance.persistence)==null||a.set_property(hg,h),{isRateLimited:p,remainingTokens:h.tokens}}zi(t){var n=this.instance.config.property_denylist;return!Ve(n)||!n.includes(t)}Wi(){var t;if(this.zi("$current_url")&&this.zi("$pathname")&&Vt!=null&&Vt.pathname)return""+((t=Vt.origin)!==null&&t!==void 0?t:"")+Vt.pathname}Ui(t){var n,i,a=this.captureEventsBurstLimit,o=this.captureEventsPerSecond,u=this.Wi(),f=this.zi("$session_id")?(n=(i=this.instance).get_session_id)==null?void 0:n.call(i):void 0,h=[t+" event(s) dropped since the last warning",u?"triggered on "+u:void 0,f?"session "+f:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited: "+h+". Config is set to "+o+" events per second and "+a+" events burst limit."},{skip_client_rate_limiting:!0})}isServerRateLimited(t){var n=this.serverLimits[t||"events"]||!1;return n!==!1&&new Date().getTime()<n}}var ks=Wt("[RemoteConfig]");class Yw{constructor(t){this._instance=t}get remoteConfig(){var t;return(t=Oe._POSTHOG_REMOTE_CONFIG)==null||(t=t[this._instance.config.token])==null?void 0:t.config}Vi(t){var n,i;(n=Oe.__PosthogExtensions__)!=null&&n.loadExternalDependency?(i=Oe.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):t()}Zi(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return ks.info("Using preloaded remote config",this.remoteConfig),this.Gi(this.remoteConfig),void this.Qi();if(this._instance.Ki())return void ks.warn("Remote config is disabled. Falling back to local config.");this.Vi((t=>{if(!t)return ks.info("No config found after loading remote JS config. Falling back to JSON."),void this.Zi((n=>{this.Gi(n.json,n),this.Qi()}));this.Gi(t),this.Qi()}))}catch(t){ks.error("Error loading remote config",t),this.Gi()}}stop(){this.Ji&&(clearInterval(this.Ji),this.Ji=void 0)}refresh(){!this._instance.Ki()&&ke&&ke.visibilityState!=="hidden"&&this._instance.reloadFeatureFlags()}Qi(){var t;if(!this.Ji){var n=(t=this._instance.config.remote_config_refresh_interval_ms)!==null&&t!==void 0?t:3e5;n!==0&&(this.Ji=setInterval((()=>{this.refresh()}),n))}}Gi(t,n){!t&&n&&(n.statusCode===0?n.error||ks.warn("Failed to fetch remote config from PostHog."):ks.error("Failed to fetch remote config from PostHog."));try{this._instance.Gi(t?{ok:!0,config:t}:{ok:!1})}catch(a){ks.error("Error applying remote config",a)}if((t==null?void 0:t.hasFeatureFlags)!==!1&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var i;(i=this._instance.featureFlags)==null||i.ensureFlagsLoaded()}catch(a){ks.error("Error loading feature flags",a)}}}var Pr=Uint8Array,tr=Uint16Array,Rl=Uint32Array,lx=new Pr([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]),ox=new Pr([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]),Ey=new Pr([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ww=function(e,t){for(var n=new tr(31),i=0;31>i;++i)n[i]=t+=1<<e[i-1];var a=new Rl(n[30]);for(i=1;30>i;++i)for(var o=n[i];n[i+1]>o;++o)a[o]=o-n[i]<<5|i;return[n,a]},Qw=Ww(lx,2),_g=Qw[1];Qw[0][28]=258,_g[258]=28;for(var Ty=Ww(ox,0)[1],Xw=new tr(32768),Yt=0;32768>Yt;++Yt){var pl=(43690&Yt)>>>1|(21845&Yt)<<1;Xw[Yt]=((65280&(pl=(61680&(pl=(52428&pl)>>>2|(13107&pl)<<2))>>>4|(3855&pl)<<4))>>>8|(255&pl)<<8)>>>1}var dc=function(e,t,n){for(var i=e.length,a=0,o=new tr(t);i>a;++a)++o[e[a]-1];var u,f=new tr(t);for(a=0;t>a;++a)f[a]=f[a-1]+o[a-1]<<1;for(u=new tr(i),a=0;i>a;++a)u[a]=Xw[f[e[a]-1]++]>>>15-e[a];return u},ya=new Pr(288);for(Yt=0;144>Yt;++Yt)ya[Yt]=8;for(Yt=144;256>Yt;++Yt)ya[Yt]=9;for(Yt=256;280>Yt;++Yt)ya[Yt]=7;for(Yt=280;288>Yt;++Yt)ya[Yt]=8;var sf=new Pr(32);for(Yt=0;32>Yt;++Yt)sf[Yt]=5;var u4=dc(ya,9),d4=dc(sf,5),Kw=function(e){return(e/8>>0)+(7&e&&1)},Zw=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var i=new(e instanceof tr?tr:e instanceof Rl?Rl:Pr)(n-t);return i.set(e.subarray(t,n)),i},Mi=function(e,t,n){var i=t/8>>0;e[i]|=n<<=7&t,e[i+1]|=n>>>8},Uo=function(e,t,n){var i=t/8>>0;e[i]|=n<<=7&t,e[i+1]|=n>>>8,e[i+2]|=n>>>16},Jp=function(e,t){for(var n=[],i=0;e.length>i;++i)e[i]&&n.push({s:i,f:e[i]});var a=n.length,o=n.slice();if(!a)return[new Pr(0),0];if(a==1){var u=new Pr(n[0].s+1);return u[n[0].s]=1,[u,1]}n.sort((function(O,L){return O.f-L.f})),n.push({s:-1,f:25001});var f=n[0],h=n[1],p=0,g=1,x=2;for(n[0]={s:-1,f:f.f+h.f,l:f,r:h};g!=a-1;)f=n[n[x].f>n[p].f?p++:x++],h=n[p!=g&&n[x].f>n[p].f?p++:x++],n[g++]={s:-1,f:f.f+h.f,l:f,r:h};var b=o[0].s;for(i=1;a>i;++i)o[i].s>b&&(b=o[i].s);var y=new tr(b+1),_=wg(n[g-1],y,0);if(_>t){i=0;var j=0,C=_-t,k=1<<C;for(o.sort((function(O,L){return y[L.s]-y[O.s]||O.f-L.f}));a>i;++i){var E=o[i].s;if(t>=y[E])break;j+=k-(1<<_-y[E]),y[E]=t}for(j>>>=C;j>0;){var N=o[i].s;t>y[N]?j-=1<<t-y[N]++-1:++i}for(;i>=0&&j;--i){var D=o[i].s;y[D]==t&&(--y[D],++j)}_=t}return[new Pr(y),_]},wg=function(e,t,n){return e.s==-1?Math.max(wg(e.l,t,n+1),wg(e.r,t,n+1)):t[e.s]=n},Ay=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new tr(++t),i=0,a=e[0],o=1,u=function(h){n[i++]=h},f=1;t>=f;++f)if(e[f]==a&&f!=t)++o;else{if(!a&&o>2){for(;o>138;o-=138)u(32754);o>2&&(u(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(u(a),--o;o>6;o-=6)u(8304);o>2&&(u(o-3<<5|8208),o=0)}for(;o--;)u(a);o=1,a=e[f]}return[n.subarray(0,i),t]},Io=function(e,t){for(var n=0,i=0;t.length>i;++i)n+=e[i]*t[i];return n},Sg=function(e,t,n){var i=n.length,a=Kw(t+2);e[a]=255&i,e[a+1]=i>>>8,e[a+2]=255^e[a],e[a+3]=255^e[a+1];for(var o=0;i>o;++o)e[a+o+4]=n[o];return 8*(a+4+i)},My=function(e,t,n,i,a,o,u,f,h,p,g){Mi(t,g++,n),++a[256];for(var x=Jp(a,15),b=x[0],y=x[1],_=Jp(o,15),j=_[0],C=_[1],k=Ay(b),E=k[0],N=k[1],D=Ay(j),O=D[0],L=D[1],G=new tr(19),P=0;E.length>P;++P)G[31&E[P]]++;for(P=0;O.length>P;++P)G[31&O[P]]++;for(var Q=Jp(G,7),B=Q[0],I=Q[1],M=19;M>4&&!B[Ey[M-1]];--M);var le,J,Y,$,F=p+5<<3,V=Io(a,ya)+Io(o,sf)+u,ge=Io(a,b)+Io(o,j)+u+14+3*M+Io(G,B)+(2*G[16]+3*G[17]+7*G[18]);if(V>=F&&ge>=F)return Sg(t,g,e.subarray(h,h+p));if(Mi(t,g,1+(V>ge)),g+=2,V>ge){le=dc(b,y),J=b,Y=dc(j,C),$=j;var R=dc(B,I);for(Mi(t,g,N-257),Mi(t,g+5,L-1),Mi(t,g+10,M-4),g+=14,P=0;M>P;++P)Mi(t,g+3*P,B[Ey[P]]);g+=3*M;for(var z=[E,O],Z=0;2>Z;++Z){var A=z[Z];for(P=0;A.length>P;++P)Mi(t,g,R[ue=31&A[P]]),g+=B[ue],ue>15&&(Mi(t,g,A[P]>>>5&127),g+=A[P]>>>12)}}else le=u4,J=ya,Y=d4,$=sf;for(P=0;f>P;++P)if(i[P]>255){var ue;Uo(t,g,le[257+(ue=i[P]>>>18&31)]),g+=J[ue+257],ue>7&&(Mi(t,g,i[P]>>>23&31),g+=lx[ue]);var xe=31&i[P];Uo(t,g,Y[xe]),g+=$[xe],xe>3&&(Uo(t,g,i[P]>>>5&8191),g+=ox[xe])}else Uo(t,g,le[i[P]]),g+=J[i[P]];return Uo(t,g,le[256]),g+J[256]},f4=new Rl([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),h4=(function(){for(var e=new Rl(256),t=0;256>t;++t){for(var n=t,i=9;--i;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e})(),em=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function p4(e,t){t===void 0&&(t={});var n=(function(){var x=4294967295;return{p(b){for(var y=x,_=0;b.length>_;++_)y=h4[255&y^b[_]]^y>>>8;x=y},d(){return 4294967295^x}}})(),i=e.length;n.p(e);var a,o,u,f,h,p=(f=10+((a=t).filename&&a.filename.length+1||0),h=8,(function(x,b,y,_,j,C){var k=x.length,E=new Pr(_+k+5*(1+Math.floor(k/7e3))+j),N=E.subarray(_,E.length-j),D=0;if(!b||8>k)for(var O=0;k>=O;O+=65535){var L=O+65535;k>L?D=Sg(N,D,x.subarray(O,L)):(N[O]=!0,D=Sg(N,D,x.subarray(O,k)))}else{for(var G=f4[b-1],P=G>>>13,Q=8191&G,B=(1<<y)-1,I=new tr(32768),M=new tr(B+1),le=Math.ceil(y/3),J=2*le,Y=function(mt){return(x[mt]^x[mt+1]<<le^x[mt+2]<<J)&B},$=new Rl(25e3),F=new tr(288),V=new tr(32),ge=0,R=0,z=(O=0,0),Z=0,A=0;k>O;++O){var ue=Y(O),xe=32767&O,je=M[ue];if(I[xe]=je,M[ue]=xe,O>=Z){var Re=k-O;if((ge>7e3||z>24576)&&Re>423){D=My(x,N,0,$,F,V,R,z,A,O-A,D),z=ge=R=0,A=O;for(var Le=0;286>Le;++Le)F[Le]=0;for(Le=0;30>Le;++Le)V[Le]=0}var Be=2,Je=0,it=Q,ht=xe-je&32767;if(Re>2&&ue==Y(O-ht))for(var Jt=Math.min(P,Re)-1,pt=Math.min(32767,O),_t=Math.min(258,Re);pt>=ht&&--it&&xe!=je;){if(x[O+Be]==x[O+Be-ht]){for(var Nt=0;_t>Nt&&x[O+Nt]==x[O+Nt-ht];++Nt);if(Nt>Be){if(Be=Nt,Je=ht,Nt>Jt)break;var ve=Math.min(ht,Nt-2),Fe=0;for(Le=0;ve>Le;++Le){var ct=O-ht+Le+32768&32767,xn=ct-I[ct]+32768&32767;xn>Fe&&(Fe=xn,je=ct)}}}ht+=(xe=je)-(je=I[xe])+32768&32767}if(Je){$[z++]=268435456|_g[Be]<<18|Ty[Je];var Ne=31&_g[Be],ze=31&Ty[Je];R+=lx[Ne]+ox[ze],++F[257+Ne],++V[ze],Z=O+Be,++ge}else $[z++]=x[O],++F[x[O]]}}D=My(x,N,!0,$,F,V,R,z,A,O-A,D)}return Zw(E,0,_+Kw(D)+j)})(o=e,(u=t).level==null?6:u.level,u.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(o.length)))):12+u.mem,f,h)),g=p.length;return(function(x,b){var y=b.filename;if(x[0]=31,x[1]=139,x[2]=8,x[8]=2>b.level?4:b.level==9?2:0,x[9]=3,b.mtime!=0&&em(x,4,Math.floor(new Date(b.mtime||Date.now())/1e3)),y){x[3]=8;for(var _=0;y.length>=_;++_)x[_+10]=y.charCodeAt(_)}})(p,t),em(p,g-8,n.d()),em(p,g-4,i),p}var m4=!!Hm||!!Gg,Jw="text/plain",Md=!1,e2=(e,t)=>{var n=e.split("#"),i=n[1],a=n[0].split("?"),o=a[0],u=a[1];if(!u)return e;var f=u.split("&").filter((h=>h.split("=")[0]!==t)).join("&");return o+(f?"?"+f:"")+(i?"#"+i:"")},vf=function(e,t,n){var i;n===void 0&&(n=!0);var a=e.split("?"),o=a[0],u=a[1],f=he({},t),h=(i=u==null?void 0:u.split("&").map((g=>{var x,b=g.split("="),y=b[0],_=n&&(x=f[y])!==null&&x!==void 0?x:b[1];return delete f[y],y+"="+_})))!==null&&i!==void 0?i:[],p=(function(g,x){var b,y;x===void 0&&(x="&");var _=[];return Rt(g,(function(j,C){ye(j)||ye(C)||C==="undefined"||(b=encodeURIComponent((k=>k instanceof File)(j)?j.name:j.toString()),y=encodeURIComponent(C),_[_.length]=y+"="+b)})),_.join(x)})(f);return p&&h.push(p),h.length>0?o+"?"+h.join("&"):o},tm=e=>{if(e.Yi)return e.Yi;var t=e.data,n=e.compression;if(t){if(n===$n.GZipJS){var i=p4((function(f,h){var p=f.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(f);for(var g=new Pr(f.length+(f.length>>>1)),x=0,b=function(C){g[x++]=C},y=0;p>y;++y){if(x+5>g.length){var _=new Pr(x+8+(p-y<<1));_.set(g),g=_}var j=f.charCodeAt(y);128>j?b(j):2048>j?(b(192|j>>>6),b(128|63&j)):j>55295&&57344>j?(b(240|(j=65536+(1047552&j)|1023&f.charCodeAt(++y))>>>18),b(128|j>>>12&63),b(128|j>>>6&63),b(128|63&j)):(b(224|j>>>12),b(128|j>>>6&63),b(128|63&j))}return Zw(g,0,x)})(Sl(t)),{mtime:0});return{contentType:Jw,body:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),estimatedSize:i.byteLength}}if(n===$n.Base64){var a=(function(f){return f&&btoa(encodeURIComponent(f).replace(/%([0-9A-F]{2})/g,((h,p)=>String.fromCharCode(parseInt(p,16)))))})(Sl(t)),o=(f=>"data="+encodeURIComponent(typeof f=="string"?f:Sl(f)))(a);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var u=Sl(t);return{contentType:"application/json",body:u,estimatedSize:new Blob([u]).size}}},t2=e=>{var t,n,i=()=>e.transport==="sendBeacon"?{url:vf(e.url,{compression:$n.Base64}),encodedBody:tm(he({},e,{compression:$n.Base64,Yi:void 0}))}:{url:e2(e.url,"compression"),encodedBody:tm(he({},e,{compression:void 0,Yi:void 0}))};try{t=tm(e)}catch(a){if(Kb(e.compression,Al(e.url,"compression")))return we.error("Failed to gzip request body, sending uncompressed payload",a),i();throw a}return t&&Kb(e.compression,Al(e.url,"compression"))&&!((n=t.body)instanceof ArrayBuffer?qm(new Uint8Array(n)):ArrayBuffer.isView(n)&&qm(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)))?(Md=!0,i()):{url:e.url,encodedBody:t}},n2=e=>{try{return t2(e)}catch(t){return we.error(t),void(e.callback==null||e.callback({statusCode:0,error:t}))}},g4=(function(){var e=Ut((function*(t){var n=Sl(t.data),i=yield(function(o,u,f){return Vm.apply(this,arguments)})(n,jt.DEBUG,{rethrow:!0});if(!i)return t;var a=yield i.arrayBuffer();return he({},t,{Yi:{contentType:Jw,body:a,estimatedSize:a.byteLength}})}));return function(t){return e.apply(this,arguments)}})(),x4=/Failed to fetch|NetworkError|Load failed/i,r2=e=>(e==null?void 0:e.name)==="TypeError"&&x4.test((e==null?void 0:e.message)||""),i2=e=>{var t=n2(e);if(t){var n=t.url,i=t.encodedBody,a=i??{},o=a.contentType,u=a.body,f=a.estimatedSize,h=new Headers;Rt(e.headers,(function(_,j){h.append(j,_)})),o&&h.append("Content-Type",o);var p=null,g=!1;if(Vb){var x=new Vb;p={signal:x.signal,timeout:setTimeout((()=>{var _,j;g=!0,x.abort((_=e.timeout,(j=new Error("PostHog request timed out"+(_?" after "+_+"ms":""))).name="AbortError",j))}),e.timeout)}}var b=_=>{g&&(_==null?void 0:_.name)==="AbortError"||r2(_)?we.warn(_):we.error(_),e.callback==null||e.callback({statusCode:0,error:_})};try{var y;Gg(n,he({method:(e==null?void 0:e.method)||"GET",headers:h,keepalive:e.method==="POST"&&!e.Xi&&52428.8>(f||0),body:u,signal:(y=p)==null?void 0:y.signal},e.fetchOptions)).then((_=>_.text().then((j=>{var C={statusCode:_.status,text:j};if(_.status===200)try{C.json=JSON.parse(j)}catch(k){we.error(k)}e.callback==null||e.callback(C)})))).catch(b).finally((()=>p?clearTimeout(p.timeout):null))}catch(_){p&&clearTimeout(p.timeout),b(_)}}},kg=e=>{try{var t,n=t2(e),i=n.url,a=n.encodedBody,o=a??{},u=o.body,f=o.estimatedSize;if(!u)return;var h=u instanceof Blob?u:new Blob([u],{type:o.contentType});if(In.sendBeacon(i,h))return;var p=Ve(e.data)?e.data:(t=e.data)==null?void 0:t.batch;if(Ve(p)&&p.length>1&&(f??0)>16384){var g=Math.ceil(p.length/2),x=b=>Ve(e.data)?b:he({},e.data,{batch:b});return kg(he({},e,{data:x(p.slice(0,g))})),void kg(he({},e,{data:x(p.slice(g))}))}we.warn("Beacon of ~"+(f??0)+" bytes was rejected by the browser, falling back to fetch"),i2(he({},e,{Xi:!0}))}catch(b){we.warn("Beacon send failed",b)}},Ry=(e,t,n,i)=>{var a=i==="query"?t==="POST"?"sent_at":"_":void 0;return vf(n===$n.GZipJS?e2(e,"compression"):e,he({},a?{[a]:Date.now().toString()}:{},n===$n.GZipJS?{}:{compression:n}))},Rd=[];Gg&&Rd.push({transport:"fetch",method:i2}),Hm&&Rd.push({transport:"XHR",method(e){var t=n2(e);if(t){var n=new Hm,i=t.encodedBody;n.open(e.method||"GET",t.url,!0);var a=i??{},o=a.contentType,u=a.body;Rt(e.headers,(function(f,h){n.setRequestHeader(h,f)})),o&&n.setRequestHeader("Content-Type",o),e.timeout&&(n.timeout=e.timeout),n.onreadystatechange=()=>{if(n.readyState===4){var f={statusCode:n.status,text:n.responseText};if(n.status===200)try{f.json=JSON.parse(n.responseText)}catch{}e.callback==null||e.callback(f)}},n.send(u)}}}),In!=null&&In.sendBeacon&&Rd.push({transport:"sendBeacon",method:kg});var jg=3e3;class v4{constructor(t,n){this.tr=!0,this.er=[],this.ir=ui((n==null?void 0:n.flush_interval_ms)||jg,250,5e3,we.createLogger("flush interval"),jg),this.rr=t}enqueue(t){this.er.push(t),this.nr||this.sr()}unload(){this.ar();var t=this.er.length>0?this.lr():{},n=Object.values(t);[...n.filter((i=>i.url.indexOf("/e")===0)),...n.filter((i=>i.url.indexOf("/e")!==0))].map((i=>{this.ur(he({},i,{transport:"sendBeacon"}))}))}enable(){this.tr=!1,this.sr()}sr(){var t=this;this.tr||(this.nr=setTimeout((()=>{if(this.ar(),this.er.length>0){var n=this.lr(),i=function(){var o=n[a],u=new Date().getTime();o.data&&Ve(o.data)&&Rt(o.data,(f=>{f.offset=Math.abs(f.timestamp-u),delete f.timestamp})),t.ur(o)};for(var a in n)i()}}),this.ir))}ur(t){try{this.rr(t)}catch(n){we.error(n)}}ar(){clearTimeout(this.nr),this.nr=void 0}lr(){var t={};return Rt(this.er,(n=>{var i,a=n,o=(a?a.batchKey:null)||a.url;ye(t[o])&&(t[o]=he({},a,{data:[]})),(i=t[o].data)==null||i.push(a.data)})),this.er=[],t}}var b4=["retriesPerformedSoFar"];class y4{constructor(t){this.hr=!1,this.dr=3e3,this.er=[],this._instance=t,this.er=[],this.vr=!0,!ye(ie)&&"onLine"in ie.navigator&&(this.vr=ie.navigator.onLine,this.cr=()=>{this.vr=!0,this.pr()},this.gr=()=>{this.vr=!1},Gt(ie,"online",this.cr),Gt(ie,"offline",this.gr))}get length(){return this.er.length}retriableRequest(t){var n=t.retriesPerformedSoFar,i=R5(t,b4);zi(n)&&(i.url=vf(i.url,{retry_count:n})),this._instance._send_request(he({},i,{callback:a=>{if(a.statusCode!==200&&(400>a.statusCode||a.statusCode>=500)){if((a.statusCode===0?3:10)>(n??0))return void this.At(he({retriesPerformedSoFar:n},i));a.statusCode===0&&we.warn("Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after "+(n??0)+" retries.")}i.callback==null||i.callback(a)}}))}At(t){var n=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=n+1;var i=(function(u){var f=3e3*Math.pow(2,u),h=f/2,p=Math.min(18e5,f),g=Math.random()-.5;return Math.ceil(p+g*(p-h))})(n),a=Date.now()+i;this.er.push({retryAt:a,requestOptions:t});var o="Enqueued failed request for retry in "+i;navigator.onLine||(o+=" (Browser is offline)"),we.warn(o),this.hr||(this.hr=!0,this.mr())}mr(){if(this.yr&&clearTimeout(this.yr),this.er.length===0)return this.hr=!1,void(this.yr=void 0);this.yr=setTimeout((()=>{this.vr&&this.er.length>0&&this.pr(),this.mr()}),this.dr)}pr(){var t=Date.now(),n=[],i=this.er.filter((o=>t>o.retryAt||(n.push(o),!1)));if(this.er=n,i.length>0)for(var a of i)this.retriableRequest(a.requestOptions)}unload(){for(var t of(this.yr&&(clearTimeout(this.yr),this.yr=void 0),this.hr=!1,ye(ie)||(this.cr&&(ie.removeEventListener("online",this.cr),this.cr=void 0),this.gr&&(ie.removeEventListener("offline",this.gr),this.gr=void 0)),this.er)){var n=t.requestOptions;try{this._instance._send_request(he({},n,{transport:"sendBeacon"}))}catch(i){we.error(i)}}this.er=[]}}class _4{constructor(t){this.br=()=>{var n,i,a,o;this._r||(this._r={});var u=this.scrollElement(),f=this.scrollY(),h=u?Math.max(0,u.scrollHeight-u.clientHeight):0,p=f+((u==null?void 0:u.clientHeight)||0),g=(u==null?void 0:u.scrollHeight)||0;this._r.lastScrollY=Math.ceil(f),this._r.maxScrollY=Math.max(f,(n=this._r.maxScrollY)!==null&&n!==void 0?n:0),this._r.maxScrollHeight=Math.max(h,(i=this._r.maxScrollHeight)!==null&&i!==void 0?i:0),this._r.lastContentY=p,this._r.maxContentY=Math.max(p,(a=this._r.maxContentY)!==null&&a!==void 0?a:0),this._r.maxContentHeight=Math.max(g,(o=this._r.maxContentHeight)!==null&&o!==void 0?o:0)},this._instance=t}get wr(){return this._instance.config.scroll_root_selector}getContext(){return this._r}resetContext(){var t=this._r;return setTimeout(this.br,0),t}startMeasuringScrollPosition(){Gt(ie,"scroll",this.br,{capture:!0}),Gt(ie,"scrollend",this.br,{capture:!0}),Gt(ie,"resize",this.br)}scrollElement(){if(!this.wr)return ie==null?void 0:ie.document.documentElement;var t=Ve(this.wr)?this.wr:[this.wr];for(var n of t){var i=ie==null?void 0:ie.document.querySelector(n);if(i)return i}}kr(t){var n=t==="y"?"scrollTop":"scrollLeft";if(this.wr){var i=this.scrollElement();return i&&i[n]||0}return ie?t==="y"?ie.scrollY||ie.pageYOffset||ie.document.documentElement.scrollTop||0:ie.scrollX||ie.pageXOffset||ie.document.documentElement.scrollLeft||0:0}scrollY(){return this.kr("y")}scrollX(){return this.kr("x")}}var w4=e=>qw(e==null?void 0:e.config.mask_personal_data_properties,e==null?void 0:e.config.custom_personal_data_properties,e==null?void 0:e.config.disable_capture_url_hashes);class Ly{constructor(t,n,i,a){this.Sr=o=>{var u=this.Cr();if(!u||u.sessionId!==o){var f={sessionId:o,props:this.Mr(this._instance)};this.Tr.register({[fg]:f})}},this._instance=t,this.Er=n,this.Tr=i,this.Mr=a||w4,this.Er.onSessionId(this.Sr)}Cr(){return this.Tr.props[fg]}getSetOnceProps(){var t,n=(t=this.Cr())==null?void 0:t.props;return n?"r"in n?Vw(n,this._instance.config.disable_capture_url_hashes):{$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 t={};return Rt(rx(this.getSetOnceProps()),((n,i)=>{i==="$current_url"&&(i="url"),t["$session_entry_"+Gm(i)]=n})),t}}class cx{on(t,n){return this.Ir[t]||(this.Ir[t]=[]),this.Ir[t].push(n),()=>{this.Ir[t]=this.Ir[t].filter((i=>i!==n))}}emit(t,n){for(var i of this.Ir[t]||[])i(n);for(var a of this.Ir["*"]||[])a(t,n)}constructor(){this.Ir={}}}var Ho=Wt("[SessionId]");class Dy{on(t,n){return this.Pr.on(t,n)}constructor(t,n,i){var a;if(this.Rr=null,this.Ar=[],this.Fr=void 0,this.Lr=!1,this.Pr=new cx,this.Or=(p,g)=>!(!zi(p)||!zi(g))&&Math.abs(p-g)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(t.config.cookieless_mode===$i)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Ne=t.config,this.Tr=t.persistence,this.Dr=void 0,this.$r=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.Nr=n||Pi,this.qr=i||Pi;var o=this.Ne.persistence_name||this.Ne.token;if(this._sessionTimeoutMs=1e3*ui(this.Ne.session_idle_timeout_seconds||1800,60,36e3,Ho.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.jr(),this.Br="ph_"+o+"_window_id",this.Hr="ph_"+o+"_primary_window_exists",this.Ur()){var u=Zt.H(this.Br),f=Zt.H(this.Hr);u&&!f?this.Dr=u:Zt.q(this.Br),Zt.F(this.Hr,!0)}if((a=this.Ne.bootstrap)!=null&&a.sessionID)try{var h=(p=>{var g=this.Ne.bootstrap.sessionID.replace(/-/g,"");if(g.length!==32)throw new Error("Not a valid UUID");if(g[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(g.substring(0,12),16)})();this.zr(this.Ne.bootstrap.sessionID,new Date().getTime(),h)}catch(p){Ho.error("Invalid sessionID in bootstrap",p)}this.Wr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return ye(this.Ar)&&(this.Ar=[]),this.Ar.push(t),this.$r&&t(this.$r,this.Dr),()=>{this.Ar=this.Ar.filter((n=>n!==t))}}Ur(){return this.Ne.persistence!=="memory"&&!this.Tr.xi&&Zt.N()}Vr(t){t!==this.Dr&&(this.Dr=t,this.Ur()&&Zt.F(this.Br,t))}Zr(){return this.Dr?this.Dr:this.Ur()?Zt.H(this.Br):null}Gr(t){var n=this.Rr;return!Hn(n)&&!Hn(t)&&5e3>Math.abs(t-n)}zr(t,n,i){var a=n!==this._sessionActivityTimestamp,o=!(t!==this.$r||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=n,this.$r=t,o&&!a||o&&this.Gr(n)||(this.Rr=n,this.Tr.register({[wl]:[n,t,i]}))}Qr(){var t,n=(t=this.Ne)==null?void 0:t.persistence_save_debounce_ms;return zi(n)&&n>0}Kr(){this.Qr()?this.Tr.refreshKey(wl):(this.Tr.flush(),this.Tr.load())}Jr(){var t;if(!Hn(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.Rr){this.Kr();var n=this.Yr();n[1]===this.$r&&n[2]===this._sessionStartTimestamp&&(this.Rr=this._sessionActivityTimestamp,this.Tr.register({[wl]:[this._sessionActivityTimestamp,(t=this.$r)!==null&&t!==void 0?t:null,this._sessionStartTimestamp]}),this.Tr.flush())}}Xr(){var t=this.Yr()[0],n=zi(t)?t:0,i=zi(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(n,i)}tn(t){return this.Kr(),this.Or(t,this.Xr())}Yr(){var t=this.Tr.props[wl];return Ve(t)&&t.length===2&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.Rr=null,clearTimeout(this.en),this.en=void 0,this.zr(null,null,null)}destroy(){this.Lr=!0,this.Jr(),clearTimeout(this.en),this.en=void 0,this.Fr&&ie&&(ie.removeEventListener(Zd,this.Fr,{capture:!1}),this.Fr=void 0),this.Ar=[]}Wr(){this.Fr=()=>{this.Jr(),this.Ur()&&Zt.q(this.Hr)},Gt(ie,Zd,this.Fr,{capture:!1})}checkAndGetSessionAndWindowId(t,n){if(t===void 0&&(t=!1),n===void 0&&(n=null),this.Ne.cookieless_mode===$i)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=n||new Date().getTime(),a=this.Yr(),o=a[1],u=a[2],f=this.Xr(),h=this.Zr(),p=zi(u)&&Math.abs(i-u)>864e5,g=!1,x=!1,b=!o,y=o,_=!b&&!t&&this.Or(i,f);if(_){(_=this.tn(i))||Ho.info("cross-tab refresh kept the session alive",{sessionId:o});var j=this.Yr();o=j[1],u=j[2]}b||_||p?(o=this.Nr(),h=this.qr(),Ho.info("new session ID generated",{sessionId:o,windowId:h,changeReason:{noSessionId:b,activityTimeout:_,sessionPastMaximumLength:p}}),u=i,g=!0):(h||(h=this.qr(),g=!0),(x=o!==y)&&(Ho.info("adopted cross-tab session id",{sessionId:o,windowId:h}),g=!0));var C=zi(f)&&t&&!p?f:i,k=zi(u)?u:new Date().getTime();this.Vr(h),this.zr(o,C,k),t||this.jr();var E={noSessionId:b,activityTimeout:_,sessionPastMaximumLength:p,crossTabAdoption:x};return g&&this.Ar.forEach((N=>N(o,h,E))),{sessionId:o,windowId:h,sessionStartTimestamp:k,changeReason:g?E:void 0,lastActivityTimestamp:f}}jr(){this.Lr||(clearTimeout(this.en),this.en=setTimeout((()=>{if(!this.Lr)if(this.tn(new Date().getTime())){var t=this.$r;this.resetSessionId(),this.Pr.emit("forcedIdleReset",{idleSessionId:t})}else this.jr()}),1.1*this.sessionTimeoutMs))}}var s2=function(e,t){if(!e)return!1;var n=e.userAgent;if(n&&Jb(n,t))return!0;try{var i=e==null?void 0:e.userAgentData;if(i!=null&&i.brands&&i.brands.some((a=>Jb(a==null?void 0:a.brand,t))))return!0}catch{}return!!e.webdriver};function a2(){return(a2=Ut((function*(){var e=In==null?void 0:In.userAgentData;if(e!=null&&e.getHighEntropyValues)try{var t=yield e.getHighEntropyValues(["model"]),n=t==null?void 0:t.model;return vt(n)&&n.length>0?n:void 0}catch(i){return void we.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",i)}}))).apply(this,arguments)}var af=function(e,t){if(!(function(n){try{new RegExp(n)}catch{return!1}return!0})(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}};function nm(e,t,n){return Sl({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}var l2={exact:(e,t)=>t.some((n=>e.some((i=>n===i)))),is_not:(e,t)=>t.every((n=>e.every((i=>n!==i)))),regex:(e,t)=>t.some((n=>e.some((i=>af(n,i))))),not_regex:(e,t)=>t.every((n=>e.every((i=>!af(n,i))))),icontains:(e,t)=>t.map(fd).some((n=>e.map(fd).some((i=>n.includes(i))))),not_icontains:(e,t)=>t.map(fd).every((n=>e.map(fd).every((i=>!n.includes(i))))),gt:(e,t)=>t.some((n=>{var i=parseFloat(n);return!isNaN(i)&&e.some((a=>i>parseFloat(a)))})),lt:(e,t)=>t.some((n=>{var i=parseFloat(n);return!isNaN(i)&&e.some((a=>i<parseFloat(a)))}))},fd=e=>e.toLowerCase();function o2(e,t){return!e||Object.entries(e).every((n=>{var i=n[1],a=t==null?void 0:t[n[0]];if(ye(a)||Hn(a))return!1;var o=[String(a)],u=l2[i.operator];return!!u&&u(i.values,o)}))}var Ng="custom",zy="i.posthog.com",S4=/^\/static\//;class k4{constructor(t){this.rn={},this.instance=t}get apiHost(){var t=this.instance.config.api_host.trim().replace(/\/$/,"");return t==="https://app.posthog.com"?"https://us.i.posthog.com":t}get flagsApiHost(){var t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t,n=(t=this.instance.config.ui_host)==null?void 0:t.replace(/\/$/,"");return n||(n=this.apiHost.replace("."+zy,".posthog.com")),n==="https://app.posthog.com"?"https://us.posthog.com":n}get region(){return this.rn[this.apiHost]||(this.rn[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"us":/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"eu":Ng),this.rn[this.apiHost]}nn(t){if(S4.test(t)){var n=this.instance.config.asset_host;if(typeof n=="string")return n.trim().replace(/\/$/,"")||void 0}}endpointFor(t,n){if(n===void 0&&(n=""),n&&(n=n[0]==="/"?n:"/"+n),t==="ui")return this.uiHost+n;if(t==="flags")return this.flagsApiHost+n;if(t==="assets"){var i=this.nn(n);if(i)return""+i+n}if(this.region===Ng)return this.apiHost+n;var a=zy+n;switch(t){case"assets":return"https://"+this.region+"-assets."+a;case"api":return"https://"+this.region+"."+a}}}function c2(e){var t;return!((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null||!t.length)}var kt=Wt("[Surveys]"),u2="seenSurvey_",d2=e=>{try{var t=(n=>((i,a)=>""+u2+(function(o){return o.current_iteration&&o.current_iteration>0?o.id+"_"+o.current_iteration:o.id})(a))(0,n))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(n){kt.error("Failed to persist survey seen state",n)}},j4=[Kp.Popover,Kp.Widget,Kp.API],N4={ignoreConditions:!1,ignoreDelay:!1,displayType:yg.Popover},C4=Wt("[PostHog ExternalIntegrations]"),E4={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class T4{constructor(t){this._instance=t}ai(t,n){var i;(i=Oe.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,t,(a=>{if(a)return C4.error("failed to load script",a);n()}))}startIfEnabledOrStop(){var t=this,n=function(){var o,u,f,h=i[0],p=i[1];!p||(o=Oe.__PosthogExtensions__)!=null&&(o=o.integrations)!=null&&o[h]||t.ai(E4[h],(()=>{var g;(g=Oe.__PosthogExtensions__)==null||(g=g.integrations)==null||(g=g[h])==null||g.start(t._instance)})),!p&&(u=Oe.__PosthogExtensions__)!=null&&(u=u.integrations)!=null&&u[h]&&((f=Oe.__PosthogExtensions__)==null||(f=f.integrations)==null||(f=f[h])==null||f.stop())};for(var i of Object.entries((a=this._instance.config.integrations)!==null&&a!==void 0?a:{})){var a;n()}}}class A4{constructor(t,n){this.rt=t,this.sn=n,this.an=new Map,this.ln=!1}add(t){var n=this;return Ut((function*(){if(n.ln)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(n.an.has(t.name))throw new Error('Browser extension "'+t.name+'" is already registered');n.an.set(t.name,t);try{var i=t.setup(n.sn);i&&(yield i)}catch(o){var a=n.an.get(t.name)===t;a&&n.an.delete(t.name),n.rt.error('Failed to set up browser extension "'+t.name+'"',o),a&&n.un(t)}}))()}dispose(){if(!this.ln){this.ln=!0;var t=Array.from(this.an.values()).reverse();for(var n of(this.an.clear(),t))this.un(n)}}un(t){try{var n=t.dispose==null?void 0:t.dispose();n&&pr(n.then)&&n.then(void 0,(i=>{this.rt.error('Failed to dispose browser extension "'+t.name+'"',i)}))}catch(i){this.rt.error('Failed to dispose browser extension "'+t.name+'"',i)}}}class M4{constructor(t){this._instance=t}get(t){var n;return(n=this._instance.persistence)==null?void 0:n.get_property(t)}set(t,n){var i;(i=this._instance.persistence)==null||i.set_property(t,n)}remove(t){var n;(n=this._instance.persistence)==null||n.unregister(t)}}var Oy="extensionsRemoteConfig";class R4{constructor(t){this.ln=!1,this.instance=t,this.rt=we.createLogger("[BrowserExtensions]"),this.hn=t.dn,this.kv=new M4(t),this.onEvent=n=>dd(this.instance.on("eventCaptured",(i=>{try{n({event:i.event,properties:i.properties})}catch(a){this.rt.error("Browser extension event listener failed",a)}}))),this.onRemoteConfig=n=>{if(this.ln)return dd((()=>{}));var i=o=>{try{n(o)}catch(u){this.rt.error("Browser extension remote config listener failed",u)}},a=this.instance.vn.on(Oy,i);return this.hn&&i(this.hn),dd(a)},this.cn=new A4(this.rt,this)}get logger(){return this.rt}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return(t=this.instance.get_property(wc))!==null&&t!==void 0?t:this.distinctId}get groups(){return this.instance.getGroups()}get session(){try{var t,n,i,a,o=(t=this.instance.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0);return{sessionId:(n=o==null?void 0:o.sessionId)!==null&&n!==void 0?n:"",windowId:(i=o==null?void 0:o.windowId)!==null&&i!==void 0?i:"",sessionStartTimestamp:(a=o==null?void 0:o.sessionStartTimestamp)!==null&&a!==void 0?a:0}}catch{return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get projectToken(){return this.instance.config.token}add(t){return this.cn.add(t)}capture(t,n,i){var a=this;return Ut((function*(){i?a.instance.capture(t,n,{timestamp:i.timestamp,uuid:i.uuid,$set:i.set,$set_once:i.setOnce}):a.instance.capture(t,n)}))()}registerDynamicEventProperties(t){return dd(this.instance.fn(t))}handleRemoteConfig(t){this.ln||(this.hn=t,this.instance.vn.emit(Oy,t))}sendRequest(t,n){var i=this;return Ut((function*(){var a;n===void 0&&(n={});var o=i.instance.requestRouter.endpointFor((a=n.target)!==null&&a!==void 0?a:"api",t),u={method:n.method,url:n.query?vf(o,n.query):o,data:n.body,headers:n.headers,timeout:n.timeoutMs,fireCallbackOnDrop:!0,transport:n.transport};return n.transport==="sendBeacon"?(i.instance._send_request(u),{statusCode:202}):new Promise((f=>{u.callback=f,i.instance._send_request(u)}))}))()}dispose(){this.ln||(this.ln=!0,this.cn.dispose())}}var fc={},rm=0,lf=()=>{},By='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',qo="Surveys module not available",Py="sanitize_properties is deprecated. Use before_send instead",f2="Invalid value for property_denylist config: ",L4=["token","distinct_id",bw],yl="posthog",h2=!m4&&(er==null?void 0:er.indexOf("MSIE"))===-1&&(er==null?void 0:er.indexOf("Mozilla"))===-1,im=e=>{var t;return he({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:D3(ke==null?void 0:ke.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:lf,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:e??"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:Vt&&vt(Vt==null?void 0:Vt.search)&&Vt.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,disableDeviceModel:!1,disable_external_dependency_loading:!1,strict_script_versioning:!1,enable_recording_console_log:void 0,secure_cookie:(ie==null||(t=ie.location)==null?void 0:t.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){we.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:gg,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:jg},error_tracking:{},_onCapture:lf},(n=>({rageclick:n&&n>="2026-05-30"?{content_ignorelist:G3,ignore_text_selection:!0}:!n||"2025-11-30">n||{content_ignorelist:!0},capture_pageview:!n||"2025-05-24">n||"history_change",session_recording:n&&n>="2026-06-25"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6},streamNetworkBody:!0}:n&&n>="2026-05-30"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6}}: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,persistence_save_debounce_ms:n&&n>="2026-05-30"?250:0,split_storage:!(!n||"2026-05-30">n),detect_google_search_app:!(!n||"2026-05-30">n),disable_capture_url_hashes:!(!n||"2026-06-25">n)}))(e))},D4=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["__preview_disable_beacon","disable_beacon"],["store_google","save_campaign_params"],["verbose","debug"]],$y=e=>{var t={};for(var n of D4){var i=n[0],a=n[1];ye(e[i])||(t[a]=e[i])}var o=Ot({},t,e),u=e.__preview_external_dependency_versioned_paths;return ye(u)||(ye(e.strict_script_versioning)&&(o.strict_script_versioning=!!u),vt(u)&&ye(e.asset_host)&&(o.asset_host=u)),Ve(e.property_blacklist)&&(ye(e.property_denylist)?o.property_denylist=e.property_blacklist:Ve(e.property_denylist)?o.property_denylist=[...e.property_blacklist,...e.property_denylist]:we.error(f2+e.property_denylist)),o};class z4{constructor(){this.__forceAllowLocalhost=!1}get pn(){return this.__forceAllowLocalhost}set pn(t){we.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}}class Or{gn(t,n){if(t){var i=this.an.indexOf(t);i!==-1&&this.an.splice(i,1)}return this.an.push(n),n.initialize==null||n.initialize(),n}mn(){return this.config.cookieless_mode===$i||this.config.cookieless_mode===pa&&this.consent.isRejected()}get decideEndpointWasHit(){var t,n;return(t=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&t!==void 0&&t}get flagsEndpointWasHit(){var t,n;return(t=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&t!==void 0&&t}constructor(){var t;this.webPerformance=new z4,this.yn=!1,this.version=jt.LIB_VERSION,this.bn=new Set,this._n="",this.vn=new cx,this.an=[],this.wn=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=im(),this.SentryIntegration=e4,this.sentryIntegration=i=>(function(a,o){var u=Bw(a,o);return{name:Ow,processEvent:f=>u(f)}})(this,i),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.kn=!1,this.xn=null,this.Sn=null,this.Cn=null,this.scrollManager=new _4(this),this.pageViewManager=new ky(this),this.rateLimiter=new c4(this),this.requestRouter=new k4(this),this.consent=new U3(this),this.externalIntegrations=new T4(this);var n=(t=Or.__defaultExtensionClasses)!==null&&t!==void 0?t:{};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.metrics=n.metrics&&new n.metrics(this),this.experiments=n.experiments&&new n.experiments(this),this.exceptions=n.exceptions&&new n.exceptions(this),this.people={set:(i,a,o)=>{var u=vt(i)?{[i]:a}:i;this.setPersonProperties(u),o==null||o({})},set_once:(i,a,o)=>{var u=vt(i)?{[i]:a}:i;this.setPersonProperties(void 0,u),o==null||o({})}},this.on("eventCaptured",(i=>we.info('send "'+(i==null?void 0:i.event)+'"',i)))}init(t,n,i){if(i&&i!==yl){var a,o=(a=fc[i])!==null&&a!==void 0?a:new Or;return o._init(t,n,i),fc[i]=o,fc[yl][i]=o,o}return this._init(t,n,i)}_init(t,n,i){var a,o;n===void 0&&(n={});var u,f=vt(t)?t.trim():"";if(!f)return we.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 f!==((u=this.config)==null?void 0:u.token)?console.warn("[PostHog.js]","You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('"+f+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=im(n.defaults),n.debug=this.Mn(n.debug),this.Tn=n,this.En=[],n.person_profiles?this.Sn=n.person_profiles:n.process_person&&(this.Sn=n.process_person);var h=im(n.defaults),p=$y(n),g=Ot({},h,p,{name:i,token:f});Bt(h.rageclick)&&Bt(p.rageclick)&&(g.rageclick=Ot({},h.rageclick,p.rageclick)),Bt(h.session_recording)&&Bt(p.session_recording)&&(g.session_recording=Ot({},h.session_recording,p.session_recording)),this.set_config(g),this.config.on_xhr_error&&we.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:$n.GZipJS;var x=this.In();if(this.persistence=new Xp(this.config,x),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Xp(he({},this.config,{persistence:"sessionStorage"}),x,!1),this._n="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!x&&Zt.N()){var b=Zt.H(this._n);Ve(b)&&b.forEach((L=>{vt(L)&&this.bn.add(L)}))}else Zt.q(this._n);var y=he({},this.persistence.props),_=he({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Pn=new v4((L=>this.Rn(L)),this.config.request_queue_config),this.An=new y4(this),this.__request_queue=[];var j=this.mn();if(j||(this.sessionManager=new Dy(this),this.sessionPropsManager=new Ly(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId(((L,G,P)=>{(P!=null&&P.activityTimeout||P!=null&&P.sessionPastMaximumLength||P!=null&&P.crossTabAdoption)&&this.Fn()}))),this.config.__preview_deferred_init_extensions?(we.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.Ln(j)}),0)):(we.info("Initializing extensions synchronously"),this.Ln(j)),jt.DEBUG=jt.DEBUG||this.config.debug,jt.DEBUG&&we.info("Starting in debug mode",{this:this,config:n,thisC:he({},this.config),p:y,s:_}),!this.config.identity_distinct_id||(a=n.bootstrap)!=null&&a.distinctID||(n.bootstrap=he({},n.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),((o=n.bootstrap)==null?void 0:o.distinctID)!==void 0){var C=n.bootstrap.distinctID,k=this.get_distinct_id(),E=this.persistence.get_property(zr);if(n.bootstrap.isIdentifiedID&&k!=null&&k!==C&&E===fl)this.identify(C);else if(n.bootstrap.isIdentifiedID&&k!=null&&k!==C&&E===ia)we.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 N=this.config.get_device_id(Pi()),D=n.bootstrap.isIdentifiedID?N:C;this.persistence.set_property(zr,n.bootstrap.isIdentifiedID?ia:fl),this.register({distinct_id:C,$device_id:D})}}if(j)this.register_once({distinct_id:ad,$device_id:null},"");else if(!this.get_distinct_id()){var O=this.config.get_device_id(Pi());this.register_once({distinct_id:O,$device_id:O},""),this.persistence.set_property(zr,fl)}return Gt(ie,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),n.segment?(function(L,G){var P=L.config.segment;if(!P)return G();(function(Q,B){var I=Q.config.segment;if(!I)return B();var M=J=>{var Y=()=>J.anonymousId()||Pi();Q.config.get_device_id=Y,J.id()&&(Q.register({distinct_id:J.id(),$device_id:Y()}),Q.persistence.set_property(zr,ia)),B()},le=I.user();"then"in le&&pr(le.then)?le.then(M):M(le)})(L,(()=>{P.register((Q=>{typeof Promise<"u"&&Promise.resolve||Wp.warn("This browser does not have Promise support, and can not use the segment integration");var B=(I,M)=>{if(!M)return I;I.event.userId||I.event.anonymousId===Q.get_distinct_id()||(Wp.info("No userId set, resetting PostHog"),Q.reset()),I.event.userId&&I.event.userId!==Q.get_distinct_id()&&(Wp.info("UserId set, identifying with PostHog"),Q.identify(I.event.userId));var le=Q.calculateEventProperties(M,I.event.properties);return I.event.properties=Object.assign({},le,I.event.properties),I};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:I=>B(I,I.event.event),page:I=>B(I,bl),identify:I=>B(I,Vp),screen:I=>B(I,"$screen")}})(L)).then((()=>{G()}))}))})(this,(()=>this.On())):this.On(),pr(this.config._onCapture)&&this.config._onCapture!==lf&&(we.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(L=>this.config._onCapture(L.event,L)))),this.config.ip&&we.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this.config.disableDeviceModel||(function(){return a2.apply(this,arguments)})().then((L=>{L&&this.register({[Hp]:L})})).catch(lf),this}Ln(t){var n,i,a,o,u,f,h,p,g=performance.now(),x=he({},Or.__defaultExtensionClasses,this.config.__extensionClasses),b=[];x.featureFlags&&this.an.push(this.featureFlags=(n=this.featureFlags)!==null&&n!==void 0?n:new x.featureFlags(this)),x.exceptions&&this.an.push(this.exceptions=(i=this.exceptions)!==null&&i!==void 0?i:new x.exceptions(this)),x.historyAutocapture&&this.an.push(this.historyAutocapture=new x.historyAutocapture(this)),x.tracingHeaders&&this.an.push(this.tracingHeaders=new x.tracingHeaders(this)),x.siteApps&&this.an.push(this.siteApps=new x.siteApps(this)),x.sessionRecording&&!t&&this.an.push(this.sessionRecording=new x.sessionRecording(this)),this.config.disable_scroll_properties||b.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),x.autocapture&&this.an.push(this.autocapture=new x.autocapture(this)),x.surveys&&this.an.push(this.surveys=(a=this.surveys)!==null&&a!==void 0?a:new x.surveys(this)),x.logs&&this.an.push(this.logs=(o=this.logs)!==null&&o!==void 0?o:new x.logs(this)),x.metrics&&this.an.push(this.metrics=(u=this.metrics)!==null&&u!==void 0?u:new x.metrics(this)),x.conversations&&this.an.push(this.conversations=(f=this.conversations)!==null&&f!==void 0?f:new x.conversations(this)),x.productTours&&this.an.push(this.productTours=new x.productTours(this)),x.heatmaps&&this.an.push(this.heatmaps=new x.heatmaps(this)),x.webVitalsAutocapture&&this.an.push(this.webVitalsAutocapture=new x.webVitalsAutocapture(this)),x.exceptionObserver&&this.an.push(this.exceptionObserver=new x.exceptionObserver(this)),x.deadClicksAutocapture&&this.an.push(this.deadClicksAutocapture=new x.deadClicksAutocapture(this,J3)),x.toolbar&&this.an.push(this.toolbar=(h=this.toolbar)!==null&&h!==void 0?h:new x.toolbar(this)),x.experiments&&this.an.push(this.experiments=(p=this.experiments)!==null&&p!==void 0?p:new x.experiments(this)),this.an.forEach((y=>{y.initialize&&b.push((()=>{y.initialize==null||y.initialize()}))})),b.push((()=>{if(this.Dn){var y=this.Dn;this.Dn=void 0,this.an.forEach((_=>_.onRemoteConfig==null?void 0:_.onRemoteConfig(y)))}})),this.$n(b,g)}$n(t,n){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-n>=30&&t.length>0)return void setTimeout((()=>{this.$n(t,n)}),0);var i=t.shift();if(i)try{i()}catch(o){we.error("Error initializing extension:",o)}}var a=Math.round(performance.now()-n);this.register_for_session({[yw]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[_w]:a}),this.config.__preview_deferred_init_extensions&&we.info("PostHog extensions initialized ("+a+"ms)")}Gi(t){var n;if(!ke||!ke.body)return we.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Gi(t)}),500);if(this.config.__preview_deferred_init_extensions&&(this.Dn=t),this.dn=t,this.compression=void 0,t.ok){var i,a=t.config;a.supportedCompression&&!this.config.disable_compression&&(this.compression=qe(a.supportedCompression,$n.GZipJS)?$n.GZipJS:qe(a.supportedCompression,$n.Base64)?$n.Base64:void 0),(i=a.analytics)!=null&&i.endpoint&&(this.analyticsDefaultEndpoint=a.analytics.endpoint)}this.set_config({person_profiles:this.Sn?this.Sn:gg}),(n=this.Nn)==null||n.handleRemoteConfig(t),this.an.forEach((o=>o.onRemoteConfig==null?void 0:o.onRemoteConfig(t)))}On(){try{this.config.loaded(this)}catch(i){we.critical("`loaded` function failed",i)}if(this.qn(),this.config.internal_or_test_user_hostname&&Vt!=null&&Vt.hostname){var t=Vt.hostname,n=this.config.internal_or_test_user_hostname;(typeof n=="string"?t===n:n.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.mn())&&this.jn()}),1),this.Bn=new Yw(this),this.Bn.load()}qn(){var t;this.is_capturing()&&this.config.request_batching&&((t=this.Pn)==null||t.enable())}_dom_loaded(){this.is_capturing()&&ld(this.__request_queue,(t=>this.Rn(t))),this.__request_queue=[],this.qn()}_handle_unload(){var t,n,i,a,o;(t=this.surveys)==null||t.handlePageUnload==null||t.handlePageUnload(),(n=this.metrics)==null||n.flush("sendBeacon"),this.config.request_batching?(this.Hn()&&this.capture(qp),(i=this.logs)==null||i.flushLogs("sendBeacon"),(a=this.Pn)==null||a.unload(),(o=this.An)==null||o.unload()):this.Hn()&&this.capture(qp,null,{transport:"sendBeacon"})}_send_request(t){this.__loaded?h2?this.__request_queue.push(t):this.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(t.callback==null||t.callback({statusCode:429})):(t.transport=t.transport||this.config.api_transport,t.headers=he({},this.config.request_headers,t.headers),t.compression=t.compression==="best-available"?this.compression:t.compression,(ye(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||this.config.fetch_options,(n=>{var i,a,o,u=he({},n);u.timeout=u.timeout||6e4;var f,h,p,g,x,b=(i=u.transport)!==null&&i!==void 0?i:"fetch";b==="sendBeacon"&&ye(u.compression)&&u.data&&(u.compression=$n.Base64),u.method==="POST"&&u.data&&(u.timestampMode==="capture-body"?u.data={api_key:(h=(x=(g=Ve(f=u.data)?f:[f])[0])==null||(p=x.properties)==null?void 0:p.token)!==null&&h!==void 0?h:x==null?void 0:x.token,batch:g,sent_at:new Date().toISOString()}:u.timestampMode==="body"&&(u.data=(function(C,k){return k===void 0&&(k=new Date().toISOString()),Ve(C)?C.map((E=>he({},E,{sent_at:k}))):he({},C,{sent_at:k})})(u.data))),u.url=Ry(u.url,u.method,u.compression,u.timestampMode);var y=Rd.filter((C=>!u.disableTransport||!C.transport||!u.disableTransport.includes(C.transport))),_=(a=(o=(function(C,k){for(var E=0;C.length>E;E++)if(C[E].transport===b)return C[E]})(y))==null?void 0:o.method)!==null&&a!==void 0?a:y[0].method;if(!_)throw new Error("No available transport method");var j=C=>{try{_(C)}catch(k){r2(k)?we.warn(k):we.error(k),u.callback==null||u.callback({statusCode:0,error:k})}};b!=="sendBeacon"&&u.data&&u.compression===$n.GZipJS&&OC&&typeof Promise<"u"&&!Md?g4(u).then((C=>{j(C)})).catch((C=>{if(Zb(C))return Md=!0,void j(he({},u,{compression:void 0,url:Ry(n.url,n.method,void 0,n.timestampMode)}));(k=>{if(!k||typeof k!="object")return!1;var E="name"in k?String(k.name):"";return Zb(k)||E===L5})(C)&&(Md=!0),j(u)})):_(u)})(he({},t,{callback:n=>{var i,a;this.rateLimiter.checkForLimiting(n),400>n.statusCode||(i=(a=this.config).on_request_error)==null||i.call(a,n),t.callback==null||t.callback(n)}}))):t.fireCallbackOnDrop&&(t.callback==null||t.callback({statusCode:0}))}Rn(t){this.An?this.An.retriableRequest(t):this._send_request(t)}_execute_array(t){rm++;try{var n,i=[],a=[],o=[];ld(t,(f=>{if(f)if(Ve(n=f[0]))o.push(f);else if(pr(f))try{f.call(this)}catch(h){we.error("Error executing queued PostHog call",f,h)}else Ve(f)&&n==="alias"?i.push(f):Ve(f)&&n.indexOf("capture")!==-1&&pr(this[n])?o.push(f):a.push(f)}));var u=function(f,h){ld(f,(function(p){try{if(Ve(p[0])){var g=h;Rt(p,(function(x){g=g[x[0]].apply(g,x.slice(1))}))}else h[p[0]].apply(h,p.slice(1))}catch(x){we.error("Error executing queued PostHog call",p,x)}}))};u(i,this),u(a,this),u(o,this)}finally{rm--}}push(t){if(rm>0&&Ve(t)&&vt(t[0])){var n=Or.prototype[t[0]];pr(n)&&n.apply(this,t.slice(1))}else this._execute_array([t])}capture(t,n,i){var a,o,u,f,h,p,g;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Pn){if(this.is_capturing())if(!ye(t)&&vt(t)){var x=!this.config.opt_out_useragent_filter&&this._is_bot();if(!x||this.config.__preview_capture_bot_pageviews){var b=i!=null&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(b==null||!b.isRateLimited){if(this.wn.length>0){var y={};for(var _ of this.wn.slice())try{Ot(y,_())}catch(R){we.error("Failed to produce browser extension event properties",R)}n=he({},y,n??{})}var j;(a=n)!=null&&a.$current_url&&!vt((o=n)==null?void 0:o.$current_url)&&(we.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),(j=n)==null||delete j.$current_url),t!=="$exception"||i!=null&&i.Un||we.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 C=new Date,k=(i==null?void 0:i.timestamp)||C,E=ry(i==null?void 0:i.uuid,Pi),N={uuid:E,event:t,properties:this.calculateEventProperties(t,n||{},k,E)};t===bl&&this.config.__preview_capture_bot_pageviews&&x&&(N.event="$bot_pageview",N.properties.$browser_type="bot"),b&&(N.properties.$lib_rate_limit_remaining_tokens=b.remainingTokens);var D=t==="$feature_flag_called"&&N.properties.$feature_flag_has_experiment===!1&&this.get_property(Yd)===!0;i!=null&&i.$set&&!D&&(N.$set=i==null?void 0:i.$set);var O=i==null?void 0:i.$unset;O&&(N.$unset=O);var L,G,P,Q=D?void 0:this.zn(i==null?void 0:i.$set_once,t!==cy,t===Vp);if(Q&&(N.$set_once=Q),i!=null&&i._noTruncate||(f=this.config.properties_string_max_length,h=N,p=R=>vt(R)?R.slice(0,f):R,g=new Set,N=(function R(z,Z){if(z!==Object(z))return p?p(z):z;if(!g.has(z)){var A;if(g.add(z),Ve(z))A=[],ld(z,(xe=>{A.push(R(xe))}));else{var ue={};Rt(z,((xe,je)=>{g.has(xe)||(ue[je]=R(xe))})),A=ue}return A}})(h)),N.timestamp=k,ye(i==null?void 0:i.timestamp)||(N.properties.$event_time_override_provided=!0,N.properties.$event_time_override_system_time=C),D&&(N.properties=(function(R,z){z===void 0&&(z=[]);var Z={},A=ue=>{R[ue]!==void 0&&(Z[ue]=R[ue])};return BC.forEach(A),z.forEach(A),Z})(N.properties,L4)),t===Ui.DISMISSED||t===Ui.SENT){var B,I,M=(B=n)==null?void 0:B[Zp.SURVEY_ID],le=(I=n)==null?void 0:I[Zp.SURVEY_ITERATION];d2({id:M,current_iteration:le}),N.$set=he({},N.$set,{[(L={id:M,current_iteration:le},G=t===Ui.SENT?"responded":"dismissed",P="$survey_"+G+"/"+L.id,L.current_iteration&&L.current_iteration>0&&(P="$survey_"+G+"/"+L.id+"/"+L.current_iteration),P)]:!0})}else t===Ui.SHOWN&&(N.$set=he({},N.$set,{[Zp.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(t===o4.SHOWN){var J,Y=(J=n)==null?void 0:J[Ny.TOUR_TYPE];Y&&(N.$set=he({},N.$set,{[Ny.TOUR_LAST_SEEN_DATE+"/"+Y]:new Date().toISOString()}))}var $=he({},N.properties.$set,N.$set);if(Ii($)||this.setPersonPropertiesForFlags($),!Ye(this.config.before_send)){var F=this.Pt(N);if(!F)return;(N=F).uuid=ry(N.uuid,Pi)}this.vn.emit("eventCaptured",N);var V=(u=i==null?void 0:i._url)!==null&&u!==void 0?u:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),ge={method:"POST",url:V,data:N,compression:"best-available",timestampMode:(i==null?void 0:i._batchKey)==="recordings"||/\/s\/(?:\?|$)/.test(V)?"body":"capture-body",batchKey:i==null?void 0:i._batchKey,transport:i==null?void 0:i.transport};return!this.config.request_batching||i&&(i==null||!i._batchKey)||i!=null&&i.send_instantly?this.Rn(ge):this.Pn.enqueue(ge),N}we.critical("This capture call is ignored due to client rate limiting.")}}else we.error("No event name provided to posthog.capture")}else we.uninitializedWarning("posthog.capture")}_addCaptureHook(t){return this.on("eventCaptured",(n=>t(n.event,n)))}Wn(){var t;return(t=this.Nn)!==null&&t!==void 0?t:this.Nn=new R4(this)}fn(t){this.wn.push(t);var n=!0;return()=>{if(n){n=!1;var i=this.wn.indexOf(t);i!==-1&&this.wn.splice(i,1)}}}calculateEventProperties(t,n,i,a,o){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return n;var u=o?void 0:this.persistence.remove_event_timer(t),f=he({},n);if(f.token=this.config.token,f.$config_defaults=this.config.defaults,this.mn()&&(f[bw]=!0),t==="$snapshot"){var h=he({},this.persistence.properties(),this.sessionPersistence.properties());return f.distinct_id=h.distinct_id,(!vt(f.distinct_id)&&!sn(f.distinct_id)||Ym(f.distinct_id))&&we.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),f}var p,g=(function(N,D,O,L){var G,P,Q,B;if(L===void 0&&(L=!1),!er)return{};var I,M=N?[...Ml,...D||[]]:[],le=(function(Jt){for(var pt=0;ty.length>pt;pt++){var _t=ty[pt],Nt=_t[1],ve=_t[0].exec(Jt),Fe=ve&&(pr(Nt)?Nt(ve,Jt):Nt);if(Fe)return Fe}return["",""]})(er),J=le[0],Y=le[1],$=(I=typeof navigator<"u"?navigator:void 0)!=null&&I.brave?{brave:!0}:{},F={};ye(O)||(F.detectGoogleSearchApp=O);var V={},ge=(G=navigator)==null||(G=G.userAgentData)==null?void 0:G.platform,R=(P=navigator)==null?void 0:P.maxTouchPoints,z=ie==null||(Q=ie.screen)==null?void 0:Q.width,Z=ie==null||(B=ie.screen)==null?void 0:B.height,A=ie==null?void 0:ie.devicePixelRatio;ye(ge)||(V.userAgentDataPlatform=ge),ye(R)||(V.maxTouchPoints=R),ye(z)||(V.screenWidth=z),ye(Z)||(V.screenHeight=Z),ye(A)||(V.devicePixelRatio=A);var ue,xe,je,Re,Le,Be,Je,it,ht=Ot(rx({$os:J,$os_version:Y,$browser:iw(er,navigator.vendor,$,F),$device:ny(er),$device_type:(xe=er,je=V,it=ny(xe),it===F5||it===$5||it==="Kobo"||it==="Kindle Fire"||it===J5?Cl:it===yc||it===jl||it===_c||it===Qm?"Console":it===I5?"Wearable":it?gr:(je==null?void 0:je.userAgentDataPlatform)==="Android"&&((Re=je==null?void 0:je.maxTouchPoints)!==null&&Re!==void 0?Re:0)>0?600>Math.min((Le=je==null?void 0:je.screenWidth)!==null&&Le!==void 0?Le:0,(Be=je==null?void 0:je.screenHeight)!==null&&Be!==void 0?Be:0)/((Je=je==null?void 0:je.devicePixelRatio)!==null&&Je!==void 0?Je:1)?gr:Cl:"Desktop"),$timezone:Gw(),$timezone_offset:s4()}),{$current_url:jc(L?Ts(Vt==null?void 0:Vt.href):Vt==null?void 0:Vt.href,M,Nc),$host:Vt==null?void 0:Vt.host,$pathname:Vt==null?void 0:Vt.pathname,$raw_user_agent:er.length>1e3?er.substring(0,997)+"...":er,$browser_version:n3(er,navigator.vendor,$,F),$browser_language:jy(),$browser_language_prefix:(ue=jy(),typeof ue=="string"?ue.split("-")[0]:void 0),$screen_height:ie==null?void 0:ie.screen.height,$screen_width:ie==null?void 0:ie.screen.width,$viewport_height:ie==null?void 0:ie.innerHeight,$viewport_width:ie==null?void 0:ie.innerWidth,$lib:jt.LIB_NAME,$lib_version:jt.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return jt.SDK_DIST_CHANNEL&&(ht.$sdk_dist_channel=jt.SDK_DIST_CHANNEL),ht})(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){var x=this.sessionManager.checkAndGetSessionAndWindowId(o,i.getTime()),b=x.windowId;f.$session_id=x.sessionId,f.$window_id=b}this.sessionPropsManager&&Ot(f,this.sessionPropsManager.getSessionProps());try{var y;this.sessionRecording&&Ot(f,this.sessionRecording.sdkDebugProperties),f.$sdk_debug_retry_queue_size=(y=this.An)==null?void 0:y.length}catch(N){f.$sdk_debug_error_capturing_properties=String(N)}if(this.requestRouter.region===Ng&&(f.$lib_custom_api_host=this.config.api_host),p=t!==bl||o?t!==qp||o?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,a),f=Ot(f,p),t===bl&&ke&&(f.title=ke.title),!ye(u)){var _=i.getTime()-u;f.$duration=parseFloat((_/1e3).toFixed(3))}er&&this.config.opt_out_useragent_filter&&(f.$browser_type=this._is_bot()?"bot":"browser");var j=this.persistence.properties(),C=this.sessionPersistence.properties();Rt(["$referrer","$referring_domain"],(N=>{N in j&&delete C[N]})),(f=Ot({},g,j,C,f)).$is_identified=this._isIdentified(),Ve(this.config.property_denylist)?Rt(this.config.property_denylist,(function(N){delete f[N]})):we.error(f2+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var k=this.config.sanitize_properties;k&&(we.error(Py),f=k(f,t));var E=this.Vn();return f.$process_person_profile=E,E&&!o&&this.Zn("_calculate_event_properties"),f}zn(t,n,i){var a;if(n===void 0&&(n=!0),i===void 0&&(i=!1),!this.persistence||!this.Vn()||this.yn&&!i)return t;var o=this.persistence.get_initial_props(),u=(a=this.sessionPropsManager)==null?void 0:a.getSetOnceProps(),f=Ot({},o,u||{},t||{}),h=this.config.sanitize_properties;return h&&(we.error(Py),f=h(f,"$set_once")),n&&(this.yn=!0),Ii(f)?void 0:f}register(t,n){var i;(i=this.persistence)==null||i.register(t,n)}register_once(t,n,i){var a;(a=this.persistence)==null||a.register_once(t,n,i)}register_for_session(t){var n;(n=this.sessionPersistence)==null||n.register(t),Object.keys(t).forEach((i=>this.bn.add(i))),this.Gn()}unregister(t){var n;(n=this.persistence)==null||n.unregister(t)}unregister_for_session(t){var n;(n=this.sessionPersistence)==null||n.unregister(t),this.bn.delete(t),this.Gn()}Qn(t,n){this.register({[t]:n})}Fn(){this.bn.forEach((t=>{var n;(n=this.sessionPersistence)==null||n.unregister(t)})),this.bn.clear(),this.Gn()}Gn(){var t;if(this._n)if(this.config.persistence==="memory"||(t=this.sessionPersistence)!=null&&t.xi||!Zt.N())Zt.q(this._n);else{var n=[];this.bn.forEach((i=>n.push(i))),n.length>0?Zt.F(this._n,n):Zt.q(this._n)}}getFeatureFlag(t,n){var i;return(i=this.featureFlags)==null?void 0:i.getFeatureFlag(t,n)}getFeatureFlagPayload(t){var n;return(n=this.featureFlags)==null?void 0:n.getFeatureFlagPayload(t)}getFeatureFlagResult(t,n){var i;return(i=this.featureFlags)==null?void 0:i.getFeatureFlagResult(t,n)}getAllFeatureFlags(){var t,n;return(t=(n=this.featureFlags)==null?void 0:n.getAllFeatureFlags())!==null&&t!==void 0?t:[]}isFeatureEnabled(t,n){var i,a;return(i=(a=this.featureFlags)==null?void 0:a.isFeatureEnabled(t,n))!==null&&i!==void 0?i:n==null?void 0:n.defaultValue}reloadFeatureFlags(){var t;(t=this.featureFlags)==null||t.reloadFeatureFlags()}updateFlags(t,n,i){var a;(a=this.featureFlags)==null||a.updateFlags(t,n,i)}updateEarlyAccessFeatureEnrollment(t,n,i){var a;(a=this.featureFlags)==null||a.updateEarlyAccessFeatureEnrollment(t,n,i)}getEarlyAccessFeatures(t,n,i){var a;return n===void 0&&(n=!1),(a=this.featureFlags)==null?void 0:a.getEarlyAccessFeatures(t,n,i)}on(t,n){return this.vn.on(t,n)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:qo}),()=>{})}onSessionId(t){var n,i;return(n=(i=this.sessionManager)==null?void 0:i.onSessionId(t))!==null&&n!==void 0?n:()=>{}}getSurveys(t,n){n===void 0&&(n=!1),this.surveys?this.surveys.getSurveys(t,n):t([],{isLoaded:!1,error:qo})}getActiveMatchingSurveys(t,n){n===void 0&&(n=!1),this.surveys?this.surveys.getActiveMatchingSurveys(t,n):t([],{isLoaded:!1,error:qo})}renderSurvey(t,n){var i;(i=this.surveys)==null||i.renderSurvey(t,n)}displaySurvey(t,n){var i;n===void 0&&(n=N4),(i=this.surveys)==null||i.displaySurvey(t,n)}cancelPendingSurvey(t){var n;(n=this.surveys)==null||n.cancelPendingSurvey(t)}canRenderSurvey(t){var n,i;return(n=(i=this.surveys)==null?void 0:i.canRenderSurvey(t))!==null&&n!==void 0?n:{visible:!1,disabledReason:qo}}canRenderSurveyAsync(t,n){var i,a;return n===void 0&&(n=!1),(i=(a=this.surveys)==null?void 0:a.canRenderSurveyAsync(t,n))!==null&&i!==void 0?i:Promise.resolve({visible:!1,disabledReason:qo})}Kn(t){return!t||Ym(t)?(we.critical("Unique user id has not been set in posthog.identify"),!1):t===ad?(we.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(we.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(t,n,i){if(!this.__loaded||!this.persistence)return we.uninitializedWarning("posthog.identify");if(sn(t)&&(t=t.toString(),we.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.Kn(t)&&this.Zn("posthog.identify")){var a=this.get_distinct_id();this.register({$user_id:t}),this.get_property(wc)||this.register_once({$had_persisted_distinct_id:!0,$device_id:a},""),t!==a&&t!==this.get_property(ec)&&(this.unregister(ec),this.register({distinct_id:t}));var o,u=(this.persistence.get_property(zr)||fl)===fl,f=t!==a,h=!f&&u;if(f&&u)this.persistence.set_property(zr,ia),this.setPersonPropertiesForFlags({$set:n||{},$set_once:i||{}},!1),this.capture(Vp,{distinct_id:t,$anon_distinct_id:a},{$set:n||{},$set_once:i||{}}),this.Cn=nm(t,n,i),(o=this.featureFlags)==null||o.setAnonymousDistinctId(a);else if(h){this.persistence.set_property(zr,ia);var p=n||{},g=i||{};this.setPersonPropertiesForFlags({$set:p,$set_once:g},!1),this.capture("$set",{$set:p,$set_once:g}),this.Cn=nm(t,n,i)}else(n||i)&&this.setPersonProperties(n,i);f?(this.reloadFeatureFlags(),this.unregister(cc)):h&&(n||i)&&this.reloadFeatureFlags()}}setPersonProperties(t,n){if((t||n)&&this.Zn("posthog.setPersonProperties")){var i=nm(this.get_distinct_id(),t,n);this.Cn!==i?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:n||{}},!0),this.capture("$set",{$set:t||{},$set_once:n||{}}),this.Cn=i):we.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(t){var n,i=(Ve(t)?t:[t]).filter((a=>vt(a)&&a.length>0));i.length!==0&&this.Zn("posthog.unsetPersonProperties")&&((n=this.featureFlags)==null||n.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this.Cn=null)}group(t,n,i){if(t&&n){var a=this.getGroups(),o=a[t]!==n;if(o&&this.resetGroupPropertiesForFlags(t),this.register({$groups:he({},a,{[t]:n})}),o||i){var u={$group_type:t,$group_key:n};i&&(u.$group_set=i),this.capture(cy,u)}i&&this.setGroupPropertiesForFlags({[t]:i}),o&&!i&&this.reloadFeatureFlags()}else we.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,n){var i;n===void 0&&(n=!0),(i=this.featureFlags)==null||i.setPersonPropertiesForFlags(t,n)}resetPersonPropertiesForFlags(t){var n;t===void 0&&(t=!0),(n=this.featureFlags)==null||n.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,n){var i;n===void 0&&(n=!0),this.Zn("posthog.setGroupPropertiesForFlags")&&((i=this.featureFlags)==null||i.setGroupPropertiesForFlags(t,n))}resetGroupPropertiesForFlags(t){var n;(n=this.featureFlags)==null||n.resetGroupPropertiesForFlags(t)}reset(t){this.Jn(t)}Jn(t,n){var i,a,o,u,f,h,p,g,x,b;if(n===void 0&&(n=!1),we.info("reset"),!this.__loaded)return we.uninitializedWarning("posthog.reset");var y,_=this.get_property(wc),j=this.get_property(Hp),C=this.get_property(xa),k=this.is_capturing();if(this.consent.reset(),n||!k||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after."),(i=this.persistence)==null||i.clear(),(a=this.sessionPersistence)==null||a.clear(),this.bn.clear(),this.Gn(),ye(C)||(y=this.persistence)==null||y.register({[xa]:C}),(o=this.surveys)==null||o.reset(),(u=this.Bn)==null||u.stop(),(f=this.featureFlags)==null||f.reset(),(h=this.conversations)==null||h.reset(),(p=this.logs)==null||p.reset(),(g=this.metrics)==null||g.reset(),(x=this.persistence)==null||x.set_property(zr,fl),(b=this.sessionManager)==null||b.resetSessionId(),this.Cn=null,this.config.cookieless_mode===$i)this.register_once({distinct_id:ad,$device_id:null},"");else{var E=this.config.get_device_id(Pi());this.register_once({distinct_id:E,$device_id:t?E:_},""),t||ye(j)||this.register({[Hp]:j})}this.register({$last_posthog_reset:new Date().toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}shutdown(t){var n=this;return Ut((function*(){var i,a,o,u,f,h,p,g;n.__loaded?((i=n.Bn)==null||i.stop(),(a=n.Nn)==null||a.dispose(),(o=n.sessionRecording)==null||o.dispose(),(u=n.logs)==null||u.flushLogs("sendBeacon"),(f=n.metrics)==null||f.flush("sendBeacon"),(h=n.Pn)==null||h.unload(),(p=n.An)==null||p.unload(),(g=n.featureFlags)==null||g.destroy()):we.uninitializedWarning("posthog.shutdown")}))()}setIdentity(t,n){var i;this.config.identity_distinct_id=t,this.config.identity_hash=n,this.alias(t),(i=this.conversations)==null||i.Yn()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,(t=this.conversations)==null||t.Xn()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,n;return(t=(n=this.sessionManager)==null?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&t!==void 0?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";var n=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=n.sessionStartTimestamp,a=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+n.sessionId);if(t!=null&&t.withTimestamp&&i){var o,u=(o=t.timestampLookBack)!==null&&o!==void 0?o:10;if(!i)return a;a+="?t="+Math.max(Math.floor((new Date().getTime()-i)/1e3)-u,0)}return a}alias(t,n){return t===this.get_property(hw)?(we.critical("Attempting to create alias for existing People user - aborting."),-2):this.Zn("posthog.alias")?(ye(n)&&(n=this.get_distinct_id()),t!==n?(this.Qn(ec,t),this.capture("$create_alias",{alias:t,distinct_id:n})):(we.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){var n=he({},this.config);if(Bt(t)){var i,a,o,u,f,h,p,g,x,b,y;Ot(this.config,$y(t));var _=this.In();(i=this.persistence)==null||i.update_config(this.config,n,_),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Xp(he({},this.config,{persistence:"sessionStorage"}),_,!1);var j=this.Mn(this.config.debug);Wr(j)&&(this.config.debug=j),Wr(this.config.debug)&&(this.config.debug?(jt.DEBUG=!0,zt.N()&&zt.F("ph_debug",!0),we.info("set_config",{config:t,oldConfig:n,newConfig:he({},this.config)})):(jt.DEBUG=!1,zt.N()&&zt.q("ph_debug"))),(a=this.exceptionObserver)==null||a.onConfigChange(),(o=this.exceptions)==null||o.onConfigChange(),(u=this.sessionRecording)==null||u.startIfEnabledOrStop(),(f=this.tracingHeaders)==null||f.startIfEnabledOrStop(),(h=this.autocapture)==null||h.startIfEnabled(),(p=this.heatmaps)==null||p.startIfEnabled(),(g=this.exceptionObserver)==null||g.startIfEnabledOrStop(),(x=this.deadClicksAutocapture)==null||x.startIfEnabledOrStop(),(b=this.surveys)==null||b.loadIfEnabled(),this.ts(),(y=this.externalIntegrations)==null||y.startIfEnabledOrStop()}}_overrideSDKInfo(t,n){jt.LIB_NAME=t,jt.LIB_VERSION=n}startSessionRecording(t){var n,i,a,o,u,f=t===!0,h={sampling:f||!(t==null||!t.sampling),linked_flag:f||!(t==null||!t.linked_flag),url_trigger:f||!(t==null||!t.url_trigger),event_trigger:f||!(t==null||!t.event_trigger)};Object.values(h).some(Boolean)&&((n=this.sessionManager)==null||n.checkAndGetSessionAndWindowId(),h.sampling&&((i=this.sessionRecording)==null||i.overrideSampling()),h.linked_flag&&((a=this.sessionRecording)==null||a.overrideLinkedFlag()),h.url_trigger&&((o=this.sessionRecording)==null||o.overrideTrigger("url")),h.event_trigger&&((u=this.sessionRecording)==null||u.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var t;return!((t=this.sessionRecording)==null||!t.started)}captureException(t,n){if(this.exceptions){var i=new Error("PostHog syntheticException"),a=this.exceptions.buildProperties(t,{handled:!0,syntheticException:i});return this.exceptions.sendExceptionEvent(he({},a,n))}}addExceptionStep(t,n){var i;(i=this.exceptions)==null||i.addExceptionStep(t,n)}captureLog(t){var n;(n=this.logs)==null||n.captureLog(t)}get logger(){var t,n;return(t=(n=this.logs)==null?void 0:n.logger)!==null&&t!==void 0?t:Or.es}startExceptionAutocapture(t){this.set_config({capture_exceptions:t==null||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var n,i;return(n=(i=this.toolbar)==null?void 0:i.loadToolbar(t))!==null&&n!==void 0&&n}get_property(t){var n;return(n=this.persistence)==null?void 0:n.props[t]}getSessionProperty(t){var n;return(n=this.sessionPersistence)==null?void 0:n.props[t]}toString(){var t,n=(t=this.config.name)!==null&&t!==void 0?t:yl;return n!==yl&&(n=yl+"."+n),n}_isIdentified(){var t,n;return((t=this.persistence)==null?void 0:t.get_property(zr))===ia||((n=this.sessionPersistence)==null?void 0:n.get_property(zr))===ia}Vn(){var t,n;return!(this.config.person_profiles==="never"||this.config.person_profiles===gg&&!this._isIdentified()&&Ii(this.getGroups())&&((t=this.persistence)==null||(t=t.props)==null||!t[ec])&&((n=this.persistence)==null||(n=n.props)==null||!n[Xd]))}Hn(){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.Vn()||this.Zn("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Zn("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Zn(t){return this.config.person_profiles==="never"?(we.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Qn(Xd,!0),!0)}In(){if(this.config.cookieless_mode==="always")return!0;var t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==pa)}ts(){var t,n,i,a,o=this.In();return((t=this.persistence)==null?void 0:t.xi)!==o&&((i=this.persistence)==null||i.set_disabled(o)),((n=this.sessionPersistence)==null?void 0:n.xi)!==o&&((a=this.sessionPersistence)==null||a.set_disabled(o)),o&&(this.bn.clear(),this.Gn()),o}opt_in_capturing(t){var n;if(this.config.cookieless_mode!==$i){if(this.mn()){var i,a,o,u,f;this.Jn(!0,!0),(i=this.sessionManager)==null||i.destroy(),(a=this.pageViewManager)==null||a.destroy(),this.sessionManager=new Dy(this),this.pageViewManager=new ky(this),this.persistence&&(this.sessionPropsManager=new Ly(this,this.sessionManager,this.persistence));var h,p=(o=(u=this.config.__extensionClasses)==null?void 0:u.sessionRecording)!==null&&o!==void 0?o:(f=Or.__defaultExtensionClasses)==null?void 0:f.sessionRecording;p&&(this.sessionRecording=this.gn(this.sessionRecording,new p(this)),this.dn&&((h=this.sessionRecording)==null||h.onRemoteConfig==null||h.onRemoteConfig(this.dn)))}var g,x;this.consent.optInOut(!0),this.ts(),this.qn(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==pa&&((g=this.surveys)==null||g.loadIfEnabled()),(ye(t==null?void 0:t.captureEventName)||t!=null&&t.captureEventName)&&this.capture((x=t==null?void 0:t.captureEventName)!==null&&x!==void 0?x:"$opt_in",t==null?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.jn()}else we.warn(By)}opt_out_capturing(){var t,n,i;this.config.cookieless_mode!==$i?(this.config.cookieless_mode===pa&&this.consent.isOptedIn()&&this.Jn(!0,!0),this.consent.optInOut(!1),this.ts(),this.config.cookieless_mode===pa&&(this.register({distinct_id:ad,$device_id:null}),(t=this.sessionRecording)==null||t.stopRecording(),this.sessionRecording=void 0,(n=this.sessionManager)==null||n.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.jn(),this.qn())):we.warn(By)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var t=this.consent.consent;return t===1?"granted":t===0?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===$i||(this.config.cookieless_mode===pa?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.ts()}_is_bot(){return In?s2(In,this.config.custom_blocked_useragents):void 0}jn(){ke&&(ke.visibilityState==="visible"?this.kn||(this.kn=!0,this.capture(bl,{title:ke.title},{send_instantly:!0}),this.xn&&(ke.removeEventListener(Kd,this.xn),this.xn=null)):this.xn||(this.xn=this.jn.bind(this),Gt(ke,Kd,this.xn)))}debug(t){t===!1?(ie==null||ie.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(ie==null||ie.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}))}Ki(){var t=this.Tn||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(we.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(function(n,i,a,o,u){var f=i in n&&!Ye(n[i]),h=a in n&&!Ye(n[a]);return f?n[i]:!!h&&(u&&u.warn("Config field '"+a+"' is deprecated. Please use '"+i+"' instead. The old field will be removed in a future major version."),n[a])})(t,"advanced_disable_flags","advanced_disable_decide",0,we)}Pt(t){var n;if(Ye(this.config.before_send))return t;var i=Object.keys((n=t.properties)!==null&&n!==void 0?n:{}).filter(qC),a=Ve(this.config.before_send)?this.config.before_send:[this.config.before_send],o=t;for(var u of a){if(o=u(o),Ye(o)){var f="Event '"+t.event+"' was rejected in beforeSend function";return HC(t.event)?we.warn(f+". This can cause unexpected behavior."):we.info(f),null}o.properties&&!Ii(o.properties)||we.warn("Event '"+t.event+"' has no properties after beforeSend function, this is likely an error.")}for(var h of i)if(o.properties&&Ye(o.properties[h]))return we.warn("Event '"+t.event+"' had its '"+h+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return o}getPageViewId(){var t;return(t=this.pageViewManager.ui)==null?void 0:t.pageViewId}captureTraceFeedback(t,n){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:n})}captureTraceMetric(t,n,i){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:n,$ai_metric_value:String(i)})}Mn(t){var n=Wr(t)&&!t,i=zt.N()&&zt.P("ph_debug")==="true";return!n&&(!!i||t)}}Or.__defaultExtensionClasses={},Or.es=(()=>{var e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),(function(e,t){for(var n=0;t.length>n;n++)e.prototype[t[n]]=R3(e.prototype[t[n]])})(Or,["identify"]);class Fy{constructor(t){this.disabled=t===!1;var n=Bt(t)?t:{};this.thresholdPx=n.threshold_px||30,this.timeoutMs=n.timeout_ms||1e3,this.clickCount=n.click_count||3,this.clicks=[]}isRageClick(t,n,i){if(this.disabled)return!1;var a=this.clicks[this.clicks.length-1];if(a&&Math.abs(t-a.x)+Math.abs(n-a.y)<this.thresholdPx&&this.timeoutMs>i-a.timestamp){if(this.clicks.push({x:t,y:n,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:n,timestamp:i}];return!1}}var sm="$copy_autocapture",am=Wt("[AutoCapture]");function lm(e,t){return t.length>e?t.slice(0,e)+"...":t}function O4(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!As(t));return t}function B4(e,t){var n,i,a=t.e,o=t.maskAllElementAttributes,u=t.maskAllText,f=t.elementAttributeIgnoreList,h=t.elementsChainAsString,p=t.disableCaptureUrlHashes;if(!As(e))return{props:{}};for(var g=[e],x=new Set([e]),b=e;b.parentNode&&!mr(b,"body")&&Tw>g.length;)if(Ew(b.parentNode)){var y=b.parentNode.host;if(x.has(y))break;x.add(y),g.push(y),b=y}else{if(!As(b.parentNode)||x.has(b.parentNode))break;x.add(b.parentNode),g.push(b.parentNode),b=b.parentNode}var _,j,C=[],k={},E=!1,N=!1;if(Rt(g,(P=>{var Q=bg(P);if(mr(P,"a")){var B=P.getAttribute("href");E=!!(Q&&B&&uc(B))&&(p?Ts(B):B)}qe(ef(P),"ph-no-capture")&&(N=!0),C.push((function(M,le,J,Y,$){$===void 0&&($=!1);var F=M.tagName.toLowerCase(),V={tag_name:F};sx.indexOf(F)>-1&&!J&&(V.$el_text=F.toLowerCase()==="a"||F.toLowerCase()==="button"?lm(1024,_y(M)):lm(1024,kc(M)));var ge=ef(M);ge.length>0&&(V.classes=ge.filter((function(A){return A!==""}))),Rt(M.attributes,(function(A){var ue;if((!Dw(M)||["name","id","class","aria-label"].indexOf(A.name)!==-1)&&(Y==null||!Y.includes(A.name))&&!le&&uc(A.value)&&(!vt(ue=A.name)||ue.substring(0,10)!=="_ngcontent"&&ue.substring(0,7)!=="_nghost")){var xe=A.value;A.name==="class"&&(xe=ix(xe).join(" ")),V["attr__"+A.name]=lm(1024,A.name==="href"&&$?Ts(xe):xe)}}));for(var R=1,z=1,Z=M;Z=O4(Z);)R++,Z.tagName===M.tagName&&z++;return V.nth_child=R,V.nth_of_type=z,V})(P,o,u,f,p));var I=(function(M){if(!bg(M))return{};var le={};return Rt(M.attributes,(function(J){if(J.name&&J.name.indexOf("data-ph-capture-attribute")===0){var Y=J.name.replace("data-ph-capture-attribute-",""),$=J.value;Y&&$&&uc($)&&(le[Y]=$)}})),le})(P);Ot(k,I)})),N)return{props:{},explicitNoCapture:N};if(u||(C[0].$el_text=mr(e,"a")||mr(e,"button")?_y(e):kc(e)),E){var D,O;C[0].attr__href=E;var L=(D=tf(E))==null?void 0:D.host,G=ie==null||(O=ie.location)==null?void 0:O.host;L&&G&&L!==G&&(_=E)}return{props:Ot({$event_type:a.type,$ce_version:1},h?{}:{$elements:C},{$elements_chain:(j=C,(function(P){return P.map((Q=>{var B,I,M="";if(Q.tag_name&&(M+=Q.tag_name),Q.attr_class)for(var le of(Q.attr_class.sort(),Q.attr_class))M+="."+le.replace(/"/g,"");var J=he({},Q.text?{text:Q.text}:{},{"nth-child":(B=Q.nth_child)!==null&&B!==void 0?B:0,"nth-of-type":(I=Q.nth_of_type)!==null&&I!==void 0?I:0},Q.href?{href:Q.href}:{},Q.attr_id?{attr_id:Q.attr_id}:{},Q.attributes),Y={};return Ad(J).sort((($,F)=>$[0].localeCompare(F[0]))).forEach(($=>{var F=$[1];return Y[wy($[0].toString())]=wy(F.toString())})),(M+=":")+Ad(Y).map(($=>$[0]+'="'+$[1]+'"')).join("")})).join(";")})((function(P){return P.map((Q=>{var B,I,M={text:(B=Q.$el_text)==null?void 0:B.slice(0,400),tag_name:Q.tag_name,href:(I=Q.attr__href)==null?void 0:I.slice(0,2048),attr_class:K3(Q),attr_id:Q.attr__id,nth_child:Q.nth_child,nth_of_type:Q.nth_of_type,attributes:{}};return Ad(Q).filter((le=>le[0].indexOf("attr__")===0)).forEach((le=>M.attributes[le[0]]=le[1])),M}))})(j)))},(n=C[0])!=null&&n.$el_text?{$el_text:(i=C[0])==null?void 0:i.$el_text}:{},_&&a.type==="click"?{$external_click_url:_}:{},k)}}var Vo=Wt("[ExceptionAutocapture]"),Uy=()=>{},P4=Wt("[TracingHeaders]"),la=Wt("[Web Vitals]"),Iy=9e5,Hy="disabled",qy="lazy_loading",Go="awaiting_config",hd="missing_config";Wt("[SessionRecording]"),Wt("[SessionRecording]");var Cg="[SessionRecording]",Ri=Wt(Cg),$4=Wt("[Heatmaps]");function om(e){return Bt(e)&&"clientX"in e&&"clientY"in e&&sn(e.clientX)&&sn(e.clientY)}var pd=Wt("[Product Tours]"),cm=e=>{var t;return!e.config.disable_product_tours&&!((t=e.persistence)==null||!t.get_property(ex))},F4=["$set_once","$set"],ai=Wt("[SiteApps]"),Vy="Error while initializing PostHog app with config id ";function ml(e,t,n){if(Ye(e))return!1;switch(n){case"exact":return e===t;case"contains":var i=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(e);case"regex":try{return new RegExp(t).test(e)}catch{return!1}default:return!1}}class U4{constructor(t){this.rs=new cx,this.ns=(n,i)=>this.ss(n,i)&&this.os(n,i)&&this.ls(n,i)&&this.us(n,i),this.ss=(n,i)=>i==null||!i.event||(n==null?void 0:n.event)===(i==null?void 0:i.event),this._instance=t,this.hs=new Set,this.ds=new Set}init(){var t,n;ye((t=this._instance)==null?void 0:t._addCaptureHook)||(n=this._instance)==null||n._addCaptureHook(((i,a)=>{this.on(i,a)}))}register(t){var n,i;if(!ye((n=this._instance)==null?void 0:n._addCaptureHook)&&(t.forEach((u=>{var f,h;(f=this.ds)==null||f.add(u),(h=u.steps)==null||h.forEach((p=>{var g;(g=this.hs)==null||g.add((p==null?void 0:p.event)||"")}))})),(i=this._instance)!=null&&i.autocapture)){var a,o=new Set;t.forEach((u=>{var f;(f=u.steps)==null||f.forEach((h=>{h!=null&&h.selector&&o.add(h==null?void 0:h.selector)}))})),(a=this._instance)==null||a.autocapture.setElementSelectors(o)}}on(t,n){var i;n!=null&&t.length!=0&&(this.hs.has(t)||this.hs.has(n.event))&&this.ds&&((i=this.ds)==null?void 0:i.size)>0&&this.ds.forEach((a=>{this.vs(n,a)&&this.rs.emit("actionCaptured",a.name)}))}cs(t){this.onAction("actionCaptured",(n=>t(n)))}vs(t,n){if((n==null?void 0:n.steps)==null)return!1;for(var i of n.steps)if(this.ns(t,i))return!0;return!1}onAction(t,n){return this.rs.on(t,n)}os(t,n){if(n!=null&&n.url){var i,a=t==null||(i=t.properties)==null?void 0:i.$current_url;if(!a||typeof a!="string"||!ml(a,n.url,n.url_matching||"contains"))return!1}return!0}ls(t,n){return!!this.fs(t,n)&&!!this.ps(t,n)&&!!this.gs(t,n)}fs(t,n){var i;if(n==null||!n.href)return!0;var a=this.ys(t);if(a.length>0)return a.some((f=>ml(f.href,n.href,n.href_matching||"exact")));var o,u=(t==null||(i=t.properties)==null?void 0:i.$elements_chain)||"";return!!u&&ml((o=u.match(/(?::|")href="(.*?)"/))?o[1]:"",n.href,n.href_matching||"exact")}ps(t,n){var i;if(n==null||!n.text)return!0;var a=this.ys(t);if(a.length>0)return a.some((p=>ml(p.text,n.text,n.text_matching||"exact")||ml(p.$el_text,n.text,n.text_matching||"exact")));var o,u,f,h=(t==null||(i=t.properties)==null?void 0:i.$elements_chain)||"";return!!h&&(o=(function(p){for(var g,x=[],b=/(?::|")text="(.*?)"/g;!Ye(g=b.exec(p));)x.includes(g[1])||x.push(g[1]);return x})(h),u=n.text,f=n.text_matching||"exact",o.some((p=>ml(p,u,f))))}gs(t,n){var i,a;if(n==null||!n.selector)return!0;var o=t==null||(i=t.properties)==null?void 0:i.$element_selectors;if(o!=null&&o.includes(n.selector))return!0;var u=(t==null||(a=t.properties)==null?void 0:a.$elements_chain)||"";if(n.selector_regex&&u)try{return new RegExp(n.selector_regex).test(u)}catch{return!1}return!1}ys(t){var n;return(t==null||(n=t.properties)==null?void 0:n.$elements)==null?[]:t==null?void 0:t.properties.$elements}us(t,n){return n==null||!n.properties||n.properties.length===0||o2(n.properties.reduce(((i,a)=>{var o=Ve(a.value)?a.value.map(String):a.value!=null?[String(a.value)]:[];return i[a.key]={values:o,operator:a.operator||"exact"},i}),{}),t==null?void 0:t.properties)}}class I4{constructor(t){var n;this.bs=[],this._instance=t,this._s=new Map,this.ws=new Map,this.ks=new Map,(n=this._instance)==null||n.onSessionId==null||n.onSessionId((i=>this.xs(i)))}Ss(t){return!1}Cs(){return null}Ms(t){}Ts(){}Es(t,n){return!!t&&o2(t.propertyFilters,n==null?void 0:n.properties)}Is(t,n){var i=new Map;return t.forEach((a=>{var o;(o=a.conditions)==null||(o=o[n])==null||(o=o.values)==null||o.forEach((u=>{if(u!=null&&u.name){var f=i.get(u.name)||[];f.push(a.id),i.set(u.name,f)}}))})),i}Ps(t,n,i){var a=(i===Fo.Activation?this._s:this.ws).get(t),o=[];return this.Rs((u=>{o=u.filter((f=>a==null?void 0:a.includes(f.id)))})),o.filter((u=>{var f,h=(f=u.conditions)==null||(f=f[i])==null||(f=f.values)==null?void 0:f.find((p=>p.name===t));return this.Es(h,n)}))}register(t){var n;ye((n=this._instance)==null?void 0:n._addCaptureHook)||(this.As(t),this.Fs(t))}Fs(t){var n=t.filter((i=>{var a,o;return((a=i.conditions)==null?void 0:a.actions)&&((o=i.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0}));n.length!==0&&(this.Ls==null&&(this.Ls=new U4(this._instance),this.Ls.init(),this.Ls.cs((i=>{this.onAction(i)}))),n.forEach((i=>{var a,o,u,f,h;i.conditions&&(a=i.conditions)!=null&&a.actions&&(o=i.conditions)!=null&&(o=o.actions)!=null&&o.values&&((u=i.conditions)==null||(u=u.actions)==null||(u=u.values)==null?void 0:u.length)>0&&((f=this.Ls)==null||f.register(i.conditions.actions.values),(h=i.conditions)==null||(h=h.actions)==null||(h=h.values)==null||h.forEach((p=>{if(p&&p.name){var g=this.ks.get(p.name);g&&g.push(i.id),this.ks.set(p.name,g||[i.id])}})))})))}As(t){var n,i=t.filter((o=>{var u,f;return((u=o.conditions)==null?void 0:u.events)&&((f=o.conditions)==null||(f=f.events)==null||(f=f.values)==null?void 0:f.length)>0})),a=t.filter((o=>{var u,f;return((u=o.conditions)==null?void 0:u.cancelEvents)&&((f=o.conditions)==null||(f=f.cancelEvents)==null||(f=f.values)==null?void 0:f.length)>0}));i.length===0&&a.length===0||((n=this._instance)==null||n._addCaptureHook(((o,u)=>{this.onEvent(o,u)})),this._s=this.Is(t,Fo.Activation),this.ws=this.Is(t,Fo.Cancellation))}onEvent(t,n){var i,a,o=this.Os(),u=(n==null||(i=n.properties)==null?void 0:i.$survey_id)||(n==null||(a=n.properties)==null?void 0:a.$product_tour_id);if(u&&this.getActivatedIds().includes(u)){var f=this.Ds(t,u);if(f==="consume")return o.info("event consumed activated item, removing it",{event:t,itemId:u}),void this.$s([u]);if(f==="persist")return o.info("shown item promoted to persisted activation",{event:t,itemId:u}),this.Ns(u),void this.qs([u])}if(this.ws.has(t)){var h=this.Ps(t,n,Fo.Cancellation);h.length>0&&(o.info("cancel event matched, cancelling items",{event:t,itemsToCancel:h.map((g=>g.id))}),this.$s(h.map((g=>g.id))),h.forEach((g=>this.js(g.id))))}if(this._s.has(t)){o.info("event name matched",{event:t,eventPayload:n,items:this._s.get(t)});var p=this.Ps(t,n,Fo.Activation);this.Bs(p.map((g=>g.id)))}}onAction(t){this.ks.has(t)&&this.Bs(this.ks.get(t)||[])}Bs(t){var n;if(t.length!==0){var i=!((n=this._instance)==null||n.get_session_id==null||!n.get_session_id()),a=[];for(var o of t)i&&this.Ss(o)?this.Ns(o)&&this.Hs(o):a.push(o);a.length>0&&(this.bs=[...new Set([...this.bs,...a])]),this.Os().info("updating activated items",{activatedItems:this.getActivatedIds()})}}Ns(t){this.bs=this.bs.filter((i=>i!==t));var n=this.Us();return!n.includes(t)&&(this.zs([...n,t]),this.Ws(),!0)}$s(t){var n=new Set(t);this.bs=this.bs.filter((o=>!n.has(o)));var i=this.Vs(),a=i.filter((o=>!n.has(o)));a.length!==i.length&&(this.zs(a),a.length===0&&this.Zs()),this.qs(t)}Gs(){var t,n=this.Cs();if(!n)return{};var i=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[n];return i&&typeof i=="object"?i:{}}Hs(t){if(this.Cs()){var n=this.Gs();this.Ms(he({},n,{[t]:Date.now()}))}}qs(t){if(this.Cs()){var n=this.Gs(),i={},a=!1;for(var o of Object.entries(n)){var u=o[0],f=o[1];t.includes(u)?a=!0:i[u]=f}a&&(Ii(i)?this.Ts():this.Ms(i))}}Qs(){this.Cs()&&this.Ts()}getActivationTimestamp(t){if(this.Us().includes(t)){var n=this.Gs()[t];return sn(n)?n:void 0}}Vs(){var t,n=this.Ks();return((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[n])||[]}Us(){var t,n,i=this.Vs();if(i.length===0)return[];var a=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[this.Js()],o=(n=this._instance)==null||n.get_session_id==null?void 0:n.get_session_id();return o&&a===o?i:[]}Ws(){var t,n=(t=this._instance)==null||t.get_session_id==null?void 0:t.get_session_id();n&&this.Ys(n)}Zs(){this.Xs()}xs(t){var n,i=(n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[this.Js()];if(i&&i!==t){var a=this.Vs(),o=this.Gs();a.length>0&&(this.zs([]),a.filter((u=>sn(o[u]))).forEach((u=>this.js(u)))),this.Zs(),this.Qs()}}getActivatedIds(){return[...new Set([...this.Us(),...this.bs])].filter((t=>!this.ta(t)))}reset(){this.bs=[],this.Vs().length>0&&this.zs([]),this.Zs(),this.Qs()}getEventToItemsMap(){return this._s}ea(){return this.Ls}}class H4 extends I4{constructor(t){super(t)}Ks(){return cg}Js(){return Ed}Cs(){return Td}Ms(t){var n;(n=this._instance)==null||(n=n.persistence)==null||n.register({[Td]:t})}Ts(){var t;(t=this._instance)==null||(t=t.persistence)==null||t.unregister(Td)}Ss(t){var n,i;this.Rs((o=>{i=o.find((u=>u.id===t))}));var a=(n=i)==null||(n=n.appearance)==null?void 0:n.surveyPopupDelaySeconds;return sn(a)&&a>0}ia(){return Ui.SHOWN}Rs(t){var n;(n=this._instance)==null||n.getSurveys(t)}js(t){var n;(n=this._instance)==null||n.cancelPendingSurvey(t)}Os(){return kt}zs(t){var n;(n=this._instance)==null||(n=n.persistence)==null||n.register({[cg]:t})}Ys(t){var n;(n=this._instance)==null||(n=n.persistence)==null||n.register({[Ed]:t})}Xs(){var t;(t=this._instance)==null||(t=t.persistence)==null||t.unregister(Ed)}ta(){return!1}Ds(t,n){var i;this.Rs((o=>{i=o.find((u=>u.id===n))}));var a=!i||(function(o){var u;return c2(o)&&!((u=o.conditions)==null||(u=u.events)==null||!u.repeatedActivation)||o.schedule==="always"})(i);return a?t===Ui.SHOWN?"consume":"ignore":t===Ui.SHOWN?"persist":t===Ui.DISMISSED||t===Ui.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var md="SDK is not enabled or survey functionality is not yet loaded",Gy="Disabled. Not loading surveys.",q4=ie!=null&&ie.location?nf(ie.location.hash,"__posthog")||nf(location.hash,"state"):null,Yy="_postHogToolbarParams",Wy=Wt("[Toolbar]"),pn=Wt("[FeatureFlags]"),oa=Wt("[FeatureFlags]",{debugEnabled:!0}),um=`" failed. Feature flags didn't load in time.`,Qy=e=>{for(var t={},n=0;e.length>n;n++)t[e[n]]=!0;return t},Xy=e=>{var t={};for(var n of Ad(e||{})){var i=n[1];i&&(t[n[0]]=i)}return t},li=Wt("[Error tracking]"),Ky="Refusing to render web experiment since the viewer is a likely bot",V4={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>af(t,e),not_regex:(e,t)=>!af(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e};class Mn{get Ne(){return this._instance.config}constructor(t){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(i){i===void 0&&(i=!1),n.getWebExperiments((a=>{Mn.ra("retrieved web experiments from the server"),n.na=new Map,a.forEach((o=>{if(o.feature_flag_key){var u;n.na&&(Mn.ra("setting flag key ",o.feature_flag_key," to web experiment ",o),(u=n.na)==null||u.set(o.feature_flag_key,o));var f=n._instance.getFeatureFlag(o.feature_flag_key);vt(f)&&o.variants[f]&&n.sa(o.name,f,o.variants[f].transforms)}else if(o.variants)for(var h in o.variants){var p=o.variants[h];Mn.aa(p,n._instance)&&n.sa(o.name,h,p.transforms)}}))}),i)},this._instance=t,this._instance.onFeatureFlags((i=>{this.onFeatureFlags(i)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())Mn.ra(Ky);else if(!this.Ne.disable_web_experiments){if(Ye(this.na))return this.na=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Mn.ra("applying feature flags",t),t.forEach((n=>{var i;if(this.na&&(i=this.na)!=null&&i.has(n)){var a,o=this._instance.getFeatureFlag(n),u=(a=this.na)==null?void 0:a.get(n);o&&u!=null&&u.variants[o]&&this.sa(u.name,o,u.variants[o].transforms)}}))}}previewWebExperiment(){var t=Mn.getWindowLocation();if(t!=null&&t.search){var n=Al(t==null?void 0:t.search,"__experiment_id"),i=Al(t==null?void 0:t.search,"__experiment_variant");n&&i&&(Mn.ra("previewing web experiments "+n+" && "+i),this.getWebExperiments((a=>{this.oa(parseInt(n),i,a)}),!1,!0))}}loadIfEnabled(){this.Ne.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,n,i){if(this.Ne.disable_web_experiments&&!i)return t([]);var a=this._instance.get_property("$web_experiments");if(a&&!n)return t(a);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Ne.token),method:"GET",timestampMode:"query",callback:o=>t(o.statusCode===200&&o.json&&o.json.experiments||[])})}oa(t,n,i){var a=i.filter((o=>o.id===t));a&&a.length>0&&(Mn.ra("Previewing web experiment ["+a[0].name+"] with variant ["+n+"]"),this.sa(a[0].name,n,a[0].variants[n].transforms))}static aa(t,n){return!Ye(t.conditions)&&Mn.la(t,n)&&Mn.ua(t)}static la(t,n){var i;if(Ye(t.conditions)||Ye((i=t.conditions)==null?void 0:i.url))return!0;var a=Mn.getWindowLocation();if(a){var o,u,f,h=jw(n,a.href);return(o=t.conditions)==null||!o.url||V4[(u=(f=t.conditions)==null?void 0:f.urlMatchType)!==null&&u!==void 0?u:"icontains"](t.conditions.url,h)}return!1}static getWindowLocation(){return ie==null?void 0:ie.location}static ua(t){var n;if(Ye(t.conditions)||Ye((n=t.conditions)==null?void 0:n.utm))return!0;var i=Fw();if(i.utm_source){var a,o,u,f,h,p,g,x,b=(a=t.conditions)==null||(a=a.utm)==null||!a.utm_campaign||((o=t.conditions)==null||(o=o.utm)==null?void 0:o.utm_campaign)==i.utm_campaign,y=(u=t.conditions)==null||(u=u.utm)==null||!u.utm_source||((f=t.conditions)==null||(f=f.utm)==null?void 0:f.utm_source)==i.utm_source,_=(h=t.conditions)==null||(h=h.utm)==null||!h.utm_medium||((p=t.conditions)==null||(p=p.utm)==null?void 0:p.utm_medium)==i.utm_medium,j=(g=t.conditions)==null||(g=g.utm)==null||!g.utm_term||((x=t.conditions)==null||(x=x.utm)==null?void 0:x.utm_term)==i.utm_term;return b&&_&&j&&y}return!1}static ra(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),a=1;n>a;a++)i[a-1]=arguments[a];we.info("[WebExperiments] "+t,i)}sa(t,n,i){this._is_bot()?Mn.ra(Ky):n!=="control"?i.forEach((a=>{if(a.selector){var o;Mn.ra("applying transform of variant "+n+" for experiment "+t+" ",a);var u=(o=document)==null?void 0:o.querySelectorAll(a.selector);u==null||u.forEach((f=>{var h=f;a.html&&(h.innerHTML=a.html),a.css&&h.setAttribute("style",a.css)}))}})):Mn.ra("Control variants leave the page unmodified.")}_is_bot(){return In&&this._instance?s2(In,this.Ne.custom_blocked_useragents):void 0}}var Rr=Wt("[Conversations]"),ca="Conversations not available yet.",Zy="console",p2="__posthogHandledLogsRequestError",dm=(e,t)=>{var n=e instanceof Error?e:new Error(t);return n[p2]=!0,n},Jy=e=>!!e&&typeof e=="object"&&e[p2]===!0,bf={featureFlags:class{constructor(e){this.ha=!1,this.da=!1,this.va=!1,this.ca=!1,this.fa=!1,this.pa=!1,this.ga=!1,this.ma=!1,this.ya=0,this.ba=()=>{var t=this._a();this.ya=0,t&&this.reloadFeatureFlags()},this._instance=e,this.featureFlagEventHandlers=[],ie&&Gt(ie,"online",this.ba)}destroy(){ie==null||ie.removeEventListener("online",this.ba)}get Ne(){return this._instance.config}get Tr(){return this._instance.persistence}wa(e){return this._instance.get_property(e)}ka(){var e,t;return(e=(t=this.Tr)==null?void 0:t.Ci(this.Ne.feature_flag_cache_ttl_ms))!==null&&e!==void 0&&e}xa(){return!!this.ka()&&(this.ma||this.va||(this.ma=!0,pn.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Sa(){var e,t=(e=this.Ne.evaluation_contexts)!==null&&e!==void 0?e:this.Ne.evaluation_environments;return!this.Ne.evaluation_environments||this.Ne.evaluation_contexts||this.ga||(pn.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ga=!0),t!=null&&t.length?t.filter((n=>{var i=n&&typeof n=="string"&&n.trim().length>0;return i||pn.error("Invalid evaluation context found:",n,"Expected non-empty string"),i})):[]}Ca(){return this.Sa().length>0}Ma(){var e=this.Ne.flag_keys;if(!ye(e)){if(Ve(e))return e.filter((t=>{var n=t&&typeof t=="string"&&t.trim().length>0;return n||pn.error("Invalid flag key found:",t,"Expected non-empty string"),n}));pn.error("Invalid flag_keys found:",e,"Expected array of non-empty strings")}}initialize(){var e,t,n=this._instance.config,i=(e=(t=n.bootstrap)==null?void 0:t.featureFlags)!==null&&e!==void 0?e:{};if(Object.keys(i).length){var a,o,u=(a=(o=n.bootstrap)==null?void 0:o.featureFlagPayloads)!==null&&a!==void 0?a:{},f=Object.keys(i).filter((p=>!!i[p])).reduce(((p,g)=>(p[g]=i[g]||!1,p)),{}),h=Object.keys(u).filter((p=>f[p])).reduce(((p,g)=>(u[g]&&(p[g]=u[g]),p)),{});this.receivedFeatureFlags({featureFlags:f,featureFlagPayloads:h})}}updateFlags(e,t,n){var i,a,o=n!=null&&n.merge&&(i=this.wa(ga))!==null&&i!==void 0?i:{},u=n!=null&&n.merge&&(a=this.wa(Cd))!==null&&a!==void 0?a:{},f=he({},o,e),h=he({},u,t),p={};for(var g of Object.entries(f)){var x=g[0],b=g[1];p[x]={key:x,enabled:Wb(b),variant:Qb(b),reason:void 0,metadata:ye(h==null?void 0:h[x])?void 0:{id:0,version:void 0,description:void 0,payload:h[x]}}}this.receivedFeatureFlags({flags:p})}get hasLoadedFlags(){return this.da}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this.wa(ag),t=this.wa(Oi),n=this.wa(vl);if(!n&&!t)return e||{};var i=Ot({},e||{}),a=[...new Set([...Object.keys(n||{}),...Object.keys(t||{})])];for(var o of a){var u,f,h=i[o],p=t==null?void 0:t[o],g=ye(p)?(u=h==null?void 0:h.enabled)!==null&&u!==void 0&&u:!!p,x=ye(p)?h.variant:typeof p=="string"?p:void 0,b=n==null?void 0:n[o],y=he({},h,{enabled:g,variant:g?x??(h==null?void 0:h.variant):void 0});g!==(h==null?void 0:h.enabled)&&(y.original_enabled=h==null?void 0:h.enabled),x!==(h==null?void 0:h.variant)&&(y.original_variant=h==null?void 0:h.variant),b&&(y.metadata=he({},h==null?void 0:h.metadata,{payload:b,original_payload:h==null||(f=h.metadata)==null?void 0:f.payload})),i[o]=y}return this.ha||(pn.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:n,finalDetails:i}),this.ha=!0),i}getAllFeatureFlags(){var e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map((n=>{var i=e[n];return{key:n,enabled:Wb(i),variant:Qb(i),payload:Yb(t[n])}}))}getFlagVariants(){var e=this.wa(ga),t=this.wa(Oi);if(!t)return e||{};for(var n=Ot({},e),i=Object.keys(t),a=0;i.length>a;a++)n[i[a]]=t[i[a]];return this.ha||(pn.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:n}),this.ha=!0),n}getFlagPayloads(){var e=this.wa(Cd),t=this.wa(vl);if(!t)return e||{};for(var n=Ot({},e||{}),i=Object.keys(t),a=0;i.length>a;a++)n[i[a]]=t[i[a]];return this.ha||(pn.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:n}),this.ha=!0),n}reloadFeatureFlags(){this.ca||this.Ne.advanced_disable_feature_flags||this._a()||this.Ta||(this._instance.vn.emit("featureFlagsReloading",!0),this.Ta=setTimeout((()=>{this.Ea()}),5))}Ia(){clearTimeout(this.Ta),this.Ta=void 0}ensureFlagsLoaded(){this.da||this.va||this.Ta||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.ca=e}Ea(e){var t;if(this.Ia(),!this._instance.Ki()&&!this._a())if(this.va)this.fa=!0;else{var n=this.Ne.token,i=this.wa(wc),a={token:n,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:he({},((t=this.Tr)==null?void 0:t.get_initial_props())||{},this.wa(fa)||{},{$lib:jt.LIB_NAME,$lib_version:jt.LIB_VERSION}),group_properties:this.wa(ha),timezone:Gw()};Hn(i)||ye(i)||(a.$device_id=i),(e!=null&&e.disableFlags||this.Ne.advanced_disable_feature_flags)&&(a.disable_flags=!0),this.Ca()&&(a.evaluation_contexts=this.Sa());var o=this.Ma();ye(o)||(a.flag_keys=o);var u=!!this.Ne.advanced_only_evaluate_survey_feature_flags,f=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.Ne.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.va=!0,this._instance._send_request({method:"POST",url:f,data:a,compression:this.Ne.disable_compression?void 0:$n.Base64,timestampMode:"body",timeout:this.Ne.feature_flag_request_timeout_ms,callback:h=>{var p,g,x,b=!0;if(this.Pa(h.statusCode),h.statusCode===200&&(this.fa||(this.$anon_distinct_id=void 0),b=!1),this.va=!1,!a.disable_flags||this.fa){this.pa=!b;var y=[];h.error?h.error instanceof Error?y.push(h.error.name==="AbortError"?"timeout":"connection_error"):y.push("unknown_error"):h.statusCode!==200&&y.push("api_error_"+h.statusCode),(p=h.json)!=null&&p.errorsWhileComputingFlags&&y.push("errors_while_computing_flags");var _,j=!((g=h.json)==null||(g=g.quotaLimited)==null||!g.includes("feature_flags"));j&&y.push("quota_limited"),(x=this.Tr)==null||x.register({[dg]:y}),j?pn.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."):(a.disable_flags||this.receivedFeatureFlags((_=h.json)!==null&&_!==void 0?_:{},b,{partialResponse:u}),this.fa&&(this.fa=!1,this.Ea()))}}})}}_a(){return Pw(this.ya,3)}Pa(e){this.ya=$w(e,this.ya,3,(()=>pn.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes.")))}getFeatureFlag(e,t){var n;if(t===void 0&&(t={}),!t.fresh||this.pa)if(this.da||this.getFlags()&&this.getFlags().length>0){if(!this.xa()){var i=this.getFeatureFlagResult(e,t);return(n=i==null?void 0:i.variant)!==null&&n!==void 0?n:i==null?void 0:i.enabled}}else pn.warn('getFeatureFlag for key "'+e+um)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return t==null?void 0:t.payload}getFeatureFlagResult(e,t){if(t===void 0&&(t={}),!t.fresh||this.pa)if(this.da||this.getFlags()&&this.getFlags().length>0){if(!this.xa()){var n=this.getFlagVariants(),i=e in n,a=n[e],o=this.getFlagPayloads()[e],u=String(a),f=this.wa(lg)||void 0,h=this.wa(Sc)||void 0,p=this.wa(cc)||{};if(this.Ne.advanced_feature_flags_dedup_per_session){var g,x=this._instance.get_session_id(),b=this.wa(ug);x&&x!==b&&(p={},(g=this.Tr)==null||g.register({[cc]:p,[ug]:x}))}if((t.send_event||!("send_event"in t))&&(!(e in p)||!p[e].includes(u))){var y,_,j,C,k,E,N,D,O,L,G;Ve(p[e])?p[e].push(u):p[e]=[u],(y=this.Tr)==null||y.register({[cc]:p});var P=this.getFeatureFlagDetails(e),Q=[...(_=this.wa(dg))!==null&&_!==void 0?_:[]];ye(a)&&Q.push("flag_missing");var B={$feature_flag:e,$feature_flag_response:a,$feature_flag_payload:o||null,$feature_flag_request_id:f,$feature_flag_evaluated_at:h,$feature_flag_bootstrapped_response:((j=this.Ne.bootstrap)==null||(j=j.featureFlags)==null?void 0:j[e])||null,$feature_flag_bootstrapped_payload:((C=this.Ne.bootstrap)==null||(C=C.featureFlagPayloads)==null?void 0:C[e])||null,$used_bootstrap_value:!this.pa};ye(P==null||(k=P.metadata)==null?void 0:k.has_experiment)||(B.$feature_flag_has_experiment=P.metadata.has_experiment),ye(P==null||(E=P.metadata)==null?void 0:E.version)||(B.$feature_flag_version=P.metadata.version);var I,M=(N=P==null||(D=P.reason)==null?void 0:D.description)!==null&&N!==void 0?N:P==null||(O=P.reason)==null?void 0:O.code;M&&(B.$feature_flag_reason=M),P!=null&&(L=P.metadata)!=null&&L.id&&(B.$feature_flag_id=P.metadata.id),ye(P==null?void 0:P.original_variant)&&ye(P==null?void 0:P.original_enabled)||(B.$feature_flag_original_response=ye(P.original_variant)?P.original_enabled:P.original_variant),P!=null&&(G=P.metadata)!=null&&G.original_payload&&(B.$feature_flag_original_payload=P==null||(I=P.metadata)==null?void 0:I.original_payload),Q.length&&(B.$feature_flag_error=Q.join(",")),this._instance.capture("$feature_flag_called",B)}if(i)return{key:e,enabled:!!a,variant:typeof a=="string"?a:void 0,payload:Yb(o)}}}else pn.warn('getFeatureFlagResult for key "'+e+um)}getRemoteConfigPayload(e,t){var n=this.Ne.token,i={distinct_id:this._instance.get_distinct_id(),token:n,person_properties:{$lib:jt.LIB_NAME,$lib_version:jt.LIB_VERSION}};this.Ca()&&(i.evaluation_contexts=this.Sa());var a=this.Ma();ye(a)||(i.flag_keys=a),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:i,compression:this.Ne.disable_compression?void 0:$n.Base64,timestampMode:"body",timeout:this.Ne.feature_flag_request_timeout_ms,callback(o){var u,f=(u=o.json)==null?void 0:u.featureFlagPayloads;t((f==null?void 0:f[e])||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),t.fresh&&!this.pa)return t.defaultValue;if(!(this.da||this.getFlags()&&this.getFlags().length>0))return pn.warn('isFeatureEnabled for key "'+e+um),t.defaultValue;var n=this.getFeatureFlag(e,t);return ye(n)?t.defaultValue:!!n}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t,n){if(this.Tr){this.da=!0;var i=this.getFlagVariants(),a=this.getFlagPayloads(),o=this.getFlagsWithDetails();(function(u,f,h,p,g,x){h===void 0&&(h={}),p===void 0&&(p={}),g===void 0&&(g={});var b=(P=>{var Q=P.flags;return Q?(P.featureFlags=Object.fromEntries(Object.keys(Q).map((B=>{var I;return[B,(I=Q[B].variant)!==null&&I!==void 0?I:Q[B].enabled]}))),P.featureFlagPayloads=Object.fromEntries(Object.keys(Q).filter((B=>Q[B].enabled)).filter((B=>{var I;return(I=Q[B].metadata)==null?void 0:I.payload})).map((B=>{var I;return[B,(I=Q[B].metadata)==null?void 0:I.payload]})))):P.featureFlags&&pn.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),P})(u),y=b.flags,_=b.featureFlags,j=b.featureFlagPayloads;if(_){var C=u.requestId,k=u.evaluatedAt;if(Ve(_)){pn.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var E={};if(_)for(var N=0;_.length>N;N++)E[_[N]]=!0;f&&f.register({[Nd]:_,[ga]:E,[Yd]:!1})}else{var D=_,O=j,L=y;if(x!=null&&x.partialResponse)D=he({},h,D),O=he({},p,O),L=he({},g,L);else if(u.errorsWhileComputingFlags)if(y){var G=new Set(Object.keys(y).filter((P=>{var Q;return!((Q=y[P])!=null&&Q.failed)})));D=he({},h,Object.fromEntries(Object.entries(D).filter((P=>G.has(P[0]))))),O=he({},p,Object.fromEntries(Object.entries(O||{}).filter((P=>G.has(P[0]))))),L=he({},g,Object.fromEntries(Object.entries(L||{}).filter((P=>G.has(P[0])))))}else D=he({},h,D),O=he({},p,O),L=he({},g,L);f&&f.register(he({[Nd]:Object.keys(Xy(D)),[ga]:D||{},[Cd]:O||{},[ag]:L||{},[Yd]:u.minimalFlagCalledEvents===!0},C?{[lg]:C}:{},k?{[Sc]:k}:{}))}}})(e,this.Tr,i,a,o,n),t||(this.ma=!1),this.Ra(t)}}override(e,t){t===void 0&&(t=!1),pn.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this.Tr)return pn.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this.Tr.unregister(Oi),this.Tr.unregister(vl),this.Ra(),oa.info("All overrides cleared");if(Ve(e)){var t=Qy(e);return this.Tr.register({[Oi]:t}),this.Ra(),oa.info("Flag overrides set",{flags:e})}if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var n,i=e;if(this.ha=!!((n=i.suppressWarning)!==null&&n!==void 0&&n),"flags"in i){if(i.flags===!1)this.Tr.unregister(Oi),oa.info("Flag overrides cleared");else if(i.flags){if(Ve(i.flags)){var a=Qy(i.flags);this.Tr.register({[Oi]:a})}else this.Tr.register({[Oi]:i.flags});oa.info("Flag overrides set",{flags:i.flags})}}return"payloads"in i&&(i.payloads===!1?(this.Tr.unregister(vl),oa.info("Payload overrides cleared")):i.payloads&&(this.Tr.register({[vl]:i.payloads}),oa.info("Payload overrides set",{payloads:i.payloads}))),void this.Ra()}if(e&&typeof e=="object")return this.Tr.register({[Oi]:e}),this.Ra(),oa.info("Flag overrides set",{flags:e});pn.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.da){var t=this.Aa(),n=t.flags,i=t.flagVariants;try{e(n,i)}catch(a){pn.error("Error while running feature flags callback",a)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,n){var i,a=(this.wa(nc)||[]).find((h=>h.flagKey===e)),o={["$feature_enrollment/"+e]:t},u={$feature_flag:e,$feature_enrollment:t,$set:o};a&&(u.$early_access_feature_name=a.name),n&&(u.$feature_enrollment_stage=n),this._instance.capture("$feature_enrollment_update",u),this.setPersonPropertiesForFlags(o,!1);var f=he({},this.getFlagVariants(),{[e]:t});(i=this.Tr)==null||i.register({[Nd]:Object.keys(Xy(f)),[ga]:f}),this.Ra()}getEarlyAccessFeatures(e,t,n){t===void 0&&(t=!1);var i=this.wa(nc),a=n?"&"+n.map((o=>"stage="+o)).join("&"):"";if(i&&!t)return e(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.Ne.token+a),method:"GET",timestampMode:"query",callback:o=>{var u,f;if(o.json){var h=o.json.earlyAccessFeatures;return(u=this.Tr)==null||u.unregister(nc),(f=this.Tr)==null||f.register({[nc]:h}),e(h)}}})}Aa(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((n=>t[n])),flagVariants:Object.keys(t).filter((n=>t[n])).reduce(((n,i)=>(n[i]=t[i],n)),{})}}Ra(e){var t=this.Aa(),n=t.flags,i=t.flagVariants;this.featureFlagEventHandlers.forEach((a=>{try{a(n,i,{errorsLoading:e})}catch(o){pn.error("Error while running feature flags callback",o)}}))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.wa(fa)||{},i=(e==null?void 0:e.$set)||(e!=null&&e.$set_once?{}:e),a=e==null?void 0:e.$set_once,o={};if(a)for(var u in a)({}).hasOwnProperty.call(a,u)&&(u in n||(o[u]=a[u]));this._instance.register({[fa]:he({},n,o,i)}),t&&this._instance.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=he({},this.wa(fa)||{});e.forEach((i=>{delete n[i]})),this._instance.register({[fa]:n}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(e){e===void 0&&(e=!0),this._instance.unregister(fa),e&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.wa(ha)||{};Object.keys(n).length!==0&&Object.keys(n).forEach((i=>{n[i]=he({},n[i],e[i]),delete e[i]})),this._instance.register({[ha]:he({},n,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this.wa(ha)||{};this._instance.register({[ha]:he({},t,{[e]:{}})})}else this._instance.unregister(ha)}reset(){this.da=!1,this.va=!1,this.ca=!1,this.fa=!1,this.pa=!1,this.$anon_distinct_id=void 0,this.Ia(),this.ha=!1,this.ya=0}}},G4={sessionRecording:class{get Ne(){return this._instance.config}get Tr(){return this._instance.persistence}get started(){var e;return!((e=this.Fa)==null||!e.isStarted)}get status(){var e,t;return this.La===Go||this.La===hd?this.La:(e=(t=this.Fa)==null?void 0:t.status)!==null&&e!==void 0?e:this.La}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.La=Hy,this.Oa=void 0,this.Da=!1,this.$a=(()=>{var t;if(ke==null||!ke.visibilityState||ke.visibilityState==="visible")return!0;var n=ie==null||(t=ie.performance)==null||t.getEntriesByType==null?void 0:t.getEntriesByType("visibility-state");return!(n!=null&&n.length)||n.some((i=>i.name==="visible"))})(),this.Ie=()=>{var t;(ke==null?void 0:ke.visibilityState)==="visible"&&(this.$a=!0,(t=this.Fa)==null||t.setDocumentWasEverVisible==null||t.setDocumentWasEverVisible(!0))},this._instance=e,!this._instance.sessionManager)throw Ri.error("started without valid sessionManager"),new Error(Cg+" started without valid sessionManager. This is a bug.");if(this.Ne.cookieless_mode===$i)throw new Error(Cg+' cannot be used with cookieless_mode="always"');ke!=null&&ke.addEventListener&&Gt(ke,"visibilitychange",this.Ie)}initialize(){this.startIfEnabledOrStop()}dispose(){this.Da=!0,ke==null||ke.removeEventListener==null||ke.removeEventListener("visibilitychange",this.Ie),this.stopRecording()}get Na(){var e,t=!((e=this._instance.get_property(xa))==null||!e.enabled),n=!this.Ne.disable_session_recording,i=this.Ne.disable_session_recording||this._instance.consent.isOptedOut();return ie&&t&&n&&!i}startIfEnabledOrStop(e){var t;if(!(this.Da||this.Na&&(t=this.Fa)!=null&&t.isStarted)){var n=!ye(Object.assign)&&!ye(Array.from);this.Na&&n?(this.qa(e),Ri.info("starting")):(this.La=Hy,this.stopRecording())}}qa(e){var t,n,i;this.Na&&(this.La!==Go&&this.La!==hd&&(this.La=qy),Oe!=null&&(t=Oe.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(n=Oe.__PosthogExtensions__)!=null&&n.initSessionRecording?this.ja(e):(i=Oe.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.Ba,(a=>{if(a)return Ri.error("could not load recorder",a);this.ja(e)})))}stopRecording(){var e,t;(e=this.Oa)==null||e.call(this),this.Oa=void 0,(t=this.Fa)==null||t.stop()}Ha(){var e,t;(e=this.Oa)==null||e.call(this),this.Oa=void 0,(t=this.Fa)==null||t.discard()}Ua(){var e,t;(e=this.Tr)==null||e.unregister(tx),(t=this.Tr)==null||t.unregister(pw)}za(e,t){if(Ye(e))return null;var n,i=sn(e)?e:parseFloat(e);return typeof(n=i)!="number"||!Number.isFinite(n)||0>n||n>1?(Ri.warn(t+" must be between 0 and 1. Ignoring invalid value:",e),null):i}Wa(e){if(this.Tr){var t,n,i=this.Tr,a=()=>{var o,u=e.sessionRecording===!1?void 0:e.sessionRecording,f=this.za((o=this.Ne.session_recording)==null?void 0:o.sampleRate,"session_recording.sampleRate"),h=this.za(u==null?void 0:u.sampleRate,"remote config sampleRate"),p=f??h;Ye(p)&&this.Ua();var g=u==null?void 0:u.minimumDurationMilliseconds;i.register({[xa]:he({cache_timestamp:Date.now(),enabled:!!u},u,{networkPayloadCapture:he({capturePerformance:e.capturePerformance},u==null?void 0:u.networkPayloadCapture),canvasRecording:{enabled:u==null?void 0:u.recordCanvas,fps:u==null?void 0:u.canvasFps,quality:u==null?void 0:u.canvasQuality},sampleRate:p,minimumDurationMilliseconds:ye(g)?null:g,endpoint:u==null?void 0:u.endpoint,triggerMatchType:u==null?void 0:u.triggerMatchType,masking:u==null?void 0:u.masking,urlTriggers:u==null?void 0:u.urlTriggers,version:u==null?void 0:u.version,triggerGroups:u==null?void 0:u.triggerGroups})})};a(),(t=this.Oa)==null||t.call(this),this.Oa=(n=this._instance.sessionManager)==null?void 0:n.onSessionId(a)}}onRemoteConfig(e){var t=e.ok?e.config:void 0;return t&&"sessionRecording"in t?t.sessionRecording===!1?(this.Wa(t),void this.Ha()):(this.Wa(t),void this.startIfEnabledOrStop()):(this.La===Go&&(this.La=hd,Ri.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t){var n;t===void 0&&(t="log"),(n=this.Fa)!=null&&n.log?this.Fa.log(e,t):Ri.warn("log called before recorder was ready")}get Ba(){var e,t,n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(xa);return(n==null||(t=n.scriptConfig)==null?void 0:t.script)||"lazy-recorder"}Va(){var e,t,n=this._instance.get_property(xa);if(!n)return!1;try{t=typeof n=="object"?n:JSON.parse(n)}catch(a){return Ri.warn("persisted remote config for session recording is invalid and will be ignored",a),!1}var i=(e=t.cache_timestamp)!==null&&e!==void 0?e:Date.now();return 36e5>=Date.now()-i}ja(e){var t,n,i;if(!this.Da){if((t=Oe.__PosthogExtensions__)==null||!t.initSessionRecording)return Ri.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[ww]:!0});var a;if(this.Fa||(this.Fa=(a=Oe.__PosthogExtensions__)==null?void 0:a.initSessionRecording(this._instance,this.$a),this.Fa._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Va())return this.La===hd||this.La===Go?void 0:(this.La=Go,Ri.info("persisted remote config is stale, requesting fresh config before starting"),void new Yw(this._instance).load());this.La=qy,(n=(i=this.Fa).setDocumentWasEverVisible)==null||n.call(i,this.$a),this.Fa.start(e)}}onRRwebEmit(e){var t;(t=this.Fa)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.Fa||(t=this.Tr)==null||t.register({[gw]:!0}),(e=this.Fa)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Fa||(t=this.Tr)==null||t.register({[mw]:!0}),(e=this.Fa)==null||e.overrideSampling()}overrideTrigger(e){var t,n;this.Fa||(n=this.Tr)==null||n.register({[e==="url"?xw:vw]:!0}),(t=this.Fa)==null||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.Fa)==null?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var n;return!((n=this.Fa)==null||!n.tryAddCustomEvent(e,t))}}},Y4={autocapture:class{constructor(e){this.Za=!1,this.Ga=null,this.Qa=!1,this.Ka=!1,this.instance=e,this.rageclicks=new Fy(e.config.rageclick),this.Ja=null}initialize(){this.startIfEnabled()}get Ne(){var e,t,n=Bt(this.instance.config.autocapture)?this.instance.config.autocapture:{};return n.url_allowlist=(e=n.url_allowlist)==null?void 0:e.map((i=>new RegExp(i))),n.url_ignorelist=(t=n.url_ignorelist)==null?void 0:t.map((i=>new RegExp(i))),n}Ya(){if(this.isBrowserSupported()){if(ie&&ke){var e=n=>{n=n||(ie==null?void 0:ie.event);try{this.Xa(n)}catch(i){am.error("Failed to capture event",i)}};if(Gt(ke,"submit",e,{capture:!0}),Gt(ke,"change",e,{capture:!0}),Gt(ke,"click",e,{capture:!0}),this.Ne.capture_copied_text){var t=n=>{n=n||(ie==null?void 0:ie.event);try{this.Xa(n,sm)}catch(i){am.error("Failed to capture copy/cut event",i)}};Gt(ke,"copy",t,{capture:!0}),Gt(ke,"cut",t,{capture:!0})}}}else am.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.Za&&(this.Ya(),this.Za=!0)}onRemoteConfig(e){if(this.Qa=!0,e.ok){var t=e.config;t.elementsChainAsString&&(this.Ka=t.elementsChainAsString);var n=t.autocapture_opt_out;Wr(n)&&(this.instance.persistence&&this.instance.persistence.register({[Jm]:n}),this.Ga=n),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(e){this.Ja=e}getElementSelectors(e){var t,n=[];return(t=this.Ja)==null||t.forEach((i=>{var a=ke==null?void 0:ke.querySelectorAll(i);a==null||a.forEach((o=>{e===o&&n.push(i)}))})),n}get isEnabled(){var e,t,n=(e=this.instance.persistence)==null?void 0:e.props[Jm],i=this.Ga,a=this.instance.Ki()&&!this.Qa;if(Hn(i)&&!Wr(n)&&!a)return!1;var o=(t=this.Ga)!==null&&t!==void 0?t:!!n;return!!this.instance.config.autocapture&&!o}Xa(e,t){if(t===void 0&&(t="$autocapture"),this.isEnabled){var n,i=Yp(e);Cw(i)&&(i=i.parentNode||null),t==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&this.instance.config.rageclick&&(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime())&&gy(i,this.instance.config.rageclick)&&this.Xa(e,"$rageclick");var a=t===sm;if(i&&(function(x,b,y,_,j,C){var k;if(!ie||ax(x)||y!=null&&y.url_allowlist&&!hy(y.url_allowlist,C)||y!=null&&y.url_ignorelist&&hy(y.url_ignorelist,C))return!1;if(y!=null&&y.dom_event_allowlist){var E=y.dom_event_allowlist;if(E&&!E.some((P=>b.type===P)))return!1}var N=Lw(x,_),D=N.parentIsUsefulElement,O=N.targetElementList;if(!(function(P,Q){var B=Q==null?void 0:Q.element_allowlist;if(ye(B))return!0;var I,M=function(J){if(B.some((Y=>J.tagName.toLowerCase()===Y)))return{v:!0}};for(var le of P)if(I=M(le))return I.v;return!1})(O,y)||!vg(O,y==null?void 0:y.css_selector_allowlist)||vg(O,(k=y==null?void 0:y.css_selector_ignorelist)!==null&&k!==void 0?k:V3))return!1;try{var L=ie.getComputedStyle(x);if(L&&L.getPropertyValue("cursor")==="pointer"&&b.type==="click")return!0}catch{}var G=x.tagName.toLowerCase();switch(G){case"html":return!1;case"form":return(j||["submit"]).indexOf(b.type)>=0;case"input":case"select":case"textarea":return(j||["change","click"]).indexOf(b.type)>=0;default:return D?(j||["click"]).indexOf(b.type)>=0:(j||["click"]).indexOf(b.type)>=0&&(sx.indexOf(G)>-1||x.getAttribute("contenteditable")==="true")}})(i,e,this.Ne,a,a?["copy","cut"]:void 0,this.instance)){var o=B4(i,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Ne.element_attribute_ignorelist,elementsChainAsString:this.Ka,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes}),u=o.props;if(o.explicitNoCapture)return!1;var f=this.getElementSelectors(i);if(f&&f.length>0&&(u.$element_selectors=f),t===sm){var h,p=Aw(ie==null||(h=ie.getSelection())==null?void 0:h.toString()),g=e.type||"clipboard";if(!p)return!1;u.$selected_content=p,u.$copy_type=g}return this.instance.capture(t,u),!0}}}isBrowserSupported(){return pr(ke==null?void 0:ke.querySelectorAll)}},historyAutocapture:class{constructor(e){var t;this._instance=e,this.eo=(ie==null||(t=ie.location)==null?void 0:t.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(we.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.io&&this.io(),this.io=void 0,we.info("History API monitoring stopped")}monitorHistoryChanges(){ie&&ie.history&&(this.ro("pushState"),this.ro("replaceState"),this.no())}ro(e){var t;if(ie&&((t=ie.history[e])==null||!t.__posthog_wrapped__)){var n=this;(function(i,a,o){try{if(!(a in i))return Uy;var u={next:i[a]},f=o((function(){for(var h=arguments.length,p=new Array(h),g=0;h>g;g++)p[g]=arguments[g];return u.next.apply(this,p)}));return pr(f)&&(f.prototype=f.prototype||{},Object.defineProperties(f,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:u}})),i[a]=f,()=>{if(i[a]!==f)for(var h=i[a];pr(h)&&h.__posthog_layer__;){var p=h.__posthog_layer__;if(p.next===f)return void(p.next=u.next);h=p.next}else i[a]=u.next}}catch{return Uy}})(ie.history,e,(i=>function(a,o,u){i.call(this,a,o,u),n.so(e)}))}}so(e){try{var t,n=ie==null||(t=ie.location)==null?void 0:t.pathname;if(!n)return;n!==this.eo&&this.isEnabled&&this._instance.capture(bl,{navigation_type:e}),this.eo=n}catch(i){we.error("Error capturing "+e+" pageview",i)}}no(){if(!this.io){var e=()=>{this.so("popstate")};Gt(ie,"popstate",e),this.io=()=>{ie&&ie.removeEventListener("popstate",e)}}}},heatmaps:class{get Ne(){return this.instance.config}constructor(e){var t;this.ao=!1,this.Za=!1,this.oo=null,this.instance=e,this.ao=!((t=this.instance.persistence)==null||!t.props[eg]),this.rageclicks=new Fy(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return Bt(this.Ne.capture_heatmaps)&&this.Ne.capture_heatmaps.flush_interval_milliseconds&&(e=this.Ne.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return Ye(this.Ne.capture_heatmaps)?Ye(this.Ne.enable_heatmaps)?this.ao:this.Ne.enable_heatmaps:this.Ne.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.Za)return;$4.info("starting..."),this.lo(),this.Ie()}else{var e;clearInterval((e=this.oo)!==null&&e!==void 0?e:void 0),this.uo(),this.getAndClearBuffer()}}onRemoteConfig(e){if(e.ok){var t=e.config;if("heatmaps"in t){var n=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[eg]:n}),this.ao=n,this.startIfEnabled()}}}getAndClearBuffer(){var e=this.R;return this.R=void 0,e}ho(e){om(e.originalEvent)&&this.ke(e.originalEvent,"deadclick")}Ie(){this.oo&&clearInterval(this.oo),this.oo=(ke==null?void 0:ke.visibilityState)==="visible"?setInterval(this.pr.bind(this),this.flushIntervalMilliseconds):null}lo(){ie&&ke&&(this.do=this.pr.bind(this),Gt(ie,Zd,this.do),this.vo=e=>this.ke(e||(ie==null?void 0:ie.event)),Gt(ke,"click",this.vo,{capture:!0}),this.co=e=>this.fo(e||(ie==null?void 0:ie.event)),Gt(ke,"mousemove",this.co,{capture:!0}),this.po=new Sy(this.instance,Z3,this.ho.bind(this)),this.po.startIfEnabledOrStop(),this.mo=this.Ie.bind(this),Gt(ke,Kd,this.mo),this.Za=!0)}uo(){var e;ie&&ke&&(this.do&&ie.removeEventListener(Zd,this.do),this.vo&&ke.removeEventListener("click",this.vo,{capture:!0}),this.co&&ke.removeEventListener("mousemove",this.co,{capture:!0}),this.mo&&ke.removeEventListener(Kd,this.mo),clearTimeout(this.yo),(e=this.po)==null||e.stop(),this.Za=!1)}bo(e,t){var n=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),a=this.instance.scrollManager.scrollElement(),o=(function(u,f,h){for(var p=u;p&&As(p)&&!mr(p,"body");){if(p===h)return!1;var g=void 0;try{var x,b,y;g=(x=(b=(y=p.ownerDocument)==null?void 0:y.defaultView)!==null&&b!==void 0?b:ie)==null?void 0:x.getComputedStyle(p).position}catch{return!1}if(qe(f,g))return!0;p=Mw(p)}return!1})(Yp(e),["fixed","sticky"],a);return{x:e.clientX+(o?0:i),y:e.clientY+(o?0:n),target_fixed:o,type:t}}ke(e,t){var n;if(t===void 0&&(t="click"),!fy(e.target)&&om(e)){var i=this.bo(e,t);(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,new Date().getTime())&&gy(Yp(e),this.instance.config.rageclick)&&this.Vt(he({},i,{type:"rageclick"})),this.Vt(i)}}fo(e){!fy(e.target)&&om(e)&&(clearTimeout(this.yo),this.yo=setTimeout((()=>{this.Vt(this.bo(e,"mousemove"))}),500))}Vt(e){if(ie){var t=this.Ne.disable_capture_url_hashes?Ts(ie.location.href):ie.location.href,n=this.Ne.custom_personal_data_properties,i=this.Ne.mask_personal_data_properties?[...Ml,...n||[]]:[],a=jc(t,i,Nc);this.R=this.R||{},this.R[a]||(this.R[a]=[]),this.R[a].push(e)}}pr(){this.R&&!Ii(this.R)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Sy,webVitalsAutocapture:class{constructor(e){var t;this.ao=!1,this.Za=!1,this.R={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this._o=()=>{clearTimeout(this.wo),this.wo=void 0,this.R.metrics.length!==0&&(this._instance.capture("$web_vitals",he({$current_url:this.R.url},this.R.metrics.reduce(((n,i)=>he({},n,{["$web_vitals_"+i.name+"_event"]:he({},i),["$web_vitals_"+i.name+"_value"]:i.value})),{}))),this.R={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.ko=n=>{var i;if(this.R=this.R||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},Ye(n==null?void 0:n.name)||Ye(n==null?void 0:n.value))la.error("Invalid metric received",n);else{var a=typeof n.navigationURL=="string"?n.navigationURL:void 0,o=this.xo(a);if(!ye(o)){var u=sn(n.navigationId)||typeof n.navigationId=="string"?"navigation:"+n.navigationId:"url:"+o;if(!this.So||this.So>n.value){this.R.navigationKey!==u&&(this._o(),this.wo=setTimeout(this._o,this.flushToCaptureTimeoutMs)),ye(this.R.navigationKey)&&(this.R.navigationKey=u,this.R.url=o),this.R.firstMetricTimestamp=ye(this.R.firstMetricTimestamp)?Date.now():this.R.firstMetricTimestamp,n.attribution&&n.attribution.interactionTargetElement&&(n.attribution.interactionTargetElement=void 0);var f=(i=this._instance.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0),h=he({},n,a?{navigationURL:o}:{},{$current_url:o,timestamp:Date.now()});ye(f)||(h.$session_id=f.sessionId,h.$window_id=f.windowId),this.R.metrics.push(h),this.R.metrics.length===this.allowedMetrics.length&&this._o()}else la.error("Ignoring metric with value >= "+this.So,n)}}},this.Co=()=>{if(!this.Za){var n,i,a,o,u=Oe.__PosthogExtensions__,f=u==null?void 0:u.postHogWebVitalsCallbacksByFlavor,h=(f==null?void 0:f[this.Mo])||(this.Mo==="web-vitals"&&ye(f)?u==null?void 0:u.postHogWebVitalsCallbacks:void 0);if(ye(h)||(n=h.onLCP,i=h.onCLS,a=h.onFCP,o=h.onINP),n&&i&&a&&o){var p={reportSoftNavs:this.useSoftNavs};this.allowedMetrics.indexOf("LCP")>-1&&n(this.ko.bind(this),p),this.allowedMetrics.indexOf("CLS")>-1&&i(this.ko.bind(this),p),this.allowedMetrics.indexOf("FCP")>-1&&a(this.ko.bind(this),p),this.allowedMetrics.indexOf("INP")>-1&&o(this.ko.bind(this),p),this.Za=!0}else la.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this.ao=!((t=this._instance.persistence)==null||!t.props[ig]),this.startIfEnabled()}get To(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t,n=Bt(this.To)?(e=this.To)==null?void 0:e.web_vitals_allowed_metrics:void 0;return Ye(n)?((t=this._instance.persistence)==null?void 0:t.props[sg])||["CLS","FCP","INP","LCP"]:n}get flushToCaptureTimeoutMs(){return(Bt(this.To)?this.To.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=Bt(this.To)?this.To.web_vitals_attribution:void 0;return e!=null&&e}get useSoftNavs(){var e=Bt(this.To)?this.To.__preview_web_vitals_soft_navs:void 0;return e!=null&&e}get So(){var e=Bt(this.To)&&sn(this.To.__web_vitals_max_value)?this.To.__web_vitals_max_value:Iy;return e>0&&6e4>=e?Iy:e}get isEnabled(){var e=Vt==null?void 0:Vt.protocol;if(e!=="http:"&&e!=="https:")return la.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=Bt(this.To)?this.To.web_vitals:Wr(this.To)?this.To:void 0;return Wr(t)?t:this.ao}startIfEnabled(){this.isEnabled&&!this.Za&&(la.info("enabled, starting..."),this.ai(this.Co))}onRemoteConfig(e){if(e.ok){var t=e.config;if("capturePerformance"in t){var n=Bt(t.capturePerformance)&&!!t.capturePerformance.web_vitals,i=Bt(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[ig]:n}),this._instance.persistence.register({[sg]:i})),this.ao=n,this.startIfEnabled()}}}get Mo(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}ai(e){var t=Oe.__PosthogExtensions__,n=this.Mo,i=t==null?void 0:t.postHogWebVitalsCallbacksByFlavor;i!=null&&i[n]||n==="web-vitals"&&ye(i)&&t!=null&&t.postHogWebVitalsCallbacks?e():t==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,n,(a=>{a?la.error("failed to load script",a):e()}))}xo(e){var t=e||(ie==null?void 0:ie.location.href);if(t){var n=this._instance.config.disable_capture_url_hashes?Ts(t):t,i=this._instance.config.custom_personal_data_properties,a=this._instance.config.mask_personal_data_properties?[...Ml,...i||[]]:[];return jc(n,a,Nc)}la.error("Could not determine current URL")}}},W4={exceptionObserver:class{constructor(e){var t;this.Co=()=>{var n;if(ie&&this.isEnabled&&(n=Oe.__PosthogExtensions__)!=null&&n.errorWrappingFunctions){var i=Oe.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,a=Oe.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,o=Oe.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Eo&&this.Ne.capture_unhandled_errors&&(this.Eo=i(this.captureException.bind(this))),!this.Io&&this.Ne.capture_unhandled_rejections&&(this.Io=a(this.captureException.bind(this))),!this.Po&&this.Ne.capture_console_errors&&(this.Po=o(this.captureException.bind(this)))}catch(u){Vo.error("failed to start",u),this.Ro()}}},this._instance=e,this.Ao=!((t=this._instance.persistence)==null||!t.props[tg]),this.Fo=new YC(he({},(function(n){var i,a,o,u;return n===void 0&&(n={}),{refillRate:(i=(a=n.exceptionRateLimiterRefillRate)!==null&&a!==void 0?a:n.__exceptionRateLimiterRefillRate)!==null&&i!==void 0?i:1,bucketSize:(o=(u=n.exceptionRateLimiterBucketSize)!==null&&u!==void 0?u:n.__exceptionRateLimiterBucketSize)!==null&&o!==void 0?o:10}})(this._instance.config.error_tracking),{refillInterval:1e4,rt:Vo})),this.Ne=this.Lo(),this.startIfEnabledOrStop()}Lo(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Bt(e)?t=he({},t,e):(ye(e)?this.Ao:e)&&(t=he({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Ne.capture_console_errors||this.Ne.capture_unhandled_errors||this.Ne.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Vo.info("enabled"),this.Ro(),this.ai(this.Co)):this.Ro()}ai(e){var t,n;(t=Oe.__PosthogExtensions__)!=null&&t.errorWrappingFunctions?e():(n=Oe.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"exception-autocapture",(i=>{if(i)return Vo.error("failed to load script",i);e()}))}Ro(){var e,t,n;(e=this.Eo)==null||e.call(this),this.Eo=void 0,(t=this.Io)==null||t.call(this),this.Io=void 0,(n=this.Po)==null||n.call(this),this.Po=void 0}onRemoteConfig(e){if(e.ok){var t=e.config;"autocaptureExceptions"in t&&(this.Ao=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[tg]:this.Ao}),this.Ne=this.Lo(),this.startIfEnabledOrStop())}}onConfigChange(){this.Ne=this.Lo()}captureException(e){var t,n,i,a=(t=e==null||(n=e.$exception_list)==null||(n=n[0])==null?void 0:n.type)!==null&&t!==void 0?t:"Exception";this.Fo.consumeRateLimit(a)?Vo.info("Skipping exception capture because of client rate limiting.",{exception:a}):(i=this._instance.exceptions)==null||i.sendExceptionEvent(e)}},exceptions:class{constructor(e){var t,n;this.Oo=[],this.Do=new u3([new v3,new C3,new y3,new b3,new j3,new k3,new w3,new N3],(function(i){for(var a=arguments.length,o=new Array(a>1?a-1:0),u=1;a>u;u++)o[u-1]=arguments[u];return function(f,h){h===void 0&&(h=0);for(var p=[],g=f.split(`
|
|
67
67
|
`),x=h;g.length>x;x++){var b=g[x];if(1024>=b.length){var y=oy.test(b)?b.replace(oy,"$1"):b;if(!y.match(/\S*Error: /)){for(var _ of o){var j=_(y,i);if(j){p.push(j);break}}if(p.length>=50)break}}}return(function(C){if(!C.length)return[];var k=Array.from(C);return k.reverse(),k.slice(0,50).map((E=>{return he({},E,{filename:E.filename||(N=k,N[N.length-1]||{}).filename,function:E.function||Tl});var N}))})(p)}})("web:javascript",p3,x3)),this._instance=e,this.Oo=(t=(n=this._instance.persistence)==null?void 0:n.get_property(ng))!==null&&t!==void 0?t:[],this.$o=Gd(this.No()),this.qo=new T3(this.$o)}onConfigChange(){this.$o=Gd(this.No()),this.qo.setConfig(this.$o)}onRemoteConfig(e){var t,n,i;if(e.ok){var a=e.config;if("errorTracking"in a){var o=(t=(n=a.errorTracking)==null?void 0:n.suppressionRules)!==null&&t!==void 0?t:[],u=(i=a.errorTracking)==null?void 0:i.captureExtensionExceptions;this.Oo=o,this._instance.persistence&&this._instance.persistence.register({[ng]:this.Oo,[rg]:u})}}}get jo(){var e,t=!!this._instance.get_property(rg),n=this._instance.config.error_tracking.captureExtensionExceptions;return(e=n??t)!==null&&e!==void 0&&e}buildProperties(e,t){return this.Do.buildFromUnknown(e,{syntheticException:t==null?void 0:t.syntheticException,mechanism:{handled:t==null?void 0:t.handled}})}addExceptionStep(e,t){if(this.$o.enabled)try{if(!vt(e)||e.trim().length===0)return void li.warn("Ignoring exception step because message must be a non-empty string");var n=(function(o){if(!o)return{sanitizedProperties:{},droppedKeys:[]};var u=[];return{sanitizedProperties:Object.keys(o).reduce(((f,h)=>E3.has(h)?(u.push(h),f):(f[h]=o[h],f)),{}),droppedKeys:u}})(this.Bo(t)),i=n.sanitizedProperties,a=n.droppedKeys;a.length>0&&li.warn("Ignoring reserved exception step fields",{droppedKeys:a}),this.qo.add(he({[qd]:e,[Vd]:new Date().toISOString()},i))}catch(o){li.error("Failed to add exception step. Ignoring breadcrumb.",o)}}sendExceptionEvent(e){try{var t=e.$exception_list;if(this.Ho(t)){if(this.Uo(t))return this.zo("Exception dropped: matched a suppression rule"),void li.info("Skipping exception capture because a suppression rule matched");if(!this.jo&&this.Wo(t))return this.zo("Exception dropped: thrown by a browser extension"),void li.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Vo(t))return this.zo("Exception dropped: thrown by the PostHog SDK"),void li.info("Skipping exception capture because it was thrown by the PostHog SDK")}var n=this.$o.enabled&&Ye(e.$exception_steps)?this.Zo(e):e,i=typeof(o=globalThis._posthogReleaseId)=="string"&&o.length>0?o:void 0;i&&(n.$release_id=i);try{var a=this._instance.capture("$exception",n,{_noTruncate:!0,_batchKey:"exceptionEvent",Un:!0});return a&&this.qo.clear(),a}catch(u){return li.error("Failed to capture exception event. Dropping this exception.",u),void this.qo.clear()}}catch(u){return void li.error("Failed to process exception event. Ignoring this exception.",u)}var o}Zo(e){try{var t=this.qo.getAttachable();return t.length===0?e:he({},e,{$exception_steps:t})}catch(n){return li.error("Failed to read buffered exception steps. Capturing exception without steps.",n),e}}zo(e){this.$o.enabled&&this.qo.add({[qd]:e,[Vd]:new Date().toISOString()})}Bo(e){return Bt(e)?he({},e):{}}No(){var e,t;return(e=(t=this._instance.config.error_tracking)==null?void 0:t.exception_steps)!==null&&e!==void 0?e:{}}Uo(e){if(e.length===0)return!1;try{var t=e.reduce(((n,i)=>{var a=i.type,o=i.value;return vt(a)&&a.length>0&&n.$exception_types.push(a),vt(o)&&o.length>0&&n.$exception_values.push(o),n}),{$exception_types:[],$exception_values:[]});return this.Oo.some((n=>{var i=n.values.map((a=>{var o=l2[a.operator],u=t[a.key];if(!o||!u)return!1;var f=Ve(a.value)?a.value:[a.value];return f.length>0&&o(f,u)}));return n.type==="OR"?i.some(Boolean):i.every(Boolean)}))}catch(n){return li.warn("Failed to evaluate suppression rules. Capturing the exception.",n),!1}}Wo(e){return e.flatMap((t=>{var n,i;return(n=(i=t.stacktrace)==null?void 0:i.frames)!==null&&n!==void 0?n:[]})).some((t=>t.filename&&t.filename.startsWith("chrome-extension://")))}Vo(e){if(e.length>0){var t,n,i,a,o=(t=(n=e[0].stacktrace)==null?void 0:n.frames)!==null&&t!==void 0?t:[],u=o[o.length-1];return(i=u==null||(a=u.filename)==null?void 0:a.includes("posthog.com/static"))!==null&&i!==void 0&&i}return!1}Ho(e){return!Ye(e)&&Ve(e)}}},Q4=he({productTours:class{get Tr(){return this._instance.persistence}constructor(e){this.Go=null,this.Qo=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(e.ok){var t=e.config;if("productTours"in t){var n,i;if(this.Tr&&this.Tr.register({[ex]:!!t.productTours}),!cm(this._instance))return!this.Go&&Ye((n=this.Tr)==null?void 0:n.props[rc])||pd.info("product tours disabled; stopping and clearing cached tours"),(i=this.Go)==null||i.stop(),this.Go=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.Go&&cm(this._instance)&&this.ai((()=>this.Ko()))}ai(e){var t,n;(t=Oe.__PosthogExtensions__)!=null&&t.generateProductTours?e():(n=Oe.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"product-tours",(i=>{i?pd.error("Could not load product tours script",i):e()}))}Ko(){var e;!this.Go&&(e=Oe.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Go=Oe.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!Ve(this.Qo)||t){var n=this.Tr;if(n){var i=n.props[rc];if(Ve(i)&&!t)return this.Qo=i,void e(i,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:a=>{if(cm(this._instance)){var o=a.statusCode;if(o!==200||!a.json){var u="Product Tours API could not be loaded, status: "+o;return o===0?a.error||pd.warn(u):pd.error(u),void e([],{isLoaded:!1,error:u})}var f=Ve(a.json.product_tours)?a.json.product_tours:[];this.Qo=f,n&&n.register({[rc]:f}),e(f,{isLoaded:!0})}else e([],{isLoaded:!0})}})}else e(this.Qo,{isLoaded:!0})}getActiveProductTours(e){Ye(this.Go)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.Go.getActiveProductTours(e)}showProductTour(e){var t;(t=this.Go)==null||t.showTourById(e)}previewTour(e){this.Go?this.Go.previewTour(e):this.ai((()=>{var t;this.Ko(),(t=this.Go)==null||t.previewTour(e)}))}dismissProductTour(){var e;(e=this.Go)==null||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.Go)==null||e.nextStep()}previousStep(){var e;(e=this.Go)==null||e.previousStep()}clearCache(){var e;this.Qo=null,(e=this.Tr)==null||e.unregister(rc)}resetTour(e){var t;(t=this.Go)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.Go)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.Go)==null||t.cancelPendingTour(e)}}},bf),X4={siteApps:class{constructor(e){this.Jo=0,this._instance=e,this.Yo=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Xo(e,t){if(t){var n=this.globalsForEvent(t);this.Yo.push(n),this.Yo.length>1e3&&(this.Yo=this.Yo.slice(10))}}get siteAppLoaders(){var e;return(e=Oe._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}initialize(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.Xo.bind(this));this.tl=()=>{e(),this.Yo=[],this.tl=void 0}}}globalsForEvent(e){var t,n,i,a,o,u,f;if(!e)throw new Error("Event payload is required");var h={},p=this._instance.get_property("$groups")||[],g=this._instance.get_property("$stored_group_properties")||{};for(var x of Object.entries(g)){var b=x[0];h[b]={id:p[b],type:b,properties:x[1]}}var y=e.$set_once,_=e.$set;return{event:he({},R5(e,F4),{properties:he({},e.properties,_?{$set:he({},(t=(n=e.properties)==null?void 0:n.$set)!==null&&t!==void 0?t:{},_)}:{},y?{$set_once:he({},(i=(a=e.properties)==null?void 0:a.$set_once)!==null&&i!==void 0?i:{},y)}:{}),elements_chain:(o=(u=e.properties)==null?void 0:u.$elements_chain)!==null&&o!==void 0?o:"",distinct_id:(f=e.properties)==null?void 0:f.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:h}}el(e){var t,n=(t=e.tagName)==null?void 0:t.toLowerCase();return n==="style"&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(ai.error("prepare_external_dependency_stylesheet returned null"),null):n==="script"&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(e)||(ai.error("prepare_external_dependency_script returned null"),null):e}il(){var e,t,n,i,a,o,u,f;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var h=ke==null?void 0:ke.defaultView,p=h==null||(e=h.Node)==null?void 0:e.prototype;if(!h||!p)return()=>{};if(this.Jo++,this.rl)return this.nl();var g=[],x=this,b=new WeakSet,y=(C,k,E)=>{if(C!=null&&C[k]){var N=C[k];C[k]=E(N),g.push((()=>{C[k]=N}))}},_=C=>{if(b.has(C))return C;var k=x.el(C);return k&&b.add(k),k},j=C=>C.map((k=>typeof k=="string"?k:_(k))).filter((k=>!Hn(k)));return y(p,"appendChild",(C=>function(k){var E=_(k);return E?C.call(this,E):k})),y(p,"insertBefore",(C=>function(k,E){var N=_(k);return N?C.call(this,N,E):k})),y(p,"replaceChild",(C=>function(k,E){var N=_(k);return N?C.call(this,N,E):E})),[(t=h.Element)==null?void 0:t.prototype,(n=h.Document)==null?void 0:n.prototype,(i=h.DocumentFragment)==null?void 0:i.prototype].forEach((C=>{y(C,"append",(k=>function(){for(var E=arguments.length,N=new Array(E),D=0;E>D;D++)N[D]=arguments[D];return k.apply(this,j(N))})),y(C,"prepend",(k=>function(){for(var E=arguments.length,N=new Array(E),D=0;E>D;D++)N[D]=arguments[D];return k.apply(this,j(N))}))})),[(a=h.Element)==null?void 0:a.prototype,(o=h.CharacterData)==null?void 0:o.prototype,(u=h.DocumentType)==null?void 0:u.prototype].forEach((C=>{y(C,"before",(k=>function(){for(var E=arguments.length,N=new Array(E),D=0;E>D;D++)N[D]=arguments[D];return k.apply(this,j(N))})),y(C,"after",(k=>function(){for(var E=arguments.length,N=new Array(E),D=0;E>D;D++)N[D]=arguments[D];return k.apply(this,j(N))})),y(C,"replaceWith",(k=>function(){for(var E=arguments.length,N=new Array(E),D=0;E>D;D++)N[D]=arguments[D];var O=j(N);return N.length&&!O.length?void 0:k.apply(this,O)}))})),y((f=h.Element)==null?void 0:f.prototype,"insertAdjacentElement",(C=>function(k,E){var N=_(E);return N?C.call(this,k,N):null})),this.rl=()=>{g.forEach((C=>C())),this.rl=void 0},this.nl()}nl(){var e=!1;return()=>{var t;e||(e=!0,this.Jo--,this.Jo===0&&((t=this.rl)==null||t.call(this)))}}sl(e,t){t===void 0&&(t=!0);var n=this.il();try{var i=e(n);return t&&n(),i}catch(a){throw n(),a}}setupSiteApp(e){var t=this.apps[e.id],n=()=>{var u;!t.errored&&this.Yo.length&&(ai.info("Processing "+this.Yo.length+" events for site app with id "+e.id),this.Yo.forEach((f=>this.sl((()=>t.processEvent==null?void 0:t.processEvent(f))))),t.processedBuffer=!0),Object.values(this.apps).every((f=>f.processedBuffer||f.errored))&&((u=this.tl)==null||u.call(this))},i=!1,a=u=>{t.errored=!u,t.loaded=!0,ai.info("Site app with id "+e.id+" "+(u?"loaded":"errored")),i&&n()};try{var o=this.sl((u=>e.init({posthog:this._instance,callback(f){u(),a(f)}})),!1).processEvent;o&&(t.processEvent=o),i=!0}catch(u){ai.error(Vy+e.id,u),a(!1)}if(i&&t.loaded)try{n()}catch(u){ai.error("Error while processing buffered events PostHog app with config id "+e.id,u),t.errored=!0}}al(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var n of e)this.setupSiteApp(n)}ol(e){var t=this;if(Object.keys(this.apps).length!==0){var n=this.globalsForEvent(e),i=function(o){try{t.sl((()=>o.processEvent==null?void 0:o.processEvent(n)))}catch(u){ai.error("Error while processing event "+e.event+" for site app "+o.id,u)}};for(var a of Object.values(this.apps))i(a)}}onRemoteConfig(e){var t,n,i,a=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.al(),void this._instance.on("eventCaptured",(h=>this.ol(h)))):void ai.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((n=this.tl)==null||n.call(this),e.ok){var o=e.config;if((i=o.siteApps)!=null&&i.length)if(this.isEnabled){var u=function(){var h,p=f.id,g=f.url;Oe["__$$ph_site_app_"+p]=a._instance,(h=Oe.__PosthogExtensions__)==null||h.loadSiteApp==null||h.loadSiteApp(a._instance,g,(x=>{if(x)return ai.error(Vy+p,x)}))};for(var f of o.siteApps)u()}else ai.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},K4={tracingHeaders:class{constructor(e){this.ll=void 0,this.ul=void 0,this.hl=void 0,this.Co=()=>{var t,n,i=this.dl();i?(ye(this.ll)&&(this.ll=(t=Oe.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null?void 0:t._patchXHR(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),ye(this.ul)&&(this.ul=(n=Oe.__PosthogExtensions__)==null||(n=n.tracingHeadersPatchFns)==null?void 0:n._patchFetch(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.Ro()},this._instance=e}initialize(){this.startIfEnabledOrStop()}ai(e){var t,n;(t=Oe.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns?e():(n=Oe.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"tracing-headers",(i=>{if(i)return P4.error("failed to load script",i);e()}))}vl(){var e,t;return(e=(t=this._instance.config.tracing_headers)!==null&&t!==void 0?t:this._instance.config.addTracingHeaders)!==null&&e!==void 0?e:this._instance.config.__add_tracing_headers}dl(){var e=this.vl();return Ve(e)?(Ve(this.hl)?this.hl.splice(0,this.hl.length,...e):this.hl=[...e],e.length>0?this.hl:void 0):(Ve(this.hl)&&this.hl.splice(0),this.hl=e||void 0,this.hl)}Ro(){var e,t;(e=this.ll)==null||e.call(this),(t=this.ul)==null||t.call(this),this.ll=void 0,this.ul=void 0}startIfEnabledOrStop(){this.dl()?this.ai(this.Co):this.Ro()}}},Z4=he({surveys:class{get Ne(){return this._instance.config}constructor(e){this.cl=void 0,this._surveyManager=null,this.fl=!1,this.pl=[],this.gl=null,this.ml=null,this._instance=e,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this.Ne.disable_surveys){if(!e.ok)return kt.warn("Remote config unavailable. Not loading surveys.");var t=e.config.surveys;if(Ye(t))return kt.warn("Flags not loaded yet. Not loading surveys.");var n=Ve(t);this.cl=n?t.length>0:t,kt.info("flags response received, isSurveysEnabled: "+this.cl),this.loadIfEnabled()}}reset(){try{var e;(e=this._surveyEventReceiver)==null||e.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var t=[],n=0;n<localStorage.length;n++){var i=localStorage.key(n);(i!=null&&i.startsWith(u2)||i!=null&&i.startsWith("inProgressSurvey_"))&&t.push(i)}t.forEach((a=>localStorage.removeItem(a)))}catch{}}loadIfEnabled(){if(!this._surveyManager)if(this.fl)kt.info("Already initializing surveys, skipping...");else if(this.Ne.disable_surveys)kt.info(Gy);else if(this.Ne.cookieless_mode&&this._instance.consent.isOptedOut())kt.info("Not loading surveys in cookieless mode without consent.");else{var e=Oe==null?void 0:Oe.__PosthogExtensions__;if(e){if(!ye(this.cl)||this.Ne.advanced_enable_surveys){var t=this.cl||this.Ne.advanced_enable_surveys;this.fl=!0;try{var n=e.generateSurveys;if(n)return void this.yl(n,t);var i=e.loadExternalDependency;if(!i)return void this.bl(nx);i(this._instance,"surveys",(a=>{a||!e.generateSurveys?this.bl("Could not load surveys script",a):this.yl(e.generateSurveys,t)}))}catch(a){throw this.bl("Error initializing surveys",a),a}finally{this.fl=!1}}}else kt.error("PostHog Extensions not found.")}}yl(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new H4(this._instance),kt.info("Surveys loaded successfully"),this._l({isLoaded:!0})}bl(e,t){kt.error(e,t),this._l({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.pl.push(e),this._surveyManager&&this._l({isLoaded:!0}),()=>{this.pl=this.pl.filter((t=>t!==e))}}getSurveys(e,t){if(t===void 0&&(t=!1),this.Ne.disable_surveys)return kt.info(Gy),e([]);var n,i=this._instance.get_property(og);if(i&&!t)return e(i,{isLoaded:!0}),void(this.wl()&&this.getSurveys((()=>{}),!0));typeof Promise<"u"&&this.gl?this.gl.then((a=>e(a.surveys,a.context))):(typeof Promise<"u"&&(this.gl=new Promise((a=>{n=a}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.Ne.token),method:"GET",timestampMode:"query",timeout:this.Ne.surveys_request_timeout_ms,callback:a=>{var o;this.gl=null;var u=a.statusCode;if(u!==200||!a.json){var f="Surveys API could not be loaded, status: "+u;u!==0?kt.error(f):a.error||kt.warn(f),this.ml=Date.now();var h={isLoaded:!1,error:f};return e([],h),void(n==null||n({surveys:[],context:h}))}this.ml=null;var p,g=a.json.surveys||[],x=g.filter((y=>(function(_){return!(!_.start_date||_.end_date)})(y)&&(c2(y)||(function(_){var j;return!((j=_.conditions)==null||(j=j.actions)==null||(j=j.values)==null||!j.length)})(y))));x.length>0&&((p=this._surveyEventReceiver)==null||p.register(x)),(o=this._instance.persistence)==null||o.register({[og]:g,[Wd]:Date.now()});var b={isLoaded:!0};e(g,b),n==null||n({surveys:g,context:b})}}))}wl(){return this.kl()&&!this.gl&&!this.xl()}kl(){var e=this._instance.get_property(Wd);return sn(e)&&Date.now()-e>3e5}xl(){return sn(this.ml)&&3e5>Date.now()-this.ml}markSurveyAsSeen(e,t){var n,i={id:e,current_iteration:(n=t==null?void 0:t.iteration)!==null&&n!==void 0?n:null};d2(i);try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}}_l(e){for(var t of this.pl)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(n){kt.error("Error in survey callback",n)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!Ye(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);kt.warn("init was not called")}Sl(e){var t=null;return this.getSurveys((n=>{var i;t=(i=n.find((a=>a.id===e)))!==null&&i!==void 0?i:null})),t}Cl(e){if(Ye(this._surveyManager))return{eligible:!1,reason:md};var t=typeof e=="string"?this.Sl(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}Ml(e){if(Ye(this._surveyManager))return{eligible:!1,reason:md};var t=typeof e=="string"?this.Sl(e):e;return t?this._surveyManager.checkSurveyRenderability(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(Ye(this._surveyManager))return kt.warn("init was not called"),{visible:!1,disabledReason:md};var t=this.Ml(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return Ye(this._surveyManager)?(kt.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:md})):new Promise((n=>{this.getSurveys((i=>{var a,o=(a=i.find((f=>f.id===e)))!==null&&a!==void 0?a:null;if(o){var u=this.Ml(o);n({visible:u.eligible,disabledReason:u.reason})}else n({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t,n){var i;if(Ye(this._surveyManager))kt.warn("init was not called");else{var a=typeof e=="string"?this.Sl(e):e;if(a!=null&&a.id)if(j4.includes(a.type)){var o=ke==null?void 0:ke.querySelector(t);if(o)return(i=a.appearance)!=null&&i.surveyPopupDelaySeconds?(kt.info("Rendering survey "+a.id+" with delay of "+a.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var u,f;kt.info("Rendering survey "+a.id+" with delay of "+((u=a.appearance)==null?void 0:u.surveyPopupDelaySeconds)+" seconds"),(f=this._surveyManager)==null||f.renderSurvey(a,o,n),kt.info("Survey "+a.id+" rendered")}),1e3*a.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(a,o,n);kt.warn("Survey element not found")}else kt.warn("Surveys of type "+a.type+" cannot be rendered in the app");else kt.warn("Survey not found")}}displaySurvey(e,t){var n;if(Ye(this._surveyManager))kt.warn("init was not called");else{var i=this.Sl(e);if(i){var a=i;if((n=i.appearance)!=null&&n.surveyPopupDelaySeconds&&t.ignoreDelay&&(a=he({},i,{appearance:he({},i.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==yg.Popover&&t.initialResponses&&kt.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),t.ignoreConditions===!1){var o=this.Cl(i);if(!o.eligible)return void kt.warn("Survey is not eligible to be displayed: ",o.reason)}t.displayType!==yg.Inline?this._surveyManager.handlePopoverSurvey(a,t):this.renderSurvey(a,t.selector,t.properties)}else kt.warn("Survey not found")}}cancelPendingSurvey(e){Ye(this._surveyManager)?kt.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload==null||e.handlePageUnload()}}},bf),J4={toolbar:class{constructor(e){this.instance=e}Tl(e){Oe.ph_toolbar_state=e}El(){var e;return(e=Oe.ph_toolbar_state)!==null&&e!==void 0?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,t,n){if(e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),xg(this.instance.config)||!ie||!ke)return!1;e=e??ie.location,n=n??ie.history;try{if(!t){try{ie.localStorage.setItem("test","test"),ie.localStorage.removeItem("test")}catch{return!1}t=ie==null?void 0:ie.localStorage}var i,a=q4||nf(e.hash,"__posthog")||nf(e.hash,"state"),o=a?uy((()=>JSON.parse(atob(decodeURIComponent(a)))))||uy((()=>JSON.parse(decodeURIComponent(a)))):null;return o&&o.action==="ph_authorize"?((i=o).source="url",i&&Object.keys(i).length>0&&(o.desiredHash?e.hash=o.desiredHash:n?n.replaceState(n.state,"",e.pathname+e.search):e.hash="")):((i=JSON.parse(t.getItem(Yy)||"{}")).source="localstorage",delete i.userIntent),!(!i.token||this.instance.config.token!==i.token||(this.loadToolbar(i),0))}catch{return!1}}Il(e){var t=Oe.ph_load_toolbar||Oe.ph_load_editor;!Ye(t)&&pr(t)?t(e,this.instance):Wy.warn("No toolbar load function found")}loadToolbar(e){var t=!(ke==null||!ke.getElementById(Nw));if(!ie||t)return!1;var n=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=he({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},n?{instrument:!1}:{});if(ie.localStorage.setItem(Yy,JSON.stringify(he({},i,{source:void 0}))),this.El()===2)this.Il(i);else if(this.El()===0){var a;this.Tl(1),(a=Oe.__PosthogExtensions__)==null||a.loadExternalDependency==null||a.loadExternalDependency(this.instance,"toolbar",(o=>{if(o)return Wy.error("[Toolbar] Failed to load",o),void this.Tl(0);this.Tl(2),this.Il(i)})),Gt(ie,"turbolinks:load",(()=>{this.Tl(0),this.loadToolbar(i)}))}return!0}Pl(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,n){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),this.maybeLoadToolbar(e,t,n)}}},eE=he({experiments:Mn},bf),tE={conversations:class{constructor(e){this.Rl=void 0,this._conversationsManager=null,this.Al=!1,this.Fl=null,this.Ll=!1,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations&&(this.Ol=e.ok,e.ok)){var t=e.config.conversations;Ye(t)||(Wr(t)?this.Rl=t:(this.Rl=t.enabled,this.Fl=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.Rl=void 0,this.Fl=null,this.Ol=void 0,this.Ll=!1}loadIfEnabled(){if(!(this._conversationsManager||this.Al||this._instance.config.disable_conversations||xg(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=Oe==null?void 0:Oe.__PosthogExtensions__;if(e&&!ye(this.Rl)&&this.Rl)if(this.Fl&&this.Fl.token){this.Al=!0;try{var t=e.initConversations;if(t)return this.Dl(t),void(this.Al=!1);var n=e.loadExternalDependency;if(!n)return void this.$l(nx);n(this._instance,"conversations",(i=>{i||!e.initConversations?this.$l("Could not load conversations script",i):this.Dl(e.initConversations),this.Al=!1}))}catch(i){this.$l("Error initializing conversations",i),this.Al=!1}}else Rr.error("Conversations enabled but missing token in remote config.")}}Dl(e){if(this.Fl)try{this._conversationsManager=e(this.Fl,this._instance),this.Ll=!1,Rr.info("Conversations loaded successfully")}catch(t){this.$l("Error completing conversations initialization",t)}else Rr.error("Cannot complete initialization: remote config is null")}$l(e,t){Rr.error(e,t),this._conversationsManager=null,this.Al=!1,this.Ll=!0}show(){this._conversationsManager?this._conversationsManager.show():Rr.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Rl===!0&&!Hn(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":xg(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":this.Ol===!1?"remote_config_failed":ye(this.Rl)?this.Ol?"disabled_in_project":"remote_config_pending":this.Rl?Ye(this.Fl)||!this.Fl.token?"missing_token":Oe!=null&&Oe.__PosthogExtensions__?this.Al?"initializing":this.Ll?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.isVisible())!==null&&e!==void 0&&e}sendMessage(e,t,n){var i=this;return Ut((function*(){return i._conversationsManager?i._conversationsManager.sendMessage(e,t,n):(Rr.warn(ca),null)}))()}getMessages(e,t){var n=this;return Ut((function*(){return n._conversationsManager?n._conversationsManager.getMessages(e,t):(Rr.warn(ca),null)}))()}markAsRead(e){var t=this;return Ut((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Rr.warn(ca),null)}))()}getTickets(e){var t=this;return Ut((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Rr.warn(ca),null)}))()}requestRestoreLink(e){var t=this;return Ut((function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(Rr.warn(ca),null)}))()}restoreFromToken(e){var t=this;return Ut((function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(Rr.warn(ca),null)}))()}restoreFromUrlToken(){var e=this;return Ut((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Rr.warn(ca),null)}))()}getCurrentTicketId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getCurrentTicketId())!==null&&e!==void 0?e:null}getWidgetSessionId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getWidgetSessionId())!==null&&e!==void 0?e:null}Yn(){var e;(e=this._conversationsManager)==null||e.setIdentity()}Xn(){var e;(e=this._conversationsManager)==null||e.clearIdentity()}}},nE={logs:class{constructor(e){var t,n=this;this.Nl=!1,this.ql=!1,this.rt=Wt("[logs]"),this.jl=he({},this.rt,{error(){for(var i=arguments.length,a=new Array(i),o=0;i>o;o++)a[o]=arguments[o];a.some(Jy)||n.rt.error(...a)}}),this.er=[],this.Bl=[],this.ya=0,this.Hl=()=>{var i,a;this.ya=0,(i=this.Ul)==null||i.onReconnect(),(a=this.zl)==null||a.onReconnect()},this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.Nl=!0),ie&&Gt(ie,"online",this.Hl)}Wl(e,t,n,i){var a,o=(function(u,f){var h,p,g,x,b,y,_,j=(h=u==null?void 0:u.flushIntervalMs)!==null&&h!==void 0?h:3e3,C=(p=u==null?void 0:u.maxBufferSize)!==null&&p!==void 0?p:100,k=f!=null&&f.consoleCapture?void 0:(g=u==null?void 0:u.maxLogsPerInterval)!==null&&g!==void 0?g:1e3,E=ye(k)?Math.max(C,2048):Math.max(C,k),N=u==null?void 0:u.resourceAttributes;return{serviceName:(x=(b=N==null?void 0:N["service.name"])!==null&&b!==void 0?b:u==null?void 0:u.serviceName)!==null&&x!==void 0?x:f==null?void 0:f.serviceNameDefault,serviceVersion:(y=N==null?void 0:N["service.version"])!==null&&y!==void 0?y:u==null?void 0:u.serviceVersion,environment:(_=N==null?void 0:N["deployment.environment"])!==null&&_!==void 0?_:u==null?void 0:u.environment,resourceAttributes:N,beforeSend:u==null?void 0:u.beforeSend,flushIntervalMs:j,maxBufferSize:C,maxQueueSize:E,maxBatchRecordsPerPost:100,rateCapWindowMs:j,maxLogsPerInterval:k,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}})((a=this._instance)==null||(a=a.config)==null?void 0:a.logs,n);return[new l3(this.Vl(e,t),o,this.jl,(()=>this.Zl()),(u=>u()),void 0,i),o]}Gl(){var e,t=(e=this._instance)==null||(e=e.config)==null?void 0:e.logs;if(!this.Ul||this.Ql!==t){var n;(n=this.Ul)==null||n.reset(),this.Ql=t;var i=this.Wl((()=>this.er),(a=>{this.er=a}));this.Ul=i[0],this.Kl=i[1]}return this.Ul}Jl(){var e,t=(e=this._instance)==null||(e=e.config)==null?void 0:e.logs;if(!this.zl||this.Yl!==t){var n;(n=this.zl)==null||n.reset(),this.Yl=t;var i=this.Wl((()=>this.Bl),(a=>{this.Bl=a}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Zy);this.zl=i[0],this.Xl=i[1]}return this.zl}initialize(){this.loadIfEnabled()}onRemoteConfig(e){var t;if(e.ok){var n=(t=e.config.logs)==null?void 0:t.captureConsoleLogs;!Ye(n)&&n&&(this.Nl=!0,this.loadIfEnabled())}}reset(){var e,t;this.er=[],(e=this.Ul)==null||e.reset(),this.Bl=[],(t=this.zl)==null||t.reset(),this.ya=0}captureLog(e){this.Gl().captureLog(e)}he(e){this.Jl().captureLog(e)}get logger(){return this.tu||(this.tu={trace:(e,t)=>this.captureLog({body:e,level:"trace",attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:"debug",attributes:t}),info:(e,t)=>this.captureLog({body:e,level:"info",attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:"warn",attributes:t}),error:(e,t)=>this.captureLog({body:e,level:"error",attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:"fatal",attributes:t})}),this.tu}flushLogs(e){e?this.eu(e):(this.Ul&&this.Ul.flush().catch((t=>this.iu(t))),this.zl&&this.zl.flush().catch((t=>this.iu(t))))}iu(e){Jy(e)||this.rt.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(this.Nl&&!this.ql){var e=Oe==null?void 0:Oe.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,"logs",(n=>{var i;n||(i=e.logs)==null||!i.initializeLogs?this.rt.error("Could not load logs script",n):(e.logs.initializeLogs(this._instance),this.ql=!0)})):this.rt.error(nx)}else this.rt.error("PostHog Extensions not found.")}}Vl(e,t){var n=this._instance;return{get isDisabled(){return!1},get optedOut(){return!n.is_capturing()},getPersistedProperty:i=>i===Bi.LogsQueue?e():void 0,setPersistedProperty(i,a){var o;i===Bi.LogsQueue&&t((o=a)!==null&&o!==void 0?o:[])},Ot:i=>this.Ot(i),getLibraryId:()=>jt.LIB_NAME,getLibraryVersion:()=>jt.LIB_VERSION}}Ot(e){return new Promise((t=>{if(Pw(this.ya,3))t({kind:"fatal",error:dm(void 0,"logs endpoint is unreachable, dropping batch")});else{var n=!1,i=o=>{n||(n=!0,clearTimeout(a),t(o))},a=setTimeout((()=>{this.rt.warn("Logs request timed out before receiving a response"),i({kind:"retry-later",error:dm(void 0,"logs request timed out")})}),9e4);this._instance._send_request({method:"POST",url:this.ru(),data:e,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:o=>{var u=o.statusCode;if(this.nu(u),u>=200&&300>u)i({kind:"ok"});else if(u===413)i({kind:"too-large"});else if(u!==0&&u!==429&&500>u)i({kind:"fatal",error:new Error("logs request failed with status "+u)});else{var f;u===0?(o.error||this.rt.warn("Logs request failed before receiving an HTTP response"),i({kind:"retry-later",error:dm(o.error,"logs request failed before receiving an HTTP response")})):i({kind:"retry-later",error:(f=o.error)!==null&&f!==void 0?f:new Error("logs request failed with status "+u)})}}})}}))}nu(e){(e!==0||this._instance.__loaded)&&(this.ya=$w(e,this.ya,3,(()=>this.rt.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes."))))}eu(e){this.er.length>0&&this.su(e,this.er,this.Kl,jt.LIB_NAME,(t=>{this.er=t})),this.Bl.length>0&&this.su(e,this.Bl,this.Xl,Zy,(t=>{this.Bl=t}))}su(e,t,n,i,a){if(t.length!==0){var o=t.map((f=>f.record));a([]);var u=cw(o,ow(n,jt.LIB_NAME,jt.LIB_VERSION),i,jt.LIB_VERSION);this._instance._send_request({method:"POST",url:this.ru(),data:u,compression:"best-available",batchKey:"logs",transport:e})}}ru(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}Zl(){var e,t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var n=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),i=n.windowId,a=n.sessionStartTimestamp,o=n.lastActivityTimestamp;t.sessionId=n.sessionId,t.windowId=i,Ye(a)||(t.sessionStartTimestamp=a),Ye(o)||(t.lastActivityTimestamp=o)}if(Oe!=null&&(e=Oe.location)!=null&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?Ts(Oe.location.href):Oe.location.href),this._instance.featureFlags){var u=this._instance.featureFlags.getFlags();u&&u.length>0&&(t.activeFeatureFlags=u)}return t}}},rE={metrics:class{constructor(e){this.rt=Wt("[metrics]"),this._instance=e}initialize(){}Gl(){var e,t,n=(e=this._instance)==null||(e=e.config)==null?void 0:e.metrics;return this.Ul&&this.Ql===n||((t=this.Ul)==null||t.reset(),this.Ql=n,this.Ul=new o3(this.Vl(),(function(i){var a,o,u,f,h,p=i==null?void 0:i.resourceAttributes;return{serviceName:(a=p==null?void 0:p["service.name"])!==null&&a!==void 0?a:i==null?void 0:i.serviceName,serviceVersion:(o=p==null?void 0:p["service.version"])!==null&&o!==void 0?o:i==null?void 0:i.serviceVersion,environment:(u=p==null?void 0:p["deployment.environment"])!==null&&u!==void 0?u:i==null?void 0:i.environment,resourceAttributes:p,beforeSend:i==null?void 0:i.beforeSend,flushIntervalMs:(f=i==null?void 0:i.flushIntervalMs)!==null&&f!==void 0?f:1e4,maxSeriesPerFlush:(h=i==null?void 0:i.maxSeriesPerFlush)!==null&&h!==void 0?h:1e3}})(n),this.rt)),this.Ul}count(e,t,n){t===void 0&&(t=1),this.Gl().count(e,t,n)}gauge(e,t,n){this.Gl().gauge(e,t,n)}histogram(e,t,n){this.Gl().histogram(e,t,n)}flush(e){if(!this.Ul)return Promise.resolve();if(e){var t=this.Ul.drainWindow();return t&&this.Jt(t,e),Promise.resolve()}return this.Ul.flush().catch((n=>this.rt.error("PostHog metrics flush failed:",n)))}reset(){var e;(e=this.Ul)==null||e.reset()}Vl(){var e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},Jt:n=>t.Jt(n),getLibraryId:()=>jt.LIB_NAME,getLibraryVersion:()=>jt.LIB_VERSION}}Jt(e,t){return new Promise((n=>{var i=!1,a=u=>{i||(i=!0,clearTimeout(o),n(u))},o=setTimeout((()=>a({kind:"retry-later",error:new Error("metrics request timed out")})),9e4);this._instance._send_request(he({method:"POST",url:this.au(),data:e,compression:"best-available",batchKey:"metrics"},t&&{transport:t},{fireCallbackOnDrop:!0,callback(u){var f=u.statusCode;if(f>=200&&300>f)a({kind:"ok"});else if(f===413)a({kind:"too-large"});else if(f!==0&&f!==429&&500>f)a({kind:"fatal",error:new Error("metrics request failed with status "+f)});else{var h;a({kind:"retry-later",error:(h=u.error)!==null&&h!==void 0?h:new Error("metrics request failed with status "+f)})}}}))}))}au(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},iE=he({},bf,G4,Y4,W4,Q4,X4,Z4,K4,J4,eE,tE,nE,rE);Or.__defaultExtensionClasses=he({},iE);var Cc=(function(){jt.SDK_DIST_CHANNEL="npm";var e=fc[yl]=new Or;return(function(){function t(){t.done||(t.done=!0,h2=!1,Rt(fc,(function(n){n._dom_loaded()})))}ke!=null&&ke.addEventListener?ke.readyState==="complete"?t():Gt(ke,"DOMContentLoaded",t,{capture:!1}):ie&&we.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),e})();const sE="https://us.i.posthog.com",m2="cc-telemetry-enabled";let Eg=!1,Ec=!1;function aE(){return sE}function lE(){if(typeof localStorage>"u")return!0;const e=localStorage.getItem(m2);return e===null?!0:e==="true"}function g2(e){Eg&&(e?(Cc.opt_in_capturing({captureEventName:null}),Ec=!0):(Cc.opt_out_capturing(),Ec=!1))}function UD(e){typeof localStorage<"u"&&localStorage.setItem(m2,String(e)),g2(e)}function oE(){const e=void 0;return e?(Cc.init(e,{api_host:aE(),defaults:"2026-01-30",capture_pageview:!1,capture_pageleave:!0,capture_exceptions:!0,autocapture:!0,respect_dnt:!0}),Eg=!0,g2(lE()),!0):(Eg=!1,Ec=!1,!1)}function ux(e,t){Ec&&Cc.capture(e,t)}function Ms(e,t){Ec&&Cc.captureException(e,t)}function cE(e){ux("$pageview",{$current_url:e})}const di="/api",x2="companion_auth_token";function Rs(){if(typeof window>"u")return{};const e=localStorage.getItem(x2);return e?{Authorization:`Bearer ${e}`}:{}}function _a(e){e===401&&typeof window<"u"&&(localStorage.removeItem(x2),qn(async()=>{const{useStore:t}=await Promise.resolve().then(()=>CN);return{useStore:t}},void 0).then(({useStore:t})=>{t.getState().logout()}).catch(()=>{}))}function gn(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Lc(e,t,n,i){ux("api_request_succeeded",{method:e,path:t,status:i,duration_ms:Math.round(n)})}function fi(e,t,n,i,a){ux("api_request_failed",{method:e,path:t,status:a,duration_ms:Math.round(n),error:i instanceof Error?i.message:String(i)}),Ms(i,{method:e,path:t,status:a})}async function Ie(e,t){const n=gn();let i=!1;try{const a=await fetch(`${di}${e}`,{method:"POST",headers:{"Content-Type":"application/json",...Rs()},body:t?JSON.stringify(t):void 0});if(!a.ok){_a(a.status);const o=await a.json().catch(()=>({error:a.statusText})),u=new Error(o.error||a.statusText);throw fi("POST",e,gn()-n,u,a.status),i=!0,u}return Lc("POST",e,gn()-n,a.status),a.json()}catch(a){throw i||fi("POST",e,gn()-n,a),a}}async function Ae(e){const t=gn();let n=!1;try{const i=await fetch(`${di}${e}`,{headers:{...Rs()}});if(!i.ok){_a(i.status);const a=await i.json().catch(()=>({error:i.statusText})),o=new Error(a.error||i.statusText);throw fi("GET",e,gn()-t,o,i.status),n=!0,o}return Lc("GET",e,gn()-t,i.status),i.json()}catch(i){throw n||fi("GET",e,gn()-t,i),i}}async function Lr(e,t){const n=gn();let i=!1;try{const a=await fetch(`${di}${e}`,{method:"PUT",headers:{"Content-Type":"application/json",...Rs()},body:t?JSON.stringify(t):void 0});if(!a.ok){_a(a.status);const o=await a.json().catch(()=>({error:a.statusText})),u=new Error(o.error||a.statusText);throw fi("PUT",e,gn()-n,u,a.status),i=!0,u}return Lc("PUT",e,gn()-n,a.status),a.json()}catch(a){throw i||fi("PUT",e,gn()-n,a),a}}async function uE(e,t){const n=gn();let i=!1;try{const a=await fetch(`${di}${e}`,{method:"PATCH",headers:{"Content-Type":"application/json",...Rs()},body:t?JSON.stringify(t):void 0});if(!a.ok){_a(a.status);const o=await a.json().catch(()=>({error:a.statusText})),u=new Error(o.error||a.statusText);throw fi("PATCH",e,gn()-n,u,a.status),i=!0,u}return Lc("PATCH",e,gn()-n,a.status),a.json()}catch(a){throw i||fi("PATCH",e,gn()-n,a),a}}async function Dr(e,t){const n=gn();let i=!1;try{const a=await fetch(`${di}${e}`,{method:"DELETE",headers:{...t?{"Content-Type":"application/json"}:{},...Rs()},body:t?JSON.stringify(t):void 0});if(!a.ok){_a(a.status);const o=await a.json().catch(()=>({error:a.statusText})),u=new Error(o.error||a.statusText);throw fi("DELETE",e,gn()-n,u,a.status),i=!0,u}return Lc("DELETE",e,gn()-n,a.status),a.json()}catch(a){throw i||fi("DELETE",e,gn()-n,a),a}}async function dE(e,t){const n=await fetch(`${di}/sessions/create-stream`,{method:"POST",headers:{"Content-Type":"application/json",...Rs()},body:JSON.stringify(e??{})});if(!n.ok||!n.body){const f=await n.json().catch(()=>({error:n.statusText}));throw new Error(f.error||n.statusText)}const i=n.body.getReader(),a=new TextDecoder;let o="",u=null;for(;;){const{done:f,value:h}=await i.read();if(f)break;o+=a.decode(h,{stream:!0});const p=o.split(`
|
|
68
68
|
|
|
69
69
|
`);o=p.pop()||"";for(const g of p){if(!g.trim())continue;let x="",b="";for(const _ of g.split(`
|
|
@@ -126,7 +126,7 @@ ${H.resumeSessionId}`,children:"Continue"})]})]},`${H.resumeSessionId}-row-${H.s
|
|
|
126
126
|
`)})]}),n==="done"&&l.jsxs("div",{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4 text-cc-success",children:l.jsx("path",{fillRule:"evenodd",d:"M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm3.78-9.72a.75.75 0 0 0-1.06-1.06L7 8.94 5.28 7.22a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.06 0l4.25-4.25z"})}),l.jsx("h2",{className:"text-base font-semibold text-cc-success",children:"Sandbox Image Updated"})]}),l.jsx("p",{className:"text-sm text-cc-muted mb-5",children:"The Docker image has been updated successfully."}),l.jsx("div",{className:"flex justify-end",children:l.jsx("button",{type:"button",onClick:b,className:"px-4 py-2 min-h-[40px] rounded-lg text-sm font-medium bg-cc-primary hover:bg-cc-primary-hover text-white transition-colors cursor-pointer",children:"Done"})})]}),n==="error"&&l.jsxs("div",{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4 text-cc-error",children:l.jsx("path",{fillRule:"evenodd",d:"M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zM5.22 5.22a.75.75 0 0 1 1.06 0L8 6.94l1.72-1.72a.75.75 0 1 1 1.06 1.06L9.06 8l1.72 1.72a.75.75 0 1 1-1.06 1.06L8 9.06l-1.72 1.72a.75.75 0 0 1-1.06-1.06L6.94 8 5.22 6.28a.75.75 0 0 1 0-1.06z"})}),l.jsx("h2",{className:"text-base font-semibold text-cc-error",children:"Image Update Failed"})]}),l.jsxs("p",{className:"text-sm text-cc-muted mb-2",children:["Failed to update the Docker image.",(u==null?void 0:u.error)&&l.jsx("span",{className:"block mt-1 text-xs text-cc-error",children:u.error})]}),(u==null?void 0:u.progress)&&u.progress.length>0&&l.jsx("pre",{className:"px-3 py-2 text-[10px] font-mono-code bg-cc-code-bg rounded-lg text-cc-muted max-h-[120px] overflow-auto whitespace-pre-wrap mb-4","data-testid":"pull-progress",children:u.progress.slice(-20).join(`
|
|
127
127
|
`)}),l.jsxs("div",{className:"flex justify-end gap-2",children:[l.jsx("button",{type:"button",onClick:y,className:"px-4 py-2 min-h-[40px] rounded-lg text-sm font-medium bg-cc-hover hover:bg-cc-active text-cc-fg transition-colors cursor-pointer",children:"Close"}),l.jsx("button",{type:"button",onClick:g,className:"px-4 py-2 min-h-[40px] rounded-lg text-sm font-medium bg-cc-primary hover:bg-cc-primary-hover text-white transition-colors cursor-pointer",children:"Retry"})]})]})]})})}function VD({phase:e}){return l.jsx("div",{className:"relative bg-black/50 rounded-lg overflow-hidden h-[300px] flex items-center justify-center",children:l.jsxs("div",{className:"bg-cc-bg rounded-xl shadow-xl border border-cc-border w-full max-w-sm mx-4 overflow-hidden",children:[e==="prompt"&&l.jsxs("div",{className:"p-5",children:[l.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-1.5",children:"Update Sandbox Image?"}),l.jsx("p",{className:"text-xs text-cc-muted mb-4",children:"A new version of The Companion was installed. Would you like to also update the sandbox Docker image?"}),l.jsxs("div",{className:"flex items-center justify-between px-2 py-2 rounded-lg bg-cc-hover text-xs text-cc-fg mb-4",children:[l.jsx("span",{children:"Always update automatically"}),l.jsx("span",{className:"relative inline-flex h-4 w-7 rounded-full bg-cc-border",children:l.jsx("span",{className:"inline-block h-3 w-3 rounded-full bg-white shadow translate-x-0 mt-0.5 ml-0.5"})})]}),l.jsxs("div",{className:"flex justify-end gap-2",children:[l.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs bg-cc-hover text-cc-fg",children:"Skip"}),l.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs bg-cc-primary text-white",children:"Update"})]})]}),e==="pulling"&&l.jsxs("div",{className:"p-5",children:[l.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[l.jsx("svg",{className:"w-3.5 h-3.5 animate-spin text-cc-primary",viewBox:"0 0 24 24",fill:"none",children:l.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2.5",strokeDasharray:"31.4 31.4",strokeLinecap:"round"})}),l.jsx("h2",{className:"text-sm font-semibold text-cc-fg",children:"Updating Sandbox Image..."})]}),l.jsx("pre",{className:"px-2 py-1.5 text-[9px] font-mono-code bg-cc-code-bg rounded text-cc-muted max-h-[80px] overflow-auto whitespace-pre-wrap",children:`Pulling the-companion:latest...
|
|
128
128
|
Layer 1/5: abc123 downloading
|
|
129
|
-
Layer 2/5: def456 complete`})]}),e==="done"&&l.jsxs("div",{className:"p-5",children:[l.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-success",children:l.jsx("path",{fillRule:"evenodd",d:"M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm3.78-9.72a.75.75 0 0 0-1.06-1.06L7 8.94 5.28 7.22a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.06 0l4.25-4.25z"})}),l.jsx("h2",{className:"text-sm font-semibold text-cc-success",children:"Sandbox Image Updated"})]}),l.jsx("p",{className:"text-xs text-cc-muted mb-4",children:"The Docker image has been updated successfully."}),l.jsx("div",{className:"flex justify-end",children:l.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs bg-cc-primary text-white",children:"Done"})})]}),e==="error"&&l.jsxs("div",{className:"p-5",children:[l.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-error",children:l.jsx("path",{fillRule:"evenodd",d:"M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zM5.22 5.22a.75.75 0 0 1 1.06 0L8 6.94l1.72-1.72a.75.75 0 1 1 1.06 1.06L9.06 8l1.72 1.72a.75.75 0 1 1-1.06 1.06L8 9.06l-1.72 1.72a.75.75 0 0 1-1.06-1.06L6.94 8 5.22 6.28a.75.75 0 0 1 0-1.06z"})}),l.jsx("h2",{className:"text-sm font-semibold text-cc-error",children:"Image Update Failed"})]}),l.jsx("p",{className:"text-xs text-cc-muted mb-4",children:"Failed to update the Docker image."}),l.jsxs("div",{className:"flex justify-end gap-2",children:[l.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs bg-cc-hover text-cc-fg",children:"Close"}),l.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs bg-cc-primary text-white",children:"Retry"})]})]})]})})}const Lm=["welcome","claude","codex","done"],m5='button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])';function Hg(){return typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function vD({onComplete:e}){const[t,n]=S.useState("welcome"),[i,a]=S.useState(""),[o,u]=S.useState(""),[f,h]=S.useState(!1),[p,g]=S.useState(""),[x,b]=S.useState(!1),[y,_]=S.useState(!1),[j,C]=S.useState(Hg),k=S.useRef(null);S.useEffect(()=>{j||requestAnimationFrame(()=>C(!0))},[j]),S.useEffect(()=>{const I=k.current;if(!I)return;function M(J){if(J.key==="Escape"){J.preventDefault();return}if(J.key!=="Tab")return;const Y=I.querySelectorAll(m5);if(Y.length===0)return;const $=Y[0],F=Y[Y.length-1];J.shiftKey?document.activeElement===$&&(J.preventDefault(),F.focus()):document.activeElement===F&&(J.preventDefault(),$.focus())}document.addEventListener("keydown",M);const le=I.querySelector(m5);return le==null||le.focus(),()=>document.removeEventListener("keydown",M)},[t]);const E=S.useCallback(async()=>{if(!i.trim()){n("codex");return}h(!0),g("");try{await Ce.updateSettings({claudeCodeOAuthToken:i.trim()}),b(!0),n("codex")}catch(I){g(I instanceof Error?I.message:"Failed to save token")}finally{h(!1)}},[i]),N=S.useCallback(async()=>{h(!0),g("");try{(await Ce.getSettings()).codexDeviceAuthConfigured?(_(!0),await O()):g("No Codex auth found. Run codex --login in your terminal first.")}catch(I){g(I instanceof Error?I.message:"Failed to check auth status")}finally{h(!1)}},[]),D=S.useCallback(async()=>{h(!0),g("");try{await Ce.updateSettings({openaiApiKey:o.trim()}),_(!0),await O()}catch(I){g(I instanceof Error?I.message:"Failed to save API key")}finally{h(!1)}},[o]),O=S.useCallback(async()=>{try{await Ce.updateSettings({onboardingCompleted:!0})}catch{}n("done")},[]),L=S.useCallback(()=>{e()},[e]),G=S.useCallback(async()=>{await O(),e()},[O,e]),P=S.useCallback(I=>{g(""),n(I)},[]),Q=Lm.indexOf(t),B=Hg();return Ol.createPortal(l.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"linear-gradient(145deg, var(--color-cc-bg) 0%, color-mix(in srgb, var(--color-cc-bg) 94%, var(--color-cc-primary) 6%) 100%)",opacity:j?1:0,transition:B?"none":"opacity 400ms cubic-bezier(0.16, 1, 0.3, 1)"},children:[l.jsx("div",{className:"absolute top-0 left-0 right-0 h-[2px]",style:{background:"linear-gradient(90deg, transparent 0%, var(--color-cc-primary) 30%, var(--color-cc-primary) 70%, transparent 100%)",opacity:.6}}),l.jsxs("div",{ref:k,role:"dialog","aria-modal":"true","aria-label":"Provider setup",className:"w-full max-w-[520px] mx-6",style:{transform:j?"translateY(0)":"translateY(12px)",opacity:j?1:0,transition:B?"none":"transform 500ms cubic-bezier(0.16, 1, 0.3, 1) 100ms, opacity 400ms cubic-bezier(0.16, 1, 0.3, 1) 100ms"},children:[t!=="done"&&l.jsx("div",{className:"flex items-center gap-1.5 mb-6 justify-center",role:"status","aria-label":`Step ${Q+1} of ${Lm.length-1}`,children:Lm.slice(0,3).map((I,M)=>l.jsx("div",{className:"h-[3px] rounded-full transition-[transform,background,opacity] duration-300",style:{width:32,transform:M===Q?"scaleX(1)":"scaleX(0.375)",transformOrigin:"center",background:M<=Q?"var(--color-cc-primary)":"var(--color-cc-border)",opacity:M<=Q?1:.5}},I))}),l.jsxs("div",{className:"bg-cc-card border border-cc-border overflow-hidden",style:{borderRadius:16,boxShadow:"0 1px 3px var(--color-cc-border), 0 8px 32px var(--color-cc-border)"},children:[t==="welcome"&&l.jsx(bD,{onSetupClaude:()=>P("claude"),onSetupCodex:()=>P("codex")}),t==="claude"&&l.jsx(yD,{token:i,onTokenChange:a,onSave:E,onSkip:()=>P("codex"),saving:f,error:p}),t==="codex"&&l.jsx(_D,{apiKey:o,onApiKeyChange:u,onCheckAuth:N,onSaveApiKey:D,onSkip:()=>O(),onBack:()=>P("claude"),saving:f,error:p}),t==="done"&&l.jsx(wD,{claudeConfigured:x,codexConfigured:y,onDone:L})]}),t==="welcome"&&l.jsx("button",{onClick:G,className:"w-full text-center text-xs text-cc-muted hover:text-cc-fg transition-colors mt-4 min-h-[44px] flex items-center justify-center",children:"Skip setup — I'll configure this later in Settings"})]})]}),document.body)}function bD({onSetupClaude:e,onSetupCodex:t}){return l.jsxs("div",{className:"p-7 pb-6",children:[l.jsxs("div",{className:"mb-6",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-[0.12em] text-cc-muted font-medium mb-2",children:"First time setup"}),l.jsx("h2",{className:"text-xl font-semibold text-cc-fg leading-tight",children:"Welcome to The Companion"}),l.jsx("p",{className:"text-sm text-cc-muted mt-1.5 leading-relaxed",children:"Connect your AI providers to start coding. Configure one or both."})]}),l.jsxs("div",{className:"space-y-2.5",children:[l.jsxs("button",{onClick:e,className:"provider-card--claude group w-full flex items-center gap-3.5 p-3.5 min-h-[52px] rounded-xl border border-cc-border bg-cc-bg text-left transition-[transform,border-color,box-shadow] duration-150",children:[l.jsx("div",{className:"w-9 h-9 rounded-lg flex items-center justify-center flex-shrink-0 font-semibold text-sm bg-cc-primary/10 text-cc-primary",children:"C"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-[13px] font-medium text-cc-fg",children:"Claude Code"}),l.jsx("div",{className:"text-[11px] text-cc-muted leading-snug mt-0.5",children:"Anthropic's coding agent — requires an OAuth token"})]}),l.jsx("svg",{className:"w-4 h-4 text-cc-muted flex-shrink-0 transition-transform duration-150 group-hover:translate-x-0.5",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),l.jsxs("button",{onClick:t,className:"provider-card--codex group w-full flex items-center gap-3.5 p-3.5 min-h-[52px] rounded-xl border border-cc-border bg-cc-bg text-left transition-[transform,border-color,box-shadow] duration-150",children:[l.jsx("div",{className:"w-9 h-9 rounded-lg flex items-center justify-center flex-shrink-0 font-semibold text-sm bg-cc-codex/10 text-cc-codex",children:"X"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-[13px] font-medium text-cc-fg",children:"Codex"}),l.jsx("div",{className:"text-[11px] text-cc-muted leading-snug mt-0.5",children:"OpenAI's coding agent — log in via ChatGPT"})]}),l.jsx("svg",{className:"w-4 h-4 text-cc-muted flex-shrink-0 transition-transform duration-150 group-hover:translate-x-0.5",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]})]})]})}function yD({token:e,onTokenChange:t,onSave:n,onSkip:i,saving:a,error:o}){const u=S.useRef(null);S.useEffect(()=>{var h;(h=u.current)==null||h.focus()},[]);const f="claude-token-error";return l.jsxs("div",{className:"p-7 pb-6",children:[l.jsxs("div",{className:"mb-5",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-[0.12em] text-cc-muted font-medium mb-2",children:"Step 1 of 2"}),l.jsx("h2",{className:"text-xl font-semibold text-cc-fg leading-tight",children:"Set up Claude Code"}),l.jsx("p",{className:"text-sm text-cc-muted mt-1.5 leading-relaxed",children:"Generate an OAuth token by running this in your terminal:"})]}),l.jsxs("div",{className:"rounded-lg overflow-hidden mb-4 border border-cc-border",style:{background:"var(--color-cc-code-bg)"},children:[l.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-cc-border",children:[l.jsxs("div",{className:"flex items-center gap-1.5","aria-hidden":"true",children:[l.jsx("div",{className:"w-[7px] h-[7px] rounded-full bg-cc-error opacity-60"}),l.jsx("div",{className:"w-[7px] h-[7px] rounded-full bg-cc-warning opacity-60"}),l.jsx("div",{className:"w-[7px] h-[7px] rounded-full bg-cc-success opacity-60"})]}),l.jsx(QS,{text:"claude setup-token"})]}),l.jsx("div",{className:"px-3.5 py-3",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-cc-muted text-xs font-mono-code select-none","aria-hidden":"true",children:"$"}),l.jsx("code",{className:"text-[13px] font-mono-code text-cc-fg select-all",children:"claude setup-token"})]})})]}),l.jsxs("div",{className:"mb-4",children:[l.jsx("label",{htmlFor:"claude-token",className:"text-xs text-cc-muted block mb-1.5",children:"OAuth Token"}),l.jsx("input",{ref:u,id:"claude-token",type:"password",value:e,onChange:h=>t(h.target.value),placeholder:"Paste the token from your terminal...","aria-describedby":o?f:void 0,"aria-invalid":o?!0:void 0,className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg border border-cc-border text-cc-fg placeholder:text-cc-muted/60 focus:outline-none focus:ring-1 focus:ring-cc-primary focus:border-cc-primary font-mono-code transition-shadow duration-150"})]}),o&&l.jsxs("div",{id:f,role:"alert",className:"flex items-start gap-2 mb-4 text-xs text-cc-error",children:[l.jsxs("svg",{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24","aria-hidden":"true",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("path",{d:"M12 8v4m0 4h.01"})]}),l.jsx("span",{children:o})]}),l.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[l.jsx("button",{onClick:i,className:"flex-1 px-4 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors",children:"Skip"}),l.jsx("button",{onClick:n,disabled:a,className:"btn-primary-aa flex-1 px-4 py-2.5 min-h-[44px] rounded-lg text-sm font-medium text-white transition-[background,opacity] duration-150 disabled:opacity-50",style:{boxShadow:a?"none":"0 1px 3px var(--color-cc-primary-btn)"},children:a?"Saving...":e.trim()?"Save & Continue":"Continue"})]})]})}function _D({apiKey:e,onApiKeyChange:t,onCheckAuth:n,onSaveApiKey:i,onSkip:a,onBack:o,saving:u,error:f}){const[h,p]=S.useState(!1),g="codex-auth-error";return l.jsxs("div",{className:"p-7 pb-6",children:[l.jsxs("div",{className:"mb-5",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-[0.12em] text-cc-muted font-medium mb-2",children:"Step 2 of 2"}),l.jsx("h2",{className:"text-xl font-semibold text-cc-fg leading-tight",children:"Set up Codex"}),l.jsx("p",{className:"text-sm text-cc-muted mt-1.5 leading-relaxed",children:"Log in with your ChatGPT account by running this in your terminal:"})]}),l.jsxs("div",{className:"rounded-lg overflow-hidden mb-4 border border-cc-border",style:{background:"var(--color-cc-code-bg)"},children:[l.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-cc-border",children:[l.jsxs("div",{className:"flex items-center gap-1.5","aria-hidden":"true",children:[l.jsx("div",{className:"w-[7px] h-[7px] rounded-full bg-cc-error opacity-60"}),l.jsx("div",{className:"w-[7px] h-[7px] rounded-full bg-cc-warning opacity-60"}),l.jsx("div",{className:"w-[7px] h-[7px] rounded-full bg-cc-success opacity-60"})]}),l.jsx(QS,{text:"codex --login"})]}),l.jsx("div",{className:"px-3.5 py-3",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-cc-muted text-xs font-mono-code select-none","aria-hidden":"true",children:"$"}),l.jsx("code",{className:"text-[13px] font-mono-code text-cc-fg select-all",children:"codex --login"})]})})]}),f&&l.jsxs("div",{id:g,role:"alert",className:"flex items-start gap-2 mb-4 text-xs text-cc-error",children:[l.jsxs("svg",{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24","aria-hidden":"true",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("path",{d:"M12 8v4m0 4h.01"})]}),l.jsx("span",{children:f})]}),l.jsxs("div",{className:"mb-4",children:[l.jsxs("button",{onClick:()=>p(!h),className:"text-xs text-cc-muted hover:text-cc-fg transition-colors flex items-center gap-1",children:[l.jsx("svg",{className:"w-3 h-3 transition-transform duration-150",style:{transform:h?"rotate(90deg)":"rotate(0deg)"},fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),"Or use an API key instead"]}),l.jsx("div",{className:"accordion-panel","data-open":h?"true":"false",children:l.jsx("div",{className:"accordion-inner",children:l.jsxs("div",{className:"mt-3",children:[l.jsx("label",{htmlFor:"openai-key",className:"text-xs text-cc-muted block mb-1.5",children:"OpenAI API Key"}),l.jsx("input",{id:"openai-key",type:"password",value:e,onChange:x=>t(x.target.value),placeholder:"sk-...","aria-describedby":f?g:void 0,"aria-invalid":f?!0:void 0,className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg border border-cc-border text-cc-fg placeholder:text-cc-muted/60 focus:outline-none focus:ring-1 focus:ring-cc-codex focus:border-cc-codex font-mono-code transition-shadow duration-150"})]})})})]}),l.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[l.jsxs("button",{onClick:o,className:"px-3 py-2.5 min-h-[44px] min-w-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg transition-colors flex items-center gap-1",children:[l.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})}),"Back"]}),l.jsx("div",{className:"flex-1"}),l.jsx("button",{onClick:a,className:"px-4 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors",children:"Skip"}),l.jsx("button",{onClick:e.trim()?i:n,disabled:u,className:"btn-codex-aa px-5 py-2.5 min-h-[44px] rounded-lg text-sm font-medium text-white transition-[background,opacity] duration-150 disabled:opacity-50",style:{boxShadow:u?"none":"0 1px 3px var(--color-cc-codex-btn)"},children:u?"Checking...":e.trim()?"Save & Finish":"I've logged in"})]})]})}function wD({claudeConfigured:e,codexConfigured:t,onDone:n}){const i=!e&&!t,a=Hg(),[o,u]=S.useState(a);return S.useEffect(()=>{o||requestAnimationFrame(()=>u(!0))},[o]),l.jsxs("div",{className:"p-7 pb-6 text-center",style:{opacity:o?1:0,transform:o?"translateY(0)":"translateY(8px)",transition:a?"none":"opacity 400ms cubic-bezier(0.16, 1, 0.3, 1), transform 400ms cubic-bezier(0.16, 1, 0.3, 1)"},children:[l.jsx("div",{className:"w-14 h-14 mx-auto rounded-2xl flex items-center justify-center mb-5",style:{background:i?"var(--color-cc-hover)":"color-mix(in srgb, var(--color-cc-success) 12%, transparent)"},children:i?l.jsx("svg",{className:"w-6 h-6 text-cc-muted",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}):l.jsx("svg",{className:"w-6 h-6 text-cc-success",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),l.jsx("h2",{className:"text-xl font-semibold text-cc-fg mb-2",children:i?"Setup Skipped":"You're all set!"}),l.jsx("div",{className:"text-sm text-cc-muted leading-relaxed mb-6",children:i?"You can configure providers anytime in Settings.":l.jsxs(l.Fragment,{children:[e&&l.jsx("span",{className:"block",children:"Claude Code is ready."}),t&&l.jsx("span",{className:"block",children:"Codex is ready."}),l.jsx("span",{className:"block mt-1 text-xs",children:"You can update these anytime in Settings."})]})}),l.jsx("button",{onClick:n,className:"btn-primary-aa w-full px-4 py-2.5 min-h-[44px] rounded-lg text-sm font-medium text-white transition-[background] duration-150",style:{boxShadow:"0 1px 3px var(--color-cc-primary-btn)"},children:"Get Started"})]})}function QS({text:e}){const[t,n]=S.useState(!1),i=S.useCallback(()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)}).catch(()=>{})},[e]);return l.jsx("button",{onClick:i,className:"text-[10px] text-cc-muted hover:text-cc-fg transition-colors flex items-center gap-1 min-h-[44px] min-w-[44px] justify-end","aria-label":"Copy command",children:t?l.jsxs(l.Fragment,{children:[l.jsx("svg",{className:"w-3 h-3 text-cc-success",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),"Copied!"]}):l.jsxs(l.Fragment,{children:[l.jsxs("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:[l.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),l.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),"Copy"]})})}const SD=S.lazy(()=>qn(()=>import("./Playground-D4grJraF.js"),[]).then(e=>({default:e.Playground}))),kD=S.lazy(()=>qn(()=>import("./SettingsPage-BqgHW-iW.js"),[]).then(e=>({default:e.SettingsPage}))),jD=S.lazy(()=>qn(()=>import("./IntegrationsPage-qtFQh0W4.js"),[]).then(e=>({default:e.IntegrationsPage}))),ND=S.lazy(()=>qn(()=>import("./LinearSettingsPage-xRA0eYZu.js"),[]).then(e=>({default:e.LinearSettingsPage}))),CD=S.lazy(()=>qn(()=>import("./LinearOAuthSettingsPage-BQI6rpIY.js"),[]).then(e=>({default:e.LinearOAuthSettingsPage}))),ED=S.lazy(()=>qn(()=>import("./TailscalePage-Bwn1jXsi.js"),[]).then(e=>({default:e.TailscalePage}))),TD=S.lazy(()=>qn(()=>import("./PromptsPage-HjtFVFMk.js"),[]).then(e=>({default:e.PromptsPage}))),AD=S.lazy(()=>qn(()=>Promise.resolve().then(()=>fL),void 0).then(e=>({default:e.EnvManager}))),MD=S.lazy(()=>qn(()=>import("./SandboxManager-CzLhWS6u.js"),[]).then(e=>({default:e.SandboxManager}))),RD=S.lazy(()=>qn(()=>import("./CronManager-Bd7Y5oVN.js"),[]).then(e=>({default:e.CronManager}))),LD=S.lazy(()=>qn(()=>import("./AgentsPage-CF3SGtxh.js"),[]).then(e=>({default:e.AgentsPage}))),DD=S.lazy(()=>qn(()=>import("./RunsPage-BRn8vlFq.js"),[]).then(e=>({default:e.RunsPage}))),zD=S.lazy(()=>qn(()=>import("./DashboardPage-DExUR_C4.js"),[]).then(e=>({default:e.DashboardPage})));function fr(){return l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsx("div",{className:"text-sm text-cc-muted",children:"Loading..."})})}function OD(){return S.useSyncExternalStore(e=>(window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)),()=>window.location.hash)}function BD(){const e=X(V=>V.isAuthenticated),t=X(V=>V.darkMode),n=X(V=>V.currentSessionId),i=X(V=>V.sidebarOpen),a=X(V=>V.taskPanelOpen),o=X(V=>V.homeResetKey),u=X(V=>V.activeTab),f=X(V=>V.sessionCreating),h=X(V=>V.sessionCreatingBackend),p=X(V=>V.creationProgress),g=X(V=>V.creationError),x=X(V=>V.updateOverlayActive),b=OD(),y=S.useMemo(()=>fx(b),[b]),_=y.page==="settings",j=y.page==="prompts",C=y.page==="integrations",k=y.page==="integration-linear",E=y.page==="integration-linear-oauth",N=y.page==="integration-tailscale",D=y.page==="environments",O=y.page==="sandboxes",L=y.page==="scheduled",G=y.page==="agents"||y.page==="agent-detail",P=y.page==="runs",Q=y.page==="dashboard",B=y.page==="session"||y.page==="home";S.useEffect(()=>{cE(b||"#/")},[b]),S.useEffect(()=>{document.documentElement.classList.toggle("dark",t)},[t]);const I=S.useRef(X.getState().currentSessionId);S.useEffect(()=>{if(I.current!==null&&y.page==="home"){hx(I.current,!0),I.current=null;return}if(I.current=null,y.page==="session"){const V=X.getState();V.currentSessionId!==y.sessionId&&V.setCurrentSession(y.sessionId),Rc(y.sessionId)}else if(y.page==="home"){const V=X.getState();V.currentSessionId!==null&&V.setCurrentSession(null)}},[y]);const M=X(V=>n?V.changedFilesTick.get(n)??0:0),le=X(V=>V.diffBase),J=X(V=>V.setGitChangedFilesCount),Y=X(V=>{var ge,R;return n&&(((ge=V.sessions.get(n))==null?void 0:ge.cwd)||((R=V.sdkSessions.find(z=>z.sessionId===n))==null?void 0:R.cwd))||null});S.useEffect(()=>{if(!n||!Y)return;let V=!1;return Ce.getChangedFiles(Y,le).then(({files:ge})=>{if(V)return;const R=`${Y}/`,z=ge.filter(Z=>Z.path===Y||Z.path.startsWith(R)).length;J(n,z)}).catch(()=>{}),()=>{V=!0}},[n,Y,le,M,J]),S.useEffect(()=>{const V=()=>{Ce.checkForUpdate().then(R=>{X.getState().setUpdateInfo(R)}).catch(()=>{})};V();const ge=setInterval(V,300*1e3);return()=>clearInterval(ge)},[]),S.useEffect(()=>{const V=()=>{Ce.getClaudeCompat().then(R=>{X.getState().setClaudeCompatInfo(R)}).catch(()=>{})};V();const ge=setInterval(V,300*1e3);return()=>clearInterval(ge)},[]);const[$,F]=S.useState(!1);return S.useEffect(()=>{e&&Ce.getSettings().then(V=>{V.publicUrl&&X.getState().setPublicUrl(V.publicUrl),V.onboardingCompleted||F(!0)}).catch(()=>{})},[e]),S.useEffect(()=>{localStorage.getItem("companion_docker_prompt_pending")==="1"&&localStorage.removeItem("companion_docker_prompt_pending")},[]),e?y.page==="playground"?l.jsx(S.Suspense,{fallback:l.jsx(fr,{}),children:l.jsx(SD,{})}):l.jsxs("div",{className:"fixed inset-0 flex font-sans-ui bg-cc-bg text-cc-fg antialiased pt-safe overflow-hidden overscroll-none",children:[i&&l.jsx("div",{className:"fixed inset-0 bg-black/30 z-30 md:hidden",onClick:()=>X.getState().setSidebarOpen(!1)}),l.jsx("div",{className:`
|
|
129
|
+
Layer 2/5: def456 complete`})]}),e==="done"&&l.jsxs("div",{className:"p-5",children:[l.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-success",children:l.jsx("path",{fillRule:"evenodd",d:"M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm3.78-9.72a.75.75 0 0 0-1.06-1.06L7 8.94 5.28 7.22a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.06 0l4.25-4.25z"})}),l.jsx("h2",{className:"text-sm font-semibold text-cc-success",children:"Sandbox Image Updated"})]}),l.jsx("p",{className:"text-xs text-cc-muted mb-4",children:"The Docker image has been updated successfully."}),l.jsx("div",{className:"flex justify-end",children:l.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs bg-cc-primary text-white",children:"Done"})})]}),e==="error"&&l.jsxs("div",{className:"p-5",children:[l.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-error",children:l.jsx("path",{fillRule:"evenodd",d:"M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zM5.22 5.22a.75.75 0 0 1 1.06 0L8 6.94l1.72-1.72a.75.75 0 1 1 1.06 1.06L9.06 8l1.72 1.72a.75.75 0 1 1-1.06 1.06L8 9.06l-1.72 1.72a.75.75 0 0 1-1.06-1.06L6.94 8 5.22 6.28a.75.75 0 0 1 0-1.06z"})}),l.jsx("h2",{className:"text-sm font-semibold text-cc-error",children:"Image Update Failed"})]}),l.jsx("p",{className:"text-xs text-cc-muted mb-4",children:"Failed to update the Docker image."}),l.jsxs("div",{className:"flex justify-end gap-2",children:[l.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs bg-cc-hover text-cc-fg",children:"Close"}),l.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs bg-cc-primary text-white",children:"Retry"})]})]})]})})}const Lm=["welcome","claude","codex","done"],m5='button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])';function Hg(){return typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function vD({onComplete:e}){const[t,n]=S.useState("welcome"),[i,a]=S.useState(""),[o,u]=S.useState(""),[f,h]=S.useState(!1),[p,g]=S.useState(""),[x,b]=S.useState(!1),[y,_]=S.useState(!1),[j,C]=S.useState(Hg),k=S.useRef(null);S.useEffect(()=>{j||requestAnimationFrame(()=>C(!0))},[j]),S.useEffect(()=>{const I=k.current;if(!I)return;function M(J){if(J.key==="Escape"){J.preventDefault();return}if(J.key!=="Tab")return;const Y=I.querySelectorAll(m5);if(Y.length===0)return;const $=Y[0],F=Y[Y.length-1];J.shiftKey?document.activeElement===$&&(J.preventDefault(),F.focus()):document.activeElement===F&&(J.preventDefault(),$.focus())}document.addEventListener("keydown",M);const le=I.querySelector(m5);return le==null||le.focus(),()=>document.removeEventListener("keydown",M)},[t]);const E=S.useCallback(async()=>{if(!i.trim()){n("codex");return}h(!0),g("");try{await Ce.updateSettings({claudeCodeOAuthToken:i.trim()}),b(!0),n("codex")}catch(I){g(I instanceof Error?I.message:"Failed to save token")}finally{h(!1)}},[i]),N=S.useCallback(async()=>{h(!0),g("");try{(await Ce.getSettings()).codexDeviceAuthConfigured?(_(!0),await O()):g("No Codex auth found. Run codex --login in your terminal first.")}catch(I){g(I instanceof Error?I.message:"Failed to check auth status")}finally{h(!1)}},[]),D=S.useCallback(async()=>{h(!0),g("");try{await Ce.updateSettings({openaiApiKey:o.trim()}),_(!0),await O()}catch(I){g(I instanceof Error?I.message:"Failed to save API key")}finally{h(!1)}},[o]),O=S.useCallback(async()=>{try{await Ce.updateSettings({onboardingCompleted:!0})}catch{}n("done")},[]),L=S.useCallback(()=>{e()},[e]),G=S.useCallback(async()=>{await O(),e()},[O,e]),P=S.useCallback(I=>{g(""),n(I)},[]),Q=Lm.indexOf(t),B=Hg();return Ol.createPortal(l.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"linear-gradient(145deg, var(--color-cc-bg) 0%, color-mix(in srgb, var(--color-cc-bg) 94%, var(--color-cc-primary) 6%) 100%)",opacity:j?1:0,transition:B?"none":"opacity 400ms cubic-bezier(0.16, 1, 0.3, 1)"},children:[l.jsx("div",{className:"absolute top-0 left-0 right-0 h-[2px]",style:{background:"linear-gradient(90deg, transparent 0%, var(--color-cc-primary) 30%, var(--color-cc-primary) 70%, transparent 100%)",opacity:.6}}),l.jsxs("div",{ref:k,role:"dialog","aria-modal":"true","aria-label":"Provider setup",className:"w-full max-w-[520px] mx-6",style:{transform:j?"translateY(0)":"translateY(12px)",opacity:j?1:0,transition:B?"none":"transform 500ms cubic-bezier(0.16, 1, 0.3, 1) 100ms, opacity 400ms cubic-bezier(0.16, 1, 0.3, 1) 100ms"},children:[t!=="done"&&l.jsx("div",{className:"flex items-center gap-1.5 mb-6 justify-center",role:"status","aria-label":`Step ${Q+1} of ${Lm.length-1}`,children:Lm.slice(0,3).map((I,M)=>l.jsx("div",{className:"h-[3px] rounded-full transition-[transform,background,opacity] duration-300",style:{width:32,transform:M===Q?"scaleX(1)":"scaleX(0.375)",transformOrigin:"center",background:M<=Q?"var(--color-cc-primary)":"var(--color-cc-border)",opacity:M<=Q?1:.5}},I))}),l.jsxs("div",{className:"bg-cc-card border border-cc-border overflow-hidden",style:{borderRadius:16,boxShadow:"0 1px 3px var(--color-cc-border), 0 8px 32px var(--color-cc-border)"},children:[t==="welcome"&&l.jsx(bD,{onSetupClaude:()=>P("claude"),onSetupCodex:()=>P("codex")}),t==="claude"&&l.jsx(yD,{token:i,onTokenChange:a,onSave:E,onSkip:()=>P("codex"),saving:f,error:p}),t==="codex"&&l.jsx(_D,{apiKey:o,onApiKeyChange:u,onCheckAuth:N,onSaveApiKey:D,onSkip:()=>O(),onBack:()=>P("claude"),saving:f,error:p}),t==="done"&&l.jsx(wD,{claudeConfigured:x,codexConfigured:y,onDone:L})]}),t==="welcome"&&l.jsx("button",{onClick:G,className:"w-full text-center text-xs text-cc-muted hover:text-cc-fg transition-colors mt-4 min-h-[44px] flex items-center justify-center",children:"Skip setup — I'll configure this later in Settings"})]})]}),document.body)}function bD({onSetupClaude:e,onSetupCodex:t}){return l.jsxs("div",{className:"p-7 pb-6",children:[l.jsxs("div",{className:"mb-6",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-[0.12em] text-cc-muted font-medium mb-2",children:"First time setup"}),l.jsx("h2",{className:"text-xl font-semibold text-cc-fg leading-tight",children:"Welcome to The Companion"}),l.jsx("p",{className:"text-sm text-cc-muted mt-1.5 leading-relaxed",children:"Connect your AI providers to start coding. Configure one or both."})]}),l.jsxs("div",{className:"space-y-2.5",children:[l.jsxs("button",{onClick:e,className:"provider-card--claude group w-full flex items-center gap-3.5 p-3.5 min-h-[52px] rounded-xl border border-cc-border bg-cc-bg text-left transition-[transform,border-color,box-shadow] duration-150",children:[l.jsx("div",{className:"w-9 h-9 rounded-lg flex items-center justify-center flex-shrink-0 font-semibold text-sm bg-cc-primary/10 text-cc-primary",children:"C"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-[13px] font-medium text-cc-fg",children:"Claude Code"}),l.jsx("div",{className:"text-[11px] text-cc-muted leading-snug mt-0.5",children:"Anthropic's coding agent — requires an OAuth token"})]}),l.jsx("svg",{className:"w-4 h-4 text-cc-muted flex-shrink-0 transition-transform duration-150 group-hover:translate-x-0.5",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),l.jsxs("button",{onClick:t,className:"provider-card--codex group w-full flex items-center gap-3.5 p-3.5 min-h-[52px] rounded-xl border border-cc-border bg-cc-bg text-left transition-[transform,border-color,box-shadow] duration-150",children:[l.jsx("div",{className:"w-9 h-9 rounded-lg flex items-center justify-center flex-shrink-0 font-semibold text-sm bg-cc-codex/10 text-cc-codex",children:"X"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-[13px] font-medium text-cc-fg",children:"Codex"}),l.jsx("div",{className:"text-[11px] text-cc-muted leading-snug mt-0.5",children:"OpenAI's coding agent — log in via ChatGPT"})]}),l.jsx("svg",{className:"w-4 h-4 text-cc-muted flex-shrink-0 transition-transform duration-150 group-hover:translate-x-0.5",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]})]})]})}function yD({token:e,onTokenChange:t,onSave:n,onSkip:i,saving:a,error:o}){const u=S.useRef(null);S.useEffect(()=>{var h;(h=u.current)==null||h.focus()},[]);const f="claude-token-error";return l.jsxs("div",{className:"p-7 pb-6",children:[l.jsxs("div",{className:"mb-5",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-[0.12em] text-cc-muted font-medium mb-2",children:"Step 1 of 2"}),l.jsx("h2",{className:"text-xl font-semibold text-cc-fg leading-tight",children:"Set up Claude Code"}),l.jsx("p",{className:"text-sm text-cc-muted mt-1.5 leading-relaxed",children:"Generate an OAuth token by running this in your terminal:"})]}),l.jsxs("div",{className:"rounded-lg overflow-hidden mb-4 border border-cc-border",style:{background:"var(--color-cc-code-bg)"},children:[l.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-cc-border",children:[l.jsxs("div",{className:"flex items-center gap-1.5","aria-hidden":"true",children:[l.jsx("div",{className:"w-[7px] h-[7px] rounded-full bg-cc-error opacity-60"}),l.jsx("div",{className:"w-[7px] h-[7px] rounded-full bg-cc-warning opacity-60"}),l.jsx("div",{className:"w-[7px] h-[7px] rounded-full bg-cc-success opacity-60"})]}),l.jsx(QS,{text:"claude setup-token"})]}),l.jsx("div",{className:"px-3.5 py-3",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-cc-muted text-xs font-mono-code select-none","aria-hidden":"true",children:"$"}),l.jsx("code",{className:"text-[13px] font-mono-code text-cc-fg select-all",children:"claude setup-token"})]})})]}),l.jsxs("div",{className:"mb-4",children:[l.jsx("label",{htmlFor:"claude-token",className:"text-xs text-cc-muted block mb-1.5",children:"OAuth Token"}),l.jsx("input",{ref:u,id:"claude-token",type:"password",value:e,onChange:h=>t(h.target.value),placeholder:"Paste the token from your terminal...","aria-describedby":o?f:void 0,"aria-invalid":o?!0:void 0,className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg border border-cc-border text-cc-fg placeholder:text-cc-muted/60 focus:outline-none focus:ring-1 focus:ring-cc-primary focus:border-cc-primary font-mono-code transition-shadow duration-150"})]}),o&&l.jsxs("div",{id:f,role:"alert",className:"flex items-start gap-2 mb-4 text-xs text-cc-error",children:[l.jsxs("svg",{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24","aria-hidden":"true",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("path",{d:"M12 8v4m0 4h.01"})]}),l.jsx("span",{children:o})]}),l.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[l.jsx("button",{onClick:i,className:"flex-1 px-4 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors",children:"Skip"}),l.jsx("button",{onClick:n,disabled:a,className:"btn-primary-aa flex-1 px-4 py-2.5 min-h-[44px] rounded-lg text-sm font-medium text-white transition-[background,opacity] duration-150 disabled:opacity-50",style:{boxShadow:a?"none":"0 1px 3px var(--color-cc-primary-btn)"},children:a?"Saving...":e.trim()?"Save & Continue":"Continue"})]})]})}function _D({apiKey:e,onApiKeyChange:t,onCheckAuth:n,onSaveApiKey:i,onSkip:a,onBack:o,saving:u,error:f}){const[h,p]=S.useState(!1),g="codex-auth-error";return l.jsxs("div",{className:"p-7 pb-6",children:[l.jsxs("div",{className:"mb-5",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-[0.12em] text-cc-muted font-medium mb-2",children:"Step 2 of 2"}),l.jsx("h2",{className:"text-xl font-semibold text-cc-fg leading-tight",children:"Set up Codex"}),l.jsx("p",{className:"text-sm text-cc-muted mt-1.5 leading-relaxed",children:"Log in with your ChatGPT account by running this in your terminal:"})]}),l.jsxs("div",{className:"rounded-lg overflow-hidden mb-4 border border-cc-border",style:{background:"var(--color-cc-code-bg)"},children:[l.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-cc-border",children:[l.jsxs("div",{className:"flex items-center gap-1.5","aria-hidden":"true",children:[l.jsx("div",{className:"w-[7px] h-[7px] rounded-full bg-cc-error opacity-60"}),l.jsx("div",{className:"w-[7px] h-[7px] rounded-full bg-cc-warning opacity-60"}),l.jsx("div",{className:"w-[7px] h-[7px] rounded-full bg-cc-success opacity-60"})]}),l.jsx(QS,{text:"codex --login"})]}),l.jsx("div",{className:"px-3.5 py-3",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-cc-muted text-xs font-mono-code select-none","aria-hidden":"true",children:"$"}),l.jsx("code",{className:"text-[13px] font-mono-code text-cc-fg select-all",children:"codex --login"})]})})]}),f&&l.jsxs("div",{id:g,role:"alert",className:"flex items-start gap-2 mb-4 text-xs text-cc-error",children:[l.jsxs("svg",{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24","aria-hidden":"true",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("path",{d:"M12 8v4m0 4h.01"})]}),l.jsx("span",{children:f})]}),l.jsxs("div",{className:"mb-4",children:[l.jsxs("button",{onClick:()=>p(!h),className:"text-xs text-cc-muted hover:text-cc-fg transition-colors flex items-center gap-1",children:[l.jsx("svg",{className:"w-3 h-3 transition-transform duration-150",style:{transform:h?"rotate(90deg)":"rotate(0deg)"},fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),"Or use an API key instead"]}),l.jsx("div",{className:"accordion-panel","data-open":h?"true":"false",children:l.jsx("div",{className:"accordion-inner",children:l.jsxs("div",{className:"mt-3",children:[l.jsx("label",{htmlFor:"openai-key",className:"text-xs text-cc-muted block mb-1.5",children:"OpenAI API Key"}),l.jsx("input",{id:"openai-key",type:"password",value:e,onChange:x=>t(x.target.value),placeholder:"sk-...","aria-describedby":f?g:void 0,"aria-invalid":f?!0:void 0,className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg border border-cc-border text-cc-fg placeholder:text-cc-muted/60 focus:outline-none focus:ring-1 focus:ring-cc-codex focus:border-cc-codex font-mono-code transition-shadow duration-150"})]})})})]}),l.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[l.jsxs("button",{onClick:o,className:"px-3 py-2.5 min-h-[44px] min-w-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg transition-colors flex items-center gap-1",children:[l.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})}),"Back"]}),l.jsx("div",{className:"flex-1"}),l.jsx("button",{onClick:a,className:"px-4 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors",children:"Skip"}),l.jsx("button",{onClick:e.trim()?i:n,disabled:u,className:"btn-codex-aa px-5 py-2.5 min-h-[44px] rounded-lg text-sm font-medium text-white transition-[background,opacity] duration-150 disabled:opacity-50",style:{boxShadow:u?"none":"0 1px 3px var(--color-cc-codex-btn)"},children:u?"Checking...":e.trim()?"Save & Finish":"I've logged in"})]})]})}function wD({claudeConfigured:e,codexConfigured:t,onDone:n}){const i=!e&&!t,a=Hg(),[o,u]=S.useState(a);return S.useEffect(()=>{o||requestAnimationFrame(()=>u(!0))},[o]),l.jsxs("div",{className:"p-7 pb-6 text-center",style:{opacity:o?1:0,transform:o?"translateY(0)":"translateY(8px)",transition:a?"none":"opacity 400ms cubic-bezier(0.16, 1, 0.3, 1), transform 400ms cubic-bezier(0.16, 1, 0.3, 1)"},children:[l.jsx("div",{className:"w-14 h-14 mx-auto rounded-2xl flex items-center justify-center mb-5",style:{background:i?"var(--color-cc-hover)":"color-mix(in srgb, var(--color-cc-success) 12%, transparent)"},children:i?l.jsx("svg",{className:"w-6 h-6 text-cc-muted",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}):l.jsx("svg",{className:"w-6 h-6 text-cc-success",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),l.jsx("h2",{className:"text-xl font-semibold text-cc-fg mb-2",children:i?"Setup Skipped":"You're all set!"}),l.jsx("div",{className:"text-sm text-cc-muted leading-relaxed mb-6",children:i?"You can configure providers anytime in Settings.":l.jsxs(l.Fragment,{children:[e&&l.jsx("span",{className:"block",children:"Claude Code is ready."}),t&&l.jsx("span",{className:"block",children:"Codex is ready."}),l.jsx("span",{className:"block mt-1 text-xs",children:"You can update these anytime in Settings."})]})}),l.jsx("button",{onClick:n,className:"btn-primary-aa w-full px-4 py-2.5 min-h-[44px] rounded-lg text-sm font-medium text-white transition-[background] duration-150",style:{boxShadow:"0 1px 3px var(--color-cc-primary-btn)"},children:"Get Started"})]})}function QS({text:e}){const[t,n]=S.useState(!1),i=S.useCallback(()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)}).catch(()=>{})},[e]);return l.jsx("button",{onClick:i,className:"text-[10px] text-cc-muted hover:text-cc-fg transition-colors flex items-center gap-1 min-h-[44px] min-w-[44px] justify-end","aria-label":"Copy command",children:t?l.jsxs(l.Fragment,{children:[l.jsx("svg",{className:"w-3 h-3 text-cc-success",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),"Copied!"]}):l.jsxs(l.Fragment,{children:[l.jsxs("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:[l.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),l.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),"Copy"]})})}const SD=S.lazy(()=>qn(()=>import("./Playground-DlzomEOu.js"),[]).then(e=>({default:e.Playground}))),kD=S.lazy(()=>qn(()=>import("./SettingsPage-BvrrlEKj.js"),[]).then(e=>({default:e.SettingsPage}))),jD=S.lazy(()=>qn(()=>import("./IntegrationsPage-CK_ThzWg.js"),[]).then(e=>({default:e.IntegrationsPage}))),ND=S.lazy(()=>qn(()=>import("./LinearSettingsPage-BwjC9Vd-.js"),[]).then(e=>({default:e.LinearSettingsPage}))),CD=S.lazy(()=>qn(()=>import("./LinearOAuthSettingsPage-InTf-E7u.js"),[]).then(e=>({default:e.LinearOAuthSettingsPage}))),ED=S.lazy(()=>qn(()=>import("./TailscalePage-fE7Z9uiF.js"),[]).then(e=>({default:e.TailscalePage}))),TD=S.lazy(()=>qn(()=>import("./PromptsPage-hRZhLUYR.js"),[]).then(e=>({default:e.PromptsPage}))),AD=S.lazy(()=>qn(()=>Promise.resolve().then(()=>fL),void 0).then(e=>({default:e.EnvManager}))),MD=S.lazy(()=>qn(()=>import("./SandboxManager-Bq_aXA1z.js"),[]).then(e=>({default:e.SandboxManager}))),RD=S.lazy(()=>qn(()=>import("./CronManager-DxLaNh9T.js"),[]).then(e=>({default:e.CronManager}))),LD=S.lazy(()=>qn(()=>import("./AgentsPage-BBi92OuO.js"),[]).then(e=>({default:e.AgentsPage}))),DD=S.lazy(()=>qn(()=>import("./RunsPage-zsVmbFoi.js"),[]).then(e=>({default:e.RunsPage}))),zD=S.lazy(()=>qn(()=>import("./DashboardPage-BvuDoRlp.js"),[]).then(e=>({default:e.DashboardPage})));function fr(){return l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsx("div",{className:"text-sm text-cc-muted",children:"Loading..."})})}function OD(){return S.useSyncExternalStore(e=>(window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)),()=>window.location.hash)}function BD(){const e=X(V=>V.isAuthenticated),t=X(V=>V.darkMode),n=X(V=>V.currentSessionId),i=X(V=>V.sidebarOpen),a=X(V=>V.taskPanelOpen),o=X(V=>V.homeResetKey),u=X(V=>V.activeTab),f=X(V=>V.sessionCreating),h=X(V=>V.sessionCreatingBackend),p=X(V=>V.creationProgress),g=X(V=>V.creationError),x=X(V=>V.updateOverlayActive),b=OD(),y=S.useMemo(()=>fx(b),[b]),_=y.page==="settings",j=y.page==="prompts",C=y.page==="integrations",k=y.page==="integration-linear",E=y.page==="integration-linear-oauth",N=y.page==="integration-tailscale",D=y.page==="environments",O=y.page==="sandboxes",L=y.page==="scheduled",G=y.page==="agents"||y.page==="agent-detail",P=y.page==="runs",Q=y.page==="dashboard",B=y.page==="session"||y.page==="home";S.useEffect(()=>{cE(b||"#/")},[b]),S.useEffect(()=>{document.documentElement.classList.toggle("dark",t)},[t]);const I=S.useRef(X.getState().currentSessionId);S.useEffect(()=>{if(I.current!==null&&y.page==="home"){hx(I.current,!0),I.current=null;return}if(I.current=null,y.page==="session"){const V=X.getState();V.currentSessionId!==y.sessionId&&V.setCurrentSession(y.sessionId),Rc(y.sessionId)}else if(y.page==="home"){const V=X.getState();V.currentSessionId!==null&&V.setCurrentSession(null)}},[y]);const M=X(V=>n?V.changedFilesTick.get(n)??0:0),le=X(V=>V.diffBase),J=X(V=>V.setGitChangedFilesCount),Y=X(V=>{var ge,R;return n&&(((ge=V.sessions.get(n))==null?void 0:ge.cwd)||((R=V.sdkSessions.find(z=>z.sessionId===n))==null?void 0:R.cwd))||null});S.useEffect(()=>{if(!n||!Y)return;let V=!1;return Ce.getChangedFiles(Y,le).then(({files:ge})=>{if(V)return;const R=`${Y}/`,z=ge.filter(Z=>Z.path===Y||Z.path.startsWith(R)).length;J(n,z)}).catch(()=>{}),()=>{V=!0}},[n,Y,le,M,J]),S.useEffect(()=>{const V=()=>{Ce.checkForUpdate().then(R=>{X.getState().setUpdateInfo(R)}).catch(()=>{})};V();const ge=setInterval(V,300*1e3);return()=>clearInterval(ge)},[]),S.useEffect(()=>{const V=()=>{Ce.getClaudeCompat().then(R=>{X.getState().setClaudeCompatInfo(R)}).catch(()=>{})};V();const ge=setInterval(V,300*1e3);return()=>clearInterval(ge)},[]);const[$,F]=S.useState(!1);return S.useEffect(()=>{e&&Ce.getSettings().then(V=>{V.publicUrl&&X.getState().setPublicUrl(V.publicUrl),V.onboardingCompleted||F(!0)}).catch(()=>{})},[e]),S.useEffect(()=>{localStorage.getItem("companion_docker_prompt_pending")==="1"&&localStorage.removeItem("companion_docker_prompt_pending")},[]),e?y.page==="playground"?l.jsx(S.Suspense,{fallback:l.jsx(fr,{}),children:l.jsx(SD,{})}):l.jsxs("div",{className:"fixed inset-0 flex font-sans-ui bg-cc-bg text-cc-fg antialiased pt-safe overflow-hidden overscroll-none",children:[i&&l.jsx("div",{className:"fixed inset-0 bg-black/30 z-30 md:hidden",onClick:()=>X.getState().setSidebarOpen(!1)}),l.jsx("div",{className:`
|
|
130
130
|
fixed inset-y-0 left-0 md:relative md:inset-auto z-40 md:z-auto
|
|
131
131
|
h-full shrink-0 transition-all duration-200 pt-safe md:pt-0
|
|
132
132
|
${i?"w-full md:w-[260px] translate-x-0":"w-0 -translate-x-full md:w-0 md:-translate-x-full"}
|
|
@@ -136,4 +136,4 @@ Layer 2/5: def456 complete`})]}),e==="done"&&l.jsxs("div",{className:"p-5",child
|
|
|
136
136
|
h-full shrink-0 transition-all duration-200 pt-safe lg:pt-0
|
|
137
137
|
${a?"w-full lg:w-[320px] translate-x-0":"w-0 translate-x-full lg:w-0 lg:translate-x-full"}
|
|
138
138
|
overflow-hidden
|
|
139
|
-
`,children:l.jsx(lD,{sessionId:n})})]}),l.jsx(gD,{active:x}),l.jsx(xD,{}),$&&l.jsx(vD,{onComplete:()=>F(!1)})]}):l.jsx(mE,{})}class PD extends S.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,n){Ms(t,{source:"react_error_boundary",componentStack:n.componentStack})}render(){return this.state.hasError?l.jsx("div",{className:"h-[100dvh] flex items-center justify-center bg-cc-bg text-cc-fg px-4",children:l.jsxs("div",{className:"max-w-md w-full rounded-xl border border-cc-border bg-cc-card p-5 shadow-sm",children:[l.jsx("h1",{className:"text-base font-semibold",children:"A runtime error occurred"}),l.jsx("p",{className:"text-sm text-cc-muted mt-2",children:"Reload the page to recover. The error has been reported."}),l.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"mt-4 inline-flex items-center rounded-md bg-cc-primary px-3 py-1.5 text-sm text-white hover:bg-cc-primary-hover cursor-pointer",children:"Reload"})]})}):this.props.children}}oE();rN.createRoot(document.getElementById("root")).render(l.jsx(S.StrictMode,{children:l.jsx(PD,{children:l.jsx(BD,{})})}));qn(()=>import("./sw-register-
|
|
139
|
+
`,children:l.jsx(lD,{sessionId:n})})]}),l.jsx(gD,{active:x}),l.jsx(xD,{}),$&&l.jsx(vD,{onComplete:()=>F(!1)})]}):l.jsx(mE,{})}class PD extends S.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,n){Ms(t,{source:"react_error_boundary",componentStack:n.componentStack})}render(){return this.state.hasError?l.jsx("div",{className:"h-[100dvh] flex items-center justify-center bg-cc-bg text-cc-fg px-4",children:l.jsxs("div",{className:"max-w-md w-full rounded-xl border border-cc-border bg-cc-card p-5 shadow-sm",children:[l.jsx("h1",{className:"text-base font-semibold",children:"A runtime error occurred"}),l.jsx("p",{className:"text-sm text-cc-muted mt-2",children:"Reload the page to recover. The error has been reported."}),l.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"mt-4 inline-flex items-center rounded-md bg-cc-primary px-3 py-1.5 text-sm text-white hover:bg-cc-primary-hover cursor-pointer",children:"Reload"})]})}):this.props.children}}oE();rN.createRoot(document.getElementById("root")).render(l.jsx(S.StrictMode,{children:l.jsx(PD,{children:l.jsx(BD,{})})}));qn(()=>import("./sw-register-Cjt2BQTW.js"),[]).catch(()=>{});export{WR as A,n5 as B,iL as C,FD as D,OS as E,pL as F,QL as G,AR as H,HD as I,ID as J,gc as L,eR as M,OR as P,fD as S,j5 as T,dD as U,qn as _,Ce as a,fm as b,Dl as c,qD as d,wE as e,VD as f,lE as g,dR as h,uL as i,l as j,fR as k,sL as l,GL as m,hx as n,YL as o,Es as p,Nl as q,S as r,UD as s,PL as t,X as u,xc as v,LL as w,Ld as x,Mc as y,Ol as z};
|