rivet-design 0.14.16 → 0.14.17

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.
Files changed (71) hide show
  1. package/README.md +19 -0
  2. package/README.npm.md +19 -0
  3. package/bin/rivet.js +196 -28
  4. package/dist/agent-variants/contracts.d.ts +1 -1
  5. package/dist/agent-variants/contracts.js +4 -4
  6. package/dist/agent-variants/contracts.js.map +1 -1
  7. package/dist/agent-variants/directionAuthoring.d.ts +2 -0
  8. package/dist/agent-variants/directionAuthoring.d.ts.map +1 -1
  9. package/dist/agent-variants/directionAuthoring.js +2 -0
  10. package/dist/agent-variants/directionAuthoring.js.map +1 -1
  11. package/dist/cli/commandNames.d.ts.map +1 -1
  12. package/dist/cli/commandNames.js +1 -0
  13. package/dist/cli/commandNames.js.map +1 -1
  14. package/dist/cli/commands/mcpServe.d.ts.map +1 -1
  15. package/dist/cli/commands/mcpServe.js +3 -0
  16. package/dist/cli/commands/mcpServe.js.map +1 -1
  17. package/dist/cli/commands/update.d.ts +4 -0
  18. package/dist/cli/commands/update.d.ts.map +1 -0
  19. package/dist/cli/commands/update.js +71 -0
  20. package/dist/cli/commands/update.js.map +1 -0
  21. package/dist/cli/router.d.ts.map +1 -1
  22. package/dist/cli/router.js +8 -0
  23. package/dist/cli/router.js.map +1 -1
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +2 -8
  26. package/dist/index.js.map +1 -1
  27. package/dist/install/automaticCliUpdate.d.ts +50 -0
  28. package/dist/install/automaticCliUpdate.d.ts.map +1 -0
  29. package/dist/install/automaticCliUpdate.js +470 -0
  30. package/dist/install/automaticCliUpdate.js.map +1 -0
  31. package/dist/install/codexGuidance.d.ts +2 -0
  32. package/dist/install/codexGuidance.d.ts.map +1 -1
  33. package/dist/install/codexGuidance.js +13 -1
  34. package/dist/install/codexGuidance.js.map +1 -1
  35. package/dist/install/harnesses.d.ts +12 -2
  36. package/dist/install/harnesses.d.ts.map +1 -1
  37. package/dist/install/harnesses.js +78 -30
  38. package/dist/install/harnesses.js.map +1 -1
  39. package/dist/install/mcpRegistration.d.ts +4 -0
  40. package/dist/install/mcpRegistration.d.ts.map +1 -1
  41. package/dist/install/mcpRegistration.js +48 -6
  42. package/dist/install/mcpRegistration.js.map +1 -1
  43. package/dist/routes/agentVariants.d.ts.map +1 -1
  44. package/dist/routes/agentVariants.js +5 -0
  45. package/dist/routes/agentVariants.js.map +1 -1
  46. package/dist/services/TelemetryService.d.ts.map +1 -1
  47. package/dist/services/TelemetryService.js.map +1 -1
  48. package/dist/services/VariantGenerationService.d.ts.map +1 -1
  49. package/dist/services/VariantGenerationService.js +32 -5
  50. package/dist/services/VariantGenerationService.js.map +1 -1
  51. package/dist/services/VariantRunService.d.ts +3 -0
  52. package/dist/services/VariantRunService.d.ts.map +1 -1
  53. package/dist/services/VariantRunService.js +26 -1
  54. package/dist/services/VariantRunService.js.map +1 -1
  55. package/dist/types/change-request-types.d.ts +3 -0
  56. package/dist/types/change-request-types.d.ts.map +1 -1
  57. package/dist/utils/displayLocale.d.ts +10 -0
  58. package/dist/utils/displayLocale.d.ts.map +1 -0
  59. package/dist/utils/displayLocale.js +30 -0
  60. package/dist/utils/displayLocale.js.map +1 -0
  61. package/dist/utils/skills/claude-skill.d.ts +1 -1
  62. package/dist/utils/skills/claude-skill.d.ts.map +1 -1
  63. package/dist/utils/skills/cli-guidance.d.ts +2 -2
  64. package/dist/utils/skills/cli-guidance.d.ts.map +1 -1
  65. package/dist/utils/skills/cli-guidance.js +7 -4
  66. package/dist/utils/skills/cli-guidance.js.map +1 -1
  67. package/dist/utils/skills/cursor-rules.d.ts +1 -1
  68. package/dist/utils/skills/cursor-rules.d.ts.map +1 -1
  69. package/package.json +1 -1
  70. package/src/ui/dist/assets/{main-DEQafg4b.js → main-C5tdh5OX.js} +3 -3
  71. package/src/ui/dist/index.html +1 -1
@@ -14,7 +14,7 @@ var EO=Object.defineProperty;var YS=t=>{throw TypeError(t)};var CO=(t,e,n)=>e in
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var JS;function TO(){if(JS)return Zu;JS=1;var t=f2(),e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function a(c,u,f){var h,p={},m=null,_=null;f!==void 0&&(m=""+f),u.key!==void 0&&(m=""+u.key),u.ref!==void 0&&(_=u.ref);for(h in u)r.call(u,h)&&!i.hasOwnProperty(h)&&(p[h]=u[h]);if(c&&c.defaultProps)for(h in u=c.defaultProps,u)p[h]===void 0&&(p[h]=u[h]);return{$$typeof:e,type:c,key:m,ref:_,props:p,_owner:s.current}}return Zu.Fragment=n,Zu.jsx=a,Zu.jsxs=a,Zu}var eE;function RO(){return eE||(eE=1,fv.exports=TO()),fv.exports}var E=RO(),v=f2();const ve=Jm(v),xf=kO({__proto__:null,default:ve},[v]);var wf=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},ll,$o,Nc,P8,AO=(P8=class extends wf{constructor(){super();He(this,ll);He(this,$o);He(this,Nc);ke(this,Nc,e=>{if(typeof window<"u"&&window.addEventListener){const n=()=>e();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){U(this,$o)||this.setEventListener(U(this,Nc))}onUnsubscribe(){var e;this.hasListeners()||((e=U(this,$o))==null||e.call(this),ke(this,$o,void 0))}setEventListener(e){var n;ke(this,Nc,e),(n=U(this,$o))==null||n.call(this),ke(this,$o,e(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(e){U(this,ll)!==e&&(ke(this,ll,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(n=>{n(e)})}isFocused(){var e;return typeof U(this,ll)=="boolean"?U(this,ll):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},ll=new WeakMap,$o=new WeakMap,Nc=new WeakMap,P8),h2=new AO,IO={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Ho,d2,T8,MO=(T8=class{constructor(){He(this,Ho,IO);He(this,d2,!1)}setTimeoutProvider(t){ke(this,Ho,t)}setTimeout(t,e){return U(this,Ho).setTimeout(t,e)}clearTimeout(t){U(this,Ho).clearTimeout(t)}setInterval(t,e){return U(this,Ho).setInterval(t,e)}clearInterval(t){U(this,Ho).clearInterval(t)}},Ho=new WeakMap,d2=new WeakMap,T8),rl=new MO;function OO(t){setTimeout(t,0)}var LO=typeof window>"u"||"Deno"in globalThis;function Cr(){}function NO(t,e){return typeof t=="function"?t(e):t}function U1(t){return typeof t=="number"&&t>=0&&t!==1/0}function j8(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Jo(t,e){return typeof t=="function"?t(e):t}function Gr(t,e){return typeof t=="function"?t(e):t}function tE(t,e){const{type:n="all",exact:r,fetchStatus:s,predicate:i,queryKey:a,stale:c}=t;if(a){if(r){if(e.queryHash!==p2(a,e.options))return!1}else if(!Zc(e.queryKey,a))return!1}if(n!=="all"){const u=e.isActive();if(n==="active"&&!u||n==="inactive"&&u)return!1}return!(typeof c=="boolean"&&e.isStale()!==c||s&&s!==e.state.fetchStatus||i&&!i(e))}function nE(t,e){const{exact:n,status:r,predicate:s,mutationKey:i}=t;if(i){if(!e.options.mutationKey)return!1;if(n){if(Dd(e.options.mutationKey)!==Dd(i))return!1}else if(!Zc(e.options.mutationKey,i))return!1}return!(r&&e.state.status!==r||s&&!s(e))}function p2(t,e){return((e==null?void 0:e.queryKeyHashFn)||Dd)(t)}function Dd(t){return JSON.stringify(t,(e,n)=>W1(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function Zc(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(t&&e&&typeof t=="object"&&typeof e=="object"){if(Array.isArray(t)&&Array.isArray(e)){for(let r=0;r<e.length;r++)if(!Zc(t[r],e[r]))return!1;return!0}const n=Object.keys(e);for(const r of n)if(!Zc(t[r],e[r]))return!1;return!0}return!1}var DO=Object.prototype.hasOwnProperty;function F8(t,e,n=0){if(t===e)return t;if(n>500)return e;const r=rE(t)&&rE(e);if(!r&&!(W1(t)&&W1(e)))return e;const i=(r?t:Object.keys(t)).length,a=r?e:Object.keys(e),c=a.length,u=r?new Array(c):{};let f=0;for(let h=0;h<c;h++){const p=r?h:a[h],m=t[p],_=e[p];if(m===_){u[p]=m,(r?h<i:DO.call(t,p))&&f++;continue}if(m===null||_===null||typeof m!="object"||typeof _!="object"){u[p]=_;continue}const x=F8(m,_,n+1);u[p]=x,x===m&&f++}return i===c&&f===i?t:u}function B1(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const n in t)if(t[n]!==e[n])return!1;return!0}function rE(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function W1(t){if(!sE(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!sE(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function sE(t){return Object.prototype.toString.call(t)==="[object Object]"}function jO(t){return new Promise(e=>{rl.setTimeout(e,t)})}function G1(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?F8(t,e):e}function FO(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function VO(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var m2=Symbol();function V8(t,e){return!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===m2?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function $8(t,e){return typeof t=="function"?t(...e):!!t}function $O(t,e,n){let r=!1,s;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(s??(s=e()),r||(r=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}),t}var jd=(()=>{let t=()=>LO;return{isServer(){return t()},setIsServer(e){t=e}}})();function K1(){let t,e;const n=new Promise((s,i)=>{t=s,e=i});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),t(s)},n.reject=s=>{r({status:"rejected",reason:s}),e(s)},n}var HO=OO;function zO(){let t=[],e=0,n=c=>{c()},r=c=>{c()},s=HO;const i=c=>{e?t.push(c):s(()=>{n(c)})},a=()=>{const c=t;t=[],c.length&&s(()=>{r(()=>{c.forEach(u=>{n(u)})})})};return{batch:c=>{let u;e++;try{u=c()}finally{e--,e||a()}return u},batchCalls:c=>(...u)=>{i(()=>{c(...u)})},schedule:i,setNotifyFunction:c=>{n=c},setBatchNotifyFunction:c=>{r=c},setScheduler:c=>{s=c}}}var Fn=zO(),Dc,zo,jc,R8,UO=(R8=class extends wf{constructor(){super();He(this,Dc,!0);He(this,zo);He(this,jc);ke(this,jc,e=>{if(typeof window<"u"&&window.addEventListener){const n=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){U(this,zo)||this.setEventListener(U(this,jc))}onUnsubscribe(){var e;this.hasListeners()||((e=U(this,zo))==null||e.call(this),ke(this,zo,void 0))}setEventListener(e){var n;ke(this,jc,e),(n=U(this,zo))==null||n.call(this),ke(this,zo,e(this.setOnline.bind(this)))}setOnline(e){U(this,Dc)!==e&&(ke(this,Dc,e),this.listeners.forEach(r=>{r(e)}))}isOnline(){return U(this,Dc)}},Dc=new WeakMap,zo=new WeakMap,jc=new WeakMap,R8),Xp=new UO;function BO(t){return Math.min(1e3*2**t,3e4)}function H8(t){return(t??"online")==="online"?Xp.isOnline():!0}var Z1=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function z8(t){let e=!1,n=0,r;const s=K1(),i=()=>s.status!=="pending",a=y=>{var w;if(!i()){const S=new Z1(y);m(S),(w=t.onCancel)==null||w.call(t,S)}},c=()=>{e=!0},u=()=>{e=!1},f=()=>h2.isFocused()&&(t.networkMode==="always"||Xp.isOnline())&&t.canRun(),h=()=>H8(t.networkMode)&&t.canRun(),p=y=>{i()||(r==null||r(),s.resolve(y))},m=y=>{i()||(r==null||r(),s.reject(y))},_=()=>new Promise(y=>{var w;r=S=>{(i()||f())&&y(S)},(w=t.onPause)==null||w.call(t)}).then(()=>{var y;r=void 0,i()||(y=t.onContinue)==null||y.call(t)}),x=()=>{if(i())return;let y;const w=n===0?t.initialPromise:void 0;try{y=w??t.fn()}catch(S){y=Promise.reject(S)}Promise.resolve(y).then(p).catch(S=>{var L;if(i())return;const T=t.retry??(jd.isServer()?0:3),P=t.retryDelay??BO,k=typeof P=="function"?P(n,S):P,R=T===!0||typeof T=="number"&&n<T||typeof T=="function"&&T(n,S);if(e||!R){m(S);return}n++,(L=t.onFail)==null||L.call(t,n,S),jO(k).then(()=>f()?void 0:_()).then(()=>{e?m(S):x()})})};return{promise:s,status:()=>s.status,cancel:a,continue:()=>(r==null||r(),s),cancelRetry:c,continueRetry:u,canStart:h,start:()=>(h()?x():_().then(x),s)}}var cl,A8,U8=(A8=class{constructor(){He(this,cl)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),U1(this.gcTime)&&ke(this,cl,rl.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(jd.isServer()?1/0:300*1e3))}clearGcTimeout(){U(this,cl)!==void 0&&(rl.clearTimeout(U(this,cl)),ke(this,cl,void 0))}},cl=new WeakMap,A8);function WO(t){return{onFetch:(e,n)=>{var h,p,m,_,x;const r=e.options,s=(m=(p=(h=e.fetchOptions)==null?void 0:h.meta)==null?void 0:p.fetchMore)==null?void 0:m.direction,i=((_=e.state.data)==null?void 0:_.pages)||[],a=((x=e.state.data)==null?void 0:x.pageParams)||[];let c={pages:[],pageParams:[]},u=0;const f=async()=>{let y=!1;const w=P=>{$O(P,()=>e.signal,()=>y=!0)},S=V8(e.options,e.fetchOptions),T=async(P,k,R)=>{if(y)return Promise.reject(e.signal.reason);if(k==null&&P.pages.length)return Promise.resolve(P);const O=(()=>{const j={client:e.client,queryKey:e.queryKey,pageParam:k,direction:R?"backward":"forward",meta:e.options.meta};return w(j),j})(),A=await S(O),{maxPages:I}=e.options,N=R?VO:FO;return{pages:N(P.pages,A,I),pageParams:N(P.pageParams,k,I)}};if(s&&i.length){const P=s==="backward",k=P?GO:iE,R={pages:i,pageParams:a},L=k(r,R);c=await T(R,L,P)}else{const P=t??i.length;do{const k=u===0?a[0]??r.initialPageParam:iE(r,c);if(u>0&&k==null)break;c=await T(c,k),u++}while(u<P)}return c};e.options.persister?e.fetchFn=()=>{var y,w;return(w=(y=e.options).persister)==null?void 0:w.call(y,f,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n)}:e.fetchFn=f}}}function iE(t,{pages:e,pageParams:n}){const r=e.length-1;return e.length>0?t.getNextPageParam(e[r],e,n[r],n):void 0}function GO(t,{pages:e,pageParams:n}){var r;return e.length>0?(r=t.getPreviousPageParam)==null?void 0:r.call(t,e[0],e,n[0],n):void 0}var Fc,ul,Vc,gs,dl,kn,mf,fl,Br,B8,$i,I8,KO=(I8=class extends U8{constructor(e){super();He(this,Br);He(this,Fc);He(this,ul);He(this,Vc);He(this,gs);He(this,dl);He(this,kn);He(this,mf);He(this,fl);ke(this,fl,!1),ke(this,mf,e.defaultOptions),this.setOptions(e.options),this.observers=[],ke(this,dl,e.client),ke(this,gs,U(this,dl).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,ke(this,ul,aE(this.options)),this.state=e.state??U(this,ul),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return U(this,Fc)}get promise(){var e;return(e=U(this,kn))==null?void 0:e.promise}setOptions(e){if(this.options={...U(this,mf),...e},e!=null&&e._type&&ke(this,Fc,e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=aE(this.options);n.data!==void 0&&(this.setState(oE(n.data,n.dataUpdatedAt)),ke(this,ul,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&U(this,gs).remove(this)}setData(e,n){const r=G1(this.state.data,e,this.options);return lt(this,Br,$i).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(e){lt(this,Br,$i).call(this,{type:"setState",state:e})}cancel(e){var r,s;const n=(r=U(this,kn))==null?void 0:r.promise;return(s=U(this,kn))==null||s.cancel(e),n?n.then(Cr).catch(Cr):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return U(this,ul)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>Gr(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===m2||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>Jo(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!j8(this.state.dataUpdatedAt,e)}onFocus(){var n;const e=this.observers.find(r=>r.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(n=U(this,kn))==null||n.continue()}onOnline(){var n;const e=this.observers.find(r=>r.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(n=U(this,kn))==null||n.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),U(this,gs).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(n=>n!==e),this.observers.length||(U(this,kn)&&(U(this,fl)||lt(this,Br,B8).call(this)?U(this,kn).cancel({revert:!0}):U(this,kn).cancelRetry()),this.scheduleGc()),U(this,gs).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||lt(this,Br,$i).call(this,{type:"invalidate"})}async fetch(e,n){var f,h,p,m,_,x,y,w,S,T,P;if(this.state.fetchStatus!=="idle"&&((f=U(this,kn))==null?void 0:f.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(U(this,kn))return U(this,kn).continueRetry(),U(this,kn).promise}if(e&&this.setOptions(e),!this.options.queryFn){const k=this.observers.find(R=>R.options.queryFn);k&&this.setOptions(k.options)}const r=new AbortController,s=k=>{Object.defineProperty(k,"signal",{enumerable:!0,get:()=>(ke(this,fl,!0),r.signal)})},i=()=>{const k=V8(this.options,n),L=(()=>{const O={client:U(this,dl),queryKey:this.queryKey,meta:this.meta};return s(O),O})();return ke(this,fl,!1),this.options.persister?this.options.persister(k,L,this):k(L)},c=(()=>{const k={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:U(this,dl),state:this.state,fetchFn:i};return s(k),k})(),u=U(this,Fc)==="infinite"?WO(this.options.pages):this.options.behavior;u==null||u.onFetch(c,this),ke(this,Vc,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((h=c.fetchOptions)==null?void 0:h.meta))&&lt(this,Br,$i).call(this,{type:"fetch",meta:(p=c.fetchOptions)==null?void 0:p.meta}),ke(this,kn,z8({initialPromise:n==null?void 0:n.initialPromise,fn:c.fetchFn,onCancel:k=>{k instanceof Z1&&k.revert&&this.setState({...U(this,Vc),fetchStatus:"idle"}),r.abort()},onFail:(k,R)=>{lt(this,Br,$i).call(this,{type:"failed",failureCount:k,error:R})},onPause:()=>{lt(this,Br,$i).call(this,{type:"pause"})},onContinue:()=>{lt(this,Br,$i).call(this,{type:"continue"})},retry:c.options.retry,retryDelay:c.options.retryDelay,networkMode:c.options.networkMode,canRun:()=>!0}));try{const k=await U(this,kn).start();if(k===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(k),(_=(m=U(this,gs).config).onSuccess)==null||_.call(m,k,this),(y=(x=U(this,gs).config).onSettled)==null||y.call(x,k,this.state.error,this),k}catch(k){if(k instanceof Z1){if(k.silent)return U(this,kn).promise;if(k.revert){if(this.state.data===void 0)throw k;return this.state.data}}throw lt(this,Br,$i).call(this,{type:"error",error:k}),(S=(w=U(this,gs).config).onError)==null||S.call(w,k,this),(P=(T=U(this,gs).config).onSettled)==null||P.call(T,this.state.data,k,this),k}finally{this.scheduleGc()}}},Fc=new WeakMap,ul=new WeakMap,Vc=new WeakMap,gs=new WeakMap,dl=new WeakMap,kn=new WeakMap,mf=new WeakMap,fl=new WeakMap,Br=new WeakSet,B8=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},$i=function(e){const n=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...W8(r.data,this.options),fetchMeta:e.meta??null};case"success":const s={...r,...oE(e.data,e.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return ke(this,Vc,e.manual?s:void 0),s;case"error":const i=e.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=n(this.state),Fn.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),U(this,gs).notify({query:this,type:"updated",action:e})})},I8);function W8(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:H8(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function oE(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function aE(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,n=e!==void 0,r=n?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var br,ct,gf,ir,hl,$c,qi,Uo,vf,Hc,zc,pl,ml,Bo,Uc,vt,dd,q1,Y1,X1,Q1,J1,ey,ty,G8,M8,ZO=(M8=class extends wf{constructor(e,n){super();He(this,vt);He(this,br);He(this,ct);He(this,gf);He(this,ir);He(this,hl);He(this,$c);He(this,qi);He(this,Uo);He(this,vf);He(this,Hc);He(this,zc);He(this,pl);He(this,ml);He(this,Bo);He(this,Uc,new Set);this.options=n,ke(this,br,e),ke(this,Uo,null),ke(this,qi,K1()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(U(this,ct).addObserver(this),lE(U(this,ct),this.options)?lt(this,vt,dd).call(this):this.updateResult(),lt(this,vt,Q1).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ny(U(this,ct),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ny(U(this,ct),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,lt(this,vt,J1).call(this),lt(this,vt,ey).call(this),U(this,ct).removeObserver(this)}setOptions(e){const n=this.options,r=U(this,ct);if(this.options=U(this,br).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Gr(this.options.enabled,U(this,ct))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");lt(this,vt,ty).call(this),U(this,ct).setOptions(this.options),n._defaulted&&!B1(this.options,n)&&U(this,br).getQueryCache().notify({type:"observerOptionsUpdated",query:U(this,ct),observer:this});const s=this.hasListeners();s&&cE(U(this,ct),r,this.options,n)&&lt(this,vt,dd).call(this),this.updateResult(),s&&(U(this,ct)!==r||Gr(this.options.enabled,U(this,ct))!==Gr(n.enabled,U(this,ct))||Jo(this.options.staleTime,U(this,ct))!==Jo(n.staleTime,U(this,ct)))&&lt(this,vt,q1).call(this);const i=lt(this,vt,Y1).call(this);s&&(U(this,ct)!==r||Gr(this.options.enabled,U(this,ct))!==Gr(n.enabled,U(this,ct))||i!==U(this,Bo))&&lt(this,vt,X1).call(this,i)}getOptimisticResult(e){const n=U(this,br).getQueryCache().build(U(this,br),e),r=this.createResult(n,e);return YO(this,r)&&(ke(this,ir,r),ke(this,$c,this.options),ke(this,hl,U(this,ct).state)),r}getCurrentResult(){return U(this,ir)}trackResult(e,n){return new Proxy(e,{get:(r,s)=>(this.trackProp(s),n==null||n(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&U(this,qi).status==="pending"&&U(this,qi).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(e){U(this,Uc).add(e)}getCurrentQuery(){return U(this,ct)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const n=U(this,br).defaultQueryOptions(e),r=U(this,br).getQueryCache().build(U(this,br),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(e){return lt(this,vt,dd).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),U(this,ir)))}createResult(e,n){var I;const r=U(this,ct),s=this.options,i=U(this,ir),a=U(this,hl),c=U(this,$c),f=e!==r?e.state:U(this,gf),{state:h}=e;let p={...h},m=!1,_;if(n._optimisticResults){const N=this.hasListeners(),j=!N&&lE(e,n),F=N&&cE(e,r,n,s);(j||F)&&(p={...p,...W8(h.data,e.options)}),n._optimisticResults==="isRestoring"&&(p.fetchStatus="idle")}let{error:x,errorUpdatedAt:y,status:w}=p;_=p.data;let S=!1;if(n.placeholderData!==void 0&&_===void 0&&w==="pending"){let N;i!=null&&i.isPlaceholderData&&n.placeholderData===(c==null?void 0:c.placeholderData)?(N=i.data,S=!0):N=typeof n.placeholderData=="function"?n.placeholderData((I=U(this,zc))==null?void 0:I.state.data,U(this,zc)):n.placeholderData,N!==void 0&&(w="success",_=G1(i==null?void 0:i.data,N,n),m=!0)}if(n.select&&_!==void 0&&!S)if(i&&_===(a==null?void 0:a.data)&&n.select===U(this,vf))_=U(this,Hc);else try{ke(this,vf,n.select),_=n.select(_),_=G1(i==null?void 0:i.data,_,n),ke(this,Hc,_),ke(this,Uo,null)}catch(N){ke(this,Uo,N)}U(this,Uo)&&(x=U(this,Uo),_=U(this,Hc),y=Date.now(),w="error");const T=p.fetchStatus==="fetching",P=w==="pending",k=w==="error",R=P&&T,L=_!==void 0,A={status:w,fetchStatus:p.fetchStatus,isPending:P,isSuccess:w==="success",isError:k,isInitialLoading:R,isLoading:R,data:_,dataUpdatedAt:p.dataUpdatedAt,error:x,errorUpdatedAt:y,failureCount:p.fetchFailureCount,failureReason:p.fetchFailureReason,errorUpdateCount:p.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:p.dataUpdateCount>f.dataUpdateCount||p.errorUpdateCount>f.errorUpdateCount,isFetching:T,isRefetching:T&&!P,isLoadingError:k&&!L,isPaused:p.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:k&&L,isStale:g2(e,n),refetch:this.refetch,promise:U(this,qi),isEnabled:Gr(n.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const N=A.data!==void 0,j=A.status==="error"&&!N,F=W=>{j?W.reject(A.error):N&&W.resolve(A.data)},K=()=>{const W=ke(this,qi,A.promise=K1());F(W)},X=U(this,qi);switch(X.status){case"pending":e.queryHash===r.queryHash&&F(X);break;case"fulfilled":(j||A.data!==X.value)&&K();break;case"rejected":(!j||A.error!==X.reason)&&K();break}}return A}updateResult(){const e=U(this,ir),n=this.createResult(U(this,ct),this.options);if(ke(this,hl,U(this,ct).state),ke(this,$c,this.options),U(this,hl).data!==void 0&&ke(this,zc,U(this,ct)),B1(n,e))return;ke(this,ir,n);const r=()=>{if(!e)return!0;const{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!U(this,Uc).size)return!0;const a=new Set(i??U(this,Uc));return this.options.throwOnError&&a.add("error"),Object.keys(U(this,ir)).some(c=>{const u=c;return U(this,ir)[u]!==e[u]&&a.has(u)})};lt(this,vt,G8).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&lt(this,vt,Q1).call(this)}},br=new WeakMap,ct=new WeakMap,gf=new WeakMap,ir=new WeakMap,hl=new WeakMap,$c=new WeakMap,qi=new WeakMap,Uo=new WeakMap,vf=new WeakMap,Hc=new WeakMap,zc=new WeakMap,pl=new WeakMap,ml=new WeakMap,Bo=new WeakMap,Uc=new WeakMap,vt=new WeakSet,dd=function(e){lt(this,vt,ty).call(this);let n=U(this,ct).fetch(this.options,e);return e!=null&&e.throwOnError||(n=n.catch(Cr)),n},q1=function(){lt(this,vt,J1).call(this);const e=Jo(this.options.staleTime,U(this,ct));if(jd.isServer()||U(this,ir).isStale||!U1(e))return;const r=j8(U(this,ir).dataUpdatedAt,e)+1;ke(this,pl,rl.setTimeout(()=>{U(this,ir).isStale||this.updateResult()},r))},Y1=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(U(this,ct)):this.options.refetchInterval)??!1},X1=function(e){lt(this,vt,ey).call(this),ke(this,Bo,e),!(jd.isServer()||Gr(this.options.enabled,U(this,ct))===!1||!U1(U(this,Bo))||U(this,Bo)===0)&&ke(this,ml,rl.setInterval(()=>{(this.options.refetchIntervalInBackground||h2.isFocused())&&lt(this,vt,dd).call(this)},U(this,Bo)))},Q1=function(){lt(this,vt,q1).call(this),lt(this,vt,X1).call(this,lt(this,vt,Y1).call(this))},J1=function(){U(this,pl)!==void 0&&(rl.clearTimeout(U(this,pl)),ke(this,pl,void 0))},ey=function(){U(this,ml)!==void 0&&(rl.clearInterval(U(this,ml)),ke(this,ml,void 0))},ty=function(){const e=U(this,br).getQueryCache().build(U(this,br),this.options);if(e===U(this,ct))return;const n=U(this,ct);ke(this,ct,e),ke(this,gf,e.state),this.hasListeners()&&(n==null||n.removeObserver(this),e.addObserver(this))},G8=function(e){Fn.batch(()=>{e.listeners&&this.listeners.forEach(n=>{n(U(this,ir))}),U(this,br).getQueryCache().notify({query:U(this,ct),type:"observerResultsUpdated"})})},M8);function qO(t,e){return Gr(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&Gr(e.retryOnMount,t)===!1)}function lE(t,e){return qO(t,e)||t.state.data!==void 0&&ny(t,e,e.refetchOnMount)}function ny(t,e,n){if(Gr(e.enabled,t)!==!1&&Jo(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&g2(t,e)}return!1}function cE(t,e,n,r){return(t!==e||Gr(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&g2(t,n)}function g2(t,e){return Gr(e.enabled,t)!==!1&&t.isStaleByTime(Jo(e.staleTime,t))}function YO(t,e){return!B1(t.getCurrentResult(),e)}var yf,ai,Xn,gl,li,Fo,O8,XO=(O8=class extends U8{constructor(e){super();He(this,li);He(this,yf);He(this,ai);He(this,Xn);He(this,gl);ke(this,yf,e.client),this.mutationId=e.mutationId,ke(this,Xn,e.mutationCache),ke(this,ai,[]),this.state=e.state||QO(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){U(this,ai).includes(e)||(U(this,ai).push(e),this.clearGcTimeout(),U(this,Xn).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){ke(this,ai,U(this,ai).filter(n=>n!==e)),this.scheduleGc(),U(this,Xn).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){U(this,ai).length||(this.state.status==="pending"?this.scheduleGc():U(this,Xn).remove(this))}continue(){var e;return((e=U(this,gl))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var a,c,u,f,h,p,m,_,x,y,w,S,T,P,k,R,L,O;const n=()=>{lt(this,li,Fo).call(this,{type:"continue"})},r={client:U(this,yf),meta:this.options.meta,mutationKey:this.options.mutationKey};ke(this,gl,z8({fn:()=>this.options.mutationFn?this.options.mutationFn(e,r):Promise.reject(new Error("No mutationFn found")),onFail:(A,I)=>{lt(this,li,Fo).call(this,{type:"failed",failureCount:A,error:I})},onPause:()=>{lt(this,li,Fo).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>U(this,Xn).canRun(this)}));const s=this.state.status==="pending",i=!U(this,gl).canStart();try{if(s)n();else{lt(this,li,Fo).call(this,{type:"pending",variables:e,isPaused:i}),U(this,Xn).config.onMutate&&await U(this,Xn).config.onMutate(e,this,r);const I=await((c=(a=this.options).onMutate)==null?void 0:c.call(a,e,r));I!==this.state.context&&lt(this,li,Fo).call(this,{type:"pending",context:I,variables:e,isPaused:i})}const A=await U(this,gl).start();return await((f=(u=U(this,Xn).config).onSuccess)==null?void 0:f.call(u,A,e,this.state.context,this,r)),await((p=(h=this.options).onSuccess)==null?void 0:p.call(h,A,e,this.state.context,r)),await((_=(m=U(this,Xn).config).onSettled)==null?void 0:_.call(m,A,null,this.state.variables,this.state.context,this,r)),await((y=(x=this.options).onSettled)==null?void 0:y.call(x,A,null,e,this.state.context,r)),lt(this,li,Fo).call(this,{type:"success",data:A}),A}catch(A){try{await((S=(w=U(this,Xn).config).onError)==null?void 0:S.call(w,A,e,this.state.context,this,r))}catch(I){Promise.reject(I)}try{await((P=(T=this.options).onError)==null?void 0:P.call(T,A,e,this.state.context,r))}catch(I){Promise.reject(I)}try{await((R=(k=U(this,Xn).config).onSettled)==null?void 0:R.call(k,void 0,A,this.state.variables,this.state.context,this,r))}catch(I){Promise.reject(I)}try{await((O=(L=this.options).onSettled)==null?void 0:O.call(L,void 0,A,e,this.state.context,r))}catch(I){Promise.reject(I)}throw lt(this,li,Fo).call(this,{type:"error",error:A}),A}finally{U(this,Xn).runNext(this)}}},yf=new WeakMap,ai=new WeakMap,Xn=new WeakMap,gl=new WeakMap,li=new WeakSet,Fo=function(e){const n=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Fn.batch(()=>{U(this,ai).forEach(r=>{r.onMutationUpdate(e)}),U(this,Xn).notify({mutation:this,type:"updated",action:e})})},O8);function QO(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Yi,Hs,_f,L8,JO=(L8=class extends wf{constructor(e={}){super();He(this,Yi);He(this,Hs);He(this,_f);this.config=e,ke(this,Yi,new Set),ke(this,Hs,new Map),ke(this,_f,0)}build(e,n,r){const s=new XO({client:e,mutationCache:this,mutationId:++Hh(this,_f)._,options:e.defaultMutationOptions(n),state:r});return this.add(s),s}add(e){U(this,Yi).add(e);const n=zh(e);if(typeof n=="string"){const r=U(this,Hs).get(n);r?r.push(e):U(this,Hs).set(n,[e])}this.notify({type:"added",mutation:e})}remove(e){if(U(this,Yi).delete(e)){const n=zh(e);if(typeof n=="string"){const r=U(this,Hs).get(n);if(r)if(r.length>1){const s=r.indexOf(e);s!==-1&&r.splice(s,1)}else r[0]===e&&U(this,Hs).delete(n)}}this.notify({type:"removed",mutation:e})}canRun(e){const n=zh(e);if(typeof n=="string"){const r=U(this,Hs).get(n),s=r==null?void 0:r.find(i=>i.state.status==="pending");return!s||s===e}else return!0}runNext(e){var r;const n=zh(e);if(typeof n=="string"){const s=(r=U(this,Hs).get(n))==null?void 0:r.find(i=>i!==e&&i.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Fn.batch(()=>{U(this,Yi).forEach(e=>{this.notify({type:"removed",mutation:e})}),U(this,Yi).clear(),U(this,Hs).clear()})}getAll(){return Array.from(U(this,Yi))}find(e){const n={exact:!0,...e};return this.getAll().find(r=>nE(n,r))}findAll(e={}){return this.getAll().filter(n=>nE(e,n))}notify(e){Fn.batch(()=>{this.listeners.forEach(n=>{n(e)})})}resumePausedMutations(){const e=this.getAll().filter(n=>n.state.isPaused);return Fn.batch(()=>Promise.all(e.map(n=>n.continue().catch(Cr))))}},Yi=new WeakMap,Hs=new WeakMap,_f=new WeakMap,L8);function zh(t){var e;return(e=t.options.scope)==null?void 0:e.id}var ci,N8,eL=(N8=class extends wf{constructor(e={}){super();He(this,ci);this.config=e,ke(this,ci,new Map)}build(e,n,r){const s=n.queryKey,i=n.queryHash??p2(s,n);let a=this.get(i);return a||(a=new KO({client:e,queryKey:s,queryHash:i,options:e.defaultQueryOptions(n),state:r,defaultOptions:e.getQueryDefaults(s)}),this.add(a)),a}add(e){U(this,ci).has(e.queryHash)||(U(this,ci).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const n=U(this,ci).get(e.queryHash);n&&(e.destroy(),n===e&&U(this,ci).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){Fn.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return U(this,ci).get(e)}getAll(){return[...U(this,ci).values()]}find(e){const n={exact:!0,...e};return this.getAll().find(r=>tE(n,r))}findAll(e={}){const n=this.getAll();return Object.keys(e).length>0?n.filter(r=>tE(e,r)):n}notify(e){Fn.batch(()=>{this.listeners.forEach(n=>{n(e)})})}onFocus(){Fn.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Fn.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},ci=new WeakMap,N8),Qt,Wo,Go,Bc,Wc,Ko,Gc,Kc,D8,tL=(D8=class{constructor(t={}){He(this,Qt);He(this,Wo);He(this,Go);He(this,Bc);He(this,Wc);He(this,Ko);He(this,Gc);He(this,Kc);ke(this,Qt,t.queryCache||new eL),ke(this,Wo,t.mutationCache||new JO),ke(this,Go,t.defaultOptions||{}),ke(this,Bc,new Map),ke(this,Wc,new Map),ke(this,Ko,0)}mount(){Hh(this,Ko)._++,U(this,Ko)===1&&(ke(this,Gc,h2.subscribe(async t=>{t&&(await this.resumePausedMutations(),U(this,Qt).onFocus())})),ke(this,Kc,Xp.subscribe(async t=>{t&&(await this.resumePausedMutations(),U(this,Qt).onOnline())})))}unmount(){var t,e;Hh(this,Ko)._--,U(this,Ko)===0&&((t=U(this,Gc))==null||t.call(this),ke(this,Gc,void 0),(e=U(this,Kc))==null||e.call(this),ke(this,Kc,void 0))}isFetching(t){return U(this,Qt).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return U(this,Wo).findAll({...t,status:"pending"}).length}getQueryData(t){var n;const e=this.defaultQueryOptions({queryKey:t});return(n=U(this,Qt).get(e.queryHash))==null?void 0:n.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=U(this,Qt).build(this,e),r=n.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(Jo(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return U(this,Qt).findAll(t).map(({queryKey:e,state:n})=>{const r=n.data;return[e,r]})}setQueryData(t,e,n){const r=this.defaultQueryOptions({queryKey:t}),s=U(this,Qt).get(r.queryHash),i=s==null?void 0:s.state.data,a=NO(e,i);if(a!==void 0)return U(this,Qt).build(this,r).setData(a,{...n,manual:!0})}setQueriesData(t,e,n){return Fn.batch(()=>U(this,Qt).findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,n)]))}getQueryState(t){var n;const e=this.defaultQueryOptions({queryKey:t});return(n=U(this,Qt).get(e.queryHash))==null?void 0:n.state}removeQueries(t){const e=U(this,Qt);Fn.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=U(this,Qt);return Fn.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=Fn.batch(()=>U(this,Qt).findAll(t).map(s=>s.cancel(n)));return Promise.all(r).then(Cr).catch(Cr)}invalidateQueries(t,e={}){return Fn.batch(()=>(U(this,Qt).findAll(t).forEach(n=>{n.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},e)))}refetchQueries(t,e={}){const n={...e,cancelRefetch:e.cancelRefetch??!0},r=Fn.batch(()=>U(this,Qt).findAll(t).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let i=s.fetch(void 0,n);return n.throwOnError||(i=i.catch(Cr)),s.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Cr)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=U(this,Qt).build(this,e);return n.isStaleByTime(Jo(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Cr).catch(Cr)}fetchInfiniteQuery(t){return t._type="infinite",this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Cr).catch(Cr)}ensureInfiniteQueryData(t){return t._type="infinite",this.ensureQueryData(t)}resumePausedMutations(){return Xp.isOnline()?U(this,Wo).resumePausedMutations():Promise.resolve()}getQueryCache(){return U(this,Qt)}getMutationCache(){return U(this,Wo)}getDefaultOptions(){return U(this,Go)}setDefaultOptions(t){ke(this,Go,t)}setQueryDefaults(t,e){U(this,Bc).set(Dd(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...U(this,Bc).values()],n={};return e.forEach(r=>{Zc(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){U(this,Wc).set(Dd(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...U(this,Wc).values()],n={};return e.forEach(r=>{Zc(t,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(t){if(t._defaulted)return t;const e={...U(this,Go).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=p2(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===m2&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...U(this,Go).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){U(this,Qt).clear(),U(this,Wo).clear()}},Qt=new WeakMap,Wo=new WeakMap,Go=new WeakMap,Bc=new WeakMap,Wc=new WeakMap,Ko=new WeakMap,Gc=new WeakMap,Kc=new WeakMap,D8),K8=v.createContext(void 0),Z8=t=>{const e=v.useContext(K8);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},nL=({client:t,children:e})=>(v.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),E.jsx(K8.Provider,{value:t,children:e})),q8=v.createContext(!1),rL=()=>v.useContext(q8);q8.Provider;function sL(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var iL=v.createContext(sL()),oL=()=>v.useContext(iL),aL=(t,e,n)=>{const r=n!=null&&n.state.error&&typeof t.throwOnError=="function"?$8(t.throwOnError,[n.state.error,n]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||r)&&(e.isReset()||(t.retryOnMount=!1))},lL=t=>{v.useEffect(()=>{t.clearReset()},[t])},cL=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:s})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(s&&t.data===void 0||$8(n,[t.error,r])),uL=t=>{if(t.suspense){const n=s=>s==="static"?s:Math.max(s??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...s)=>n(r(...s)):n(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},dL=(t,e)=>t.isLoading&&t.isFetching&&!e,fL=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,uE=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function hL(t,e,n){var _,x,y,w;const r=rL(),s=oL(),i=Z8(),a=i.defaultQueryOptions(t);(x=(_=i.getDefaultOptions().queries)==null?void 0:_._experimental_beforeQuery)==null||x.call(_,a);const c=i.getQueryCache().get(a.queryHash),u=t.subscribed!==!1;a._optimisticResults=r?"isRestoring":u?"optimistic":void 0,uL(a),aL(a,s,c),lL(s);const f=!i.getQueryCache().get(a.queryHash),[h]=v.useState(()=>new e(i,a)),p=h.getOptimisticResult(a),m=!r&&u;if(v.useSyncExternalStore(v.useCallback(S=>{const T=m?h.subscribe(Fn.batchCalls(S)):Cr;return h.updateResult(),T},[h,m]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),v.useEffect(()=>{h.setOptions(a)},[a,h]),fL(a,p))throw uE(a,h,s);if(cL({result:p,errorResetBoundary:s,throwOnError:a.throwOnError,query:c,suspense:a.suspense}))throw p.error;if((w=(y=i.getDefaultOptions().queries)==null?void 0:y._experimental_afterQuery)==null||w.call(y,a,p),a.experimental_prefetchInRender&&!jd.isServer()&&dL(p,r)){const S=f?uE(a,h,s):c==null?void 0:c.promise;S==null||S.catch(Cr).finally(()=>{h.updateResult()})}return a.notifyOnChangeProps?p:h.trackResult(p)}function ry(t,e){return hL(t,ZO)}var te=typeof window<"u"?window:void 0,Jn=typeof globalThis<"u"?globalThis:te,ar=Jn==null?void 0:Jn.navigator,Se=Jn==null?void 0:Jn.document,rn=Jn==null?void 0:Jn.location,v2=Jn==null?void 0:Jn.fetch,sy=Jn!=null&&Jn.XMLHttpRequest&&"withCredentials"in new Jn.XMLHttpRequest?Jn.XMLHttpRequest:void 0,dE=Jn==null?void 0:Jn.AbortController,pL=Jn==null?void 0:Jn.CompressionStream,Sr=ar==null?void 0:ar.userAgent;function Y8(){return!(!te||te.navigator.onLine===!1)}var qu=typeof globalThis<"u"?globalThis:te;qu&&typeof self>"u"&&(qu.self=qu),qu&&typeof File>"u"&&(qu.File=function(){});var $e=te??{},gt={DEBUG:!1,LIB_VERSION:"0.2.4",LIB_NAME:"browser-common"};function fE(t,e,n,r,s,i,a){try{var c=t[i](a),u=c.value}catch(f){return void n(f)}c.done?e(u):Promise.resolve(u).then(r,s)}function en(t){return function(){var e=this,n=arguments;return new Promise((function(r,s){var i=t.apply(e,n);function a(u){fE(i,r,s,a,c,"next",u)}function c(u){fE(i,r,s,a,c,"throw",u)}a(void 0)}))}}function ue(){return ue=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},ue.apply(null,arguments)}function X8(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var hE=t=>{if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}};function pE(t){return typeof t=="string"||t}function mE(t){return typeof t=="string"?t:void 0}var Yu,mL=["$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","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],Bi=(function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t})({}),gE=(function(t){return t.GZipJS="gzip-js",t.Base64="base64",t})({}),gL=["$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"],vL=["token"],Q8="NativeGzipValidationError",iy=t=>t.length>=2&&t[0]===31&&t[1]===139,vE=(t,e)=>t===gE.GZipJS||e===gE.GZipJS||e==="gzip",yE=t=>!(!t||typeof t!="object")&&("name"in t?String(t.name):"")==="NotReadableError",Uh=t=>{var e=new Error("Native gzip produced invalid output: "+t);throw e.name=Q8,e},yL=(function(){var t=en((function*(e,n){18>e.size&&Uh("too-short");var r=new Uint8Array(yield e.slice(0,10).arrayBuffer());iy(r)&&r[2]===8||Uh("invalid-header");var s=new DataView(yield e.slice(e.size-8).arrayBuffer());s.getUint32(0,!0)!==(a=>{for(var c=(()=>{if(Yu)return Yu;Yu=[];for(var h=0;256>h;h++){for(var p=h,m=0;8>m;m++)p=1&p?3988292384^p>>>1:p>>>1;Yu[h]=p>>>0}return Yu})(),u=4294967295,f=0;a.length>f;f++)u=c[255&(u^a[f])]^u>>>8;return(4294967295^u)>>>0})(n)&&Uh("invalid-crc");var i=n.length>>>0;s.getUint32(4,!0)!==i&&Uh("invalid-size")}));return function(e,n){return t.apply(this,arguments)}})();function oy(){return oy=en((function*(t,e,n){e===void 0&&(e=!0);try{var r=new TextEncoder().encode(t),s=new globalThis.CompressionStream("gzip"),i=s.writable.getWriter(),a=i.write(r).then((()=>i.close())).catch((function(){var f=en((function*(h){try{yield i.abort(h)}catch{}throw h}));return function(h){return f.apply(this,arguments)}})()),c=new Response(s.readable).blob(),u=(yield Promise.all([c,a]))[0];return yield yL(u,r),u}catch(f){if(n!=null&&n.rethrow)throw f;return e&&console.error("Failed to gzip compress data",f),null}})),oy.apply(this,arguments)}var _L=["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"],_E=function(t,e){if(e===void 0&&(e=[]),!t)return!1;var n=t.toLowerCase();return _L.concat(e).some((r=>{var s=r.toLowerCase();return n.indexOf(s)!==-1}))};function Ge(t,e){return t.indexOf(e)!==-1}var e0=function(t){return t.trim()},ay=function(t){return t.replace(/^\$/,"")};function J8(t){var e,n=[];return(e=JSON.stringify(t,(function(r,s){if(typeof s=="bigint")return s.toString();if(typeof s!="function"&&typeof s!="symbol"){if(s instanceof Error)return{name:s.name,message:s.message,stack:s.stack};if(s&&typeof s=="object"){for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(n.includes(s))return"[Circular]";n.push(s)}return s}})))!==null&&e!==void 0?e:"null"}var e6=Object.prototype,t6=e6.hasOwnProperty,t0=e6.toString,Qe=Array.isArray||function(t){return t0.call(t)==="[object Array]"},zs=t=>typeof t=="function",Nt=t=>t===Object(t)&&!Qe(t),Zo=t=>{if(Nt(t)){for(var e in t)if(t6.call(t,e))return!1;return!0}return!1},ge=t=>t===void 0,xt=t=>t0.call(t)=="[object String]",ly=t=>xt(t)&&t.trim().length===0,dr=t=>t===null,Je=t=>ge(t)||dr(t),$n=t=>t0.call(t)=="[object Number]"&&t==t,Hi=t=>$n(t)&&t>0,Us=t=>t0.call(t)==="[object Boolean]",xL=t=>t instanceof FormData,wL=t=>Ge(gL,t),bL=t=>Ge(vL,t);function n6(t){return t===null||typeof t!="object"}function Qp(t,e){return{}.toString.call(t)==="[object "+e+"]"}function y2(t){return typeof Event<"u"&&(function(e,n){try{return e instanceof n}catch{return!1}})(t,Event)}var SL=[!0,"true",1,"1","yes"],pv=t=>Ge(SL,t),EL=[!1,"false",0,"0","no"];function hi(t,e,n,r,s){return e>n&&(r.warn("min cannot be greater than max."),e=n),$n(t)?t>n?(r.warn(" cannot be greater than max: "+n+". Using max value instead."),n):e>t?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(r.warn(" must be a number. using max or fallback. max: "+n+", fallback: "+s),hi(s||n,e,n,r))}class CL{constructor(e){this.$e={},this.ze=e.ze,this.Ze=hi(e.bucketSize,0,100,e.Ge),this.Qe=hi(e.refillRate,0,this.Ze,e.Ge),this.Je=hi(e.refillInterval,0,864e5,e.Ge)}Ke(e,n){var r=Math.floor((n-e.lastAccess)/this.Je);r>0&&(e.tokens=Math.min(e.tokens+r*this.Qe,this.Ze),e.lastAccess=e.lastAccess+r*this.Je)}consumeRateLimit(e){var n,r=Date.now(),s=String(e),i=this.$e[s];return i?this.Ke(i,r):this.$e[s]=i={tokens:this.Ze,lastAccess:r},i.tokens===0||(i.tokens--,i.tokens===0&&((n=this.ze)==null||n.call(this,e)),i.tokens===0)}stop(){this.$e={}}}var Qr="Mobile",Jp="iOS",no="Android",qc="Tablet",r6=no+" "+qc,s6="iPad",i6="Apple",o6=i6+" Watch",xd="Safari",Yc="BlackBerry",a6="Samsung",l6=a6+"Browser",c6=a6+" Internet",vl="Chrome",kL=vl+" OS",u6=vl+" "+Jp,_2="Internet Explorer",d6=_2+" "+Qr,x2="Opera",PL=x2+" Mini",w2="Edge",f6="Microsoft "+w2,kc="Firefox",h6=kc+" "+Jp,Fd="Nintendo",Vd="PlayStation",Pc="Xbox",p6=no+" "+Qr,m6=Qr+" "+xd,fd="Windows",cy=fd+" Phone",xE="Nokia",uy="Ouya",g6="Generic",TL=g6+" "+Qr.toLowerCase(),v6=g6+" "+qc.toLowerCase(),dy="Konqueror",y6="Oculus Browser",em="Vivaldi",_6="Yandex",tm="Whale",fy="DuckDuckGo",x6="Pale Moon",nm="Waterfox",wd="Brave",w6="Google Search App",Ht="(\\d+(\\.\\d+)?)",mv=new RegExp("Version/"+Ht),RL=new RegExp(Pc,"i"),AL=new RegExp(Vd+" \\w+","i"),IL=new RegExp(Fd+" \\w+","i"),b2=new RegExp(Yc+"|PlayBook|BB10","i"),ML={"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"},b6=function(t,e,n,r){e=e||"";var s=(function(i){return i!=null&&i.brave?wd:null})(n);return s||(r!=null&&r.detectGoogleSearchApp&&Ge(t,"GSA/")?w6:Ge(t," OPR/")&&Ge(t,"Mini")?PL:Ge(t," OPR/")?x2:b2.test(t)?Yc:Ge(t,"IE"+Qr)||Ge(t,"WPDesktop")?d6:Ge(t,"OculusBrowser")?y6:Ge(t,l6)?c6:Ge(t,w2)||Ge(t,"Edg/")?f6:Ge(t,em+"/")?em:Ge(t,"YaBrowser/")?_6:Ge(t,tm+"/")?tm:Ge(t,fy+"/")||Ge(t,"Ddg/")?fy:Ge(t,"FBIOS")?"Facebook "+Qr:Ge(t,"UCWEB")||Ge(t,"UCBrowser")?"UC Browser":Ge(t,"CriOS")?u6:Ge(t,"CrMo")||Ge(t,vl)?vl:Ge(t,no)&&Ge(t,xd)?p6:Ge(t,"FxiOS")?h6:Ge(t.toLowerCase(),dy.toLowerCase())?dy:Ge(t,wd+"/")?wd:((i,a)=>a&&Ge(a,i6)||(function(c){return Ge(c,xd)&&!Ge(c,vl)&&!Ge(c,no)})(i))(t,e)?Ge(t,Qr)?m6:xd:Ge(t,"PaleMoon/")?x6:Ge(t,nm+"/")?nm:Ge(t,kc)?kc:Ge(t,"MSIE")||Ge(t,"Trident/")?_2:Ge(t,"Gecko")?kc:"")},OL={[d6]:[new RegExp("rv:"+Ht)],[f6]:[new RegExp(w2+"?\\/"+Ht)],[vl]:[new RegExp("("+vl+"|CrMo)\\/"+Ht)],[u6]:[new RegExp("CriOS\\/"+Ht)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ht)],[xd]:[mv],[m6]:[mv],[x2]:[new RegExp("(Opera|OPR)\\/"+Ht)],[kc]:[new RegExp(kc+"\\/"+Ht)],[h6]:[new RegExp("FxiOS\\/"+Ht)],[dy]:[new RegExp("Konqueror[:/]?"+Ht,"i")],[Yc]:[new RegExp(Yc+" "+Ht),mv],[p6]:[new RegExp("android\\s"+Ht,"i")],[c6]:[new RegExp(l6+"\\/"+Ht)],[y6]:[new RegExp("OculusBrowser\\/"+Ht)],[em]:[new RegExp(em+"\\/"+Ht)],[_6]:[new RegExp("YaBrowser\\/"+Ht)],[tm]:[new RegExp(tm+"\\/"+Ht)],[wd]:[new RegExp(wd+"\\/"+Ht)],[fy]:[new RegExp("(DuckDuckGo|Ddg)\\/"+Ht)],[x6]:[new RegExp("PaleMoon\\/"+Ht)],[nm]:[new RegExp(nm+"\\/"+Ht)],[w6]:[new RegExp("GSA\\/"+Ht)],[_2]:[new RegExp("(rv:|MSIE )"+Ht)],Mozilla:[new RegExp("rv:"+Ht)]},LL=function(t,e,n,r){var s=b6(t,e,n,r),i=OL[s];if(ge(i))return null;for(var a=0;i.length>a;a++){var c=t.match(i[a]);if(c)return parseFloat(c[c.length-2])}return null},wE=[[new RegExp(Pc+"; "+Pc+" (.*?)[);]","i"),t=>[Pc,t&&t[1]||""]],[new RegExp(Fd,"i"),[Fd,""]],[new RegExp(Vd,"i"),[Vd,""]],[b2,[Yc,""]],[new RegExp(fd,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[cy,""];if(new RegExp(Qr).test(e)&&!/IEMobile\b/.test(e))return[fd+" "+Qr,""];var n=/Windows NT ([0-9.]+)/i.exec(e);if(n&&n[1]){var r=ML[n[1]]||"";return/arm/i.test(e)&&(r="RT"),[fd,r]}return[fd,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?[Jp,[t[3],t[4],t[5]||"0"].join(".")]:[Jp,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=ge(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("("+no+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+no+")","i"),t=>t&&t[2]?[no,[t[2],t[3],t[4]||"0"].join(".")]:[no,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];return t&&t[1]&&(e[1]=[t[1],t[2],t[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[kL,""]],[/Linux|debian/i,["Linux",""]]],bE=function(t){return IL.test(t)?Fd:AL.test(t)?Vd:RL.test(t)?Pc:new RegExp(uy,"i").test(t)?uy:new RegExp("("+cy+"|WPDesktop)","i").test(t)?cy:/iPad/.test(t)?s6:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?o6:b2.test(t)?Yc:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(xE,"i").test(t)?xE:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(Qr).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?no:r6:new RegExp("(pda|"+Qr+")","i").test(t)?TL:new RegExp(qc,"i").test(t)&&!new RegExp(qc+" pc","i").test(t)?v6:""},NL=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function SE(t,e){return typeof(n=t)=="string"&&NL.test(n)?t:e();var n}function sa(t){return t&&t.split("#")[0]}function bp(t,e){var n=setTimeout(t,e);return n!=null&&n.unref&&(n==null||n.unref()),n}var DL=t=>t instanceof Error,S6={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}},jL=S6.info;function E6(t){if(Us(t))return{boolValue:t};if(typeof t=="number")return Number.isFinite(t)?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:{stringValue:String(t)};if(typeof t=="string")return{stringValue:t};if(Qe(t))return{arrayValue:{values:t.map((e=>E6(e)))}};try{return{stringValue:JSON.stringify(t)}}catch{return{stringValue:String(t)}}}function rm(t){var e=[];for(var n in t){var r=t[n];dr(r)||ge(r)||e.push({key:n,value:E6(r)})}return e}function FL(t,e){var n=S6[t.level||"info"]||jL,r=n.text,s=n.number,i=String(Date.now())+"000000",a={};e.distinctId&&(a.posthogDistinctId=e.distinctId),e.sessionId&&(a.sessionId=e.sessionId),e.windowId&&(a["window.id"]=e.windowId),Je(e.sessionStartTimestamp)||(a.sessionStartTimestamp=String(e.sessionStartTimestamp)),Je(e.lastActivityTimestamp)||(a.lastActivityTimestamp=String(e.lastActivityTimestamp)),e.currentUrl&&(a["url.full"]=e.currentUrl),e.screenName&&(a["screen.name"]=e.screenName),e.appState&&(a["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(a.feature_flags=e.activeFeatureFlags);var c=ue({},a,t.attributes||{}),u={timeUnixNano:i,observedTimeUnixNano:i,severityNumber:s,severityText:r,body:{stringValue:t.body},attributes:rm(c)};return t.trace_id&&(u.traceId=t.trace_id),t.span_id&&(u.spanId=t.span_id),ge(t.trace_flags)||(u.flags=t.trace_flags),u}function C6(t,e,n){return ue({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":n})}function k6(t,e,n,r){return{resourceLogs:[{resource:{attributes:rm(e)},scopeLogs:[{scope:{name:n,version:r},logRecords:t}]}]}}let VL=class{constructor(t,e,n,r,s,i,a){var c;i===void 0&&(i=()=>Promise.resolve()),this._instance=t,this.Te=e,this.Ge=n,this.Ye=r,this.Xe=s,this.et=i,this.tt=a,this.rt=null,this.it=0,this.nt=0,this.st=0,this.ot=0,this.ut=!1,this.ht=e.maxBufferSize,this.dt=Math.max((c=e.maxQueueSize)!==null&&c!==void 0?c:e.maxBufferSize,e.maxBufferSize),this.ct=e.flushIntervalMs,this.vt=e.maxBatchRecordsPerPost,this.ft=e.rateCapWindowMs,this.yt=e.maxLogsPerInterval}reset(){this.bt(),this.rt=null,this.st=0,this.ot=0,this.ut=!1,this.it=0,this.nt=0,this.vt=this.Te.maxBatchRecordsPerPost}onReconnect(){this.nt=0,this._t()}captureLog(t){if(!this._instance.isDisabled&&!this._instance.optedOut&&t!=null&&t.body){var e=this.wt(t);if(e!==null)if(e.body){if(this.xt()){var n={record:FL(e,this.Ye())};this.Xe((()=>this.kt(n)))}}else this.Ge.info("Log was rejected in beforeSend function")}}wt(t){var e=this.Te.beforeSend;if(!e)return t;var n=Qe(e)?e:[e],r=t;for(var s of n)try{var i=s(r);if(!i)return this.Ge.info("Log was rejected in beforeSend function"),null;r=i}catch(a){return this.Ge.error("Error in beforeSend function for log:",a),null}return r}xt(){if(this.yt===void 0)return!0;var t=Date.now(),e=t-this.st;return this.ft>e&&e>=0||(this.st=t,this.ot=0,this.ut=!1),this.yt>this.ot?(this.ot++,!0):(this.ut||(this.Ge.warn("captureLog dropping logs: exceeded "+this.yt+" logs per "+this.ft+"ms"),this.ut=!0),!1)}flush(){var t=this;return en((function*(){if(!t._instance.isDisabled)return t.rt||(t.rt=t.St().finally((()=>{t.rt=null}))),t.rt}))()}St(){var t=this;return en((function*(){var e;t.bt();var n=(e=t._instance.getPersistedProperty(Bi.LogsQueue))!==null&&e!==void 0?e:[];if(n.length!==0)for(var r=n.length,s=0;n.length>0&&r>s;){var i,a;t.it=0;var c=Math.min(n.length,t.vt),u=n.slice(0,c),f=k6(u.map((p=>p.record)),t.Ct(),(i=t.tt)!==null&&i!==void 0?i:t._instance.getLibraryId(),t._instance.getLibraryVersion()),h=yield t._instance.Mt(f);if(h.kind==="too-large"&&u.length>1)t.vt=Math.max(1,Math.floor(u.length/2)),t.Ge.warn("Received 413 when sending logs batch of size "+u.length+", reducing batch size to "+t.vt);else if(h.kind==="retry-later"||(h.kind==="too-large"?t.Ge.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."):h.kind==="ok"&&t.Te.maxBatchRecordsPerPost>t.vt&&(t.vt=Math.min(t.Te.maxBatchRecordsPerPost,t.vt+1)),yield t.It(u.length),n=(a=t._instance.getPersistedProperty(Bi.LogsQueue))!==null&&a!==void 0?a:[],s+=u.length,h.kind==="fatal"))throw h.error}}))()}It(t){var e=this;return en((function*(){var n,r=Math.max(0,t-e.it),s=(n=e._instance.getPersistedProperty(Bi.LogsQueue))!==null&&n!==void 0?n:[];e._instance.setPersistedProperty(Bi.LogsQueue,s.slice(r)),yield e.et()}))()}Ct(){return C6(this.Te,this._instance.getLibraryId(),this._instance.getLibraryVersion())}kt(t){var e;if(!this._instance.optedOut){var n=(e=this._instance.getPersistedProperty(Bi.LogsQueue))!==null&&e!==void 0?e:[];this.dt>n.length||(n.shift(),this.it++,this.Ge.info("Logs queue is full, dropping oldest record.")),n.push(t),this._instance.setPersistedProperty(Bi.LogsQueue,n),this.ht>n.length?this.Tt():this._t()}}Tt(t){t===void 0&&(t=this.ct),this.Et||(this.Et=bp((()=>{this.Et=void 0,this._t()}),t))}Rt(){var t=Math.min(Math.max(0,this.nt-1),6);return this.ct*Math.pow(2,t)}Pt(){var t=this._instance.getPersistedProperty(Bi.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return en((function*(){e.bt();var n=e.flush().catch((()=>{}));t!==void 0?yield Promise.race([n,new Promise((r=>bp(r,t)))]):yield n}))()}flushWithTimeout(t){var e=this;return en((function*(){var n=!1,r=e.flush(),s=new Promise((i=>bp((()=>{n=!0,i()}),t)));try{yield Promise.race([r,s])}finally{n&&r.catch((()=>{}))}}))()}_t(){this.flush().then((()=>{this.nt=0}),(t=>{this.nt++,this.Ge.error("PostHog logs flush failed:",t)})).finally((()=>{!this._instance.isDisabled&&this.Pt()&&this.Tt(this.Rt())}))}bt(){this.Et&&(clearTimeout(this.Et),this.Et=void 0)}};var gv=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function EE(t){return String(t)+"000000"}function CE(t,e,n,r){var s="";return r&&(s=Object.keys(r).sort().map((i=>JSON.stringify(i)+":"+JSON.stringify(r[i]))).join(",")),t+"\0"+e+"\0"+(n??"")+"\0"+s}let $L=class{constructor(t,e,n){this._instance=t,this.Te=e,this.Ge=n,this.Ot=new Map,this.rt=null,this.Ft=!1,this.At=new Map,this.Lt=new Set,this.$t=0}count(t,e,n){e===void 0&&(e=1),this.Nt({name:t,type:"count",value:e,unit:n==null?void 0:n.unit,attributes:n==null?void 0:n.attributes})}gauge(t,e,n){this.Nt({name:t,type:"gauge",value:e,unit:n==null?void 0:n.unit,attributes:n==null?void 0:n.attributes})}histogram(t,e,n){this.Nt({name:t,type:"histogram",value:e,unit:n==null?void 0:n.unit,attributes:n==null?void 0:n.attributes})}flush(){var t=this,e=this.rt,n=(function(){var s=en((function*(){e&&(yield e.catch((()=>{}))),yield t.Dt()}));return function(){return s.apply(this,arguments)}})(),r=n().finally((()=>{this.rt===r&&(this.rt=null)}));return this.rt=r,r}drainWindow(){if(this.Ot.size===0)return null;var t=this.Ot;return this.Ot=new Map,this.Ft=!1,this.At=new Map,this.Lt=new Set,this.qt(t)}reset(){this.$t++,this.bt(),this.Ot=new Map,this.rt=null,this.Ft=!1,this.At=new Map,this.Lt=new Set}Nt(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var e=this.wt(t);if(e!==null)if(e.name&&typeof e.name=="string")if(typeof e.value=="number"&&Number.isFinite(e.value))if(e.type==="count"&&0>e.value)this.Ge.warn("Dropping count '"+e.name+"': counters are monotonic, value must be >= 0");else{var n,r;try{n=e.attributes?ue({},e.attributes):void 0,r=CE(e.type,e.name,e.unit,n)}catch(a){return void this.Ge.warn("Dropping metric '"+e.name+"': attributes could not be serialized",a)}var s=this.Ot.get(r);if(!s){if(!this.jt())return;s={name:e.name,type:e.type,unit:e.unit,attributes:n,windowStartMs:Date.now()},this.Ot.set(r,s)}var i=this.At.get(e.name);i===void 0?this.At.set(e.name,e.type):i===e.type||this.Lt.has(e.name)||(this.Lt.add(e.name),this.Ge.warn("Metric name '"+e.name+"' is already used as a "+i+"; recording it as a "+e.type+" too will blend both series in charts. Use a distinct name.")),this.Ht(s,e.value),this.Tt()}else this.Ge.warn("Dropping metric '"+e.name+"': value must be a finite number");else this.Ge.warn("Dropping metric with empty name")}}jt(){return this.Te.maxSeriesPerFlush>this.Ot.size||(this.Ft||(this.Ft=!0,this.Ge.warn("Metric series cap reached ("+this.Te.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Ht(t,e){var n;switch(t.type){case"count":t.total=((n=t.total)!==null&&n!==void 0?n:0)+e;break;case"gauge":t.last=e;break;case"histogram":t.hist||(t.hist={count:0,sum:0,min:e,max:e,bucketCounts:new Array(gv.length+1).fill(0)});var r=t.hist;r.count+=1,r.sum+=e,r.min=Math.min(r.min,e),r.max=Math.max(r.max,e),r.bucketCounts[(function(s,i){for(var a=0;i.length>a;a++)if(i[a]>=s)return a;return i.length})(e,gv)]+=1}}wt(t){var e=this.Te.beforeSend;if(!e)return t;var n=Qe(e)?e:[e],r=t;for(var s of n)try{var i=s(r);if(!i)return this.Ge.info("Metric was rejected in beforeSend function"),null;r=i}catch(a){return this.Ge.error("Error in beforeSend function for metric:",a),null}return r}Tt(){this.Et||(this.Et=bp((()=>{this.Et=void 0,this.flush().catch((t=>{this.Ge.error("Metrics flush failed:",t)}))}),this.Te.flushIntervalMs))}bt(){this.Et&&(clearTimeout(this.Et),this.Et=void 0)}Dt(){var t=this;return en((function*(){if(t.Ot.size!==0){var e=t.Ot;t.Ot=new Map,t.Ft=!1,t.At=new Map,t.Lt=new Set;var n=t.$t,r=yield t._instance.Bt(t.qt(e));if(n===t.$t)switch(r.kind){case"ok":return;case"retry-later":return t.Ut(e),void t.Tt();case"too-large":return void t.Ge.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.Ge.error("Failed to send metrics batch:",r.error)}}}))()}qt(t){return e=this.zt(t),n=(function(i,a,c){return ue({},i.resourceAttributes,{"service.name":i.serviceName||"unknown_service"},i.environment&&{"deployment.environment":i.environment},i.serviceVersion&&{"service.version":i.serviceVersion},{"telemetry.sdk.name":a,"telemetry.sdk.version":c})})(this.Te,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),s=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:rm(n)},scopeMetrics:[{scope:{name:r,version:s},metrics:e}]}]};var e,n,r,s}zt(t){var e=EE(Date.now()),n=new Map;for(var r of t.values()){var s,i=CE(r.type,r.name,r.unit,void 0),a=n.get(i);a||(a=ue({name:r.name},r.unit&&{unit:r.unit}),r.type==="count"?a.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:r.type==="gauge"?a.gauge={dataPoints:[]}:a.histogram={aggregationTemporality:1,dataPoints:[]},n.set(i,a));var c=rm((s=r.attributes)!==null&&s!==void 0?s:{}),u=EE(r.windowStartMs);if(r.type==="count"){var f,h={attributes:c,startTimeUnixNano:u,timeUnixNano:e,asDouble:(f=r.total)!==null&&f!==void 0?f:0};a.sum.dataPoints.push(h)}else if(r.type==="gauge"){var p,m={attributes:c,timeUnixNano:e,asDouble:(p=r.last)!==null&&p!==void 0?p:0};a.gauge.dataPoints.push(m)}else r.hist&&a.histogram.dataPoints.push({attributes:c,startTimeUnixNano:u,timeUnixNano:e,count:r.hist.count,sum:r.hist.sum,min:r.hist.min,max:r.hist.max,bucketCounts:r.hist.bucketCounts,explicitBounds:gv})}return Array.from(n.values())}Ut(t){var e,n;for(var r of t){var s=r[0],i=r[1],a=this.Ot.get(s);if(a)switch(a.windowStartMs=Math.min(a.windowStartMs,i.windowStartMs),a.type){case"count":a.total=((e=a.total)!==null&&e!==void 0?e:0)+((n=i.total)!==null&&n!==void 0?n:0);break;case"gauge":break;case"histogram":if(i.hist)if(a.hist){a.hist.count+=i.hist.count,a.hist.sum+=i.hist.sum,a.hist.min=Math.min(a.hist.min,i.hist.min),a.hist.max=Math.max(a.hist.max,i.hist.max);for(var c=0;a.hist.bucketCounts.length>c;c++)a.hist.bucketCounts[c]+=i.hist.bucketCounts[c]}else a.hist=i.hist}else this.jt()&&this.Ot.set(s,i)}}};var Bh,kE,vv;function HL(t){var e=globalThis._posthogChunkIds;if(e){var n=Object.keys(e);return vv&&n.length===kE||(kE=n.length,vv=n.reduce(((r,s)=>{Bh||(Bh={});var i=Bh[s];if(i)r[i[0]]=i[1];else for(var a=t(s),c=a.length-1;c>=0;c--){var u=a[c],f=u==null?void 0:u.filename,h=e[s];if(f&&h){r[f]=h,Bh[s]=[f,h];break}}return r}),{})),vv}}class zL{constructor(e,n,r){r===void 0&&(r=[]),this.coercers=e,this.stackParser=n,this.modifiers=r}buildFromUnknown(e,n){n===void 0&&(n={});var r=n&&n.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(r,n,0).apply(e),i=this.buildParsingContext(n),a=this.parseStacktrace(s,i);return{$exception_list:this.convertToExceptionList(a,r),$exception_level:"error"}}modifyFrames(e){var n=this;return en((function*(){for(var r of e)r.stacktrace&&r.stacktrace.frames&&Qe(r.stacktrace.frames)&&(r.stacktrace.frames=yield n.applyModifiers(r.stacktrace.frames));return e}))()}coerceFallback(e){var n;return{type:"Error",value:"Unknown error",stack:(n=e.syntheticException)==null?void 0:n.stack,synthetic:!0}}parseStacktrace(e,n){var r,s;return e.cause!=null&&(r=this.parseStacktrace(e.cause,n)),e.stack!=""&&e.stack!=null&&(s=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?n.skipFirstLines:0),n.chunkIdMap)),ue({},e,{cause:r,stack:s})}applyChunkIds(e,n){return e.map((r=>(r.filename&&n&&(r.chunk_id=n[r.filename]),r)))}applyCoercers(e,n){for(var r of this.coercers)if(r.match(e))return r.coerce(e,n);return this.coerceFallback(n)}applyModifiers(e){var n=this;return en((function*(){var r=e;for(var s of n.modifiers)r=yield s(r);return r}))()}convertToExceptionList(e,n){var r,s,i,a={type:e.type,value:e.value,mechanism:{type:(r=n.type)!==null&&r!==void 0?r:"generic",handled:(s=n.handled)===null||s===void 0||s,synthetic:(i=e.synthetic)!==null&&i!==void 0&&i}};e.stack&&(a.stacktrace={type:"raw",frames:e.stack});var c=[a];return e.cause!=null&&c.push(...this.convertToExceptionList(e.cause,ue({},n,{handled:!0}))),c}buildParsingContext(e){var n;return{chunkIdMap:HL(this.stackParser),skipFirstLines:(n=e.skipFirstLines)!==null&&n!==void 0?n:1}}buildCoercingContext(e,n,r){r===void 0&&(r=0);var s=(i,a)=>{if(4>=a){var c=this.buildCoercingContext(e,n,a);return this.applyCoercers(i,c)}};return ue({},n,{syntheticException:r==0?n.syntheticException:void 0,mechanism:e,apply:i=>s(i,r),next:i=>s(i,r+1)})}}var Xc="?";function hy(t,e,n,r,s){var i={platform:t,filename:e,function:n==="<anonymous>"?Xc:n,in_app:!0};return ge(r)||(i.lineno=r),ge(s)||(i.colno=s),i}var P6=(t,e)=>{var n=t.indexOf("safari-extension")!==-1,r=t.indexOf("safari-web-extension")!==-1;return n||r?[t.indexOf("@")!==-1?t.split("@")[0]:Xc,n?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},UL=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,BL=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,WL=/\((\S*)(?::(\d+))(?::(\d+))\)/,GL=(t,e)=>{var n=UL.exec(t);if(n)return hy(e,n[1],Xc,+n[2],+n[3]);var r=BL.exec(t);if(r){if(r[2]&&r[2].indexOf("eval")===0){var s=WL.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var i=P6(r[1]||Xc,r[2]);return hy(e,i[1],i[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},KL=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ZL=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,qL=(t,e)=>{var n=KL.exec(t);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){var r=ZL.exec(n[3]);r&&(n[1]=n[1]||"eval",n[3]=r[1],n[4]=r[2],n[5]="")}var s=n[3],i=n[1]||Xc,a=P6(i,s);return hy(e,s=a[1],i=a[0],n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},PE=/\(error: (.*)\)/;class YL{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,n){var r=xt(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:r?e.stack:void 0,cause:e.cause?n.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var n=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?n+": "+e.message:n}isDOMException(e){return Qp(e,"DOMException")}isDOMError(e){return Qp(e,"DOMError")}}class XL{match(e){return(n=>n instanceof Error)(e)}coerce(e,n){return{type:this.getType(e),value:this.getMessage(e,n),stack:this.getStack(e),cause:e.cause?n.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,n){var r=e.message;return String(r.error&&typeof r.error.message=="string"?r.error.message:r)}getStack(e){return e.stacktrace||e.stack||void 0}}class QL{constructor(){}match(e){return Qp(e,"ErrorEvent")&&e.error!=null}coerce(e,n){var r;return n.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}}var JL=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class eN{match(e){return typeof e=="string"}coerce(e,n){var r,s=this.getInfos(e),i=s[0],a=s[1];return{type:i??"Error",value:a??e,stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}getInfos(e){var n="Error",r=e,s=e.match(JL);return s&&(n=s[1],r=s[2]),[n,r]}}var tN=["fatal","error","warning","log","info","debug"];function T6(t,e){e===void 0&&(e=40);var n=Object.keys(t);if(n.sort(),!n.length)return"[object has no keys]";for(var r=n.length;r>0;r--){var s=n.slice(0,r).join(", ");if(e>=s.length)return r===n.length?s:s.length>e?s.slice(0,e)+"...":s}return""}class nN{match(e){return typeof e=="object"&&e!==null}coerce(e,n){var r,s=this.getErrorPropertyFromObject(e);return s?n.apply(s):{type:this.getType(e),value:this.getValue(e),stack:(r=n.syntheticException)==null?void 0:r.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return y2(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var n="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(n+=" with message: '"+e.message+"'"),n}if("message"in e&&typeof e.message=="string")return e.message;var r=this.getObjectClassName(e);return(r&&r!=="Object"?"'"+r+"'":"Object")+" captured as exception with keys: "+T6(e)}isSeverityLevel(e){return xt(e)&&!ly(e)&&tN.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var n in e)if({}.hasOwnProperty.call(e,n)){var r=e[n];if(DL(r))return r}}getObjectClassName(e){try{var n=Object.getPrototypeOf(e);return n?n.constructor.name:void 0}catch{return}}}class rN{match(e){return y2(e)}coerce(e,n){var r,s=e.constructor.name;return{type:s,value:s+" captured as exception with keys: "+T6(e),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}}class sN{match(e){return n6(e)}coerce(e,n){var r;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}}class iN{match(e){return Qp(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!y2(e))return!1;try{var n=e.detail;return n!=null&&typeof n=="object"&&"reason"in n}catch{return!1}}coerce(e,n){var r,s=this.getUnhandledRejectionReason(e);return n6(s)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(s),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}:n.apply(s)}getUnhandledRejectionReason(e){try{if("reason"in e)return e.reason;if("detail"in e&&e.detail!=null&&typeof e.detail=="object"&&"reason"in e.detail)return e.detail.reason}catch{}return e}}var sm="$message",im="$timestamp",oN=new Set([sm,im]),yv={enabled:!0,max_bytes:32768};function om(t){var e;return t?{enabled:(e=t.enabled)!==null&&e!==void 0?e:yv.enabled,max_bytes:lN(t.max_bytes,yv.max_bytes)}:ue({},yv)}class aN{constructor(e){this.Vt=[],this.Wt=0,this.Te=om(e)}setConfig(e){this.Te=om(e),this.Zt()}add(e){var n=(function(s){var i;try{i=J8(s)}catch{return}try{var a=JSON.parse(i);if(!Nt(a))return;var c=a,u=c[sm],f=c[im];return!xt(u)||u.trim().length===0||!xt(f)&&!$n(f)?void 0:{step:c,json:i}}catch{return}})(e);if(n){var r=(function(s){if(typeof TextEncoder<"u")return new TextEncoder().encode(s).length;for(var i=encodeURIComponent(s),a=0,c=0;i.length>c;c++)i[c]==="%"?(a+=1,c+=2):a+=1;return a})(n.json);r>this.Te.max_bytes||(this.Vt.push({step:n.step,bytes:r}),this.Wt+=r,this.Zt())}}getAttachable(){return this.Vt.map((e=>e.step))}clear(){this.Vt=[],this.Wt=0}size(){return this.Vt.length}Zt(){for(;this.Wt>this.Te.max_bytes&&this.Vt.length>0;){var e=this.Vt.shift();e&&(this.Wt-=e.bytes)}}}function lN(t,e){if(!$n(t)||t===1/0||t===-1/0)return e;var n=Math.floor(t);return 0>n?e:n}var R6=function(t,e){var n=(e===void 0?{}:e).debugEnabled,r={k(s){if(te&&(gt.DEBUG||te.POSTHOG_DEBUG||n)&&!ge(te.console)&&te.console){for(var i=("__rrweb_original__"in te.console[s])?te.console[s].__rrweb_original__:te.console[s],a=arguments.length,c=new Array(a>1?a-1:0),u=1;a>u;u++)c[u-1]=arguments[u];i(t,...c)}},debug(){for(var s=arguments.length,i=new Array(s),a=0;s>a;a++)i[a]=arguments[a];r.k("debug",...i)},info(){for(var s=arguments.length,i=new Array(s),a=0;s>a;a++)i[a]=arguments[a];r.k("log",...i)},warn(){for(var s=arguments.length,i=new Array(s),a=0;s>a;a++)i[a]=arguments[a];r.k("warn",...i)},error(){for(var s=arguments.length,i=new Array(s),a=0;s>a;a++)i[a]=arguments[a];r.k("error",...i)},critical(){for(var s=arguments.length,i=new Array(s),a=0;s>a;a++)i[a]=arguments[a];console.error(t,...i)},uninitializedWarning(s){r.error("You must initialize PostHog before calling "+s)},createLogger:(s,i)=>R6(t+" "+s,i)};return r},_e=R6("[PostHog.js]"),Vt=_e.createLogger,cN=Vt("[ExternalScriptsLoader]"),_v=(t,e,n)=>{if(t.config.disable_external_dependency_loading)return cN.warn(e+" was requested but loading of external scripts is disabled."),n("Loading of external scripts is disabled");var r=Se==null?void 0:Se.querySelectorAll("script");if(r){for(var s,i=function(){if(r[a].src===e){var u=r[a];return u.__posthog_loading_callback_fired?{v:n()}:(u.addEventListener("load",(f=>{u.__posthog_loading_callback_fired=!0,n(void 0,f)})),u.onerror=f=>n(f),{v:void 0})}},a=0;r.length>a;a++)if(s=i())return s.v}var c=()=>{if(!Se)return n("document not found");var u=Se.createElement("script");if(u.type="text/javascript",u.crossOrigin="anonymous",u.src=e,u.onload=p=>{u.__posthog_loading_callback_fired=!0,n(void 0,p)},u.onerror=p=>n(p),t.config.prepare_external_dependency_script&&(u=t.config.prepare_external_dependency_script(u)),!u)return n("prepare_external_dependency_script returned null");if(t.config.external_scripts_inject_target==="head")Se.head.appendChild(u);else{var f,h=Se.querySelectorAll("body > script");h.length>0?(f=h[0].parentNode)==null||f.insertBefore(u,h[0]):Se.body.appendChild(u)}};Se!=null&&Se.body?c():Se==null||Se.addEventListener("DOMContentLoaded",c)};$e.__PosthogExtensions__=$e.__PosthogExtensions__||{},$e.__PosthogExtensions__.loadExternalDependency=(t,e,n)=>{if(e!=="remote-config"){var r;if(t.config.strict_script_versioning)r=t.requestRouter.endpointFor("assets","/static/"+t.version+"/"+e+".js");else{var s="/static/"+e+".js?v="+t.version;if(e==="toolbar"){var i=3e5;s=s+"&t="+Math.floor(Date.now()/i)*i}r=t.requestRouter.endpointFor("assets",s)}_v(t,r,n)}else{var a=t.requestRouter.endpointFor("assets","/array/"+t.config.token+"/config.js");_v(t,a,n)}},$e.__PosthogExtensions__.loadSiteApp=(t,e,n)=>{var r=t.requestRouter.endpointFor("api",e);_v(t,r,n)};gt.DEBUG=!1,gt.LIB_VERSION="1.408.0",gt.LIB_NAME="web";var A6="$people_distinct_id",am="$device_id",xv="$device_model",hd="__alias",pd="__timers",py="$autocapture_disabled_server_side",my="$heatmaps_enabled_server_side",gy="$exception_capture_enabled_server_side",vy="$error_tracking_suppression_rules",yy="$error_tracking_capture_extension_exceptions",_y="$web_vitals_enabled_server_side",S2="$dead_clicks_enabled_server_side",E2="$product_tours_enabled_server_side",xy="$web_vitals_allowed_metrics",sl="$session_recording_remote_config",I6="$replay_sample_rate",M6="$replay_override_sampling",O6="$replay_override_linked_flag",L6="$replay_override_url_trigger",N6="$replay_override_event_trigger",_c="$sesid",C2="$session_is_sampled",tl="$enabled_feature_flags",Sp="$active_feature_flags",md="$early_access_features",wy="$feature_flag_details",Ep="$feature_flag_payloads",by="$feature_flag_request_id",lm="$minimal_flag_called_events",zi="$override_feature_flags",pc="$override_feature_flag_payloads",Ya="$stored_person_properties",Xa="$stored_group_properties",Sy="$surveys",cm="$surveys_loaded_at",Ey="$surveys_activated",Cp="$surveys_activated_session",gd="ph_product_tours",bd="$flag_call_reported",Cy="$flag_call_reported_session_id",ky="$feature_flag_errors",$d="$feature_flag_evaluated_at",Fs="$user_state",Py="$client_session_props",Ty="$capture_rate_limit",Ry="$initial_campaign_params",Ay="$initial_referrer_info",um="$initial_person_info",dm="$epp",Wh="$posthog_cookieless",D6="$cookieless_mode",j6="$sdk_debug_extensions_init_method",F6="$sdk_debug_extensions_init_time_ms",V6="$sdk_debug_recording_script_not_loaded",k2="PostHog loadExternalDependency extension not found.",Qa="on_reject",Xi="always",rc="anonymous",sc="identified",Iy="identified_only",fm="visibilitychange",hm="beforeunload",mc="$pageview",wv="$pageleave",bv="$identify",TE="$groupidentify";function Gh(t,e){Qe(t)&&t.forEach(e)}function wt(t,e){if(!Je(t))if(Qe(t))t.forEach(e);else if(xL(t))t.forEach(((r,s)=>e(r,s)));else for(var n in t)t6.call(t,n)&&e(t[n],n)}var At=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;e>r;r++)n[r-1]=arguments[r];for(var s of n)for(var i in s)s[i]!==void 0&&(t[i]=s[i]);return t};function kp(t){for(var e=Object.keys(t),n=e.length,r=new Array(n);n--;)r[n]=[e[n],t[e[n]]];return r}var RE=function(t){try{return t()}catch{return}},uN=function(t){return function(){try{for(var e=arguments.length,n=new Array(e),r=0;e>r;r++)n[r]=arguments[r];return t.apply(this,n)}catch(s){_e.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),_e.critical(s)}}},P2=function(t){var e={};return wt(t,(function(n,r){(xt(n)&&n.length>0||$n(n))&&(e[r]=n)})),e},dN=["herokuapp.com","vercel.app","netlify.app"];function fN(t){var e=t==null?void 0:t.hostname;if(!xt(e))return!1;var n=e.split(".").slice(-2).join(".");for(var r of dN)if(n===r)return!1;return!0}function zt(t,e,n,r){var s=r??{},i=s.capture,a=s.passive;t==null||t.addEventListener(e,n,{capture:i!==void 0&&i,passive:a===void 0||a})}function $6(t){return t.name==="ph_toolbar_internal"}var H6=t=>{if(Se){try{for(var e=t+"=",n=Se.cookie.split(";").filter((i=>i.length)),r=0;n.length>r;r++){for(var s=n[r];s.charAt(0)==" ";)s=s.substring(1,s.length);if(s.indexOf(e)===0)return decodeURIComponent(s.substring(e.length,s.length))}}catch{}return null}};Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return $n(t)&&isFinite(t)&&Math.floor(t)===t});class pm{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,n,r,s){if(!Number.isInteger(e)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(s)||0>e||0>n||0>r||0>s||e>0xffffffffffff||n>4095||r>1073741823||s>4294967295)throw new RangeError("invalid field value");var i=new Uint8Array(16);return i[0]=e/Math.pow(2,40),i[1]=e/Math.pow(2,32),i[2]=e/Math.pow(2,24),i[3]=e/Math.pow(2,16),i[4]=e/256,i[5]=e,i[6]=112|n>>>8,i[7]=n,i[8]=128|r>>>24,i[9]=r>>>16,i[10]=r>>>8,i[11]=r,i[12]=s>>>24,i[13]=s>>>16,i[14]=s>>>8,i[15]=s,new pm(i)}toString(){for(var e="",n=0;this.bytes.length>n;n++)e=e+(this.bytes[n]>>>4).toString(16)+(15&this.bytes[n]).toString(16),n!==3&&n!==5&&n!==7&&n!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new pm(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var n=0;16>n;n++){var r=this.bytes[n]-e.bytes[n];if(r!==0)return Math.sign(r)}return 0}}class hN{generate(){var e=this.generateOrAbort();if(!ge(e))return e;this.S=0;var n=this.generateOrAbort();if(ge(n))throw new Error("Could not generate UUID after timestamp reset");return n}generateOrAbort(){var e=Date.now();if(e>this.S)this.S=e,this.C();else{if(this.S>=e+1e4)return;this.M++,this.M>4398046511103&&(this.S++,this.C())}return pm.fromFieldsV7(this.S,Math.trunc(this.M/Math.pow(2,30)),this.M&Math.pow(2,30)-1,this.I.nextUint32())}C(){this.M=1024*this.I.nextUint32()+(1023&this.I.nextUint32())}constructor(){this.S=0,this.M=0,this.I=new pN}}var AE,z6=t=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;t.length>e;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};te&&!ge(te.crypto)&&crypto.getRandomValues&&(z6=t=>crypto.getRandomValues(t));class pN{nextUint32(){return this.R.length>this.O||(z6(this.R),this.O=0),this.R[this.O++]}constructor(){this.R=new Uint32Array(8),this.O=1/0}}var Ki=()=>mN().toString(),mN=()=>(AE||(AE=new hN)).generate(),Xu="",gN=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,Qi={N:()=>!!Se,D(t){_e.error("cookieStore error: "+t)},A:H6,F(t){var e;try{e=JSON.parse(Qi.A(t))||{}}catch{}return e},q(t,e,n,r,s){if(!Se)return!1;try{var i="",a="",c=(function(h,p){if(p){var m=(function(x,y){if(y===void 0&&(y=Se),Xu)return Xu;if(!y||["localhost","127.0.0.1"].includes(x))return"";for(var w=x.split("."),S=Math.min(w.length,8),T="dmn_chk_"+Ki();!Xu&&S--;){var P=w.slice(S).join("."),k=T+"=1;domain=."+P+";path=/";y.cookie=k+";max-age=3",y.cookie.includes(T)&&(y.cookie=k+";max-age=0",Xu=P)}return Xu})(h);if(!m){var _=(x=>{var y=x.match(gN);return y?y[0]:""})(h);_!==m&&_e.info("Warning: cookie subdomain discovery mismatch",_,m),m=_}return m?"; domain=."+m:""}return""})(Se.location.hostname,r);if(n){var u=new Date;u.setTime(u.getTime()+864e5*n),i="; expires="+u.toUTCString()}s&&(a="; secure");var f=t+"="+encodeURIComponent(JSON.stringify(e))+i+"; SameSite=Lax; path=/"+c+a;return f.length>3686.4&&_e.warn("cookieStore warning: large cookie, len="+f.length),Se.cookie=f,!0}catch{return!1}},P(t,e){if(Se!=null&&Se.cookie)try{Qi.q(t,"",-1,e)}catch{return}}},Sv=null,St={N(){if(!dr(Sv))return Sv;var t=!0;if(ge(te))t=!1;else try{var e="__mplssupport__";St.q(e,"xyz"),St.A(e)!=='"xyz"'&&(t=!1),St.P(e)}catch{t=!1}return t||_e.error("localStorage unsupported; falling back to cookie store"),Sv=t,t},D(t){_e.error("localStorage error: "+t)},A(t){try{return te==null?void 0:te.localStorage.getItem(t)}catch(e){St.D(e)}return null},F(t){try{return JSON.parse(St.A(t))||{}}catch{}return null},q(t,e){try{return te==null||te.localStorage.setItem(t,JSON.stringify(e)),!0}catch(n){St.D(n)}return!1},P(t){try{te==null||te.localStorage.removeItem(t)}catch(e){St.D(e)}}},vN=[am,"distinct_id",_c,C2,dm,um,Fs],Kh={},yN={N:()=>!0,D(t){_e.error("memoryStorage error: "+t)},A:t=>Kh[t]||null,F:t=>Kh[t]||null,q:(t,e)=>(Kh[t]=e,!0),P(t){delete Kh[t]}},ja=null,jn={N(){if(!dr(ja))return ja;if(ja=!0,ge(te))ja=!1;else try{var t="__support__";jn.q(t,"xyz"),jn.A(t)!=='"xyz"'&&(ja=!1),jn.P(t)}catch{ja=!1}return ja},D(t){_e.error("sessionStorage error: ",t)},A(t){try{return te==null?void 0:te.sessionStorage.getItem(t)}catch(e){jn.D(e)}return null},F(t){try{return JSON.parse(jn.A(t))||null}catch{}return null},q(t,e){try{return te==null||te.sessionStorage.setItem(t,JSON.stringify(e)),!0}catch(n){jn.D(n)}return!1},P(t){try{te==null||te.sessionStorage.removeItem(t)}catch(e){jn.D(e)}}};class _N{constructor(e){this._instance=e}get Te(){return this._instance.config}get consent(){return this.Gt()?0:this.Qt}isOptedOut(){return this.Te.cookieless_mode===Xi||this.isRejected()||this.consent===-1&&this.Te.cookieless_mode===Qa}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Te.opt_out_capturing_by_default}optInOut(e){this.Jt.q(this.Kt,e?1:0,this.Te.cookie_expiration,this.Te.cross_subdomain_cookie,this.Te.secure_cookie)}reset(){this.Jt.P(this.Kt,this.Te.cross_subdomain_cookie)}get Kt(){var e=this._instance.config,n=e.token,r=e.opt_out_capturing_cookie_prefix;return e.consent_persistence_name||(r?r+n:"__ph_opt_in_out_"+n)}get Qt(){var e=this.Jt.A(this.Kt);return pv(e)?1:Ge(EL,e)?0:-1}get Jt(){var e=this.Te.opt_out_capturing_persistence_type,n=e==="localStorage"?St:Qi;if(!this.Yt||this.Yt!==n){this.Yt=n;var r=e==="localStorage"?Qi:St;r.A(this.Kt)&&(this.Yt.A(this.Kt)||this.optInOut(pv(r.A(this.Kt))),r.P(this.Kt,this.Te.cross_subdomain_cookie))}return this.Yt}Gt(){return!!this.Te.respect_dnt&&[ar==null?void 0:ar.doNotTrack,ar==null?void 0:ar.msDoNotTrack,$e.doNotTrack].some((e=>pv(e)))}}function U6(t,e){var n,r=t==null||(n=t.config)==null?void 0:n.get_current_url;if(!zs(r))return e;try{var s=r(e);return xt(s)&&s?s:e}catch(i){return _e.error("Error in get_current_url, falling back to window.location.href",i),e}}var B6="__POSTHOG_TOOLBAR__",xN=1,wN=3,bN=11;function IE(t){return t instanceof Element&&(t.id===B6||!(t.closest==null||!t.closest(".toolbar-global-fade-container")))}function ia(t){return!!t&&t.nodeType===xN}function qr(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function W6(t){return!!t&&t.nodeType===wN}function G6(t){return!!t&&t.nodeType===bN&&ia(t.host)}var K6=1e3;function T2(t){return t?e0(t).split(/\s+/):[]}function ME(t,e){var n=(function(r){var s,i=te==null||(s=te.location)==null?void 0:s.href;return ge(i)?void 0:U6(r,i)})(e);return!!(n&&t&&t.some((r=>n.match(r))))}function mm(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return T2(e)}function Z6(t){return Je(t)?null:e0(t).split(/(\s+)/).filter((e=>Sd(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Hd(t){var e="";return Oy(t)&&!Q6(t)&&t.childNodes&&t.childNodes.length&&wt(t.childNodes,(function(n){var r;W6(n)&&n.textContent&&(e+=(r=Z6(n.textContent))!==null&&r!==void 0?r:"")})),e0(e)}function Ev(t){var e;return ge(t.target)?t.srcElement||null:(e=t.target)!=null&&e.shadowRoot?t.composedPath()[0]||null:t.target||null}var R2=["a","button","form","input","select","textarea","label"];function My(t,e){if(ge(e))return!0;var n,r=function(i){if(e.some((a=>(function(c,u){var f=c.matches||c.matchesSelector||c.msMatchesSelector||c.mozMatchesSelector||c.webkitMatchesSelector||c.oMatchesSelector;try{return!!f&&f.call(c,u)}catch{return!1}})(i,a))))return{v:!0}};for(var s of t)if(n=r(s))return n.v;return!1}function q6(t){var e=t.parentNode;return!(!e||!ia(e))&&e}var SN=[".ph-no-autocapture","[data-ph-no-autocapture]"],Y6=["next","previous","prev",">","<"],EN=[...Y6,"+","-","−","–"],OE=(t,e)=>/[a-z0-9]/i.test(e)?t.includes(e):t===e,LE=[".ph-no-rageclick",".ph-no-capture"],CN=["","text","search","email","password","url","tel","number"];function NE(t,e){if(!te||A2(t))return!1;var n,r,s,i,a;if(Us(e)?(n=!!e&&LE,r=void 0,s=!1):(n=(i=e==null?void 0:e.css_selector_ignorelist)!==null&&i!==void 0?i:LE,r=e==null?void 0:e.content_ignorelist,s=(a=e==null?void 0:e.ignore_text_selection)!==null&&a!==void 0&&a),n===!1||s&&(function(u){return!(!u||!ia(u))&&(!!qr(u,"textarea")||(qr(u,"input")?Ge(CN,(u.getAttribute("type")||"").toLowerCase()):(function(f){if(f.isContentEditable)return!0;var h=f.getAttribute==null?void 0:f.getAttribute("contenteditable");return h==="true"||h===""})(u)))})(t))return!1;var c=X6(t,!1).targetElementList;return!(function(u,f){if(u===!1||ge(u))return!1;var h;if(u===!0)h=Y6;else{if(!Qe(u))return!1;if(u.length>10)return _e.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;h=u.map((p=>p.toLowerCase()))}return f.some((p=>{var m=p.safeText,_=p.ariaLabel;return h.some((x=>OE(m,x)||OE(_,x)))}))})(r,c.map((u=>{var f;return{safeText:Hd(u).toLowerCase(),ariaLabel:((f=u.getAttribute("aria-label"))==null?void 0:f.toLowerCase().trim())||""}})))&&!My(c,n)}var A2=t=>!t||qr(t,"html")||!ia(t),X6=(t,e)=>{if(!te||A2(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var n=!1,r=[t],s=t;s.parentNode&&!qr(s,"body");)if(G6(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var i=q6(s);if(!i)break;if(e||R2.indexOf(i.tagName.toLowerCase())>-1)n=!0;else try{var a=te.getComputedStyle(i);a&&a.getPropertyValue("cursor")==="pointer"&&(n=!0)}catch{}r.push(i),s=i}return{parentIsUsefulElement:n,targetElementList:r}};function Oy(t){for(var e=new Set,n=0,r=t;r.parentNode&&!qr(r,"body");r=r.parentNode){if(n++>=K6||e.has(r))return!1;e.add(r);var s=mm(r);if(Ge(s,"ph-sensitive")||Ge(s,"ph-no-capture"))return!1}if(Ge(mm(t),"ph-include"))return!0;var i=t.type||"";if(xt(i))switch(i.toLowerCase()){case"hidden":case"password":return!1}var a=t.name||t.id||"";return!xt(a)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(a.replace(/[^a-zA-Z0-9]/g,""))}function Q6(t){return!!(qr(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||qr(t,"select")||qr(t,"textarea")||t.getAttribute("contenteditable")==="true")}var J6="(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})",kN=new RegExp("^(?:"+J6+")$"),PN=new RegExp(J6),eP="\\d{3}-?\\d{2}-?\\d{4}",TN=new RegExp("^("+eP+")$"),RN=new RegExp("("+eP+")");function Sd(t,e){return e===void 0&&(e=!0),!(Je(t)||xt(t)&&(t=e0(t),(e?kN:PN).test((t||"").replace(/[- ]/g,""))||(e?TN:RN).test(t)))}function DE(t){var e=Hd(t);return Sd(e=(e+" "+tP(t)).trim())?e:""}function tP(t){var e="";return t&&t.childNodes&&t.childNodes.length&&wt(t.childNodes,(function(n){var r;if(n&&((r=n.tagName)==null?void 0:r.toLowerCase())==="span")try{var s=Hd(n);e=(e+" "+s).trim(),n.childNodes&&n.childNodes.length&&(e=(e+" "+tP(n)).trim())}catch(i){_e.error("[AutoCapture]",i)}})),e}function jE(t){return t.replace(/"|\\"/g,'\\"')}function AN(t){var e=t.attr__class;if(e)return Qe(e)?e:T2(e)}var Zh=Vt("[Dead Clicks]"),IN=()=>!0,MN=t=>{var e,n=!((e=t.instance.persistence)==null||!e.get_property(S2)),r=t.instance.config.capture_dead_clicks;return Us(r)?r:!!Nt(r)||n};class FE{get lazyLoadedDeadClicksAutocapture(){return this.Xt}constructor(e,n,r){this.instance=e,this.isEnabled=n,this.onCapture=r,this.startIfEnabledOrStop()}onRemoteConfig(e){if(e.ok){var n=e.config;"captureDeadClicks"in n&&(this.instance.persistence&&this.instance.persistence.register({[S2]:n.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.er((()=>{this.tr()})):this.stop()}er(e){var n,r;(n=$e.__PosthogExtensions__)!=null&&n.initDeadClicksAutocapture?e():(r=$e.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"dead-clicks-autocapture",(s=>{s?Zh.error("failed to load script",s):e()}))}tr(){var e;if(Se){if(!this.Xt&&(e=$e.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var n=Nt(this.instance.config.capture_dead_clicks)?ue({},this.instance.config.capture_dead_clicks):{};n.__onCapture=this.onCapture,this.onCapture&&(n.capture_dead_swipes=!1),this.Xt=$e.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this.Xt.start(Se),Zh.info("starting...")}}else Zh.error("`document` not found. Cannot start.")}stop(){this.Xt&&(this.Xt.stop(),this.Xt=void 0,Zh.info("stopping..."))}}var Cv=Vt("[SegmentIntegration]"),nP="posthog-js";function rP(t,e){var n=e===void 0?{}:e,r=n.organization,s=n.projectId,i=n.prefix,a=n.severityAllowList,c=a===void 0?["error"]:a,u=n.sendExceptionsToPostHog,f=u===void 0||u;return h=>{var p,m,_,x,y;if(c!=="*"&&!c.includes(h.level)||!t.__loaded)return h;h.tags||(h.tags={});var w=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());h.tags["PostHog Person URL"]=w,t.sessionRecordingStarted()&&(h.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var S,T=((p=h.exception)==null?void 0:p.values)||[],P=T.map((R=>ue({},R,{stacktrace:R.stacktrace?ue({},R.stacktrace,{type:"raw",frames:(R.stacktrace.frames||[]).map((L=>ue({},L,{platform:"web:javascript"})))}):void 0}))),k={$exception_message:((m=T[0])==null?void 0:m.value)||h.message,$exception_type:(_=T[0])==null?void 0:_.type,$exception_level:h.level,$exception_list:P,$sentry_event_id:h.event_id,$sentry_exception:h.exception,$sentry_exception_message:((x=T[0])==null?void 0:x.value)||h.message,$sentry_exception_type:(y=T[0])==null?void 0:y.type,$sentry_tags:h.tags};return r&&s&&(k.$sentry_url=(i||"https://sentry.io/organizations/")+r+"/issues/?project="+s+"&query="+h.event_id),f&&((S=t.exceptions)==null||S.sendExceptionEvent(k)),h}}class ON{constructor(e,n,r,s,i,a){this.name=nP,this.setupOnce=function(c){c(rP(e,{organization:n,projectId:r,prefix:s,severityAllowList:i,sendExceptionsToPostHog:a==null||a}))}}}class VE{constructor(e){this.rr=(n,r,s)=>{s&&(s.noSessionId||s.activityTimeout||s.sessionPastMaximumLength||s.crossTabAdoption)&&(_e.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:n,changeReason:s}),this.ir=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.nr()}nr(){var e;this.sr=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.rr)}destroy(){var e;(e=this.sr)==null||e.call(this),this.sr=void 0}doPageView(e,n){var r,s=this.ar(e,n);return this.ir={pathname:(r=te==null?void 0:te.location.pathname)!==null&&r!==void 0?r:"",pageViewId:n,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var n;return this.ar(e,(n=this.ir)==null?void 0:n.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.ir)==null?void 0:e.pageViewId}}ar(e,n){var r=this.ir;if(!r)return{$pageview_id:n};var s={$pageview_id:n,$prev_pageview_id:r.pageViewId},i=this._instance.scrollManager.getContext();if(i&&!this._instance.config.disable_scroll_properties){var a=i.maxScrollHeight,c=i.lastScrollY,u=i.maxScrollY,f=i.maxContentHeight,h=i.lastContentY,p=i.maxContentY;if(!(ge(a)||ge(c)||ge(u)||ge(f)||ge(h)||ge(p))){a=Math.ceil(a),c=Math.ceil(c),u=Math.ceil(u),f=Math.ceil(f),h=Math.ceil(h),p=Math.ceil(p);var m=a>1?hi(c/a,0,1,_e):1,_=a>1?hi(u/a,0,1,_e):1,x=f>1?hi(h/f,0,1,_e):1,y=f>1?hi(p/f,0,1,_e):1;s=At(s,{$prev_pageview_last_scroll:c,$prev_pageview_last_scroll_percentage:m,$prev_pageview_max_scroll:u,$prev_pageview_max_scroll_percentage:_,$prev_pageview_last_content:h,$prev_pageview_last_content_percentage:x,$prev_pageview_max_content:p,$prev_pageview_max_content_percentage:y})}}return r.pathname&&(s.$prev_pageview_pathname=r.pathname),r.timestamp&&(s.$prev_pageview_duration=(e.getTime()-r.timestamp.getTime())/1e3),s}}var kv=["flags","surveys"],LN={[A6]:{exposure:"hidden"},[hd]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[pd]:{exposure:"hidden"},[py]:{exposure:"event"},[my]:{exposure:"hidden"},[gy]:{exposure:"event"},[vy]:{exposure:"hidden"},[yy]:{exposure:"event"},[_y]:{exposure:"event"},[S2]:{exposure:"event"},[E2]:{exposure:"hidden"},[xy]:{exposure:"event"},[sl]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[_c]:{exposure:"hidden"},[C2]:{exposure:"event"},[I6]:{exposure:"event",shouldSkipFromEventProperties:t=>dr(t)},$session_past_minimum_duration:{exposure:"event"},$session_recording_url_trigger_activated_session:{exposure:"event"},$session_recording_event_trigger_activated_session:{exposure:"event"},$debug_first_full_snapshot_timestamp:{exposure:"event"},$sess_rec_flush_size:{exposure:"hidden"},[tl]:{exposure:"derived",storageGroup:"flags",shouldSkipFromEventProperties:(t,e)=>e(),transformToEventProperties(t){if(!Nt(t))return{};for(var e={},n=Object.keys(t),r=0;n.length>r;r++)e["$feature/"+n[r]]=t[n[r]];return e}},[Sp]:{exposure:"event",storageGroup:"flags"},[md]:{exposure:"hidden"},[wy]:{exposure:"hidden",storageGroup:"flags"},[Ep]:{exposure:"event",storageGroup:"flags"},[by]:{exposure:"event",storageGroup:"flags",volatile:!0},[lm]:{exposure:"hidden",storageGroup:"flags"},[zi]:{exposure:"event"},[pc]:{exposure:"hidden"},[Ya]:{exposure:"hidden"},[Xa]:{exposure:"hidden"},[Sy]:{exposure:"hidden",storageGroup:"surveys"},[cm]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[Ey]:{exposure:"event"},[Cp]:{exposure:"hidden"},[gd]:{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"},[bd]:{exposure:"hidden"},[Cy]:{exposure:"hidden"},[ky]:{exposure:"hidden"},[$d]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Fs]:{exposure:"hidden"},[Py]:{exposure:"hidden"},[Ty]:{exposure:"hidden"},[Ry]:{exposure:"hidden"},[Ay]:{exposure:"hidden"},[um]:{exposure:"hidden"},[dm]:{exposure:"hidden"},[M6]:{exposure:"event"},[O6]:{exposure:"event"},[L6]:{exposure:"event"},[N6]:{exposure:"event"},[j6]:{exposure:"event"},[F6]:{exposure:"event"},[V6]:{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"}},NN=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],Fa=t=>{var e=LN[t];if(e)return e;for(var n of NN){var r=n[1];if(t.indexOf(n[0])===0)return r}},xc=(t,e)=>{try{return JSON.stringify(t,((n,r)=>typeof r=="bigint"?r.toString():r),e)}catch{return J8(t)}},gm=t=>{var e=Se==null?void 0:Se.createElement("a");return ge(e)?null:(e.href=t,e)},Qc=function(t,e){for(var n,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var i=r[s].split("=");if(i[0]===e){n=i;break}}if(!Qe(n)||2>n.length)return"";var a=n[1];try{a=decodeURIComponent(a)}catch{_e.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},zd=function(t,e,n){if(!t||!e||!e.length)return t;for(var r=t.split("#"),s=r[1],i=(r[0]||"").split("?"),a=i[1],c=i[0],u=(a||"").split("&"),f=[],h=0;u.length>h;h++){var p=u[h].split("=");Qe(p)&&(e.includes(p[0])?f.push(p[0]+"="+n):f.push(u[h]))}var m=c;return a!=null&&(m+="?"+f.join("&")),s!=null&&(m+="#"+s),m},vm=function(t,e){var n=t.match(new RegExp(e+"=([^&]*)"));return n?n[1]:null},sP=(t,e)=>t>=e&&Y8(),iP=(t,e,n,r)=>{if(t===0){if(Y8()){var s=e+1;return s===n&&r(),s}return e}return 0},qh="https?://(.*)",Jc=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],DN=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Jc],Ud="<masked>",jN=["li_fat_id"];function oP(t,e,n){if(!Se)return{};var r,s=e?[...Jc,...n||[]]:[],i=aP(zd(Se.URL,s,Ud),t),a=(r={},wt(jN,(function(c){var u=H6(c);r[c]=u||null})),r);return At(a,i)}function aP(t,e){var n=DN.concat(e||[]),r={};return wt(n,(function(s){var i=Qc(t,s);r[s]=i||null})),r}function lP(t){var e=(function(i){return i?i.search(qh+"google.([^/?]*)")===0?"google":i.search(qh+"bing.com")===0?"bing":i.search(qh+"yahoo.com")===0?"yahoo":i.search(qh+"duckduckgo.com")===0?"duckduckgo":null:null})(t),n=e!="yahoo"?"q":"p",r={};if(!dr(e)){r.$search_engine=e;var s=Se?Qc(Se.referrer,n):"";s.length&&(r.ph_keyword=s)}return r}function $E(){return navigator.language||navigator.userLanguage}var ym="$direct";function cP(){return(Se==null?void 0:Se.referrer)||ym}function uP(t,e,n){n===void 0&&(n=!1);var r=t?[...Jc,...e||[]]:[],s=n?sa(rn==null?void 0:rn.href):rn==null?void 0:rn.href,i=s==null?void 0:s.substring(0,1e3);return{r:cP().substring(0,1e3),u:i?zd(i,r,Ud):void 0}}function dP(t,e){var n;e===void 0&&(e=!1);var r=t.r,s=t.u,i=e?sa(s):s,a={$referrer:r,$referring_domain:r==null?void 0:r==ym?ym:(n=gm(r))==null?void 0:n.host};if(i){a.$current_url=i;var c=gm(i);a.$host=c==null?void 0:c.host,a.$pathname=c==null?void 0:c.pathname;var u=aP(i);At(a,u)}if(r){var f=lP(r);At(a,f)}return a}function fP(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function FN(){try{return new Date().getTimezoneOffset()}catch{return}}var VN={flags:$d,surveys:cm},$N=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],ic="main";class Pv{constructor(e,n,r){if(r===void 0&&(r=!0),this.lr={},this.ur=!1,this.hr=!1,this.Te=e,this.dr=r,this.props={},this.cr=!1,this.vr=(i=>{var a="";return i.token&&(a=i.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),i.persistence_name?"ph_"+i.persistence_name:"ph_"+a+"_posthog"})(e),this.Jt=this.pr(e),this.hr=this.gr(e),this.load(),e.debug&&_e.info("Persistence loaded",e.persistence,ue({},this.props)),this.update_config(e,e,n),this.save(),te){var s=()=>this.flush();zt(te,"beforeunload",s,{capture:!1}),zt(te,"pagehide",s,{capture:!1})}}mr(){var e,n=(e=this.Te)==null?void 0:e.persistence_save_debounce_ms;return $n(n)&&n>0?n:0}isDisabled(){return!!this.yr}pr(e){$N.indexOf(e.persistence.toLowerCase())===-1&&(_e.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var n,r=(function(a,c){a===void 0&&(a=[]),c===void 0&&(c=!1);var u=[...vN,...a];return ue({},St,{F(f){try{var h={};try{h=Qi.F(f)||{}}catch{}var p,m=JSON.parse(St.A(f)||"{}");if(c){var _={};for(var x in h){var y=h[x];dr(y)||y===""||(_[x]=y)}p=At(m,_)}else p=At(h,m);return St.q(f,p),p}catch{}return null},q(f,h,p,m,_,x){var y=St.q(f,h,void 0,void 0,x);try{var w={};u.forEach((S=>{h[S]&&(w[S]=h[S])})),Object.keys(w).length&&Qi.q(f,w,p,m,_,x)}catch(S){St.D(S)}return y},P(f,h){try{te==null||te.localStorage.removeItem(f),Qi.P(f,h)}catch(p){St.D(p)}}})})(e.cookie_persisted_properties||[],e.__preview_cookie_wins_on_conflict||!1),s=!1,i=e.persistence.toLowerCase();return i==="localstorage"&&St.N()?(n=St,s=!0):i==="localstorage+cookie"&&r.N()?(n=r,s=!0):i==="sessionstorage"&&jn.N()?n=jn:i==="memory"?n=yN:i==="cookie"?n=Qi:r.N()?(n=r,s=!0):n=Qi,this.ur=s,n}br(e){return this.vr+"__"+e}gr(e){return this.ur&&!!e.split_storage}_r(e){var n=e??this.Te.feature_flag_cache_ttl_ms;if(!n||0>=n)return!1;var r=this.props[$d];return!r||typeof r!="number"||Date.now()-r>n}properties(){var e={};return wt(this.props,((n,r)=>{var s=Fa(r);if((s==null?void 0:s.exposure)==="derived"){if(s.shouldSkipFromEventProperties!=null&&s.shouldSkipFromEventProperties(n,r===tl?()=>this._r():()=>!1))return;s.transformToEventProperties&&At(e,s.transformToEventProperties(n))}else if(!s||s.exposure==="event"){if(s!=null&&s.shouldSkipFromEventProperties!=null&&s.shouldSkipFromEventProperties(n,(()=>!1)))return;e[r]=n}})),e}load(){if(!this.yr){var e=this.Jt.F(this.vr);e&&(this.props=At({},e)),this.hr&&this.wr()}}wr(){for(var e of kv){var n=St.F(this.br(e));if(n&&!Zo(n)){var r=this.kr(e);r.persisted=!0,this.Sr(e)||(r.fingerprint=this.Cr(n,e)),this.Mr(e,n)||At(this.props,n)}}}Sr(e){return Object.keys(this.props).some((n=>{var r;return((r=Fa(n))==null?void 0:r.storageGroup)===e}))}Mr(e,n){var r=VN[e];if(!r)return!1;var s=n[r],i=this.props[r];return $n(s)&&$n(i)&&i>s}refreshKey(e){var n;if(!this.yr){var r=this.hr?(n=Fa(e))==null?void 0:n.storageGroup:void 0,s=r?St.F(this.br(r)):this.Jt.F(this.vr);if(s&&e in s)this.Ir(e,s[e]);else{if(r){var i=this.Jt.F(this.vr);if(i&&e in i)return void this.Ir(e,i[e])}this.Tr(e)}}}save(){if(!this.yr){var e=this.mr();e>0?ge(this.Er)&&(this.Er=setTimeout((()=>{this.Er=void 0,this.Rr()}),e)):this.Rr()}}flush(){ge(this.Er)||(clearTimeout(this.Er),this.Er=void 0,this.Rr())}Rr(){this.yr||(this.hr?this.Pr():this.Or(this.Jt,this.vr,this.props,ic))}Pr(){var e=this.Fr(),n=e.main,r=e.groups;for(var s of(this.Or(this.Jt,this.vr,n,ic),kv)){var i,a=r[s];(!Zo(a)||(i=this.lr[s])!=null&&i.persisted)&&this.Or(St,this.br(s),a,s)}}Fr(){var e={},n={flags:{},surveys:{}};return wt(this.props,((r,s)=>{var i,a=(i=Fa(s))==null?void 0:i.storageGroup;a?n[a][s]=r:e[s]=r})),{main:e,groups:n}}Cr(e,n){if(n===ic)return JSON.stringify(e)+"|"+this.Ar+"|"+this.Lr+"|"+this.$r;var r={};return wt(e,((s,i)=>{var a;r[i]=(a=Fa(i))!=null&&a.volatile?"__volatile__":s})),JSON.stringify(r)}Or(e,n,r,s){var i=this.kr(s);if(s===ic||i.dirty||ge(i.fingerprint)){var a;try{if((a=this.Cr(r,s))===i.fingerprint)return void(i.dirty=!1)}catch{a=void 0}e.q(n,r,this.Ar,this.Lr,this.$r,this.Te.debug)?(i.dirty=!1,s!==ic&&(i.persisted=!0),ge(a)||(i.fingerprint=a)):this.Te.debug&&_e.warn('failed to persist storage entry "'+n+'"; will retry on next save')}}remove(e){var n=(e===void 0?{}:e).keepGroupEntries,r=n!==void 0&&n;if(ge(this.Er)||(clearTimeout(this.Er),this.Er=void 0),this.Jt.P(this.vr,!1),this.Jt.P(this.vr,!0),!r&&this.dr)for(var s of kv)St.P(this.br(s));r?delete this.lr[ic]:this.lr={}}clear(){this.remove(),this.props={}}register_once(e,n,r){if(Nt(e)){ge(n)&&(n="None"),this.Ar=ge(r)?this.Nr:r;var s=!1;if(wt(e,((i,a)=>{this.props.hasOwnProperty(a)&&this.props[a]!==n||(this.Ir(a,i),s=!0)})),s)return this.save(),!0}return!1}register(e,n){if(Nt(e)){this.Ar=ge(n)?this.Nr:n;var r=!1;if(wt(e,((s,i)=>{e.hasOwnProperty(i)&&this.props[i]!==s&&(this.Ir(i,s),r=!0)})),r)return this.save(),!0}return!1}unregister(e){e in this.props&&(this.Tr(e),this.save())}update_campaign_params(){if(!this.cr){var e=oP(this.Te.custom_campaign_params,this.Te.mask_personal_data_properties,this.Te.custom_personal_data_properties);Zo(P2(e))||this.register(e),this.cr=!0}}update_search_keyword(){var e;this.register((e=Se==null?void 0:Se.referrer)?lP(e):{})}update_referrer_info(){var e;this.register_once({$referrer:cP(),$referring_domain:Se!=null&&Se.referrer&&((e=gm(Se.referrer))==null?void 0:e.host)||ym},void 0)}set_initial_person_info(){this.props[Ry]||this.props[Ay]||this.register_once({[um]:uP(this.Te.mask_personal_data_properties,this.Te.custom_personal_data_properties,this.Te.disable_capture_url_hashes)},void 0)}get_initial_props(){var e={};wt([Ay,Ry],(s=>{var i=this.props[s];i&&wt(i,(function(a,c){e["$initial_"+ay(c)]=a}))}));var n=this.props[um];if(n){var r=(function(s,i){i===void 0&&(i=!1);var a=dP(s,i),c={};return wt(a,(function(u,f){c["$initial_"+ay(f)]=u})),c})(n,this.Te.disable_capture_url_hashes);At(e,r)}return e}safe_merge(e){return wt(this.props,(function(n,r){r in e||(e[r]=n)})),e}update_config(e,n,r){this.Nr=this.Ar=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!r),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie);var s=e.persistence!==n.persistence||!((u,f)=>{if(u.length!==f.length)return!1;var h=[...u].sort(),p=[...f].sort();return h.every(((m,_)=>m===p[_]))})(e.cookie_persisted_properties||[],n.cookie_persisted_properties||[]),i=s?this.pr(e):this.Jt,a=this.gr(e);if(s||a!==this.hr){var c=this.props;this.clear(),this.Jt=i,this.hr=a,this.props=c,this.save()}}set_disabled(e){this.yr=e,this.yr?this.remove():this.save()}set_cross_subdomain(e){e!==this.Lr&&(this.Lr=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this.$r&&(this.$r=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,n){var r=this.props[pd]||{};r[e]=n,this.Ir(pd,r),this.save()}remove_event_timer(e){var n=this.props[pd]||{},r=n[e];return ge(r)||(delete n[e],this.Ir(pd,n),this.save()),r}get_property(e){return this.props[e]}set_property(e,n){this.Ir(e,n),this.save()}Ir(e,n){var r;this.props[e]=n,(r=Fa(e))!=null&&r.volatile||this.Dr(e)}Tr(e){delete this.props[e],this.Dr(e)}Dr(e){var n,r=(n=Fa(e))==null?void 0:n.storageGroup;r&&(this.kr(r).dirty=!0)}kr(e){return this.lr[e]||(this.lr[e]={})}}var or={GZipJS:"gzip-js",Base64:"base64"},Qu={Activation:"events",Cancellation:"cancelEvents"},Tv={Popover:"popover",API:"api",Widget:"widget"},Ji={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},Rv={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},Ly={Popover:"popover",Inline:"inline"},HN={SHOWN:"product tour shown"},HE={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},zE=Vt("[RateLimiter]");class zN{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=n=>{var r=n.text;if(r&&r.length)try{(JSON.parse(r).quota_limited||[]).forEach((s=>{zE.info((s||"events")+" is quota limited."),this.serverLimits[s]=new Date().getTime()+6e4}))}catch(s){return void zE.warn('could not rate limit - continuing. Error: "'+(s==null?void 0:s.message)+'"',{text:r})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var n,r,s;e===void 0&&(e=!1);var i=this.captureEventsBurstLimit,a=this.captureEventsPerSecond,c=new Date().getTime(),u=(n=(r=this.instance.persistence)==null?void 0:r.get_property(Ty))!==null&&n!==void 0?n:{tokens:i,last:c};u.tokens+=(c-u.last)/1e3*a,u.last=c,u.tokens>i&&(u.tokens=i);var f=1>u.tokens;return f||e||(u.tokens=Math.max(0,u.tokens-1)),!f||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+a+" events per second and "+i+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=f,(s=this.instance.persistence)==null||s.set_property(Ty,u),{isRateLimited:f,remainingTokens:u.tokens}}isServerRateLimited(e){var n=this.serverLimits[e||"events"]||!1;return n!==!1&&new Date().getTime()<n}}var Ju=Vt("[RemoteConfig]");class hP{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=$e._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}qr(e){var n,r;(n=$e.__PosthogExtensions__)!=null&&n.loadExternalDependency?(r=$e.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):e()}jr(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback(n){e(n.json)}})}load(){try{if(this.remoteConfig)return Ju.info("Using preloaded remote config",this.remoteConfig),this.Hr(this.remoteConfig),void this.Br();if(this._instance.Ur())return void Ju.warn("Remote config is disabled. Falling back to local config.");this.qr((e=>{if(!e)return Ju.info("No config found after loading remote JS config. Falling back to JSON."),void this.jr((n=>{this.Hr(n),this.Br()}));this.Hr(e),this.Br()}))}catch(e){Ju.error("Error loading remote config",e)}}stop(){this.zr&&(clearInterval(this.zr),this.zr=void 0)}refresh(){!this._instance.Ur()&&Se&&Se.visibilityState!=="hidden"&&this._instance.reloadFeatureFlags()}Br(){var e;if(!this.zr){var n=(e=this._instance.config.remote_config_refresh_interval_ms)!==null&&e!==void 0?e:3e5;n!==0&&(this.zr=setInterval((()=>{this.refresh()}),n))}}Hr(e){var n;e||Ju.error("Failed to fetch remote config from PostHog."),this._instance.Hr(e?{ok:!0,config:e}:{ok:!1}),(e==null?void 0:e.hasFeatureFlags)!==!1&&(this._instance.config.advanced_disable_feature_flags_on_first_load||(n=this._instance.featureFlags)==null||n.ensureFlagsLoaded())}}var bs=Uint8Array,Pr=Uint16Array,eu=Uint32Array,I2=new bs([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]),M2=new bs([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]),UE=new bs([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),pP=function(t,e){for(var n=new Pr(31),r=0;31>r;++r)n[r]=e+=1<<t[r-1];var s=new eu(n[30]);for(r=1;30>r;++r)for(var i=n[r];n[r+1]>i;++i)s[i]=i-n[r]<<5|r;return[n,s]},mP=pP(I2,2),Ny=mP[1];mP[0][28]=258,Ny[258]=28;for(var BE=pP(M2,0)[1],gP=new Pr(32768),jt=0;32768>jt;++jt){var oc=(43690&jt)>>>1|(21845&jt)<<1;gP[jt]=((65280&(oc=(61680&(oc=(52428&oc)>>>2|(13107&oc)<<2))>>>4|(3855&oc)<<4))>>>8|(255&oc)<<8)>>>1}var Ed=function(t,e,n){for(var r=t.length,s=0,i=new Pr(e);r>s;++s)++i[t[s]-1];var a,c=new Pr(e);for(s=0;e>s;++s)c[s]=c[s-1]+i[s-1]<<1;for(a=new Pr(r),s=0;r>s;++s)a[s]=gP[c[t[s]-1]++]>>>15-t[s];return a},Cl=new bs(288);for(jt=0;144>jt;++jt)Cl[jt]=8;for(jt=144;256>jt;++jt)Cl[jt]=9;for(jt=256;280>jt;++jt)Cl[jt]=7;for(jt=280;288>jt;++jt)Cl[jt]=8;var _m=new bs(32);for(jt=0;32>jt;++jt)_m[jt]=5;var UN=Ed(Cl,9),BN=Ed(_m,5),vP=function(t){return(t/8>>0)+(7&t&&1)},yP=function(t,e,n){(n==null||n>t.length)&&(n=t.length);var r=new(t instanceof Pr?Pr:t instanceof eu?eu:bs)(n-e);return r.set(t.subarray(e,n)),r},Oi=function(t,e,n){var r=e/8>>0;t[r]|=n<<=7&e,t[r+1]|=n>>>8},ed=function(t,e,n){var r=e/8>>0;t[r]|=n<<=7&e,t[r+1]|=n>>>8,t[r+2]|=n>>>16},Av=function(t,e){for(var n=[],r=0;t.length>r;++r)t[r]&&n.push({s:r,f:t[r]});var s=n.length,i=n.slice();if(!s)return[new bs(0),0];if(s==1){var a=new bs(n[0].s+1);return a[n[0].s]=1,[a,1]}n.sort((function(R,L){return R.f-L.f})),n.push({s:-1,f:25001});var c=n[0],u=n[1],f=0,h=1,p=2;for(n[0]={s:-1,f:c.f+u.f,l:c,r:u};h!=s-1;)c=n[n[p].f>n[f].f?f++:p++],u=n[f!=h&&n[p].f>n[f].f?f++:p++],n[h++]={s:-1,f:c.f+u.f,l:c,r:u};var m=i[0].s;for(r=1;s>r;++r)i[r].s>m&&(m=i[r].s);var _=new Pr(m+1),x=Dy(n[h-1],_,0);if(x>e){r=0;var y=0,w=x-e,S=1<<w;for(i.sort((function(R,L){return _[L.s]-_[R.s]||R.f-L.f}));s>r;++r){var T=i[r].s;if(e>=_[T])break;y+=S-(1<<x-_[T]),_[T]=e}for(y>>>=w;y>0;){var P=i[r].s;e>_[P]?y-=1<<e-_[P]++-1:++r}for(;r>=0&&y;--r){var k=i[r].s;_[k]==e&&(--_[k],++y)}x=e}return[new bs(_),x]},Dy=function(t,e,n){return t.s==-1?Math.max(Dy(t.l,e,n+1),Dy(t.r,e,n+1)):e[t.s]=n},WE=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new Pr(++e),r=0,s=t[0],i=1,a=function(u){n[r++]=u},c=1;e>=c;++c)if(t[c]==s&&c!=e)++i;else{if(!s&&i>2){for(;i>138;i-=138)a(32754);i>2&&(a(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(a(s),--i;i>6;i-=6)a(8304);i>2&&(a(i-3<<5|8208),i=0)}for(;i--;)a(s);i=1,s=t[c]}return[n.subarray(0,r),e]},td=function(t,e){for(var n=0,r=0;e.length>r;++r)n+=t[r]*e[r];return n},jy=function(t,e,n){var r=n.length,s=vP(e+2);t[s]=255&r,t[s+1]=r>>>8,t[s+2]=255^t[s],t[s+3]=255^t[s+1];for(var i=0;r>i;++i)t[s+i+4]=n[i];return 8*(s+4+r)},GE=function(t,e,n,r,s,i,a,c,u,f,h){Oi(e,h++,n),++s[256];for(var p=Av(s,15),m=p[0],_=p[1],x=Av(i,15),y=x[0],w=x[1],S=WE(m),T=S[0],P=S[1],k=WE(y),R=k[0],L=k[1],O=new Pr(19),A=0;T.length>A;++A)O[31&T[A]]++;for(A=0;R.length>A;++A)O[31&R[A]]++;for(var I=Av(O,7),N=I[0],j=I[1],F=19;F>4&&!N[UE[F-1]];--F);var K,X,W,G,q=f+5<<3,$=td(s,Cl)+td(i,_m)+a,ne=td(s,m)+td(i,y)+a+14+3*F+td(O,N)+(2*O[16]+3*O[17]+7*O[18]);if($>=q&&ne>=q)return jy(e,h,t.subarray(u,u+f));if(Oi(e,h,1+($>ne)),h+=2,$>ne){K=Ed(m,_),X=m,W=Ed(y,w),G=y;var H=Ed(N,j);for(Oi(e,h,P-257),Oi(e,h+5,L-1),Oi(e,h+10,F-4),h+=14,A=0;F>A;++A)Oi(e,h+3*A,N[UE[A]]);h+=3*F;for(var D=[T,R],Y=0;2>Y;++Y){var ee=D[Y];for(A=0;ee.length>A;++A)Oi(e,h,H[ie=31&ee[A]]),h+=N[ie],ie>15&&(Oi(e,h,ee[A]>>>5&127),h+=ee[A]>>>12)}}else K=UN,X=Cl,W=BN,G=_m;for(A=0;c>A;++A)if(r[A]>255){var ie;ed(e,h,K[257+(ie=r[A]>>>18&31)]),h+=X[ie+257],ie>7&&(Oi(e,h,r[A]>>>23&31),h+=I2[ie]);var oe=31&r[A];ed(e,h,W[oe]),h+=G[oe],oe>3&&(ed(e,h,r[A]>>>5&8191),h+=M2[oe])}else ed(e,h,K[r[A]]),h+=X[r[A]];return ed(e,h,K[256]),h+X[256]},WN=new eu([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),GN=(function(){for(var t=new eu(256),e=0;256>e;++e){for(var n=e,r=9;--r;)n=(1&n&&3988292384)^n>>>1;t[e]=n}return t})(),Iv=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8};function KN(t,e){e===void 0&&(e={});var n=(function(){var p=4294967295;return{p(m){for(var _=p,x=0;m.length>x;++x)_=GN[255&_^m[x]]^_>>>8;p=_},d(){return 4294967295^p}}})(),r=t.length;n.p(t);var s,i,a,c,u,f=(c=10+((s=e).filename&&s.filename.length+1||0),u=8,(function(p,m,_,x,y,w){var S=p.length,T=new bs(x+S+5*(1+Math.floor(S/7e3))+y),P=T.subarray(x,T.length-y),k=0;if(!m||8>S)for(var R=0;S>=R;R+=65535){var L=R+65535;S>L?k=jy(P,k,p.subarray(R,L)):(P[R]=!0,k=jy(P,k,p.subarray(R,S)))}else{for(var O=WN[m-1],A=O>>>13,I=8191&O,N=(1<<_)-1,j=new Pr(32768),F=new Pr(N+1),K=Math.ceil(_/3),X=2*K,W=function(It){return(p[It]^p[It+1]<<K^p[It+2]<<X)&N},G=new eu(25e3),q=new Pr(288),$=new Pr(32),ne=0,H=0,D=(R=0,0),Y=0,ee=0;S>R;++R){var ie=W(R),oe=32767&R,ce=F[ie];if(j[oe]=ce,F[ie]=oe,R>=Y){var xe=S-R;if((ne>7e3||D>24576)&&xe>423){k=GE(p,P,0,G,q,$,H,D,ee,R-ee,k),D=ne=H=0,ee=R;for(var ae=0;286>ae;++ae)q[ae]=0;for(ae=0;30>ae;++ae)$[ae]=0}var se=2,Ve=0,De=I,Re=oe-ce&32767;if(xe>2&&ie==W(R-Re))for(var Ye=Math.min(A,xe)-1,dt=Math.min(32767,R),Pt=Math.min(258,xe);dt>=Re&&--De&&oe!=ce;){if(p[R+se]==p[R+se-Re]){for(var we=0;Pt>we&&p[R+we]==p[R+we-Re];++we);if(we>se){if(se=we,Ve=Re,we>Ye)break;var je=Math.min(Re,we-2),ze=0;for(ae=0;je>ae;++ae){var it=R-Re+ae+32768&32767,Tt=it-j[it]+32768&32767;Tt>ze&&(ze=Tt,ce=it)}}}Re+=(oe=ce)-(ce=j[oe])+32768&32767}if(Ve){G[D++]=268435456|Ny[se]<<18|BE[Ve];var tt=31&Ny[se],Xe=31&BE[Ve];H+=I2[tt]+M2[Xe],++q[257+tt],++$[Xe],Y=R+se,++ne}else G[D++]=p[R],++q[p[R]]}}k=GE(p,P,!0,G,q,$,H,D,ee,R-ee,k)}return yP(T,0,x+vP(k)+y)})(i=t,(a=e).level==null?6:a.level,a.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(i.length)))):12+a.mem,c,u)),h=f.length;return(function(p,m){var _=m.filename;if(p[0]=31,p[1]=139,p[2]=8,p[8]=2>m.level?4:m.level==9?2:0,p[9]=3,m.mtime!=0&&Iv(p,4,Math.floor(new Date(m.mtime||Date.now())/1e3)),_){p[3]=8;for(var x=0;_.length>=x;++x)p[x+10]=_.charCodeAt(x)}})(f,e),Iv(f,h-8,n.d()),Iv(f,h-4,r),f}var ZN=!!sy||!!v2,_P="text/plain",Pp=!1,xP=(t,e)=>{var n=t.split("#"),r=n[1],s=n[0].split("?"),i=s[0],a=s[1];if(!a)return t;var c=a.split("&").filter((u=>u.split("=")[0]!==e)).join("&");return i+(c?"?"+c:"")+(r?"#"+r:"")},O2=function(t,e,n){var r;n===void 0&&(n=!0);var s=t.split("?"),i=s[0],a=s[1],c=ue({},e),u=(r=a==null?void 0:a.split("&").map((h=>{var p,m=h.split("="),_=m[0],x=n&&(p=c[_])!==null&&p!==void 0?p:m[1];return delete c[_],_+"="+x})))!==null&&r!==void 0?r:[],f=(function(h,p){var m,_;p===void 0&&(p="&");var x=[];return wt(h,(function(y,w){ge(y)||ge(w)||w==="undefined"||(m=encodeURIComponent((S=>S instanceof File)(y)?y.name:y.toString()),_=encodeURIComponent(w),x[x.length]=_+"="+m)})),x.join(p)})(c);return f&&u.push(f),u.length>0?i+"?"+u.join("&"):i},Mv=t=>{if(t.Vr)return t.Vr;var e=t.data,n=t.compression;if(e){if(n===or.GZipJS){var r=KN((function(c,u){var f=c.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(c);for(var h=new bs(c.length+(c.length>>>1)),p=0,m=function(w){h[p++]=w},_=0;f>_;++_){if(p+5>h.length){var x=new bs(p+8+(f-_<<1));x.set(h),h=x}var y=c.charCodeAt(_);128>y?m(y):2048>y?(m(192|y>>>6),m(128|63&y)):y>55295&&57344>y?(m(240|(y=65536+(1047552&y)|1023&c.charCodeAt(++_))>>>18),m(128|y>>>12&63),m(128|y>>>6&63),m(128|63&y)):(m(224|y>>>12),m(128|y>>>6&63),m(128|63&y))}return yP(h,0,p)})(xc(e)),{mtime:0});return{contentType:_P,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(n===or.Base64){var s=(function(c){return c&&btoa(encodeURIComponent(c).replace(/%([0-9A-F]{2})/g,((u,f)=>String.fromCharCode(parseInt(f,16)))))})(xc(e)),i=(c=>"data="+encodeURIComponent(typeof c=="string"?c:xc(c)))(s);return{contentType:"application/x-www-form-urlencoded",body:i,estimatedSize:new Blob([i]).size}}var a=xc(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},wP=t=>{var e,n,r=()=>t.transport==="sendBeacon"?{url:O2(t.url,{compression:or.Base64}),encodedBody:Mv(ue({},t,{compression:or.Base64,Vr:void 0}))}:{url:xP(t.url,"compression"),encodedBody:Mv(ue({},t,{compression:void 0,Vr:void 0}))};try{e=Mv(t)}catch(s){if(vE(t.compression,Qc(t.url,"compression")))return _e.error("Failed to gzip request body, sending uncompressed payload",s),r();throw s}return e&&vE(t.compression,Qc(t.url,"compression"))&&!((n=e.body)instanceof ArrayBuffer?iy(new Uint8Array(n)):ArrayBuffer.isView(n)&&iy(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)))?(Pp=!0,r()):{url:t.url,encodedBody:e}},bP=t=>{try{return wP(t)}catch(e){return _e.error(e),void(t.callback==null||t.callback({statusCode:0,error:e}))}},qN=(function(){var t=en((function*(e){var n=xc(e.data),r=yield(function(i,a,c){return oy.apply(this,arguments)})(n,gt.DEBUG,{rethrow:!0});if(!r)return e;var s=yield r.arrayBuffer();return ue({},e,{Vr:{contentType:_P,body:s,estimatedSize:s.byteLength}})}));return function(e){return t.apply(this,arguments)}})(),YN=/Failed to fetch|NetworkError|Load failed/i,SP=t=>{var e=bP(t);if(e){var n=e.url,r=e.encodedBody,s=r??{},i=s.contentType,a=s.body,c=s.estimatedSize,u=new Headers;wt(t.headers,(function(x,y){u.append(y,x)})),i&&u.append("Content-Type",i);var f=null,h=!1;if(dE){var p=new dE;f={signal:p.signal,timeout:setTimeout((()=>{var x,y;h=!0,p.abort((x=t.timeout,(y=new Error("PostHog request timed out"+(x?" after "+x+"ms":""))).name="AbortError",y))}),t.timeout)}}var m=x=>{h&&(x==null?void 0:x.name)==="AbortError"||(y=>(y==null?void 0:y.name)==="TypeError"&&YN.test((y==null?void 0:y.message)||""))(x)?_e.warn(x):_e.error(x),t.callback==null||t.callback({statusCode:0,error:x})};try{var _;v2(n,ue({method:(t==null?void 0:t.method)||"GET",headers:u,keepalive:t.method==="POST"&&!t.Wr&&52428.8>(c||0),body:a,signal:(_=f)==null?void 0:_.signal},t.fetchOptions)).then((x=>x.text().then((y=>{var w={statusCode:x.status,text:y};if(x.status===200)try{w.json=JSON.parse(y)}catch(S){_e.error(S)}t.callback==null||t.callback(w)})))).catch(m).finally((()=>f?clearTimeout(f.timeout):null))}catch(x){f&&clearTimeout(f.timeout),m(x)}}},Fy=t=>{try{var e,n=wP(t),r=n.url,s=n.encodedBody,i=s??{},a=i.body,c=i.estimatedSize;if(!a)return;var u=a instanceof Blob?a:new Blob([a],{type:i.contentType});if(ar.sendBeacon(r,u))return;var f=Qe(t.data)?t.data:(e=t.data)==null?void 0:e.batch;if(Qe(f)&&f.length>1&&(c??0)>16384){var h=Math.ceil(f.length/2),p=m=>Qe(t.data)?m:ue({},t.data,{batch:m});return Fy(ue({},t,{data:p(f.slice(0,h))})),void Fy(ue({},t,{data:p(f.slice(h))}))}_e.warn("Beacon of ~"+(c??0)+" bytes was rejected by the browser, falling back to fetch"),SP(ue({},t,{Wr:!0}))}catch(m){_e.warn("Beacon send failed",m)}},KE=(t,e,n,r)=>{var s=r==="query"?e==="POST"?"sent_at":"_":void 0;return O2(n===or.GZipJS?xP(t,"compression"):t,ue({},s?{[s]:Date.now().toString()}:{},n===or.GZipJS?{}:{compression:n}))},Tp=[];v2&&Tp.push({transport:"fetch",method:SP}),sy&&Tp.push({transport:"XHR",method(t){var e=bP(t);if(e){var n=new sy,r=e.encodedBody;n.open(t.method||"GET",e.url,!0);var s=r??{},i=s.contentType,a=s.body;wt(t.headers,(function(c,u){n.setRequestHeader(u,c)})),i&&n.setRequestHeader("Content-Type",i),t.timeout&&(n.timeout=t.timeout),n.onreadystatechange=()=>{if(n.readyState===4){var c={statusCode:n.status,text:n.responseText};if(n.status===200)try{c.json=JSON.parse(n.responseText)}catch{}t.callback==null||t.callback(c)}},n.send(a)}}}),ar!=null&&ar.sendBeacon&&Tp.push({transport:"sendBeacon",method:Fy});var Vy=3e3;class XN{constructor(e,n){this.Zr=!0,this.Gr=[],this.Qr=hi((n==null?void 0:n.flush_interval_ms)||Vy,250,5e3,_e.createLogger("flush interval"),Vy),this.Jr=e}enqueue(e){this.Gr.push(e),this.Kr||this.Yr()}unload(){this.Xr();var e=this.Gr.length>0?this.ei():{},n=Object.values(e);[...n.filter((r=>r.url.indexOf("/e")===0)),...n.filter((r=>r.url.indexOf("/e")!==0))].map((r=>{this.ti(ue({},r,{transport:"sendBeacon"}))}))}enable(){this.Zr=!1,this.Yr()}Yr(){var e=this;this.Zr||(this.Kr=setTimeout((()=>{if(this.Xr(),this.Gr.length>0){var n=this.ei(),r=function(){var i=n[s],a=new Date().getTime();i.data&&Qe(i.data)&&wt(i.data,(c=>{c.offset=Math.abs(c.timestamp-a),delete c.timestamp})),e.ti(i)};for(var s in n)r()}}),this.Qr))}ti(e){try{this.Jr(e)}catch(n){_e.error(n)}}Xr(){clearTimeout(this.Kr),this.Kr=void 0}ei(){var e={};return wt(this.Gr,(n=>{var r,s=n,i=(s?s.batchKey:null)||s.url;ge(e[i])&&(e[i]=ue({},s,{data:[]})),(r=e[i].data)==null||r.push(s.data)})),this.Gr=[],e}}var QN=["retriesPerformedSoFar"];class JN{constructor(e){this.ri=!1,this.ii=3e3,this.Gr=[],this._instance=e,this.Gr=[],this.ni=!0,!ge(te)&&"onLine"in te.navigator&&(this.ni=te.navigator.onLine,this.si=()=>{this.ni=!0,this.oi()},this.ai=()=>{this.ni=!1},zt(te,"online",this.si),zt(te,"offline",this.ai))}get length(){return this.Gr.length}retriableRequest(e){var n=e.retriesPerformedSoFar,r=X8(e,QN);Hi(n)&&(r.url=O2(r.url,{retry_count:n})),this._instance._send_request(ue({},r,{callback:s=>{if(s.statusCode!==200&&(400>s.statusCode||s.statusCode>=500)){if((s.statusCode===0?3:10)>(n??0))return void this.kt(ue({retriesPerformedSoFar:n},r));s.statusCode===0&&_e.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.")}r.callback==null||r.callback(s)}}))}kt(e){var n=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=n+1;var r=(function(a){var c=3e3*Math.pow(2,a),u=c/2,f=Math.min(18e5,c),h=Math.random()-.5;return Math.ceil(f+h*(f-u))})(n),s=Date.now()+r;this.Gr.push({retryAt:s,requestOptions:e});var i="Enqueued failed request for retry in "+r;navigator.onLine||(i+=" (Browser is offline)"),_e.warn(i),this.ri||(this.ri=!0,this.li())}li(){if(this.ui&&clearTimeout(this.ui),this.Gr.length===0)return this.ri=!1,void(this.ui=void 0);this.ui=setTimeout((()=>{this.ni&&this.Gr.length>0&&this.oi(),this.li()}),this.ii)}oi(){var e=Date.now(),n=[],r=this.Gr.filter((i=>e>i.retryAt||(n.push(i),!1)));if(this.Gr=n,r.length>0)for(var s of r)this.retriableRequest(s.requestOptions)}unload(){for(var e of(this.ui&&(clearTimeout(this.ui),this.ui=void 0),this.ri=!1,ge(te)||(this.si&&(te.removeEventListener("online",this.si),this.si=void 0),this.ai&&(te.removeEventListener("offline",this.ai),this.ai=void 0)),this.Gr)){var n=e.requestOptions;try{this._instance._send_request(ue({},n,{transport:"sendBeacon"}))}catch(r){_e.error(r)}}this.Gr=[]}}class eD{constructor(e){this.hi=()=>{var n,r,s,i;this.di||(this.di={});var a=this.scrollElement(),c=this.scrollY(),u=a?Math.max(0,a.scrollHeight-a.clientHeight):0,f=c+((a==null?void 0:a.clientHeight)||0),h=(a==null?void 0:a.scrollHeight)||0;this.di.lastScrollY=Math.ceil(c),this.di.maxScrollY=Math.max(c,(n=this.di.maxScrollY)!==null&&n!==void 0?n:0),this.di.maxScrollHeight=Math.max(u,(r=this.di.maxScrollHeight)!==null&&r!==void 0?r:0),this.di.lastContentY=f,this.di.maxContentY=Math.max(f,(s=this.di.maxContentY)!==null&&s!==void 0?s:0),this.di.maxContentHeight=Math.max(h,(i=this.di.maxContentHeight)!==null&&i!==void 0?i:0)},this._instance=e}get ci(){return this._instance.config.scroll_root_selector}getContext(){return this.di}resetContext(){var e=this.di;return setTimeout(this.hi,0),e}startMeasuringScrollPosition(){zt(te,"scroll",this.hi,{capture:!0}),zt(te,"scrollend",this.hi,{capture:!0}),zt(te,"resize",this.hi)}scrollElement(){if(!this.ci)return te==null?void 0:te.document.documentElement;var e=Qe(this.ci)?this.ci:[this.ci];for(var n of e){var r=te==null?void 0:te.document.querySelector(n);if(r)return r}}vi(e){var n=e==="y"?"scrollTop":"scrollLeft";if(this.ci){var r=this.scrollElement();return r&&r[n]||0}return te?e==="y"?te.scrollY||te.pageYOffset||te.document.documentElement.scrollTop||0:te.scrollX||te.pageXOffset||te.document.documentElement.scrollLeft||0:0}scrollY(){return this.vi("y")}scrollX(){return this.vi("x")}}var tD=t=>uP(t==null?void 0:t.config.mask_personal_data_properties,t==null?void 0:t.config.custom_personal_data_properties,t==null?void 0:t.config.disable_capture_url_hashes);class ZE{constructor(e,n,r,s){this.fi=i=>{var a=this.pi();if(!a||a.sessionId!==i){var c={sessionId:i,props:this.gi(this._instance)};this.mi.register({[Py]:c})}},this._instance=e,this.yi=n,this.mi=r,this.gi=s||tD,this.yi.onSessionId(this.fi)}pi(){return this.mi.props[Py]}getSetOnceProps(){var e,n=(e=this.pi())==null?void 0:e.props;return n?"r"in n?dP(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 e={};return wt(P2(this.getSetOnceProps()),((n,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+ay(r)]=n})),e}}class L2{on(e,n){return this.bi[e]||(this.bi[e]=[]),this.bi[e].push(n),()=>{this.bi[e]=this.bi[e].filter((r=>r!==n))}}emit(e,n){for(var r of this.bi[e]||[])r(n);for(var s of this.bi["*"]||[])s(e,n)}constructor(){this.bi={}}}var nd=Vt("[SessionId]");class qE{on(e,n){return this.wi.on(e,n)}constructor(e,n,r){var s;if(this.xi=null,this.ki=[],this.Si=void 0,this.Ci=!1,this.wi=new L2,this.Mi=(f,h)=>!(!Hi(f)||!Hi(h))&&Math.abs(f-h)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===Xi)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Te=e.config,this.mi=e.persistence,this.Ii=void 0,this.Ti=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.Ei=n||Ki,this.Ri=r||Ki;var i=this.Te.persistence_name||this.Te.token;if(this._sessionTimeoutMs=1e3*hi(this.Te.session_idle_timeout_seconds||1800,60,36e3,nd.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Pi(),this.Oi="ph_"+i+"_window_id",this.Fi="ph_"+i+"_primary_window_exists",this.Ai()){var a=jn.F(this.Oi),c=jn.F(this.Fi);a&&!c?this.Ii=a:jn.P(this.Oi),jn.q(this.Fi,!0)}if((s=this.Te.bootstrap)!=null&&s.sessionID)try{var u=(f=>{var h=this.Te.bootstrap.sessionID.replace(/-/g,"");if(h.length!==32)throw new Error("Not a valid UUID");if(h[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(h.substring(0,12),16)})();this.Li(this.Te.bootstrap.sessionID,new Date().getTime(),u)}catch(f){nd.error("Invalid sessionID in bootstrap",f)}this.$i()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return ge(this.ki)&&(this.ki=[]),this.ki.push(e),this.Ti&&e(this.Ti,this.Ii),()=>{this.ki=this.ki.filter((n=>n!==e))}}Ai(){return this.Te.persistence!=="memory"&&!this.mi.yr&&jn.N()}Ni(e){e!==this.Ii&&(this.Ii=e,this.Ai()&&jn.q(this.Oi,e))}Di(){return this.Ii?this.Ii:this.Ai()?jn.F(this.Oi):null}qi(e){var n=this.xi;return!dr(n)&&!dr(e)&&5e3>Math.abs(e-n)}Li(e,n,r){var s=n!==this._sessionActivityTimestamp,i=!(e!==this.Ti||r!==this._sessionStartTimestamp);this._sessionStartTimestamp=r,this._sessionActivityTimestamp=n,this.Ti=e,i&&!s||i&&this.qi(n)||(this.xi=n,this.mi.register({[_c]:[n,e,r]}))}ji(){var e,n=(e=this.Te)==null?void 0:e.persistence_save_debounce_ms;return Hi(n)&&n>0}Hi(){this.ji()?this.mi.refreshKey(_c):(this.mi.flush(),this.mi.load())}Bi(){var e;if(!dr(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.xi){this.Hi();var n=this.Ui();n[1]===this.Ti&&n[2]===this._sessionStartTimestamp&&(this.xi=this._sessionActivityTimestamp,this.mi.register({[_c]:[this._sessionActivityTimestamp,(e=this.Ti)!==null&&e!==void 0?e:null,this._sessionStartTimestamp]}),this.mi.flush())}}zi(){var e=this.Ui()[0],n=Hi(e)?e:0,r=Hi(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(n,r)}Vi(e){return this.Hi(),this.Mi(e,this.zi())}Ui(){var e=this.mi.props[_c];return Qe(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.xi=null,clearTimeout(this.Wi),this.Wi=void 0,this.Li(null,null,null)}destroy(){this.Ci=!0,this.Bi(),clearTimeout(this.Wi),this.Wi=void 0,this.Si&&te&&(te.removeEventListener(hm,this.Si,{capture:!1}),this.Si=void 0),this.ki=[]}$i(){this.Si=()=>{this.Bi(),this.Ai()&&jn.P(this.Fi)},zt(te,hm,this.Si,{capture:!1})}checkAndGetSessionAndWindowId(e,n){if(e===void 0&&(e=!1),n===void 0&&(n=null),this.Te.cookieless_mode===Xi)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=n||new Date().getTime(),s=this.Ui(),i=s[1],a=s[2],c=this.zi(),u=this.Di(),f=Hi(a)&&Math.abs(r-a)>864e5,h=!1,p=!1,m=!i,_=i,x=!m&&!e&&this.Mi(r,c);if(x){(x=this.Vi(r))||nd.info("cross-tab refresh kept the session alive",{sessionId:i});var y=this.Ui();i=y[1],a=y[2]}m||x||f?(i=this.Ei(),u=this.Ri(),nd.info("new session ID generated",{sessionId:i,windowId:u,changeReason:{noSessionId:m,activityTimeout:x,sessionPastMaximumLength:f}}),a=r,h=!0):(u||(u=this.Ri(),h=!0),(p=i!==_)&&(nd.info("adopted cross-tab session id",{sessionId:i,windowId:u}),h=!0));var w=Hi(c)&&e&&!f?c:r,S=Hi(a)?a:new Date().getTime();this.Ni(u),this.Li(i,w,S),e||this.Pi();var T={noSessionId:m,activityTimeout:x,sessionPastMaximumLength:f,crossTabAdoption:p};return h&&this.ki.forEach((P=>P(i,u,T))),{sessionId:i,windowId:u,sessionStartTimestamp:S,changeReason:h?T:void 0,lastActivityTimestamp:c}}Pi(){this.Ci||(clearTimeout(this.Wi),this.Wi=setTimeout((()=>{if(!this.Ci)if(this.Vi(new Date().getTime())){var e=this.Ti;this.resetSessionId(),this.wi.emit("forcedIdleReset",{idleSessionId:e})}else this.Pi()}),1.1*this.sessionTimeoutMs))}}var EP=function(t,e){if(!t)return!1;var n=t.userAgent;if(n&&_E(n,e))return!0;try{var r=t==null?void 0:t.userAgentData;if(r!=null&&r.brands&&r.brands.some((s=>_E(s==null?void 0:s.brand,e))))return!0}catch{}return!!t.webdriver};function CP(){return(CP=en((function*(){var t=ar==null?void 0:ar.userAgentData;if(t!=null&&t.getHighEntropyValues)try{var e=yield t.getHighEntropyValues(["model"]),n=e==null?void 0:e.model;return xt(n)&&n.length>0?n:void 0}catch(r){return void _e.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",r)}}))).apply(this,arguments)}var xm=function(t,e){if(!(function(n){try{new RegExp(n)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(t)}catch{return!1}};function YE(t,e,n){return xc({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:n})}var kP={exact:(t,e)=>e.some((n=>t.some((r=>n===r)))),is_not:(t,e)=>e.every((n=>t.every((r=>n!==r)))),regex:(t,e)=>e.some((n=>t.some((r=>xm(n,r))))),not_regex:(t,e)=>e.every((n=>t.every((r=>!xm(n,r))))),icontains:(t,e)=>e.map(Yh).some((n=>t.map(Yh).some((r=>n.includes(r))))),not_icontains:(t,e)=>e.map(Yh).every((n=>t.map(Yh).every((r=>!n.includes(r))))),gt:(t,e)=>e.some((n=>{var r=parseFloat(n);return!isNaN(r)&&t.some((s=>r>parseFloat(s)))})),lt:(t,e)=>e.some((n=>{var r=parseFloat(n);return!isNaN(r)&&t.some((s=>r<parseFloat(s)))}))},Yh=t=>t.toLowerCase();function PP(t,e){return!t||Object.entries(t).every((n=>{var r=n[1],s=e==null?void 0:e[n[0]];if(ge(s)||dr(s))return!1;var i=[String(s)],a=kP[r.operator];return!!a&&a(r.values,i)}))}var $y="custom",XE="i.posthog.com",nD=/^\/static\//;class rD{constructor(e){this.Zi={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,n=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return n||(n=this.apiHost.replace("."+XE,".posthog.com")),n==="https://app.posthog.com"?"https://us.posthog.com":n}get region(){return this.Zi[this.apiHost]||(this.Zi[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":$y),this.Zi[this.apiHost]}Gi(e){if(nD.test(e)){var n=this.instance.config.asset_host;if(typeof n=="string")return n.trim().replace(/\/$/,"")||void 0}}endpointFor(e,n){if(n===void 0&&(n=""),n&&(n=n[0]==="/"?n:"/"+n),e==="ui")return this.uiHost+n;if(e==="flags")return this.flagsApiHost+n;if(e==="assets"){var r=this.Gi(n);if(r)return""+r+n}if(this.region===$y)return this.apiHost+n;var s=XE+n;switch(e){case"assets":return"https://"+this.region+"-assets."+s;case"api":return"https://"+this.region+"."+s}}}function TP(t){var e;return!((e=t.conditions)==null||(e=e.events)==null||(e=e.values)==null||!e.length)}var yt=Vt("[Surveys]"),RP="seenSurvey_",AP=t=>{try{var e=(n=>((r,s)=>""+RP+(function(i){return i.current_iteration&&i.current_iteration>0?i.id+"_"+i.current_iteration:i.id})(s))(0,n))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(n){yt.error("Failed to persist survey seen state",n)}},sD=[Tv.Popover,Tv.Widget,Tv.API],iD={ignoreConditions:!1,ignoreDelay:!1,displayType:Ly.Popover},oD=Vt("[PostHog ExternalIntegrations]"),aD={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class lD{constructor(e){this._instance=e}er(e,n){var r;(r=$e.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,e,(s=>{if(s)return oD.error("failed to load script",s);n()}))}startIfEnabledOrStop(){var e=this,n=function(){var i,a,c,u=r[0],f=r[1];!f||(i=$e.__PosthogExtensions__)!=null&&(i=i.integrations)!=null&&i[u]||e.er(aD[u],(()=>{var h;(h=$e.__PosthogExtensions__)==null||(h=h.integrations)==null||(h=h[u])==null||h.start(e._instance)})),!f&&(a=$e.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[u]&&((c=$e.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[u])==null||c.stop())};for(var r of Object.entries((s=this._instance.config.integrations)!==null&&s!==void 0?s:{})){var s;n()}}}var Cd={},Ov=0,wm=()=>{},QE='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',rd="Surveys module not available",JE="sanitize_properties is deprecated. Use before_send instead",IP="Invalid value for property_denylist config: ",cD=["token","distinct_id",D6],gc="posthog",MP=!ZN&&(Sr==null?void 0:Sr.indexOf("MSIE"))===-1&&(Sr==null?void 0:Sr.indexOf("Mozilla"))===-1,Lv=t=>{var e;return ue({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:fN(Se==null?void 0:Se.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:wm,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:t??"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:rn&&xt(rn==null?void 0:rn.search)&&rn.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:(te==null||(e=te.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(n){_e.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:Iy,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:Vy},error_tracking:{},_onCapture:wm},(n=>({rageclick:n&&n>="2026-05-30"?{content_ignorelist:EN,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)}))(t))},uD=[["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"]],eC=t=>{var e={};for(var n of uD){var r=n[0],s=n[1];ge(t[r])||(e[s]=t[r])}var i=At({},e,t),a=t.__preview_external_dependency_versioned_paths;return ge(a)||(ge(t.strict_script_versioning)&&(i.strict_script_versioning=!!a),xt(a)&&ge(t.asset_host)&&(i.asset_host=a)),Qe(t.property_blacklist)&&(ge(t.property_denylist)?i.property_denylist=t.property_blacklist:Qe(t.property_denylist)?i.property_denylist=[...t.property_blacklist,...t.property_denylist]:_e.error(IP+t.property_denylist)),i};class dD{constructor(){this.__forceAllowLocalhost=!1}get Qi(){return this.__forceAllowLocalhost}set Qi(e){_e.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class vs{Ji(e,n){if(e){var r=this.Ki.indexOf(e);r!==-1&&this.Ki.splice(r,1)}return this.Ki.push(n),n.initialize==null||n.initialize(),n}Yi(){return this.config.cookieless_mode===Xi||this.config.cookieless_mode===Qa&&this.consent.isRejected()}get decideEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){var e;this.webPerformance=new dD,this.Xi=!1,this.version=gt.LIB_VERSION,this.en=new L2,this.Ki=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Lv(),this.SentryIntegration=ON,this.sentryIntegration=r=>(function(s,i){var a=rP(s,i);return{name:nP,processEvent:c=>a(c)}})(this,r),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.tn=!1,this.rn=null,this.nn=null,this.sn=null,this.scrollManager=new eD(this),this.pageViewManager=new VE(this),this.rateLimiter=new zN(this),this.requestRouter=new rD(this),this.consent=new _N(this),this.externalIntegrations=new lD(this);var n=(e=vs.__defaultExtensionClasses)!==null&&e!==void 0?e:{};this.featureFlags=n.featureFlags&&new n.featureFlags(this),this.toolbar=n.toolbar&&new n.toolbar(this),this.surveys=n.surveys&&new n.surveys(this),this.conversations=n.conversations&&new n.conversations(this),this.logs=n.logs&&new n.logs(this),this.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:(r,s,i)=>{var a=xt(r)?{[r]:s}:r;this.setPersonProperties(a),i==null||i({})},set_once:(r,s,i)=>{var a=xt(r)?{[r]:s}:r;this.setPersonProperties(void 0,a),i==null||i({})}},this.on("eventCaptured",(r=>_e.info('send "'+(r==null?void 0:r.event)+'"',r)))}init(e,n,r){if(r&&r!==gc){var s,i=(s=Cd[r])!==null&&s!==void 0?s:new vs;return i._init(e,n,r),Cd[r]=i,Cd[gc][r]=i,i}return this._init(e,n,r)}_init(e,n,r){var s,i;n===void 0&&(n={});var a=xt(e)?e.trim():"";if(!a)return _e.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Lv(n.defaults),n.debug=this.an(n.debug),this.ln=n,this.un=[],n.person_profiles?this.nn=n.person_profiles:n.process_person&&(this.nn=n.process_person);var c=Lv(n.defaults),u=eC(n),f=At({},c,u,{name:r,token:a});Nt(c.rageclick)&&Nt(u.rageclick)&&(f.rageclick=At({},c.rageclick,u.rageclick)),Nt(c.session_recording)&&Nt(u.session_recording)&&(f.session_recording=At({},c.session_recording,u.session_recording)),this.set_config(f),this.config.on_xhr_error&&_e.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:or.GZipJS;var h=this.hn();this.persistence=new Pv(this.config,h),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Pv(ue({},this.config,{persistence:"sessionStorage"}),h,!1);var p=ue({},this.persistence.props),m=ue({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.dn=new XN((k=>this.cn(k)),this.config.request_queue_config),this.vn=new JN(this),this.__request_queue=[];var _=this.Yi();if(_||(this.sessionManager=new qE(this),this.sessionPropsManager=new ZE(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(_e.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.fn(_)}),0)):(_e.info("Initializing extensions synchronously"),this.fn(_)),gt.DEBUG=gt.DEBUG||this.config.debug,gt.DEBUG&&_e.info("Starting in debug mode",{this:this,config:n,thisC:ue({},this.config),p,s:m}),!this.config.identity_distinct_id||(s=n.bootstrap)!=null&&s.distinctID||(n.bootstrap=ue({},n.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),((i=n.bootstrap)==null?void 0:i.distinctID)!==void 0){var x=n.bootstrap.distinctID,y=this.get_distinct_id(),w=this.persistence.get_property(Fs);if(n.bootstrap.isIdentifiedID&&y!=null&&y!==x&&w===rc)this.identify(x);else if(n.bootstrap.isIdentifiedID&&y!=null&&y!==x&&w===sc)_e.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 S=this.config.get_device_id(Ki()),T=n.bootstrap.isIdentifiedID?S:x;this.persistence.set_property(Fs,n.bootstrap.isIdentifiedID?sc:rc),this.register({distinct_id:x,$device_id:T})}}if(_)this.register_once({distinct_id:Wh,$device_id:null},"");else if(!this.get_distinct_id()){var P=this.config.get_device_id(Ki());this.register_once({distinct_id:P,$device_id:P},""),this.persistence.set_property(Fs,rc)}return zt(te,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),n.segment?(function(k,R){var L=k.config.segment;if(!L)return R();(function(O,A){var I=O.config.segment;if(!I)return A();var N=F=>{var K=()=>F.anonymousId()||Ki();O.config.get_device_id=K,F.id()&&(O.register({distinct_id:F.id(),$device_id:K()}),O.persistence.set_property(Fs,sc)),A()},j=I.user();"then"in j&&zs(j.then)?j.then(N):N(j)})(k,(()=>{L.register((O=>{typeof Promise<"u"&&Promise.resolve||Cv.warn("This browser does not have Promise support, and can not use the segment integration");var A=(I,N)=>{if(!N)return I;I.event.userId||I.event.anonymousId===O.get_distinct_id()||(Cv.info("No userId set, resetting PostHog"),O.reset()),I.event.userId&&I.event.userId!==O.get_distinct_id()&&(Cv.info("UserId set, identifying with PostHog"),O.identify(I.event.userId));var j=O.calculateEventProperties(N,I.event.properties);return I.event.properties=Object.assign({},j,I.event.properties),I};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:I=>A(I,I.event.event),page:I=>A(I,mc),identify:I=>A(I,bv),screen:I=>A(I,"$screen")}})(k)).then((()=>{R()}))}))})(this,(()=>this.pn())):this.pn(),zs(this.config._onCapture)&&this.config._onCapture!==wm&&(_e.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(k=>this.config._onCapture(k.event,k)))),this.config.ip&&_e.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 CP.apply(this,arguments)})().then((k=>{k&&this.register({[xv]:k})})).catch(wm),this}fn(e){var n,r,s,i,a,c,u,f,h=performance.now(),p=ue({},vs.__defaultExtensionClasses,this.config.__extensionClasses),m=[];p.featureFlags&&this.Ki.push(this.featureFlags=(n=this.featureFlags)!==null&&n!==void 0?n:new p.featureFlags(this)),p.exceptions&&this.Ki.push(this.exceptions=(r=this.exceptions)!==null&&r!==void 0?r:new p.exceptions(this)),p.historyAutocapture&&this.Ki.push(this.historyAutocapture=new p.historyAutocapture(this)),p.tracingHeaders&&this.Ki.push(this.tracingHeaders=new p.tracingHeaders(this)),p.siteApps&&this.Ki.push(this.siteApps=new p.siteApps(this)),p.sessionRecording&&!e&&this.Ki.push(this.sessionRecording=new p.sessionRecording(this)),this.config.disable_scroll_properties||m.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),p.autocapture&&this.Ki.push(this.autocapture=new p.autocapture(this)),p.surveys&&this.Ki.push(this.surveys=(s=this.surveys)!==null&&s!==void 0?s:new p.surveys(this)),p.logs&&this.Ki.push(this.logs=(i=this.logs)!==null&&i!==void 0?i:new p.logs(this)),p.metrics&&this.Ki.push(this.metrics=(a=this.metrics)!==null&&a!==void 0?a:new p.metrics(this)),p.conversations&&this.Ki.push(this.conversations=(c=this.conversations)!==null&&c!==void 0?c:new p.conversations(this)),p.productTours&&this.Ki.push(this.productTours=new p.productTours(this)),p.heatmaps&&this.Ki.push(this.heatmaps=new p.heatmaps(this)),p.webVitalsAutocapture&&this.Ki.push(this.webVitalsAutocapture=new p.webVitalsAutocapture(this)),p.exceptionObserver&&this.Ki.push(this.exceptionObserver=new p.exceptionObserver(this)),p.deadClicksAutocapture&&this.Ki.push(this.deadClicksAutocapture=new p.deadClicksAutocapture(this,MN)),p.toolbar&&this.Ki.push(this.toolbar=(u=this.toolbar)!==null&&u!==void 0?u:new p.toolbar(this)),p.experiments&&this.Ki.push(this.experiments=(f=this.experiments)!==null&&f!==void 0?f:new p.experiments(this)),this.Ki.forEach((_=>{_.initialize&&m.push((()=>{_.initialize==null||_.initialize()}))})),m.push((()=>{if(this.gn){var _=this.gn;this.gn=void 0,this.Hr(_)}})),this.mn(m,h)}mn(e,n){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-n>=30&&e.length>0)return void setTimeout((()=>{this.mn(e,n)}),0);var r=e.shift();if(r)try{r()}catch(i){_e.error("Error initializing extension:",i)}}var s=Math.round(performance.now()-n);this.register_for_session({[j6]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[F6]:s}),this.config.__preview_deferred_init_extensions&&_e.info("PostHog extensions initialized ("+s+"ms)")}Hr(e){if(!Se||!Se.body)return _e.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Hr(e)}),500);if(this.config.__preview_deferred_init_extensions&&(this.gn=e),this.yn=e,this.compression=void 0,e.ok){var n,r=e.config;r.supportedCompression&&!this.config.disable_compression&&(this.compression=Ge(r.supportedCompression,or.GZipJS)?or.GZipJS:Ge(r.supportedCompression,or.Base64)?or.Base64:void 0),(n=r.analytics)!=null&&n.endpoint&&(this.analyticsDefaultEndpoint=r.analytics.endpoint)}this.set_config({person_profiles:this.nn?this.nn:Iy}),this.Ki.forEach((s=>s.onRemoteConfig==null?void 0:s.onRemoteConfig(e)))}pn(){try{this.config.loaded(this)}catch(r){_e.critical("`loaded` function failed",r)}if(this.bn(),this.config.internal_or_test_user_hostname&&rn!=null&&rn.hostname){var e=rn.hostname,n=this.config.internal_or_test_user_hostname;(typeof n=="string"?e===n:n.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.Yi())&&this._n()}),1),this.wn=new hP(this),this.wn.load()}bn(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.dn)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Gh(this.__request_queue,(e=>this.cn(e))),this.__request_queue=[],this.bn()}_handle_unload(){var e,n,r,s,i;(e=this.surveys)==null||e.handlePageUnload==null||e.handlePageUnload(),(n=this.metrics)==null||n.flush("sendBeacon"),this.config.request_batching?(this.xn()&&this.capture(wv),(r=this.logs)==null||r.flushLogs("sendBeacon"),(s=this.dn)==null||s.unload(),(i=this.vn)==null||i.unload()):this.xn()&&this.capture(wv,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded?MP?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&(e.callback==null||e.callback({statusCode:429})):(e.transport=e.transport||this.config.api_transport,e.headers=ue({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?this.compression:e.compression,(ge(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(n=>{var r,s,i,a=ue({},n);a.timeout=a.timeout||6e4;var c,u,f,h,p,m=(r=a.transport)!==null&&r!==void 0?r:"fetch";m==="sendBeacon"&&ge(a.compression)&&a.data&&(a.compression=or.Base64),a.method==="POST"&&a.data&&(a.timestampMode==="capture-body"?a.data={api_key:(u=(p=(h=Qe(c=a.data)?c:[c])[0])==null||(f=p.properties)==null?void 0:f.token)!==null&&u!==void 0?u:p==null?void 0:p.token,batch:h,sent_at:new Date().toISOString()}:a.timestampMode==="body"&&(a.data=(function(y,w){return w===void 0&&(w=new Date().toISOString()),Qe(y)?y.map((S=>ue({},S,{sent_at:w}))):ue({},y,{sent_at:w})})(a.data))),a.url=KE(a.url,a.method,a.compression,a.timestampMode);var _=Tp.filter((y=>!a.disableTransport||!y.transport||!a.disableTransport.includes(y.transport))),x=(s=(i=(function(y,w){for(var S=0;y.length>S;S++)if(y[S].transport===m)return y[S]})(_))==null?void 0:i.method)!==null&&s!==void 0?s:_[0].method;if(!x)throw new Error("No available transport method");m!=="sendBeacon"&&a.data&&a.compression===or.GZipJS&&pL&&typeof Promise<"u"&&!Pp?qN(a).then((y=>{x(y)})).catch((y=>{if(yE(y))return Pp=!0,void x(ue({},a,{compression:void 0,url:KE(n.url,n.method,void 0,n.timestampMode)}));(w=>{if(!w||typeof w!="object")return!1;var S="name"in w?String(w.name):"";return yE(w)||S===Q8})(y)&&(Pp=!0),x(a)})):x(a)})(ue({},e,{callback:n=>{var r,s;this.rateLimiter.checkForLimiting(n),400>n.statusCode||(r=(s=this.config).on_request_error)==null||r.call(s,n),e.callback==null||e.callback(n)}}))):e.fireCallbackOnDrop&&(e.callback==null||e.callback({statusCode:0}))}cn(e){this.vn?this.vn.retriableRequest(e):this._send_request(e)}_execute_array(e){Ov++;try{var n,r=[],s=[],i=[];Gh(e,(c=>{if(c)if(Qe(n=c[0]))i.push(c);else if(zs(c))try{c.call(this)}catch(u){_e.error("Error executing queued PostHog call",c,u)}else Qe(c)&&n==="alias"?r.push(c):Qe(c)&&n.indexOf("capture")!==-1&&zs(this[n])?i.push(c):s.push(c)}));var a=function(c,u){Gh(c,(function(f){try{if(Qe(f[0])){var h=u;wt(f,(function(p){h=h[p[0]].apply(h,p.slice(1))}))}else u[f[0]].apply(u,f.slice(1))}catch(p){_e.error("Error executing queued PostHog call",f,p)}}))};a(r,this),a(s,this),a(i,this)}finally{Ov--}}push(e){if(Ov>0&&Qe(e)&&xt(e[0])){var n=vs.prototype[e[0]];zs(n)&&n.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,n,r){var s,i,a,c,u;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.dn){if(this.is_capturing())if(!ge(e)&&xt(e)){var f=!this.config.opt_out_useragent_filter&&this._is_bot();if(!f||this.config.__preview_capture_bot_pageviews){var h=r!=null&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(h==null||!h.isRateLimited){n!=null&&n.$current_url&&!xt(n==null?void 0:n.$current_url)&&(_e.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),n==null||delete n.$current_url),e!=="$exception"||r!=null&&r.kn||_e.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var p=new Date,m=(r==null?void 0:r.timestamp)||p,_=SE(r==null?void 0:r.uuid,Ki),x={uuid:_,event:e,properties:this.calculateEventProperties(e,n||{},m,_)};e===mc&&this.config.__preview_capture_bot_pageviews&&f&&(x.event="$bot_pageview",x.properties.$browser_type="bot"),h&&(x.properties.$lib_rate_limit_remaining_tokens=h.remainingTokens);var y=e==="$feature_flag_called"&&x.properties.$feature_flag_has_experiment===!1&&this.get_property(lm)===!0;r!=null&&r.$set&&!y&&(x.$set=r==null?void 0:r.$set);var w=r==null?void 0:r.$unset;w&&(x.$unset=w);var S,T,P,k=y?void 0:this.Sn(r==null?void 0:r.$set_once,e!==TE,e===bv);if(k&&(x.$set_once=k),r!=null&&r._noTruncate||(i=this.config.properties_string_max_length,a=x,c=F=>xt(F)?F.slice(0,i):F,u=new Set,x=(function F(K,X){if(K!==Object(K))return c?c(K):K;if(!u.has(K)){var W;if(u.add(K),Qe(K))W=[],Gh(K,(q=>{W.push(F(q))}));else{var G={};wt(K,((q,$)=>{u.has(q)||(G[$]=F(q))})),W=G}return W}})(a)),x.timestamp=m,ge(r==null?void 0:r.timestamp)||(x.properties.$event_time_override_provided=!0,x.properties.$event_time_override_system_time=p),y&&(x.properties=(function(F,K){K===void 0&&(K=[]);var X={},W=G=>{F[G]!==void 0&&(X[G]=F[G])};return mL.forEach(W),K.forEach(W),X})(x.properties,cD)),e===Ji.DISMISSED||e===Ji.SENT){var R=n==null?void 0:n[Rv.SURVEY_ID],L=n==null?void 0:n[Rv.SURVEY_ITERATION];AP({id:R,current_iteration:L}),x.$set=ue({},x.$set,{[(S={id:R,current_iteration:L},T=e===Ji.SENT?"responded":"dismissed",P="$survey_"+T+"/"+S.id,S.current_iteration&&S.current_iteration>0&&(P="$survey_"+T+"/"+S.id+"/"+S.current_iteration),P)]:!0})}else e===Ji.SHOWN&&(x.$set=ue({},x.$set,{[Rv.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===HN.SHOWN){var O=n==null?void 0:n[HE.TOUR_TYPE];O&&(x.$set=ue({},x.$set,{[HE.TOUR_LAST_SEEN_DATE+"/"+O]:new Date().toISOString()}))}var A=ue({},x.properties.$set,x.$set);if(Zo(A)||this.setPersonPropertiesForFlags(A),!Je(this.config.before_send)){var I=this.wt(x);if(!I)return;(x=I).uuid=SE(x.uuid,Ki)}this.en.emit("eventCaptured",x);var N=(s=r==null?void 0:r._url)!==null&&s!==void 0?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),j={method:"POST",url:N,data:x,compression:"best-available",timestampMode:(r==null?void 0:r._batchKey)==="recordings"||/\/s\/(?:\?|$)/.test(N)?"body":"capture-body",batchKey:r==null?void 0:r._batchKey,transport:r==null?void 0:r.transport};return!this.config.request_batching||r&&(r==null||!r._batchKey)||r!=null&&r.send_instantly?this.cn(j):this.dn.enqueue(j),x}_e.critical("This capture call is ignored due to client rate limiting.")}}else _e.error("No event name provided to posthog.capture")}else _e.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(n=>e(n.event,n)))}calculateEventProperties(e,n,r,s,i){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return n;var a=i?void 0:this.persistence.remove_event_timer(e),c=ue({},n);if(c.token=this.config.token,c.$config_defaults=this.config.defaults,this.Yi()&&(c[D6]=!0),e==="$snapshot"){var u=ue({},this.persistence.properties(),this.sessionPersistence.properties());return c.distinct_id=u.distinct_id,(!xt(c.distinct_id)&&!$n(c.distinct_id)||ly(c.distinct_id))&&_e.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),c}var f,h=(function(P,k,R,L){var O,A,I,N;if(L===void 0&&(L=!1),!Sr)return{};var j,F=P?[...Jc,...k||[]]:[],K=(function(Ye){for(var dt=0;wE.length>dt;dt++){var Pt=wE[dt],we=Pt[1],je=Pt[0].exec(Ye),ze=je&&(zs(we)?we(je,Ye):we);if(ze)return ze}return["",""]})(Sr),X=K[0],W=K[1],G=(j=typeof navigator<"u"?navigator:void 0)!=null&&j.brave?{brave:!0}:{},q={};ge(R)||(q.detectGoogleSearchApp=R);var $={},ne=(O=navigator)==null||(O=O.userAgentData)==null?void 0:O.platform,H=(A=navigator)==null?void 0:A.maxTouchPoints,D=te==null||(I=te.screen)==null?void 0:I.width,Y=te==null||(N=te.screen)==null?void 0:N.height,ee=te==null?void 0:te.devicePixelRatio;ge(ne)||($.userAgentDataPlatform=ne),ge(H)||($.maxTouchPoints=H),ge(D)||($.screenWidth=D),ge(Y)||($.screenHeight=Y),ge(ee)||($.devicePixelRatio=ee);var ie,oe,ce,xe,ae,se,Ve,De,Re=At(P2({$os:X,$os_version:W,$browser:b6(Sr,navigator.vendor,G,q),$device:bE(Sr),$device_type:(oe=Sr,ce=$,De=bE(oe),De===s6||De===r6||De==="Kobo"||De==="Kindle Fire"||De===v6?qc:De===Fd||De===Pc||De===Vd||De===uy?"Console":De===o6?"Wearable":De?Qr:(ce==null?void 0:ce.userAgentDataPlatform)==="Android"&&((xe=ce==null?void 0:ce.maxTouchPoints)!==null&&xe!==void 0?xe:0)>0?600>Math.min((ae=ce==null?void 0:ce.screenWidth)!==null&&ae!==void 0?ae:0,(se=ce==null?void 0:ce.screenHeight)!==null&&se!==void 0?se:0)/((Ve=ce==null?void 0:ce.devicePixelRatio)!==null&&Ve!==void 0?Ve:1)?Qr:qc:"Desktop"),$timezone:fP(),$timezone_offset:FN()}),{$current_url:zd(L?sa(rn==null?void 0:rn.href):rn==null?void 0:rn.href,F,Ud),$host:rn==null?void 0:rn.host,$pathname:rn==null?void 0:rn.pathname,$raw_user_agent:Sr.length>1e3?Sr.substring(0,997)+"...":Sr,$browser_version:LL(Sr,navigator.vendor,G,q),$browser_language:$E(),$browser_language_prefix:(ie=$E(),typeof ie=="string"?ie.split("-")[0]:void 0),$screen_height:te==null?void 0:te.screen.height,$screen_width:te==null?void 0:te.screen.width,$viewport_height:te==null?void 0:te.innerHeight,$viewport_width:te==null?void 0:te.innerWidth,$lib:gt.LIB_NAME,$lib_version:gt.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return gt.SDK_DIST_CHANNEL&&(Re.$sdk_dist_channel=gt.SDK_DIST_CHANNEL),Re})(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){var p=this.sessionManager.checkAndGetSessionAndWindowId(i,r.getTime()),m=p.windowId;c.$session_id=p.sessionId,c.$window_id=m}this.sessionPropsManager&&At(c,this.sessionPropsManager.getSessionProps());try{var _;this.sessionRecording&&At(c,this.sessionRecording.sdkDebugProperties),c.$sdk_debug_retry_queue_size=(_=this.vn)==null?void 0:_.length}catch(P){c.$sdk_debug_error_capturing_properties=String(P)}if(this.requestRouter.region===$y&&(c.$lib_custom_api_host=this.config.api_host),f=e!==mc||i?e!==wv||i?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,s),c=At(c,f),e===mc&&Se&&(c.title=Se.title),!ge(a)){var x=r.getTime()-a;c.$duration=parseFloat((x/1e3).toFixed(3))}Sr&&this.config.opt_out_useragent_filter&&(c.$browser_type=this._is_bot()?"bot":"browser");var y=this.persistence.properties(),w=this.sessionPersistence.properties();wt(["$referrer","$referring_domain"],(P=>{P in y&&delete w[P]})),(c=At({},h,y,w,c)).$is_identified=this._isIdentified(),Qe(this.config.property_denylist)?wt(this.config.property_denylist,(function(P){delete c[P]})):_e.error(IP+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var S=this.config.sanitize_properties;S&&(_e.error(JE),c=S(c,e));var T=this.Cn();return c.$process_person_profile=T,T&&!i&&this.Mn("_calculate_event_properties"),c}Sn(e,n,r){var s;if(n===void 0&&(n=!0),r===void 0&&(r=!1),!this.persistence||!this.Cn()||this.Xi&&!r)return e;var i=this.persistence.get_initial_props(),a=(s=this.sessionPropsManager)==null?void 0:s.getSetOnceProps(),c=At({},i,a||{},e||{}),u=this.config.sanitize_properties;return u&&(_e.error(JE),c=u(c,"$set_once")),n&&(this.Xi=!0),Zo(c)?void 0:c}register(e,n){var r;(r=this.persistence)==null||r.register(e,n)}register_once(e,n,r){var s;(s=this.persistence)==null||s.register_once(e,n,r)}register_for_session(e){var n;(n=this.sessionPersistence)==null||n.register(e)}unregister(e){var n;(n=this.persistence)==null||n.unregister(e)}unregister_for_session(e){var n;(n=this.sessionPersistence)==null||n.unregister(e)}In(e,n){this.register({[e]:n})}getFeatureFlag(e,n){var r;return(r=this.featureFlags)==null?void 0:r.getFeatureFlag(e,n)}getFeatureFlagPayload(e){var n;return(n=this.featureFlags)==null?void 0:n.getFeatureFlagPayload(e)}getFeatureFlagResult(e,n){var r;return(r=this.featureFlags)==null?void 0:r.getFeatureFlagResult(e,n)}getAllFeatureFlags(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.getAllFeatureFlags())!==null&&e!==void 0?e:[]}isFeatureEnabled(e,n){var r,s;return(r=(s=this.featureFlags)==null?void 0:s.isFeatureEnabled(e,n))!==null&&r!==void 0?r:n==null?void 0:n.defaultValue}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,n,r){var s;(s=this.featureFlags)==null||s.updateFlags(e,n,r)}updateEarlyAccessFeatureEnrollment(e,n,r){var s;(s=this.featureFlags)==null||s.updateEarlyAccessFeatureEnrollment(e,n,r)}getEarlyAccessFeatures(e,n,r){var s;return n===void 0&&(n=!1),(s=this.featureFlags)==null?void 0:s.getEarlyAccessFeatures(e,n,r)}on(e,n){return this.en.on(e,n)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:rd}),()=>{})}onSessionId(e){var n,r;return(n=(r=this.sessionManager)==null?void 0:r.onSessionId(e))!==null&&n!==void 0?n:()=>{}}getSurveys(e,n){n===void 0&&(n=!1),this.surveys?this.surveys.getSurveys(e,n):e([],{isLoaded:!1,error:rd})}getActiveMatchingSurveys(e,n){n===void 0&&(n=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,n):e([],{isLoaded:!1,error:rd})}renderSurvey(e,n){var r;(r=this.surveys)==null||r.renderSurvey(e,n)}displaySurvey(e,n){var r;n===void 0&&(n=iD),(r=this.surveys)==null||r.displaySurvey(e,n)}cancelPendingSurvey(e){var n;(n=this.surveys)==null||n.cancelPendingSurvey(e)}canRenderSurvey(e){var n,r;return(n=(r=this.surveys)==null?void 0:r.canRenderSurvey(e))!==null&&n!==void 0?n:{visible:!1,disabledReason:rd}}canRenderSurveyAsync(e,n){var r,s;return n===void 0&&(n=!1),(r=(s=this.surveys)==null?void 0:s.canRenderSurveyAsync(e,n))!==null&&r!==void 0?r:Promise.resolve({visible:!1,disabledReason:rd})}Tn(e){return!e||ly(e)?(_e.critical("Unique user id has not been set in posthog.identify"),!1):e===Wh?(_e.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(e.toLowerCase())&&!["undefined","null"].includes(e.toLowerCase())||(_e.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(e,n,r){if(!this.__loaded||!this.persistence)return _e.uninitializedWarning("posthog.identify");if($n(e)&&(e=e.toString(),_e.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.Tn(e)&&this.Mn("posthog.identify")){var s=this.get_distinct_id();this.register({$user_id:e}),this.get_property(am)||this.register_once({$had_persisted_distinct_id:!0,$device_id:s},""),e!==s&&e!==this.get_property(hd)&&(this.unregister(hd),this.register({distinct_id:e}));var i,a=(this.persistence.get_property(Fs)||rc)===rc;e!==s&&a?(this.persistence.set_property(Fs,sc),this.setPersonPropertiesForFlags({$set:n||{},$set_once:r||{}},!1),this.capture(bv,{distinct_id:e,$anon_distinct_id:s},{$set:n||{},$set_once:r||{}}),this.sn=YE(e,n,r),(i=this.featureFlags)==null||i.setAnonymousDistinctId(s)):(n||r)&&this.setPersonProperties(n,r),e!==s&&(this.reloadFeatureFlags(),this.unregister(bd))}}setPersonProperties(e,n){if((e||n)&&this.Mn("posthog.setPersonProperties")){var r=YE(this.get_distinct_id(),e,n);this.sn!==r?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:n||{}},!0),this.capture("$set",{$set:e||{},$set_once:n||{}}),this.sn=r):_e.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(e){var n,r=(Qe(e)?e:[e]).filter((s=>xt(s)&&s.length>0));r.length!==0&&this.Mn("posthog.unsetPersonProperties")&&((n=this.featureFlags)==null||n.unsetPersonPropertiesForFlags(r,!0),this.capture("$set",{$unset:r}),this.sn=null)}group(e,n,r){if(e&&n){var s=this.getGroups(),i=s[e]!==n;if(i&&this.resetGroupPropertiesForFlags(e),this.register({$groups:ue({},s,{[e]:n})}),i||r){var a={$group_type:e,$group_key:n};r&&(a.$group_set=r),this.capture(TE,a)}r&&this.setGroupPropertiesForFlags({[e]:r}),i&&!r&&this.reloadFeatureFlags()}else _e.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,n){var r;n===void 0&&(n=!0),(r=this.featureFlags)==null||r.setPersonPropertiesForFlags(e,n)}resetPersonPropertiesForFlags(e){var n;e===void 0&&(e=!0),(n=this.featureFlags)==null||n.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,n){var r;n===void 0&&(n=!0),this.Mn("posthog.setGroupPropertiesForFlags")&&((r=this.featureFlags)==null||r.setGroupPropertiesForFlags(e,n))}resetGroupPropertiesForFlags(e){var n;(n=this.featureFlags)==null||n.resetGroupPropertiesForFlags(e)}reset(e){var n,r,s,i,a,c,u,f,h,p;if(_e.info("reset"),!this.__loaded)return _e.uninitializedWarning("posthog.reset");var m,_=this.get_property(am),x=this.get_property(xv),y=this.get_property(sl);if(this.consent.reset(),(n=this.persistence)==null||n.clear(),(r=this.sessionPersistence)==null||r.clear(),ge(y)||(m=this.persistence)==null||m.register({[sl]:y}),(s=this.surveys)==null||s.reset(),(i=this.wn)==null||i.stop(),(a=this.featureFlags)==null||a.reset(),(c=this.conversations)==null||c.reset(),(u=this.logs)==null||u.reset(),(f=this.metrics)==null||f.reset(),(h=this.persistence)==null||h.set_property(Fs,rc),(p=this.sessionManager)==null||p.resetSessionId(),this.sn=null,this.config.cookieless_mode===Xi)this.register_once({distinct_id:Wh,$device_id:null},"");else{var w=this.config.get_device_id(Ki());this.register_once({distinct_id:w,$device_id:e?w:_},""),e||ge(x)||this.register({[xv]:x})}this.register({$last_posthog_reset:new Date().toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}shutdown(e){var n=this;return en((function*(){var r,s,i,a,c;n.__loaded?((r=n.logs)==null||r.flushLogs("sendBeacon"),(s=n.metrics)==null||s.flush("sendBeacon"),(i=n.dn)==null||i.unload(),(a=n.vn)==null||a.unload(),(c=n.featureFlags)==null||c.destroy()):_e.uninitializedWarning("posthog.shutdown")}))()}setIdentity(e,n){var r;this.config.identity_distinct_id=e,this.config.identity_hash=n,this.alias(e),(r=this.conversations)==null||r.En()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,(e=this.conversations)==null||e.Rn()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,n;return(e=(n=this.sessionManager)==null?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var n=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=n.sessionStartTimestamp,s=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+n.sessionId);if(e!=null&&e.withTimestamp&&r){var i,a=(i=e.timestampLookBack)!==null&&i!==void 0?i:10;if(!r)return s;s+="?t="+Math.max(Math.floor((new Date().getTime()-r)/1e3)-a,0)}return s}alias(e,n){return e===this.get_property(A6)?(_e.critical("Attempting to create alias for existing People user - aborting."),-2):this.Mn("posthog.alias")?(ge(n)&&(n=this.get_distinct_id()),e!==n?(this.In(hd,e),this.capture("$create_alias",{alias:e,distinct_id:n})):(_e.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var n=ue({},this.config);if(Nt(e)){var r,s,i,a,c,u,f,h,p,m,_;At(this.config,eC(e));var x=this.hn();(r=this.persistence)==null||r.update_config(this.config,n,x),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Pv(ue({},this.config,{persistence:"sessionStorage"}),x,!1);var y=this.an(this.config.debug);Us(y)&&(this.config.debug=y),Us(this.config.debug)&&(this.config.debug?(gt.DEBUG=!0,St.N()&&St.q("ph_debug",!0),_e.info("set_config",{config:e,oldConfig:n,newConfig:ue({},this.config)})):(gt.DEBUG=!1,St.N()&&St.P("ph_debug"))),(s=this.exceptionObserver)==null||s.onConfigChange(),(i=this.exceptions)==null||i.onConfigChange(),(a=this.sessionRecording)==null||a.startIfEnabledOrStop(),(c=this.tracingHeaders)==null||c.startIfEnabledOrStop(),(u=this.autocapture)==null||u.startIfEnabled(),(f=this.heatmaps)==null||f.startIfEnabled(),(h=this.exceptionObserver)==null||h.startIfEnabledOrStop(),(p=this.deadClicksAutocapture)==null||p.startIfEnabledOrStop(),(m=this.surveys)==null||m.loadIfEnabled(),this.Pn(),(_=this.externalIntegrations)==null||_.startIfEnabledOrStop()}}_overrideSDKInfo(e,n){gt.LIB_NAME=e,gt.LIB_VERSION=n}startSessionRecording(e){var n,r,s,i,a,c=e===!0,u={sampling:c||!(e==null||!e.sampling),linked_flag:c||!(e==null||!e.linked_flag),url_trigger:c||!(e==null||!e.url_trigger),event_trigger:c||!(e==null||!e.event_trigger)};Object.values(u).some(Boolean)&&((n=this.sessionManager)==null||n.checkAndGetSessionAndWindowId(),u.sampling&&((r=this.sessionRecording)==null||r.overrideSampling()),u.linked_flag&&((s=this.sessionRecording)==null||s.overrideLinkedFlag()),u.url_trigger&&((i=this.sessionRecording)==null||i.overrideTrigger("url")),u.event_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,n){if(this.exceptions){var r=new Error("PostHog syntheticException"),s=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(ue({},s,n))}}addExceptionStep(e,n){var r;(r=this.exceptions)==null||r.addExceptionStep(e,n)}captureLog(e){var n;(n=this.logs)==null||n.captureLog(e)}get logger(){var e,n;return(e=(n=this.logs)==null?void 0:n.logger)!==null&&e!==void 0?e:vs.On}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var n,r;return(n=(r=this.toolbar)==null?void 0:r.loadToolbar(e))!==null&&n!==void 0&&n}get_property(e){var n;return(n=this.persistence)==null?void 0:n.props[e]}getSessionProperty(e){var n;return(n=this.sessionPersistence)==null?void 0:n.props[e]}toString(){var e,n=(e=this.config.name)!==null&&e!==void 0?e:gc;return n!==gc&&(n=gc+"."+n),n}_isIdentified(){var e,n;return((e=this.persistence)==null?void 0:e.get_property(Fs))===sc||((n=this.sessionPersistence)==null?void 0:n.get_property(Fs))===sc}Cn(){var e,n;return!(this.config.person_profiles==="never"||this.config.person_profiles===Iy&&!this._isIdentified()&&Zo(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[hd])&&((n=this.persistence)==null||(n=n.props)==null||!n[dm]))}xn(){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.Cn()||this.Mn("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Mn("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Mn(e){return this.config.person_profiles==="never"?(_e.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.In(dm,!0),!0)}hn(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==Qa)}Pn(){var e,n,r,s,i=this.hn();return((e=this.persistence)==null?void 0:e.yr)!==i&&((r=this.persistence)==null||r.set_disabled(i)),((n=this.sessionPersistence)==null?void 0:n.yr)!==i&&((s=this.sessionPersistence)==null||s.set_disabled(i)),i}opt_in_capturing(e){var n;if(this.config.cookieless_mode!==Xi){if(this.Yi()){var r,s,i,a,c;this.reset(!0),(r=this.sessionManager)==null||r.destroy(),(s=this.pageViewManager)==null||s.destroy(),this.sessionManager=new qE(this),this.pageViewManager=new VE(this),this.persistence&&(this.sessionPropsManager=new ZE(this,this.sessionManager,this.persistence));var u,f=(i=(a=this.config.__extensionClasses)==null?void 0:a.sessionRecording)!==null&&i!==void 0?i:(c=vs.__defaultExtensionClasses)==null?void 0:c.sessionRecording;f&&(this.sessionRecording=this.Ji(this.sessionRecording,new f(this)),this.yn&&((u=this.sessionRecording)==null||u.onRemoteConfig==null||u.onRemoteConfig(this.yn)))}var h,p;this.consent.optInOut(!0),this.Pn(),this.bn(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==Qa&&((h=this.surveys)==null||h.loadIfEnabled()),(ge(e==null?void 0:e.captureEventName)||e!=null&&e.captureEventName)&&this.capture((p=e==null?void 0:e.captureEventName)!==null&&p!==void 0?p:"$opt_in",e==null?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this._n()}else _e.warn(QE)}opt_out_capturing(){var e,n,r;this.config.cookieless_mode!==Xi?(this.config.cookieless_mode===Qa&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.Pn(),this.config.cookieless_mode===Qa&&(this.register({distinct_id:Wh,$device_id:null}),(e=this.sessionRecording)==null||e.stopRecording(),this.sessionRecording=void 0,(n=this.sessionManager)==null||n.destroy(),(r=this.pageViewManager)==null||r.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this._n(),this.bn())):_e.warn(QE)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===1?"granted":e===0?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===Xi||(this.config.cookieless_mode===Qa?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.Pn()}_is_bot(){return ar?EP(ar,this.config.custom_blocked_useragents):void 0}_n(){Se&&(Se.visibilityState==="visible"?this.tn||(this.tn=!0,this.capture(mc,{title:Se.title},{send_instantly:!0}),this.rn&&(Se.removeEventListener(fm,this.rn),this.rn=null)):this.rn||(this.rn=this._n.bind(this),zt(Se,fm,this.rn)))}debug(e){e===!1?(te==null||te.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(te==null||te.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}))}Ur(){var e=this.ln||{};return"advanced_disable_flags"in e?!!e.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(_e.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,r,s,i,a){var c=r in n&&!Je(n[r]),u=s in n&&!Je(n[s]);return c?n[r]:!!u&&(a&&a.warn("Config field '"+s+"' is deprecated. Please use '"+r+"' instead. The old field will be removed in a future major version."),n[s])})(e,"advanced_disable_flags","advanced_disable_decide",0,_e)}wt(e){var n;if(Je(this.config.before_send))return e;var r=Object.keys((n=e.properties)!==null&&n!==void 0?n:{}).filter(bL),s=Qe(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var a of s){if(i=a(i),Je(i)){var c="Event '"+e.event+"' was rejected in beforeSend function";return wL(e.event)?_e.warn(c+". This can cause unexpected behavior."):_e.info(c),null}i.properties&&!Zo(i.properties)||_e.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}for(var u of r)if(i.properties&&Je(i.properties[u]))return _e.warn("Event '"+e.event+"' had its '"+u+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return i}getPageViewId(){var e;return(e=this.pageViewManager.ir)==null?void 0:e.pageViewId}captureTraceFeedback(e,n){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:n})}captureTraceMetric(e,n,r){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:n,$ai_metric_value:String(r)})}an(e){var n=Us(e)&&!e,r=St.N()&&St.A("ph_debug")==="true";return!n&&(!!r||e)}}vs.__defaultExtensionClasses={},vs.On=(()=>{var t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),(function(t,e){for(var n=0;e.length>n;n++)t.prototype[e[n]]=uN(t.prototype[e[n]])})(vs,["identify"]);class tC{constructor(e){this.disabled=e===!1;var n=Nt(e)?e:{};this.thresholdPx=n.threshold_px||30,this.timeoutMs=n.timeout_ms||1e3,this.clickCount=n.click_count||3,this.clicks=[]}isRageClick(e,n,r){if(this.disabled)return!1;var s=this.clicks[this.clicks.length-1];if(s&&Math.abs(e-s.x)+Math.abs(n-s.y)<this.thresholdPx&&this.timeoutMs>r-s.timestamp){if(this.clicks.push({x:e,y:n,timestamp:r}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:n,timestamp:r}];return!1}}var Nv="$copy_autocapture",Dv=Vt("[AutoCapture]");function jv(t,e){return e.length>t?e.slice(0,t)+"...":e}function fD(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do e=e.previousSibling;while(e&&!ia(e));return e}function hD(t,e){var n,r,s=e.e,i=e.maskAllElementAttributes,a=e.maskAllText,c=e.elementAttributeIgnoreList,u=e.elementsChainAsString,f=e.disableCaptureUrlHashes;if(!ia(t))return{props:{}};for(var h=[t],p=new Set([t]),m=t;m.parentNode&&!qr(m,"body")&&K6>h.length;)if(G6(m.parentNode)){var _=m.parentNode.host;if(p.has(_))break;p.add(_),h.push(_),m=_}else{if(!ia(m.parentNode)||p.has(m.parentNode))break;p.add(m.parentNode),h.push(m.parentNode),m=m.parentNode}var x,y,w=[],S={},T=!1,P=!1;if(wt(h,(A=>{var I=Oy(A);if(qr(A,"a")){var N=A.getAttribute("href");T=!!(I&&N&&Sd(N))&&(f?sa(N):N)}Ge(mm(A),"ph-no-capture")&&(P=!0),w.push((function(F,K,X,W,G){G===void 0&&(G=!1);var q=F.tagName.toLowerCase(),$={tag_name:q};R2.indexOf(q)>-1&&!X&&($.$el_text=q.toLowerCase()==="a"||q.toLowerCase()==="button"?jv(1024,DE(F)):jv(1024,Hd(F)));var ne=mm(F);ne.length>0&&($.classes=ne.filter((function(ee){return ee!==""}))),wt(F.attributes,(function(ee){var ie;if((!Q6(F)||["name","id","class","aria-label"].indexOf(ee.name)!==-1)&&(W==null||!W.includes(ee.name))&&!K&&Sd(ee.value)&&(!xt(ie=ee.name)||ie.substring(0,10)!=="_ngcontent"&&ie.substring(0,7)!=="_nghost")){var oe=ee.value;ee.name==="class"&&(oe=T2(oe).join(" ")),$["attr__"+ee.name]=jv(1024,ee.name==="href"&&G?sa(oe):oe)}}));for(var H=1,D=1,Y=F;Y=fD(Y);)H++,Y.tagName===F.tagName&&D++;return $.nth_child=H,$.nth_of_type=D,$})(A,i,a,c,f));var j=(function(F){if(!Oy(F))return{};var K={};return wt(F.attributes,(function(X){if(X.name&&X.name.indexOf("data-ph-capture-attribute")===0){var W=X.name.replace("data-ph-capture-attribute-",""),G=X.value;W&&G&&Sd(G)&&(K[W]=G)}})),K})(A);At(S,j)})),P)return{props:{},explicitNoCapture:P};if(a||(w[0].$el_text=qr(t,"a")||qr(t,"button")?DE(t):Hd(t)),T){var k,R;w[0].attr__href=T;var L=(k=gm(T))==null?void 0:k.host,O=te==null||(R=te.location)==null?void 0:R.host;L&&O&&L!==O&&(x=T)}return{props:At({$event_type:s.type,$ce_version:1},u?{}:{$elements:w},{$elements_chain:(y=w,(function(A){return A.map((I=>{var N,j,F="";if(I.tag_name&&(F+=I.tag_name),I.attr_class)for(var K of(I.attr_class.sort(),I.attr_class))F+="."+K.replace(/"/g,"");var X=ue({},I.text?{text:I.text}:{},{"nth-child":(N=I.nth_child)!==null&&N!==void 0?N:0,"nth-of-type":(j=I.nth_of_type)!==null&&j!==void 0?j:0},I.href?{href:I.href}:{},I.attr_id?{attr_id:I.attr_id}:{},I.attributes),W={};return kp(X).sort(((G,q)=>G[0].localeCompare(q[0]))).forEach((G=>{var q=G[1];return W[jE(G[0].toString())]=jE(q.toString())})),(F+=":")+kp(W).map((G=>G[0]+'="'+G[1]+'"')).join("")})).join(";")})((function(A){return A.map((I=>{var N,j,F={text:(N=I.$el_text)==null?void 0:N.slice(0,400),tag_name:I.tag_name,href:(j=I.attr__href)==null?void 0:j.slice(0,2048),attr_class:AN(I),attr_id:I.attr__id,nth_child:I.nth_child,nth_of_type:I.nth_of_type,attributes:{}};return kp(I).filter((K=>K[0].indexOf("attr__")===0)).forEach((K=>F.attributes[K[0]]=K[1])),F}))})(y)))},(n=w[0])!=null&&n.$el_text?{$el_text:(r=w[0])==null?void 0:r.$el_text}:{},x&&s.type==="click"?{$external_click_url:x}:{},S)}}var sd=Vt("[ExceptionAutocapture]"),nC=()=>{},pD=Vt("[TracingHeaders]"),Va=Vt("[Web Vitals]"),rC=9e5,sC="disabled",iC="lazy_loading",id="awaiting_config",Xh="missing_config";Vt("[SessionRecording]"),Vt("[SessionRecording]");var Hy="[SessionRecording]",Li=Vt(Hy),mD=Vt("[Heatmaps]");function Fv(t){return Nt(t)&&"clientX"in t&&"clientY"in t&&$n(t.clientX)&&$n(t.clientY)}var Vv=Vt("[Product Tours]"),$v=t=>{var e;return!t.config.disable_product_tours&&!((e=t.persistence)==null||!e.get_property(E2))},gD=["$set_once","$set"],ti=Vt("[SiteApps]"),oC="Error while initializing PostHog app with config id ";function ac(t,e,n){if(Je(t))return!1;switch(n){case"exact":return t===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch{return!1}default:return!1}}class vD{constructor(e){this.Fn=new L2,this.An=(n,r)=>this.Ln(n,r)&&this.$n(n,r)&&this.Nn(n,r)&&this.Dn(n,r),this.Ln=(n,r)=>r==null||!r.event||(n==null?void 0:n.event)===(r==null?void 0:r.event),this._instance=e,this.qn=new Set,this.jn=new Set}init(){var e,n;ge((e=this._instance)==null?void 0:e._addCaptureHook)||(n=this._instance)==null||n._addCaptureHook(((r,s)=>{this.on(r,s)}))}register(e){var n,r;if(!ge((n=this._instance)==null?void 0:n._addCaptureHook)&&(e.forEach((a=>{var c,u;(c=this.jn)==null||c.add(a),(u=a.steps)==null||u.forEach((f=>{var h;(h=this.qn)==null||h.add((f==null?void 0:f.event)||"")}))})),(r=this._instance)!=null&&r.autocapture)){var s,i=new Set;e.forEach((a=>{var c;(c=a.steps)==null||c.forEach((u=>{u!=null&&u.selector&&i.add(u==null?void 0:u.selector)}))})),(s=this._instance)==null||s.autocapture.setElementSelectors(i)}}on(e,n){var r;n!=null&&e.length!=0&&(this.qn.has(e)||this.qn.has(n.event))&&this.jn&&((r=this.jn)==null?void 0:r.size)>0&&this.jn.forEach((s=>{this.Hn(n,s)&&this.Fn.emit("actionCaptured",s.name)}))}Bn(e){this.onAction("actionCaptured",(n=>e(n)))}Hn(e,n){if((n==null?void 0:n.steps)==null)return!1;for(var r of n.steps)if(this.An(e,r))return!0;return!1}onAction(e,n){return this.Fn.on(e,n)}$n(e,n){if(n!=null&&n.url){var r,s=e==null||(r=e.properties)==null?void 0:r.$current_url;if(!s||typeof s!="string"||!ac(s,n.url,n.url_matching||"contains"))return!1}return!0}Nn(e,n){return!!this.Un(e,n)&&!!this.zn(e,n)&&!!this.Vn(e,n)}Un(e,n){var r;if(n==null||!n.href)return!0;var s=this.Wn(e);if(s.length>0)return s.some((c=>ac(c.href,n.href,n.href_matching||"exact")));var i,a=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!a&&ac((i=a.match(/(?::|")href="(.*?)"/))?i[1]:"",n.href,n.href_matching||"exact")}zn(e,n){var r;if(n==null||!n.text)return!0;var s=this.Wn(e);if(s.length>0)return s.some((f=>ac(f.text,n.text,n.text_matching||"exact")||ac(f.$el_text,n.text,n.text_matching||"exact")));var i,a,c,u=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!u&&(i=(function(f){for(var h,p=[],m=/(?::|")text="(.*?)"/g;!Je(h=m.exec(f));)p.includes(h[1])||p.push(h[1]);return p})(u),a=n.text,c=n.text_matching||"exact",i.some((f=>ac(f,a,c))))}Vn(e,n){var r,s;if(n==null||!n.selector)return!0;var i=e==null||(r=e.properties)==null?void 0:r.$element_selectors;if(i!=null&&i.includes(n.selector))return!0;var a=(e==null||(s=e.properties)==null?void 0:s.$elements_chain)||"";if(n.selector_regex&&a)try{return new RegExp(n.selector_regex).test(a)}catch{return!1}return!1}Wn(e){var n;return(e==null||(n=e.properties)==null?void 0:n.$elements)==null?[]:e==null?void 0:e.properties.$elements}Dn(e,n){return n==null||!n.properties||n.properties.length===0||PP(n.properties.reduce(((r,s)=>{var i=Qe(s.value)?s.value.map(String):s.value!=null?[String(s.value)]:[];return r[s.key]={values:i,operator:s.operator||"exact"},r}),{}),e==null?void 0:e.properties)}}class yD{constructor(e){var n;this.Zn=[],this._instance=e,this.Gn=new Map,this.Qn=new Map,this.Jn=new Map,(n=this._instance)==null||n.onSessionId==null||n.onSessionId((r=>this.Kn(r)))}Yn(e,n){return!!e&&PP(e.propertyFilters,n==null?void 0:n.properties)}Xn(e,n){var r=new Map;return e.forEach((s=>{var i;(i=s.conditions)==null||(i=i[n])==null||(i=i.values)==null||i.forEach((a=>{if(a!=null&&a.name){var c=r.get(a.name)||[];c.push(s.id),r.set(a.name,c)}}))})),r}es(e,n,r){var s=(r===Qu.Activation?this.Gn:this.Qn).get(e),i=[];return this.ts((a=>{i=a.filter((c=>s==null?void 0:s.includes(c.id)))})),i.filter((a=>{var c,u=(c=a.conditions)==null||(c=c[r])==null||(c=c.values)==null?void 0:c.find((f=>f.name===e));return this.Yn(u,n)}))}register(e){var n;ge((n=this._instance)==null?void 0:n._addCaptureHook)||(this.rs(e),this.ns(e))}ns(e){var n=e.filter((r=>{var s,i;return((s=r.conditions)==null?void 0:s.actions)&&((i=r.conditions)==null||(i=i.actions)==null||(i=i.values)==null?void 0:i.length)>0}));n.length!==0&&(this.ss==null&&(this.ss=new vD(this._instance),this.ss.init(),this.ss.Bn((r=>{this.onAction(r)}))),n.forEach((r=>{var s,i,a,c,u;r.conditions&&(s=r.conditions)!=null&&s.actions&&(i=r.conditions)!=null&&(i=i.actions)!=null&&i.values&&((a=r.conditions)==null||(a=a.actions)==null||(a=a.values)==null?void 0:a.length)>0&&((c=this.ss)==null||c.register(r.conditions.actions.values),(u=r.conditions)==null||(u=u.actions)==null||(u=u.values)==null||u.forEach((f=>{if(f&&f.name){var h=this.Jn.get(f.name);h&&h.push(r.id),this.Jn.set(f.name,h||[r.id])}})))})))}rs(e){var n,r=e.filter((i=>{var a,c;return((a=i.conditions)==null?void 0:a.events)&&((c=i.conditions)==null||(c=c.events)==null||(c=c.values)==null?void 0:c.length)>0})),s=e.filter((i=>{var a,c;return((a=i.conditions)==null?void 0:a.cancelEvents)&&((c=i.conditions)==null||(c=c.cancelEvents)==null||(c=c.values)==null?void 0:c.length)>0}));r.length===0&&s.length===0||((n=this._instance)==null||n._addCaptureHook(((i,a)=>{this.onEvent(i,a)})),this.Gn=this.Xn(e,Qu.Activation),this.Qn=this.Xn(e,Qu.Cancellation))}onEvent(e,n){var r,s,i=this.os(),a=(n==null||(r=n.properties)==null?void 0:r.$survey_id)||(n==null||(s=n.properties)==null?void 0:s.$product_tour_id);if(a&&this.getActivatedIds().includes(a)){var c=this.ls(e,a);if(c==="consume")return i.info("event consumed activated item, removing it",{event:e,itemId:a}),void this.us([a]);if(c==="persist")return i.info("shown item promoted to persisted activation",{event:e,itemId:a}),void this.hs(a)}if(this.Qn.has(e)){var u=this.es(e,n,Qu.Cancellation);u.length>0&&(i.info("cancel event matched, cancelling items",{event:e,itemsToCancel:u.map((h=>h.id))}),this.us(u.map((h=>h.id))),u.forEach((h=>this.ds(h.id))))}if(this.Gn.has(e)){i.info("event name matched",{event:e,eventPayload:n,items:this.Gn.get(e)});var f=this.es(e,n,Qu.Activation);this.cs(f.map((h=>h.id)))}}onAction(e){this.Jn.has(e)&&this.cs(this.Jn.get(e)||[])}cs(e){e.length!==0&&(this.Zn=[...new Set([...this.Zn,...e])],this.os().info("updating activated items",{activatedItems:this.getActivatedIds()}))}hs(e){this.Zn=this.Zn.filter((r=>r!==e));var n=this.vs();n.includes(e)||(this.fs([...n,e]),this.ps())}us(e){var n=new Set(e);this.Zn=this.Zn.filter((i=>!n.has(i)));var r=this.gs(),s=r.filter((i=>!n.has(i)));s.length!==r.length&&(this.fs(s),s.length===0&&this.ys())}gs(){var e,n=this.bs();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[n])||[]}vs(){var e,n,r=this.gs();if(r.length===0)return[];var s=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[this._s()],i=(n=this._instance)==null||n.get_session_id==null?void 0:n.get_session_id();return i&&s===i?r:[]}ps(){var e,n=(e=this._instance)==null||e.get_session_id==null?void 0:e.get_session_id();n&&this.ws(n)}ys(){this.xs()}Kn(e){var n,r=(n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[this._s()];r&&r!==e&&(this.gs().length>0&&this.fs([]),this.ys())}getActivatedIds(){return[...new Set([...this.vs(),...this.Zn])].filter((e=>!this.ks(e)))}reset(){this.Zn=[],this.gs().length>0&&this.fs([]),this.ys()}getEventToItemsMap(){return this.Gn}Ss(){return this.ss}}class _D extends yD{constructor(e){super(e)}bs(){return Ey}_s(){return Cp}Cs(){return Ji.SHOWN}ts(e){var n;(n=this._instance)==null||n.getSurveys(e)}ds(e){var n;(n=this._instance)==null||n.cancelPendingSurvey(e)}os(){return yt}fs(e){var n;(n=this._instance)==null||(n=n.persistence)==null||n.register({[Ey]:e})}ws(e){var n;(n=this._instance)==null||(n=n.persistence)==null||n.register({[Cp]:e})}xs(){var e;(e=this._instance)==null||(e=e.persistence)==null||e.unregister(Cp)}ks(){return!1}ls(e,n){var r;this.ts((i=>{r=i.find((a=>a.id===n))}));var s=!r||(function(i){var a;return TP(i)&&!((a=i.conditions)==null||(a=a.events)==null||!a.repeatedActivation)||i.schedule==="always"})(r);return s?e===Ji.SHOWN?"consume":"ignore":e===Ji.SHOWN?"persist":e===Ji.DISMISSED||e===Ji.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var Qh="SDK is not enabled or survey functionality is not yet loaded",aC="Disabled. Not loading surveys.",xD=te!=null&&te.location?vm(te.location.hash,"__posthog")||vm(location.hash,"state"):null,lC="_postHogToolbarParams",cC=Vt("[Toolbar]"),un=Vt("[FeatureFlags]"),$a=Vt("[FeatureFlags]",{debugEnabled:!0}),Hv=`" failed. Feature flags didn't load in time.`,uC=t=>{for(var e={},n=0;t.length>n;n++)e[t[n]]=!0;return e},dC=t=>{var e={};for(var n of kp(t||{})){var r=n[1];r&&(e[n[0]]=r)}return e},Ni=Vt("[Error tracking]"),fC="Refusing to render web experiment since the viewer is a likely bot",wD={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>xm(e,t),not_regex:(t,e)=>!xm(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t};class Yn{get Te(){return this._instance.config}constructor(e){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(r){r===void 0&&(r=!1),n.getWebExperiments((s=>{Yn.Ms("retrieved web experiments from the server"),n.Is=new Map,s.forEach((i=>{if(i.feature_flag_key){var a;n.Is&&(Yn.Ms("setting flag key ",i.feature_flag_key," to web experiment ",i),(a=n.Is)==null||a.set(i.feature_flag_key,i));var c=n._instance.getFeatureFlag(i.feature_flag_key);xt(c)&&i.variants[c]&&n.Ts(i.name,c,i.variants[c].transforms)}else if(i.variants)for(var u in i.variants){var f=i.variants[u];Yn.Es(f,n._instance)&&n.Ts(i.name,u,f.transforms)}}))}),r)},this._instance=e,this._instance.onFeatureFlags((r=>{this.onFeatureFlags(r)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())Yn.Ms(fC);else if(!this.Te.disable_web_experiments){if(Je(this.Is))return this.Is=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Yn.Ms("applying feature flags",e),e.forEach((n=>{var r;if(this.Is&&(r=this.Is)!=null&&r.has(n)){var s,i=this._instance.getFeatureFlag(n),a=(s=this.Is)==null?void 0:s.get(n);i&&a!=null&&a.variants[i]&&this.Ts(a.name,i,a.variants[i].transforms)}}))}}previewWebExperiment(){var e=Yn.getWindowLocation();if(e!=null&&e.search){var n=Qc(e==null?void 0:e.search,"__experiment_id"),r=Qc(e==null?void 0:e.search,"__experiment_variant");n&&r&&(Yn.Ms("previewing web experiments "+n+" && "+r),this.getWebExperiments((s=>{this.Rs(parseInt(n),r,s)}),!1,!0))}}loadIfEnabled(){this.Te.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,n,r){if(this.Te.disable_web_experiments&&!r)return e([]);var s=this._instance.get_property("$web_experiments");if(s&&!n)return e(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Te.token),method:"GET",timestampMode:"query",callback:i=>e(i.statusCode===200&&i.json&&i.json.experiments||[])})}Rs(e,n,r){var s=r.filter((i=>i.id===e));s&&s.length>0&&(Yn.Ms("Previewing web experiment ["+s[0].name+"] with variant ["+n+"]"),this.Ts(s[0].name,n,s[0].variants[n].transforms))}static Es(e,n){return!Je(e.conditions)&&Yn.Ps(e,n)&&Yn.Os(e)}static Ps(e,n){var r;if(Je(e.conditions)||Je((r=e.conditions)==null?void 0:r.url))return!0;var s=Yn.getWindowLocation();if(s){var i,a,c,u=U6(n,s.href);return(i=e.conditions)==null||!i.url||wD[(a=(c=e.conditions)==null?void 0:c.urlMatchType)!==null&&a!==void 0?a:"icontains"](e.conditions.url,u)}return!1}static getWindowLocation(){return te==null?void 0:te.location}static Os(e){var n;if(Je(e.conditions)||Je((n=e.conditions)==null?void 0:n.utm))return!0;var r=oP();if(r.utm_source){var s,i,a,c,u,f,h,p,m=(s=e.conditions)==null||(s=s.utm)==null||!s.utm_campaign||((i=e.conditions)==null||(i=i.utm)==null?void 0:i.utm_campaign)==r.utm_campaign,_=(a=e.conditions)==null||(a=a.utm)==null||!a.utm_source||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_source)==r.utm_source,x=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_medium||((f=e.conditions)==null||(f=f.utm)==null?void 0:f.utm_medium)==r.utm_medium,y=(h=e.conditions)==null||(h=h.utm)==null||!h.utm_term||((p=e.conditions)==null||(p=p.utm)==null?void 0:p.utm_term)==r.utm_term;return m&&x&&y&&_}return!1}static Ms(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;n>s;s++)r[s-1]=arguments[s];_e.info("[WebExperiments] "+e,r)}Ts(e,n,r){this._is_bot()?Yn.Ms(fC):n!=="control"?r.forEach((s=>{if(s.selector){var i;Yn.Ms("applying transform of variant "+n+" for experiment "+e+" ",s);var a=(i=document)==null?void 0:i.querySelectorAll(s.selector);a==null||a.forEach((c=>{var u=c;s.html&&(u.innerHTML=s.html),s.css&&u.setAttribute("style",s.css)}))}})):Yn.Ms("Control variants leave the page unmodified.")}_is_bot(){return ar&&this._instance?EP(ar,this.Te.custom_blocked_useragents):void 0}}var ps=Vt("[Conversations]"),Ha="Conversations not available yet.",hC="console",n0={featureFlags:class{constructor(t){this.Fs=!1,this.As=!1,this.Ls=!1,this.$s=!1,this.Ns=!1,this.Ds=!1,this.qs=!1,this.js=!1,this.Hs=0,this.Bs=()=>{var e=this.Us();this.Hs=0,e&&this.reloadFeatureFlags()},this._instance=t,this.featureFlagEventHandlers=[],te&&zt(te,"online",this.Bs)}destroy(){te==null||te.removeEventListener("online",this.Bs)}get Te(){return this._instance.config}get mi(){return this._instance.persistence}zs(t){return this._instance.get_property(t)}Vs(){var t,e;return(t=(e=this.mi)==null?void 0:e._r(this.Te.feature_flag_cache_ttl_ms))!==null&&t!==void 0&&t}Ws(){return!!this.Vs()&&(this.js||this.Ls||(this.js=!0,un.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Zs(){var t,e=(t=this.Te.evaluation_contexts)!==null&&t!==void 0?t:this.Te.evaluation_environments;return!this.Te.evaluation_environments||this.Te.evaluation_contexts||this.qs||(un.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.qs=!0),e!=null&&e.length?e.filter((n=>{var r=n&&typeof n=="string"&&n.trim().length>0;return r||un.error("Invalid evaluation context found:",n,"Expected non-empty string"),r})):[]}Gs(){return this.Zs().length>0}Qs(){var t=this.Te.flag_keys;if(!ge(t)){if(Qe(t))return t.filter((e=>{var n=e&&typeof e=="string"&&e.trim().length>0;return n||un.error("Invalid flag key found:",e,"Expected non-empty string"),n}));un.error("Invalid flag_keys found:",t,"Expected array of non-empty strings")}}initialize(){var t,e,n=this._instance.config,r=(t=(e=n.bootstrap)==null?void 0:e.featureFlags)!==null&&t!==void 0?t:{};if(Object.keys(r).length){var s,i,a=(s=(i=n.bootstrap)==null?void 0:i.featureFlagPayloads)!==null&&s!==void 0?s:{},c=Object.keys(r).filter((f=>!!r[f])).reduce(((f,h)=>(f[h]=r[h]||!1,f)),{}),u=Object.keys(a).filter((f=>c[f])).reduce(((f,h)=>(a[h]&&(f[h]=a[h]),f)),{});this.receivedFeatureFlags({featureFlags:c,featureFlagPayloads:u})}}updateFlags(t,e,n){var r,s,i=n!=null&&n.merge&&(r=this.zs(tl))!==null&&r!==void 0?r:{},a=n!=null&&n.merge&&(s=this.zs(Ep))!==null&&s!==void 0?s:{},c=ue({},i,t),u=ue({},a,e),f={};for(var h of Object.entries(c)){var p=h[0],m=h[1];f[p]={key:p,enabled:pE(m),variant:mE(m),reason:void 0,metadata:ge(u==null?void 0:u[p])?void 0:{id:0,version:void 0,description:void 0,payload:u[p]}}}this.receivedFeatureFlags({flags:f})}get hasLoadedFlags(){return this.As}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.zs(wy),e=this.zs(zi),n=this.zs(pc);if(!n&&!e)return t||{};var r=At({},t||{}),s=[...new Set([...Object.keys(n||{}),...Object.keys(e||{})])];for(var i of s){var a,c,u=r[i],f=e==null?void 0:e[i],h=ge(f)?(a=u==null?void 0:u.enabled)!==null&&a!==void 0&&a:!!f,p=ge(f)?u.variant:typeof f=="string"?f:void 0,m=n==null?void 0:n[i],_=ue({},u,{enabled:h,variant:h?p??(u==null?void 0:u.variant):void 0});h!==(u==null?void 0:u.enabled)&&(_.original_enabled=u==null?void 0:u.enabled),p!==(u==null?void 0:u.variant)&&(_.original_variant=u==null?void 0:u.variant),m&&(_.metadata=ue({},u==null?void 0:u.metadata,{payload:m,original_payload:u==null||(c=u.metadata)==null?void 0:c.payload})),r[i]=_}return this.Fs||(un.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:n,finalDetails:r}),this.Fs=!0),r}getAllFeatureFlags(){var t=this.getFlagVariants(),e=this.getFlagPayloads();return Object.keys(t).map((n=>{var r=t[n];return{key:n,enabled:pE(r),variant:mE(r),payload:hE(e[n])}}))}getFlagVariants(){var t=this.zs(tl),e=this.zs(zi);if(!e)return t||{};for(var n=At({},t),r=Object.keys(e),s=0;r.length>s;s++)n[r[s]]=e[r[s]];return this.Fs||(un.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:n}),this.Fs=!0),n}getFlagPayloads(){var t=this.zs(Ep),e=this.zs(pc);if(!e)return t||{};for(var n=At({},t||{}),r=Object.keys(e),s=0;r.length>s;s++)n[r[s]]=e[r[s]];return this.Fs||(un.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:n}),this.Fs=!0),n}reloadFeatureFlags(){this.$s||this.Te.advanced_disable_feature_flags||this.Us()||this.Js||(this._instance.en.emit("featureFlagsReloading",!0),this.Js=setTimeout((()=>{this.Ks()}),5))}Ys(){clearTimeout(this.Js),this.Js=void 0}ensureFlagsLoaded(){this.As||this.Ls||this.Js||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.$s=t}Ks(t){var e;if(this.Ys(),!this._instance.Ur()&&!this.Us())if(this.Ls)this.Ns=!0;else{var n=this.Te.token,r=this.zs(am),s={token:n,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:ue({},((e=this.mi)==null?void 0:e.get_initial_props())||{},this.zs(Ya)||{},{$lib:gt.LIB_NAME,$lib_version:gt.LIB_VERSION}),group_properties:this.zs(Xa),timezone:fP()};dr(r)||ge(r)||(s.$device_id=r),(t!=null&&t.disableFlags||this.Te.advanced_disable_feature_flags)&&(s.disable_flags=!0),this.Gs()&&(s.evaluation_contexts=this.Zs());var i=this.Qs();ge(i)||(s.flag_keys=i);var a=!!this.Te.advanced_only_evaluate_survey_feature_flags,c=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.Te.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.Ls=!0,this._instance._send_request({method:"POST",url:c,data:s,compression:this.Te.disable_compression?void 0:or.Base64,timestampMode:"body",timeout:this.Te.feature_flag_request_timeout_ms,callback:u=>{var f,h,p,m=!0;if(this.Xs(u.statusCode),u.statusCode===200&&(this.Ns||(this.$anon_distinct_id=void 0),m=!1),this.Ls=!1,!s.disable_flags||this.Ns){this.Ds=!m;var _=[];u.error?u.error instanceof Error?_.push(u.error.name==="AbortError"?"timeout":"connection_error"):_.push("unknown_error"):u.statusCode!==200&&_.push("api_error_"+u.statusCode),(f=u.json)!=null&&f.errorsWhileComputingFlags&&_.push("errors_while_computing_flags");var x,y=!((h=u.json)==null||(h=h.quotaLimited)==null||!h.includes("feature_flags"));y&&_.push("quota_limited"),(p=this.mi)==null||p.register({[ky]:_}),y?un.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):(s.disable_flags||this.receivedFeatureFlags((x=u.json)!==null&&x!==void 0?x:{},m,{partialResponse:a}),this.Ns&&(this.Ns=!1,this.Ks()))}}})}}Us(){return sP(this.Hs,3)}Xs(t){this.Hs=iP(t,this.Hs,3,(()=>un.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes.")))}getFeatureFlag(t,e){var n;if(e===void 0&&(e={}),!e.fresh||this.Ds)if(this.As||this.getFlags()&&this.getFlags().length>0){if(!this.Ws()){var r=this.getFeatureFlagResult(t,e);return(n=r==null?void 0:r.variant)!==null&&n!==void 0?n:r==null?void 0:r.enabled}}else un.warn('getFeatureFlag for key "'+t+Hv)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var e=this.getFeatureFlagResult(t,{send_event:!1});return e==null?void 0:e.payload}getFeatureFlagResult(t,e){if(e===void 0&&(e={}),!e.fresh||this.Ds)if(this.As||this.getFlags()&&this.getFlags().length>0){if(!this.Ws()){var n=this.getFlagVariants(),r=t in n,s=n[t],i=this.getFlagPayloads()[t],a=String(s),c=this.zs(by)||void 0,u=this.zs($d)||void 0,f=this.zs(bd)||{};if(this.Te.advanced_feature_flags_dedup_per_session){var h,p=this._instance.get_session_id(),m=this.zs(Cy);p&&p!==m&&(f={},(h=this.mi)==null||h.register({[bd]:f,[Cy]:p}))}if((e.send_event||!("send_event"in e))&&(!(t in f)||!f[t].includes(a))){var _,x,y,w,S,T,P,k,R,L,O;Qe(f[t])?f[t].push(a):f[t]=[a],(_=this.mi)==null||_.register({[bd]:f});var A=this.getFeatureFlagDetails(t),I=[...(x=this.zs(ky))!==null&&x!==void 0?x:[]];ge(s)&&I.push("flag_missing");var N={$feature_flag:t,$feature_flag_response:s,$feature_flag_payload:i||null,$feature_flag_request_id:c,$feature_flag_evaluated_at:u,$feature_flag_bootstrapped_response:((y=this.Te.bootstrap)==null||(y=y.featureFlags)==null?void 0:y[t])||null,$feature_flag_bootstrapped_payload:((w=this.Te.bootstrap)==null||(w=w.featureFlagPayloads)==null?void 0:w[t])||null,$used_bootstrap_value:!this.Ds};ge(A==null||(S=A.metadata)==null?void 0:S.has_experiment)||(N.$feature_flag_has_experiment=A.metadata.has_experiment),ge(A==null||(T=A.metadata)==null?void 0:T.version)||(N.$feature_flag_version=A.metadata.version);var j,F=(P=A==null||(k=A.reason)==null?void 0:k.description)!==null&&P!==void 0?P:A==null||(R=A.reason)==null?void 0:R.code;F&&(N.$feature_flag_reason=F),A!=null&&(L=A.metadata)!=null&&L.id&&(N.$feature_flag_id=A.metadata.id),ge(A==null?void 0:A.original_variant)&&ge(A==null?void 0:A.original_enabled)||(N.$feature_flag_original_response=ge(A.original_variant)?A.original_enabled:A.original_variant),A!=null&&(O=A.metadata)!=null&&O.original_payload&&(N.$feature_flag_original_payload=A==null||(j=A.metadata)==null?void 0:j.original_payload),I.length&&(N.$feature_flag_error=I.join(",")),this._instance.capture("$feature_flag_called",N)}if(r)return{key:t,enabled:!!s,variant:typeof s=="string"?s:void 0,payload:hE(i)}}}else un.warn('getFeatureFlagResult for key "'+t+Hv)}getRemoteConfigPayload(t,e){var n=this.Te.token,r={distinct_id:this._instance.get_distinct_id(),token:n,person_properties:{$lib:gt.LIB_NAME,$lib_version:gt.LIB_VERSION}};this.Gs()&&(r.evaluation_contexts=this.Zs());var s=this.Qs();ge(s)||(r.flag_keys=s),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this.Te.disable_compression?void 0:or.Base64,timestampMode:"body",timeout:this.Te.feature_flag_request_timeout_ms,callback(i){var a,c=(a=i.json)==null?void 0:a.featureFlagPayloads;e((c==null?void 0:c[t])||void 0)}})}isFeatureEnabled(t,e){if(e===void 0&&(e={}),e.fresh&&!this.Ds)return e.defaultValue;if(!(this.As||this.getFlags()&&this.getFlags().length>0))return un.warn('isFeatureEnabled for key "'+t+Hv),e.defaultValue;var n=this.getFeatureFlag(t,e);return ge(n)?e.defaultValue:!!n}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==t))}receivedFeatureFlags(t,e,n){if(this.mi){this.As=!0;var r=this.getFlagVariants(),s=this.getFlagPayloads(),i=this.getFlagsWithDetails();(function(a,c,u,f,h,p){u===void 0&&(u={}),f===void 0&&(f={}),h===void 0&&(h={});var m=(A=>{var I=A.flags;return I?(A.featureFlags=Object.fromEntries(Object.keys(I).map((N=>{var j;return[N,(j=I[N].variant)!==null&&j!==void 0?j:I[N].enabled]}))),A.featureFlagPayloads=Object.fromEntries(Object.keys(I).filter((N=>I[N].enabled)).filter((N=>{var j;return(j=I[N].metadata)==null?void 0:j.payload})).map((N=>{var j;return[N,(j=I[N].metadata)==null?void 0:j.payload]})))):A.featureFlags&&un.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),A})(a),_=m.flags,x=m.featureFlags,y=m.featureFlagPayloads;if(x){var w=a.requestId,S=a.evaluatedAt;if(Qe(x)){un.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var T={};if(x)for(var P=0;x.length>P;P++)T[x[P]]=!0;c&&c.register({[Sp]:x,[tl]:T,[lm]:!1})}else{var k=x,R=y,L=_;if(p!=null&&p.partialResponse)k=ue({},u,k),R=ue({},f,R),L=ue({},h,L);else if(a.errorsWhileComputingFlags)if(_){var O=new Set(Object.keys(_).filter((A=>{var I;return!((I=_[A])!=null&&I.failed)})));k=ue({},u,Object.fromEntries(Object.entries(k).filter((A=>O.has(A[0]))))),R=ue({},f,Object.fromEntries(Object.entries(R||{}).filter((A=>O.has(A[0]))))),L=ue({},h,Object.fromEntries(Object.entries(L||{}).filter((A=>O.has(A[0])))))}else k=ue({},u,k),R=ue({},f,R),L=ue({},h,L);c&&c.register(ue({[Sp]:Object.keys(dC(k)),[tl]:k||{},[Ep]:R||{},[wy]:L||{},[lm]:a.minimalFlagCalledEvents===!0},w?{[by]:w}:{},S?{[$d]:S}:{}))}}})(t,this.mi,r,s,i,n),e||(this.js=!1),this.eo(e)}}override(t,e){e===void 0&&(e=!1),un.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.mi)return un.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(t===!1)return this.mi.unregister(zi),this.mi.unregister(pc),this.eo(),$a.info("All overrides cleared");if(Qe(t)){var e=uC(t);return this.mi.register({[zi]:e}),this.eo(),$a.info("Flag overrides set",{flags:t})}if(t&&typeof t=="object"&&("flags"in t||"payloads"in t)){var n,r=t;if(this.Fs=!!((n=r.suppressWarning)!==null&&n!==void 0&&n),"flags"in r){if(r.flags===!1)this.mi.unregister(zi),$a.info("Flag overrides cleared");else if(r.flags){if(Qe(r.flags)){var s=uC(r.flags);this.mi.register({[zi]:s})}else this.mi.register({[zi]:r.flags});$a.info("Flag overrides set",{flags:r.flags})}}return"payloads"in r&&(r.payloads===!1?(this.mi.unregister(pc),$a.info("Payload overrides cleared")):r.payloads&&(this.mi.register({[pc]:r.payloads}),$a.info("Payload overrides set",{payloads:r.payloads}))),void this.eo()}if(t&&typeof t=="object")return this.mi.register({[zi]:t}),this.eo(),$a.info("Flag overrides set",{flags:t});un.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.As){var e=this.ro(),n=e.flags,r=e.flagVariants;try{t(n,r)}catch(s){un.error("Error while running feature flags callback",s)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,n){var r,s=(this.zs(md)||[]).find((u=>u.flagKey===t)),i={["$feature_enrollment/"+t]:e},a={$feature_flag:t,$feature_enrollment:e,$set:i};s&&(a.$early_access_feature_name=s.name),n&&(a.$feature_enrollment_stage=n),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(i,!1);var c=ue({},this.getFlagVariants(),{[t]:e});(r=this.mi)==null||r.register({[Sp]:Object.keys(dC(c)),[tl]:c}),this.eo()}getEarlyAccessFeatures(t,e,n){e===void 0&&(e=!1);var r=this.zs(md),s=n?"&"+n.map((i=>"stage="+i)).join("&"):"";if(r&&!e)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.Te.token+s),method:"GET",timestampMode:"query",callback:i=>{var a,c;if(i.json){var u=i.json.earlyAccessFeatures;return(a=this.mi)==null||a.unregister(md),(c=this.mi)==null||c.register({[md]:u}),t(u)}}})}ro(){var t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter((n=>e[n])),flagVariants:Object.keys(e).filter((n=>e[n])).reduce(((n,r)=>(n[r]=e[r],n)),{})}}eo(t){var e=this.ro(),n=e.flags,r=e.flagVariants;this.featureFlagEventHandlers.forEach((s=>{try{s(n,r,{errorsLoading:t})}catch(i){un.error("Error while running feature flags callback",i)}}))}setPersonPropertiesForFlags(t,e){e===void 0&&(e=!0);var n=this.zs(Ya)||{},r=(t==null?void 0:t.$set)||(t!=null&&t.$set_once?{}:t),s=t==null?void 0:t.$set_once,i={};if(s)for(var a in s)({}).hasOwnProperty.call(s,a)&&(a in n||(i[a]=s[a]));this._instance.register({[Ya]:ue({},n,i,r)}),e&&this._instance.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e){e===void 0&&(e=!0);var n=ue({},this.zs(Ya)||{});t.forEach((r=>{delete n[r]})),this._instance.register({[Ya]:n}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){t===void 0&&(t=!0),this._instance.unregister(Ya),t&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){e===void 0&&(e=!0);var n=this.zs(Xa)||{};Object.keys(n).length!==0&&Object.keys(n).forEach((r=>{n[r]=ue({},n[r],t[r]),delete t[r]})),this._instance.register({[Xa]:ue({},n,t)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.zs(Xa)||{};this._instance.register({[Xa]:ue({},e,{[t]:{}})})}else this._instance.unregister(Xa)}reset(){this.As=!1,this.Ls=!1,this.$s=!1,this.Ns=!1,this.Ds=!1,this.$anon_distinct_id=void 0,this.Ys(),this.Fs=!1,this.Hs=0}}},bD={sessionRecording:class{get Te(){return this._instance.config}get mi(){return this._instance.persistence}get started(){var t;return!((t=this.io)==null||!t.isStarted)}get status(){var t,e;return this.no===id||this.no===Xh?this.no:(t=(e=this.io)==null?void 0:e.status)!==null&&t!==void 0?t:this.no}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.no=sC,this.so=void 0,this._instance=t,!this._instance.sessionManager)throw Li.error("started without valid sessionManager"),new Error(Hy+" started without valid sessionManager. This is a bug.");if(this.Te.cookieless_mode===Xi)throw new Error(Hy+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get oo(){var t,e=!((t=this._instance.get_property(sl))==null||!t.enabled),n=!this.Te.disable_session_recording,r=this.Te.disable_session_recording||this._instance.consent.isOptedOut();return te&&e&&n&&!r}startIfEnabledOrStop(t){var e;if(!this.oo||(e=this.io)==null||!e.isStarted){var n=!ge(Object.assign)&&!ge(Array.from);this.oo&&n?(this.ao(t),Li.info("starting")):(this.no=sC,this.stopRecording())}}ao(t){var e,n,r;this.oo&&(this.no!==id&&this.no!==Xh&&(this.no=iC),$e!=null&&(e=$e.__PosthogExtensions__)!=null&&(e=e.rrweb)!=null&&e.record&&(n=$e.__PosthogExtensions__)!=null&&n.initSessionRecording?this.lo(t):(r=$e.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,this.uo,(s=>{if(s)return Li.error("could not load recorder",s);this.lo(t)})))}stopRecording(){var t,e;(t=this.so)==null||t.call(this),this.so=void 0,(e=this.io)==null||e.stop()}ho(){var t,e;(t=this.so)==null||t.call(this),this.so=void 0,(e=this.io)==null||e.discard()}do(){var t,e;(t=this.mi)==null||t.unregister(C2),(e=this.mi)==null||e.unregister(I6)}co(t,e){if(Je(t))return null;var n,r=$n(t)?t:parseFloat(t);return typeof(n=r)!="number"||!Number.isFinite(n)||0>n||n>1?(Li.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}vo(t){if(this.mi){var e,n,r=this.mi,s=()=>{var i,a=t.sessionRecording===!1?void 0:t.sessionRecording,c=this.co((i=this.Te.session_recording)==null?void 0:i.sampleRate,"session_recording.sampleRate"),u=this.co(a==null?void 0:a.sampleRate,"remote config sampleRate"),f=c??u;Je(f)&&this.do();var h=a==null?void 0:a.minimumDurationMilliseconds;r.register({[sl]:ue({cache_timestamp:Date.now(),enabled:!!a},a,{networkPayloadCapture:ue({capturePerformance:t.capturePerformance},a==null?void 0:a.networkPayloadCapture),canvasRecording:{enabled:a==null?void 0:a.recordCanvas,fps:a==null?void 0:a.canvasFps,quality:a==null?void 0:a.canvasQuality},sampleRate:f,minimumDurationMilliseconds:ge(h)?null:h,endpoint:a==null?void 0:a.endpoint,triggerMatchType:a==null?void 0:a.triggerMatchType,masking:a==null?void 0:a.masking,urlTriggers:a==null?void 0:a.urlTriggers,version:a==null?void 0:a.version,triggerGroups:a==null?void 0:a.triggerGroups})})};s(),(e=this.so)==null||e.call(this),this.so=(n=this._instance.sessionManager)==null?void 0:n.onSessionId(s)}}onRemoteConfig(t){var e=t.ok?t.config:void 0;return e&&"sessionRecording"in e?e.sessionRecording===!1?(this.vo(e),void this.ho()):(this.vo(e),void this.startIfEnabledOrStop()):(this.no===id&&(this.no=Xh,Li.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e){var n;e===void 0&&(e="log"),(n=this.io)!=null&&n.log?this.io.log(t,e):Li.warn("log called before recorder was ready")}get uo(){var t,e,n=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.get_property(sl);return(n==null||(e=n.scriptConfig)==null?void 0:e.script)||"lazy-recorder"}fo(){var t,e,n=this._instance.get_property(sl);if(!n)return!1;try{e=typeof n=="object"?n:JSON.parse(n)}catch(s){return Li.warn("persisted remote config for session recording is invalid and will be ignored",s),!1}var r=(t=e.cache_timestamp)!==null&&t!==void 0?t:Date.now();return 36e5>=Date.now()-r}lo(t){var e,n;if((e=$e.__PosthogExtensions__)==null||!e.initSessionRecording)return Li.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[V6]:!0});if(this.io||(this.io=(n=$e.__PosthogExtensions__)==null?void 0:n.initSessionRecording(this._instance),this.io._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.fo())return this.no===Xh||this.no===id?void 0:(this.no=id,Li.info("persisted remote config is stale, requesting fresh config before starting"),void new hP(this._instance).load());this.no=iC,this.io.start(t)}onRRwebEmit(t){var e;(e=this.io)==null||e.onRRwebEmit==null||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.io||(e=this.mi)==null||e.register({[O6]:!0}),(t=this.io)==null||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.io||(e=this.mi)==null||e.register({[M6]:!0}),(t=this.io)==null||t.overrideSampling()}overrideTrigger(t){var e,n;this.io||(n=this.mi)==null||n.register({[t==="url"?L6:N6]:!0}),(e=this.io)==null||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return((t=this.io)==null?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var n;return!((n=this.io)==null||!n.tryAddCustomEvent(t,e))}}},SD={autocapture:class{constructor(t){this.po=!1,this.mo=null,this.yo=!1,this.bo=!1,this.instance=t,this.rageclicks=new tC(t.config.rageclick),this._o=null}initialize(){this.startIfEnabled()}get Te(){var t,e,n=Nt(this.instance.config.autocapture)?this.instance.config.autocapture:{};return n.url_allowlist=(t=n.url_allowlist)==null?void 0:t.map((r=>new RegExp(r))),n.url_ignorelist=(e=n.url_ignorelist)==null?void 0:e.map((r=>new RegExp(r))),n}wo(){if(this.isBrowserSupported()){if(te&&Se){var t=n=>{n=n||(te==null?void 0:te.event);try{this.xo(n)}catch(r){Dv.error("Failed to capture event",r)}};if(zt(Se,"submit",t,{capture:!0}),zt(Se,"change",t,{capture:!0}),zt(Se,"click",t,{capture:!0}),this.Te.capture_copied_text){var e=n=>{n=n||(te==null?void 0:te.event);try{this.xo(n,Nv)}catch(r){Dv.error("Failed to capture copy/cut event",r)}};zt(Se,"copy",e,{capture:!0}),zt(Se,"cut",e,{capture:!0})}}}else Dv.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.po&&(this.wo(),this.po=!0)}onRemoteConfig(t){if(this.yo=!0,t.ok){var e=t.config;e.elementsChainAsString&&(this.bo=e.elementsChainAsString);var n=e.autocapture_opt_out;Us(n)&&(this.instance.persistence&&this.instance.persistence.register({[py]:n}),this.mo=n),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this._o=t}getElementSelectors(t){var e,n=[];return(e=this._o)==null||e.forEach((r=>{var s=Se==null?void 0:Se.querySelectorAll(r);s==null||s.forEach((i=>{t===i&&n.push(r)}))})),n}get isEnabled(){var t,e,n=(t=this.instance.persistence)==null?void 0:t.props[py],r=this.mo,s=this.instance.Ur()&&!this.yo;if(dr(r)&&!Us(n)&&!s)return!1;var i=(e=this.mo)!==null&&e!==void 0?e:!!n;return!!this.instance.config.autocapture&&!i}xo(t,e){if(e===void 0&&(e="$autocapture"),this.isEnabled){var n,r=Ev(t);W6(r)&&(r=r.parentNode||null),e==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&this.instance.config.rageclick&&(n=this.rageclicks)!=null&&n.isRageClick(t.clientX,t.clientY,t.timeStamp||new Date().getTime())&&NE(r,this.instance.config.rageclick)&&this.xo(t,"$rageclick");var s=e===Nv;if(r&&(function(p,m,_,x,y,w){var S;if(!te||A2(p)||_!=null&&_.url_allowlist&&!ME(_.url_allowlist,w)||_!=null&&_.url_ignorelist&&ME(_.url_ignorelist,w))return!1;if(_!=null&&_.dom_event_allowlist){var T=_.dom_event_allowlist;if(T&&!T.some((A=>m.type===A)))return!1}var P=X6(p,x),k=P.parentIsUsefulElement,R=P.targetElementList;if(!(function(A,I){var N=I==null?void 0:I.element_allowlist;if(ge(N))return!0;var j,F=function(X){if(N.some((W=>X.tagName.toLowerCase()===W)))return{v:!0}};for(var K of A)if(j=F(K))return j.v;return!1})(R,_)||!My(R,_==null?void 0:_.css_selector_allowlist)||My(R,(S=_==null?void 0:_.css_selector_ignorelist)!==null&&S!==void 0?S:SN))return!1;try{var L=te.getComputedStyle(p);if(L&&L.getPropertyValue("cursor")==="pointer"&&m.type==="click")return!0}catch{}var O=p.tagName.toLowerCase();switch(O){case"html":return!1;case"form":return(y||["submit"]).indexOf(m.type)>=0;case"input":case"select":case"textarea":return(y||["change","click"]).indexOf(m.type)>=0;default:return k?(y||["click"]).indexOf(m.type)>=0:(y||["click"]).indexOf(m.type)>=0&&(R2.indexOf(O)>-1||p.getAttribute("contenteditable")==="true")}})(r,t,this.Te,s,s?["copy","cut"]:void 0,this.instance)){var i=hD(r,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Te.element_attribute_ignorelist,elementsChainAsString:this.bo,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes}),a=i.props;if(i.explicitNoCapture)return!1;var c=this.getElementSelectors(r);if(c&&c.length>0&&(a.$element_selectors=c),e===Nv){var u,f=Z6(te==null||(u=te.getSelection())==null?void 0:u.toString()),h=t.type||"clipboard";if(!f)return!1;a.$selected_content=f,a.$copy_type=h}return this.instance.capture(e,a),!0}}}isBrowserSupported(){return zs(Se==null?void 0:Se.querySelectorAll)}},historyAutocapture:class{constructor(t){var e;this._instance=t,this.ko=(te==null||(e=te.location)==null?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(_e.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.So&&this.So(),this.So=void 0,_e.info("History API monitoring stopped")}monitorHistoryChanges(){te&&te.history&&(this.Co("pushState"),this.Co("replaceState"),this.Mo())}Co(t){var e;if(te&&((e=te.history[t])==null||!e.__posthog_wrapped__)){var n=this;(function(r,s,i){try{if(!(s in r))return nC;var a={next:r[s]},c=i((function(){for(var u=arguments.length,f=new Array(u),h=0;u>h;h++)f[h]=arguments[h];return a.next.apply(this,f)}));return zs(c)&&(c.prototype=c.prototype||{},Object.defineProperties(c,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:a}})),r[s]=c,()=>{if(r[s]!==c)for(var u=r[s];zs(u)&&u.__posthog_layer__;){var f=u.__posthog_layer__;if(f.next===c)return void(f.next=a.next);u=f.next}else r[s]=a.next}}catch{return nC}})(te.history,t,(r=>function(s,i,a){r.call(this,s,i,a),n.Io(t)}))}}Io(t){try{var e,n=te==null||(e=te.location)==null?void 0:e.pathname;if(!n)return;n!==this.ko&&this.isEnabled&&this._instance.capture(mc,{navigation_type:t}),this.ko=n}catch(r){_e.error("Error capturing "+t+" pageview",r)}}Mo(){if(!this.So){var t=()=>{this.Io("popstate")};zt(te,"popstate",t),this.So=()=>{te&&te.removeEventListener("popstate",t)}}}},heatmaps:class{get Te(){return this.instance.config}constructor(t){var e;this.To=!1,this.po=!1,this.Eo=null,this.instance=t,this.To=!((e=this.instance.persistence)==null||!e.props[my]),this.rageclicks=new tC(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return Nt(this.Te.capture_heatmaps)&&this.Te.capture_heatmaps.flush_interval_milliseconds&&(t=this.Te.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return Je(this.Te.capture_heatmaps)?Je(this.Te.enable_heatmaps)?this.To:this.Te.enable_heatmaps:this.Te.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.po)return;mD.info("starting..."),this.Ro(),this.xe()}else{var t;clearInterval((t=this.Eo)!==null&&t!==void 0?t:void 0),this.Po(),this.getAndClearBuffer()}}onRemoteConfig(t){if(t.ok){var e=t.config;if("heatmaps"in e){var n=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[my]:n}),this.To=n,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.R;return this.R=void 0,t}Oo(t){Fv(t.originalEvent)&&this.pe(t.originalEvent,"deadclick")}xe(){this.Eo&&clearInterval(this.Eo),this.Eo=(Se==null?void 0:Se.visibilityState)==="visible"?setInterval(this.oi.bind(this),this.flushIntervalMilliseconds):null}Ro(){te&&Se&&(this.Fo=this.oi.bind(this),zt(te,hm,this.Fo),this.Ao=t=>this.pe(t||(te==null?void 0:te.event)),zt(Se,"click",this.Ao,{capture:!0}),this.Lo=t=>this.$o(t||(te==null?void 0:te.event)),zt(Se,"mousemove",this.Lo,{capture:!0}),this.No=new FE(this.instance,IN,this.Oo.bind(this)),this.No.startIfEnabledOrStop(),this.Do=this.xe.bind(this),zt(Se,fm,this.Do),this.po=!0)}Po(){var t;te&&Se&&(this.Fo&&te.removeEventListener(hm,this.Fo),this.Ao&&Se.removeEventListener("click",this.Ao,{capture:!0}),this.Lo&&Se.removeEventListener("mousemove",this.Lo,{capture:!0}),this.Do&&Se.removeEventListener(fm,this.Do),clearTimeout(this.qo),(t=this.No)==null||t.stop(),this.po=!1)}jo(t,e){var n=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),i=(function(a,c,u){for(var f=a;f&&ia(f)&&!qr(f,"body");){if(f===u)return!1;var h=void 0;try{var p,m,_;h=(p=(m=(_=f.ownerDocument)==null?void 0:_.defaultView)!==null&&m!==void 0?m:te)==null?void 0:p.getComputedStyle(f).position}catch{return!1}if(Ge(c,h))return!0;f=q6(f)}return!1})(Ev(t),["fixed","sticky"],s);return{x:t.clientX+(i?0:r),y:t.clientY+(i?0:n),target_fixed:i,type:e}}pe(t,e){var n;if(e===void 0&&(e="click"),!IE(t.target)&&Fv(t)){var r=this.jo(t,e);(n=this.rageclicks)!=null&&n.isRageClick(t.clientX,t.clientY,new Date().getTime())&&NE(Ev(t),this.instance.config.rageclick)&&this.Nt(ue({},r,{type:"rageclick"})),this.Nt(r)}}$o(t){!IE(t.target)&&Fv(t)&&(clearTimeout(this.qo),this.qo=setTimeout((()=>{this.Nt(this.jo(t,"mousemove"))}),500))}Nt(t){if(te){var e=this.Te.disable_capture_url_hashes?sa(te.location.href):te.location.href,n=this.Te.custom_personal_data_properties,r=this.Te.mask_personal_data_properties?[...Jc,...n||[]]:[],s=zd(e,r,Ud);this.R=this.R||{},this.R[s]||(this.R[s]=[]),this.R[s].push(t)}}oi(){this.R&&!Zo(this.R)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:FE,webVitalsAutocapture:class{constructor(t){var e;this.To=!1,this.po=!1,this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Ho=()=>{clearTimeout(this.Bo),this.R.metrics.length!==0&&(this._instance.capture("$web_vitals",this.R.metrics.reduce(((n,r)=>ue({},n,{["$web_vitals_"+r.name+"_event"]:ue({},r),["$web_vitals_"+r.name+"_value"]:r.value})),{})),this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Uo=n=>{var r;this.R=this.R||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var s=this.zo();if(!ge(s))if(Je(n==null?void 0:n.name)||Je(n==null?void 0:n.value))Va.error("Invalid metric received",n);else if(!this.Vo||this.Vo>n.value){this.R.url!==s&&(this.Ho(),this.Bo=setTimeout(this.Ho,this.flushToCaptureTimeoutMs)),ge(this.R.url)&&(this.R.url=s),this.R.firstMetricTimestamp=ge(this.R.firstMetricTimestamp)?Date.now():this.R.firstMetricTimestamp,n.attribution&&n.attribution.interactionTargetElement&&(n.attribution.interactionTargetElement=void 0);var i=(r=this._instance.sessionManager)==null?void 0:r.checkAndGetSessionAndWindowId(!0),a=ue({},n,{$current_url:s,timestamp:Date.now()});ge(i)||(a.$session_id=i.sessionId,a.$window_id=i.windowId),this.R.metrics.push(a),this.R.metrics.length===this.allowedMetrics.length&&this.Ho()}else Va.error("Ignoring metric with value >= "+this.Vo,n)},this.Wo=()=>{if(!this.po){var n,r,s,i,a=$e.__PosthogExtensions__;if(!ge(a)&&!ge(a.postHogWebVitalsCallbacks)){var c=a.postHogWebVitalsCallbacks;n=c.onLCP,r=c.onCLS,s=c.onFCP,i=c.onINP}n&&r&&s&&i?(this.allowedMetrics.indexOf("LCP")>-1&&n(this.Uo.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&r(this.Uo.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&s(this.Uo.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&i(this.Uo.bind(this)),this.po=!0):Va.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.To=!((e=this._instance.persistence)==null||!e.props[_y]),this.startIfEnabled()}get Zo(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,n=Nt(this.Zo)?(t=this.Zo)==null?void 0:t.web_vitals_allowed_metrics:void 0;return Je(n)?((e=this._instance.persistence)==null?void 0:e.props[xy])||["CLS","FCP","INP","LCP"]:n}get flushToCaptureTimeoutMs(){return(Nt(this.Zo)?this.Zo.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=Nt(this.Zo)?this.Zo.web_vitals_attribution:void 0;return t!=null&&t}get Vo(){var t=Nt(this.Zo)&&$n(this.Zo.__web_vitals_max_value)?this.Zo.__web_vitals_max_value:rC;return t>0&&6e4>=t?rC:t}get isEnabled(){var t=rn==null?void 0:rn.protocol;if(t!=="http:"&&t!=="https:")return Va.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=Nt(this.Zo)?this.Zo.web_vitals:Us(this.Zo)?this.Zo:void 0;return Us(e)?e:this.To}startIfEnabled(){this.isEnabled&&!this.po&&(Va.info("enabled, starting..."),this.er(this.Wo))}onRemoteConfig(t){if(t.ok){var e=t.config;if("capturePerformance"in e){var n=Nt(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=Nt(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[_y]:n}),this._instance.persistence.register({[xy]:r})),this.To=n,this.startIfEnabled()}}}er(t){var e,n;(e=$e.__PosthogExtensions__)!=null&&e.postHogWebVitalsCallbacks?t():(n=$e.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(r=>{r?Va.error("failed to load script",r):t()}))}zo(){var t=te?this._instance.config.disable_capture_url_hashes?sa(te.location.href):te.location.href:void 0;if(t){var e=this._instance.config.custom_personal_data_properties,n=this._instance.config.mask_personal_data_properties?[...Jc,...e||[]]:[];return zd(t,n,Ud)}Va.error("Could not determine current URL")}}},ED={exceptionObserver:class{constructor(t){var e;this.Wo=()=>{var n;if(te&&this.isEnabled&&(n=$e.__PosthogExtensions__)!=null&&n.errorWrappingFunctions){var r=$e.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,s=$e.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,i=$e.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Go&&this.Te.capture_unhandled_errors&&(this.Go=r(this.captureException.bind(this))),!this.Qo&&this.Te.capture_unhandled_rejections&&(this.Qo=s(this.captureException.bind(this))),!this.Jo&&this.Te.capture_console_errors&&(this.Jo=i(this.captureException.bind(this)))}catch(a){sd.error("failed to start",a),this.Ko()}}},this._instance=t,this.Yo=!((e=this._instance.persistence)==null||!e.props[gy]),this.Xo=new CL(ue({},(function(n){var r,s,i,a;return n===void 0&&(n={}),{refillRate:(r=(s=n.exceptionRateLimiterRefillRate)!==null&&s!==void 0?s:n.__exceptionRateLimiterRefillRate)!==null&&r!==void 0?r:1,bucketSize:(i=(a=n.exceptionRateLimiterBucketSize)!==null&&a!==void 0?a:n.__exceptionRateLimiterBucketSize)!==null&&i!==void 0?i:10}})(this._instance.config.error_tracking),{refillInterval:1e4,Ge:sd})),this.Te=this.ea(),this.startIfEnabledOrStop()}ea(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Nt(t)?e=ue({},e,t):(ge(t)?this.Yo:t)&&(e=ue({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Te.capture_console_errors||this.Te.capture_unhandled_errors||this.Te.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(sd.info("enabled"),this.Ko(),this.er(this.Wo)):this.Ko()}er(t){var e,n;(e=$e.__PosthogExtensions__)!=null&&e.errorWrappingFunctions?t():(n=$e.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"exception-autocapture",(r=>{if(r)return sd.error("failed to load script",r);t()}))}Ko(){var t,e,n;(t=this.Go)==null||t.call(this),this.Go=void 0,(e=this.Qo)==null||e.call(this),this.Qo=void 0,(n=this.Jo)==null||n.call(this),this.Jo=void 0}onRemoteConfig(t){if(t.ok){var e=t.config;"autocaptureExceptions"in e&&(this.Yo=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[gy]:this.Yo}),this.Te=this.ea(),this.startIfEnabledOrStop())}}onConfigChange(){this.Te=this.ea()}captureException(t){var e,n,r,s=(e=t==null||(n=t.$exception_list)==null||(n=n[0])==null?void 0:n.type)!==null&&e!==void 0?e:"Exception";this.Xo.consumeRateLimit(s)?sd.info("Skipping exception capture because of client rate limiting.",{exception:s}):(r=this._instance.exceptions)==null||r.sendExceptionEvent(t)}},exceptions:class{constructor(t){var e,n;this.ta=[],this.ra=new zL([new YL,new iN,new QL,new XL,new rN,new nN,new eN,new sN],(function(r){for(var s=arguments.length,i=new Array(s>1?s-1:0),a=1;s>a;a++)i[a-1]=arguments[a];return function(c,u){u===void 0&&(u=0);for(var f=[],h=c.split(`
17
+ */var JS;function TO(){if(JS)return Zu;JS=1;var t=f2(),e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function a(c,u,f){var h,p={},m=null,_=null;f!==void 0&&(m=""+f),u.key!==void 0&&(m=""+u.key),u.ref!==void 0&&(_=u.ref);for(h in u)r.call(u,h)&&!i.hasOwnProperty(h)&&(p[h]=u[h]);if(c&&c.defaultProps)for(h in u=c.defaultProps,u)p[h]===void 0&&(p[h]=u[h]);return{$$typeof:e,type:c,key:m,ref:_,props:p,_owner:s.current}}return Zu.Fragment=n,Zu.jsx=a,Zu.jsxs=a,Zu}var eE;function RO(){return eE||(eE=1,fv.exports=TO()),fv.exports}var E=RO(),v=f2();const ve=Jm(v),xf=kO({__proto__:null,default:ve},[v]);var wf=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},ll,$o,Nc,P8,AO=(P8=class extends wf{constructor(){super();He(this,ll);He(this,$o);He(this,Nc);ke(this,Nc,e=>{if(typeof window<"u"&&window.addEventListener){const n=()=>e();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){U(this,$o)||this.setEventListener(U(this,Nc))}onUnsubscribe(){var e;this.hasListeners()||((e=U(this,$o))==null||e.call(this),ke(this,$o,void 0))}setEventListener(e){var n;ke(this,Nc,e),(n=U(this,$o))==null||n.call(this),ke(this,$o,e(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(e){U(this,ll)!==e&&(ke(this,ll,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(n=>{n(e)})}isFocused(){var e;return typeof U(this,ll)=="boolean"?U(this,ll):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},ll=new WeakMap,$o=new WeakMap,Nc=new WeakMap,P8),h2=new AO,IO={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Ho,d2,T8,MO=(T8=class{constructor(){He(this,Ho,IO);He(this,d2,!1)}setTimeoutProvider(t){ke(this,Ho,t)}setTimeout(t,e){return U(this,Ho).setTimeout(t,e)}clearTimeout(t){U(this,Ho).clearTimeout(t)}setInterval(t,e){return U(this,Ho).setInterval(t,e)}clearInterval(t){U(this,Ho).clearInterval(t)}},Ho=new WeakMap,d2=new WeakMap,T8),rl=new MO;function OO(t){setTimeout(t,0)}var LO=typeof window>"u"||"Deno"in globalThis;function Cr(){}function NO(t,e){return typeof t=="function"?t(e):t}function U1(t){return typeof t=="number"&&t>=0&&t!==1/0}function j8(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Jo(t,e){return typeof t=="function"?t(e):t}function Gr(t,e){return typeof t=="function"?t(e):t}function tE(t,e){const{type:n="all",exact:r,fetchStatus:s,predicate:i,queryKey:a,stale:c}=t;if(a){if(r){if(e.queryHash!==p2(a,e.options))return!1}else if(!Zc(e.queryKey,a))return!1}if(n!=="all"){const u=e.isActive();if(n==="active"&&!u||n==="inactive"&&u)return!1}return!(typeof c=="boolean"&&e.isStale()!==c||s&&s!==e.state.fetchStatus||i&&!i(e))}function nE(t,e){const{exact:n,status:r,predicate:s,mutationKey:i}=t;if(i){if(!e.options.mutationKey)return!1;if(n){if(Dd(e.options.mutationKey)!==Dd(i))return!1}else if(!Zc(e.options.mutationKey,i))return!1}return!(r&&e.state.status!==r||s&&!s(e))}function p2(t,e){return((e==null?void 0:e.queryKeyHashFn)||Dd)(t)}function Dd(t){return JSON.stringify(t,(e,n)=>W1(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function Zc(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(t&&e&&typeof t=="object"&&typeof e=="object"){if(Array.isArray(t)&&Array.isArray(e)){for(let r=0;r<e.length;r++)if(!Zc(t[r],e[r]))return!1;return!0}const n=Object.keys(e);for(const r of n)if(!Zc(t[r],e[r]))return!1;return!0}return!1}var DO=Object.prototype.hasOwnProperty;function F8(t,e,n=0){if(t===e)return t;if(n>500)return e;const r=rE(t)&&rE(e);if(!r&&!(W1(t)&&W1(e)))return e;const i=(r?t:Object.keys(t)).length,a=r?e:Object.keys(e),c=a.length,u=r?new Array(c):{};let f=0;for(let h=0;h<c;h++){const p=r?h:a[h],m=t[p],_=e[p];if(m===_){u[p]=m,(r?h<i:DO.call(t,p))&&f++;continue}if(m===null||_===null||typeof m!="object"||typeof _!="object"){u[p]=_;continue}const x=F8(m,_,n+1);u[p]=x,x===m&&f++}return i===c&&f===i?t:u}function B1(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const n in t)if(t[n]!==e[n])return!1;return!0}function rE(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function W1(t){if(!sE(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!sE(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function sE(t){return Object.prototype.toString.call(t)==="[object Object]"}function jO(t){return new Promise(e=>{rl.setTimeout(e,t)})}function G1(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?F8(t,e):e}function FO(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function VO(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var m2=Symbol();function V8(t,e){return!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===m2?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function $8(t,e){return typeof t=="function"?t(...e):!!t}function $O(t,e,n){let r=!1,s;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(s??(s=e()),r||(r=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}),t}var jd=(()=>{let t=()=>LO;return{isServer(){return t()},setIsServer(e){t=e}}})();function K1(){let t,e;const n=new Promise((s,i)=>{t=s,e=i});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),t(s)},n.reject=s=>{r({status:"rejected",reason:s}),e(s)},n}var HO=OO;function zO(){let t=[],e=0,n=c=>{c()},r=c=>{c()},s=HO;const i=c=>{e?t.push(c):s(()=>{n(c)})},a=()=>{const c=t;t=[],c.length&&s(()=>{r(()=>{c.forEach(u=>{n(u)})})})};return{batch:c=>{let u;e++;try{u=c()}finally{e--,e||a()}return u},batchCalls:c=>(...u)=>{i(()=>{c(...u)})},schedule:i,setNotifyFunction:c=>{n=c},setBatchNotifyFunction:c=>{r=c},setScheduler:c=>{s=c}}}var Fn=zO(),Dc,zo,jc,R8,UO=(R8=class extends wf{constructor(){super();He(this,Dc,!0);He(this,zo);He(this,jc);ke(this,jc,e=>{if(typeof window<"u"&&window.addEventListener){const n=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){U(this,zo)||this.setEventListener(U(this,jc))}onUnsubscribe(){var e;this.hasListeners()||((e=U(this,zo))==null||e.call(this),ke(this,zo,void 0))}setEventListener(e){var n;ke(this,jc,e),(n=U(this,zo))==null||n.call(this),ke(this,zo,e(this.setOnline.bind(this)))}setOnline(e){U(this,Dc)!==e&&(ke(this,Dc,e),this.listeners.forEach(r=>{r(e)}))}isOnline(){return U(this,Dc)}},Dc=new WeakMap,zo=new WeakMap,jc=new WeakMap,R8),Xp=new UO;function BO(t){return Math.min(1e3*2**t,3e4)}function H8(t){return(t??"online")==="online"?Xp.isOnline():!0}var Z1=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function z8(t){let e=!1,n=0,r;const s=K1(),i=()=>s.status!=="pending",a=y=>{var w;if(!i()){const S=new Z1(y);m(S),(w=t.onCancel)==null||w.call(t,S)}},c=()=>{e=!0},u=()=>{e=!1},f=()=>h2.isFocused()&&(t.networkMode==="always"||Xp.isOnline())&&t.canRun(),h=()=>H8(t.networkMode)&&t.canRun(),p=y=>{i()||(r==null||r(),s.resolve(y))},m=y=>{i()||(r==null||r(),s.reject(y))},_=()=>new Promise(y=>{var w;r=S=>{(i()||f())&&y(S)},(w=t.onPause)==null||w.call(t)}).then(()=>{var y;r=void 0,i()||(y=t.onContinue)==null||y.call(t)}),x=()=>{if(i())return;let y;const w=n===0?t.initialPromise:void 0;try{y=w??t.fn()}catch(S){y=Promise.reject(S)}Promise.resolve(y).then(p).catch(S=>{var L;if(i())return;const T=t.retry??(jd.isServer()?0:3),P=t.retryDelay??BO,k=typeof P=="function"?P(n,S):P,R=T===!0||typeof T=="number"&&n<T||typeof T=="function"&&T(n,S);if(e||!R){m(S);return}n++,(L=t.onFail)==null||L.call(t,n,S),jO(k).then(()=>f()?void 0:_()).then(()=>{e?m(S):x()})})};return{promise:s,status:()=>s.status,cancel:a,continue:()=>(r==null||r(),s),cancelRetry:c,continueRetry:u,canStart:h,start:()=>(h()?x():_().then(x),s)}}var cl,A8,U8=(A8=class{constructor(){He(this,cl)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),U1(this.gcTime)&&ke(this,cl,rl.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(jd.isServer()?1/0:300*1e3))}clearGcTimeout(){U(this,cl)!==void 0&&(rl.clearTimeout(U(this,cl)),ke(this,cl,void 0))}},cl=new WeakMap,A8);function WO(t){return{onFetch:(e,n)=>{var h,p,m,_,x;const r=e.options,s=(m=(p=(h=e.fetchOptions)==null?void 0:h.meta)==null?void 0:p.fetchMore)==null?void 0:m.direction,i=((_=e.state.data)==null?void 0:_.pages)||[],a=((x=e.state.data)==null?void 0:x.pageParams)||[];let c={pages:[],pageParams:[]},u=0;const f=async()=>{let y=!1;const w=P=>{$O(P,()=>e.signal,()=>y=!0)},S=V8(e.options,e.fetchOptions),T=async(P,k,R)=>{if(y)return Promise.reject(e.signal.reason);if(k==null&&P.pages.length)return Promise.resolve(P);const O=(()=>{const j={client:e.client,queryKey:e.queryKey,pageParam:k,direction:R?"backward":"forward",meta:e.options.meta};return w(j),j})(),A=await S(O),{maxPages:I}=e.options,N=R?VO:FO;return{pages:N(P.pages,A,I),pageParams:N(P.pageParams,k,I)}};if(s&&i.length){const P=s==="backward",k=P?GO:iE,R={pages:i,pageParams:a},L=k(r,R);c=await T(R,L,P)}else{const P=t??i.length;do{const k=u===0?a[0]??r.initialPageParam:iE(r,c);if(u>0&&k==null)break;c=await T(c,k),u++}while(u<P)}return c};e.options.persister?e.fetchFn=()=>{var y,w;return(w=(y=e.options).persister)==null?void 0:w.call(y,f,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n)}:e.fetchFn=f}}}function iE(t,{pages:e,pageParams:n}){const r=e.length-1;return e.length>0?t.getNextPageParam(e[r],e,n[r],n):void 0}function GO(t,{pages:e,pageParams:n}){var r;return e.length>0?(r=t.getPreviousPageParam)==null?void 0:r.call(t,e[0],e,n[0],n):void 0}var Fc,ul,Vc,gs,dl,kn,mf,fl,Br,B8,$i,I8,KO=(I8=class extends U8{constructor(e){super();He(this,Br);He(this,Fc);He(this,ul);He(this,Vc);He(this,gs);He(this,dl);He(this,kn);He(this,mf);He(this,fl);ke(this,fl,!1),ke(this,mf,e.defaultOptions),this.setOptions(e.options),this.observers=[],ke(this,dl,e.client),ke(this,gs,U(this,dl).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,ke(this,ul,aE(this.options)),this.state=e.state??U(this,ul),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return U(this,Fc)}get promise(){var e;return(e=U(this,kn))==null?void 0:e.promise}setOptions(e){if(this.options={...U(this,mf),...e},e!=null&&e._type&&ke(this,Fc,e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=aE(this.options);n.data!==void 0&&(this.setState(oE(n.data,n.dataUpdatedAt)),ke(this,ul,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&U(this,gs).remove(this)}setData(e,n){const r=G1(this.state.data,e,this.options);return lt(this,Br,$i).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(e){lt(this,Br,$i).call(this,{type:"setState",state:e})}cancel(e){var r,s;const n=(r=U(this,kn))==null?void 0:r.promise;return(s=U(this,kn))==null||s.cancel(e),n?n.then(Cr).catch(Cr):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return U(this,ul)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>Gr(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===m2||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>Jo(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!j8(this.state.dataUpdatedAt,e)}onFocus(){var n;const e=this.observers.find(r=>r.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(n=U(this,kn))==null||n.continue()}onOnline(){var n;const e=this.observers.find(r=>r.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(n=U(this,kn))==null||n.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),U(this,gs).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(n=>n!==e),this.observers.length||(U(this,kn)&&(U(this,fl)||lt(this,Br,B8).call(this)?U(this,kn).cancel({revert:!0}):U(this,kn).cancelRetry()),this.scheduleGc()),U(this,gs).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||lt(this,Br,$i).call(this,{type:"invalidate"})}async fetch(e,n){var f,h,p,m,_,x,y,w,S,T,P;if(this.state.fetchStatus!=="idle"&&((f=U(this,kn))==null?void 0:f.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(U(this,kn))return U(this,kn).continueRetry(),U(this,kn).promise}if(e&&this.setOptions(e),!this.options.queryFn){const k=this.observers.find(R=>R.options.queryFn);k&&this.setOptions(k.options)}const r=new AbortController,s=k=>{Object.defineProperty(k,"signal",{enumerable:!0,get:()=>(ke(this,fl,!0),r.signal)})},i=()=>{const k=V8(this.options,n),L=(()=>{const O={client:U(this,dl),queryKey:this.queryKey,meta:this.meta};return s(O),O})();return ke(this,fl,!1),this.options.persister?this.options.persister(k,L,this):k(L)},c=(()=>{const k={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:U(this,dl),state:this.state,fetchFn:i};return s(k),k})(),u=U(this,Fc)==="infinite"?WO(this.options.pages):this.options.behavior;u==null||u.onFetch(c,this),ke(this,Vc,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((h=c.fetchOptions)==null?void 0:h.meta))&&lt(this,Br,$i).call(this,{type:"fetch",meta:(p=c.fetchOptions)==null?void 0:p.meta}),ke(this,kn,z8({initialPromise:n==null?void 0:n.initialPromise,fn:c.fetchFn,onCancel:k=>{k instanceof Z1&&k.revert&&this.setState({...U(this,Vc),fetchStatus:"idle"}),r.abort()},onFail:(k,R)=>{lt(this,Br,$i).call(this,{type:"failed",failureCount:k,error:R})},onPause:()=>{lt(this,Br,$i).call(this,{type:"pause"})},onContinue:()=>{lt(this,Br,$i).call(this,{type:"continue"})},retry:c.options.retry,retryDelay:c.options.retryDelay,networkMode:c.options.networkMode,canRun:()=>!0}));try{const k=await U(this,kn).start();if(k===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(k),(_=(m=U(this,gs).config).onSuccess)==null||_.call(m,k,this),(y=(x=U(this,gs).config).onSettled)==null||y.call(x,k,this.state.error,this),k}catch(k){if(k instanceof Z1){if(k.silent)return U(this,kn).promise;if(k.revert){if(this.state.data===void 0)throw k;return this.state.data}}throw lt(this,Br,$i).call(this,{type:"error",error:k}),(S=(w=U(this,gs).config).onError)==null||S.call(w,k,this),(P=(T=U(this,gs).config).onSettled)==null||P.call(T,this.state.data,k,this),k}finally{this.scheduleGc()}}},Fc=new WeakMap,ul=new WeakMap,Vc=new WeakMap,gs=new WeakMap,dl=new WeakMap,kn=new WeakMap,mf=new WeakMap,fl=new WeakMap,Br=new WeakSet,B8=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},$i=function(e){const n=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...W8(r.data,this.options),fetchMeta:e.meta??null};case"success":const s={...r,...oE(e.data,e.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return ke(this,Vc,e.manual?s:void 0),s;case"error":const i=e.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=n(this.state),Fn.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),U(this,gs).notify({query:this,type:"updated",action:e})})},I8);function W8(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:H8(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function oE(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function aE(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,n=e!==void 0,r=n?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var br,ct,gf,ir,hl,$c,qi,Uo,vf,Hc,zc,pl,ml,Bo,Uc,vt,dd,q1,Y1,X1,Q1,J1,ey,ty,G8,M8,ZO=(M8=class extends wf{constructor(e,n){super();He(this,vt);He(this,br);He(this,ct);He(this,gf);He(this,ir);He(this,hl);He(this,$c);He(this,qi);He(this,Uo);He(this,vf);He(this,Hc);He(this,zc);He(this,pl);He(this,ml);He(this,Bo);He(this,Uc,new Set);this.options=n,ke(this,br,e),ke(this,Uo,null),ke(this,qi,K1()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(U(this,ct).addObserver(this),lE(U(this,ct),this.options)?lt(this,vt,dd).call(this):this.updateResult(),lt(this,vt,Q1).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ny(U(this,ct),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ny(U(this,ct),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,lt(this,vt,J1).call(this),lt(this,vt,ey).call(this),U(this,ct).removeObserver(this)}setOptions(e){const n=this.options,r=U(this,ct);if(this.options=U(this,br).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Gr(this.options.enabled,U(this,ct))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");lt(this,vt,ty).call(this),U(this,ct).setOptions(this.options),n._defaulted&&!B1(this.options,n)&&U(this,br).getQueryCache().notify({type:"observerOptionsUpdated",query:U(this,ct),observer:this});const s=this.hasListeners();s&&cE(U(this,ct),r,this.options,n)&&lt(this,vt,dd).call(this),this.updateResult(),s&&(U(this,ct)!==r||Gr(this.options.enabled,U(this,ct))!==Gr(n.enabled,U(this,ct))||Jo(this.options.staleTime,U(this,ct))!==Jo(n.staleTime,U(this,ct)))&&lt(this,vt,q1).call(this);const i=lt(this,vt,Y1).call(this);s&&(U(this,ct)!==r||Gr(this.options.enabled,U(this,ct))!==Gr(n.enabled,U(this,ct))||i!==U(this,Bo))&&lt(this,vt,X1).call(this,i)}getOptimisticResult(e){const n=U(this,br).getQueryCache().build(U(this,br),e),r=this.createResult(n,e);return YO(this,r)&&(ke(this,ir,r),ke(this,$c,this.options),ke(this,hl,U(this,ct).state)),r}getCurrentResult(){return U(this,ir)}trackResult(e,n){return new Proxy(e,{get:(r,s)=>(this.trackProp(s),n==null||n(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&U(this,qi).status==="pending"&&U(this,qi).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(e){U(this,Uc).add(e)}getCurrentQuery(){return U(this,ct)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const n=U(this,br).defaultQueryOptions(e),r=U(this,br).getQueryCache().build(U(this,br),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(e){return lt(this,vt,dd).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),U(this,ir)))}createResult(e,n){var I;const r=U(this,ct),s=this.options,i=U(this,ir),a=U(this,hl),c=U(this,$c),f=e!==r?e.state:U(this,gf),{state:h}=e;let p={...h},m=!1,_;if(n._optimisticResults){const N=this.hasListeners(),j=!N&&lE(e,n),F=N&&cE(e,r,n,s);(j||F)&&(p={...p,...W8(h.data,e.options)}),n._optimisticResults==="isRestoring"&&(p.fetchStatus="idle")}let{error:x,errorUpdatedAt:y,status:w}=p;_=p.data;let S=!1;if(n.placeholderData!==void 0&&_===void 0&&w==="pending"){let N;i!=null&&i.isPlaceholderData&&n.placeholderData===(c==null?void 0:c.placeholderData)?(N=i.data,S=!0):N=typeof n.placeholderData=="function"?n.placeholderData((I=U(this,zc))==null?void 0:I.state.data,U(this,zc)):n.placeholderData,N!==void 0&&(w="success",_=G1(i==null?void 0:i.data,N,n),m=!0)}if(n.select&&_!==void 0&&!S)if(i&&_===(a==null?void 0:a.data)&&n.select===U(this,vf))_=U(this,Hc);else try{ke(this,vf,n.select),_=n.select(_),_=G1(i==null?void 0:i.data,_,n),ke(this,Hc,_),ke(this,Uo,null)}catch(N){ke(this,Uo,N)}U(this,Uo)&&(x=U(this,Uo),_=U(this,Hc),y=Date.now(),w="error");const T=p.fetchStatus==="fetching",P=w==="pending",k=w==="error",R=P&&T,L=_!==void 0,A={status:w,fetchStatus:p.fetchStatus,isPending:P,isSuccess:w==="success",isError:k,isInitialLoading:R,isLoading:R,data:_,dataUpdatedAt:p.dataUpdatedAt,error:x,errorUpdatedAt:y,failureCount:p.fetchFailureCount,failureReason:p.fetchFailureReason,errorUpdateCount:p.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:p.dataUpdateCount>f.dataUpdateCount||p.errorUpdateCount>f.errorUpdateCount,isFetching:T,isRefetching:T&&!P,isLoadingError:k&&!L,isPaused:p.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:k&&L,isStale:g2(e,n),refetch:this.refetch,promise:U(this,qi),isEnabled:Gr(n.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const N=A.data!==void 0,j=A.status==="error"&&!N,F=W=>{j?W.reject(A.error):N&&W.resolve(A.data)},K=()=>{const W=ke(this,qi,A.promise=K1());F(W)},X=U(this,qi);switch(X.status){case"pending":e.queryHash===r.queryHash&&F(X);break;case"fulfilled":(j||A.data!==X.value)&&K();break;case"rejected":(!j||A.error!==X.reason)&&K();break}}return A}updateResult(){const e=U(this,ir),n=this.createResult(U(this,ct),this.options);if(ke(this,hl,U(this,ct).state),ke(this,$c,this.options),U(this,hl).data!==void 0&&ke(this,zc,U(this,ct)),B1(n,e))return;ke(this,ir,n);const r=()=>{if(!e)return!0;const{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!U(this,Uc).size)return!0;const a=new Set(i??U(this,Uc));return this.options.throwOnError&&a.add("error"),Object.keys(U(this,ir)).some(c=>{const u=c;return U(this,ir)[u]!==e[u]&&a.has(u)})};lt(this,vt,G8).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&lt(this,vt,Q1).call(this)}},br=new WeakMap,ct=new WeakMap,gf=new WeakMap,ir=new WeakMap,hl=new WeakMap,$c=new WeakMap,qi=new WeakMap,Uo=new WeakMap,vf=new WeakMap,Hc=new WeakMap,zc=new WeakMap,pl=new WeakMap,ml=new WeakMap,Bo=new WeakMap,Uc=new WeakMap,vt=new WeakSet,dd=function(e){lt(this,vt,ty).call(this);let n=U(this,ct).fetch(this.options,e);return e!=null&&e.throwOnError||(n=n.catch(Cr)),n},q1=function(){lt(this,vt,J1).call(this);const e=Jo(this.options.staleTime,U(this,ct));if(jd.isServer()||U(this,ir).isStale||!U1(e))return;const r=j8(U(this,ir).dataUpdatedAt,e)+1;ke(this,pl,rl.setTimeout(()=>{U(this,ir).isStale||this.updateResult()},r))},Y1=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(U(this,ct)):this.options.refetchInterval)??!1},X1=function(e){lt(this,vt,ey).call(this),ke(this,Bo,e),!(jd.isServer()||Gr(this.options.enabled,U(this,ct))===!1||!U1(U(this,Bo))||U(this,Bo)===0)&&ke(this,ml,rl.setInterval(()=>{(this.options.refetchIntervalInBackground||h2.isFocused())&&lt(this,vt,dd).call(this)},U(this,Bo)))},Q1=function(){lt(this,vt,q1).call(this),lt(this,vt,X1).call(this,lt(this,vt,Y1).call(this))},J1=function(){U(this,pl)!==void 0&&(rl.clearTimeout(U(this,pl)),ke(this,pl,void 0))},ey=function(){U(this,ml)!==void 0&&(rl.clearInterval(U(this,ml)),ke(this,ml,void 0))},ty=function(){const e=U(this,br).getQueryCache().build(U(this,br),this.options);if(e===U(this,ct))return;const n=U(this,ct);ke(this,ct,e),ke(this,gf,e.state),this.hasListeners()&&(n==null||n.removeObserver(this),e.addObserver(this))},G8=function(e){Fn.batch(()=>{e.listeners&&this.listeners.forEach(n=>{n(U(this,ir))}),U(this,br).getQueryCache().notify({query:U(this,ct),type:"observerResultsUpdated"})})},M8);function qO(t,e){return Gr(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&Gr(e.retryOnMount,t)===!1)}function lE(t,e){return qO(t,e)||t.state.data!==void 0&&ny(t,e,e.refetchOnMount)}function ny(t,e,n){if(Gr(e.enabled,t)!==!1&&Jo(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&g2(t,e)}return!1}function cE(t,e,n,r){return(t!==e||Gr(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&g2(t,n)}function g2(t,e){return Gr(e.enabled,t)!==!1&&t.isStaleByTime(Jo(e.staleTime,t))}function YO(t,e){return!B1(t.getCurrentResult(),e)}var yf,ai,Xn,gl,li,Fo,O8,XO=(O8=class extends U8{constructor(e){super();He(this,li);He(this,yf);He(this,ai);He(this,Xn);He(this,gl);ke(this,yf,e.client),this.mutationId=e.mutationId,ke(this,Xn,e.mutationCache),ke(this,ai,[]),this.state=e.state||QO(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){U(this,ai).includes(e)||(U(this,ai).push(e),this.clearGcTimeout(),U(this,Xn).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){ke(this,ai,U(this,ai).filter(n=>n!==e)),this.scheduleGc(),U(this,Xn).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){U(this,ai).length||(this.state.status==="pending"?this.scheduleGc():U(this,Xn).remove(this))}continue(){var e;return((e=U(this,gl))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var a,c,u,f,h,p,m,_,x,y,w,S,T,P,k,R,L,O;const n=()=>{lt(this,li,Fo).call(this,{type:"continue"})},r={client:U(this,yf),meta:this.options.meta,mutationKey:this.options.mutationKey};ke(this,gl,z8({fn:()=>this.options.mutationFn?this.options.mutationFn(e,r):Promise.reject(new Error("No mutationFn found")),onFail:(A,I)=>{lt(this,li,Fo).call(this,{type:"failed",failureCount:A,error:I})},onPause:()=>{lt(this,li,Fo).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>U(this,Xn).canRun(this)}));const s=this.state.status==="pending",i=!U(this,gl).canStart();try{if(s)n();else{lt(this,li,Fo).call(this,{type:"pending",variables:e,isPaused:i}),U(this,Xn).config.onMutate&&await U(this,Xn).config.onMutate(e,this,r);const I=await((c=(a=this.options).onMutate)==null?void 0:c.call(a,e,r));I!==this.state.context&&lt(this,li,Fo).call(this,{type:"pending",context:I,variables:e,isPaused:i})}const A=await U(this,gl).start();return await((f=(u=U(this,Xn).config).onSuccess)==null?void 0:f.call(u,A,e,this.state.context,this,r)),await((p=(h=this.options).onSuccess)==null?void 0:p.call(h,A,e,this.state.context,r)),await((_=(m=U(this,Xn).config).onSettled)==null?void 0:_.call(m,A,null,this.state.variables,this.state.context,this,r)),await((y=(x=this.options).onSettled)==null?void 0:y.call(x,A,null,e,this.state.context,r)),lt(this,li,Fo).call(this,{type:"success",data:A}),A}catch(A){try{await((S=(w=U(this,Xn).config).onError)==null?void 0:S.call(w,A,e,this.state.context,this,r))}catch(I){Promise.reject(I)}try{await((P=(T=this.options).onError)==null?void 0:P.call(T,A,e,this.state.context,r))}catch(I){Promise.reject(I)}try{await((R=(k=U(this,Xn).config).onSettled)==null?void 0:R.call(k,void 0,A,this.state.variables,this.state.context,this,r))}catch(I){Promise.reject(I)}try{await((O=(L=this.options).onSettled)==null?void 0:O.call(L,void 0,A,e,this.state.context,r))}catch(I){Promise.reject(I)}throw lt(this,li,Fo).call(this,{type:"error",error:A}),A}finally{U(this,Xn).runNext(this)}}},yf=new WeakMap,ai=new WeakMap,Xn=new WeakMap,gl=new WeakMap,li=new WeakSet,Fo=function(e){const n=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Fn.batch(()=>{U(this,ai).forEach(r=>{r.onMutationUpdate(e)}),U(this,Xn).notify({mutation:this,type:"updated",action:e})})},O8);function QO(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Yi,Hs,_f,L8,JO=(L8=class extends wf{constructor(e={}){super();He(this,Yi);He(this,Hs);He(this,_f);this.config=e,ke(this,Yi,new Set),ke(this,Hs,new Map),ke(this,_f,0)}build(e,n,r){const s=new XO({client:e,mutationCache:this,mutationId:++Hh(this,_f)._,options:e.defaultMutationOptions(n),state:r});return this.add(s),s}add(e){U(this,Yi).add(e);const n=zh(e);if(typeof n=="string"){const r=U(this,Hs).get(n);r?r.push(e):U(this,Hs).set(n,[e])}this.notify({type:"added",mutation:e})}remove(e){if(U(this,Yi).delete(e)){const n=zh(e);if(typeof n=="string"){const r=U(this,Hs).get(n);if(r)if(r.length>1){const s=r.indexOf(e);s!==-1&&r.splice(s,1)}else r[0]===e&&U(this,Hs).delete(n)}}this.notify({type:"removed",mutation:e})}canRun(e){const n=zh(e);if(typeof n=="string"){const r=U(this,Hs).get(n),s=r==null?void 0:r.find(i=>i.state.status==="pending");return!s||s===e}else return!0}runNext(e){var r;const n=zh(e);if(typeof n=="string"){const s=(r=U(this,Hs).get(n))==null?void 0:r.find(i=>i!==e&&i.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Fn.batch(()=>{U(this,Yi).forEach(e=>{this.notify({type:"removed",mutation:e})}),U(this,Yi).clear(),U(this,Hs).clear()})}getAll(){return Array.from(U(this,Yi))}find(e){const n={exact:!0,...e};return this.getAll().find(r=>nE(n,r))}findAll(e={}){return this.getAll().filter(n=>nE(e,n))}notify(e){Fn.batch(()=>{this.listeners.forEach(n=>{n(e)})})}resumePausedMutations(){const e=this.getAll().filter(n=>n.state.isPaused);return Fn.batch(()=>Promise.all(e.map(n=>n.continue().catch(Cr))))}},Yi=new WeakMap,Hs=new WeakMap,_f=new WeakMap,L8);function zh(t){var e;return(e=t.options.scope)==null?void 0:e.id}var ci,N8,eL=(N8=class extends wf{constructor(e={}){super();He(this,ci);this.config=e,ke(this,ci,new Map)}build(e,n,r){const s=n.queryKey,i=n.queryHash??p2(s,n);let a=this.get(i);return a||(a=new KO({client:e,queryKey:s,queryHash:i,options:e.defaultQueryOptions(n),state:r,defaultOptions:e.getQueryDefaults(s)}),this.add(a)),a}add(e){U(this,ci).has(e.queryHash)||(U(this,ci).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const n=U(this,ci).get(e.queryHash);n&&(e.destroy(),n===e&&U(this,ci).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){Fn.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return U(this,ci).get(e)}getAll(){return[...U(this,ci).values()]}find(e){const n={exact:!0,...e};return this.getAll().find(r=>tE(n,r))}findAll(e={}){const n=this.getAll();return Object.keys(e).length>0?n.filter(r=>tE(e,r)):n}notify(e){Fn.batch(()=>{this.listeners.forEach(n=>{n(e)})})}onFocus(){Fn.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Fn.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},ci=new WeakMap,N8),Qt,Wo,Go,Bc,Wc,Ko,Gc,Kc,D8,tL=(D8=class{constructor(t={}){He(this,Qt);He(this,Wo);He(this,Go);He(this,Bc);He(this,Wc);He(this,Ko);He(this,Gc);He(this,Kc);ke(this,Qt,t.queryCache||new eL),ke(this,Wo,t.mutationCache||new JO),ke(this,Go,t.defaultOptions||{}),ke(this,Bc,new Map),ke(this,Wc,new Map),ke(this,Ko,0)}mount(){Hh(this,Ko)._++,U(this,Ko)===1&&(ke(this,Gc,h2.subscribe(async t=>{t&&(await this.resumePausedMutations(),U(this,Qt).onFocus())})),ke(this,Kc,Xp.subscribe(async t=>{t&&(await this.resumePausedMutations(),U(this,Qt).onOnline())})))}unmount(){var t,e;Hh(this,Ko)._--,U(this,Ko)===0&&((t=U(this,Gc))==null||t.call(this),ke(this,Gc,void 0),(e=U(this,Kc))==null||e.call(this),ke(this,Kc,void 0))}isFetching(t){return U(this,Qt).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return U(this,Wo).findAll({...t,status:"pending"}).length}getQueryData(t){var n;const e=this.defaultQueryOptions({queryKey:t});return(n=U(this,Qt).get(e.queryHash))==null?void 0:n.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=U(this,Qt).build(this,e),r=n.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(Jo(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return U(this,Qt).findAll(t).map(({queryKey:e,state:n})=>{const r=n.data;return[e,r]})}setQueryData(t,e,n){const r=this.defaultQueryOptions({queryKey:t}),s=U(this,Qt).get(r.queryHash),i=s==null?void 0:s.state.data,a=NO(e,i);if(a!==void 0)return U(this,Qt).build(this,r).setData(a,{...n,manual:!0})}setQueriesData(t,e,n){return Fn.batch(()=>U(this,Qt).findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,n)]))}getQueryState(t){var n;const e=this.defaultQueryOptions({queryKey:t});return(n=U(this,Qt).get(e.queryHash))==null?void 0:n.state}removeQueries(t){const e=U(this,Qt);Fn.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=U(this,Qt);return Fn.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=Fn.batch(()=>U(this,Qt).findAll(t).map(s=>s.cancel(n)));return Promise.all(r).then(Cr).catch(Cr)}invalidateQueries(t,e={}){return Fn.batch(()=>(U(this,Qt).findAll(t).forEach(n=>{n.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},e)))}refetchQueries(t,e={}){const n={...e,cancelRefetch:e.cancelRefetch??!0},r=Fn.batch(()=>U(this,Qt).findAll(t).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let i=s.fetch(void 0,n);return n.throwOnError||(i=i.catch(Cr)),s.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Cr)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=U(this,Qt).build(this,e);return n.isStaleByTime(Jo(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Cr).catch(Cr)}fetchInfiniteQuery(t){return t._type="infinite",this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Cr).catch(Cr)}ensureInfiniteQueryData(t){return t._type="infinite",this.ensureQueryData(t)}resumePausedMutations(){return Xp.isOnline()?U(this,Wo).resumePausedMutations():Promise.resolve()}getQueryCache(){return U(this,Qt)}getMutationCache(){return U(this,Wo)}getDefaultOptions(){return U(this,Go)}setDefaultOptions(t){ke(this,Go,t)}setQueryDefaults(t,e){U(this,Bc).set(Dd(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...U(this,Bc).values()],n={};return e.forEach(r=>{Zc(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){U(this,Wc).set(Dd(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...U(this,Wc).values()],n={};return e.forEach(r=>{Zc(t,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(t){if(t._defaulted)return t;const e={...U(this,Go).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=p2(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===m2&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...U(this,Go).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){U(this,Qt).clear(),U(this,Wo).clear()}},Qt=new WeakMap,Wo=new WeakMap,Go=new WeakMap,Bc=new WeakMap,Wc=new WeakMap,Ko=new WeakMap,Gc=new WeakMap,Kc=new WeakMap,D8),K8=v.createContext(void 0),Z8=t=>{const e=v.useContext(K8);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},nL=({client:t,children:e})=>(v.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),E.jsx(K8.Provider,{value:t,children:e})),q8=v.createContext(!1),rL=()=>v.useContext(q8);q8.Provider;function sL(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var iL=v.createContext(sL()),oL=()=>v.useContext(iL),aL=(t,e,n)=>{const r=n!=null&&n.state.error&&typeof t.throwOnError=="function"?$8(t.throwOnError,[n.state.error,n]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||r)&&(e.isReset()||(t.retryOnMount=!1))},lL=t=>{v.useEffect(()=>{t.clearReset()},[t])},cL=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:s})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(s&&t.data===void 0||$8(n,[t.error,r])),uL=t=>{if(t.suspense){const n=s=>s==="static"?s:Math.max(s??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...s)=>n(r(...s)):n(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},dL=(t,e)=>t.isLoading&&t.isFetching&&!e,fL=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,uE=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function hL(t,e,n){var _,x,y,w;const r=rL(),s=oL(),i=Z8(),a=i.defaultQueryOptions(t);(x=(_=i.getDefaultOptions().queries)==null?void 0:_._experimental_beforeQuery)==null||x.call(_,a);const c=i.getQueryCache().get(a.queryHash),u=t.subscribed!==!1;a._optimisticResults=r?"isRestoring":u?"optimistic":void 0,uL(a),aL(a,s,c),lL(s);const f=!i.getQueryCache().get(a.queryHash),[h]=v.useState(()=>new e(i,a)),p=h.getOptimisticResult(a),m=!r&&u;if(v.useSyncExternalStore(v.useCallback(S=>{const T=m?h.subscribe(Fn.batchCalls(S)):Cr;return h.updateResult(),T},[h,m]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),v.useEffect(()=>{h.setOptions(a)},[a,h]),fL(a,p))throw uE(a,h,s);if(cL({result:p,errorResetBoundary:s,throwOnError:a.throwOnError,query:c,suspense:a.suspense}))throw p.error;if((w=(y=i.getDefaultOptions().queries)==null?void 0:y._experimental_afterQuery)==null||w.call(y,a,p),a.experimental_prefetchInRender&&!jd.isServer()&&dL(p,r)){const S=f?uE(a,h,s):c==null?void 0:c.promise;S==null||S.catch(Cr).finally(()=>{h.updateResult()})}return a.notifyOnChangeProps?p:h.trackResult(p)}function ry(t,e){return hL(t,ZO)}var te=typeof window<"u"?window:void 0,Jn=typeof globalThis<"u"?globalThis:te,ar=Jn==null?void 0:Jn.navigator,Se=Jn==null?void 0:Jn.document,rn=Jn==null?void 0:Jn.location,v2=Jn==null?void 0:Jn.fetch,sy=Jn!=null&&Jn.XMLHttpRequest&&"withCredentials"in new Jn.XMLHttpRequest?Jn.XMLHttpRequest:void 0,dE=Jn==null?void 0:Jn.AbortController,pL=Jn==null?void 0:Jn.CompressionStream,Sr=ar==null?void 0:ar.userAgent;function Y8(){return!(!te||te.navigator.onLine===!1)}var qu=typeof globalThis<"u"?globalThis:te;qu&&typeof self>"u"&&(qu.self=qu),qu&&typeof File>"u"&&(qu.File=function(){});var $e=te??{},gt={DEBUG:!1,LIB_VERSION:"0.2.4",LIB_NAME:"browser-common"};function fE(t,e,n,r,s,i,a){try{var c=t[i](a),u=c.value}catch(f){return void n(f)}c.done?e(u):Promise.resolve(u).then(r,s)}function en(t){return function(){var e=this,n=arguments;return new Promise((function(r,s){var i=t.apply(e,n);function a(u){fE(i,r,s,a,c,"next",u)}function c(u){fE(i,r,s,a,c,"throw",u)}a(void 0)}))}}function ue(){return ue=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},ue.apply(null,arguments)}function X8(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var hE=t=>{if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}};function pE(t){return typeof t=="string"||t}function mE(t){return typeof t=="string"?t:void 0}var Yu,mL=["$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","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],Bi=(function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t})({}),gE=(function(t){return t.GZipJS="gzip-js",t.Base64="base64",t})({}),gL=["$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"],vL=["token"],Q8="NativeGzipValidationError",iy=t=>t.length>=2&&t[0]===31&&t[1]===139,vE=(t,e)=>t===gE.GZipJS||e===gE.GZipJS||e==="gzip",yE=t=>!(!t||typeof t!="object")&&("name"in t?String(t.name):"")==="NotReadableError",Uh=t=>{var e=new Error("Native gzip produced invalid output: "+t);throw e.name=Q8,e},yL=(function(){var t=en((function*(e,n){18>e.size&&Uh("too-short");var r=new Uint8Array(yield e.slice(0,10).arrayBuffer());iy(r)&&r[2]===8||Uh("invalid-header");var s=new DataView(yield e.slice(e.size-8).arrayBuffer());s.getUint32(0,!0)!==(a=>{for(var c=(()=>{if(Yu)return Yu;Yu=[];for(var h=0;256>h;h++){for(var p=h,m=0;8>m;m++)p=1&p?3988292384^p>>>1:p>>>1;Yu[h]=p>>>0}return Yu})(),u=4294967295,f=0;a.length>f;f++)u=c[255&(u^a[f])]^u>>>8;return(4294967295^u)>>>0})(n)&&Uh("invalid-crc");var i=n.length>>>0;s.getUint32(4,!0)!==i&&Uh("invalid-size")}));return function(e,n){return t.apply(this,arguments)}})();function oy(){return oy=en((function*(t,e,n){e===void 0&&(e=!0);try{var r=new TextEncoder().encode(t),s=new globalThis.CompressionStream("gzip"),i=s.writable.getWriter(),a=i.write(r).then((()=>i.close())).catch((function(){var f=en((function*(h){try{yield i.abort(h)}catch{}throw h}));return function(h){return f.apply(this,arguments)}})()),c=new Response(s.readable).blob(),u=(yield Promise.all([c,a]))[0];return yield yL(u,r),u}catch(f){if(n!=null&&n.rethrow)throw f;return e&&console.error("Failed to gzip compress data",f),null}})),oy.apply(this,arguments)}var _L=["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"],_E=function(t,e){if(e===void 0&&(e=[]),!t)return!1;var n=t.toLowerCase();return _L.concat(e).some((r=>{var s=r.toLowerCase();return n.indexOf(s)!==-1}))};function Ge(t,e){return t.indexOf(e)!==-1}var e0=function(t){return t.trim()},ay=function(t){return t.replace(/^\$/,"")};function J8(t){var e,n=[];return(e=JSON.stringify(t,(function(r,s){if(typeof s=="bigint")return s.toString();if(typeof s!="function"&&typeof s!="symbol"){if(s instanceof Error)return{name:s.name,message:s.message,stack:s.stack};if(s&&typeof s=="object"){for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(n.includes(s))return"[Circular]";n.push(s)}return s}})))!==null&&e!==void 0?e:"null"}var e6=Object.prototype,t6=e6.hasOwnProperty,t0=e6.toString,Qe=Array.isArray||function(t){return t0.call(t)==="[object Array]"},zs=t=>typeof t=="function",Nt=t=>t===Object(t)&&!Qe(t),Zo=t=>{if(Nt(t)){for(var e in t)if(t6.call(t,e))return!1;return!0}return!1},ge=t=>t===void 0,xt=t=>t0.call(t)=="[object String]",ly=t=>xt(t)&&t.trim().length===0,dr=t=>t===null,Je=t=>ge(t)||dr(t),$n=t=>t0.call(t)=="[object Number]"&&t==t,Hi=t=>$n(t)&&t>0,Us=t=>t0.call(t)==="[object Boolean]",xL=t=>t instanceof FormData,wL=t=>Ge(gL,t),bL=t=>Ge(vL,t);function n6(t){return t===null||typeof t!="object"}function Qp(t,e){return{}.toString.call(t)==="[object "+e+"]"}function y2(t){return typeof Event<"u"&&(function(e,n){try{return e instanceof n}catch{return!1}})(t,Event)}var SL=[!0,"true",1,"1","yes"],pv=t=>Ge(SL,t),EL=[!1,"false",0,"0","no"];function hi(t,e,n,r,s){return e>n&&(r.warn("min cannot be greater than max."),e=n),$n(t)?t>n?(r.warn(" cannot be greater than max: "+n+". Using max value instead."),n):e>t?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(r.warn(" must be a number. using max or fallback. max: "+n+", fallback: "+s),hi(s||n,e,n,r))}class CL{constructor(e){this.$e={},this.ze=e.ze,this.Ze=hi(e.bucketSize,0,100,e.Ge),this.Qe=hi(e.refillRate,0,this.Ze,e.Ge),this.Je=hi(e.refillInterval,0,864e5,e.Ge)}Ke(e,n){var r=Math.floor((n-e.lastAccess)/this.Je);r>0&&(e.tokens=Math.min(e.tokens+r*this.Qe,this.Ze),e.lastAccess=e.lastAccess+r*this.Je)}consumeRateLimit(e){var n,r=Date.now(),s=String(e),i=this.$e[s];return i?this.Ke(i,r):this.$e[s]=i={tokens:this.Ze,lastAccess:r},i.tokens===0||(i.tokens--,i.tokens===0&&((n=this.ze)==null||n.call(this,e)),i.tokens===0)}stop(){this.$e={}}}var Qr="Mobile",Jp="iOS",no="Android",qc="Tablet",r6=no+" "+qc,s6="iPad",i6="Apple",o6=i6+" Watch",xd="Safari",Yc="BlackBerry",a6="Samsung",l6=a6+"Browser",c6=a6+" Internet",vl="Chrome",kL=vl+" OS",u6=vl+" "+Jp,_2="Internet Explorer",d6=_2+" "+Qr,x2="Opera",PL=x2+" Mini",w2="Edge",f6="Microsoft "+w2,kc="Firefox",h6=kc+" "+Jp,Fd="Nintendo",Vd="PlayStation",Pc="Xbox",p6=no+" "+Qr,m6=Qr+" "+xd,fd="Windows",cy=fd+" Phone",xE="Nokia",uy="Ouya",g6="Generic",TL=g6+" "+Qr.toLowerCase(),v6=g6+" "+qc.toLowerCase(),dy="Konqueror",y6="Oculus Browser",em="Vivaldi",_6="Yandex",tm="Whale",fy="DuckDuckGo",x6="Pale Moon",nm="Waterfox",wd="Brave",w6="Google Search App",Ht="(\\d+(\\.\\d+)?)",mv=new RegExp("Version/"+Ht),RL=new RegExp(Pc,"i"),AL=new RegExp(Vd+" \\w+","i"),IL=new RegExp(Fd+" \\w+","i"),b2=new RegExp(Yc+"|PlayBook|BB10","i"),ML={"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"},b6=function(t,e,n,r){e=e||"";var s=(function(i){return i!=null&&i.brave?wd:null})(n);return s||(r!=null&&r.detectGoogleSearchApp&&Ge(t,"GSA/")?w6:Ge(t," OPR/")&&Ge(t,"Mini")?PL:Ge(t," OPR/")?x2:b2.test(t)?Yc:Ge(t,"IE"+Qr)||Ge(t,"WPDesktop")?d6:Ge(t,"OculusBrowser")?y6:Ge(t,l6)?c6:Ge(t,w2)||Ge(t,"Edg/")?f6:Ge(t,em+"/")?em:Ge(t,"YaBrowser/")?_6:Ge(t,tm+"/")?tm:Ge(t,fy+"/")||Ge(t,"Ddg/")?fy:Ge(t,"FBIOS")?"Facebook "+Qr:Ge(t,"UCWEB")||Ge(t,"UCBrowser")?"UC Browser":Ge(t,"CriOS")?u6:Ge(t,"CrMo")||Ge(t,vl)?vl:Ge(t,no)&&Ge(t,xd)?p6:Ge(t,"FxiOS")?h6:Ge(t.toLowerCase(),dy.toLowerCase())?dy:Ge(t,wd+"/")?wd:((i,a)=>a&&Ge(a,i6)||(function(c){return Ge(c,xd)&&!Ge(c,vl)&&!Ge(c,no)})(i))(t,e)?Ge(t,Qr)?m6:xd:Ge(t,"PaleMoon/")?x6:Ge(t,nm+"/")?nm:Ge(t,kc)?kc:Ge(t,"MSIE")||Ge(t,"Trident/")?_2:Ge(t,"Gecko")?kc:"")},OL={[d6]:[new RegExp("rv:"+Ht)],[f6]:[new RegExp(w2+"?\\/"+Ht)],[vl]:[new RegExp("("+vl+"|CrMo)\\/"+Ht)],[u6]:[new RegExp("CriOS\\/"+Ht)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ht)],[xd]:[mv],[m6]:[mv],[x2]:[new RegExp("(Opera|OPR)\\/"+Ht)],[kc]:[new RegExp(kc+"\\/"+Ht)],[h6]:[new RegExp("FxiOS\\/"+Ht)],[dy]:[new RegExp("Konqueror[:/]?"+Ht,"i")],[Yc]:[new RegExp(Yc+" "+Ht),mv],[p6]:[new RegExp("android\\s"+Ht,"i")],[c6]:[new RegExp(l6+"\\/"+Ht)],[y6]:[new RegExp("OculusBrowser\\/"+Ht)],[em]:[new RegExp(em+"\\/"+Ht)],[_6]:[new RegExp("YaBrowser\\/"+Ht)],[tm]:[new RegExp(tm+"\\/"+Ht)],[wd]:[new RegExp(wd+"\\/"+Ht)],[fy]:[new RegExp("(DuckDuckGo|Ddg)\\/"+Ht)],[x6]:[new RegExp("PaleMoon\\/"+Ht)],[nm]:[new RegExp(nm+"\\/"+Ht)],[w6]:[new RegExp("GSA\\/"+Ht)],[_2]:[new RegExp("(rv:|MSIE )"+Ht)],Mozilla:[new RegExp("rv:"+Ht)]},LL=function(t,e,n,r){var s=b6(t,e,n,r),i=OL[s];if(ge(i))return null;for(var a=0;i.length>a;a++){var c=t.match(i[a]);if(c)return parseFloat(c[c.length-2])}return null},wE=[[new RegExp(Pc+"; "+Pc+" (.*?)[);]","i"),t=>[Pc,t&&t[1]||""]],[new RegExp(Fd,"i"),[Fd,""]],[new RegExp(Vd,"i"),[Vd,""]],[b2,[Yc,""]],[new RegExp(fd,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[cy,""];if(new RegExp(Qr).test(e)&&!/IEMobile\b/.test(e))return[fd+" "+Qr,""];var n=/Windows NT ([0-9.]+)/i.exec(e);if(n&&n[1]){var r=ML[n[1]]||"";return/arm/i.test(e)&&(r="RT"),[fd,r]}return[fd,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?[Jp,[t[3],t[4],t[5]||"0"].join(".")]:[Jp,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=ge(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("("+no+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+no+")","i"),t=>t&&t[2]?[no,[t[2],t[3],t[4]||"0"].join(".")]:[no,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];return t&&t[1]&&(e[1]=[t[1],t[2],t[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[kL,""]],[/Linux|debian/i,["Linux",""]]],bE=function(t){return IL.test(t)?Fd:AL.test(t)?Vd:RL.test(t)?Pc:new RegExp(uy,"i").test(t)?uy:new RegExp("("+cy+"|WPDesktop)","i").test(t)?cy:/iPad/.test(t)?s6:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?o6:b2.test(t)?Yc:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(xE,"i").test(t)?xE:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(Qr).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?no:r6:new RegExp("(pda|"+Qr+")","i").test(t)?TL:new RegExp(qc,"i").test(t)&&!new RegExp(qc+" pc","i").test(t)?v6:""},NL=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function SE(t,e){return typeof(n=t)=="string"&&NL.test(n)?t:e();var n}function sa(t){return t&&t.split("#")[0]}function bp(t,e){var n=setTimeout(t,e);return n!=null&&n.unref&&(n==null||n.unref()),n}var DL=t=>t instanceof Error,S6={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}},jL=S6.info;function E6(t){if(Us(t))return{boolValue:t};if(typeof t=="number")return Number.isFinite(t)?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:{stringValue:String(t)};if(typeof t=="string")return{stringValue:t};if(Qe(t))return{arrayValue:{values:t.map((e=>E6(e)))}};try{return{stringValue:JSON.stringify(t)}}catch{return{stringValue:String(t)}}}function rm(t){var e=[];for(var n in t){var r=t[n];dr(r)||ge(r)||e.push({key:n,value:E6(r)})}return e}function FL(t,e){var n=S6[t.level||"info"]||jL,r=n.text,s=n.number,i=String(Date.now())+"000000",a={};e.distinctId&&(a.posthogDistinctId=e.distinctId),e.sessionId&&(a.sessionId=e.sessionId),e.windowId&&(a["window.id"]=e.windowId),Je(e.sessionStartTimestamp)||(a.sessionStartTimestamp=String(e.sessionStartTimestamp)),Je(e.lastActivityTimestamp)||(a.lastActivityTimestamp=String(e.lastActivityTimestamp)),e.currentUrl&&(a["url.full"]=e.currentUrl),e.screenName&&(a["screen.name"]=e.screenName),e.appState&&(a["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(a.feature_flags=e.activeFeatureFlags);var c=ue({},a,t.attributes||{}),u={timeUnixNano:i,observedTimeUnixNano:i,severityNumber:s,severityText:r,body:{stringValue:t.body},attributes:rm(c)};return t.trace_id&&(u.traceId=t.trace_id),t.span_id&&(u.spanId=t.span_id),ge(t.trace_flags)||(u.flags=t.trace_flags),u}function C6(t,e,n){return ue({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":n})}function k6(t,e,n,r){return{resourceLogs:[{resource:{attributes:rm(e)},scopeLogs:[{scope:{name:n,version:r},logRecords:t}]}]}}let VL=class{constructor(t,e,n,r,s,i,a){var c;i===void 0&&(i=()=>Promise.resolve()),this._instance=t,this.Te=e,this.Ge=n,this.Ye=r,this.Xe=s,this.et=i,this.tt=a,this.rt=null,this.it=0,this.nt=0,this.st=0,this.ot=0,this.ut=!1,this.ht=e.maxBufferSize,this.dt=Math.max((c=e.maxQueueSize)!==null&&c!==void 0?c:e.maxBufferSize,e.maxBufferSize),this.ct=e.flushIntervalMs,this.vt=e.maxBatchRecordsPerPost,this.ft=e.rateCapWindowMs,this.yt=e.maxLogsPerInterval}reset(){this.bt(),this.rt=null,this.st=0,this.ot=0,this.ut=!1,this.it=0,this.nt=0,this.vt=this.Te.maxBatchRecordsPerPost}onReconnect(){this.nt=0,this._t()}captureLog(t){if(!this._instance.isDisabled&&!this._instance.optedOut&&t!=null&&t.body){var e=this.wt(t);if(e!==null)if(e.body){if(this.xt()){var n={record:FL(e,this.Ye())};this.Xe((()=>this.kt(n)))}}else this.Ge.info("Log was rejected in beforeSend function")}}wt(t){var e=this.Te.beforeSend;if(!e)return t;var n=Qe(e)?e:[e],r=t;for(var s of n)try{var i=s(r);if(!i)return this.Ge.info("Log was rejected in beforeSend function"),null;r=i}catch(a){return this.Ge.error("Error in beforeSend function for log:",a),null}return r}xt(){if(this.yt===void 0)return!0;var t=Date.now(),e=t-this.st;return this.ft>e&&e>=0||(this.st=t,this.ot=0,this.ut=!1),this.yt>this.ot?(this.ot++,!0):(this.ut||(this.Ge.warn("captureLog dropping logs: exceeded "+this.yt+" logs per "+this.ft+"ms"),this.ut=!0),!1)}flush(){var t=this;return en((function*(){if(!t._instance.isDisabled)return t.rt||(t.rt=t.St().finally((()=>{t.rt=null}))),t.rt}))()}St(){var t=this;return en((function*(){var e;t.bt();var n=(e=t._instance.getPersistedProperty(Bi.LogsQueue))!==null&&e!==void 0?e:[];if(n.length!==0)for(var r=n.length,s=0;n.length>0&&r>s;){var i,a;t.it=0;var c=Math.min(n.length,t.vt),u=n.slice(0,c),f=k6(u.map((p=>p.record)),t.Ct(),(i=t.tt)!==null&&i!==void 0?i:t._instance.getLibraryId(),t._instance.getLibraryVersion()),h=yield t._instance.Mt(f);if(h.kind==="too-large"&&u.length>1)t.vt=Math.max(1,Math.floor(u.length/2)),t.Ge.warn("Received 413 when sending logs batch of size "+u.length+", reducing batch size to "+t.vt);else if(h.kind==="retry-later"||(h.kind==="too-large"?t.Ge.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."):h.kind==="ok"&&t.Te.maxBatchRecordsPerPost>t.vt&&(t.vt=Math.min(t.Te.maxBatchRecordsPerPost,t.vt+1)),yield t.It(u.length),n=(a=t._instance.getPersistedProperty(Bi.LogsQueue))!==null&&a!==void 0?a:[],s+=u.length,h.kind==="fatal"))throw h.error}}))()}It(t){var e=this;return en((function*(){var n,r=Math.max(0,t-e.it),s=(n=e._instance.getPersistedProperty(Bi.LogsQueue))!==null&&n!==void 0?n:[];e._instance.setPersistedProperty(Bi.LogsQueue,s.slice(r)),yield e.et()}))()}Ct(){return C6(this.Te,this._instance.getLibraryId(),this._instance.getLibraryVersion())}kt(t){var e;if(!this._instance.optedOut){var n=(e=this._instance.getPersistedProperty(Bi.LogsQueue))!==null&&e!==void 0?e:[];this.dt>n.length||(n.shift(),this.it++,this.Ge.info("Logs queue is full, dropping oldest record.")),n.push(t),this._instance.setPersistedProperty(Bi.LogsQueue,n),this.ht>n.length?this.Tt():this._t()}}Tt(t){t===void 0&&(t=this.ct),this.Et||(this.Et=bp((()=>{this.Et=void 0,this._t()}),t))}Rt(){var t=Math.min(Math.max(0,this.nt-1),6);return this.ct*Math.pow(2,t)}Pt(){var t=this._instance.getPersistedProperty(Bi.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return en((function*(){e.bt();var n=e.flush().catch((()=>{}));t!==void 0?yield Promise.race([n,new Promise((r=>bp(r,t)))]):yield n}))()}flushWithTimeout(t){var e=this;return en((function*(){var n=!1,r=e.flush(),s=new Promise((i=>bp((()=>{n=!0,i()}),t)));try{yield Promise.race([r,s])}finally{n&&r.catch((()=>{}))}}))()}_t(){this.flush().then((()=>{this.nt=0}),(t=>{this.nt++,this.Ge.error("PostHog logs flush failed:",t)})).finally((()=>{!this._instance.isDisabled&&this.Pt()&&this.Tt(this.Rt())}))}bt(){this.Et&&(clearTimeout(this.Et),this.Et=void 0)}};var gv=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function EE(t){return String(t)+"000000"}function CE(t,e,n,r){var s="";return r&&(s=Object.keys(r).sort().map((i=>JSON.stringify(i)+":"+JSON.stringify(r[i]))).join(",")),t+"\0"+e+"\0"+(n??"")+"\0"+s}let $L=class{constructor(t,e,n){this._instance=t,this.Te=e,this.Ge=n,this.Ot=new Map,this.rt=null,this.Ft=!1,this.At=new Map,this.Lt=new Set,this.$t=0}count(t,e,n){e===void 0&&(e=1),this.Nt({name:t,type:"count",value:e,unit:n==null?void 0:n.unit,attributes:n==null?void 0:n.attributes})}gauge(t,e,n){this.Nt({name:t,type:"gauge",value:e,unit:n==null?void 0:n.unit,attributes:n==null?void 0:n.attributes})}histogram(t,e,n){this.Nt({name:t,type:"histogram",value:e,unit:n==null?void 0:n.unit,attributes:n==null?void 0:n.attributes})}flush(){var t=this,e=this.rt,n=(function(){var s=en((function*(){e&&(yield e.catch((()=>{}))),yield t.Dt()}));return function(){return s.apply(this,arguments)}})(),r=n().finally((()=>{this.rt===r&&(this.rt=null)}));return this.rt=r,r}drainWindow(){if(this.Ot.size===0)return null;var t=this.Ot;return this.Ot=new Map,this.Ft=!1,this.At=new Map,this.Lt=new Set,this.qt(t)}reset(){this.$t++,this.bt(),this.Ot=new Map,this.rt=null,this.Ft=!1,this.At=new Map,this.Lt=new Set}Nt(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var e=this.wt(t);if(e!==null)if(e.name&&typeof e.name=="string")if(typeof e.value=="number"&&Number.isFinite(e.value))if(e.type==="count"&&0>e.value)this.Ge.warn("Dropping count '"+e.name+"': counters are monotonic, value must be >= 0");else{var n,r;try{n=e.attributes?ue({},e.attributes):void 0,r=CE(e.type,e.name,e.unit,n)}catch(a){return void this.Ge.warn("Dropping metric '"+e.name+"': attributes could not be serialized",a)}var s=this.Ot.get(r);if(!s){if(!this.jt())return;s={name:e.name,type:e.type,unit:e.unit,attributes:n,windowStartMs:Date.now()},this.Ot.set(r,s)}var i=this.At.get(e.name);i===void 0?this.At.set(e.name,e.type):i===e.type||this.Lt.has(e.name)||(this.Lt.add(e.name),this.Ge.warn("Metric name '"+e.name+"' is already used as a "+i+"; recording it as a "+e.type+" too will blend both series in charts. Use a distinct name.")),this.Ht(s,e.value),this.Tt()}else this.Ge.warn("Dropping metric '"+e.name+"': value must be a finite number");else this.Ge.warn("Dropping metric with empty name")}}jt(){return this.Te.maxSeriesPerFlush>this.Ot.size||(this.Ft||(this.Ft=!0,this.Ge.warn("Metric series cap reached ("+this.Te.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Ht(t,e){var n;switch(t.type){case"count":t.total=((n=t.total)!==null&&n!==void 0?n:0)+e;break;case"gauge":t.last=e;break;case"histogram":t.hist||(t.hist={count:0,sum:0,min:e,max:e,bucketCounts:new Array(gv.length+1).fill(0)});var r=t.hist;r.count+=1,r.sum+=e,r.min=Math.min(r.min,e),r.max=Math.max(r.max,e),r.bucketCounts[(function(s,i){for(var a=0;i.length>a;a++)if(i[a]>=s)return a;return i.length})(e,gv)]+=1}}wt(t){var e=this.Te.beforeSend;if(!e)return t;var n=Qe(e)?e:[e],r=t;for(var s of n)try{var i=s(r);if(!i)return this.Ge.info("Metric was rejected in beforeSend function"),null;r=i}catch(a){return this.Ge.error("Error in beforeSend function for metric:",a),null}return r}Tt(){this.Et||(this.Et=bp((()=>{this.Et=void 0,this.flush().catch((t=>{this.Ge.error("Metrics flush failed:",t)}))}),this.Te.flushIntervalMs))}bt(){this.Et&&(clearTimeout(this.Et),this.Et=void 0)}Dt(){var t=this;return en((function*(){if(t.Ot.size!==0){var e=t.Ot;t.Ot=new Map,t.Ft=!1,t.At=new Map,t.Lt=new Set;var n=t.$t,r=yield t._instance.Bt(t.qt(e));if(n===t.$t)switch(r.kind){case"ok":return;case"retry-later":return t.Ut(e),void t.Tt();case"too-large":return void t.Ge.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.Ge.error("Failed to send metrics batch:",r.error)}}}))()}qt(t){return e=this.zt(t),n=(function(i,a,c){return ue({},i.resourceAttributes,{"service.name":i.serviceName||"unknown_service"},i.environment&&{"deployment.environment":i.environment},i.serviceVersion&&{"service.version":i.serviceVersion},{"telemetry.sdk.name":a,"telemetry.sdk.version":c})})(this.Te,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),s=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:rm(n)},scopeMetrics:[{scope:{name:r,version:s},metrics:e}]}]};var e,n,r,s}zt(t){var e=EE(Date.now()),n=new Map;for(var r of t.values()){var s,i=CE(r.type,r.name,r.unit,void 0),a=n.get(i);a||(a=ue({name:r.name},r.unit&&{unit:r.unit}),r.type==="count"?a.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:r.type==="gauge"?a.gauge={dataPoints:[]}:a.histogram={aggregationTemporality:1,dataPoints:[]},n.set(i,a));var c=rm((s=r.attributes)!==null&&s!==void 0?s:{}),u=EE(r.windowStartMs);if(r.type==="count"){var f,h={attributes:c,startTimeUnixNano:u,timeUnixNano:e,asDouble:(f=r.total)!==null&&f!==void 0?f:0};a.sum.dataPoints.push(h)}else if(r.type==="gauge"){var p,m={attributes:c,timeUnixNano:e,asDouble:(p=r.last)!==null&&p!==void 0?p:0};a.gauge.dataPoints.push(m)}else r.hist&&a.histogram.dataPoints.push({attributes:c,startTimeUnixNano:u,timeUnixNano:e,count:r.hist.count,sum:r.hist.sum,min:r.hist.min,max:r.hist.max,bucketCounts:r.hist.bucketCounts,explicitBounds:gv})}return Array.from(n.values())}Ut(t){var e,n;for(var r of t){var s=r[0],i=r[1],a=this.Ot.get(s);if(a)switch(a.windowStartMs=Math.min(a.windowStartMs,i.windowStartMs),a.type){case"count":a.total=((e=a.total)!==null&&e!==void 0?e:0)+((n=i.total)!==null&&n!==void 0?n:0);break;case"gauge":break;case"histogram":if(i.hist)if(a.hist){a.hist.count+=i.hist.count,a.hist.sum+=i.hist.sum,a.hist.min=Math.min(a.hist.min,i.hist.min),a.hist.max=Math.max(a.hist.max,i.hist.max);for(var c=0;a.hist.bucketCounts.length>c;c++)a.hist.bucketCounts[c]+=i.hist.bucketCounts[c]}else a.hist=i.hist}else this.jt()&&this.Ot.set(s,i)}}};var Bh,kE,vv;function HL(t){var e=globalThis._posthogChunkIds;if(e){var n=Object.keys(e);return vv&&n.length===kE||(kE=n.length,vv=n.reduce(((r,s)=>{Bh||(Bh={});var i=Bh[s];if(i)r[i[0]]=i[1];else for(var a=t(s),c=a.length-1;c>=0;c--){var u=a[c],f=u==null?void 0:u.filename,h=e[s];if(f&&h){r[f]=h,Bh[s]=[f,h];break}}return r}),{})),vv}}class zL{constructor(e,n,r){r===void 0&&(r=[]),this.coercers=e,this.stackParser=n,this.modifiers=r}buildFromUnknown(e,n){n===void 0&&(n={});var r=n&&n.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(r,n,0).apply(e),i=this.buildParsingContext(n),a=this.parseStacktrace(s,i);return{$exception_list:this.convertToExceptionList(a,r),$exception_level:"error"}}modifyFrames(e){var n=this;return en((function*(){for(var r of e)r.stacktrace&&r.stacktrace.frames&&Qe(r.stacktrace.frames)&&(r.stacktrace.frames=yield n.applyModifiers(r.stacktrace.frames));return e}))()}coerceFallback(e){var n;return{type:"Error",value:"Unknown error",stack:(n=e.syntheticException)==null?void 0:n.stack,synthetic:!0}}parseStacktrace(e,n){var r,s;return e.cause!=null&&(r=this.parseStacktrace(e.cause,n)),e.stack!=""&&e.stack!=null&&(s=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?n.skipFirstLines:0),n.chunkIdMap)),ue({},e,{cause:r,stack:s})}applyChunkIds(e,n){return e.map((r=>(r.filename&&n&&(r.chunk_id=n[r.filename]),r)))}applyCoercers(e,n){for(var r of this.coercers)if(r.match(e))return r.coerce(e,n);return this.coerceFallback(n)}applyModifiers(e){var n=this;return en((function*(){var r=e;for(var s of n.modifiers)r=yield s(r);return r}))()}convertToExceptionList(e,n){var r,s,i,a={type:e.type,value:e.value,mechanism:{type:(r=n.type)!==null&&r!==void 0?r:"generic",handled:(s=n.handled)===null||s===void 0||s,synthetic:(i=e.synthetic)!==null&&i!==void 0&&i}};e.stack&&(a.stacktrace={type:"raw",frames:e.stack});var c=[a];return e.cause!=null&&c.push(...this.convertToExceptionList(e.cause,ue({},n,{handled:!0}))),c}buildParsingContext(e){var n;return{chunkIdMap:HL(this.stackParser),skipFirstLines:(n=e.skipFirstLines)!==null&&n!==void 0?n:1}}buildCoercingContext(e,n,r){r===void 0&&(r=0);var s=(i,a)=>{if(4>=a){var c=this.buildCoercingContext(e,n,a);return this.applyCoercers(i,c)}};return ue({},n,{syntheticException:r==0?n.syntheticException:void 0,mechanism:e,apply:i=>s(i,r),next:i=>s(i,r+1)})}}var Xc="?";function hy(t,e,n,r,s){var i={platform:t,filename:e,function:n==="<anonymous>"?Xc:n,in_app:!0};return ge(r)||(i.lineno=r),ge(s)||(i.colno=s),i}var P6=(t,e)=>{var n=t.indexOf("safari-extension")!==-1,r=t.indexOf("safari-web-extension")!==-1;return n||r?[t.indexOf("@")!==-1?t.split("@")[0]:Xc,n?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},UL=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,BL=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,WL=/\((\S*)(?::(\d+))(?::(\d+))\)/,GL=(t,e)=>{var n=UL.exec(t);if(n)return hy(e,n[1],Xc,+n[2],+n[3]);var r=BL.exec(t);if(r){if(r[2]&&r[2].indexOf("eval")===0){var s=WL.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var i=P6(r[1]||Xc,r[2]);return hy(e,i[1],i[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},KL=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ZL=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,qL=(t,e)=>{var n=KL.exec(t);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){var r=ZL.exec(n[3]);r&&(n[1]=n[1]||"eval",n[3]=r[1],n[4]=r[2],n[5]="")}var s=n[3],i=n[1]||Xc,a=P6(i,s);return hy(e,s=a[1],i=a[0],n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},PE=/\(error: (.*)\)/;class YL{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,n){var r=xt(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:r?e.stack:void 0,cause:e.cause?n.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var n=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?n+": "+e.message:n}isDOMException(e){return Qp(e,"DOMException")}isDOMError(e){return Qp(e,"DOMError")}}class XL{match(e){return(n=>n instanceof Error)(e)}coerce(e,n){return{type:this.getType(e),value:this.getMessage(e,n),stack:this.getStack(e),cause:e.cause?n.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,n){var r=e.message;return String(r.error&&typeof r.error.message=="string"?r.error.message:r)}getStack(e){return e.stacktrace||e.stack||void 0}}class QL{constructor(){}match(e){return Qp(e,"ErrorEvent")&&e.error!=null}coerce(e,n){var r;return n.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}}var JL=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class eN{match(e){return typeof e=="string"}coerce(e,n){var r,s=this.getInfos(e),i=s[0],a=s[1];return{type:i??"Error",value:a??e,stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}getInfos(e){var n="Error",r=e,s=e.match(JL);return s&&(n=s[1],r=s[2]),[n,r]}}var tN=["fatal","error","warning","log","info","debug"];function T6(t,e){e===void 0&&(e=40);var n=Object.keys(t);if(n.sort(),!n.length)return"[object has no keys]";for(var r=n.length;r>0;r--){var s=n.slice(0,r).join(", ");if(e>=s.length)return r===n.length?s:s.length>e?s.slice(0,e)+"...":s}return""}class nN{match(e){return typeof e=="object"&&e!==null}coerce(e,n){var r,s=this.getErrorPropertyFromObject(e);return s?n.apply(s):{type:this.getType(e),value:this.getValue(e),stack:(r=n.syntheticException)==null?void 0:r.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return y2(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var n="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(n+=" with message: '"+e.message+"'"),n}if("message"in e&&typeof e.message=="string")return e.message;var r=this.getObjectClassName(e);return(r&&r!=="Object"?"'"+r+"'":"Object")+" captured as exception with keys: "+T6(e)}isSeverityLevel(e){return xt(e)&&!ly(e)&&tN.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var n in e)if({}.hasOwnProperty.call(e,n)){var r=e[n];if(DL(r))return r}}getObjectClassName(e){try{var n=Object.getPrototypeOf(e);return n?n.constructor.name:void 0}catch{return}}}class rN{match(e){return y2(e)}coerce(e,n){var r,s=e.constructor.name;return{type:s,value:s+" captured as exception with keys: "+T6(e),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}}class sN{match(e){return n6(e)}coerce(e,n){var r;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}}class iN{match(e){return Qp(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!y2(e))return!1;try{var n=e.detail;return n!=null&&typeof n=="object"&&"reason"in n}catch{return!1}}coerce(e,n){var r,s=this.getUnhandledRejectionReason(e);return n6(s)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(s),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}:n.apply(s)}getUnhandledRejectionReason(e){try{if("reason"in e)return e.reason;if("detail"in e&&e.detail!=null&&typeof e.detail=="object"&&"reason"in e.detail)return e.detail.reason}catch{}return e}}var sm="$message",im="$timestamp",oN=new Set([sm,im]),yv={enabled:!0,max_bytes:32768};function om(t){var e;return t?{enabled:(e=t.enabled)!==null&&e!==void 0?e:yv.enabled,max_bytes:lN(t.max_bytes,yv.max_bytes)}:ue({},yv)}class aN{constructor(e){this.Vt=[],this.Wt=0,this.Te=om(e)}setConfig(e){this.Te=om(e),this.Zt()}add(e){var n=(function(s){var i;try{i=J8(s)}catch{return}try{var a=JSON.parse(i);if(!Nt(a))return;var c=a,u=c[sm],f=c[im];return!xt(u)||u.trim().length===0||!xt(f)&&!$n(f)?void 0:{step:c,json:i}}catch{return}})(e);if(n){var r=(function(s){if(typeof TextEncoder<"u")return new TextEncoder().encode(s).length;for(var i=encodeURIComponent(s),a=0,c=0;i.length>c;c++)i[c]==="%"?(a+=1,c+=2):a+=1;return a})(n.json);r>this.Te.max_bytes||(this.Vt.push({step:n.step,bytes:r}),this.Wt+=r,this.Zt())}}getAttachable(){return this.Vt.map((e=>e.step))}clear(){this.Vt=[],this.Wt=0}size(){return this.Vt.length}Zt(){for(;this.Wt>this.Te.max_bytes&&this.Vt.length>0;){var e=this.Vt.shift();e&&(this.Wt-=e.bytes)}}}function lN(t,e){if(!$n(t)||t===1/0||t===-1/0)return e;var n=Math.floor(t);return 0>n?e:n}var R6=function(t,e){var n=(e===void 0?{}:e).debugEnabled,r={k(s){if(te&&(gt.DEBUG||te.POSTHOG_DEBUG||n)&&!ge(te.console)&&te.console){for(var i=("__rrweb_original__"in te.console[s])?te.console[s].__rrweb_original__:te.console[s],a=arguments.length,c=new Array(a>1?a-1:0),u=1;a>u;u++)c[u-1]=arguments[u];i(t,...c)}},debug(){for(var s=arguments.length,i=new Array(s),a=0;s>a;a++)i[a]=arguments[a];r.k("debug",...i)},info(){for(var s=arguments.length,i=new Array(s),a=0;s>a;a++)i[a]=arguments[a];r.k("log",...i)},warn(){for(var s=arguments.length,i=new Array(s),a=0;s>a;a++)i[a]=arguments[a];r.k("warn",...i)},error(){for(var s=arguments.length,i=new Array(s),a=0;s>a;a++)i[a]=arguments[a];r.k("error",...i)},critical(){for(var s=arguments.length,i=new Array(s),a=0;s>a;a++)i[a]=arguments[a];console.error(t,...i)},uninitializedWarning(s){r.error("You must initialize PostHog before calling "+s)},createLogger:(s,i)=>R6(t+" "+s,i)};return r},_e=R6("[PostHog.js]"),Vt=_e.createLogger,cN=Vt("[ExternalScriptsLoader]"),_v=(t,e,n)=>{if(t.config.disable_external_dependency_loading)return cN.warn(e+" was requested but loading of external scripts is disabled."),n("Loading of external scripts is disabled");var r=Se==null?void 0:Se.querySelectorAll("script");if(r){for(var s,i=function(){if(r[a].src===e){var u=r[a];return u.__posthog_loading_callback_fired?{v:n()}:(u.addEventListener("load",(f=>{u.__posthog_loading_callback_fired=!0,n(void 0,f)})),u.onerror=f=>n(f),{v:void 0})}},a=0;r.length>a;a++)if(s=i())return s.v}var c=()=>{if(!Se)return n("document not found");var u=Se.createElement("script");if(u.type="text/javascript",u.crossOrigin="anonymous",u.src=e,u.onload=p=>{u.__posthog_loading_callback_fired=!0,n(void 0,p)},u.onerror=p=>n(p),t.config.prepare_external_dependency_script&&(u=t.config.prepare_external_dependency_script(u)),!u)return n("prepare_external_dependency_script returned null");if(t.config.external_scripts_inject_target==="head")Se.head.appendChild(u);else{var f,h=Se.querySelectorAll("body > script");h.length>0?(f=h[0].parentNode)==null||f.insertBefore(u,h[0]):Se.body.appendChild(u)}};Se!=null&&Se.body?c():Se==null||Se.addEventListener("DOMContentLoaded",c)};$e.__PosthogExtensions__=$e.__PosthogExtensions__||{},$e.__PosthogExtensions__.loadExternalDependency=(t,e,n)=>{if(e!=="remote-config"){var r;if(t.config.strict_script_versioning)r=t.requestRouter.endpointFor("assets","/static/"+t.version+"/"+e+".js");else{var s="/static/"+e+".js?v="+t.version;if(e==="toolbar"){var i=3e5;s=s+"&t="+Math.floor(Date.now()/i)*i}r=t.requestRouter.endpointFor("assets",s)}_v(t,r,n)}else{var a=t.requestRouter.endpointFor("assets","/array/"+t.config.token+"/config.js");_v(t,a,n)}},$e.__PosthogExtensions__.loadSiteApp=(t,e,n)=>{var r=t.requestRouter.endpointFor("api",e);_v(t,r,n)};gt.DEBUG=!1,gt.LIB_VERSION="1.408.1",gt.LIB_NAME="web";var A6="$people_distinct_id",am="$device_id",xv="$device_model",hd="__alias",pd="__timers",py="$autocapture_disabled_server_side",my="$heatmaps_enabled_server_side",gy="$exception_capture_enabled_server_side",vy="$error_tracking_suppression_rules",yy="$error_tracking_capture_extension_exceptions",_y="$web_vitals_enabled_server_side",S2="$dead_clicks_enabled_server_side",E2="$product_tours_enabled_server_side",xy="$web_vitals_allowed_metrics",sl="$session_recording_remote_config",I6="$replay_sample_rate",M6="$replay_override_sampling",O6="$replay_override_linked_flag",L6="$replay_override_url_trigger",N6="$replay_override_event_trigger",_c="$sesid",C2="$session_is_sampled",tl="$enabled_feature_flags",Sp="$active_feature_flags",md="$early_access_features",wy="$feature_flag_details",Ep="$feature_flag_payloads",by="$feature_flag_request_id",lm="$minimal_flag_called_events",zi="$override_feature_flags",pc="$override_feature_flag_payloads",Ya="$stored_person_properties",Xa="$stored_group_properties",Sy="$surveys",cm="$surveys_loaded_at",Ey="$surveys_activated",Cp="$surveys_activated_session",gd="ph_product_tours",bd="$flag_call_reported",Cy="$flag_call_reported_session_id",ky="$feature_flag_errors",$d="$feature_flag_evaluated_at",Fs="$user_state",Py="$client_session_props",Ty="$capture_rate_limit",Ry="$initial_campaign_params",Ay="$initial_referrer_info",um="$initial_person_info",dm="$epp",Wh="$posthog_cookieless",D6="$cookieless_mode",j6="$sdk_debug_extensions_init_method",F6="$sdk_debug_extensions_init_time_ms",V6="$sdk_debug_recording_script_not_loaded",k2="PostHog loadExternalDependency extension not found.",Qa="on_reject",Xi="always",rc="anonymous",sc="identified",Iy="identified_only",fm="visibilitychange",hm="beforeunload",mc="$pageview",wv="$pageleave",bv="$identify",TE="$groupidentify";function Gh(t,e){Qe(t)&&t.forEach(e)}function wt(t,e){if(!Je(t))if(Qe(t))t.forEach(e);else if(xL(t))t.forEach(((r,s)=>e(r,s)));else for(var n in t)t6.call(t,n)&&e(t[n],n)}var At=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;e>r;r++)n[r-1]=arguments[r];for(var s of n)for(var i in s)s[i]!==void 0&&(t[i]=s[i]);return t};function kp(t){for(var e=Object.keys(t),n=e.length,r=new Array(n);n--;)r[n]=[e[n],t[e[n]]];return r}var RE=function(t){try{return t()}catch{return}},uN=function(t){return function(){try{for(var e=arguments.length,n=new Array(e),r=0;e>r;r++)n[r]=arguments[r];return t.apply(this,n)}catch(s){_e.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),_e.critical(s)}}},P2=function(t){var e={};return wt(t,(function(n,r){(xt(n)&&n.length>0||$n(n))&&(e[r]=n)})),e},dN=["herokuapp.com","vercel.app","netlify.app"];function fN(t){var e=t==null?void 0:t.hostname;if(!xt(e))return!1;var n=e.split(".").slice(-2).join(".");for(var r of dN)if(n===r)return!1;return!0}function zt(t,e,n,r){var s=r??{},i=s.capture,a=s.passive;t==null||t.addEventListener(e,n,{capture:i!==void 0&&i,passive:a===void 0||a})}function $6(t){return t.name==="ph_toolbar_internal"}var H6=t=>{if(Se){try{for(var e=t+"=",n=Se.cookie.split(";").filter((i=>i.length)),r=0;n.length>r;r++){for(var s=n[r];s.charAt(0)==" ";)s=s.substring(1,s.length);if(s.indexOf(e)===0)return decodeURIComponent(s.substring(e.length,s.length))}}catch{}return null}};Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return $n(t)&&isFinite(t)&&Math.floor(t)===t});class pm{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,n,r,s){if(!Number.isInteger(e)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(s)||0>e||0>n||0>r||0>s||e>0xffffffffffff||n>4095||r>1073741823||s>4294967295)throw new RangeError("invalid field value");var i=new Uint8Array(16);return i[0]=e/Math.pow(2,40),i[1]=e/Math.pow(2,32),i[2]=e/Math.pow(2,24),i[3]=e/Math.pow(2,16),i[4]=e/256,i[5]=e,i[6]=112|n>>>8,i[7]=n,i[8]=128|r>>>24,i[9]=r>>>16,i[10]=r>>>8,i[11]=r,i[12]=s>>>24,i[13]=s>>>16,i[14]=s>>>8,i[15]=s,new pm(i)}toString(){for(var e="",n=0;this.bytes.length>n;n++)e=e+(this.bytes[n]>>>4).toString(16)+(15&this.bytes[n]).toString(16),n!==3&&n!==5&&n!==7&&n!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new pm(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var n=0;16>n;n++){var r=this.bytes[n]-e.bytes[n];if(r!==0)return Math.sign(r)}return 0}}class hN{generate(){var e=this.generateOrAbort();if(!ge(e))return e;this.S=0;var n=this.generateOrAbort();if(ge(n))throw new Error("Could not generate UUID after timestamp reset");return n}generateOrAbort(){var e=Date.now();if(e>this.S)this.S=e,this.C();else{if(this.S>=e+1e4)return;this.M++,this.M>4398046511103&&(this.S++,this.C())}return pm.fromFieldsV7(this.S,Math.trunc(this.M/Math.pow(2,30)),this.M&Math.pow(2,30)-1,this.I.nextUint32())}C(){this.M=1024*this.I.nextUint32()+(1023&this.I.nextUint32())}constructor(){this.S=0,this.M=0,this.I=new pN}}var AE,z6=t=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;t.length>e;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};te&&!ge(te.crypto)&&crypto.getRandomValues&&(z6=t=>crypto.getRandomValues(t));class pN{nextUint32(){return this.R.length>this.O||(z6(this.R),this.O=0),this.R[this.O++]}constructor(){this.R=new Uint32Array(8),this.O=1/0}}var Ki=()=>mN().toString(),mN=()=>(AE||(AE=new hN)).generate(),Xu="",gN=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,Qi={N:()=>!!Se,D(t){_e.error("cookieStore error: "+t)},A:H6,F(t){var e;try{e=JSON.parse(Qi.A(t))||{}}catch{}return e},q(t,e,n,r,s){if(!Se)return!1;try{var i="",a="",c=(function(h,p){if(p){var m=(function(x,y){if(y===void 0&&(y=Se),Xu)return Xu;if(!y||["localhost","127.0.0.1"].includes(x))return"";for(var w=x.split("."),S=Math.min(w.length,8),T="dmn_chk_"+Ki();!Xu&&S--;){var P=w.slice(S).join("."),k=T+"=1;domain=."+P+";path=/";y.cookie=k+";max-age=3",y.cookie.includes(T)&&(y.cookie=k+";max-age=0",Xu=P)}return Xu})(h);if(!m){var _=(x=>{var y=x.match(gN);return y?y[0]:""})(h);_!==m&&_e.info("Warning: cookie subdomain discovery mismatch",_,m),m=_}return m?"; domain=."+m:""}return""})(Se.location.hostname,r);if(n){var u=new Date;u.setTime(u.getTime()+864e5*n),i="; expires="+u.toUTCString()}s&&(a="; secure");var f=t+"="+encodeURIComponent(JSON.stringify(e))+i+"; SameSite=Lax; path=/"+c+a;return f.length>3686.4&&_e.warn("cookieStore warning: large cookie, len="+f.length),Se.cookie=f,!0}catch{return!1}},P(t,e){if(Se!=null&&Se.cookie)try{Qi.q(t,"",-1,e)}catch{return}}},Sv=null,St={N(){if(!dr(Sv))return Sv;var t=!0;if(ge(te))t=!1;else try{var e="__mplssupport__";St.q(e,"xyz"),St.A(e)!=='"xyz"'&&(t=!1),St.P(e)}catch{t=!1}return t||_e.error("localStorage unsupported; falling back to cookie store"),Sv=t,t},D(t){_e.error("localStorage error: "+t)},A(t){try{return te==null?void 0:te.localStorage.getItem(t)}catch(e){St.D(e)}return null},F(t){try{return JSON.parse(St.A(t))||{}}catch{}return null},q(t,e){try{return te==null||te.localStorage.setItem(t,JSON.stringify(e)),!0}catch(n){St.D(n)}return!1},P(t){try{te==null||te.localStorage.removeItem(t)}catch(e){St.D(e)}}},vN=[am,"distinct_id",_c,C2,dm,um,Fs],Kh={},yN={N:()=>!0,D(t){_e.error("memoryStorage error: "+t)},A:t=>Kh[t]||null,F:t=>Kh[t]||null,q:(t,e)=>(Kh[t]=e,!0),P(t){delete Kh[t]}},ja=null,jn={N(){if(!dr(ja))return ja;if(ja=!0,ge(te))ja=!1;else try{var t="__support__";jn.q(t,"xyz"),jn.A(t)!=='"xyz"'&&(ja=!1),jn.P(t)}catch{ja=!1}return ja},D(t){_e.error("sessionStorage error: ",t)},A(t){try{return te==null?void 0:te.sessionStorage.getItem(t)}catch(e){jn.D(e)}return null},F(t){try{return JSON.parse(jn.A(t))||null}catch{}return null},q(t,e){try{return te==null||te.sessionStorage.setItem(t,JSON.stringify(e)),!0}catch(n){jn.D(n)}return!1},P(t){try{te==null||te.sessionStorage.removeItem(t)}catch(e){jn.D(e)}}};class _N{constructor(e){this._instance=e}get Te(){return this._instance.config}get consent(){return this.Gt()?0:this.Qt}isOptedOut(){return this.Te.cookieless_mode===Xi||this.isRejected()||this.consent===-1&&this.Te.cookieless_mode===Qa}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Te.opt_out_capturing_by_default}optInOut(e){this.Jt.q(this.Kt,e?1:0,this.Te.cookie_expiration,this.Te.cross_subdomain_cookie,this.Te.secure_cookie)}reset(){this.Jt.P(this.Kt,this.Te.cross_subdomain_cookie)}get Kt(){var e=this._instance.config,n=e.token,r=e.opt_out_capturing_cookie_prefix;return e.consent_persistence_name||(r?r+n:"__ph_opt_in_out_"+n)}get Qt(){var e=this.Jt.A(this.Kt);return pv(e)?1:Ge(EL,e)?0:-1}get Jt(){var e=this.Te.opt_out_capturing_persistence_type,n=e==="localStorage"?St:Qi;if(!this.Yt||this.Yt!==n){this.Yt=n;var r=e==="localStorage"?Qi:St;r.A(this.Kt)&&(this.Yt.A(this.Kt)||this.optInOut(pv(r.A(this.Kt))),r.P(this.Kt,this.Te.cross_subdomain_cookie))}return this.Yt}Gt(){return!!this.Te.respect_dnt&&[ar==null?void 0:ar.doNotTrack,ar==null?void 0:ar.msDoNotTrack,$e.doNotTrack].some((e=>pv(e)))}}function U6(t,e){var n,r=t==null||(n=t.config)==null?void 0:n.get_current_url;if(!zs(r))return e;try{var s=r(e);return xt(s)&&s?s:e}catch(i){return _e.error("Error in get_current_url, falling back to window.location.href",i),e}}var B6="__POSTHOG_TOOLBAR__",xN=1,wN=3,bN=11;function IE(t){return t instanceof Element&&(t.id===B6||!(t.closest==null||!t.closest(".toolbar-global-fade-container")))}function ia(t){return!!t&&t.nodeType===xN}function qr(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function W6(t){return!!t&&t.nodeType===wN}function G6(t){return!!t&&t.nodeType===bN&&ia(t.host)}var K6=1e3;function T2(t){return t?e0(t).split(/\s+/):[]}function ME(t,e){var n=(function(r){var s,i=te==null||(s=te.location)==null?void 0:s.href;return ge(i)?void 0:U6(r,i)})(e);return!!(n&&t&&t.some((r=>n.match(r))))}function mm(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return T2(e)}function Z6(t){return Je(t)?null:e0(t).split(/(\s+)/).filter((e=>Sd(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Hd(t){var e="";return Oy(t)&&!Q6(t)&&t.childNodes&&t.childNodes.length&&wt(t.childNodes,(function(n){var r;W6(n)&&n.textContent&&(e+=(r=Z6(n.textContent))!==null&&r!==void 0?r:"")})),e0(e)}function Ev(t){var e;return ge(t.target)?t.srcElement||null:(e=t.target)!=null&&e.shadowRoot?t.composedPath()[0]||null:t.target||null}var R2=["a","button","form","input","select","textarea","label"];function My(t,e){if(ge(e))return!0;var n,r=function(i){if(e.some((a=>(function(c,u){var f=c.matches||c.matchesSelector||c.msMatchesSelector||c.mozMatchesSelector||c.webkitMatchesSelector||c.oMatchesSelector;try{return!!f&&f.call(c,u)}catch{return!1}})(i,a))))return{v:!0}};for(var s of t)if(n=r(s))return n.v;return!1}function q6(t){var e=t.parentNode;return!(!e||!ia(e))&&e}var SN=[".ph-no-autocapture","[data-ph-no-autocapture]"],Y6=["next","previous","prev",">","<"],EN=[...Y6,"+","-","−","–"],OE=(t,e)=>/[a-z0-9]/i.test(e)?t.includes(e):t===e,LE=[".ph-no-rageclick",".ph-no-capture"],CN=["","text","search","email","password","url","tel","number"];function NE(t,e){if(!te||A2(t))return!1;var n,r,s,i,a;if(Us(e)?(n=!!e&&LE,r=void 0,s=!1):(n=(i=e==null?void 0:e.css_selector_ignorelist)!==null&&i!==void 0?i:LE,r=e==null?void 0:e.content_ignorelist,s=(a=e==null?void 0:e.ignore_text_selection)!==null&&a!==void 0&&a),n===!1||s&&(function(u){return!(!u||!ia(u))&&(!!qr(u,"textarea")||(qr(u,"input")?Ge(CN,(u.getAttribute("type")||"").toLowerCase()):(function(f){if(f.isContentEditable)return!0;var h=f.getAttribute==null?void 0:f.getAttribute("contenteditable");return h==="true"||h===""})(u)))})(t))return!1;var c=X6(t,!1).targetElementList;return!(function(u,f){if(u===!1||ge(u))return!1;var h;if(u===!0)h=Y6;else{if(!Qe(u))return!1;if(u.length>10)return _e.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;h=u.map((p=>p.toLowerCase()))}return f.some((p=>{var m=p.safeText,_=p.ariaLabel;return h.some((x=>OE(m,x)||OE(_,x)))}))})(r,c.map((u=>{var f;return{safeText:Hd(u).toLowerCase(),ariaLabel:((f=u.getAttribute("aria-label"))==null?void 0:f.toLowerCase().trim())||""}})))&&!My(c,n)}var A2=t=>!t||qr(t,"html")||!ia(t),X6=(t,e)=>{if(!te||A2(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var n=!1,r=[t],s=t;s.parentNode&&!qr(s,"body");)if(G6(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var i=q6(s);if(!i)break;if(e||R2.indexOf(i.tagName.toLowerCase())>-1)n=!0;else try{var a=te.getComputedStyle(i);a&&a.getPropertyValue("cursor")==="pointer"&&(n=!0)}catch{}r.push(i),s=i}return{parentIsUsefulElement:n,targetElementList:r}};function Oy(t){for(var e=new Set,n=0,r=t;r.parentNode&&!qr(r,"body");r=r.parentNode){if(n++>=K6||e.has(r))return!1;e.add(r);var s=mm(r);if(Ge(s,"ph-sensitive")||Ge(s,"ph-no-capture"))return!1}if(Ge(mm(t),"ph-include"))return!0;var i=t.type||"";if(xt(i))switch(i.toLowerCase()){case"hidden":case"password":return!1}var a=t.name||t.id||"";return!xt(a)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(a.replace(/[^a-zA-Z0-9]/g,""))}function Q6(t){return!!(qr(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||qr(t,"select")||qr(t,"textarea")||t.getAttribute("contenteditable")==="true")}var J6="(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})",kN=new RegExp("^(?:"+J6+")$"),PN=new RegExp(J6),eP="\\d{3}-?\\d{2}-?\\d{4}",TN=new RegExp("^("+eP+")$"),RN=new RegExp("("+eP+")");function Sd(t,e){return e===void 0&&(e=!0),!(Je(t)||xt(t)&&(t=e0(t),(e?kN:PN).test((t||"").replace(/[- ]/g,""))||(e?TN:RN).test(t)))}function DE(t){var e=Hd(t);return Sd(e=(e+" "+tP(t)).trim())?e:""}function tP(t){var e="";return t&&t.childNodes&&t.childNodes.length&&wt(t.childNodes,(function(n){var r;if(n&&((r=n.tagName)==null?void 0:r.toLowerCase())==="span")try{var s=Hd(n);e=(e+" "+s).trim(),n.childNodes&&n.childNodes.length&&(e=(e+" "+tP(n)).trim())}catch(i){_e.error("[AutoCapture]",i)}})),e}function jE(t){return t.replace(/"|\\"/g,'\\"')}function AN(t){var e=t.attr__class;if(e)return Qe(e)?e:T2(e)}var Zh=Vt("[Dead Clicks]"),IN=()=>!0,MN=t=>{var e,n=!((e=t.instance.persistence)==null||!e.get_property(S2)),r=t.instance.config.capture_dead_clicks;return Us(r)?r:!!Nt(r)||n};class FE{get lazyLoadedDeadClicksAutocapture(){return this.Xt}constructor(e,n,r){this.instance=e,this.isEnabled=n,this.onCapture=r,this.startIfEnabledOrStop()}onRemoteConfig(e){if(e.ok){var n=e.config;"captureDeadClicks"in n&&(this.instance.persistence&&this.instance.persistence.register({[S2]:n.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.er((()=>{this.tr()})):this.stop()}er(e){var n,r;(n=$e.__PosthogExtensions__)!=null&&n.initDeadClicksAutocapture?e():(r=$e.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"dead-clicks-autocapture",(s=>{s?Zh.error("failed to load script",s):e()}))}tr(){var e;if(Se){if(!this.Xt&&(e=$e.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var n=Nt(this.instance.config.capture_dead_clicks)?ue({},this.instance.config.capture_dead_clicks):{};n.__onCapture=this.onCapture,this.onCapture&&(n.capture_dead_swipes=!1),this.Xt=$e.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this.Xt.start(Se),Zh.info("starting...")}}else Zh.error("`document` not found. Cannot start.")}stop(){this.Xt&&(this.Xt.stop(),this.Xt=void 0,Zh.info("stopping..."))}}var Cv=Vt("[SegmentIntegration]"),nP="posthog-js";function rP(t,e){var n=e===void 0?{}:e,r=n.organization,s=n.projectId,i=n.prefix,a=n.severityAllowList,c=a===void 0?["error"]:a,u=n.sendExceptionsToPostHog,f=u===void 0||u;return h=>{var p,m,_,x,y;if(c!=="*"&&!c.includes(h.level)||!t.__loaded)return h;h.tags||(h.tags={});var w=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());h.tags["PostHog Person URL"]=w,t.sessionRecordingStarted()&&(h.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var S,T=((p=h.exception)==null?void 0:p.values)||[],P=T.map((R=>ue({},R,{stacktrace:R.stacktrace?ue({},R.stacktrace,{type:"raw",frames:(R.stacktrace.frames||[]).map((L=>ue({},L,{platform:"web:javascript"})))}):void 0}))),k={$exception_message:((m=T[0])==null?void 0:m.value)||h.message,$exception_type:(_=T[0])==null?void 0:_.type,$exception_level:h.level,$exception_list:P,$sentry_event_id:h.event_id,$sentry_exception:h.exception,$sentry_exception_message:((x=T[0])==null?void 0:x.value)||h.message,$sentry_exception_type:(y=T[0])==null?void 0:y.type,$sentry_tags:h.tags};return r&&s&&(k.$sentry_url=(i||"https://sentry.io/organizations/")+r+"/issues/?project="+s+"&query="+h.event_id),f&&((S=t.exceptions)==null||S.sendExceptionEvent(k)),h}}class ON{constructor(e,n,r,s,i,a){this.name=nP,this.setupOnce=function(c){c(rP(e,{organization:n,projectId:r,prefix:s,severityAllowList:i,sendExceptionsToPostHog:a==null||a}))}}}class VE{constructor(e){this.rr=(n,r,s)=>{s&&(s.noSessionId||s.activityTimeout||s.sessionPastMaximumLength||s.crossTabAdoption)&&(_e.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:n,changeReason:s}),this.ir=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.nr()}nr(){var e;this.sr=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.rr)}destroy(){var e;(e=this.sr)==null||e.call(this),this.sr=void 0}doPageView(e,n){var r,s=this.ar(e,n);return this.ir={pathname:(r=te==null?void 0:te.location.pathname)!==null&&r!==void 0?r:"",pageViewId:n,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var n;return this.ar(e,(n=this.ir)==null?void 0:n.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.ir)==null?void 0:e.pageViewId}}ar(e,n){var r=this.ir;if(!r)return{$pageview_id:n};var s={$pageview_id:n,$prev_pageview_id:r.pageViewId},i=this._instance.scrollManager.getContext();if(i&&!this._instance.config.disable_scroll_properties){var a=i.maxScrollHeight,c=i.lastScrollY,u=i.maxScrollY,f=i.maxContentHeight,h=i.lastContentY,p=i.maxContentY;if(!(ge(a)||ge(c)||ge(u)||ge(f)||ge(h)||ge(p))){a=Math.ceil(a),c=Math.ceil(c),u=Math.ceil(u),f=Math.ceil(f),h=Math.ceil(h),p=Math.ceil(p);var m=a>1?hi(c/a,0,1,_e):1,_=a>1?hi(u/a,0,1,_e):1,x=f>1?hi(h/f,0,1,_e):1,y=f>1?hi(p/f,0,1,_e):1;s=At(s,{$prev_pageview_last_scroll:c,$prev_pageview_last_scroll_percentage:m,$prev_pageview_max_scroll:u,$prev_pageview_max_scroll_percentage:_,$prev_pageview_last_content:h,$prev_pageview_last_content_percentage:x,$prev_pageview_max_content:p,$prev_pageview_max_content_percentage:y})}}return r.pathname&&(s.$prev_pageview_pathname=r.pathname),r.timestamp&&(s.$prev_pageview_duration=(e.getTime()-r.timestamp.getTime())/1e3),s}}var kv=["flags","surveys"],LN={[A6]:{exposure:"hidden"},[hd]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[pd]:{exposure:"hidden"},[py]:{exposure:"event"},[my]:{exposure:"hidden"},[gy]:{exposure:"event"},[vy]:{exposure:"hidden"},[yy]:{exposure:"event"},[_y]:{exposure:"event"},[S2]:{exposure:"event"},[E2]:{exposure:"hidden"},[xy]:{exposure:"event"},[sl]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[_c]:{exposure:"hidden"},[C2]:{exposure:"event"},[I6]:{exposure:"event",shouldSkipFromEventProperties:t=>dr(t)},$session_past_minimum_duration:{exposure:"event"},$session_recording_url_trigger_activated_session:{exposure:"event"},$session_recording_event_trigger_activated_session:{exposure:"event"},$debug_first_full_snapshot_timestamp:{exposure:"event"},$sess_rec_flush_size:{exposure:"hidden"},[tl]:{exposure:"derived",storageGroup:"flags",shouldSkipFromEventProperties:(t,e)=>e(),transformToEventProperties(t){if(!Nt(t))return{};for(var e={},n=Object.keys(t),r=0;n.length>r;r++)e["$feature/"+n[r]]=t[n[r]];return e}},[Sp]:{exposure:"event",storageGroup:"flags"},[md]:{exposure:"hidden"},[wy]:{exposure:"hidden",storageGroup:"flags"},[Ep]:{exposure:"event",storageGroup:"flags"},[by]:{exposure:"event",storageGroup:"flags",volatile:!0},[lm]:{exposure:"hidden",storageGroup:"flags"},[zi]:{exposure:"event"},[pc]:{exposure:"hidden"},[Ya]:{exposure:"hidden"},[Xa]:{exposure:"hidden"},[Sy]:{exposure:"hidden",storageGroup:"surveys"},[cm]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[Ey]:{exposure:"event"},[Cp]:{exposure:"hidden"},[gd]:{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"},[bd]:{exposure:"hidden"},[Cy]:{exposure:"hidden"},[ky]:{exposure:"hidden"},[$d]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Fs]:{exposure:"hidden"},[Py]:{exposure:"hidden"},[Ty]:{exposure:"hidden"},[Ry]:{exposure:"hidden"},[Ay]:{exposure:"hidden"},[um]:{exposure:"hidden"},[dm]:{exposure:"hidden"},[M6]:{exposure:"event"},[O6]:{exposure:"event"},[L6]:{exposure:"event"},[N6]:{exposure:"event"},[j6]:{exposure:"event"},[F6]:{exposure:"event"},[V6]:{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"}},NN=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],Fa=t=>{var e=LN[t];if(e)return e;for(var n of NN){var r=n[1];if(t.indexOf(n[0])===0)return r}},xc=(t,e)=>{try{return JSON.stringify(t,((n,r)=>typeof r=="bigint"?r.toString():r),e)}catch{return J8(t)}},gm=t=>{var e=Se==null?void 0:Se.createElement("a");return ge(e)?null:(e.href=t,e)},Qc=function(t,e){for(var n,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var i=r[s].split("=");if(i[0]===e){n=i;break}}if(!Qe(n)||2>n.length)return"";var a=n[1];try{a=decodeURIComponent(a)}catch{_e.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},zd=function(t,e,n){if(!t||!e||!e.length)return t;for(var r=t.split("#"),s=r[1],i=(r[0]||"").split("?"),a=i[1],c=i[0],u=(a||"").split("&"),f=[],h=0;u.length>h;h++){var p=u[h].split("=");Qe(p)&&(e.includes(p[0])?f.push(p[0]+"="+n):f.push(u[h]))}var m=c;return a!=null&&(m+="?"+f.join("&")),s!=null&&(m+="#"+s),m},vm=function(t,e){var n=t.match(new RegExp(e+"=([^&]*)"));return n?n[1]:null},sP=(t,e)=>t>=e&&Y8(),iP=(t,e,n,r)=>{if(t===0){if(Y8()){var s=e+1;return s===n&&r(),s}return e}return 0},qh="https?://(.*)",Jc=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],DN=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Jc],Ud="<masked>",jN=["li_fat_id"];function oP(t,e,n){if(!Se)return{};var r,s=e?[...Jc,...n||[]]:[],i=aP(zd(Se.URL,s,Ud),t),a=(r={},wt(jN,(function(c){var u=H6(c);r[c]=u||null})),r);return At(a,i)}function aP(t,e){var n=DN.concat(e||[]),r={};return wt(n,(function(s){var i=Qc(t,s);r[s]=i||null})),r}function lP(t){var e=(function(i){return i?i.search(qh+"google.([^/?]*)")===0?"google":i.search(qh+"bing.com")===0?"bing":i.search(qh+"yahoo.com")===0?"yahoo":i.search(qh+"duckduckgo.com")===0?"duckduckgo":null:null})(t),n=e!="yahoo"?"q":"p",r={};if(!dr(e)){r.$search_engine=e;var s=Se?Qc(Se.referrer,n):"";s.length&&(r.ph_keyword=s)}return r}function $E(){return navigator.language||navigator.userLanguage}var ym="$direct";function cP(){return(Se==null?void 0:Se.referrer)||ym}function uP(t,e,n){n===void 0&&(n=!1);var r=t?[...Jc,...e||[]]:[],s=n?sa(rn==null?void 0:rn.href):rn==null?void 0:rn.href,i=s==null?void 0:s.substring(0,1e3);return{r:cP().substring(0,1e3),u:i?zd(i,r,Ud):void 0}}function dP(t,e){var n;e===void 0&&(e=!1);var r=t.r,s=t.u,i=e?sa(s):s,a={$referrer:r,$referring_domain:r==null?void 0:r==ym?ym:(n=gm(r))==null?void 0:n.host};if(i){a.$current_url=i;var c=gm(i);a.$host=c==null?void 0:c.host,a.$pathname=c==null?void 0:c.pathname;var u=aP(i);At(a,u)}if(r){var f=lP(r);At(a,f)}return a}function fP(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function FN(){try{return new Date().getTimezoneOffset()}catch{return}}var VN={flags:$d,surveys:cm},$N=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],ic="main";class Pv{constructor(e,n,r){if(r===void 0&&(r=!0),this.lr={},this.ur=!1,this.hr=!1,this.Te=e,this.dr=r,this.props={},this.cr=!1,this.vr=(i=>{var a="";return i.token&&(a=i.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),i.persistence_name?"ph_"+i.persistence_name:"ph_"+a+"_posthog"})(e),this.Jt=this.pr(e),this.hr=this.gr(e),this.load(),e.debug&&_e.info("Persistence loaded",e.persistence,ue({},this.props)),this.update_config(e,e,n),this.save(),te){var s=()=>this.flush();zt(te,"beforeunload",s,{capture:!1}),zt(te,"pagehide",s,{capture:!1})}}mr(){var e,n=(e=this.Te)==null?void 0:e.persistence_save_debounce_ms;return $n(n)&&n>0?n:0}isDisabled(){return!!this.yr}pr(e){$N.indexOf(e.persistence.toLowerCase())===-1&&(_e.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var n,r=(function(a,c){a===void 0&&(a=[]),c===void 0&&(c=!1);var u=[...vN,...a];return ue({},St,{F(f){try{var h={};try{h=Qi.F(f)||{}}catch{}var p,m=JSON.parse(St.A(f)||"{}");if(c){var _={};for(var x in h){var y=h[x];dr(y)||y===""||(_[x]=y)}p=At(m,_)}else p=At(h,m);return St.q(f,p),p}catch{}return null},q(f,h,p,m,_,x){var y=St.q(f,h,void 0,void 0,x);try{var w={};u.forEach((S=>{h[S]&&(w[S]=h[S])})),Object.keys(w).length&&Qi.q(f,w,p,m,_,x)}catch(S){St.D(S)}return y},P(f,h){try{te==null||te.localStorage.removeItem(f),Qi.P(f,h)}catch(p){St.D(p)}}})})(e.cookie_persisted_properties||[],e.__preview_cookie_wins_on_conflict||!1),s=!1,i=e.persistence.toLowerCase();return i==="localstorage"&&St.N()?(n=St,s=!0):i==="localstorage+cookie"&&r.N()?(n=r,s=!0):i==="sessionstorage"&&jn.N()?n=jn:i==="memory"?n=yN:i==="cookie"?n=Qi:r.N()?(n=r,s=!0):n=Qi,this.ur=s,n}br(e){return this.vr+"__"+e}gr(e){return this.ur&&!!e.split_storage}_r(e){var n=e??this.Te.feature_flag_cache_ttl_ms;if(!n||0>=n)return!1;var r=this.props[$d];return!r||typeof r!="number"||Date.now()-r>n}properties(){var e={};return wt(this.props,((n,r)=>{var s=Fa(r);if((s==null?void 0:s.exposure)==="derived"){if(s.shouldSkipFromEventProperties!=null&&s.shouldSkipFromEventProperties(n,r===tl?()=>this._r():()=>!1))return;s.transformToEventProperties&&At(e,s.transformToEventProperties(n))}else if(!s||s.exposure==="event"){if(s!=null&&s.shouldSkipFromEventProperties!=null&&s.shouldSkipFromEventProperties(n,(()=>!1)))return;e[r]=n}})),e}load(){if(!this.yr){var e=this.Jt.F(this.vr);e&&(this.props=At({},e)),this.hr&&this.wr()}}wr(){for(var e of kv){var n=St.F(this.br(e));if(n&&!Zo(n)){var r=this.kr(e);r.persisted=!0,this.Sr(e)||(r.fingerprint=this.Cr(n,e)),this.Mr(e,n)||At(this.props,n)}}}Sr(e){return Object.keys(this.props).some((n=>{var r;return((r=Fa(n))==null?void 0:r.storageGroup)===e}))}Mr(e,n){var r=VN[e];if(!r)return!1;var s=n[r],i=this.props[r];return $n(s)&&$n(i)&&i>s}refreshKey(e){var n;if(!this.yr){var r=this.hr?(n=Fa(e))==null?void 0:n.storageGroup:void 0,s=r?St.F(this.br(r)):this.Jt.F(this.vr);if(s&&e in s)this.Ir(e,s[e]);else{if(r){var i=this.Jt.F(this.vr);if(i&&e in i)return void this.Ir(e,i[e])}this.Tr(e)}}}save(){if(!this.yr){var e=this.mr();e>0?ge(this.Er)&&(this.Er=setTimeout((()=>{this.Er=void 0,this.Rr()}),e)):this.Rr()}}flush(){ge(this.Er)||(clearTimeout(this.Er),this.Er=void 0,this.Rr())}Rr(){this.yr||(this.hr?this.Pr():this.Or(this.Jt,this.vr,this.props,ic))}Pr(){var e=this.Fr(),n=e.main,r=e.groups;for(var s of(this.Or(this.Jt,this.vr,n,ic),kv)){var i,a=r[s];(!Zo(a)||(i=this.lr[s])!=null&&i.persisted)&&this.Or(St,this.br(s),a,s)}}Fr(){var e={},n={flags:{},surveys:{}};return wt(this.props,((r,s)=>{var i,a=(i=Fa(s))==null?void 0:i.storageGroup;a?n[a][s]=r:e[s]=r})),{main:e,groups:n}}Cr(e,n){if(n===ic)return JSON.stringify(e)+"|"+this.Ar+"|"+this.Lr+"|"+this.$r;var r={};return wt(e,((s,i)=>{var a;r[i]=(a=Fa(i))!=null&&a.volatile?"__volatile__":s})),JSON.stringify(r)}Or(e,n,r,s){var i=this.kr(s);if(s===ic||i.dirty||ge(i.fingerprint)){var a;try{if((a=this.Cr(r,s))===i.fingerprint)return void(i.dirty=!1)}catch{a=void 0}e.q(n,r,this.Ar,this.Lr,this.$r,this.Te.debug)?(i.dirty=!1,s!==ic&&(i.persisted=!0),ge(a)||(i.fingerprint=a)):this.Te.debug&&_e.warn('failed to persist storage entry "'+n+'"; will retry on next save')}}remove(e){var n=(e===void 0?{}:e).keepGroupEntries,r=n!==void 0&&n;if(ge(this.Er)||(clearTimeout(this.Er),this.Er=void 0),this.Jt.P(this.vr,!1),this.Jt.P(this.vr,!0),!r&&this.dr)for(var s of kv)St.P(this.br(s));r?delete this.lr[ic]:this.lr={}}clear(){this.remove(),this.props={}}register_once(e,n,r){if(Nt(e)){ge(n)&&(n="None"),this.Ar=ge(r)?this.Nr:r;var s=!1;if(wt(e,((i,a)=>{this.props.hasOwnProperty(a)&&this.props[a]!==n||(this.Ir(a,i),s=!0)})),s)return this.save(),!0}return!1}register(e,n){if(Nt(e)){this.Ar=ge(n)?this.Nr:n;var r=!1;if(wt(e,((s,i)=>{e.hasOwnProperty(i)&&this.props[i]!==s&&(this.Ir(i,s),r=!0)})),r)return this.save(),!0}return!1}unregister(e){e in this.props&&(this.Tr(e),this.save())}update_campaign_params(){if(!this.cr){var e=oP(this.Te.custom_campaign_params,this.Te.mask_personal_data_properties,this.Te.custom_personal_data_properties);Zo(P2(e))||this.register(e),this.cr=!0}}update_search_keyword(){var e;this.register((e=Se==null?void 0:Se.referrer)?lP(e):{})}update_referrer_info(){var e;this.register_once({$referrer:cP(),$referring_domain:Se!=null&&Se.referrer&&((e=gm(Se.referrer))==null?void 0:e.host)||ym},void 0)}set_initial_person_info(){this.props[Ry]||this.props[Ay]||this.register_once({[um]:uP(this.Te.mask_personal_data_properties,this.Te.custom_personal_data_properties,this.Te.disable_capture_url_hashes)},void 0)}get_initial_props(){var e={};wt([Ay,Ry],(s=>{var i=this.props[s];i&&wt(i,(function(a,c){e["$initial_"+ay(c)]=a}))}));var n=this.props[um];if(n){var r=(function(s,i){i===void 0&&(i=!1);var a=dP(s,i),c={};return wt(a,(function(u,f){c["$initial_"+ay(f)]=u})),c})(n,this.Te.disable_capture_url_hashes);At(e,r)}return e}safe_merge(e){return wt(this.props,(function(n,r){r in e||(e[r]=n)})),e}update_config(e,n,r){this.Nr=this.Ar=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!r),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie);var s=e.persistence!==n.persistence||!((u,f)=>{if(u.length!==f.length)return!1;var h=[...u].sort(),p=[...f].sort();return h.every(((m,_)=>m===p[_]))})(e.cookie_persisted_properties||[],n.cookie_persisted_properties||[]),i=s?this.pr(e):this.Jt,a=this.gr(e);if(s||a!==this.hr){var c=this.props;this.clear(),this.Jt=i,this.hr=a,this.props=c,this.save()}}set_disabled(e){this.yr=e,this.yr?this.remove():this.save()}set_cross_subdomain(e){e!==this.Lr&&(this.Lr=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this.$r&&(this.$r=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,n){var r=this.props[pd]||{};r[e]=n,this.Ir(pd,r),this.save()}remove_event_timer(e){var n=this.props[pd]||{},r=n[e];return ge(r)||(delete n[e],this.Ir(pd,n),this.save()),r}get_property(e){return this.props[e]}set_property(e,n){this.Ir(e,n),this.save()}Ir(e,n){var r;this.props[e]=n,(r=Fa(e))!=null&&r.volatile||this.Dr(e)}Tr(e){delete this.props[e],this.Dr(e)}Dr(e){var n,r=(n=Fa(e))==null?void 0:n.storageGroup;r&&(this.kr(r).dirty=!0)}kr(e){return this.lr[e]||(this.lr[e]={})}}var or={GZipJS:"gzip-js",Base64:"base64"},Qu={Activation:"events",Cancellation:"cancelEvents"},Tv={Popover:"popover",API:"api",Widget:"widget"},Ji={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},Rv={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},Ly={Popover:"popover",Inline:"inline"},HN={SHOWN:"product tour shown"},HE={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},zE=Vt("[RateLimiter]");class zN{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=n=>{var r=n.text;if(r&&r.length)try{(JSON.parse(r).quota_limited||[]).forEach((s=>{zE.info((s||"events")+" is quota limited."),this.serverLimits[s]=new Date().getTime()+6e4}))}catch(s){return void zE.warn('could not rate limit - continuing. Error: "'+(s==null?void 0:s.message)+'"',{text:r})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var n,r,s;e===void 0&&(e=!1);var i=this.captureEventsBurstLimit,a=this.captureEventsPerSecond,c=new Date().getTime(),u=(n=(r=this.instance.persistence)==null?void 0:r.get_property(Ty))!==null&&n!==void 0?n:{tokens:i,last:c};u.tokens+=(c-u.last)/1e3*a,u.last=c,u.tokens>i&&(u.tokens=i);var f=1>u.tokens;return f||e||(u.tokens=Math.max(0,u.tokens-1)),!f||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+a+" events per second and "+i+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=f,(s=this.instance.persistence)==null||s.set_property(Ty,u),{isRateLimited:f,remainingTokens:u.tokens}}isServerRateLimited(e){var n=this.serverLimits[e||"events"]||!1;return n!==!1&&new Date().getTime()<n}}var Ju=Vt("[RemoteConfig]");class hP{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=$e._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}qr(e){var n,r;(n=$e.__PosthogExtensions__)!=null&&n.loadExternalDependency?(r=$e.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):e()}jr(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback(n){e(n.json)}})}load(){try{if(this.remoteConfig)return Ju.info("Using preloaded remote config",this.remoteConfig),this.Hr(this.remoteConfig),void this.Br();if(this._instance.Ur())return void Ju.warn("Remote config is disabled. Falling back to local config.");this.qr((e=>{if(!e)return Ju.info("No config found after loading remote JS config. Falling back to JSON."),void this.jr((n=>{this.Hr(n),this.Br()}));this.Hr(e),this.Br()}))}catch(e){Ju.error("Error loading remote config",e)}}stop(){this.zr&&(clearInterval(this.zr),this.zr=void 0)}refresh(){!this._instance.Ur()&&Se&&Se.visibilityState!=="hidden"&&this._instance.reloadFeatureFlags()}Br(){var e;if(!this.zr){var n=(e=this._instance.config.remote_config_refresh_interval_ms)!==null&&e!==void 0?e:3e5;n!==0&&(this.zr=setInterval((()=>{this.refresh()}),n))}}Hr(e){var n;e||Ju.error("Failed to fetch remote config from PostHog."),this._instance.Hr(e?{ok:!0,config:e}:{ok:!1}),(e==null?void 0:e.hasFeatureFlags)!==!1&&(this._instance.config.advanced_disable_feature_flags_on_first_load||(n=this._instance.featureFlags)==null||n.ensureFlagsLoaded())}}var bs=Uint8Array,Pr=Uint16Array,eu=Uint32Array,I2=new bs([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]),M2=new bs([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]),UE=new bs([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),pP=function(t,e){for(var n=new Pr(31),r=0;31>r;++r)n[r]=e+=1<<t[r-1];var s=new eu(n[30]);for(r=1;30>r;++r)for(var i=n[r];n[r+1]>i;++i)s[i]=i-n[r]<<5|r;return[n,s]},mP=pP(I2,2),Ny=mP[1];mP[0][28]=258,Ny[258]=28;for(var BE=pP(M2,0)[1],gP=new Pr(32768),jt=0;32768>jt;++jt){var oc=(43690&jt)>>>1|(21845&jt)<<1;gP[jt]=((65280&(oc=(61680&(oc=(52428&oc)>>>2|(13107&oc)<<2))>>>4|(3855&oc)<<4))>>>8|(255&oc)<<8)>>>1}var Ed=function(t,e,n){for(var r=t.length,s=0,i=new Pr(e);r>s;++s)++i[t[s]-1];var a,c=new Pr(e);for(s=0;e>s;++s)c[s]=c[s-1]+i[s-1]<<1;for(a=new Pr(r),s=0;r>s;++s)a[s]=gP[c[t[s]-1]++]>>>15-t[s];return a},Cl=new bs(288);for(jt=0;144>jt;++jt)Cl[jt]=8;for(jt=144;256>jt;++jt)Cl[jt]=9;for(jt=256;280>jt;++jt)Cl[jt]=7;for(jt=280;288>jt;++jt)Cl[jt]=8;var _m=new bs(32);for(jt=0;32>jt;++jt)_m[jt]=5;var UN=Ed(Cl,9),BN=Ed(_m,5),vP=function(t){return(t/8>>0)+(7&t&&1)},yP=function(t,e,n){(n==null||n>t.length)&&(n=t.length);var r=new(t instanceof Pr?Pr:t instanceof eu?eu:bs)(n-e);return r.set(t.subarray(e,n)),r},Oi=function(t,e,n){var r=e/8>>0;t[r]|=n<<=7&e,t[r+1]|=n>>>8},ed=function(t,e,n){var r=e/8>>0;t[r]|=n<<=7&e,t[r+1]|=n>>>8,t[r+2]|=n>>>16},Av=function(t,e){for(var n=[],r=0;t.length>r;++r)t[r]&&n.push({s:r,f:t[r]});var s=n.length,i=n.slice();if(!s)return[new bs(0),0];if(s==1){var a=new bs(n[0].s+1);return a[n[0].s]=1,[a,1]}n.sort((function(R,L){return R.f-L.f})),n.push({s:-1,f:25001});var c=n[0],u=n[1],f=0,h=1,p=2;for(n[0]={s:-1,f:c.f+u.f,l:c,r:u};h!=s-1;)c=n[n[p].f>n[f].f?f++:p++],u=n[f!=h&&n[p].f>n[f].f?f++:p++],n[h++]={s:-1,f:c.f+u.f,l:c,r:u};var m=i[0].s;for(r=1;s>r;++r)i[r].s>m&&(m=i[r].s);var _=new Pr(m+1),x=Dy(n[h-1],_,0);if(x>e){r=0;var y=0,w=x-e,S=1<<w;for(i.sort((function(R,L){return _[L.s]-_[R.s]||R.f-L.f}));s>r;++r){var T=i[r].s;if(e>=_[T])break;y+=S-(1<<x-_[T]),_[T]=e}for(y>>>=w;y>0;){var P=i[r].s;e>_[P]?y-=1<<e-_[P]++-1:++r}for(;r>=0&&y;--r){var k=i[r].s;_[k]==e&&(--_[k],++y)}x=e}return[new bs(_),x]},Dy=function(t,e,n){return t.s==-1?Math.max(Dy(t.l,e,n+1),Dy(t.r,e,n+1)):e[t.s]=n},WE=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new Pr(++e),r=0,s=t[0],i=1,a=function(u){n[r++]=u},c=1;e>=c;++c)if(t[c]==s&&c!=e)++i;else{if(!s&&i>2){for(;i>138;i-=138)a(32754);i>2&&(a(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(a(s),--i;i>6;i-=6)a(8304);i>2&&(a(i-3<<5|8208),i=0)}for(;i--;)a(s);i=1,s=t[c]}return[n.subarray(0,r),e]},td=function(t,e){for(var n=0,r=0;e.length>r;++r)n+=t[r]*e[r];return n},jy=function(t,e,n){var r=n.length,s=vP(e+2);t[s]=255&r,t[s+1]=r>>>8,t[s+2]=255^t[s],t[s+3]=255^t[s+1];for(var i=0;r>i;++i)t[s+i+4]=n[i];return 8*(s+4+r)},GE=function(t,e,n,r,s,i,a,c,u,f,h){Oi(e,h++,n),++s[256];for(var p=Av(s,15),m=p[0],_=p[1],x=Av(i,15),y=x[0],w=x[1],S=WE(m),T=S[0],P=S[1],k=WE(y),R=k[0],L=k[1],O=new Pr(19),A=0;T.length>A;++A)O[31&T[A]]++;for(A=0;R.length>A;++A)O[31&R[A]]++;for(var I=Av(O,7),N=I[0],j=I[1],F=19;F>4&&!N[UE[F-1]];--F);var K,X,W,G,q=f+5<<3,$=td(s,Cl)+td(i,_m)+a,ne=td(s,m)+td(i,y)+a+14+3*F+td(O,N)+(2*O[16]+3*O[17]+7*O[18]);if($>=q&&ne>=q)return jy(e,h,t.subarray(u,u+f));if(Oi(e,h,1+($>ne)),h+=2,$>ne){K=Ed(m,_),X=m,W=Ed(y,w),G=y;var H=Ed(N,j);for(Oi(e,h,P-257),Oi(e,h+5,L-1),Oi(e,h+10,F-4),h+=14,A=0;F>A;++A)Oi(e,h+3*A,N[UE[A]]);h+=3*F;for(var D=[T,R],Y=0;2>Y;++Y){var ee=D[Y];for(A=0;ee.length>A;++A)Oi(e,h,H[ie=31&ee[A]]),h+=N[ie],ie>15&&(Oi(e,h,ee[A]>>>5&127),h+=ee[A]>>>12)}}else K=UN,X=Cl,W=BN,G=_m;for(A=0;c>A;++A)if(r[A]>255){var ie;ed(e,h,K[257+(ie=r[A]>>>18&31)]),h+=X[ie+257],ie>7&&(Oi(e,h,r[A]>>>23&31),h+=I2[ie]);var oe=31&r[A];ed(e,h,W[oe]),h+=G[oe],oe>3&&(ed(e,h,r[A]>>>5&8191),h+=M2[oe])}else ed(e,h,K[r[A]]),h+=X[r[A]];return ed(e,h,K[256]),h+X[256]},WN=new eu([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),GN=(function(){for(var t=new eu(256),e=0;256>e;++e){for(var n=e,r=9;--r;)n=(1&n&&3988292384)^n>>>1;t[e]=n}return t})(),Iv=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8};function KN(t,e){e===void 0&&(e={});var n=(function(){var p=4294967295;return{p(m){for(var _=p,x=0;m.length>x;++x)_=GN[255&_^m[x]]^_>>>8;p=_},d(){return 4294967295^p}}})(),r=t.length;n.p(t);var s,i,a,c,u,f=(c=10+((s=e).filename&&s.filename.length+1||0),u=8,(function(p,m,_,x,y,w){var S=p.length,T=new bs(x+S+5*(1+Math.floor(S/7e3))+y),P=T.subarray(x,T.length-y),k=0;if(!m||8>S)for(var R=0;S>=R;R+=65535){var L=R+65535;S>L?k=jy(P,k,p.subarray(R,L)):(P[R]=!0,k=jy(P,k,p.subarray(R,S)))}else{for(var O=WN[m-1],A=O>>>13,I=8191&O,N=(1<<_)-1,j=new Pr(32768),F=new Pr(N+1),K=Math.ceil(_/3),X=2*K,W=function(It){return(p[It]^p[It+1]<<K^p[It+2]<<X)&N},G=new eu(25e3),q=new Pr(288),$=new Pr(32),ne=0,H=0,D=(R=0,0),Y=0,ee=0;S>R;++R){var ie=W(R),oe=32767&R,ce=F[ie];if(j[oe]=ce,F[ie]=oe,R>=Y){var xe=S-R;if((ne>7e3||D>24576)&&xe>423){k=GE(p,P,0,G,q,$,H,D,ee,R-ee,k),D=ne=H=0,ee=R;for(var ae=0;286>ae;++ae)q[ae]=0;for(ae=0;30>ae;++ae)$[ae]=0}var se=2,Ve=0,De=I,Re=oe-ce&32767;if(xe>2&&ie==W(R-Re))for(var Ye=Math.min(A,xe)-1,dt=Math.min(32767,R),Pt=Math.min(258,xe);dt>=Re&&--De&&oe!=ce;){if(p[R+se]==p[R+se-Re]){for(var we=0;Pt>we&&p[R+we]==p[R+we-Re];++we);if(we>se){if(se=we,Ve=Re,we>Ye)break;var je=Math.min(Re,we-2),ze=0;for(ae=0;je>ae;++ae){var it=R-Re+ae+32768&32767,Tt=it-j[it]+32768&32767;Tt>ze&&(ze=Tt,ce=it)}}}Re+=(oe=ce)-(ce=j[oe])+32768&32767}if(Ve){G[D++]=268435456|Ny[se]<<18|BE[Ve];var tt=31&Ny[se],Xe=31&BE[Ve];H+=I2[tt]+M2[Xe],++q[257+tt],++$[Xe],Y=R+se,++ne}else G[D++]=p[R],++q[p[R]]}}k=GE(p,P,!0,G,q,$,H,D,ee,R-ee,k)}return yP(T,0,x+vP(k)+y)})(i=t,(a=e).level==null?6:a.level,a.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(i.length)))):12+a.mem,c,u)),h=f.length;return(function(p,m){var _=m.filename;if(p[0]=31,p[1]=139,p[2]=8,p[8]=2>m.level?4:m.level==9?2:0,p[9]=3,m.mtime!=0&&Iv(p,4,Math.floor(new Date(m.mtime||Date.now())/1e3)),_){p[3]=8;for(var x=0;_.length>=x;++x)p[x+10]=_.charCodeAt(x)}})(f,e),Iv(f,h-8,n.d()),Iv(f,h-4,r),f}var ZN=!!sy||!!v2,_P="text/plain",Pp=!1,xP=(t,e)=>{var n=t.split("#"),r=n[1],s=n[0].split("?"),i=s[0],a=s[1];if(!a)return t;var c=a.split("&").filter((u=>u.split("=")[0]!==e)).join("&");return i+(c?"?"+c:"")+(r?"#"+r:"")},O2=function(t,e,n){var r;n===void 0&&(n=!0);var s=t.split("?"),i=s[0],a=s[1],c=ue({},e),u=(r=a==null?void 0:a.split("&").map((h=>{var p,m=h.split("="),_=m[0],x=n&&(p=c[_])!==null&&p!==void 0?p:m[1];return delete c[_],_+"="+x})))!==null&&r!==void 0?r:[],f=(function(h,p){var m,_;p===void 0&&(p="&");var x=[];return wt(h,(function(y,w){ge(y)||ge(w)||w==="undefined"||(m=encodeURIComponent((S=>S instanceof File)(y)?y.name:y.toString()),_=encodeURIComponent(w),x[x.length]=_+"="+m)})),x.join(p)})(c);return f&&u.push(f),u.length>0?i+"?"+u.join("&"):i},Mv=t=>{if(t.Vr)return t.Vr;var e=t.data,n=t.compression;if(e){if(n===or.GZipJS){var r=KN((function(c,u){var f=c.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(c);for(var h=new bs(c.length+(c.length>>>1)),p=0,m=function(w){h[p++]=w},_=0;f>_;++_){if(p+5>h.length){var x=new bs(p+8+(f-_<<1));x.set(h),h=x}var y=c.charCodeAt(_);128>y?m(y):2048>y?(m(192|y>>>6),m(128|63&y)):y>55295&&57344>y?(m(240|(y=65536+(1047552&y)|1023&c.charCodeAt(++_))>>>18),m(128|y>>>12&63),m(128|y>>>6&63),m(128|63&y)):(m(224|y>>>12),m(128|y>>>6&63),m(128|63&y))}return yP(h,0,p)})(xc(e)),{mtime:0});return{contentType:_P,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(n===or.Base64){var s=(function(c){return c&&btoa(encodeURIComponent(c).replace(/%([0-9A-F]{2})/g,((u,f)=>String.fromCharCode(parseInt(f,16)))))})(xc(e)),i=(c=>"data="+encodeURIComponent(typeof c=="string"?c:xc(c)))(s);return{contentType:"application/x-www-form-urlencoded",body:i,estimatedSize:new Blob([i]).size}}var a=xc(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},wP=t=>{var e,n,r=()=>t.transport==="sendBeacon"?{url:O2(t.url,{compression:or.Base64}),encodedBody:Mv(ue({},t,{compression:or.Base64,Vr:void 0}))}:{url:xP(t.url,"compression"),encodedBody:Mv(ue({},t,{compression:void 0,Vr:void 0}))};try{e=Mv(t)}catch(s){if(vE(t.compression,Qc(t.url,"compression")))return _e.error("Failed to gzip request body, sending uncompressed payload",s),r();throw s}return e&&vE(t.compression,Qc(t.url,"compression"))&&!((n=e.body)instanceof ArrayBuffer?iy(new Uint8Array(n)):ArrayBuffer.isView(n)&&iy(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)))?(Pp=!0,r()):{url:t.url,encodedBody:e}},bP=t=>{try{return wP(t)}catch(e){return _e.error(e),void(t.callback==null||t.callback({statusCode:0,error:e}))}},qN=(function(){var t=en((function*(e){var n=xc(e.data),r=yield(function(i,a,c){return oy.apply(this,arguments)})(n,gt.DEBUG,{rethrow:!0});if(!r)return e;var s=yield r.arrayBuffer();return ue({},e,{Vr:{contentType:_P,body:s,estimatedSize:s.byteLength}})}));return function(e){return t.apply(this,arguments)}})(),YN=/Failed to fetch|NetworkError|Load failed/i,SP=t=>{var e=bP(t);if(e){var n=e.url,r=e.encodedBody,s=r??{},i=s.contentType,a=s.body,c=s.estimatedSize,u=new Headers;wt(t.headers,(function(x,y){u.append(y,x)})),i&&u.append("Content-Type",i);var f=null,h=!1;if(dE){var p=new dE;f={signal:p.signal,timeout:setTimeout((()=>{var x,y;h=!0,p.abort((x=t.timeout,(y=new Error("PostHog request timed out"+(x?" after "+x+"ms":""))).name="AbortError",y))}),t.timeout)}}var m=x=>{h&&(x==null?void 0:x.name)==="AbortError"||(y=>(y==null?void 0:y.name)==="TypeError"&&YN.test((y==null?void 0:y.message)||""))(x)?_e.warn(x):_e.error(x),t.callback==null||t.callback({statusCode:0,error:x})};try{var _;v2(n,ue({method:(t==null?void 0:t.method)||"GET",headers:u,keepalive:t.method==="POST"&&!t.Wr&&52428.8>(c||0),body:a,signal:(_=f)==null?void 0:_.signal},t.fetchOptions)).then((x=>x.text().then((y=>{var w={statusCode:x.status,text:y};if(x.status===200)try{w.json=JSON.parse(y)}catch(S){_e.error(S)}t.callback==null||t.callback(w)})))).catch(m).finally((()=>f?clearTimeout(f.timeout):null))}catch(x){f&&clearTimeout(f.timeout),m(x)}}},Fy=t=>{try{var e,n=wP(t),r=n.url,s=n.encodedBody,i=s??{},a=i.body,c=i.estimatedSize;if(!a)return;var u=a instanceof Blob?a:new Blob([a],{type:i.contentType});if(ar.sendBeacon(r,u))return;var f=Qe(t.data)?t.data:(e=t.data)==null?void 0:e.batch;if(Qe(f)&&f.length>1&&(c??0)>16384){var h=Math.ceil(f.length/2),p=m=>Qe(t.data)?m:ue({},t.data,{batch:m});return Fy(ue({},t,{data:p(f.slice(0,h))})),void Fy(ue({},t,{data:p(f.slice(h))}))}_e.warn("Beacon of ~"+(c??0)+" bytes was rejected by the browser, falling back to fetch"),SP(ue({},t,{Wr:!0}))}catch(m){_e.warn("Beacon send failed",m)}},KE=(t,e,n,r)=>{var s=r==="query"?e==="POST"?"sent_at":"_":void 0;return O2(n===or.GZipJS?xP(t,"compression"):t,ue({},s?{[s]:Date.now().toString()}:{},n===or.GZipJS?{}:{compression:n}))},Tp=[];v2&&Tp.push({transport:"fetch",method:SP}),sy&&Tp.push({transport:"XHR",method(t){var e=bP(t);if(e){var n=new sy,r=e.encodedBody;n.open(t.method||"GET",e.url,!0);var s=r??{},i=s.contentType,a=s.body;wt(t.headers,(function(c,u){n.setRequestHeader(u,c)})),i&&n.setRequestHeader("Content-Type",i),t.timeout&&(n.timeout=t.timeout),n.onreadystatechange=()=>{if(n.readyState===4){var c={statusCode:n.status,text:n.responseText};if(n.status===200)try{c.json=JSON.parse(n.responseText)}catch{}t.callback==null||t.callback(c)}},n.send(a)}}}),ar!=null&&ar.sendBeacon&&Tp.push({transport:"sendBeacon",method:Fy});var Vy=3e3;class XN{constructor(e,n){this.Zr=!0,this.Gr=[],this.Qr=hi((n==null?void 0:n.flush_interval_ms)||Vy,250,5e3,_e.createLogger("flush interval"),Vy),this.Jr=e}enqueue(e){this.Gr.push(e),this.Kr||this.Yr()}unload(){this.Xr();var e=this.Gr.length>0?this.ei():{},n=Object.values(e);[...n.filter((r=>r.url.indexOf("/e")===0)),...n.filter((r=>r.url.indexOf("/e")!==0))].map((r=>{this.ti(ue({},r,{transport:"sendBeacon"}))}))}enable(){this.Zr=!1,this.Yr()}Yr(){var e=this;this.Zr||(this.Kr=setTimeout((()=>{if(this.Xr(),this.Gr.length>0){var n=this.ei(),r=function(){var i=n[s],a=new Date().getTime();i.data&&Qe(i.data)&&wt(i.data,(c=>{c.offset=Math.abs(c.timestamp-a),delete c.timestamp})),e.ti(i)};for(var s in n)r()}}),this.Qr))}ti(e){try{this.Jr(e)}catch(n){_e.error(n)}}Xr(){clearTimeout(this.Kr),this.Kr=void 0}ei(){var e={};return wt(this.Gr,(n=>{var r,s=n,i=(s?s.batchKey:null)||s.url;ge(e[i])&&(e[i]=ue({},s,{data:[]})),(r=e[i].data)==null||r.push(s.data)})),this.Gr=[],e}}var QN=["retriesPerformedSoFar"];class JN{constructor(e){this.ri=!1,this.ii=3e3,this.Gr=[],this._instance=e,this.Gr=[],this.ni=!0,!ge(te)&&"onLine"in te.navigator&&(this.ni=te.navigator.onLine,this.si=()=>{this.ni=!0,this.oi()},this.ai=()=>{this.ni=!1},zt(te,"online",this.si),zt(te,"offline",this.ai))}get length(){return this.Gr.length}retriableRequest(e){var n=e.retriesPerformedSoFar,r=X8(e,QN);Hi(n)&&(r.url=O2(r.url,{retry_count:n})),this._instance._send_request(ue({},r,{callback:s=>{if(s.statusCode!==200&&(400>s.statusCode||s.statusCode>=500)){if((s.statusCode===0?3:10)>(n??0))return void this.kt(ue({retriesPerformedSoFar:n},r));s.statusCode===0&&_e.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.")}r.callback==null||r.callback(s)}}))}kt(e){var n=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=n+1;var r=(function(a){var c=3e3*Math.pow(2,a),u=c/2,f=Math.min(18e5,c),h=Math.random()-.5;return Math.ceil(f+h*(f-u))})(n),s=Date.now()+r;this.Gr.push({retryAt:s,requestOptions:e});var i="Enqueued failed request for retry in "+r;navigator.onLine||(i+=" (Browser is offline)"),_e.warn(i),this.ri||(this.ri=!0,this.li())}li(){if(this.ui&&clearTimeout(this.ui),this.Gr.length===0)return this.ri=!1,void(this.ui=void 0);this.ui=setTimeout((()=>{this.ni&&this.Gr.length>0&&this.oi(),this.li()}),this.ii)}oi(){var e=Date.now(),n=[],r=this.Gr.filter((i=>e>i.retryAt||(n.push(i),!1)));if(this.Gr=n,r.length>0)for(var s of r)this.retriableRequest(s.requestOptions)}unload(){for(var e of(this.ui&&(clearTimeout(this.ui),this.ui=void 0),this.ri=!1,ge(te)||(this.si&&(te.removeEventListener("online",this.si),this.si=void 0),this.ai&&(te.removeEventListener("offline",this.ai),this.ai=void 0)),this.Gr)){var n=e.requestOptions;try{this._instance._send_request(ue({},n,{transport:"sendBeacon"}))}catch(r){_e.error(r)}}this.Gr=[]}}class eD{constructor(e){this.hi=()=>{var n,r,s,i;this.di||(this.di={});var a=this.scrollElement(),c=this.scrollY(),u=a?Math.max(0,a.scrollHeight-a.clientHeight):0,f=c+((a==null?void 0:a.clientHeight)||0),h=(a==null?void 0:a.scrollHeight)||0;this.di.lastScrollY=Math.ceil(c),this.di.maxScrollY=Math.max(c,(n=this.di.maxScrollY)!==null&&n!==void 0?n:0),this.di.maxScrollHeight=Math.max(u,(r=this.di.maxScrollHeight)!==null&&r!==void 0?r:0),this.di.lastContentY=f,this.di.maxContentY=Math.max(f,(s=this.di.maxContentY)!==null&&s!==void 0?s:0),this.di.maxContentHeight=Math.max(h,(i=this.di.maxContentHeight)!==null&&i!==void 0?i:0)},this._instance=e}get ci(){return this._instance.config.scroll_root_selector}getContext(){return this.di}resetContext(){var e=this.di;return setTimeout(this.hi,0),e}startMeasuringScrollPosition(){zt(te,"scroll",this.hi,{capture:!0}),zt(te,"scrollend",this.hi,{capture:!0}),zt(te,"resize",this.hi)}scrollElement(){if(!this.ci)return te==null?void 0:te.document.documentElement;var e=Qe(this.ci)?this.ci:[this.ci];for(var n of e){var r=te==null?void 0:te.document.querySelector(n);if(r)return r}}vi(e){var n=e==="y"?"scrollTop":"scrollLeft";if(this.ci){var r=this.scrollElement();return r&&r[n]||0}return te?e==="y"?te.scrollY||te.pageYOffset||te.document.documentElement.scrollTop||0:te.scrollX||te.pageXOffset||te.document.documentElement.scrollLeft||0:0}scrollY(){return this.vi("y")}scrollX(){return this.vi("x")}}var tD=t=>uP(t==null?void 0:t.config.mask_personal_data_properties,t==null?void 0:t.config.custom_personal_data_properties,t==null?void 0:t.config.disable_capture_url_hashes);class ZE{constructor(e,n,r,s){this.fi=i=>{var a=this.pi();if(!a||a.sessionId!==i){var c={sessionId:i,props:this.gi(this._instance)};this.mi.register({[Py]:c})}},this._instance=e,this.yi=n,this.mi=r,this.gi=s||tD,this.yi.onSessionId(this.fi)}pi(){return this.mi.props[Py]}getSetOnceProps(){var e,n=(e=this.pi())==null?void 0:e.props;return n?"r"in n?dP(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 e={};return wt(P2(this.getSetOnceProps()),((n,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+ay(r)]=n})),e}}class L2{on(e,n){return this.bi[e]||(this.bi[e]=[]),this.bi[e].push(n),()=>{this.bi[e]=this.bi[e].filter((r=>r!==n))}}emit(e,n){for(var r of this.bi[e]||[])r(n);for(var s of this.bi["*"]||[])s(e,n)}constructor(){this.bi={}}}var nd=Vt("[SessionId]");class qE{on(e,n){return this.wi.on(e,n)}constructor(e,n,r){var s;if(this.xi=null,this.ki=[],this.Si=void 0,this.Ci=!1,this.wi=new L2,this.Mi=(f,h)=>!(!Hi(f)||!Hi(h))&&Math.abs(f-h)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===Xi)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Te=e.config,this.mi=e.persistence,this.Ii=void 0,this.Ti=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.Ei=n||Ki,this.Ri=r||Ki;var i=this.Te.persistence_name||this.Te.token;if(this._sessionTimeoutMs=1e3*hi(this.Te.session_idle_timeout_seconds||1800,60,36e3,nd.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Pi(),this.Oi="ph_"+i+"_window_id",this.Fi="ph_"+i+"_primary_window_exists",this.Ai()){var a=jn.F(this.Oi),c=jn.F(this.Fi);a&&!c?this.Ii=a:jn.P(this.Oi),jn.q(this.Fi,!0)}if((s=this.Te.bootstrap)!=null&&s.sessionID)try{var u=(f=>{var h=this.Te.bootstrap.sessionID.replace(/-/g,"");if(h.length!==32)throw new Error("Not a valid UUID");if(h[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(h.substring(0,12),16)})();this.Li(this.Te.bootstrap.sessionID,new Date().getTime(),u)}catch(f){nd.error("Invalid sessionID in bootstrap",f)}this.$i()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return ge(this.ki)&&(this.ki=[]),this.ki.push(e),this.Ti&&e(this.Ti,this.Ii),()=>{this.ki=this.ki.filter((n=>n!==e))}}Ai(){return this.Te.persistence!=="memory"&&!this.mi.yr&&jn.N()}Ni(e){e!==this.Ii&&(this.Ii=e,this.Ai()&&jn.q(this.Oi,e))}Di(){return this.Ii?this.Ii:this.Ai()?jn.F(this.Oi):null}qi(e){var n=this.xi;return!dr(n)&&!dr(e)&&5e3>Math.abs(e-n)}Li(e,n,r){var s=n!==this._sessionActivityTimestamp,i=!(e!==this.Ti||r!==this._sessionStartTimestamp);this._sessionStartTimestamp=r,this._sessionActivityTimestamp=n,this.Ti=e,i&&!s||i&&this.qi(n)||(this.xi=n,this.mi.register({[_c]:[n,e,r]}))}ji(){var e,n=(e=this.Te)==null?void 0:e.persistence_save_debounce_ms;return Hi(n)&&n>0}Hi(){this.ji()?this.mi.refreshKey(_c):(this.mi.flush(),this.mi.load())}Bi(){var e;if(!dr(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.xi){this.Hi();var n=this.Ui();n[1]===this.Ti&&n[2]===this._sessionStartTimestamp&&(this.xi=this._sessionActivityTimestamp,this.mi.register({[_c]:[this._sessionActivityTimestamp,(e=this.Ti)!==null&&e!==void 0?e:null,this._sessionStartTimestamp]}),this.mi.flush())}}zi(){var e=this.Ui()[0],n=Hi(e)?e:0,r=Hi(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(n,r)}Vi(e){return this.Hi(),this.Mi(e,this.zi())}Ui(){var e=this.mi.props[_c];return Qe(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.xi=null,clearTimeout(this.Wi),this.Wi=void 0,this.Li(null,null,null)}destroy(){this.Ci=!0,this.Bi(),clearTimeout(this.Wi),this.Wi=void 0,this.Si&&te&&(te.removeEventListener(hm,this.Si,{capture:!1}),this.Si=void 0),this.ki=[]}$i(){this.Si=()=>{this.Bi(),this.Ai()&&jn.P(this.Fi)},zt(te,hm,this.Si,{capture:!1})}checkAndGetSessionAndWindowId(e,n){if(e===void 0&&(e=!1),n===void 0&&(n=null),this.Te.cookieless_mode===Xi)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=n||new Date().getTime(),s=this.Ui(),i=s[1],a=s[2],c=this.zi(),u=this.Di(),f=Hi(a)&&Math.abs(r-a)>864e5,h=!1,p=!1,m=!i,_=i,x=!m&&!e&&this.Mi(r,c);if(x){(x=this.Vi(r))||nd.info("cross-tab refresh kept the session alive",{sessionId:i});var y=this.Ui();i=y[1],a=y[2]}m||x||f?(i=this.Ei(),u=this.Ri(),nd.info("new session ID generated",{sessionId:i,windowId:u,changeReason:{noSessionId:m,activityTimeout:x,sessionPastMaximumLength:f}}),a=r,h=!0):(u||(u=this.Ri(),h=!0),(p=i!==_)&&(nd.info("adopted cross-tab session id",{sessionId:i,windowId:u}),h=!0));var w=Hi(c)&&e&&!f?c:r,S=Hi(a)?a:new Date().getTime();this.Ni(u),this.Li(i,w,S),e||this.Pi();var T={noSessionId:m,activityTimeout:x,sessionPastMaximumLength:f,crossTabAdoption:p};return h&&this.ki.forEach((P=>P(i,u,T))),{sessionId:i,windowId:u,sessionStartTimestamp:S,changeReason:h?T:void 0,lastActivityTimestamp:c}}Pi(){this.Ci||(clearTimeout(this.Wi),this.Wi=setTimeout((()=>{if(!this.Ci)if(this.Vi(new Date().getTime())){var e=this.Ti;this.resetSessionId(),this.wi.emit("forcedIdleReset",{idleSessionId:e})}else this.Pi()}),1.1*this.sessionTimeoutMs))}}var EP=function(t,e){if(!t)return!1;var n=t.userAgent;if(n&&_E(n,e))return!0;try{var r=t==null?void 0:t.userAgentData;if(r!=null&&r.brands&&r.brands.some((s=>_E(s==null?void 0:s.brand,e))))return!0}catch{}return!!t.webdriver};function CP(){return(CP=en((function*(){var t=ar==null?void 0:ar.userAgentData;if(t!=null&&t.getHighEntropyValues)try{var e=yield t.getHighEntropyValues(["model"]),n=e==null?void 0:e.model;return xt(n)&&n.length>0?n:void 0}catch(r){return void _e.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",r)}}))).apply(this,arguments)}var xm=function(t,e){if(!(function(n){try{new RegExp(n)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(t)}catch{return!1}};function YE(t,e,n){return xc({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:n})}var kP={exact:(t,e)=>e.some((n=>t.some((r=>n===r)))),is_not:(t,e)=>e.every((n=>t.every((r=>n!==r)))),regex:(t,e)=>e.some((n=>t.some((r=>xm(n,r))))),not_regex:(t,e)=>e.every((n=>t.every((r=>!xm(n,r))))),icontains:(t,e)=>e.map(Yh).some((n=>t.map(Yh).some((r=>n.includes(r))))),not_icontains:(t,e)=>e.map(Yh).every((n=>t.map(Yh).every((r=>!n.includes(r))))),gt:(t,e)=>e.some((n=>{var r=parseFloat(n);return!isNaN(r)&&t.some((s=>r>parseFloat(s)))})),lt:(t,e)=>e.some((n=>{var r=parseFloat(n);return!isNaN(r)&&t.some((s=>r<parseFloat(s)))}))},Yh=t=>t.toLowerCase();function PP(t,e){return!t||Object.entries(t).every((n=>{var r=n[1],s=e==null?void 0:e[n[0]];if(ge(s)||dr(s))return!1;var i=[String(s)],a=kP[r.operator];return!!a&&a(r.values,i)}))}var $y="custom",XE="i.posthog.com",nD=/^\/static\//;class rD{constructor(e){this.Zi={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,n=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return n||(n=this.apiHost.replace("."+XE,".posthog.com")),n==="https://app.posthog.com"?"https://us.posthog.com":n}get region(){return this.Zi[this.apiHost]||(this.Zi[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":$y),this.Zi[this.apiHost]}Gi(e){if(nD.test(e)){var n=this.instance.config.asset_host;if(typeof n=="string")return n.trim().replace(/\/$/,"")||void 0}}endpointFor(e,n){if(n===void 0&&(n=""),n&&(n=n[0]==="/"?n:"/"+n),e==="ui")return this.uiHost+n;if(e==="flags")return this.flagsApiHost+n;if(e==="assets"){var r=this.Gi(n);if(r)return""+r+n}if(this.region===$y)return this.apiHost+n;var s=XE+n;switch(e){case"assets":return"https://"+this.region+"-assets."+s;case"api":return"https://"+this.region+"."+s}}}function TP(t){var e;return!((e=t.conditions)==null||(e=e.events)==null||(e=e.values)==null||!e.length)}var yt=Vt("[Surveys]"),RP="seenSurvey_",AP=t=>{try{var e=(n=>((r,s)=>""+RP+(function(i){return i.current_iteration&&i.current_iteration>0?i.id+"_"+i.current_iteration:i.id})(s))(0,n))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(n){yt.error("Failed to persist survey seen state",n)}},sD=[Tv.Popover,Tv.Widget,Tv.API],iD={ignoreConditions:!1,ignoreDelay:!1,displayType:Ly.Popover},oD=Vt("[PostHog ExternalIntegrations]"),aD={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class lD{constructor(e){this._instance=e}er(e,n){var r;(r=$e.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,e,(s=>{if(s)return oD.error("failed to load script",s);n()}))}startIfEnabledOrStop(){var e=this,n=function(){var i,a,c,u=r[0],f=r[1];!f||(i=$e.__PosthogExtensions__)!=null&&(i=i.integrations)!=null&&i[u]||e.er(aD[u],(()=>{var h;(h=$e.__PosthogExtensions__)==null||(h=h.integrations)==null||(h=h[u])==null||h.start(e._instance)})),!f&&(a=$e.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[u]&&((c=$e.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[u])==null||c.stop())};for(var r of Object.entries((s=this._instance.config.integrations)!==null&&s!==void 0?s:{})){var s;n()}}}var Cd={},Ov=0,wm=()=>{},QE='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',rd="Surveys module not available",JE="sanitize_properties is deprecated. Use before_send instead",IP="Invalid value for property_denylist config: ",cD=["token","distinct_id",D6],gc="posthog",MP=!ZN&&(Sr==null?void 0:Sr.indexOf("MSIE"))===-1&&(Sr==null?void 0:Sr.indexOf("Mozilla"))===-1,Lv=t=>{var e;return ue({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:fN(Se==null?void 0:Se.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:wm,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:t??"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:rn&&xt(rn==null?void 0:rn.search)&&rn.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:(te==null||(e=te.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(n){_e.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:Iy,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:Vy},error_tracking:{},_onCapture:wm},(n=>({rageclick:n&&n>="2026-05-30"?{content_ignorelist:EN,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)}))(t))},uD=[["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"]],eC=t=>{var e={};for(var n of uD){var r=n[0],s=n[1];ge(t[r])||(e[s]=t[r])}var i=At({},e,t),a=t.__preview_external_dependency_versioned_paths;return ge(a)||(ge(t.strict_script_versioning)&&(i.strict_script_versioning=!!a),xt(a)&&ge(t.asset_host)&&(i.asset_host=a)),Qe(t.property_blacklist)&&(ge(t.property_denylist)?i.property_denylist=t.property_blacklist:Qe(t.property_denylist)?i.property_denylist=[...t.property_blacklist,...t.property_denylist]:_e.error(IP+t.property_denylist)),i};class dD{constructor(){this.__forceAllowLocalhost=!1}get Qi(){return this.__forceAllowLocalhost}set Qi(e){_e.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class vs{Ji(e,n){if(e){var r=this.Ki.indexOf(e);r!==-1&&this.Ki.splice(r,1)}return this.Ki.push(n),n.initialize==null||n.initialize(),n}Yi(){return this.config.cookieless_mode===Xi||this.config.cookieless_mode===Qa&&this.consent.isRejected()}get decideEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){var e;this.webPerformance=new dD,this.Xi=!1,this.version=gt.LIB_VERSION,this.en=new L2,this.Ki=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Lv(),this.SentryIntegration=ON,this.sentryIntegration=r=>(function(s,i){var a=rP(s,i);return{name:nP,processEvent:c=>a(c)}})(this,r),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.tn=!1,this.rn=null,this.nn=null,this.sn=null,this.scrollManager=new eD(this),this.pageViewManager=new VE(this),this.rateLimiter=new zN(this),this.requestRouter=new rD(this),this.consent=new _N(this),this.externalIntegrations=new lD(this);var n=(e=vs.__defaultExtensionClasses)!==null&&e!==void 0?e:{};this.featureFlags=n.featureFlags&&new n.featureFlags(this),this.toolbar=n.toolbar&&new n.toolbar(this),this.surveys=n.surveys&&new n.surveys(this),this.conversations=n.conversations&&new n.conversations(this),this.logs=n.logs&&new n.logs(this),this.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:(r,s,i)=>{var a=xt(r)?{[r]:s}:r;this.setPersonProperties(a),i==null||i({})},set_once:(r,s,i)=>{var a=xt(r)?{[r]:s}:r;this.setPersonProperties(void 0,a),i==null||i({})}},this.on("eventCaptured",(r=>_e.info('send "'+(r==null?void 0:r.event)+'"',r)))}init(e,n,r){if(r&&r!==gc){var s,i=(s=Cd[r])!==null&&s!==void 0?s:new vs;return i._init(e,n,r),Cd[r]=i,Cd[gc][r]=i,i}return this._init(e,n,r)}_init(e,n,r){var s,i;n===void 0&&(n={});var a=xt(e)?e.trim():"";if(!a)return _e.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Lv(n.defaults),n.debug=this.an(n.debug),this.ln=n,this.un=[],n.person_profiles?this.nn=n.person_profiles:n.process_person&&(this.nn=n.process_person);var c=Lv(n.defaults),u=eC(n),f=At({},c,u,{name:r,token:a});Nt(c.rageclick)&&Nt(u.rageclick)&&(f.rageclick=At({},c.rageclick,u.rageclick)),Nt(c.session_recording)&&Nt(u.session_recording)&&(f.session_recording=At({},c.session_recording,u.session_recording)),this.set_config(f),this.config.on_xhr_error&&_e.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:or.GZipJS;var h=this.hn();this.persistence=new Pv(this.config,h),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Pv(ue({},this.config,{persistence:"sessionStorage"}),h,!1);var p=ue({},this.persistence.props),m=ue({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.dn=new XN((k=>this.cn(k)),this.config.request_queue_config),this.vn=new JN(this),this.__request_queue=[];var _=this.Yi();if(_||(this.sessionManager=new qE(this),this.sessionPropsManager=new ZE(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(_e.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.fn(_)}),0)):(_e.info("Initializing extensions synchronously"),this.fn(_)),gt.DEBUG=gt.DEBUG||this.config.debug,gt.DEBUG&&_e.info("Starting in debug mode",{this:this,config:n,thisC:ue({},this.config),p,s:m}),!this.config.identity_distinct_id||(s=n.bootstrap)!=null&&s.distinctID||(n.bootstrap=ue({},n.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),((i=n.bootstrap)==null?void 0:i.distinctID)!==void 0){var x=n.bootstrap.distinctID,y=this.get_distinct_id(),w=this.persistence.get_property(Fs);if(n.bootstrap.isIdentifiedID&&y!=null&&y!==x&&w===rc)this.identify(x);else if(n.bootstrap.isIdentifiedID&&y!=null&&y!==x&&w===sc)_e.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 S=this.config.get_device_id(Ki()),T=n.bootstrap.isIdentifiedID?S:x;this.persistence.set_property(Fs,n.bootstrap.isIdentifiedID?sc:rc),this.register({distinct_id:x,$device_id:T})}}if(_)this.register_once({distinct_id:Wh,$device_id:null},"");else if(!this.get_distinct_id()){var P=this.config.get_device_id(Ki());this.register_once({distinct_id:P,$device_id:P},""),this.persistence.set_property(Fs,rc)}return zt(te,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),n.segment?(function(k,R){var L=k.config.segment;if(!L)return R();(function(O,A){var I=O.config.segment;if(!I)return A();var N=F=>{var K=()=>F.anonymousId()||Ki();O.config.get_device_id=K,F.id()&&(O.register({distinct_id:F.id(),$device_id:K()}),O.persistence.set_property(Fs,sc)),A()},j=I.user();"then"in j&&zs(j.then)?j.then(N):N(j)})(k,(()=>{L.register((O=>{typeof Promise<"u"&&Promise.resolve||Cv.warn("This browser does not have Promise support, and can not use the segment integration");var A=(I,N)=>{if(!N)return I;I.event.userId||I.event.anonymousId===O.get_distinct_id()||(Cv.info("No userId set, resetting PostHog"),O.reset()),I.event.userId&&I.event.userId!==O.get_distinct_id()&&(Cv.info("UserId set, identifying with PostHog"),O.identify(I.event.userId));var j=O.calculateEventProperties(N,I.event.properties);return I.event.properties=Object.assign({},j,I.event.properties),I};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:I=>A(I,I.event.event),page:I=>A(I,mc),identify:I=>A(I,bv),screen:I=>A(I,"$screen")}})(k)).then((()=>{R()}))}))})(this,(()=>this.pn())):this.pn(),zs(this.config._onCapture)&&this.config._onCapture!==wm&&(_e.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(k=>this.config._onCapture(k.event,k)))),this.config.ip&&_e.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 CP.apply(this,arguments)})().then((k=>{k&&this.register({[xv]:k})})).catch(wm),this}fn(e){var n,r,s,i,a,c,u,f,h=performance.now(),p=ue({},vs.__defaultExtensionClasses,this.config.__extensionClasses),m=[];p.featureFlags&&this.Ki.push(this.featureFlags=(n=this.featureFlags)!==null&&n!==void 0?n:new p.featureFlags(this)),p.exceptions&&this.Ki.push(this.exceptions=(r=this.exceptions)!==null&&r!==void 0?r:new p.exceptions(this)),p.historyAutocapture&&this.Ki.push(this.historyAutocapture=new p.historyAutocapture(this)),p.tracingHeaders&&this.Ki.push(this.tracingHeaders=new p.tracingHeaders(this)),p.siteApps&&this.Ki.push(this.siteApps=new p.siteApps(this)),p.sessionRecording&&!e&&this.Ki.push(this.sessionRecording=new p.sessionRecording(this)),this.config.disable_scroll_properties||m.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),p.autocapture&&this.Ki.push(this.autocapture=new p.autocapture(this)),p.surveys&&this.Ki.push(this.surveys=(s=this.surveys)!==null&&s!==void 0?s:new p.surveys(this)),p.logs&&this.Ki.push(this.logs=(i=this.logs)!==null&&i!==void 0?i:new p.logs(this)),p.metrics&&this.Ki.push(this.metrics=(a=this.metrics)!==null&&a!==void 0?a:new p.metrics(this)),p.conversations&&this.Ki.push(this.conversations=(c=this.conversations)!==null&&c!==void 0?c:new p.conversations(this)),p.productTours&&this.Ki.push(this.productTours=new p.productTours(this)),p.heatmaps&&this.Ki.push(this.heatmaps=new p.heatmaps(this)),p.webVitalsAutocapture&&this.Ki.push(this.webVitalsAutocapture=new p.webVitalsAutocapture(this)),p.exceptionObserver&&this.Ki.push(this.exceptionObserver=new p.exceptionObserver(this)),p.deadClicksAutocapture&&this.Ki.push(this.deadClicksAutocapture=new p.deadClicksAutocapture(this,MN)),p.toolbar&&this.Ki.push(this.toolbar=(u=this.toolbar)!==null&&u!==void 0?u:new p.toolbar(this)),p.experiments&&this.Ki.push(this.experiments=(f=this.experiments)!==null&&f!==void 0?f:new p.experiments(this)),this.Ki.forEach((_=>{_.initialize&&m.push((()=>{_.initialize==null||_.initialize()}))})),m.push((()=>{if(this.gn){var _=this.gn;this.gn=void 0,this.Hr(_)}})),this.mn(m,h)}mn(e,n){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-n>=30&&e.length>0)return void setTimeout((()=>{this.mn(e,n)}),0);var r=e.shift();if(r)try{r()}catch(i){_e.error("Error initializing extension:",i)}}var s=Math.round(performance.now()-n);this.register_for_session({[j6]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[F6]:s}),this.config.__preview_deferred_init_extensions&&_e.info("PostHog extensions initialized ("+s+"ms)")}Hr(e){if(!Se||!Se.body)return _e.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Hr(e)}),500);if(this.config.__preview_deferred_init_extensions&&(this.gn=e),this.yn=e,this.compression=void 0,e.ok){var n,r=e.config;r.supportedCompression&&!this.config.disable_compression&&(this.compression=Ge(r.supportedCompression,or.GZipJS)?or.GZipJS:Ge(r.supportedCompression,or.Base64)?or.Base64:void 0),(n=r.analytics)!=null&&n.endpoint&&(this.analyticsDefaultEndpoint=r.analytics.endpoint)}this.set_config({person_profiles:this.nn?this.nn:Iy}),this.Ki.forEach((s=>s.onRemoteConfig==null?void 0:s.onRemoteConfig(e)))}pn(){try{this.config.loaded(this)}catch(r){_e.critical("`loaded` function failed",r)}if(this.bn(),this.config.internal_or_test_user_hostname&&rn!=null&&rn.hostname){var e=rn.hostname,n=this.config.internal_or_test_user_hostname;(typeof n=="string"?e===n:n.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.Yi())&&this._n()}),1),this.wn=new hP(this),this.wn.load()}bn(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.dn)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Gh(this.__request_queue,(e=>this.cn(e))),this.__request_queue=[],this.bn()}_handle_unload(){var e,n,r,s,i;(e=this.surveys)==null||e.handlePageUnload==null||e.handlePageUnload(),(n=this.metrics)==null||n.flush("sendBeacon"),this.config.request_batching?(this.xn()&&this.capture(wv),(r=this.logs)==null||r.flushLogs("sendBeacon"),(s=this.dn)==null||s.unload(),(i=this.vn)==null||i.unload()):this.xn()&&this.capture(wv,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded?MP?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&(e.callback==null||e.callback({statusCode:429})):(e.transport=e.transport||this.config.api_transport,e.headers=ue({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?this.compression:e.compression,(ge(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(n=>{var r,s,i,a=ue({},n);a.timeout=a.timeout||6e4;var c,u,f,h,p,m=(r=a.transport)!==null&&r!==void 0?r:"fetch";m==="sendBeacon"&&ge(a.compression)&&a.data&&(a.compression=or.Base64),a.method==="POST"&&a.data&&(a.timestampMode==="capture-body"?a.data={api_key:(u=(p=(h=Qe(c=a.data)?c:[c])[0])==null||(f=p.properties)==null?void 0:f.token)!==null&&u!==void 0?u:p==null?void 0:p.token,batch:h,sent_at:new Date().toISOString()}:a.timestampMode==="body"&&(a.data=(function(y,w){return w===void 0&&(w=new Date().toISOString()),Qe(y)?y.map((S=>ue({},S,{sent_at:w}))):ue({},y,{sent_at:w})})(a.data))),a.url=KE(a.url,a.method,a.compression,a.timestampMode);var _=Tp.filter((y=>!a.disableTransport||!y.transport||!a.disableTransport.includes(y.transport))),x=(s=(i=(function(y,w){for(var S=0;y.length>S;S++)if(y[S].transport===m)return y[S]})(_))==null?void 0:i.method)!==null&&s!==void 0?s:_[0].method;if(!x)throw new Error("No available transport method");m!=="sendBeacon"&&a.data&&a.compression===or.GZipJS&&pL&&typeof Promise<"u"&&!Pp?qN(a).then((y=>{x(y)})).catch((y=>{if(yE(y))return Pp=!0,void x(ue({},a,{compression:void 0,url:KE(n.url,n.method,void 0,n.timestampMode)}));(w=>{if(!w||typeof w!="object")return!1;var S="name"in w?String(w.name):"";return yE(w)||S===Q8})(y)&&(Pp=!0),x(a)})):x(a)})(ue({},e,{callback:n=>{var r,s;this.rateLimiter.checkForLimiting(n),400>n.statusCode||(r=(s=this.config).on_request_error)==null||r.call(s,n),e.callback==null||e.callback(n)}}))):e.fireCallbackOnDrop&&(e.callback==null||e.callback({statusCode:0}))}cn(e){this.vn?this.vn.retriableRequest(e):this._send_request(e)}_execute_array(e){Ov++;try{var n,r=[],s=[],i=[];Gh(e,(c=>{if(c)if(Qe(n=c[0]))i.push(c);else if(zs(c))try{c.call(this)}catch(u){_e.error("Error executing queued PostHog call",c,u)}else Qe(c)&&n==="alias"?r.push(c):Qe(c)&&n.indexOf("capture")!==-1&&zs(this[n])?i.push(c):s.push(c)}));var a=function(c,u){Gh(c,(function(f){try{if(Qe(f[0])){var h=u;wt(f,(function(p){h=h[p[0]].apply(h,p.slice(1))}))}else u[f[0]].apply(u,f.slice(1))}catch(p){_e.error("Error executing queued PostHog call",f,p)}}))};a(r,this),a(s,this),a(i,this)}finally{Ov--}}push(e){if(Ov>0&&Qe(e)&&xt(e[0])){var n=vs.prototype[e[0]];zs(n)&&n.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,n,r){var s,i,a,c,u;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.dn){if(this.is_capturing())if(!ge(e)&&xt(e)){var f=!this.config.opt_out_useragent_filter&&this._is_bot();if(!f||this.config.__preview_capture_bot_pageviews){var h=r!=null&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(h==null||!h.isRateLimited){n!=null&&n.$current_url&&!xt(n==null?void 0:n.$current_url)&&(_e.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),n==null||delete n.$current_url),e!=="$exception"||r!=null&&r.kn||_e.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var p=new Date,m=(r==null?void 0:r.timestamp)||p,_=SE(r==null?void 0:r.uuid,Ki),x={uuid:_,event:e,properties:this.calculateEventProperties(e,n||{},m,_)};e===mc&&this.config.__preview_capture_bot_pageviews&&f&&(x.event="$bot_pageview",x.properties.$browser_type="bot"),h&&(x.properties.$lib_rate_limit_remaining_tokens=h.remainingTokens);var y=e==="$feature_flag_called"&&x.properties.$feature_flag_has_experiment===!1&&this.get_property(lm)===!0;r!=null&&r.$set&&!y&&(x.$set=r==null?void 0:r.$set);var w=r==null?void 0:r.$unset;w&&(x.$unset=w);var S,T,P,k=y?void 0:this.Sn(r==null?void 0:r.$set_once,e!==TE,e===bv);if(k&&(x.$set_once=k),r!=null&&r._noTruncate||(i=this.config.properties_string_max_length,a=x,c=F=>xt(F)?F.slice(0,i):F,u=new Set,x=(function F(K,X){if(K!==Object(K))return c?c(K):K;if(!u.has(K)){var W;if(u.add(K),Qe(K))W=[],Gh(K,(q=>{W.push(F(q))}));else{var G={};wt(K,((q,$)=>{u.has(q)||(G[$]=F(q))})),W=G}return W}})(a)),x.timestamp=m,ge(r==null?void 0:r.timestamp)||(x.properties.$event_time_override_provided=!0,x.properties.$event_time_override_system_time=p),y&&(x.properties=(function(F,K){K===void 0&&(K=[]);var X={},W=G=>{F[G]!==void 0&&(X[G]=F[G])};return mL.forEach(W),K.forEach(W),X})(x.properties,cD)),e===Ji.DISMISSED||e===Ji.SENT){var R=n==null?void 0:n[Rv.SURVEY_ID],L=n==null?void 0:n[Rv.SURVEY_ITERATION];AP({id:R,current_iteration:L}),x.$set=ue({},x.$set,{[(S={id:R,current_iteration:L},T=e===Ji.SENT?"responded":"dismissed",P="$survey_"+T+"/"+S.id,S.current_iteration&&S.current_iteration>0&&(P="$survey_"+T+"/"+S.id+"/"+S.current_iteration),P)]:!0})}else e===Ji.SHOWN&&(x.$set=ue({},x.$set,{[Rv.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===HN.SHOWN){var O=n==null?void 0:n[HE.TOUR_TYPE];O&&(x.$set=ue({},x.$set,{[HE.TOUR_LAST_SEEN_DATE+"/"+O]:new Date().toISOString()}))}var A=ue({},x.properties.$set,x.$set);if(Zo(A)||this.setPersonPropertiesForFlags(A),!Je(this.config.before_send)){var I=this.wt(x);if(!I)return;(x=I).uuid=SE(x.uuid,Ki)}this.en.emit("eventCaptured",x);var N=(s=r==null?void 0:r._url)!==null&&s!==void 0?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),j={method:"POST",url:N,data:x,compression:"best-available",timestampMode:(r==null?void 0:r._batchKey)==="recordings"||/\/s\/(?:\?|$)/.test(N)?"body":"capture-body",batchKey:r==null?void 0:r._batchKey,transport:r==null?void 0:r.transport};return!this.config.request_batching||r&&(r==null||!r._batchKey)||r!=null&&r.send_instantly?this.cn(j):this.dn.enqueue(j),x}_e.critical("This capture call is ignored due to client rate limiting.")}}else _e.error("No event name provided to posthog.capture")}else _e.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(n=>e(n.event,n)))}calculateEventProperties(e,n,r,s,i){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return n;var a=i?void 0:this.persistence.remove_event_timer(e),c=ue({},n);if(c.token=this.config.token,c.$config_defaults=this.config.defaults,this.Yi()&&(c[D6]=!0),e==="$snapshot"){var u=ue({},this.persistence.properties(),this.sessionPersistence.properties());return c.distinct_id=u.distinct_id,(!xt(c.distinct_id)&&!$n(c.distinct_id)||ly(c.distinct_id))&&_e.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),c}var f,h=(function(P,k,R,L){var O,A,I,N;if(L===void 0&&(L=!1),!Sr)return{};var j,F=P?[...Jc,...k||[]]:[],K=(function(Ye){for(var dt=0;wE.length>dt;dt++){var Pt=wE[dt],we=Pt[1],je=Pt[0].exec(Ye),ze=je&&(zs(we)?we(je,Ye):we);if(ze)return ze}return["",""]})(Sr),X=K[0],W=K[1],G=(j=typeof navigator<"u"?navigator:void 0)!=null&&j.brave?{brave:!0}:{},q={};ge(R)||(q.detectGoogleSearchApp=R);var $={},ne=(O=navigator)==null||(O=O.userAgentData)==null?void 0:O.platform,H=(A=navigator)==null?void 0:A.maxTouchPoints,D=te==null||(I=te.screen)==null?void 0:I.width,Y=te==null||(N=te.screen)==null?void 0:N.height,ee=te==null?void 0:te.devicePixelRatio;ge(ne)||($.userAgentDataPlatform=ne),ge(H)||($.maxTouchPoints=H),ge(D)||($.screenWidth=D),ge(Y)||($.screenHeight=Y),ge(ee)||($.devicePixelRatio=ee);var ie,oe,ce,xe,ae,se,Ve,De,Re=At(P2({$os:X,$os_version:W,$browser:b6(Sr,navigator.vendor,G,q),$device:bE(Sr),$device_type:(oe=Sr,ce=$,De=bE(oe),De===s6||De===r6||De==="Kobo"||De==="Kindle Fire"||De===v6?qc:De===Fd||De===Pc||De===Vd||De===uy?"Console":De===o6?"Wearable":De?Qr:(ce==null?void 0:ce.userAgentDataPlatform)==="Android"&&((xe=ce==null?void 0:ce.maxTouchPoints)!==null&&xe!==void 0?xe:0)>0?600>Math.min((ae=ce==null?void 0:ce.screenWidth)!==null&&ae!==void 0?ae:0,(se=ce==null?void 0:ce.screenHeight)!==null&&se!==void 0?se:0)/((Ve=ce==null?void 0:ce.devicePixelRatio)!==null&&Ve!==void 0?Ve:1)?Qr:qc:"Desktop"),$timezone:fP(),$timezone_offset:FN()}),{$current_url:zd(L?sa(rn==null?void 0:rn.href):rn==null?void 0:rn.href,F,Ud),$host:rn==null?void 0:rn.host,$pathname:rn==null?void 0:rn.pathname,$raw_user_agent:Sr.length>1e3?Sr.substring(0,997)+"...":Sr,$browser_version:LL(Sr,navigator.vendor,G,q),$browser_language:$E(),$browser_language_prefix:(ie=$E(),typeof ie=="string"?ie.split("-")[0]:void 0),$screen_height:te==null?void 0:te.screen.height,$screen_width:te==null?void 0:te.screen.width,$viewport_height:te==null?void 0:te.innerHeight,$viewport_width:te==null?void 0:te.innerWidth,$lib:gt.LIB_NAME,$lib_version:gt.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return gt.SDK_DIST_CHANNEL&&(Re.$sdk_dist_channel=gt.SDK_DIST_CHANNEL),Re})(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){var p=this.sessionManager.checkAndGetSessionAndWindowId(i,r.getTime()),m=p.windowId;c.$session_id=p.sessionId,c.$window_id=m}this.sessionPropsManager&&At(c,this.sessionPropsManager.getSessionProps());try{var _;this.sessionRecording&&At(c,this.sessionRecording.sdkDebugProperties),c.$sdk_debug_retry_queue_size=(_=this.vn)==null?void 0:_.length}catch(P){c.$sdk_debug_error_capturing_properties=String(P)}if(this.requestRouter.region===$y&&(c.$lib_custom_api_host=this.config.api_host),f=e!==mc||i?e!==wv||i?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,s),c=At(c,f),e===mc&&Se&&(c.title=Se.title),!ge(a)){var x=r.getTime()-a;c.$duration=parseFloat((x/1e3).toFixed(3))}Sr&&this.config.opt_out_useragent_filter&&(c.$browser_type=this._is_bot()?"bot":"browser");var y=this.persistence.properties(),w=this.sessionPersistence.properties();wt(["$referrer","$referring_domain"],(P=>{P in y&&delete w[P]})),(c=At({},h,y,w,c)).$is_identified=this._isIdentified(),Qe(this.config.property_denylist)?wt(this.config.property_denylist,(function(P){delete c[P]})):_e.error(IP+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var S=this.config.sanitize_properties;S&&(_e.error(JE),c=S(c,e));var T=this.Cn();return c.$process_person_profile=T,T&&!i&&this.Mn("_calculate_event_properties"),c}Sn(e,n,r){var s;if(n===void 0&&(n=!0),r===void 0&&(r=!1),!this.persistence||!this.Cn()||this.Xi&&!r)return e;var i=this.persistence.get_initial_props(),a=(s=this.sessionPropsManager)==null?void 0:s.getSetOnceProps(),c=At({},i,a||{},e||{}),u=this.config.sanitize_properties;return u&&(_e.error(JE),c=u(c,"$set_once")),n&&(this.Xi=!0),Zo(c)?void 0:c}register(e,n){var r;(r=this.persistence)==null||r.register(e,n)}register_once(e,n,r){var s;(s=this.persistence)==null||s.register_once(e,n,r)}register_for_session(e){var n;(n=this.sessionPersistence)==null||n.register(e)}unregister(e){var n;(n=this.persistence)==null||n.unregister(e)}unregister_for_session(e){var n;(n=this.sessionPersistence)==null||n.unregister(e)}In(e,n){this.register({[e]:n})}getFeatureFlag(e,n){var r;return(r=this.featureFlags)==null?void 0:r.getFeatureFlag(e,n)}getFeatureFlagPayload(e){var n;return(n=this.featureFlags)==null?void 0:n.getFeatureFlagPayload(e)}getFeatureFlagResult(e,n){var r;return(r=this.featureFlags)==null?void 0:r.getFeatureFlagResult(e,n)}getAllFeatureFlags(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.getAllFeatureFlags())!==null&&e!==void 0?e:[]}isFeatureEnabled(e,n){var r,s;return(r=(s=this.featureFlags)==null?void 0:s.isFeatureEnabled(e,n))!==null&&r!==void 0?r:n==null?void 0:n.defaultValue}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,n,r){var s;(s=this.featureFlags)==null||s.updateFlags(e,n,r)}updateEarlyAccessFeatureEnrollment(e,n,r){var s;(s=this.featureFlags)==null||s.updateEarlyAccessFeatureEnrollment(e,n,r)}getEarlyAccessFeatures(e,n,r){var s;return n===void 0&&(n=!1),(s=this.featureFlags)==null?void 0:s.getEarlyAccessFeatures(e,n,r)}on(e,n){return this.en.on(e,n)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:rd}),()=>{})}onSessionId(e){var n,r;return(n=(r=this.sessionManager)==null?void 0:r.onSessionId(e))!==null&&n!==void 0?n:()=>{}}getSurveys(e,n){n===void 0&&(n=!1),this.surveys?this.surveys.getSurveys(e,n):e([],{isLoaded:!1,error:rd})}getActiveMatchingSurveys(e,n){n===void 0&&(n=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,n):e([],{isLoaded:!1,error:rd})}renderSurvey(e,n){var r;(r=this.surveys)==null||r.renderSurvey(e,n)}displaySurvey(e,n){var r;n===void 0&&(n=iD),(r=this.surveys)==null||r.displaySurvey(e,n)}cancelPendingSurvey(e){var n;(n=this.surveys)==null||n.cancelPendingSurvey(e)}canRenderSurvey(e){var n,r;return(n=(r=this.surveys)==null?void 0:r.canRenderSurvey(e))!==null&&n!==void 0?n:{visible:!1,disabledReason:rd}}canRenderSurveyAsync(e,n){var r,s;return n===void 0&&(n=!1),(r=(s=this.surveys)==null?void 0:s.canRenderSurveyAsync(e,n))!==null&&r!==void 0?r:Promise.resolve({visible:!1,disabledReason:rd})}Tn(e){return!e||ly(e)?(_e.critical("Unique user id has not been set in posthog.identify"),!1):e===Wh?(_e.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(e.toLowerCase())&&!["undefined","null"].includes(e.toLowerCase())||(_e.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(e,n,r){if(!this.__loaded||!this.persistence)return _e.uninitializedWarning("posthog.identify");if($n(e)&&(e=e.toString(),_e.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.Tn(e)&&this.Mn("posthog.identify")){var s=this.get_distinct_id();this.register({$user_id:e}),this.get_property(am)||this.register_once({$had_persisted_distinct_id:!0,$device_id:s},""),e!==s&&e!==this.get_property(hd)&&(this.unregister(hd),this.register({distinct_id:e}));var i,a=(this.persistence.get_property(Fs)||rc)===rc;e!==s&&a?(this.persistence.set_property(Fs,sc),this.setPersonPropertiesForFlags({$set:n||{},$set_once:r||{}},!1),this.capture(bv,{distinct_id:e,$anon_distinct_id:s},{$set:n||{},$set_once:r||{}}),this.sn=YE(e,n,r),(i=this.featureFlags)==null||i.setAnonymousDistinctId(s)):(n||r)&&this.setPersonProperties(n,r),e!==s&&(this.reloadFeatureFlags(),this.unregister(bd))}}setPersonProperties(e,n){if((e||n)&&this.Mn("posthog.setPersonProperties")){var r=YE(this.get_distinct_id(),e,n);this.sn!==r?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:n||{}},!0),this.capture("$set",{$set:e||{},$set_once:n||{}}),this.sn=r):_e.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(e){var n,r=(Qe(e)?e:[e]).filter((s=>xt(s)&&s.length>0));r.length!==0&&this.Mn("posthog.unsetPersonProperties")&&((n=this.featureFlags)==null||n.unsetPersonPropertiesForFlags(r,!0),this.capture("$set",{$unset:r}),this.sn=null)}group(e,n,r){if(e&&n){var s=this.getGroups(),i=s[e]!==n;if(i&&this.resetGroupPropertiesForFlags(e),this.register({$groups:ue({},s,{[e]:n})}),i||r){var a={$group_type:e,$group_key:n};r&&(a.$group_set=r),this.capture(TE,a)}r&&this.setGroupPropertiesForFlags({[e]:r}),i&&!r&&this.reloadFeatureFlags()}else _e.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,n){var r;n===void 0&&(n=!0),(r=this.featureFlags)==null||r.setPersonPropertiesForFlags(e,n)}resetPersonPropertiesForFlags(e){var n;e===void 0&&(e=!0),(n=this.featureFlags)==null||n.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,n){var r;n===void 0&&(n=!0),this.Mn("posthog.setGroupPropertiesForFlags")&&((r=this.featureFlags)==null||r.setGroupPropertiesForFlags(e,n))}resetGroupPropertiesForFlags(e){var n;(n=this.featureFlags)==null||n.resetGroupPropertiesForFlags(e)}reset(e){var n,r,s,i,a,c,u,f,h,p;if(_e.info("reset"),!this.__loaded)return _e.uninitializedWarning("posthog.reset");var m,_=this.get_property(am),x=this.get_property(xv),y=this.get_property(sl);if(this.consent.reset(),(n=this.persistence)==null||n.clear(),(r=this.sessionPersistence)==null||r.clear(),ge(y)||(m=this.persistence)==null||m.register({[sl]:y}),(s=this.surveys)==null||s.reset(),(i=this.wn)==null||i.stop(),(a=this.featureFlags)==null||a.reset(),(c=this.conversations)==null||c.reset(),(u=this.logs)==null||u.reset(),(f=this.metrics)==null||f.reset(),(h=this.persistence)==null||h.set_property(Fs,rc),(p=this.sessionManager)==null||p.resetSessionId(),this.sn=null,this.config.cookieless_mode===Xi)this.register_once({distinct_id:Wh,$device_id:null},"");else{var w=this.config.get_device_id(Ki());this.register_once({distinct_id:w,$device_id:e?w:_},""),e||ge(x)||this.register({[xv]:x})}this.register({$last_posthog_reset:new Date().toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}shutdown(e){var n=this;return en((function*(){var r,s,i,a,c;n.__loaded?((r=n.logs)==null||r.flushLogs("sendBeacon"),(s=n.metrics)==null||s.flush("sendBeacon"),(i=n.dn)==null||i.unload(),(a=n.vn)==null||a.unload(),(c=n.featureFlags)==null||c.destroy()):_e.uninitializedWarning("posthog.shutdown")}))()}setIdentity(e,n){var r;this.config.identity_distinct_id=e,this.config.identity_hash=n,this.alias(e),(r=this.conversations)==null||r.En()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,(e=this.conversations)==null||e.Rn()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,n;return(e=(n=this.sessionManager)==null?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var n=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=n.sessionStartTimestamp,s=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+n.sessionId);if(e!=null&&e.withTimestamp&&r){var i,a=(i=e.timestampLookBack)!==null&&i!==void 0?i:10;if(!r)return s;s+="?t="+Math.max(Math.floor((new Date().getTime()-r)/1e3)-a,0)}return s}alias(e,n){return e===this.get_property(A6)?(_e.critical("Attempting to create alias for existing People user - aborting."),-2):this.Mn("posthog.alias")?(ge(n)&&(n=this.get_distinct_id()),e!==n?(this.In(hd,e),this.capture("$create_alias",{alias:e,distinct_id:n})):(_e.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var n=ue({},this.config);if(Nt(e)){var r,s,i,a,c,u,f,h,p,m,_;At(this.config,eC(e));var x=this.hn();(r=this.persistence)==null||r.update_config(this.config,n,x),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Pv(ue({},this.config,{persistence:"sessionStorage"}),x,!1);var y=this.an(this.config.debug);Us(y)&&(this.config.debug=y),Us(this.config.debug)&&(this.config.debug?(gt.DEBUG=!0,St.N()&&St.q("ph_debug",!0),_e.info("set_config",{config:e,oldConfig:n,newConfig:ue({},this.config)})):(gt.DEBUG=!1,St.N()&&St.P("ph_debug"))),(s=this.exceptionObserver)==null||s.onConfigChange(),(i=this.exceptions)==null||i.onConfigChange(),(a=this.sessionRecording)==null||a.startIfEnabledOrStop(),(c=this.tracingHeaders)==null||c.startIfEnabledOrStop(),(u=this.autocapture)==null||u.startIfEnabled(),(f=this.heatmaps)==null||f.startIfEnabled(),(h=this.exceptionObserver)==null||h.startIfEnabledOrStop(),(p=this.deadClicksAutocapture)==null||p.startIfEnabledOrStop(),(m=this.surveys)==null||m.loadIfEnabled(),this.Pn(),(_=this.externalIntegrations)==null||_.startIfEnabledOrStop()}}_overrideSDKInfo(e,n){gt.LIB_NAME=e,gt.LIB_VERSION=n}startSessionRecording(e){var n,r,s,i,a,c=e===!0,u={sampling:c||!(e==null||!e.sampling),linked_flag:c||!(e==null||!e.linked_flag),url_trigger:c||!(e==null||!e.url_trigger),event_trigger:c||!(e==null||!e.event_trigger)};Object.values(u).some(Boolean)&&((n=this.sessionManager)==null||n.checkAndGetSessionAndWindowId(),u.sampling&&((r=this.sessionRecording)==null||r.overrideSampling()),u.linked_flag&&((s=this.sessionRecording)==null||s.overrideLinkedFlag()),u.url_trigger&&((i=this.sessionRecording)==null||i.overrideTrigger("url")),u.event_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,n){if(this.exceptions){var r=new Error("PostHog syntheticException"),s=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(ue({},s,n))}}addExceptionStep(e,n){var r;(r=this.exceptions)==null||r.addExceptionStep(e,n)}captureLog(e){var n;(n=this.logs)==null||n.captureLog(e)}get logger(){var e,n;return(e=(n=this.logs)==null?void 0:n.logger)!==null&&e!==void 0?e:vs.On}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var n,r;return(n=(r=this.toolbar)==null?void 0:r.loadToolbar(e))!==null&&n!==void 0&&n}get_property(e){var n;return(n=this.persistence)==null?void 0:n.props[e]}getSessionProperty(e){var n;return(n=this.sessionPersistence)==null?void 0:n.props[e]}toString(){var e,n=(e=this.config.name)!==null&&e!==void 0?e:gc;return n!==gc&&(n=gc+"."+n),n}_isIdentified(){var e,n;return((e=this.persistence)==null?void 0:e.get_property(Fs))===sc||((n=this.sessionPersistence)==null?void 0:n.get_property(Fs))===sc}Cn(){var e,n;return!(this.config.person_profiles==="never"||this.config.person_profiles===Iy&&!this._isIdentified()&&Zo(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[hd])&&((n=this.persistence)==null||(n=n.props)==null||!n[dm]))}xn(){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.Cn()||this.Mn("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Mn("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Mn(e){return this.config.person_profiles==="never"?(_e.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.In(dm,!0),!0)}hn(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==Qa)}Pn(){var e,n,r,s,i=this.hn();return((e=this.persistence)==null?void 0:e.yr)!==i&&((r=this.persistence)==null||r.set_disabled(i)),((n=this.sessionPersistence)==null?void 0:n.yr)!==i&&((s=this.sessionPersistence)==null||s.set_disabled(i)),i}opt_in_capturing(e){var n;if(this.config.cookieless_mode!==Xi){if(this.Yi()){var r,s,i,a,c;this.reset(!0),(r=this.sessionManager)==null||r.destroy(),(s=this.pageViewManager)==null||s.destroy(),this.sessionManager=new qE(this),this.pageViewManager=new VE(this),this.persistence&&(this.sessionPropsManager=new ZE(this,this.sessionManager,this.persistence));var u,f=(i=(a=this.config.__extensionClasses)==null?void 0:a.sessionRecording)!==null&&i!==void 0?i:(c=vs.__defaultExtensionClasses)==null?void 0:c.sessionRecording;f&&(this.sessionRecording=this.Ji(this.sessionRecording,new f(this)),this.yn&&((u=this.sessionRecording)==null||u.onRemoteConfig==null||u.onRemoteConfig(this.yn)))}var h,p;this.consent.optInOut(!0),this.Pn(),this.bn(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==Qa&&((h=this.surveys)==null||h.loadIfEnabled()),(ge(e==null?void 0:e.captureEventName)||e!=null&&e.captureEventName)&&this.capture((p=e==null?void 0:e.captureEventName)!==null&&p!==void 0?p:"$opt_in",e==null?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this._n()}else _e.warn(QE)}opt_out_capturing(){var e,n,r;this.config.cookieless_mode!==Xi?(this.config.cookieless_mode===Qa&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.Pn(),this.config.cookieless_mode===Qa&&(this.register({distinct_id:Wh,$device_id:null}),(e=this.sessionRecording)==null||e.stopRecording(),this.sessionRecording=void 0,(n=this.sessionManager)==null||n.destroy(),(r=this.pageViewManager)==null||r.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this._n(),this.bn())):_e.warn(QE)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===1?"granted":e===0?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===Xi||(this.config.cookieless_mode===Qa?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.Pn()}_is_bot(){return ar?EP(ar,this.config.custom_blocked_useragents):void 0}_n(){Se&&(Se.visibilityState==="visible"?this.tn||(this.tn=!0,this.capture(mc,{title:Se.title},{send_instantly:!0}),this.rn&&(Se.removeEventListener(fm,this.rn),this.rn=null)):this.rn||(this.rn=this._n.bind(this),zt(Se,fm,this.rn)))}debug(e){e===!1?(te==null||te.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(te==null||te.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}))}Ur(){var e=this.ln||{};return"advanced_disable_flags"in e?!!e.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(_e.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,r,s,i,a){var c=r in n&&!Je(n[r]),u=s in n&&!Je(n[s]);return c?n[r]:!!u&&(a&&a.warn("Config field '"+s+"' is deprecated. Please use '"+r+"' instead. The old field will be removed in a future major version."),n[s])})(e,"advanced_disable_flags","advanced_disable_decide",0,_e)}wt(e){var n;if(Je(this.config.before_send))return e;var r=Object.keys((n=e.properties)!==null&&n!==void 0?n:{}).filter(bL),s=Qe(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var a of s){if(i=a(i),Je(i)){var c="Event '"+e.event+"' was rejected in beforeSend function";return wL(e.event)?_e.warn(c+". This can cause unexpected behavior."):_e.info(c),null}i.properties&&!Zo(i.properties)||_e.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}for(var u of r)if(i.properties&&Je(i.properties[u]))return _e.warn("Event '"+e.event+"' had its '"+u+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return i}getPageViewId(){var e;return(e=this.pageViewManager.ir)==null?void 0:e.pageViewId}captureTraceFeedback(e,n){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:n})}captureTraceMetric(e,n,r){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:n,$ai_metric_value:String(r)})}an(e){var n=Us(e)&&!e,r=St.N()&&St.A("ph_debug")==="true";return!n&&(!!r||e)}}vs.__defaultExtensionClasses={},vs.On=(()=>{var t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),(function(t,e){for(var n=0;e.length>n;n++)t.prototype[e[n]]=uN(t.prototype[e[n]])})(vs,["identify"]);class tC{constructor(e){this.disabled=e===!1;var n=Nt(e)?e:{};this.thresholdPx=n.threshold_px||30,this.timeoutMs=n.timeout_ms||1e3,this.clickCount=n.click_count||3,this.clicks=[]}isRageClick(e,n,r){if(this.disabled)return!1;var s=this.clicks[this.clicks.length-1];if(s&&Math.abs(e-s.x)+Math.abs(n-s.y)<this.thresholdPx&&this.timeoutMs>r-s.timestamp){if(this.clicks.push({x:e,y:n,timestamp:r}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:n,timestamp:r}];return!1}}var Nv="$copy_autocapture",Dv=Vt("[AutoCapture]");function jv(t,e){return e.length>t?e.slice(0,t)+"...":e}function fD(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do e=e.previousSibling;while(e&&!ia(e));return e}function hD(t,e){var n,r,s=e.e,i=e.maskAllElementAttributes,a=e.maskAllText,c=e.elementAttributeIgnoreList,u=e.elementsChainAsString,f=e.disableCaptureUrlHashes;if(!ia(t))return{props:{}};for(var h=[t],p=new Set([t]),m=t;m.parentNode&&!qr(m,"body")&&K6>h.length;)if(G6(m.parentNode)){var _=m.parentNode.host;if(p.has(_))break;p.add(_),h.push(_),m=_}else{if(!ia(m.parentNode)||p.has(m.parentNode))break;p.add(m.parentNode),h.push(m.parentNode),m=m.parentNode}var x,y,w=[],S={},T=!1,P=!1;if(wt(h,(A=>{var I=Oy(A);if(qr(A,"a")){var N=A.getAttribute("href");T=!!(I&&N&&Sd(N))&&(f?sa(N):N)}Ge(mm(A),"ph-no-capture")&&(P=!0),w.push((function(F,K,X,W,G){G===void 0&&(G=!1);var q=F.tagName.toLowerCase(),$={tag_name:q};R2.indexOf(q)>-1&&!X&&($.$el_text=q.toLowerCase()==="a"||q.toLowerCase()==="button"?jv(1024,DE(F)):jv(1024,Hd(F)));var ne=mm(F);ne.length>0&&($.classes=ne.filter((function(ee){return ee!==""}))),wt(F.attributes,(function(ee){var ie;if((!Q6(F)||["name","id","class","aria-label"].indexOf(ee.name)!==-1)&&(W==null||!W.includes(ee.name))&&!K&&Sd(ee.value)&&(!xt(ie=ee.name)||ie.substring(0,10)!=="_ngcontent"&&ie.substring(0,7)!=="_nghost")){var oe=ee.value;ee.name==="class"&&(oe=T2(oe).join(" ")),$["attr__"+ee.name]=jv(1024,ee.name==="href"&&G?sa(oe):oe)}}));for(var H=1,D=1,Y=F;Y=fD(Y);)H++,Y.tagName===F.tagName&&D++;return $.nth_child=H,$.nth_of_type=D,$})(A,i,a,c,f));var j=(function(F){if(!Oy(F))return{};var K={};return wt(F.attributes,(function(X){if(X.name&&X.name.indexOf("data-ph-capture-attribute")===0){var W=X.name.replace("data-ph-capture-attribute-",""),G=X.value;W&&G&&Sd(G)&&(K[W]=G)}})),K})(A);At(S,j)})),P)return{props:{},explicitNoCapture:P};if(a||(w[0].$el_text=qr(t,"a")||qr(t,"button")?DE(t):Hd(t)),T){var k,R;w[0].attr__href=T;var L=(k=gm(T))==null?void 0:k.host,O=te==null||(R=te.location)==null?void 0:R.host;L&&O&&L!==O&&(x=T)}return{props:At({$event_type:s.type,$ce_version:1},u?{}:{$elements:w},{$elements_chain:(y=w,(function(A){return A.map((I=>{var N,j,F="";if(I.tag_name&&(F+=I.tag_name),I.attr_class)for(var K of(I.attr_class.sort(),I.attr_class))F+="."+K.replace(/"/g,"");var X=ue({},I.text?{text:I.text}:{},{"nth-child":(N=I.nth_child)!==null&&N!==void 0?N:0,"nth-of-type":(j=I.nth_of_type)!==null&&j!==void 0?j:0},I.href?{href:I.href}:{},I.attr_id?{attr_id:I.attr_id}:{},I.attributes),W={};return kp(X).sort(((G,q)=>G[0].localeCompare(q[0]))).forEach((G=>{var q=G[1];return W[jE(G[0].toString())]=jE(q.toString())})),(F+=":")+kp(W).map((G=>G[0]+'="'+G[1]+'"')).join("")})).join(";")})((function(A){return A.map((I=>{var N,j,F={text:(N=I.$el_text)==null?void 0:N.slice(0,400),tag_name:I.tag_name,href:(j=I.attr__href)==null?void 0:j.slice(0,2048),attr_class:AN(I),attr_id:I.attr__id,nth_child:I.nth_child,nth_of_type:I.nth_of_type,attributes:{}};return kp(I).filter((K=>K[0].indexOf("attr__")===0)).forEach((K=>F.attributes[K[0]]=K[1])),F}))})(y)))},(n=w[0])!=null&&n.$el_text?{$el_text:(r=w[0])==null?void 0:r.$el_text}:{},x&&s.type==="click"?{$external_click_url:x}:{},S)}}var sd=Vt("[ExceptionAutocapture]"),nC=()=>{},pD=Vt("[TracingHeaders]"),Va=Vt("[Web Vitals]"),rC=9e5,sC="disabled",iC="lazy_loading",id="awaiting_config",Xh="missing_config";Vt("[SessionRecording]"),Vt("[SessionRecording]");var Hy="[SessionRecording]",Li=Vt(Hy),mD=Vt("[Heatmaps]");function Fv(t){return Nt(t)&&"clientX"in t&&"clientY"in t&&$n(t.clientX)&&$n(t.clientY)}var Vv=Vt("[Product Tours]"),$v=t=>{var e;return!t.config.disable_product_tours&&!((e=t.persistence)==null||!e.get_property(E2))},gD=["$set_once","$set"],ti=Vt("[SiteApps]"),oC="Error while initializing PostHog app with config id ";function ac(t,e,n){if(Je(t))return!1;switch(n){case"exact":return t===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch{return!1}default:return!1}}class vD{constructor(e){this.Fn=new L2,this.An=(n,r)=>this.Ln(n,r)&&this.$n(n,r)&&this.Nn(n,r)&&this.Dn(n,r),this.Ln=(n,r)=>r==null||!r.event||(n==null?void 0:n.event)===(r==null?void 0:r.event),this._instance=e,this.qn=new Set,this.jn=new Set}init(){var e,n;ge((e=this._instance)==null?void 0:e._addCaptureHook)||(n=this._instance)==null||n._addCaptureHook(((r,s)=>{this.on(r,s)}))}register(e){var n,r;if(!ge((n=this._instance)==null?void 0:n._addCaptureHook)&&(e.forEach((a=>{var c,u;(c=this.jn)==null||c.add(a),(u=a.steps)==null||u.forEach((f=>{var h;(h=this.qn)==null||h.add((f==null?void 0:f.event)||"")}))})),(r=this._instance)!=null&&r.autocapture)){var s,i=new Set;e.forEach((a=>{var c;(c=a.steps)==null||c.forEach((u=>{u!=null&&u.selector&&i.add(u==null?void 0:u.selector)}))})),(s=this._instance)==null||s.autocapture.setElementSelectors(i)}}on(e,n){var r;n!=null&&e.length!=0&&(this.qn.has(e)||this.qn.has(n.event))&&this.jn&&((r=this.jn)==null?void 0:r.size)>0&&this.jn.forEach((s=>{this.Hn(n,s)&&this.Fn.emit("actionCaptured",s.name)}))}Bn(e){this.onAction("actionCaptured",(n=>e(n)))}Hn(e,n){if((n==null?void 0:n.steps)==null)return!1;for(var r of n.steps)if(this.An(e,r))return!0;return!1}onAction(e,n){return this.Fn.on(e,n)}$n(e,n){if(n!=null&&n.url){var r,s=e==null||(r=e.properties)==null?void 0:r.$current_url;if(!s||typeof s!="string"||!ac(s,n.url,n.url_matching||"contains"))return!1}return!0}Nn(e,n){return!!this.Un(e,n)&&!!this.zn(e,n)&&!!this.Vn(e,n)}Un(e,n){var r;if(n==null||!n.href)return!0;var s=this.Wn(e);if(s.length>0)return s.some((c=>ac(c.href,n.href,n.href_matching||"exact")));var i,a=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!a&&ac((i=a.match(/(?::|")href="(.*?)"/))?i[1]:"",n.href,n.href_matching||"exact")}zn(e,n){var r;if(n==null||!n.text)return!0;var s=this.Wn(e);if(s.length>0)return s.some((f=>ac(f.text,n.text,n.text_matching||"exact")||ac(f.$el_text,n.text,n.text_matching||"exact")));var i,a,c,u=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!u&&(i=(function(f){for(var h,p=[],m=/(?::|")text="(.*?)"/g;!Je(h=m.exec(f));)p.includes(h[1])||p.push(h[1]);return p})(u),a=n.text,c=n.text_matching||"exact",i.some((f=>ac(f,a,c))))}Vn(e,n){var r,s;if(n==null||!n.selector)return!0;var i=e==null||(r=e.properties)==null?void 0:r.$element_selectors;if(i!=null&&i.includes(n.selector))return!0;var a=(e==null||(s=e.properties)==null?void 0:s.$elements_chain)||"";if(n.selector_regex&&a)try{return new RegExp(n.selector_regex).test(a)}catch{return!1}return!1}Wn(e){var n;return(e==null||(n=e.properties)==null?void 0:n.$elements)==null?[]:e==null?void 0:e.properties.$elements}Dn(e,n){return n==null||!n.properties||n.properties.length===0||PP(n.properties.reduce(((r,s)=>{var i=Qe(s.value)?s.value.map(String):s.value!=null?[String(s.value)]:[];return r[s.key]={values:i,operator:s.operator||"exact"},r}),{}),e==null?void 0:e.properties)}}class yD{constructor(e){var n;this.Zn=[],this._instance=e,this.Gn=new Map,this.Qn=new Map,this.Jn=new Map,(n=this._instance)==null||n.onSessionId==null||n.onSessionId((r=>this.Kn(r)))}Yn(e,n){return!!e&&PP(e.propertyFilters,n==null?void 0:n.properties)}Xn(e,n){var r=new Map;return e.forEach((s=>{var i;(i=s.conditions)==null||(i=i[n])==null||(i=i.values)==null||i.forEach((a=>{if(a!=null&&a.name){var c=r.get(a.name)||[];c.push(s.id),r.set(a.name,c)}}))})),r}es(e,n,r){var s=(r===Qu.Activation?this.Gn:this.Qn).get(e),i=[];return this.ts((a=>{i=a.filter((c=>s==null?void 0:s.includes(c.id)))})),i.filter((a=>{var c,u=(c=a.conditions)==null||(c=c[r])==null||(c=c.values)==null?void 0:c.find((f=>f.name===e));return this.Yn(u,n)}))}register(e){var n;ge((n=this._instance)==null?void 0:n._addCaptureHook)||(this.rs(e),this.ns(e))}ns(e){var n=e.filter((r=>{var s,i;return((s=r.conditions)==null?void 0:s.actions)&&((i=r.conditions)==null||(i=i.actions)==null||(i=i.values)==null?void 0:i.length)>0}));n.length!==0&&(this.ss==null&&(this.ss=new vD(this._instance),this.ss.init(),this.ss.Bn((r=>{this.onAction(r)}))),n.forEach((r=>{var s,i,a,c,u;r.conditions&&(s=r.conditions)!=null&&s.actions&&(i=r.conditions)!=null&&(i=i.actions)!=null&&i.values&&((a=r.conditions)==null||(a=a.actions)==null||(a=a.values)==null?void 0:a.length)>0&&((c=this.ss)==null||c.register(r.conditions.actions.values),(u=r.conditions)==null||(u=u.actions)==null||(u=u.values)==null||u.forEach((f=>{if(f&&f.name){var h=this.Jn.get(f.name);h&&h.push(r.id),this.Jn.set(f.name,h||[r.id])}})))})))}rs(e){var n,r=e.filter((i=>{var a,c;return((a=i.conditions)==null?void 0:a.events)&&((c=i.conditions)==null||(c=c.events)==null||(c=c.values)==null?void 0:c.length)>0})),s=e.filter((i=>{var a,c;return((a=i.conditions)==null?void 0:a.cancelEvents)&&((c=i.conditions)==null||(c=c.cancelEvents)==null||(c=c.values)==null?void 0:c.length)>0}));r.length===0&&s.length===0||((n=this._instance)==null||n._addCaptureHook(((i,a)=>{this.onEvent(i,a)})),this.Gn=this.Xn(e,Qu.Activation),this.Qn=this.Xn(e,Qu.Cancellation))}onEvent(e,n){var r,s,i=this.os(),a=(n==null||(r=n.properties)==null?void 0:r.$survey_id)||(n==null||(s=n.properties)==null?void 0:s.$product_tour_id);if(a&&this.getActivatedIds().includes(a)){var c=this.ls(e,a);if(c==="consume")return i.info("event consumed activated item, removing it",{event:e,itemId:a}),void this.us([a]);if(c==="persist")return i.info("shown item promoted to persisted activation",{event:e,itemId:a}),void this.hs(a)}if(this.Qn.has(e)){var u=this.es(e,n,Qu.Cancellation);u.length>0&&(i.info("cancel event matched, cancelling items",{event:e,itemsToCancel:u.map((h=>h.id))}),this.us(u.map((h=>h.id))),u.forEach((h=>this.ds(h.id))))}if(this.Gn.has(e)){i.info("event name matched",{event:e,eventPayload:n,items:this.Gn.get(e)});var f=this.es(e,n,Qu.Activation);this.cs(f.map((h=>h.id)))}}onAction(e){this.Jn.has(e)&&this.cs(this.Jn.get(e)||[])}cs(e){e.length!==0&&(this.Zn=[...new Set([...this.Zn,...e])],this.os().info("updating activated items",{activatedItems:this.getActivatedIds()}))}hs(e){this.Zn=this.Zn.filter((r=>r!==e));var n=this.vs();n.includes(e)||(this.fs([...n,e]),this.ps())}us(e){var n=new Set(e);this.Zn=this.Zn.filter((i=>!n.has(i)));var r=this.gs(),s=r.filter((i=>!n.has(i)));s.length!==r.length&&(this.fs(s),s.length===0&&this.ys())}gs(){var e,n=this.bs();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[n])||[]}vs(){var e,n,r=this.gs();if(r.length===0)return[];var s=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[this._s()],i=(n=this._instance)==null||n.get_session_id==null?void 0:n.get_session_id();return i&&s===i?r:[]}ps(){var e,n=(e=this._instance)==null||e.get_session_id==null?void 0:e.get_session_id();n&&this.ws(n)}ys(){this.xs()}Kn(e){var n,r=(n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[this._s()];r&&r!==e&&(this.gs().length>0&&this.fs([]),this.ys())}getActivatedIds(){return[...new Set([...this.vs(),...this.Zn])].filter((e=>!this.ks(e)))}reset(){this.Zn=[],this.gs().length>0&&this.fs([]),this.ys()}getEventToItemsMap(){return this.Gn}Ss(){return this.ss}}class _D extends yD{constructor(e){super(e)}bs(){return Ey}_s(){return Cp}Cs(){return Ji.SHOWN}ts(e){var n;(n=this._instance)==null||n.getSurveys(e)}ds(e){var n;(n=this._instance)==null||n.cancelPendingSurvey(e)}os(){return yt}fs(e){var n;(n=this._instance)==null||(n=n.persistence)==null||n.register({[Ey]:e})}ws(e){var n;(n=this._instance)==null||(n=n.persistence)==null||n.register({[Cp]:e})}xs(){var e;(e=this._instance)==null||(e=e.persistence)==null||e.unregister(Cp)}ks(){return!1}ls(e,n){var r;this.ts((i=>{r=i.find((a=>a.id===n))}));var s=!r||(function(i){var a;return TP(i)&&!((a=i.conditions)==null||(a=a.events)==null||!a.repeatedActivation)||i.schedule==="always"})(r);return s?e===Ji.SHOWN?"consume":"ignore":e===Ji.SHOWN?"persist":e===Ji.DISMISSED||e===Ji.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var Qh="SDK is not enabled or survey functionality is not yet loaded",aC="Disabled. Not loading surveys.",xD=te!=null&&te.location?vm(te.location.hash,"__posthog")||vm(location.hash,"state"):null,lC="_postHogToolbarParams",cC=Vt("[Toolbar]"),un=Vt("[FeatureFlags]"),$a=Vt("[FeatureFlags]",{debugEnabled:!0}),Hv=`" failed. Feature flags didn't load in time.`,uC=t=>{for(var e={},n=0;t.length>n;n++)e[t[n]]=!0;return e},dC=t=>{var e={};for(var n of kp(t||{})){var r=n[1];r&&(e[n[0]]=r)}return e},Ni=Vt("[Error tracking]"),fC="Refusing to render web experiment since the viewer is a likely bot",wD={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>xm(e,t),not_regex:(t,e)=>!xm(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t};class Yn{get Te(){return this._instance.config}constructor(e){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(r){r===void 0&&(r=!1),n.getWebExperiments((s=>{Yn.Ms("retrieved web experiments from the server"),n.Is=new Map,s.forEach((i=>{if(i.feature_flag_key){var a;n.Is&&(Yn.Ms("setting flag key ",i.feature_flag_key," to web experiment ",i),(a=n.Is)==null||a.set(i.feature_flag_key,i));var c=n._instance.getFeatureFlag(i.feature_flag_key);xt(c)&&i.variants[c]&&n.Ts(i.name,c,i.variants[c].transforms)}else if(i.variants)for(var u in i.variants){var f=i.variants[u];Yn.Es(f,n._instance)&&n.Ts(i.name,u,f.transforms)}}))}),r)},this._instance=e,this._instance.onFeatureFlags((r=>{this.onFeatureFlags(r)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())Yn.Ms(fC);else if(!this.Te.disable_web_experiments){if(Je(this.Is))return this.Is=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Yn.Ms("applying feature flags",e),e.forEach((n=>{var r;if(this.Is&&(r=this.Is)!=null&&r.has(n)){var s,i=this._instance.getFeatureFlag(n),a=(s=this.Is)==null?void 0:s.get(n);i&&a!=null&&a.variants[i]&&this.Ts(a.name,i,a.variants[i].transforms)}}))}}previewWebExperiment(){var e=Yn.getWindowLocation();if(e!=null&&e.search){var n=Qc(e==null?void 0:e.search,"__experiment_id"),r=Qc(e==null?void 0:e.search,"__experiment_variant");n&&r&&(Yn.Ms("previewing web experiments "+n+" && "+r),this.getWebExperiments((s=>{this.Rs(parseInt(n),r,s)}),!1,!0))}}loadIfEnabled(){this.Te.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,n,r){if(this.Te.disable_web_experiments&&!r)return e([]);var s=this._instance.get_property("$web_experiments");if(s&&!n)return e(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Te.token),method:"GET",timestampMode:"query",callback:i=>e(i.statusCode===200&&i.json&&i.json.experiments||[])})}Rs(e,n,r){var s=r.filter((i=>i.id===e));s&&s.length>0&&(Yn.Ms("Previewing web experiment ["+s[0].name+"] with variant ["+n+"]"),this.Ts(s[0].name,n,s[0].variants[n].transforms))}static Es(e,n){return!Je(e.conditions)&&Yn.Ps(e,n)&&Yn.Os(e)}static Ps(e,n){var r;if(Je(e.conditions)||Je((r=e.conditions)==null?void 0:r.url))return!0;var s=Yn.getWindowLocation();if(s){var i,a,c,u=U6(n,s.href);return(i=e.conditions)==null||!i.url||wD[(a=(c=e.conditions)==null?void 0:c.urlMatchType)!==null&&a!==void 0?a:"icontains"](e.conditions.url,u)}return!1}static getWindowLocation(){return te==null?void 0:te.location}static Os(e){var n;if(Je(e.conditions)||Je((n=e.conditions)==null?void 0:n.utm))return!0;var r=oP();if(r.utm_source){var s,i,a,c,u,f,h,p,m=(s=e.conditions)==null||(s=s.utm)==null||!s.utm_campaign||((i=e.conditions)==null||(i=i.utm)==null?void 0:i.utm_campaign)==r.utm_campaign,_=(a=e.conditions)==null||(a=a.utm)==null||!a.utm_source||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_source)==r.utm_source,x=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_medium||((f=e.conditions)==null||(f=f.utm)==null?void 0:f.utm_medium)==r.utm_medium,y=(h=e.conditions)==null||(h=h.utm)==null||!h.utm_term||((p=e.conditions)==null||(p=p.utm)==null?void 0:p.utm_term)==r.utm_term;return m&&x&&y&&_}return!1}static Ms(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;n>s;s++)r[s-1]=arguments[s];_e.info("[WebExperiments] "+e,r)}Ts(e,n,r){this._is_bot()?Yn.Ms(fC):n!=="control"?r.forEach((s=>{if(s.selector){var i;Yn.Ms("applying transform of variant "+n+" for experiment "+e+" ",s);var a=(i=document)==null?void 0:i.querySelectorAll(s.selector);a==null||a.forEach((c=>{var u=c;s.html&&(u.innerHTML=s.html),s.css&&u.setAttribute("style",s.css)}))}})):Yn.Ms("Control variants leave the page unmodified.")}_is_bot(){return ar&&this._instance?EP(ar,this.Te.custom_blocked_useragents):void 0}}var ps=Vt("[Conversations]"),Ha="Conversations not available yet.",hC="console",n0={featureFlags:class{constructor(t){this.Fs=!1,this.As=!1,this.Ls=!1,this.$s=!1,this.Ns=!1,this.Ds=!1,this.qs=!1,this.js=!1,this.Hs=0,this.Bs=()=>{var e=this.Us();this.Hs=0,e&&this.reloadFeatureFlags()},this._instance=t,this.featureFlagEventHandlers=[],te&&zt(te,"online",this.Bs)}destroy(){te==null||te.removeEventListener("online",this.Bs)}get Te(){return this._instance.config}get mi(){return this._instance.persistence}zs(t){return this._instance.get_property(t)}Vs(){var t,e;return(t=(e=this.mi)==null?void 0:e._r(this.Te.feature_flag_cache_ttl_ms))!==null&&t!==void 0&&t}Ws(){return!!this.Vs()&&(this.js||this.Ls||(this.js=!0,un.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Zs(){var t,e=(t=this.Te.evaluation_contexts)!==null&&t!==void 0?t:this.Te.evaluation_environments;return!this.Te.evaluation_environments||this.Te.evaluation_contexts||this.qs||(un.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.qs=!0),e!=null&&e.length?e.filter((n=>{var r=n&&typeof n=="string"&&n.trim().length>0;return r||un.error("Invalid evaluation context found:",n,"Expected non-empty string"),r})):[]}Gs(){return this.Zs().length>0}Qs(){var t=this.Te.flag_keys;if(!ge(t)){if(Qe(t))return t.filter((e=>{var n=e&&typeof e=="string"&&e.trim().length>0;return n||un.error("Invalid flag key found:",e,"Expected non-empty string"),n}));un.error("Invalid flag_keys found:",t,"Expected array of non-empty strings")}}initialize(){var t,e,n=this._instance.config,r=(t=(e=n.bootstrap)==null?void 0:e.featureFlags)!==null&&t!==void 0?t:{};if(Object.keys(r).length){var s,i,a=(s=(i=n.bootstrap)==null?void 0:i.featureFlagPayloads)!==null&&s!==void 0?s:{},c=Object.keys(r).filter((f=>!!r[f])).reduce(((f,h)=>(f[h]=r[h]||!1,f)),{}),u=Object.keys(a).filter((f=>c[f])).reduce(((f,h)=>(a[h]&&(f[h]=a[h]),f)),{});this.receivedFeatureFlags({featureFlags:c,featureFlagPayloads:u})}}updateFlags(t,e,n){var r,s,i=n!=null&&n.merge&&(r=this.zs(tl))!==null&&r!==void 0?r:{},a=n!=null&&n.merge&&(s=this.zs(Ep))!==null&&s!==void 0?s:{},c=ue({},i,t),u=ue({},a,e),f={};for(var h of Object.entries(c)){var p=h[0],m=h[1];f[p]={key:p,enabled:pE(m),variant:mE(m),reason:void 0,metadata:ge(u==null?void 0:u[p])?void 0:{id:0,version:void 0,description:void 0,payload:u[p]}}}this.receivedFeatureFlags({flags:f})}get hasLoadedFlags(){return this.As}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.zs(wy),e=this.zs(zi),n=this.zs(pc);if(!n&&!e)return t||{};var r=At({},t||{}),s=[...new Set([...Object.keys(n||{}),...Object.keys(e||{})])];for(var i of s){var a,c,u=r[i],f=e==null?void 0:e[i],h=ge(f)?(a=u==null?void 0:u.enabled)!==null&&a!==void 0&&a:!!f,p=ge(f)?u.variant:typeof f=="string"?f:void 0,m=n==null?void 0:n[i],_=ue({},u,{enabled:h,variant:h?p??(u==null?void 0:u.variant):void 0});h!==(u==null?void 0:u.enabled)&&(_.original_enabled=u==null?void 0:u.enabled),p!==(u==null?void 0:u.variant)&&(_.original_variant=u==null?void 0:u.variant),m&&(_.metadata=ue({},u==null?void 0:u.metadata,{payload:m,original_payload:u==null||(c=u.metadata)==null?void 0:c.payload})),r[i]=_}return this.Fs||(un.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:n,finalDetails:r}),this.Fs=!0),r}getAllFeatureFlags(){var t=this.getFlagVariants(),e=this.getFlagPayloads();return Object.keys(t).map((n=>{var r=t[n];return{key:n,enabled:pE(r),variant:mE(r),payload:hE(e[n])}}))}getFlagVariants(){var t=this.zs(tl),e=this.zs(zi);if(!e)return t||{};for(var n=At({},t),r=Object.keys(e),s=0;r.length>s;s++)n[r[s]]=e[r[s]];return this.Fs||(un.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:n}),this.Fs=!0),n}getFlagPayloads(){var t=this.zs(Ep),e=this.zs(pc);if(!e)return t||{};for(var n=At({},t||{}),r=Object.keys(e),s=0;r.length>s;s++)n[r[s]]=e[r[s]];return this.Fs||(un.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:n}),this.Fs=!0),n}reloadFeatureFlags(){this.$s||this.Te.advanced_disable_feature_flags||this.Us()||this.Js||(this._instance.en.emit("featureFlagsReloading",!0),this.Js=setTimeout((()=>{this.Ks()}),5))}Ys(){clearTimeout(this.Js),this.Js=void 0}ensureFlagsLoaded(){this.As||this.Ls||this.Js||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.$s=t}Ks(t){var e;if(this.Ys(),!this._instance.Ur()&&!this.Us())if(this.Ls)this.Ns=!0;else{var n=this.Te.token,r=this.zs(am),s={token:n,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:ue({},((e=this.mi)==null?void 0:e.get_initial_props())||{},this.zs(Ya)||{},{$lib:gt.LIB_NAME,$lib_version:gt.LIB_VERSION}),group_properties:this.zs(Xa),timezone:fP()};dr(r)||ge(r)||(s.$device_id=r),(t!=null&&t.disableFlags||this.Te.advanced_disable_feature_flags)&&(s.disable_flags=!0),this.Gs()&&(s.evaluation_contexts=this.Zs());var i=this.Qs();ge(i)||(s.flag_keys=i);var a=!!this.Te.advanced_only_evaluate_survey_feature_flags,c=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.Te.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.Ls=!0,this._instance._send_request({method:"POST",url:c,data:s,compression:this.Te.disable_compression?void 0:or.Base64,timestampMode:"body",timeout:this.Te.feature_flag_request_timeout_ms,callback:u=>{var f,h,p,m=!0;if(this.Xs(u.statusCode),u.statusCode===200&&(this.Ns||(this.$anon_distinct_id=void 0),m=!1),this.Ls=!1,!s.disable_flags||this.Ns){this.Ds=!m;var _=[];u.error?u.error instanceof Error?_.push(u.error.name==="AbortError"?"timeout":"connection_error"):_.push("unknown_error"):u.statusCode!==200&&_.push("api_error_"+u.statusCode),(f=u.json)!=null&&f.errorsWhileComputingFlags&&_.push("errors_while_computing_flags");var x,y=!((h=u.json)==null||(h=h.quotaLimited)==null||!h.includes("feature_flags"));y&&_.push("quota_limited"),(p=this.mi)==null||p.register({[ky]:_}),y?un.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):(s.disable_flags||this.receivedFeatureFlags((x=u.json)!==null&&x!==void 0?x:{},m,{partialResponse:a}),this.Ns&&(this.Ns=!1,this.Ks()))}}})}}Us(){return sP(this.Hs,3)}Xs(t){this.Hs=iP(t,this.Hs,3,(()=>un.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes.")))}getFeatureFlag(t,e){var n;if(e===void 0&&(e={}),!e.fresh||this.Ds)if(this.As||this.getFlags()&&this.getFlags().length>0){if(!this.Ws()){var r=this.getFeatureFlagResult(t,e);return(n=r==null?void 0:r.variant)!==null&&n!==void 0?n:r==null?void 0:r.enabled}}else un.warn('getFeatureFlag for key "'+t+Hv)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var e=this.getFeatureFlagResult(t,{send_event:!1});return e==null?void 0:e.payload}getFeatureFlagResult(t,e){if(e===void 0&&(e={}),!e.fresh||this.Ds)if(this.As||this.getFlags()&&this.getFlags().length>0){if(!this.Ws()){var n=this.getFlagVariants(),r=t in n,s=n[t],i=this.getFlagPayloads()[t],a=String(s),c=this.zs(by)||void 0,u=this.zs($d)||void 0,f=this.zs(bd)||{};if(this.Te.advanced_feature_flags_dedup_per_session){var h,p=this._instance.get_session_id(),m=this.zs(Cy);p&&p!==m&&(f={},(h=this.mi)==null||h.register({[bd]:f,[Cy]:p}))}if((e.send_event||!("send_event"in e))&&(!(t in f)||!f[t].includes(a))){var _,x,y,w,S,T,P,k,R,L,O;Qe(f[t])?f[t].push(a):f[t]=[a],(_=this.mi)==null||_.register({[bd]:f});var A=this.getFeatureFlagDetails(t),I=[...(x=this.zs(ky))!==null&&x!==void 0?x:[]];ge(s)&&I.push("flag_missing");var N={$feature_flag:t,$feature_flag_response:s,$feature_flag_payload:i||null,$feature_flag_request_id:c,$feature_flag_evaluated_at:u,$feature_flag_bootstrapped_response:((y=this.Te.bootstrap)==null||(y=y.featureFlags)==null?void 0:y[t])||null,$feature_flag_bootstrapped_payload:((w=this.Te.bootstrap)==null||(w=w.featureFlagPayloads)==null?void 0:w[t])||null,$used_bootstrap_value:!this.Ds};ge(A==null||(S=A.metadata)==null?void 0:S.has_experiment)||(N.$feature_flag_has_experiment=A.metadata.has_experiment),ge(A==null||(T=A.metadata)==null?void 0:T.version)||(N.$feature_flag_version=A.metadata.version);var j,F=(P=A==null||(k=A.reason)==null?void 0:k.description)!==null&&P!==void 0?P:A==null||(R=A.reason)==null?void 0:R.code;F&&(N.$feature_flag_reason=F),A!=null&&(L=A.metadata)!=null&&L.id&&(N.$feature_flag_id=A.metadata.id),ge(A==null?void 0:A.original_variant)&&ge(A==null?void 0:A.original_enabled)||(N.$feature_flag_original_response=ge(A.original_variant)?A.original_enabled:A.original_variant),A!=null&&(O=A.metadata)!=null&&O.original_payload&&(N.$feature_flag_original_payload=A==null||(j=A.metadata)==null?void 0:j.original_payload),I.length&&(N.$feature_flag_error=I.join(",")),this._instance.capture("$feature_flag_called",N)}if(r)return{key:t,enabled:!!s,variant:typeof s=="string"?s:void 0,payload:hE(i)}}}else un.warn('getFeatureFlagResult for key "'+t+Hv)}getRemoteConfigPayload(t,e){var n=this.Te.token,r={distinct_id:this._instance.get_distinct_id(),token:n,person_properties:{$lib:gt.LIB_NAME,$lib_version:gt.LIB_VERSION}};this.Gs()&&(r.evaluation_contexts=this.Zs());var s=this.Qs();ge(s)||(r.flag_keys=s),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this.Te.disable_compression?void 0:or.Base64,timestampMode:"body",timeout:this.Te.feature_flag_request_timeout_ms,callback(i){var a,c=(a=i.json)==null?void 0:a.featureFlagPayloads;e((c==null?void 0:c[t])||void 0)}})}isFeatureEnabled(t,e){if(e===void 0&&(e={}),e.fresh&&!this.Ds)return e.defaultValue;if(!(this.As||this.getFlags()&&this.getFlags().length>0))return un.warn('isFeatureEnabled for key "'+t+Hv),e.defaultValue;var n=this.getFeatureFlag(t,e);return ge(n)?e.defaultValue:!!n}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==t))}receivedFeatureFlags(t,e,n){if(this.mi){this.As=!0;var r=this.getFlagVariants(),s=this.getFlagPayloads(),i=this.getFlagsWithDetails();(function(a,c,u,f,h,p){u===void 0&&(u={}),f===void 0&&(f={}),h===void 0&&(h={});var m=(A=>{var I=A.flags;return I?(A.featureFlags=Object.fromEntries(Object.keys(I).map((N=>{var j;return[N,(j=I[N].variant)!==null&&j!==void 0?j:I[N].enabled]}))),A.featureFlagPayloads=Object.fromEntries(Object.keys(I).filter((N=>I[N].enabled)).filter((N=>{var j;return(j=I[N].metadata)==null?void 0:j.payload})).map((N=>{var j;return[N,(j=I[N].metadata)==null?void 0:j.payload]})))):A.featureFlags&&un.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),A})(a),_=m.flags,x=m.featureFlags,y=m.featureFlagPayloads;if(x){var w=a.requestId,S=a.evaluatedAt;if(Qe(x)){un.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var T={};if(x)for(var P=0;x.length>P;P++)T[x[P]]=!0;c&&c.register({[Sp]:x,[tl]:T,[lm]:!1})}else{var k=x,R=y,L=_;if(p!=null&&p.partialResponse)k=ue({},u,k),R=ue({},f,R),L=ue({},h,L);else if(a.errorsWhileComputingFlags)if(_){var O=new Set(Object.keys(_).filter((A=>{var I;return!((I=_[A])!=null&&I.failed)})));k=ue({},u,Object.fromEntries(Object.entries(k).filter((A=>O.has(A[0]))))),R=ue({},f,Object.fromEntries(Object.entries(R||{}).filter((A=>O.has(A[0]))))),L=ue({},h,Object.fromEntries(Object.entries(L||{}).filter((A=>O.has(A[0])))))}else k=ue({},u,k),R=ue({},f,R),L=ue({},h,L);c&&c.register(ue({[Sp]:Object.keys(dC(k)),[tl]:k||{},[Ep]:R||{},[wy]:L||{},[lm]:a.minimalFlagCalledEvents===!0},w?{[by]:w}:{},S?{[$d]:S}:{}))}}})(t,this.mi,r,s,i,n),e||(this.js=!1),this.eo(e)}}override(t,e){e===void 0&&(e=!1),un.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.mi)return un.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(t===!1)return this.mi.unregister(zi),this.mi.unregister(pc),this.eo(),$a.info("All overrides cleared");if(Qe(t)){var e=uC(t);return this.mi.register({[zi]:e}),this.eo(),$a.info("Flag overrides set",{flags:t})}if(t&&typeof t=="object"&&("flags"in t||"payloads"in t)){var n,r=t;if(this.Fs=!!((n=r.suppressWarning)!==null&&n!==void 0&&n),"flags"in r){if(r.flags===!1)this.mi.unregister(zi),$a.info("Flag overrides cleared");else if(r.flags){if(Qe(r.flags)){var s=uC(r.flags);this.mi.register({[zi]:s})}else this.mi.register({[zi]:r.flags});$a.info("Flag overrides set",{flags:r.flags})}}return"payloads"in r&&(r.payloads===!1?(this.mi.unregister(pc),$a.info("Payload overrides cleared")):r.payloads&&(this.mi.register({[pc]:r.payloads}),$a.info("Payload overrides set",{payloads:r.payloads}))),void this.eo()}if(t&&typeof t=="object")return this.mi.register({[zi]:t}),this.eo(),$a.info("Flag overrides set",{flags:t});un.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.As){var e=this.ro(),n=e.flags,r=e.flagVariants;try{t(n,r)}catch(s){un.error("Error while running feature flags callback",s)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,n){var r,s=(this.zs(md)||[]).find((u=>u.flagKey===t)),i={["$feature_enrollment/"+t]:e},a={$feature_flag:t,$feature_enrollment:e,$set:i};s&&(a.$early_access_feature_name=s.name),n&&(a.$feature_enrollment_stage=n),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(i,!1);var c=ue({},this.getFlagVariants(),{[t]:e});(r=this.mi)==null||r.register({[Sp]:Object.keys(dC(c)),[tl]:c}),this.eo()}getEarlyAccessFeatures(t,e,n){e===void 0&&(e=!1);var r=this.zs(md),s=n?"&"+n.map((i=>"stage="+i)).join("&"):"";if(r&&!e)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.Te.token+s),method:"GET",timestampMode:"query",callback:i=>{var a,c;if(i.json){var u=i.json.earlyAccessFeatures;return(a=this.mi)==null||a.unregister(md),(c=this.mi)==null||c.register({[md]:u}),t(u)}}})}ro(){var t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter((n=>e[n])),flagVariants:Object.keys(e).filter((n=>e[n])).reduce(((n,r)=>(n[r]=e[r],n)),{})}}eo(t){var e=this.ro(),n=e.flags,r=e.flagVariants;this.featureFlagEventHandlers.forEach((s=>{try{s(n,r,{errorsLoading:t})}catch(i){un.error("Error while running feature flags callback",i)}}))}setPersonPropertiesForFlags(t,e){e===void 0&&(e=!0);var n=this.zs(Ya)||{},r=(t==null?void 0:t.$set)||(t!=null&&t.$set_once?{}:t),s=t==null?void 0:t.$set_once,i={};if(s)for(var a in s)({}).hasOwnProperty.call(s,a)&&(a in n||(i[a]=s[a]));this._instance.register({[Ya]:ue({},n,i,r)}),e&&this._instance.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e){e===void 0&&(e=!0);var n=ue({},this.zs(Ya)||{});t.forEach((r=>{delete n[r]})),this._instance.register({[Ya]:n}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){t===void 0&&(t=!0),this._instance.unregister(Ya),t&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){e===void 0&&(e=!0);var n=this.zs(Xa)||{};Object.keys(n).length!==0&&Object.keys(n).forEach((r=>{n[r]=ue({},n[r],t[r]),delete t[r]})),this._instance.register({[Xa]:ue({},n,t)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.zs(Xa)||{};this._instance.register({[Xa]:ue({},e,{[t]:{}})})}else this._instance.unregister(Xa)}reset(){this.As=!1,this.Ls=!1,this.$s=!1,this.Ns=!1,this.Ds=!1,this.$anon_distinct_id=void 0,this.Ys(),this.Fs=!1,this.Hs=0}}},bD={sessionRecording:class{get Te(){return this._instance.config}get mi(){return this._instance.persistence}get started(){var t;return!((t=this.io)==null||!t.isStarted)}get status(){var t,e;return this.no===id||this.no===Xh?this.no:(t=(e=this.io)==null?void 0:e.status)!==null&&t!==void 0?t:this.no}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.no=sC,this.so=void 0,this._instance=t,!this._instance.sessionManager)throw Li.error("started without valid sessionManager"),new Error(Hy+" started without valid sessionManager. This is a bug.");if(this.Te.cookieless_mode===Xi)throw new Error(Hy+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get oo(){var t,e=!((t=this._instance.get_property(sl))==null||!t.enabled),n=!this.Te.disable_session_recording,r=this.Te.disable_session_recording||this._instance.consent.isOptedOut();return te&&e&&n&&!r}startIfEnabledOrStop(t){var e;if(!this.oo||(e=this.io)==null||!e.isStarted){var n=!ge(Object.assign)&&!ge(Array.from);this.oo&&n?(this.ao(t),Li.info("starting")):(this.no=sC,this.stopRecording())}}ao(t){var e,n,r;this.oo&&(this.no!==id&&this.no!==Xh&&(this.no=iC),$e!=null&&(e=$e.__PosthogExtensions__)!=null&&(e=e.rrweb)!=null&&e.record&&(n=$e.__PosthogExtensions__)!=null&&n.initSessionRecording?this.lo(t):(r=$e.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,this.uo,(s=>{if(s)return Li.error("could not load recorder",s);this.lo(t)})))}stopRecording(){var t,e;(t=this.so)==null||t.call(this),this.so=void 0,(e=this.io)==null||e.stop()}ho(){var t,e;(t=this.so)==null||t.call(this),this.so=void 0,(e=this.io)==null||e.discard()}do(){var t,e;(t=this.mi)==null||t.unregister(C2),(e=this.mi)==null||e.unregister(I6)}co(t,e){if(Je(t))return null;var n,r=$n(t)?t:parseFloat(t);return typeof(n=r)!="number"||!Number.isFinite(n)||0>n||n>1?(Li.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}vo(t){if(this.mi){var e,n,r=this.mi,s=()=>{var i,a=t.sessionRecording===!1?void 0:t.sessionRecording,c=this.co((i=this.Te.session_recording)==null?void 0:i.sampleRate,"session_recording.sampleRate"),u=this.co(a==null?void 0:a.sampleRate,"remote config sampleRate"),f=c??u;Je(f)&&this.do();var h=a==null?void 0:a.minimumDurationMilliseconds;r.register({[sl]:ue({cache_timestamp:Date.now(),enabled:!!a},a,{networkPayloadCapture:ue({capturePerformance:t.capturePerformance},a==null?void 0:a.networkPayloadCapture),canvasRecording:{enabled:a==null?void 0:a.recordCanvas,fps:a==null?void 0:a.canvasFps,quality:a==null?void 0:a.canvasQuality},sampleRate:f,minimumDurationMilliseconds:ge(h)?null:h,endpoint:a==null?void 0:a.endpoint,triggerMatchType:a==null?void 0:a.triggerMatchType,masking:a==null?void 0:a.masking,urlTriggers:a==null?void 0:a.urlTriggers,version:a==null?void 0:a.version,triggerGroups:a==null?void 0:a.triggerGroups})})};s(),(e=this.so)==null||e.call(this),this.so=(n=this._instance.sessionManager)==null?void 0:n.onSessionId(s)}}onRemoteConfig(t){var e=t.ok?t.config:void 0;return e&&"sessionRecording"in e?e.sessionRecording===!1?(this.vo(e),void this.ho()):(this.vo(e),void this.startIfEnabledOrStop()):(this.no===id&&(this.no=Xh,Li.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e){var n;e===void 0&&(e="log"),(n=this.io)!=null&&n.log?this.io.log(t,e):Li.warn("log called before recorder was ready")}get uo(){var t,e,n=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.get_property(sl);return(n==null||(e=n.scriptConfig)==null?void 0:e.script)||"lazy-recorder"}fo(){var t,e,n=this._instance.get_property(sl);if(!n)return!1;try{e=typeof n=="object"?n:JSON.parse(n)}catch(s){return Li.warn("persisted remote config for session recording is invalid and will be ignored",s),!1}var r=(t=e.cache_timestamp)!==null&&t!==void 0?t:Date.now();return 36e5>=Date.now()-r}lo(t){var e,n;if((e=$e.__PosthogExtensions__)==null||!e.initSessionRecording)return Li.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[V6]:!0});if(this.io||(this.io=(n=$e.__PosthogExtensions__)==null?void 0:n.initSessionRecording(this._instance),this.io._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.fo())return this.no===Xh||this.no===id?void 0:(this.no=id,Li.info("persisted remote config is stale, requesting fresh config before starting"),void new hP(this._instance).load());this.no=iC,this.io.start(t)}onRRwebEmit(t){var e;(e=this.io)==null||e.onRRwebEmit==null||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.io||(e=this.mi)==null||e.register({[O6]:!0}),(t=this.io)==null||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.io||(e=this.mi)==null||e.register({[M6]:!0}),(t=this.io)==null||t.overrideSampling()}overrideTrigger(t){var e,n;this.io||(n=this.mi)==null||n.register({[t==="url"?L6:N6]:!0}),(e=this.io)==null||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return((t=this.io)==null?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var n;return!((n=this.io)==null||!n.tryAddCustomEvent(t,e))}}},SD={autocapture:class{constructor(t){this.po=!1,this.mo=null,this.yo=!1,this.bo=!1,this.instance=t,this.rageclicks=new tC(t.config.rageclick),this._o=null}initialize(){this.startIfEnabled()}get Te(){var t,e,n=Nt(this.instance.config.autocapture)?this.instance.config.autocapture:{};return n.url_allowlist=(t=n.url_allowlist)==null?void 0:t.map((r=>new RegExp(r))),n.url_ignorelist=(e=n.url_ignorelist)==null?void 0:e.map((r=>new RegExp(r))),n}wo(){if(this.isBrowserSupported()){if(te&&Se){var t=n=>{n=n||(te==null?void 0:te.event);try{this.xo(n)}catch(r){Dv.error("Failed to capture event",r)}};if(zt(Se,"submit",t,{capture:!0}),zt(Se,"change",t,{capture:!0}),zt(Se,"click",t,{capture:!0}),this.Te.capture_copied_text){var e=n=>{n=n||(te==null?void 0:te.event);try{this.xo(n,Nv)}catch(r){Dv.error("Failed to capture copy/cut event",r)}};zt(Se,"copy",e,{capture:!0}),zt(Se,"cut",e,{capture:!0})}}}else Dv.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.po&&(this.wo(),this.po=!0)}onRemoteConfig(t){if(this.yo=!0,t.ok){var e=t.config;e.elementsChainAsString&&(this.bo=e.elementsChainAsString);var n=e.autocapture_opt_out;Us(n)&&(this.instance.persistence&&this.instance.persistence.register({[py]:n}),this.mo=n),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this._o=t}getElementSelectors(t){var e,n=[];return(e=this._o)==null||e.forEach((r=>{var s=Se==null?void 0:Se.querySelectorAll(r);s==null||s.forEach((i=>{t===i&&n.push(r)}))})),n}get isEnabled(){var t,e,n=(t=this.instance.persistence)==null?void 0:t.props[py],r=this.mo,s=this.instance.Ur()&&!this.yo;if(dr(r)&&!Us(n)&&!s)return!1;var i=(e=this.mo)!==null&&e!==void 0?e:!!n;return!!this.instance.config.autocapture&&!i}xo(t,e){if(e===void 0&&(e="$autocapture"),this.isEnabled){var n,r=Ev(t);W6(r)&&(r=r.parentNode||null),e==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&this.instance.config.rageclick&&(n=this.rageclicks)!=null&&n.isRageClick(t.clientX,t.clientY,t.timeStamp||new Date().getTime())&&NE(r,this.instance.config.rageclick)&&this.xo(t,"$rageclick");var s=e===Nv;if(r&&(function(p,m,_,x,y,w){var S;if(!te||A2(p)||_!=null&&_.url_allowlist&&!ME(_.url_allowlist,w)||_!=null&&_.url_ignorelist&&ME(_.url_ignorelist,w))return!1;if(_!=null&&_.dom_event_allowlist){var T=_.dom_event_allowlist;if(T&&!T.some((A=>m.type===A)))return!1}var P=X6(p,x),k=P.parentIsUsefulElement,R=P.targetElementList;if(!(function(A,I){var N=I==null?void 0:I.element_allowlist;if(ge(N))return!0;var j,F=function(X){if(N.some((W=>X.tagName.toLowerCase()===W)))return{v:!0}};for(var K of A)if(j=F(K))return j.v;return!1})(R,_)||!My(R,_==null?void 0:_.css_selector_allowlist)||My(R,(S=_==null?void 0:_.css_selector_ignorelist)!==null&&S!==void 0?S:SN))return!1;try{var L=te.getComputedStyle(p);if(L&&L.getPropertyValue("cursor")==="pointer"&&m.type==="click")return!0}catch{}var O=p.tagName.toLowerCase();switch(O){case"html":return!1;case"form":return(y||["submit"]).indexOf(m.type)>=0;case"input":case"select":case"textarea":return(y||["change","click"]).indexOf(m.type)>=0;default:return k?(y||["click"]).indexOf(m.type)>=0:(y||["click"]).indexOf(m.type)>=0&&(R2.indexOf(O)>-1||p.getAttribute("contenteditable")==="true")}})(r,t,this.Te,s,s?["copy","cut"]:void 0,this.instance)){var i=hD(r,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Te.element_attribute_ignorelist,elementsChainAsString:this.bo,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes}),a=i.props;if(i.explicitNoCapture)return!1;var c=this.getElementSelectors(r);if(c&&c.length>0&&(a.$element_selectors=c),e===Nv){var u,f=Z6(te==null||(u=te.getSelection())==null?void 0:u.toString()),h=t.type||"clipboard";if(!f)return!1;a.$selected_content=f,a.$copy_type=h}return this.instance.capture(e,a),!0}}}isBrowserSupported(){return zs(Se==null?void 0:Se.querySelectorAll)}},historyAutocapture:class{constructor(t){var e;this._instance=t,this.ko=(te==null||(e=te.location)==null?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(_e.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.So&&this.So(),this.So=void 0,_e.info("History API monitoring stopped")}monitorHistoryChanges(){te&&te.history&&(this.Co("pushState"),this.Co("replaceState"),this.Mo())}Co(t){var e;if(te&&((e=te.history[t])==null||!e.__posthog_wrapped__)){var n=this;(function(r,s,i){try{if(!(s in r))return nC;var a={next:r[s]},c=i((function(){for(var u=arguments.length,f=new Array(u),h=0;u>h;h++)f[h]=arguments[h];return a.next.apply(this,f)}));return zs(c)&&(c.prototype=c.prototype||{},Object.defineProperties(c,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:a}})),r[s]=c,()=>{if(r[s]!==c)for(var u=r[s];zs(u)&&u.__posthog_layer__;){var f=u.__posthog_layer__;if(f.next===c)return void(f.next=a.next);u=f.next}else r[s]=a.next}}catch{return nC}})(te.history,t,(r=>function(s,i,a){r.call(this,s,i,a),n.Io(t)}))}}Io(t){try{var e,n=te==null||(e=te.location)==null?void 0:e.pathname;if(!n)return;n!==this.ko&&this.isEnabled&&this._instance.capture(mc,{navigation_type:t}),this.ko=n}catch(r){_e.error("Error capturing "+t+" pageview",r)}}Mo(){if(!this.So){var t=()=>{this.Io("popstate")};zt(te,"popstate",t),this.So=()=>{te&&te.removeEventListener("popstate",t)}}}},heatmaps:class{get Te(){return this.instance.config}constructor(t){var e;this.To=!1,this.po=!1,this.Eo=null,this.instance=t,this.To=!((e=this.instance.persistence)==null||!e.props[my]),this.rageclicks=new tC(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return Nt(this.Te.capture_heatmaps)&&this.Te.capture_heatmaps.flush_interval_milliseconds&&(t=this.Te.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return Je(this.Te.capture_heatmaps)?Je(this.Te.enable_heatmaps)?this.To:this.Te.enable_heatmaps:this.Te.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.po)return;mD.info("starting..."),this.Ro(),this.xe()}else{var t;clearInterval((t=this.Eo)!==null&&t!==void 0?t:void 0),this.Po(),this.getAndClearBuffer()}}onRemoteConfig(t){if(t.ok){var e=t.config;if("heatmaps"in e){var n=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[my]:n}),this.To=n,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.R;return this.R=void 0,t}Oo(t){Fv(t.originalEvent)&&this.pe(t.originalEvent,"deadclick")}xe(){this.Eo&&clearInterval(this.Eo),this.Eo=(Se==null?void 0:Se.visibilityState)==="visible"?setInterval(this.oi.bind(this),this.flushIntervalMilliseconds):null}Ro(){te&&Se&&(this.Fo=this.oi.bind(this),zt(te,hm,this.Fo),this.Ao=t=>this.pe(t||(te==null?void 0:te.event)),zt(Se,"click",this.Ao,{capture:!0}),this.Lo=t=>this.$o(t||(te==null?void 0:te.event)),zt(Se,"mousemove",this.Lo,{capture:!0}),this.No=new FE(this.instance,IN,this.Oo.bind(this)),this.No.startIfEnabledOrStop(),this.Do=this.xe.bind(this),zt(Se,fm,this.Do),this.po=!0)}Po(){var t;te&&Se&&(this.Fo&&te.removeEventListener(hm,this.Fo),this.Ao&&Se.removeEventListener("click",this.Ao,{capture:!0}),this.Lo&&Se.removeEventListener("mousemove",this.Lo,{capture:!0}),this.Do&&Se.removeEventListener(fm,this.Do),clearTimeout(this.qo),(t=this.No)==null||t.stop(),this.po=!1)}jo(t,e){var n=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),i=(function(a,c,u){for(var f=a;f&&ia(f)&&!qr(f,"body");){if(f===u)return!1;var h=void 0;try{var p,m,_;h=(p=(m=(_=f.ownerDocument)==null?void 0:_.defaultView)!==null&&m!==void 0?m:te)==null?void 0:p.getComputedStyle(f).position}catch{return!1}if(Ge(c,h))return!0;f=q6(f)}return!1})(Ev(t),["fixed","sticky"],s);return{x:t.clientX+(i?0:r),y:t.clientY+(i?0:n),target_fixed:i,type:e}}pe(t,e){var n;if(e===void 0&&(e="click"),!IE(t.target)&&Fv(t)){var r=this.jo(t,e);(n=this.rageclicks)!=null&&n.isRageClick(t.clientX,t.clientY,new Date().getTime())&&NE(Ev(t),this.instance.config.rageclick)&&this.Nt(ue({},r,{type:"rageclick"})),this.Nt(r)}}$o(t){!IE(t.target)&&Fv(t)&&(clearTimeout(this.qo),this.qo=setTimeout((()=>{this.Nt(this.jo(t,"mousemove"))}),500))}Nt(t){if(te){var e=this.Te.disable_capture_url_hashes?sa(te.location.href):te.location.href,n=this.Te.custom_personal_data_properties,r=this.Te.mask_personal_data_properties?[...Jc,...n||[]]:[],s=zd(e,r,Ud);this.R=this.R||{},this.R[s]||(this.R[s]=[]),this.R[s].push(t)}}oi(){this.R&&!Zo(this.R)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:FE,webVitalsAutocapture:class{constructor(t){var e;this.To=!1,this.po=!1,this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Ho=()=>{clearTimeout(this.Bo),this.R.metrics.length!==0&&(this._instance.capture("$web_vitals",this.R.metrics.reduce(((n,r)=>ue({},n,{["$web_vitals_"+r.name+"_event"]:ue({},r),["$web_vitals_"+r.name+"_value"]:r.value})),{})),this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Uo=n=>{var r;this.R=this.R||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var s=this.zo();if(!ge(s))if(Je(n==null?void 0:n.name)||Je(n==null?void 0:n.value))Va.error("Invalid metric received",n);else if(!this.Vo||this.Vo>n.value){this.R.url!==s&&(this.Ho(),this.Bo=setTimeout(this.Ho,this.flushToCaptureTimeoutMs)),ge(this.R.url)&&(this.R.url=s),this.R.firstMetricTimestamp=ge(this.R.firstMetricTimestamp)?Date.now():this.R.firstMetricTimestamp,n.attribution&&n.attribution.interactionTargetElement&&(n.attribution.interactionTargetElement=void 0);var i=(r=this._instance.sessionManager)==null?void 0:r.checkAndGetSessionAndWindowId(!0),a=ue({},n,{$current_url:s,timestamp:Date.now()});ge(i)||(a.$session_id=i.sessionId,a.$window_id=i.windowId),this.R.metrics.push(a),this.R.metrics.length===this.allowedMetrics.length&&this.Ho()}else Va.error("Ignoring metric with value >= "+this.Vo,n)},this.Wo=()=>{if(!this.po){var n,r,s,i,a=$e.__PosthogExtensions__;if(!ge(a)&&!ge(a.postHogWebVitalsCallbacks)){var c=a.postHogWebVitalsCallbacks;n=c.onLCP,r=c.onCLS,s=c.onFCP,i=c.onINP}n&&r&&s&&i?(this.allowedMetrics.indexOf("LCP")>-1&&n(this.Uo.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&r(this.Uo.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&s(this.Uo.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&i(this.Uo.bind(this)),this.po=!0):Va.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.To=!((e=this._instance.persistence)==null||!e.props[_y]),this.startIfEnabled()}get Zo(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,n=Nt(this.Zo)?(t=this.Zo)==null?void 0:t.web_vitals_allowed_metrics:void 0;return Je(n)?((e=this._instance.persistence)==null?void 0:e.props[xy])||["CLS","FCP","INP","LCP"]:n}get flushToCaptureTimeoutMs(){return(Nt(this.Zo)?this.Zo.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=Nt(this.Zo)?this.Zo.web_vitals_attribution:void 0;return t!=null&&t}get Vo(){var t=Nt(this.Zo)&&$n(this.Zo.__web_vitals_max_value)?this.Zo.__web_vitals_max_value:rC;return t>0&&6e4>=t?rC:t}get isEnabled(){var t=rn==null?void 0:rn.protocol;if(t!=="http:"&&t!=="https:")return Va.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=Nt(this.Zo)?this.Zo.web_vitals:Us(this.Zo)?this.Zo:void 0;return Us(e)?e:this.To}startIfEnabled(){this.isEnabled&&!this.po&&(Va.info("enabled, starting..."),this.er(this.Wo))}onRemoteConfig(t){if(t.ok){var e=t.config;if("capturePerformance"in e){var n=Nt(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=Nt(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[_y]:n}),this._instance.persistence.register({[xy]:r})),this.To=n,this.startIfEnabled()}}}er(t){var e,n;(e=$e.__PosthogExtensions__)!=null&&e.postHogWebVitalsCallbacks?t():(n=$e.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(r=>{r?Va.error("failed to load script",r):t()}))}zo(){var t=te?this._instance.config.disable_capture_url_hashes?sa(te.location.href):te.location.href:void 0;if(t){var e=this._instance.config.custom_personal_data_properties,n=this._instance.config.mask_personal_data_properties?[...Jc,...e||[]]:[];return zd(t,n,Ud)}Va.error("Could not determine current URL")}}},ED={exceptionObserver:class{constructor(t){var e;this.Wo=()=>{var n;if(te&&this.isEnabled&&(n=$e.__PosthogExtensions__)!=null&&n.errorWrappingFunctions){var r=$e.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,s=$e.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,i=$e.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Go&&this.Te.capture_unhandled_errors&&(this.Go=r(this.captureException.bind(this))),!this.Qo&&this.Te.capture_unhandled_rejections&&(this.Qo=s(this.captureException.bind(this))),!this.Jo&&this.Te.capture_console_errors&&(this.Jo=i(this.captureException.bind(this)))}catch(a){sd.error("failed to start",a),this.Ko()}}},this._instance=t,this.Yo=!((e=this._instance.persistence)==null||!e.props[gy]),this.Xo=new CL(ue({},(function(n){var r,s,i,a;return n===void 0&&(n={}),{refillRate:(r=(s=n.exceptionRateLimiterRefillRate)!==null&&s!==void 0?s:n.__exceptionRateLimiterRefillRate)!==null&&r!==void 0?r:1,bucketSize:(i=(a=n.exceptionRateLimiterBucketSize)!==null&&a!==void 0?a:n.__exceptionRateLimiterBucketSize)!==null&&i!==void 0?i:10}})(this._instance.config.error_tracking),{refillInterval:1e4,Ge:sd})),this.Te=this.ea(),this.startIfEnabledOrStop()}ea(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Nt(t)?e=ue({},e,t):(ge(t)?this.Yo:t)&&(e=ue({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Te.capture_console_errors||this.Te.capture_unhandled_errors||this.Te.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(sd.info("enabled"),this.Ko(),this.er(this.Wo)):this.Ko()}er(t){var e,n;(e=$e.__PosthogExtensions__)!=null&&e.errorWrappingFunctions?t():(n=$e.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"exception-autocapture",(r=>{if(r)return sd.error("failed to load script",r);t()}))}Ko(){var t,e,n;(t=this.Go)==null||t.call(this),this.Go=void 0,(e=this.Qo)==null||e.call(this),this.Qo=void 0,(n=this.Jo)==null||n.call(this),this.Jo=void 0}onRemoteConfig(t){if(t.ok){var e=t.config;"autocaptureExceptions"in e&&(this.Yo=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[gy]:this.Yo}),this.Te=this.ea(),this.startIfEnabledOrStop())}}onConfigChange(){this.Te=this.ea()}captureException(t){var e,n,r,s=(e=t==null||(n=t.$exception_list)==null||(n=n[0])==null?void 0:n.type)!==null&&e!==void 0?e:"Exception";this.Xo.consumeRateLimit(s)?sd.info("Skipping exception capture because of client rate limiting.",{exception:s}):(r=this._instance.exceptions)==null||r.sendExceptionEvent(t)}},exceptions:class{constructor(t){var e,n;this.ta=[],this.ra=new zL([new YL,new iN,new QL,new XL,new rN,new nN,new eN,new sN],(function(r){for(var s=arguments.length,i=new Array(s>1?s-1:0),a=1;s>a;a++)i[a-1]=arguments[a];return function(c,u){u===void 0&&(u=0);for(var f=[],h=c.split(`
18
18
  `),p=u;h.length>p;p++){var m=h[p];if(1024>=m.length){var _=PE.test(m)?m.replace(PE,"$1"):m;if(!_.match(/\S*Error: /)){for(var x of i){var y=x(_,r);if(y){f.push(y);break}}if(f.length>=50)break}}}return(function(w){if(!w.length)return[];var S=Array.from(w);return S.reverse(),S.slice(0,50).map((T=>{return ue({},T,{filename:T.filename||(P=S,P[P.length-1]||{}).filename,function:T.function||Xc});var P}))})(f)}})("web:javascript",GL,qL)),this._instance=t,this.ta=(e=(n=this._instance.persistence)==null?void 0:n.get_property(vy))!==null&&e!==void 0?e:[],this.ia=om(this.na()),this.sa=new aN(this.ia)}onConfigChange(){this.ia=om(this.na()),this.sa.setConfig(this.ia)}onRemoteConfig(t){var e,n,r;if(t.ok){var s=t.config;if("errorTracking"in s){var i=(e=(n=s.errorTracking)==null?void 0:n.suppressionRules)!==null&&e!==void 0?e:[],a=(r=s.errorTracking)==null?void 0:r.captureExtensionExceptions;this.ta=i,this._instance.persistence&&this._instance.persistence.register({[vy]:this.ta,[yy]:a})}}}get oa(){var t,e=!!this._instance.get_property(yy),n=this._instance.config.error_tracking.captureExtensionExceptions;return(t=n??e)!==null&&t!==void 0&&t}buildProperties(t,e){return this.ra.buildFromUnknown(t,{syntheticException:e==null?void 0:e.syntheticException,mechanism:{handled:e==null?void 0:e.handled}})}addExceptionStep(t,e){if(this.ia.enabled)try{if(!xt(t)||t.trim().length===0)return void Ni.warn("Ignoring exception step because message must be a non-empty string");var n=(function(i){if(!i)return{sanitizedProperties:{},droppedKeys:[]};var a=[];return{sanitizedProperties:Object.keys(i).reduce(((c,u)=>oN.has(u)?(a.push(u),c):(c[u]=i[u],c)),{}),droppedKeys:a}})(this.aa(e)),r=n.sanitizedProperties,s=n.droppedKeys;s.length>0&&Ni.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.sa.add(ue({[sm]:t,[im]:new Date().toISOString()},r))}catch(i){Ni.error("Failed to add exception step. Ignoring breadcrumb.",i)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.la(e)){if(this.ua(e))return this.ha("Exception dropped: matched a suppression rule"),void Ni.info("Skipping exception capture because a suppression rule matched");if(!this.oa&&this.da(e))return this.ha("Exception dropped: thrown by a browser extension"),void Ni.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ca(e))return this.ha("Exception dropped: thrown by the PostHog SDK"),void Ni.info("Skipping exception capture because it was thrown by the PostHog SDK")}var n=this.ia.enabled&&Je(t.$exception_steps)?this.va(t):t;try{var r=this._instance.capture("$exception",n,{_noTruncate:!0,_batchKey:"exceptionEvent",kn:!0});return r&&this.sa.clear(),r}catch(s){return Ni.error("Failed to capture exception event. Dropping this exception.",s),void this.sa.clear()}}catch(s){return void Ni.error("Failed to process exception event. Ignoring this exception.",s)}}va(t){try{var e=this.sa.getAttachable();return e.length===0?t:ue({},t,{$exception_steps:e})}catch(n){return Ni.error("Failed to read buffered exception steps. Capturing exception without steps.",n),t}}ha(t){this.ia.enabled&&this.sa.add({[sm]:t,[im]:new Date().toISOString()})}aa(t){return Nt(t)?ue({},t):{}}na(){var t,e;return(t=(e=this._instance.config.error_tracking)==null?void 0:e.exception_steps)!==null&&t!==void 0?t:{}}ua(t){if(t.length===0)return!1;var e=t.reduce(((n,r)=>{var s=r.type,i=r.value;return xt(s)&&s.length>0&&n.$exception_types.push(s),xt(i)&&i.length>0&&n.$exception_values.push(i),n}),{$exception_types:[],$exception_values:[]});return this.ta.some((n=>{var r=n.values.map((s=>{var i,a=kP[s.operator],c=Qe(s.value)?s.value:[s.value],u=(i=e[s.key])!==null&&i!==void 0?i:[];return c.length>0&&a(c,u)}));return n.type==="OR"?r.some(Boolean):r.every(Boolean)}))}da(t){return t.flatMap((e=>{var n,r;return(n=(r=e.stacktrace)==null?void 0:r.frames)!==null&&n!==void 0?n:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}ca(t){if(t.length>0){var e,n,r,s,i=(e=(n=t[0].stacktrace)==null?void 0:n.frames)!==null&&e!==void 0?e:[],a=i[i.length-1];return(r=a==null||(s=a.filename)==null?void 0:s.includes("posthog.com/static"))!==null&&r!==void 0&&r}return!1}la(t){return!Je(t)&&Qe(t)}}},CD=ue({productTours:class{get mi(){return this._instance.persistence}constructor(t){this.fa=null,this.pa=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(t.ok){var e=t.config;if("productTours"in e){var n,r;if(this.mi&&this.mi.register({[E2]:!!e.productTours}),!$v(this._instance))return!this.fa&&Je((n=this.mi)==null?void 0:n.props[gd])||Vv.info("product tours disabled; stopping and clearing cached tours"),(r=this.fa)==null||r.stop(),this.fa=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.fa&&$v(this._instance)&&this.er((()=>this.ga()))}er(t){var e,n;(e=$e.__PosthogExtensions__)!=null&&e.generateProductTours?t():(n=$e.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"product-tours",(r=>{r?Vv.error("Could not load product tours script",r):t()}))}ga(){var t;!this.fa&&(t=$e.__PosthogExtensions__)!=null&&t.generateProductTours&&(this.fa=$e.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(e===void 0&&(e=!1),!Qe(this.pa)||e){var n=this.mi;if(n){var r=n.props[gd];if(Qe(r)&&!e)return this.pa=r,void t(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:s=>{if($v(this._instance)){var i=s.statusCode;if(i!==200||!s.json){var a="Product Tours API could not be loaded, status: "+i;return Vv.error(a),void t([],{isLoaded:!1,error:a})}var c=Qe(s.json.product_tours)?s.json.product_tours:[];this.pa=c,n&&n.register({[gd]:c}),t(c,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.pa,{isLoaded:!0})}getActiveProductTours(t){Je(this.fa)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.fa.getActiveProductTours(t)}showProductTour(t){var e;(e=this.fa)==null||e.showTourById(t)}previewTour(t){this.fa?this.fa.previewTour(t):this.er((()=>{var e;this.ga(),(e=this.fa)==null||e.previewTour(t)}))}dismissProductTour(){var t;(t=this.fa)==null||t.dismissTour("user_clicked_skip")}nextStep(){var t;(t=this.fa)==null||t.nextStep()}previousStep(){var t;(t=this.fa)==null||t.previousStep()}clearCache(){var t;this.pa=null,(t=this.mi)==null||t.unregister(gd)}resetTour(t){var e;(e=this.fa)==null||e.resetTour(t)}resetAllTours(){var t;(t=this.fa)==null||t.resetAllTours()}cancelPendingTour(t){var e;(e=this.fa)==null||e.cancelPendingTour(t)}}},n0),kD={siteApps:class{constructor(t){this.ma=0,this._instance=t,this.ya=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}ba(t,e){if(e){var n=this.globalsForEvent(e);this.ya.push(n),this.ya.length>1e3&&(this.ya=this.ya.slice(10))}}get siteAppLoaders(){var t;return(t=$e._POSTHOG_REMOTE_CONFIG)==null||(t=t[this._instance.config.token])==null?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.ba.bind(this));this._a=()=>{t(),this.ya=[],this._a=void 0}}}globalsForEvent(t){var e,n,r,s,i,a,c;if(!t)throw new Error("Event payload is required");var u={},f=this._instance.get_property("$groups")||[],h=this._instance.get_property("$stored_group_properties")||{};for(var p of Object.entries(h)){var m=p[0];u[m]={id:f[m],type:m,properties:p[1]}}var _=t.$set_once,x=t.$set;return{event:ue({},X8(t,gD),{properties:ue({},t.properties,x?{$set:ue({},(e=(n=t.properties)==null?void 0:n.$set)!==null&&e!==void 0?e:{},x)}:{},_?{$set_once:ue({},(r=(s=t.properties)==null?void 0:s.$set_once)!==null&&r!==void 0?r:{},_)}:{}),elements_chain:(i=(a=t.properties)==null?void 0:a.$elements_chain)!==null&&i!==void 0?i:"",distinct_id:(c=t.properties)==null?void 0:c.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:u}}wa(t){var e,n=(e=t.tagName)==null?void 0:e.toLowerCase();return n==="style"&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(ti.error("prepare_external_dependency_stylesheet returned null"),null):n==="script"&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||(ti.error("prepare_external_dependency_script returned null"),null):t}xa(){var t,e,n,r,s,i,a,c;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var u=Se==null?void 0:Se.defaultView,f=u==null||(t=u.Node)==null?void 0:t.prototype;if(!u||!f)return()=>{};if(this.ma++,this.ka)return this.Sa();var h=[],p=this,m=new WeakSet,_=(w,S,T)=>{if(w!=null&&w[S]){var P=w[S];w[S]=T(P),h.push((()=>{w[S]=P}))}},x=w=>{if(m.has(w))return w;var S=p.wa(w);return S&&m.add(S),S},y=w=>w.map((S=>typeof S=="string"?S:x(S))).filter((S=>!dr(S)));return _(f,"appendChild",(w=>function(S){var T=x(S);return T?w.call(this,T):S})),_(f,"insertBefore",(w=>function(S,T){var P=x(S);return P?w.call(this,P,T):S})),_(f,"replaceChild",(w=>function(S,T){var P=x(S);return P?w.call(this,P,T):T})),[(e=u.Element)==null?void 0:e.prototype,(n=u.Document)==null?void 0:n.prototype,(r=u.DocumentFragment)==null?void 0:r.prototype].forEach((w=>{_(w,"append",(S=>function(){for(var T=arguments.length,P=new Array(T),k=0;T>k;k++)P[k]=arguments[k];return S.apply(this,y(P))})),_(w,"prepend",(S=>function(){for(var T=arguments.length,P=new Array(T),k=0;T>k;k++)P[k]=arguments[k];return S.apply(this,y(P))}))})),[(s=u.Element)==null?void 0:s.prototype,(i=u.CharacterData)==null?void 0:i.prototype,(a=u.DocumentType)==null?void 0:a.prototype].forEach((w=>{_(w,"before",(S=>function(){for(var T=arguments.length,P=new Array(T),k=0;T>k;k++)P[k]=arguments[k];return S.apply(this,y(P))})),_(w,"after",(S=>function(){for(var T=arguments.length,P=new Array(T),k=0;T>k;k++)P[k]=arguments[k];return S.apply(this,y(P))})),_(w,"replaceWith",(S=>function(){for(var T=arguments.length,P=new Array(T),k=0;T>k;k++)P[k]=arguments[k];var R=y(P);return P.length&&!R.length?void 0:S.apply(this,R)}))})),_((c=u.Element)==null?void 0:c.prototype,"insertAdjacentElement",(w=>function(S,T){var P=x(T);return P?w.call(this,S,P):null})),this.ka=()=>{h.forEach((w=>w())),this.ka=void 0},this.Sa()}Sa(){var t=!1;return()=>{var e;t||(t=!0,this.ma--,this.ma===0&&((e=this.ka)==null||e.call(this)))}}Ca(t,e){e===void 0&&(e=!0);var n=this.xa();try{var r=t(n);return e&&n(),r}catch(s){throw n(),s}}setupSiteApp(t){var e=this.apps[t.id],n=()=>{var a;!e.errored&&this.ya.length&&(ti.info("Processing "+this.ya.length+" events for site app with id "+t.id),this.ya.forEach((c=>this.Ca((()=>e.processEvent==null?void 0:e.processEvent(c))))),e.processedBuffer=!0),Object.values(this.apps).every((c=>c.processedBuffer||c.errored))&&((a=this._a)==null||a.call(this))},r=!1,s=a=>{e.errored=!a,e.loaded=!0,ti.info("Site app with id "+t.id+" "+(a?"loaded":"errored")),r&&n()};try{var i=this.Ca((a=>t.init({posthog:this._instance,callback(c){a(),s(c)}})),!1).processEvent;i&&(e.processEvent=i),r=!0}catch(a){ti.error(oC+t.id,a),s(!1)}if(r&&e.loaded)try{n()}catch(a){ti.error("Error while processing buffered events PostHog app with config id "+t.id,a),e.errored=!0}}Ma(){var t=this.siteAppLoaders||[];for(var e of t)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var n of t)this.setupSiteApp(n)}Ia(t){var e=this;if(Object.keys(this.apps).length!==0){var n=this.globalsForEvent(t),r=function(i){try{e.Ca((()=>i.processEvent==null?void 0:i.processEvent(n)))}catch(a){ti.error("Error while processing event "+t.event+" for site app "+i.id,a)}};for(var s of Object.values(this.apps))r(s)}}onRemoteConfig(t){var e,n,r,s=this;if((e=this.siteAppLoaders)!=null&&e.length)return this.isEnabled?(this.Ma(),void this._instance.on("eventCaptured",(u=>this.Ia(u)))):void ti.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((n=this._a)==null||n.call(this),t.ok){var i=t.config;if((r=i.siteApps)!=null&&r.length)if(this.isEnabled){var a=function(){var u,f=c.id,h=c.url;$e["__$$ph_site_app_"+f]=s._instance,(u=$e.__PosthogExtensions__)==null||u.loadSiteApp==null||u.loadSiteApp(s._instance,h,(p=>{if(p)return ti.error(oC+f,p)}))};for(var c of i.siteApps)a()}else ti.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},PD={tracingHeaders:class{constructor(t){this.Ta=void 0,this.Ea=void 0,this.Ra=void 0,this.Wo=()=>{var e,n,r=this.Pa();r?(ge(this.Ta)&&(this.Ta=(e=$e.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null?void 0:e._patchXHR(r,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),ge(this.Ea)&&(this.Ea=(n=$e.__PosthogExtensions__)==null||(n=n.tracingHeadersPatchFns)==null?void 0:n._patchFetch(r,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.Ko()},this._instance=t}initialize(){this.startIfEnabledOrStop()}er(t){var e,n;(e=$e.__PosthogExtensions__)!=null&&e.tracingHeadersPatchFns?t():(n=$e.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"tracing-headers",(r=>{if(r)return pD.error("failed to load script",r);t()}))}Oa(){var t,e;return(t=(e=this._instance.config.tracing_headers)!==null&&e!==void 0?e:this._instance.config.addTracingHeaders)!==null&&t!==void 0?t:this._instance.config.__add_tracing_headers}Pa(){var t=this.Oa();return Qe(t)?(Qe(this.Ra)?this.Ra.splice(0,this.Ra.length,...t):this.Ra=[...t],t.length>0?this.Ra:void 0):(Qe(this.Ra)&&this.Ra.splice(0),this.Ra=t||void 0,this.Ra)}Ko(){var t,e;(t=this.Ta)==null||t.call(this),(e=this.Ea)==null||e.call(this),this.Ta=void 0,this.Ea=void 0}startIfEnabledOrStop(){this.Pa()?this.er(this.Wo):this.Ko()}}},TD=ue({surveys:class{get Te(){return this._instance.config}constructor(t){this.Fa=void 0,this._surveyManager=null,this.Aa=!1,this.La=[],this.$a=null,this.Na=null,this._instance=t,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this.Te.disable_surveys){if(!t.ok)return yt.warn("Remote config unavailable. Not loading surveys.");var e=t.config.surveys;if(Je(e))return yt.warn("Flags not loaded yet. Not loading surveys.");var n=Qe(e);this.Fa=n?e.length>0:e,yt.info("flags response received, isSurveysEnabled: "+this.Fa),this.loadIfEnabled()}}reset(){try{var t;(t=this._surveyEventReceiver)==null||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var e=[],n=0;n<localStorage.length;n++){var r=localStorage.key(n);(r!=null&&r.startsWith(RP)||r!=null&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach((s=>localStorage.removeItem(s)))}catch{}}loadIfEnabled(){if(!this._surveyManager)if(this.Aa)yt.info("Already initializing surveys, skipping...");else if(this.Te.disable_surveys)yt.info(aC);else if(this.Te.cookieless_mode&&this._instance.consent.isOptedOut())yt.info("Not loading surveys in cookieless mode without consent.");else{var t=$e==null?void 0:$e.__PosthogExtensions__;if(t){if(!ge(this.Fa)||this.Te.advanced_enable_surveys){var e=this.Fa||this.Te.advanced_enable_surveys;this.Aa=!0;try{var n=t.generateSurveys;if(n)return void this.Da(n,e);var r=t.loadExternalDependency;if(!r)return void this.qa(k2);r(this._instance,"surveys",(s=>{s||!t.generateSurveys?this.qa("Could not load surveys script",s):this.Da(t.generateSurveys,e)}))}catch(s){throw this.qa("Error initializing surveys",s),s}finally{this.Aa=!1}}}else yt.error("PostHog Extensions not found.")}}Da(t,e){this._surveyManager=t(this._instance,e),this._surveyEventReceiver=new _D(this._instance),yt.info("Surveys loaded successfully"),this.ja({isLoaded:!0})}qa(t,e){yt.error(t,e),this.ja({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.La.push(t),this._surveyManager&&this.ja({isLoaded:!0}),()=>{this.La=this.La.filter((e=>e!==t))}}getSurveys(t,e){if(e===void 0&&(e=!1),this.Te.disable_surveys)return yt.info(aC),t([]);var n,r=this._instance.get_property(Sy);if(r&&!e)return t(r,{isLoaded:!0}),void(this.Ha()&&this.getSurveys((()=>{}),!0));typeof Promise<"u"&&this.$a?this.$a.then((s=>t(s.surveys,s.context))):(typeof Promise<"u"&&(this.$a=new Promise((s=>{n=s}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.Te.token),method:"GET",timestampMode:"query",timeout:this.Te.surveys_request_timeout_ms,callback:s=>{var i;this.$a=null;var a=s.statusCode;if(a!==200||!s.json){var c="Surveys API could not be loaded, status: "+a;yt.error(c),this.Na=Date.now();var u={isLoaded:!1,error:c};return t([],u),void(n==null||n({surveys:[],context:u}))}this.Na=null;var f,h=s.json.surveys||[],p=h.filter((_=>(function(x){return!(!x.start_date||x.end_date)})(_)&&(TP(_)||(function(x){var y;return!((y=x.conditions)==null||(y=y.actions)==null||(y=y.values)==null||!y.length)})(_))));p.length>0&&((f=this._surveyEventReceiver)==null||f.register(p)),(i=this._instance.persistence)==null||i.register({[Sy]:h,[cm]:Date.now()});var m={isLoaded:!0};t(h,m),n==null||n({surveys:h,context:m})}}))}Ha(){return this.Ba()&&!this.$a&&!this.Ua()}Ba(){var t=this._instance.get_property(cm);return $n(t)&&Date.now()-t>3e5}Ua(){return $n(this.Na)&&3e5>Date.now()-this.Na}markSurveyAsSeen(t,e){var n,r={id:t,current_iteration:(n=e==null?void 0:e.iteration)!==null&&n!==void 0?n:null};AP(r);try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}}ja(t){for(var e of this.La)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(n){yt.error("Error in survey callback",n)}}getActiveMatchingSurveys(t,e){if(e===void 0&&(e=!1),!Je(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);yt.warn("init was not called")}za(t){var e=null;return this.getSurveys((n=>{var r;e=(r=n.find((s=>s.id===t)))!==null&&r!==void 0?r:null})),e}Va(t){if(Je(this._surveyManager))return{eligible:!1,reason:Qh};var e=typeof t=="string"?this.za(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}Wa(t){if(Je(this._surveyManager))return{eligible:!1,reason:Qh};var e=typeof t=="string"?this.za(t):t;return e?this._surveyManager.checkSurveyRenderability(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(Je(this._surveyManager))return yt.warn("init was not called"),{visible:!1,disabledReason:Qh};var e=this.Wa(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return Je(this._surveyManager)?(yt.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Qh})):new Promise((n=>{this.getSurveys((r=>{var s,i=(s=r.find((c=>c.id===t)))!==null&&s!==void 0?s:null;if(i){var a=this.Wa(i);n({visible:a.eligible,disabledReason:a.reason})}else n({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(t,e,n){var r;if(Je(this._surveyManager))yt.warn("init was not called");else{var s=typeof t=="string"?this.za(t):t;if(s!=null&&s.id)if(sD.includes(s.type)){var i=Se==null?void 0:Se.querySelector(e);if(i)return(r=s.appearance)!=null&&r.surveyPopupDelaySeconds?(yt.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var a,c;yt.info("Rendering survey "+s.id+" with delay of "+((a=s.appearance)==null?void 0:a.surveyPopupDelaySeconds)+" seconds"),(c=this._surveyManager)==null||c.renderSurvey(s,i,n),yt.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,i,n);yt.warn("Survey element not found")}else yt.warn("Surveys of type "+s.type+" cannot be rendered in the app");else yt.warn("Survey not found")}}displaySurvey(t,e){var n;if(Je(this._surveyManager))yt.warn("init was not called");else{var r=this.za(t);if(r){var s=r;if((n=r.appearance)!=null&&n.surveyPopupDelaySeconds&&e.ignoreDelay&&(s=ue({},r,{appearance:ue({},r.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==Ly.Popover&&e.initialResponses&&yt.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),e.ignoreConditions===!1){var i=this.Va(r);if(!i.eligible)return void yt.warn("Survey is not eligible to be displayed: ",i.reason)}e.displayType!==Ly.Inline?this._surveyManager.handlePopoverSurvey(s,e):this.renderSurvey(s,e.selector,e.properties)}else yt.warn("Survey not found")}}cancelPendingSurvey(t){Je(this._surveyManager)?yt.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;(t=this._surveyManager)==null||t.handlePageUnload==null||t.handlePageUnload()}}},n0),RD={toolbar:class{constructor(t){this.instance=t}Za(t){$e.ph_toolbar_state=t}Ga(){var t;return(t=$e.ph_toolbar_state)!==null&&t!==void 0?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,e,n){if(t===void 0&&(t=void 0),e===void 0&&(e=void 0),n===void 0&&(n=void 0),$6(this.instance.config)||!te||!Se)return!1;t=t??te.location,n=n??te.history;try{if(!e){try{te.localStorage.setItem("test","test"),te.localStorage.removeItem("test")}catch{return!1}e=te==null?void 0:te.localStorage}var r,s=xD||vm(t.hash,"__posthog")||vm(t.hash,"state"),i=s?RE((()=>JSON.parse(atob(decodeURIComponent(s)))))||RE((()=>JSON.parse(decodeURIComponent(s)))):null;return i&&i.action==="ph_authorize"?((r=i).source="url",r&&Object.keys(r).length>0&&(i.desiredHash?t.hash=i.desiredHash:n?n.replaceState(n.state,"",t.pathname+t.search):t.hash="")):((r=JSON.parse(e.getItem(lC)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch{return!1}}Qa(t){var e=$e.ph_load_toolbar||$e.ph_load_editor;!Je(e)&&zs(e)?e(t,this.instance):cC.warn("No toolbar load function found")}loadToolbar(t){var e=!(Se==null||!Se.getElementById(B6));if(!te||e)return!1;var n=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,r=ue({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},n?{instrument:!1}:{});if(te.localStorage.setItem(lC,JSON.stringify(ue({},r,{source:void 0}))),this.Ga()===2)this.Qa(r);else if(this.Ga()===0){var s;this.Za(1),(s=$e.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this.instance,"toolbar",(i=>{if(i)return cC.error("[Toolbar] Failed to load",i),void this.Za(0);this.Za(2),this.Qa(r)})),zt(te,"turbolinks:load",(()=>{this.Za(0),this.loadToolbar(r)}))}return!0}Ja(t){return this.loadToolbar(t)}maybeLoadEditor(t,e,n){return t===void 0&&(t=void 0),e===void 0&&(e=void 0),n===void 0&&(n=void 0),this.maybeLoadToolbar(t,e,n)}}},AD=ue({experiments:Yn},n0),ID={conversations:class{constructor(t){this.Ka=void 0,this._conversationsManager=null,this.Ya=!1,this.Xa=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations&&t.ok){var e=t.config.conversations;Je(e)||(Us(e)?this.Ka=e:(this.Ka=e.enabled,this.Xa=e),this.loadIfEnabled())}}reset(){var t;(t=this._conversationsManager)==null||t.reset(),this._conversationsManager=null,this.Ka=void 0,this.Xa=null}loadIfEnabled(){if(!(this._conversationsManager||this.Ya||this._instance.config.disable_conversations||$6(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=$e==null?void 0:$e.__PosthogExtensions__;if(t&&!ge(this.Ka)&&this.Ka)if(this.Xa&&this.Xa.token){this.Ya=!0;try{var e=t.initConversations;if(e)return this.el(e),void(this.Ya=!1);var n=t.loadExternalDependency;if(!n)return void this.tl(k2);n(this._instance,"conversations",(r=>{r||!t.initConversations?this.tl("Could not load conversations script",r):this.el(t.initConversations),this.Ya=!1}))}catch(r){this.tl("Error initializing conversations",r),this.Ya=!1}}else ps.error("Conversations enabled but missing token in remote config.")}}el(t){if(this.Xa)try{this._conversationsManager=t(this.Xa,this._instance),ps.info("Conversations loaded successfully")}catch(e){this.tl("Error completing conversations initialization",e)}else ps.error("Cannot complete initialization: remote config is null")}tl(t,e){ps.error(t,e),this._conversationsManager=null,this.Ya=!1}show(){this._conversationsManager?this._conversationsManager.show():ps.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Ka===!0&&!dr(this._conversationsManager)}isVisible(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.isVisible())!==null&&t!==void 0&&t}sendMessage(t,e,n){var r=this;return en((function*(){return r._conversationsManager?r._conversationsManager.sendMessage(t,e,n):(ps.warn(Ha),null)}))()}getMessages(t,e){var n=this;return en((function*(){return n._conversationsManager?n._conversationsManager.getMessages(t,e):(ps.warn(Ha),null)}))()}markAsRead(t){var e=this;return en((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(ps.warn(Ha),null)}))()}getTickets(t){var e=this;return en((function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(ps.warn(Ha),null)}))()}requestRestoreLink(t){var e=this;return en((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(ps.warn(Ha),null)}))()}restoreFromToken(t){var e=this;return en((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(ps.warn(Ha),null)}))()}restoreFromUrlToken(){var t=this;return en((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(ps.warn(Ha),null)}))()}getCurrentTicketId(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.getCurrentTicketId())!==null&&t!==void 0?t:null}getWidgetSessionId(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.getWidgetSessionId())!==null&&t!==void 0?t:null}En(){var t;(t=this._conversationsManager)==null||t.setIdentity()}Rn(){var t;(t=this._conversationsManager)==null||t.clearIdentity()}}},MD={logs:class{constructor(t){var e;this.rl=!1,this.il=!1,this.Ge=Vt("[logs]"),this.Gr=[],this.nl=[],this.Hs=0,this.sl=()=>{var n,r;this.Hs=0,(n=this.ol)==null||n.onReconnect(),(r=this.al)==null||r.onReconnect()},this._instance=t,this._instance&&(e=this._instance.config.logs)!=null&&e.captureConsoleLogs&&(this.rl=!0),te&&zt(te,"online",this.sl)}ll(t,e,n,r){var s,i=(function(a,c){var u,f,h,p,m,_,x,y=(u=a==null?void 0:a.flushIntervalMs)!==null&&u!==void 0?u:3e3,w=(f=a==null?void 0:a.maxBufferSize)!==null&&f!==void 0?f:100,S=c!=null&&c.consoleCapture?void 0:(h=a==null?void 0:a.maxLogsPerInterval)!==null&&h!==void 0?h:1e3,T=ge(S)?Math.max(w,2048):Math.max(w,S),P=a==null?void 0:a.resourceAttributes;return{serviceName:(p=(m=P==null?void 0:P["service.name"])!==null&&m!==void 0?m:a==null?void 0:a.serviceName)!==null&&p!==void 0?p:c==null?void 0:c.serviceNameDefault,serviceVersion:(_=P==null?void 0:P["service.version"])!==null&&_!==void 0?_:a==null?void 0:a.serviceVersion,environment:(x=P==null?void 0:P["deployment.environment"])!==null&&x!==void 0?x:a==null?void 0:a.environment,resourceAttributes:P,beforeSend:a==null?void 0:a.beforeSend,flushIntervalMs:y,maxBufferSize:w,maxQueueSize:T,maxBatchRecordsPerPost:100,rateCapWindowMs:y,maxLogsPerInterval:S,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}})((s=this._instance)==null||(s=s.config)==null?void 0:s.logs,n);return[new VL(this.ul(t,e),i,this.Ge,(()=>this.hl()),(a=>a()),void 0,r),i]}dl(){var t,e=(t=this._instance)==null||(t=t.config)==null?void 0:t.logs;if(!this.ol||this.cl!==e){var n;(n=this.ol)==null||n.reset(),this.cl=e;var r=this.ll((()=>this.Gr),(s=>{this.Gr=s}));this.ol=r[0],this.vl=r[1]}return this.ol}fl(){var t,e=(t=this._instance)==null||(t=t.config)==null?void 0:t.logs;if(!this.al||this.pl!==e){var n;(n=this.al)==null||n.reset(),this.pl=e;var r=this.ll((()=>this.nl),(s=>{this.nl=s}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},hC);this.al=r[0],this.gl=r[1]}return this.al}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var e;if(t.ok){var n=(e=t.config.logs)==null?void 0:e.captureConsoleLogs;!Je(n)&&n&&(this.rl=!0,this.loadIfEnabled())}}reset(){var t,e;this.Gr=[],(t=this.ol)==null||t.reset(),this.nl=[],(e=this.al)==null||e.reset(),this.Hs=0}captureLog(t){this.dl().captureLog(t)}le(t){this.fl().captureLog(t)}get logger(){return this.ml||(this.ml={trace:(t,e)=>this.captureLog({body:t,level:"trace",attributes:e}),debug:(t,e)=>this.captureLog({body:t,level:"debug",attributes:e}),info:(t,e)=>this.captureLog({body:t,level:"info",attributes:e}),warn:(t,e)=>this.captureLog({body:t,level:"warn",attributes:e}),error:(t,e)=>this.captureLog({body:t,level:"error",attributes:e}),fatal:(t,e)=>this.captureLog({body:t,level:"fatal",attributes:e})}),this.ml}flushLogs(t){t?this.yl(t):(this.ol&&this.ol.flush().catch((e=>this.Ge.error("PostHog logs flush failed:",e))),this.al&&this.al.flush().catch((e=>this.Ge.error("PostHog logs flush failed:",e))))}loadIfEnabled(){if(this.rl&&!this.il){var t=$e==null?void 0:$e.__PosthogExtensions__;if(t){var e=t.loadExternalDependency;e?e(this._instance,"logs",(n=>{var r;n||(r=t.logs)==null||!r.initializeLogs?this.Ge.error("Could not load logs script",n):(t.logs.initializeLogs(this._instance),this.il=!0)})):this.Ge.error(k2)}else this.Ge.error("PostHog Extensions not found.")}}ul(t,e){var n=this._instance;return{get isDisabled(){return!1},get optedOut(){return!n.is_capturing()},getPersistedProperty:r=>r===Bi.LogsQueue?t():void 0,setPersistedProperty(r,s){var i;r===Bi.LogsQueue&&e((i=s)!==null&&i!==void 0?i:[])},Mt:r=>this.Mt(r),getLibraryId:()=>gt.LIB_NAME,getLibraryVersion:()=>gt.LIB_VERSION}}Mt(t){return new Promise((e=>{if(sP(this.Hs,3))e({kind:"fatal",error:new Error("logs endpoint is unreachable, dropping batch")});else{var n=!1,r=i=>{n||(n=!0,clearTimeout(s),e(i))},s=setTimeout((()=>r({kind:"retry-later",error:new Error("logs request timed out")})),9e4);this._instance._send_request({method:"POST",url:this.bl(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:i=>{var a=i.statusCode;if(this._l(a),a>=200&&300>a)r({kind:"ok"});else if(a===413)r({kind:"too-large"});else if(a!==0&&a!==429&&500>a)r({kind:"fatal",error:new Error("logs request failed with status "+a)});else{var c;r({kind:"retry-later",error:(c=i.error)!==null&&c!==void 0?c:new Error("logs request failed with status "+a)})}}})}}))}_l(t){(t!==0||this._instance.__loaded)&&(this.Hs=iP(t,this.Hs,3,(()=>this.Ge.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."))))}yl(t){this.Gr.length>0&&this.wl(t,this.Gr,this.vl,gt.LIB_NAME,(e=>{this.Gr=e})),this.nl.length>0&&this.wl(t,this.nl,this.gl,hC,(e=>{this.nl=e}))}wl(t,e,n,r,s){if(e.length!==0){var i=e.map((c=>c.record));s([]);var a=k6(i,C6(n,gt.LIB_NAME,gt.LIB_VERSION),r,gt.LIB_VERSION);this._instance._send_request({method:"POST",url:this.bl(),data:a,compression:"best-available",batchKey:"logs",transport:t})}}bl(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}hl(){var t,e={};if(e.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var n=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),r=n.windowId,s=n.sessionStartTimestamp,i=n.lastActivityTimestamp;e.sessionId=n.sessionId,e.windowId=r,Je(s)||(e.sessionStartTimestamp=s),Je(i)||(e.lastActivityTimestamp=i)}if($e!=null&&(t=$e.location)!=null&&t.href&&(e.currentUrl=this._instance.config.disable_capture_url_hashes?sa($e.location.href):$e.location.href),this._instance.featureFlags){var a=this._instance.featureFlags.getFlags();a&&a.length>0&&(e.activeFeatureFlags=a)}return e}}},OD={metrics:class{constructor(t){this.Ge=Vt("[metrics]"),this._instance=t}initialize(){}dl(){var t,e,n=(t=this._instance)==null||(t=t.config)==null?void 0:t.metrics;return this.ol&&this.cl===n||((e=this.ol)==null||e.reset(),this.cl=n,this.ol=new $L(this.ul(),(function(r){var s,i,a,c,u,f=r==null?void 0:r.resourceAttributes;return{serviceName:(s=f==null?void 0:f["service.name"])!==null&&s!==void 0?s:r==null?void 0:r.serviceName,serviceVersion:(i=f==null?void 0:f["service.version"])!==null&&i!==void 0?i:r==null?void 0:r.serviceVersion,environment:(a=f==null?void 0:f["deployment.environment"])!==null&&a!==void 0?a:r==null?void 0:r.environment,resourceAttributes:f,beforeSend:r==null?void 0:r.beforeSend,flushIntervalMs:(c=r==null?void 0:r.flushIntervalMs)!==null&&c!==void 0?c:1e4,maxSeriesPerFlush:(u=r==null?void 0:r.maxSeriesPerFlush)!==null&&u!==void 0?u:1e3}})(n),this.Ge)),this.ol}count(t,e,n){e===void 0&&(e=1),this.dl().count(t,e,n)}gauge(t,e,n){this.dl().gauge(t,e,n)}histogram(t,e,n){this.dl().histogram(t,e,n)}flush(t){if(!this.ol)return Promise.resolve();if(t){var e=this.ol.drainWindow();return e&&this.Bt(e,t),Promise.resolve()}return this.ol.flush().catch((n=>this.Ge.error("PostHog metrics flush failed:",n)))}reset(){var t;(t=this.ol)==null||t.reset()}ul(){var t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Bt:n=>e.Bt(n),getLibraryId:()=>gt.LIB_NAME,getLibraryVersion:()=>gt.LIB_VERSION}}Bt(t,e){return new Promise((n=>{var r=!1,s=a=>{r||(r=!0,clearTimeout(i),n(a))},i=setTimeout((()=>s({kind:"retry-later",error:new Error("metrics request timed out")})),9e4);this._instance._send_request(ue({method:"POST",url:this.xl(),data:t,compression:"best-available",batchKey:"metrics"},e&&{transport:e},{fireCallbackOnDrop:!0,callback(a){var c=a.statusCode;if(c>=200&&300>c)s({kind:"ok"});else if(c===413)s({kind:"too-large"});else if(c!==0&&c!==429&&500>c)s({kind:"fatal",error:new Error("metrics request failed with status "+c)});else{var u;s({kind:"retry-later",error:(u=a.error)!==null&&u!==void 0?u:new Error("metrics request failed with status "+c)})}}}))}))}xl(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},LD=ue({},n0,bD,SD,ED,CD,kD,TD,PD,RD,AD,ID,MD,OD);vs.__defaultExtensionClasses=ue({},LD);var be=(function(){gt.SDK_DIST_CHANNEL="npm";var t=Cd[gc]=new vs;return(function(){function e(){e.done||(e.done=!0,MP=!1,wt(Cd,(function(n){n._dom_loaded()})))}Se!=null&&Se.addEventListener?Se.readyState==="complete"?e():zt(Se,"DOMContentLoaded",e,{capture:!1}):te&&_e.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),t})(),OP;function ND(t){OP=t}function zy(){return OP}var N2=v.createContext({get client(){return zy()},bootstrap:void 0});function LP(t,e,n){if(n===void 0&&(n=new WeakMap),t===e)return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(n.has(t)&&n.get(t)===e)return!0;n.set(t,e);var r=Object.keys(t),s=Object.keys(e);if(r.length!==s.length)return!1;for(var i=0,a=r;i<a.length;i++){var c=a[i];if(!s.includes(c)||!LP(t[c],e[c],n))return!1}return!0}function DD(t){var e,n,r=t.children,s=t.client,i=t.apiKey,a=t.options,c=v.useRef(null),u=v.useMemo(function(){if(s)return i&&console.warn("[PostHog.js] You have provided both `client` and `apiKey` to `PostHogProvider`. `apiKey` will be ignored in favour of `client`."),a&&console.warn("[PostHog.js] You have provided both `client` and `options` to `PostHogProvider`. `options` will be ignored in favour of `client`."),s;var f=zy();return i||console.warn("[PostHog.js] No `apiKey` or `client` were provided to `PostHogProvider`. Using default global `window.posthog` instance. You must initialize it manually. This is not recommended behavior."),f},[s,i,JSON.stringify(a)]);return v.useEffect(function(){if(!(s||!i)){var f=zy(),h=c.current;h?(i!==h.apiKey&&console.warn("[PostHog.js] You have provided a different `apiKey` to `PostHogProvider` than the one that was already initialized. This is not supported by our provider and we'll keep using the previous key. If you need to toggle between API Keys you need to control the `client` yourself and pass it in as a prop rather than an `apiKey` prop."),a&&!LP(a,h.options)&&f.set_config(a),c.current={apiKey:i,options:a??{}}):(f.__loaded&&console.warn("[PostHog.js] `posthog` was already loaded elsewhere. This may cause issues."),f.init(i,a),c.current={apiKey:i,options:a??{}})}},[s,i,JSON.stringify(a)]),ve.createElement(N2.Provider,{value:{client:u,bootstrap:(e=a==null?void 0:a.bootstrap)!==null&&e!==void 0?e:(n=s==null?void 0:s.config)===null||n===void 0?void 0:n.bootstrap}},r)}var zv=function(t){return typeof t=="function"},r0=function(){var t=v.useContext(N2).client;return t},Uy=function(t,e){return Uy=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},Uy(t,e)};function jD(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Uy(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var FD={componentStack:null,exceptionEvent:null,error:null},VD={INVALID_FALLBACK:"[PostHog.js][PostHogErrorBoundary] Invalid fallback prop, provide a valid React element or a function that returns a valid React element."},$D=(function(t){jD(e,t);function e(n){var r=t.call(this,n)||this;return r.state=FD,r}return e.prototype.componentDidCatch=function(n,r){var s=this.props.additionalProperties,i;zv(s)?i=s(n):typeof s=="object"&&(i=s);var a=this.context.client,c=a.captureException(n,i),u=r.componentStack;this.setState({error:n,componentStack:u??null,exceptionEvent:c})},e.prototype.render=function(){var n=this.props,r=n.children,s=n.fallback,i=this.state;if(i.componentStack==null)return zv(r)?r():r;var a=zv(s)?ve.createElement(s,{error:i.error,componentStack:i.componentStack,exceptionEvent:i.exceptionEvent}):s;return ve.isValidElement(a)?a:(console.warn(VD.INVALID_FALLBACK),ve.createElement(ve.Fragment,null))},e.contextType=N2,e})(ve.Component);ND(be);var Jh={},Uv={exports:{}},wr={},Bv={exports:{}},Wv={};/**
19
19
  * @license React
20
20
  * scheduler.production.min.js
@@ -111,7 +111,7 @@ function useAtomValueWithDelay<Value>(
111
111
  `);if(!t.reference)return e;const n=((a=t.projectPath)==null?void 0:a.trim())??"",r=n?` --project '${n.replace(/'/g,"'\\''")}'`:"",s=[`Rivet variant: ${t.reference}`,"To inspect the full variant context, run:",`rivet variants get ${t.reference}${r}`].join(`
112
112
  `);return e?`${e}
113
113
 
114
- ${s}`:s},LG=({rows:t,activeVariantId:e,activePastKey:n,isOriginalSelected:r,busy:s,editingKey:i,onSelectActive:a,onSelectPast:c,onSelectOriginal:u,onActivePointerDown:f,onPastPointerDown:h,onHover:p,onRemove:m,onRemovePast:_,onStartRename:x,onCommitRename:y,onCancelRename:w,onCopyVariantContext:S,activeSessionId:T,projectPath:P})=>{const k=v.useRef(null),{activeIndex:R,itemRects:L,sessionRef:O,handlers:A,registerItem:I}=q5(k),N=(s==null?void 0:s.kind)==="switch",j=R!==null?L[R]:null;return E.jsxs("div",{ref:k,className:"relative",onMouseEnter:A.onMouseEnter,onMouseMove:A.onMouseMove,onMouseLeave:A.onMouseLeave,children:[E.jsx(ro,{children:j&&E.jsx(xl.div,{className:"bg-hover pointer-events-none absolute z-0 rounded-md",initial:{opacity:0,top:j.top,left:j.left,width:j.width,height:j.height},animate:{opacity:1,top:j.top,left:j.left,width:j.width,height:j.height},exit:{opacity:0,transition:{duration:.06}},transition:{...Yd.fast,opacity:{duration:.08}}},O.current)}),E.jsx("ul",{className:"relative",children:t.map((F,K)=>{const X=RG(F);let W=!1;return F.kind==="active"?W=F.variant.workItemId===e:F.kind==="past"?W=`${F.entry.sessionId}:${F.entry.variantId}`===n:W=r,E.jsx(NG,{rowKey:X,row:F,index:K,isSelected:W,isEditing:i===X,isSwitchInFlight:N,busy:s,registerItem:I,onSelectActive:a,onSelectPast:c,onSelectOriginal:u,onActivePointerDown:f,onPastPointerDown:h,onHover:p,onRemove:m,onRemovePast:_,onStartRename:x,onCommitRename:y,onCancelRename:w,onCopyVariantContext:S,activeSessionId:T,projectPath:P},X)})})]})},NG=({rowKey:t,row:e,index:n,isSelected:r,isEditing:s,isSwitchInFlight:i,busy:a,registerItem:c,onSelectActive:u,onSelectPast:f,onSelectOriginal:h,onActivePointerDown:p,onPastPointerDown:m,onHover:_,onRemove:x,onRemovePast:y,onStartRename:w,onCommitRename:S,onCancelRename:T,onCopyVariantContext:P,activeSessionId:k,projectPath:R})=>{var xe,ae;const L=v.useRef(null);UU(c,n,L);const O=e.kind==="active",A=e.kind==="original",I=e.kind==="active"?e.variant:null,N=e.kind==="past"?e.entry:null,j=O?I.status==="succeeded":!0,F=O?nl(I):!0,K=O?eA(I):!1,X=O&&(I.status==="pending"||I.status==="running"),W=O?j&&(F||K)||X:!0,G=O&&I.status==="failed",q=O&&I.status==="cancelled",$=O&&(!W||i),ne=O&&(a==null?void 0:a.kind)==="remove"&&a.variantId===I.workItemId,H=O&&(((xe=I.refinement)==null?void 0:xe.status)==="pending"||((ae=I.refinement)==null?void 0:ae.status)==="running");let D=Gx;O?D=I.label||`Direction ${n+1}`:N&&(D=N.label.trim()||"Untitled direction");let Y;O?Y=I.runLabel:N&&(Y=N.runLabel);let ee=Kx;O?ee=I.description:N&&(ee=N.brief);const ie=ee?IG(ee):null,oe=MG(e,k),ce=oe?"Copy variant reference":"Copy description";return s?E.jsx("li",{ref:L,"data-proximity-index":n,className:"group relative z-10",children:E.jsx("div",{className:"bg-main-input flex w-full items-start gap-2 rounded-md px-3 py-2",children:E.jsxs("span",{className:"min-w-0 flex-1",children:[E.jsx(DG,{initial:D,onCommit:se=>S(e,se),onCancel:T}),ie&&E.jsx("span",{className:"text-content-muted mt-1 line-clamp-2 block text-xs leading-snug",children:ie})]})})}):E.jsxs("li",{ref:L,"data-proximity-index":n,className:"group relative z-10",children:[E.jsx("div",{role:"button",tabIndex:W?0:-1,"data-variant-id":O?I.workItemId:void 0,"data-variant-key":t,onClick:()=>{if($)return;const se=window.getSelection();se&&!se.isCollapsed||(e.kind==="active"?u(e.variant):e.kind==="past"?f(e.entry):h())},onKeyDown:se=>{$||(se.key==="Enter"||se.key===" ")&&(se.preventDefault(),se.stopPropagation(),e.kind==="active"?u(e.variant):e.kind==="past"?f(e.entry):h())},onPointerDown:se=>{$||(e.kind==="active"?j&&p(e.variant.workItemId,se):e.kind==="past"&&m(e.entry,se))},"aria-pressed":W?r:void 0,"aria-disabled":O?!W:void 0,"aria-busy":X||H,onMouseEnter:O?()=>_(I.workItemId):void 0,onMouseLeave:O?()=>_(null):void 0,className:fr("focus-visible:ring-content-muted/40 flex w-full items-start gap-2 rounded-md px-3 py-2 text-left transition-colors focus:outline-none focus-visible:ring-1",r&&"bg-main-input ring-content-muted/40 ring-1 ring-inset",j&&F&&"cursor-grab active:cursor-grabbing",(X||K)&&"cursor-pointer",!j&&!X&&!K&&"cursor-not-allowed opacity-60",$&&"cursor-not-allowed opacity-50"),style:j?{touchAction:"none"}:void 0,children:E.jsxs("span",{className:"min-w-0 flex-1",children:[E.jsxs("span",{className:"flex items-center gap-2",children:[(X||H)&&E.jsx(Ix,{className:"text-content-muted shrink-0 text-sm","data-testid":H&&!X?"variant-refining":void 0}),E.jsx(to,{label:"Double-click to rename",disabled:A,children:E.jsx("span",{onDoubleClick:se=>{se.stopPropagation(),A||w(t)},className:fr("min-w-0 flex-1 truncate text-sm font-medium select-text",A?"cursor-default":"cursor-text",j||r?"text-content":"text-content-muted"),children:D})}),G&&E.jsx(to,{label:I.errorMessage??I.errorCode??"Failed",disabled:!I.errorMessage&&!I.errorCode,children:E.jsx("span",{className:"shrink-0",children:E.jsx(Pk,{label:"Failed"})})}),q&&E.jsx(Pk,{label:"Cancelled"}),Y&&E.jsx("span",{className:"ml-auto max-w-[8rem] shrink-0 truncate rounded px-1.5 py-0.5 text-[10px] font-medium opacity-100 transition-opacity duration-150 group-hover:opacity-0 group-has-[:focus-visible]:opacity-0",style:Z5(Y),children:Y})]}),ie&&E.jsx("span",{className:"text-content-muted mt-0.5 line-clamp-2 block cursor-text text-xs leading-snug select-text",children:ie})]})}),E.jsxs("div",{className:fr("absolute top-1.5 right-2 flex items-center gap-0.5 transition-opacity duration-150","pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 has-[:focus-visible]:pointer-events-auto has-[:focus-visible]:opacity-100"),children:[ee||oe?E.jsx(to,{label:ce,children:E.jsx("button",{type:"button","aria-label":ce,onClick:se=>{se.stopPropagation(),P(OG({label:D,description:ee,reference:oe,projectPath:R}))},onPointerDown:se=>se.stopPropagation(),className:"text-content-muted hover:bg-main-hover hover:text-content focus-visible:ring-content-muted/40 flex h-6 w-6 items-center justify-center rounded focus:outline-none focus-visible:ring-1",children:E.jsx(qd,{size:13,weight:"bold"})})}):null,!A&&E.jsx(to,{label:"Rename",children:E.jsx("button",{type:"button","aria-label":"Rename direction",onClick:se=>{se.stopPropagation(),w(t)},onPointerDown:se=>se.stopPropagation(),className:"text-content-muted hover:bg-main-hover hover:text-content focus-visible:ring-content-muted/40 flex h-6 w-6 items-center justify-center rounded focus:outline-none focus-visible:ring-1",children:E.jsx(Kz,{size:13,weight:"bold"})})}),!A&&E.jsx(to,{label:"Remove",children:E.jsx("button",{type:"button","data-variant-remove-id":e.kind==="active"?e.variant.workItemId:void 0,"aria-label":"Remove direction",disabled:ne,onClick:se=>{se.stopPropagation(),e.kind==="active"?x(e.variant):y(e.entry)},onPointerDown:se=>se.stopPropagation(),className:"text-content-muted hover:bg-main-hover hover:text-content focus-visible:ring-content-muted/40 ml-1 flex h-6 w-6 items-center justify-center rounded focus:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50",children:E.jsx(Yz,{size:13,weight:"bold"})})})]})]})},DG=({initial:t,onCommit:e,onCancel:n})=>{const[r,s]=v.useState(t),i=v.useRef(!1),a=v.useCallback(u=>{u&&(u.focus(),u.select())},[]),c=u=>{i.current||(i.current=!0,u?e(r):n())};return E.jsx("input",{ref:a,type:"text",value:r,maxLength:120,"aria-label":"Rename direction",onChange:u=>s(u.target.value),onKeyDown:u=>{u.stopPropagation(),u.key==="Enter"?(u.preventDefault(),c(!0)):u.key==="Escape"&&(u.preventDefault(),c(!1))},onBlur:()=>c(!0),onClick:u=>u.stopPropagation(),onPointerDown:u=>u.stopPropagation(),className:"border-content-muted/40 bg-main text-content focus:ring-content-muted/50 w-full rounded border px-1.5 py-0.5 text-sm font-medium focus:ring-1 focus:outline-none"})},Pk=({label:t})=>E.jsx("span",{className:"bg-main-input text-content-muted shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium tracking-wide uppercase",children:t}),jG=({entry:t,deploying:e,deployedUrl:n,onDeploy:r,isDeployDisabled:s=!1})=>{const a=e?"Deploying…":n?"Copy link":"Share";return E.jsxs("div",{className:"border-main-border bg-main-light flex shrink-0 items-center justify-between gap-3 border-t px-3 pt-2 pb-4",children:[E.jsxs("div",{className:"min-w-0",children:[E.jsx("div",{className:"text-content truncate text-sm font-medium",children:t.label.trim()||"Untitled direction"}),n?E.jsx("div",{className:"text-content-muted text-[11px]",children:"Deployed — share link ready"}):null]}),E.jsxs("button",{type:"button",onClick:()=>r(t),disabled:e||s,title:n?`Copy share link (${n})`:"Deploy this direction and get a public link to share",className:"border-main-border text-content hover:bg-main-input flex shrink-0 items-center gap-1 rounded-md border px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:[n&&!e?E.jsx(qd,{size:12,weight:"bold"}):null,a]})]})},FG={agent_browser:"Browser extracted",cache:"Cached",static:"Bundled catalog",manual:"Manual"},VG={design_context:"DESIGN.md",source_context:"Source",qa_report:"QA",asset:"Asset"},$G=({artifacts:t})=>{const[e,n]=v.useState(null),r=v.useMemo(()=>e&&t.some(i=>i.id===e)?e:null,[t,e]);if(t.length===0)return null;const s=i=>{n(a=>a===i?null:i)};return E.jsxs("section",{"aria-label":"Directions session artifacts",className:"mt-4",children:[E.jsx("div",{className:"flex shrink-0 items-center px-3 py-2",children:E.jsx("span",{className:"text-content truncate text-sm font-medium",children:"Artifacts"})}),E.jsx("ul",{className:"mt-2 space-y-1 px-1",children:t.map(i=>E.jsx(HG,{artifact:i,isExpanded:i.id===r,onToggle:()=>s(i.id)},i.id))})]})},HG=({artifact:t,isExpanded:e,onToggle:n})=>{const r=VG[t.kind],s=t.source?FG[t.source]:null,i=[t.kind==="design_context"?null:s,t.summary].filter(Boolean).join(" · "),a=t.kind==="design_context"&&!!t.viewUrl,c=`${e?"Hide":"View"} ${r} artifact${t.label?`: ${t.label}`:""}`;return a?E.jsx("li",{className:"border-main-border rounded-md border",children:E.jsxs("div",{className:"flex w-full items-center justify-between gap-2 px-3 py-2 text-left text-xs",children:[E.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[E.jsxs("span",{className:"flex items-center gap-2",children:[E.jsx("span",{className:"border-content-muted/30 bg-main-input text-content-muted shrink-0 rounded-full border px-2 py-0.5 text-[9px] font-semibold tracking-wide uppercase",children:r}),E.jsx("span",{className:"text-content truncate text-xs font-medium",children:t.label})]}),i?E.jsx("span",{className:"text-content-muted mt-0.5 truncate text-[11px]",children:i}):null]}),E.jsx("a",{href:t.viewUrl,target:"_blank",rel:"noreferrer",onClick:()=>{be.capture("visual_editor_design_context_opened",{context_kind:"design_system",artifact_source:t.source})},"aria-label":`Open ${r} artifact${t.label?`: ${t.label}`:""}`,className:"text-content-muted hover:bg-main-input hover:text-content focus-visible:ring-content-muted/40 shrink-0 rounded p-1 transition-colors focus:outline-none focus-visible:ring-1",children:E.jsx(zz,{className:"h-3.5 w-3.5",weight:"bold"})})]})}):E.jsxs("li",{className:"border-main-border rounded-md border",children:[E.jsxs("button",{type:"button",onClick:n,"aria-expanded":e,"aria-label":c,className:"hover:bg-main-input flex w-full items-center justify-between gap-2 px-3 py-2 text-left text-xs transition-colors",children:[E.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[E.jsxs("span",{className:"flex items-center gap-2",children:[E.jsx("span",{className:"text-content-muted text-[10px] font-semibold tracking-wide uppercase",children:r}),E.jsx("span",{className:"text-content truncate text-xs font-medium",children:t.label})]}),i?E.jsx("span",{className:"text-content-muted mt-0.5 truncate text-[11px]",children:i}):null]}),E.jsx("span",{className:"text-content-muted shrink-0 text-[11px]",children:e?"Hide":"View"})]}),e?E.jsx("div",{className:"border-main-border bg-main-light border-t px-3 py-2",children:E.jsx(zG,{artifact:t})}):null]})},zG=({artifact:t})=>E.jsxs("div",{className:"text-content-muted space-y-1 text-[11px]",children:[t.summary?E.jsx("p",{children:t.summary}):null,t.path?E.jsxs("p",{children:["Stored at ",t.path]}):null,!t.summary&&!t.path?E.jsx("p",{children:"No inline content available for this artifact."}):null]}),UG=({selectedVariant:t,busy:e,onSend:n,onDeploy:r,onDeployCanvas:s,canDeploy:i,canDeployCanvas:a,canSendToAgent:c,canvasVariantCount:u,canvasDeployedUrl:f,deployedUrl:h})=>{var O,A,I,N;const p=t?((A=(O=t.actions)==null?void 0:O.commit)==null?void 0:A.enabled)??t.status==="succeeded":!1,m=p&&e===null,_=(e==null?void 0:e.kind)==="commit"&&e.variantId===(t==null?void 0:t.workItemId),x=(e==null?void 0:e.kind)==="deploy"&&e.variantId===(t==null?void 0:t.workItemId),y=(e==null?void 0:e.kind)==="deploy-canvas",w=!i||!p||e!==null,S=a&&u>0,P=x?"Deploying…":h?"Copy link":"Share",R=y?"Sharing…":f?"Copy canvas link":"Share canvas",L=_?"Applying…":"Apply to project";return E.jsxs("div",{className:"border-main-border bg-main-light flex shrink-0 items-center justify-between gap-3 border-t px-3 pt-2 pb-4",children:[E.jsx("div",{className:"min-w-0",children:t?E.jsxs(E.Fragment,{children:[E.jsx("div",{className:"text-content truncate text-sm font-medium",children:t.label.trim()||"Untitled direction"}),h?E.jsx("div",{className:"text-content-muted text-[11px]",children:"Deployed — share link ready"}):null]}):null}),E.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[E.jsx(FR,{primaryLabel:P,primaryIcon:h&&!x?qd:void 0,primaryAction:()=>{t&&r(t)},isDisabled:w,isDropdownDisabled:e!==null,isLoading:x,loadingLabel:"Deploying…",dropdownAriaLabel:"More share actions",dropdownItems:S?[{label:R,icon:f&&!y?qd:void 0,onClick:s,isDisabled:e!==null}]:[]}),c?E.jsx("button",{type:"button",onClick:()=>{t&&n(t)},disabled:!m,title:(N=(I=t==null?void 0:t.actions)==null?void 0:I.commit)==null?void 0:N.reason,className:"bg-secondary text-secondary-foreground hover:bg-accent rounded-md px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:L}):null]})]})},tA=()=>E.jsx("div",{"data-testid":"direction-skeleton-row","aria-hidden":"true",className:"flex w-full items-start rounded-md px-3 py-2",children:E.jsxs("span",{className:"min-w-0 flex-1",children:[E.jsxs("span",{className:"flex items-center gap-2",children:[E.jsx(Ix,{className:"text-content-muted shrink-0 text-sm"}),E.jsx("span",{className:"bg-muted-foreground/15 h-3.5 w-28 animate-pulse rounded"})]}),E.jsx("span",{className:"mt-1.5 flex",children:E.jsx("span",{className:"bg-muted-foreground/10 h-2.5 w-full max-w-[14rem] animate-pulse rounded"})})]})}),BG=({groups:t})=>E.jsx("div",{className:"space-y-0.5",children:t.flatMap(e=>Array.from({length:Math.max(1,e.count)}).map((n,r)=>E.jsx(tA,{},`${e.requestId}-${r}`)))}),WG=()=>E.jsx("div",{"data-testid":"direction-boot-skeletons",className:"space-y-0.5",children:Array.from({length:3}).map((t,e)=>E.jsx(tA,{},e))}),GG=()=>E.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-center",children:[E.jsx("div",{className:"text-content text-sm",children:"No directions yet"}),E.jsx("div",{className:"text-content-muted text-xs",children:"They’ll appear here as they generate."})]}),Tk="Try different ways to create a dropdown that feels fluid and dynamic",KG=({isMCPSession:t=!1,mcpEditor:e=null})=>{const[n,r]=v.useState(!1),s=mB(e),i=t?s:"your coding agent",a=()=>{navigator.clipboard.writeText(Tk).then(()=>{r(!0),setTimeout(()=>r(!1),2e3)})};return E.jsxs("div",{className:"flex flex-col items-start gap-3 px-2 py-2",children:[E.jsx("p",{className:"text-content text-sm font-medium",children:"Create your first direction"}),E.jsxs("p",{className:"text-content-muted text-xs",children:["Use ",i," to generate directions."]}),E.jsxs("div",{className:"w-full",children:[E.jsx("p",{className:"text-content-muted mb-2 text-xs",children:"Here's a sample prompt to use:"}),E.jsxs("div",{className:"border-main-border bg-main-input relative rounded-md border px-3 py-2.5 pr-8",children:[E.jsxs("p",{className:"text-content-muted text-xs leading-snug",children:["“",Tk,"”"]}),E.jsx("button",{type:"button",onClick:a,className:"text-content-muted hover:bg-main-border hover:text-content absolute top-2 right-2 rounded p-0.5 transition-colors",title:"Copy to clipboard",children:n?E.jsx(x5,{className:"h-3.5 w-3.5 text-emerald-500",weight:"bold"}):E.jsx(qd,{className:"h-3.5 w-3.5",weight:"bold"})})]})]})]})},ZG=({onClose:t})=>{const e=et(nR);return t?E.jsxs("div",{className:"z-10 flex flex-shrink-0 items-center justify-between gap-2 border-b border-main-border bg-main-light px-2.5 py-2.5",children:[e?E.jsx("span",{className:"text-content min-w-0 truncate text-sm font-medium",title:e,children:e}):E.jsx("span",{}),E.jsx(to,{label:"Close panel",side:"bottom",children:E.jsx("button",{onClick:t,className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded p-1 text-content-subtle transition-colors hover:bg-main-input hover:text-content",children:E.jsx(Zz,{className:"h-4 w-4",weight:"bold"})})})]}):null},qG='[data-menu-item]:not([disabled]):not([aria-disabled="true"])',YG=({itemSelector:t=qG,loop:e=!1}={})=>{const n=v.useRef(null),r=v.useRef(null),s=v.useCallback(a=>{var c;n.current=a,a?r.current=hB():((c=r.current)==null||c.call(r),r.current=null)},[]),i=v.useCallback(a=>{var x;const{key:c}=a;if(c!=="ArrowDown"&&c!=="ArrowUp"&&c!=="Home"&&c!=="End")return;const u=n.current;if(!u)return;const f=Array.from(u.querySelectorAll(t));if(f.length===0)return;a.preventDefault(),a.stopPropagation();const h=f.indexOf(document.activeElement),p=f.length-1,m=y=>{if(h===-1)return y===1?0:p;const w=h+y;return e?(w+f.length)%f.length:Math.min(Math.max(w,0),p)};let _;c==="Home"?_=0:c==="End"?_=p:c==="ArrowDown"?_=m(1):_=m(-1),(x=f[_])==null||x.focus()},[t,e]);return{containerRef:s,onKeyDown:i}},Rk="/assets/arena-Db0j1set.png",XG=Es("useIntegrations"),b1=["integrations"],QG="rivet:connect-result",JG=t=>typeof t=="object"&&t!==null&&t.type===QG,eK=nt(null),Ak=async()=>{const t=await fetch("/api/integrations");if(!t.ok)throw new Error(`Failed to load integrations (${t.status})`);return(await t.json()).integrations??[]},tK=()=>{const t=Z8(),[e,n]=HP(eK),r=ry({queryKey:b1,queryFn:Ak,staleTime:1e4}),s=v.useCallback(async()=>(await t.invalidateQueries({queryKey:b1,refetchType:"none"}),t.fetchQuery({queryKey:b1,queryFn:Ak})),[t]),i=v.useCallback(async c=>{const u=window.open("","_blank","width=560,height=720");if(!u)throw new Error("Popup blocked. Allow popups to connect.");n(c);try{const f=await fetch(`/api/integrations/${c}/connect`,{method:"POST"}),h=await f.json().catch(()=>({}));if(!f.ok||!h.authUrl)throw u.close(),new Error(h.error||`Could not connect ${c}`);return u.location.href=h.authUrl,await new Promise(p=>{let m=!1,_=null;const x=async(w,S=!1)=>{if(!m){m=!0,window.removeEventListener("message",y),_&&clearInterval(_);try{const P=(await s()).some(k=>k.provider===c&&k.status==="connected");p(S&&P?"connected":w)}catch{p(w)}}},y=w=>{if(JG(w.data)&&w.data.provider===c){if(w.data.status==="error"){XG.warn(`Connect failed for ${c}:`,w.data.message),x("failed");return}x("connected")}};window.addEventListener("message",y),_=setInterval(()=>{u.closed&&x("closed",!0)},500)})}finally{n(null)}},[s,n]),a=v.useCallback(async c=>{n(c);try{const u=await fetch(`/api/integrations/${c}`,{method:"DELETE"});if(!u.ok){const f=await u.json().catch(()=>({}));throw new Error(f.error||`Could not disconnect ${c}`)}await s()}finally{n(null)}},[s,n]);return{integrations:r.data??[],isLoading:r.isPending,error:r.error instanceof Error?r.error.message:null,pendingProvider:e,connect:i,disconnect:a,refetch:s}},Ic=({onClick:t,title:e,shortcut:n,children:r,disabled:s=!1,className:i="",type:a="button","data-cy":c})=>{const u=E.jsx("button",{onClick:t,disabled:s,className:i,type:a,"data-cy":c,children:r});return e?E.jsx(Wx,{content:E.jsxs("div",{className:"flex flex-row items-center gap-2",children:[E.jsx("span",{children:e}),n?E.jsx("span",{className:"rounded bg-white/15 px-1.5 py-0.5 text-[11px]",children:n}):null]}),children:u}):u},Wa=({action:t,outcome:e,provider:n,entryPoint:r,durationMs:s,failureReason:i})=>({event:`visual_editor_reference_${t==="connect"?"connection":"disconnection"}_${e}`,properties:{provider:n,entry_point:r,...s!==void 0?{duration_ms:s}:{},...i?{failure_reason:i}:{}}}),Ik=Es("ConnectorsModal"),nK=()=>E.jsx("svg",{viewBox:"0 0 24 24",className:"h-6 w-6","aria-hidden":"true",children:E.jsx("path",{fill:"currentColor",d:"M12 0C5.373 0 0 5.372 0 12c0 5.084 3.163 9.426 7.627 11.174-.105-.949-.2-2.405.042-3.441.218-.937 1.407-5.965 1.407-5.965s-.359-.719-.359-1.781c0-1.669.967-2.915 2.171-2.915 1.024 0 1.518.769 1.518 1.69 0 1.029-.655 2.568-.994 3.995-.283 1.194.599 2.169 1.777 2.169 2.132 0 3.772-2.249 3.772-5.495 0-2.873-2.064-4.882-5.012-4.882-3.414 0-5.418 2.561-5.418 5.207 0 1.031.397 2.137.893 2.739.098.119.112.223.083.344-.091.379-.293 1.194-.333 1.361-.052.22-.174.266-.401.16-1.499-.698-2.436-2.889-2.436-4.649 0-3.785 2.75-7.262 7.929-7.262 4.163 0 7.398 2.967 7.398 6.931 0 4.136-2.607 7.464-6.227 7.464-1.216 0-2.36-.631-2.75-1.378l-.748 2.853c-.271 1.043-1.002 2.35-1.492 3.146A12.004 12.004 0 0 0 12 24c6.627 0 12-5.373 12-12C24 5.372 18.627 0 12 0z"})}),rK=()=>E.jsx("span",{"aria-hidden":"true",className:"h-6 w-6 bg-[#b1b1b1]",style:{WebkitMaskImage:`url(${Rk})`,maskImage:`url(${Rk})`,WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskPosition:"center",maskPosition:"center"}}),sK=[{provider:"pinterest",name:"Pinterest",description:"Pull boards and pins in as visual references.",tileClassName:"bg-[#e60023] text-white",icon:E.jsx(nK,{})},{provider:"arena",name:"Are.na",description:"Connect channels of collected blocks and links.",tileClassName:"bg-[#18181b] text-content",icon:E.jsx(rK,{})}],iK=({meta:t,integration:e,isPending:n,isHighlighted:r,onConnect:s,onDisconnect:i})=>{const a=(e==null?void 0:e.status)==="connected",c=e!=null&&e.externalUsername?`@${e.externalUsername}`:null;return E.jsxs("article",{className:`bg-main-light flex flex-col rounded-xl p-[18px] ${r?"ring-secondary ring-2":""}`,children:[E.jsx("span",{className:`grid h-[52px] w-[52px] flex-none place-items-center rounded-xl ${t.tileClassName}`,"aria-hidden":"true",children:t.icon}),E.jsxs("div",{className:"mt-4 flex-1",children:[E.jsxs("h2",{className:"text-content flex items-center gap-1.5 text-[15px] font-semibold",children:[t.name,a?E.jsx(x5,{className:"h-3.5 w-3.5",weight:"bold","aria-hidden":"true"}):null]}),E.jsx("p",{className:"text-content-subtle mt-1 text-[13px] leading-relaxed",children:t.description}),a&&c?E.jsx("p",{className:"text-content-muted mt-2.5 text-xs font-medium",children:c}):null]}),a?E.jsx("button",{type:"button",onClick:i,disabled:n,className:"active-push bg-main-input text-content-muted mt-[18px] inline-flex min-h-[38px] w-full items-center justify-center rounded-lg px-3.5 text-[13px] font-semibold transition-colors hover:bg-red-500/10 hover:text-red-300 disabled:cursor-not-allowed disabled:opacity-50",children:n?"Disconnecting…":"Disconnect"}):E.jsx("button",{type:"button",onClick:s,disabled:n,className:"active-push bg-secondary text-secondary-foreground hover:bg-accent mt-[18px] inline-flex min-h-[38px] w-full items-center justify-center rounded-lg px-3.5 text-[13px] font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:n?"Connecting…":"Connect"})]})},z_=({isOpen:t,onClose:e,context:n="menu",highlightProvider:r=null})=>{const{integrations:s,isLoading:i,error:a,pendingProvider:c,connect:u,disconnect:f}=tK(),h=r0(),[p,m]=v.useState(null),_=S=>s.find(T=>T.provider===S),x=v.useCallback(S=>{const T=Date.now(),P=Wa({action:"connect",outcome:"started",provider:S,entryPoint:n});h==null||h.capture(P.event,P.properties),u(S).then(k=>{const R=Date.now()-T;if(k==="connected"){const O=Wa({action:"connect",outcome:"completed",provider:S,entryPoint:n,durationMs:R});h==null||h.capture(O.event,O.properties);return}const L=Wa({action:"connect",outcome:"failed",provider:S,entryPoint:n,durationMs:R,failureReason:k==="closed"?"popup_closed":"provider_failed"});h==null||h.capture(L.event,L.properties)}).catch(k=>{const R=k instanceof Error?k.message:"Could not connect.",L=Wa({action:"connect",outcome:"failed",provider:S,entryPoint:n,durationMs:Date.now()-T,failureReason:R.includes("Popup blocked")?"popup_blocked":"request_failed"});h==null||h.capture(L.event,L.properties),Ik.warn(`Connect error for ${S}:`,R),mt.error(R)})},[u,n,h]),y=v.useCallback(S=>{const T=Date.now(),P=Wa({action:"disconnect",outcome:"started",provider:S,entryPoint:n});h==null||h.capture(P.event,P.properties),f(S).then(()=>{const k=Wa({action:"disconnect",outcome:"completed",provider:S,entryPoint:n,durationMs:Date.now()-T});h==null||h.capture(k.event,k.properties)}).catch(k=>{const R=k instanceof Error?k.message:"Could not disconnect.",L=Wa({action:"disconnect",outcome:"failed",provider:S,entryPoint:n,durationMs:Date.now()-T,failureReason:"request_failed"});h==null||h.capture(L.event,L.properties),Ik.warn(`Disconnect error for ${S}:`,R),mt.error(R)})},[n,f,h]),w=n==="onboarding";return E.jsx(wx,{open:t,onOpenChange:S=>!S&&e(),children:E.jsxs(bx,{children:[E.jsx(Sx,{className:"z-max fixed inset-0 bg-black/40"}),E.jsx(Ex,{ref:m,className:"z-max border-main-border bg-main font-main fixed top-1/2 left-1/2 w-[560px] -translate-x-1/2 -translate-y-1/2 rounded-lg border shadow-2xl outline-none",children:E.jsxs(YR,{value:p,children:[E.jsxs("div",{className:"border-main-border bg-main-light flex items-center justify-between rounded-t-lg border-b px-4 py-2",children:[E.jsx(Cx,{className:"text-content text-base font-medium",children:"Connect design references"}),E.jsx(Ic,{onClick:e,title:"Close",className:"text-content-subtle hover:bg-main-hover hover:text-content rounded p-1 transition-colors",children:E.jsx(M5,{className:"h-4 w-4",weight:"bold"})})]}),E.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[E.jsx(kx,{className:"text-content-subtle text-sm",children:"Connect your design references to use them with Rivet’s MCP."}),a?E.jsx("p",{className:"rounded-lg bg-red-500/10 px-4 py-3 text-[13px] font-medium text-red-300",children:a}):null,E.jsx("div",{className:"grid grid-cols-2 gap-4",children:sK.map(S=>E.jsx(iK,{meta:S,integration:_(S.provider),isPending:i||c===S.provider,isHighlighted:r===S.provider,onConnect:()=>x(S.provider),onDisconnect:()=>y(S.provider)},S.provider))}),w?E.jsxs("div",{className:"flex items-center justify-between gap-4",children:[E.jsx("p",{className:"text-content-subtle text-xs",children:"You can always do this later from the account menu."}),E.jsx("button",{type:"button",onClick:e,className:"active-push bg-secondary text-secondary-foreground hover:bg-accent flex-none rounded-lg px-3.5 py-2 text-[13px] font-medium transition-colors",children:"Skip for now"})]}):null]})]})})]})})},Mk=({className:t=""})=>E.jsx("span",{"aria-hidden":"true",className:`rivet-skeleton block rounded ${t}`.trim()}),oK=Es("SupportTicketModal"),Ok=5e3,S1="feedback",aK=t=>{var r;if(!t)return null;const e=(r=t.formErrors)==null?void 0:r[0];if(e)return e;const n=t.fieldErrors??{};for(const s of Object.values(n)){const i=s==null?void 0:s[0];if(i)return i}return null},lK=async t=>{let e;try{e=await t.json()}catch{e=void 0}if(t.status===400){if(typeof(e==null?void 0:e.details)=="string"&&e.details.trim())return e.details;if(typeof(e==null?void 0:e.details)=="object"&&e.details!==null){const n=aK(e.details);if(n)return n}return"Please check your feedback and try again."}return t.status>=500?typeof(e==null?void 0:e.details)=="string"&&e.details.trim()?e.details:"Could not send feedback right now. Please try again later.":typeof(e==null?void 0:e.error)=="string"&&e.error.trim()?e.error:`HTTP ${t.status}`},cK=({isOpen:t,onClose:e,contactEmail:n})=>{const r=r0(),[s,i]=v.useState(""),[a,c]=v.useState(!1),[u,f]=v.useState(null),h=v.useCallback(()=>{i("")},[]),p=v.useCallback(()=>{a||(h(),e())},[a,e,h]),m=v.useCallback(async()=>{const w=s.trim();if(!(!w||a)){c(!0);try{const S=typeof(r==null?void 0:r.get_session_id)=="function"?r.get_session_id():void 0,T=typeof(r==null?void 0:r.get_distinct_id)=="function"?r.get_distinct_id():void 0,P=n==null?void 0:n.trim(),k=await fetch("/api/support/tickets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:S1,message:w,contactEmail:P||void 0,metadata:{posthogSessionId:S??void 0,posthogDistinctId:T??void 0,appVersion:"0.14.16",appEnvironment:"production",pageUrl:window.location.href,userAgent:navigator.userAgent,submittedAt:new Date().toISOString()}})});if(!k.ok){const R=await lK(k);throw new Error(R)}r==null||r.capture("support_ticket_submitted",{ticket_type:S1,has_posthog_session_id:!!S}),mt.success("Feedback sent",{description:"Thanks for sharing this."}),h(),e()}catch(S){const T=S instanceof Error?S.message:"Failed to send message";r==null||r.capture("support_ticket_submit_failed",{ticket_type:S1,error:T}),oK.error("Failed to submit support ticket:",T),mt.error("Could not send feedback",{description:T})}finally{c(!1)}}},[n,a,s,e,r,h]),_=v.useCallback(w=>{w.key==="Enter"&&(w.metaKey||w.ctrlKey)&&(w.preventDefault(),m())},[m]),x=Ok-s.length,y=a||s.trim().length===0;return E.jsx(wx,{open:t,onOpenChange:w=>!w&&p(),children:E.jsxs(bx,{children:[E.jsx(Sx,{className:"fixed inset-0 z-max bg-black/40"}),E.jsx(Ex,{ref:f,className:"fixed left-1/2 top-1/2 z-max w-[440px] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-main-border bg-main font-main shadow-2xl outline-none",children:E.jsxs(YR,{value:u,children:[E.jsxs("div",{className:"flex items-center justify-between rounded-t-lg border-b border-main-border bg-main-light px-4 py-2",children:[E.jsx(Cx,{className:"text-base font-medium text-content",children:"Send feedback"}),E.jsx(Ic,{onClick:p,disabled:a,title:"Close",className:"rounded p-1 text-content-subtle transition-colors hover:bg-main-hover hover:text-content disabled:cursor-not-allowed disabled:opacity-50",children:E.jsx(M5,{className:"h-4 w-4",weight:"bold"})})]}),E.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[E.jsx(kx,{className:"text-sm text-content-subtle",children:"Tell us what happened or what we can improve."}),E.jsxs("div",{className:"rounded-lg bg-main-input outline outline-1 outline-transparent transition-[outline-color] focus-within:outline-white/20",children:[E.jsx("textarea",{id:"support-ticket-message","aria-label":"Your feedback",value:s,onChange:w=>i(w.target.value),onKeyDown:_,maxLength:Ok,rows:6,disabled:a,placeholder:"What happened?",className:"max-h-64 w-full resize-none overflow-y-auto bg-transparent pb-1 pl-3 pr-3 pt-3 text-sm text-content placeholder-content-subtle focus:outline-none disabled:opacity-50"}),E.jsxs("div",{className:"flex items-center justify-between px-3 pb-3 pt-1",children:[E.jsx("span",{className:"text-xs text-content-subtle",children:"Context details are included automatically."}),E.jsxs("div",{className:"flex items-center gap-2",children:[x<=500&&E.jsx("span",{className:"text-xs text-content-subtle",children:x}),E.jsx(Ic,{onClick:m,disabled:y,title:"Send feedback",shortcut:"⌘↵",className:"flex items-center justify-center rounded bg-primary p-1 text-content transition-colors hover:bg-primary-hover disabled:cursor-not-allowed disabled:opacity-80",children:a?E.jsx(h0,{className:"h-5 w-5 animate-spin",weight:"bold"}):E.jsx(Uz,{className:"h-5 w-5",weight:"bold"})})]})]})]})]})]})})]})})},uK=Es("ProfileAvatar"),nA=(t,e)=>{const n=(t??"").trim();if(n)return n.split(/\s+/).filter(Boolean)[0]??"";const s=((e??"").split("@")[0]??"").split(/[._\-+]/).filter(Boolean)[0]??"";return s?s[0].toUpperCase()+s.slice(1):""},dK=(t,e)=>nA(t,e).charAt(0).toUpperCase(),fK=({className:t="",side:e="bottom",align:n="end"})=>{const{name:r,email:s}=et(sR),i=et(cR),[a,c]=v.useState(!1),[u,f]=v.useState(!1),[h,p]=v.useState(!1),[m,_]=v.useState(!1),{containerRef:x,onKeyDown:y}=YG(),w=et(Tf),S=dK(r,s);if(!S)return w?E.jsxs("span",{"data-testid":"profile-avatar-skeleton","aria-hidden":"true",className:`flex shrink-0 items-center gap-2 ${t}`.trim(),children:[E.jsx(Mk,{className:"h-7 w-7 rounded-full"}),E.jsx(Mk,{className:"h-3 w-16"})]}):null;const T=nA(r,s),P=(r==null?void 0:r.trim())||null,k=(s==null?void 0:s.trim())||null,R=async()=>{_(!0);try{const L=await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin"});if(!L.ok)throw new Error(`Logout failed: ${L.status}`)}catch(L){uK.warn("Logout request failed",L),mt.error("Could not log out. Please try again."),_(!1);return}window.location.reload()};return E.jsxs(E.Fragment,{children:[E.jsxs(LR,{open:a,onOpenChange:c,children:[E.jsx(NR,{asChild:!0,children:E.jsxs("button",{type:"button","aria-label":"Account",className:`text-content-muted hover:text-content flex shrink-0 items-center gap-2 transition-colors select-none ${t}`,children:[E.jsx("span",{className:"border-main-border bg-main-input flex h-7 w-7 items-center justify-center rounded-full border text-[11px] leading-none font-semibold",children:S}),T?E.jsx("span",{className:"max-w-[8rem] truncate text-xs font-medium",children:T}):null]})}),E.jsx(DR,{children:E.jsxs(jR,{ref:x,onKeyDown:y,role:"menu",className:"bg-surface-2 z-[60] min-w-[180px] rounded-lg p-1 shadow-lg",side:e,sideOffset:6,align:n,children:[P||k?E.jsxs("div",{className:"border-main-border border-b px-3 py-2",children:[P?E.jsx("div",{className:"text-content truncate text-xs font-medium",children:P}):null,k?E.jsx("div",{className:"text-content-muted truncate text-[11px]",children:k}):null]}):null,E.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:()=>{c(!1),f(!0)},disabled:!i,className:"text-content hover:bg-hover focus:bg-hover mt-1 flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",children:[E.jsx(R5,{className:"h-3.5 w-3.5",weight:"bold"}),"Connect design references"]}),E.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:()=>{c(!1),p(!0)},className:"text-content hover:bg-hover focus:bg-hover mt-1 flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs transition-colors focus:outline-none",children:[E.jsx(Wz,{className:"h-3.5 w-3.5",weight:"bold"}),"Share feedback"]}),E.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:R,disabled:m,className:"text-content hover:bg-hover focus:bg-hover mt-1 flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",children:[E.jsx(qz,{className:"h-3.5 w-3.5",weight:"bold"}),m?"Logging out…":"Log out"]})]})})]}),E.jsx(z_,{isOpen:u,onClose:()=>f(!1)}),E.jsx(cK,{isOpen:h,onClose:()=>p(!1),contactEmail:s??void 0})]})},hK=({onClose:t})=>E.jsxs("div",{className:"bg-main font-main scrollbar-hide relative flex h-full w-full cursor-auto flex-col overflow-hidden shadow-2xl","data-cy":"element-inspector",children:[E.jsx(ZG,{onClose:t}),E.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:E.jsx(kG,{})}),E.jsx("div",{className:"border-main-border bg-main-light flex flex-shrink-0 items-center border-t px-2.5 py-1.5",children:E.jsx(fK,{side:"top",align:"start"})})]});async function pK(t,e){const{delaysMs:n,shouldRetry:r,onRetry:s}=e;for(let i=1;;i++)try{return await t(i)}catch(a){const c=n[i-1];if(c===void 0||r&&!r(a))throw a;s==null||s(a,i,c),await new Promise(u=>setTimeout(u,c))}}const Lk=Es("useServerConfig"),rA=[250,500,1e3,2e3,4e3],Nk=rA.length+1,mK=async()=>{var n;const t=await fetch("/api/health");if(!t.ok)throw new Error(`Failed to fetch config: ${t.status}`);const e=await t.json();if(!e.framework)throw new Error("Server did not return framework information");return{userPort:((n=e.ports)==null?void 0:n.userDevServer)||3e3,framework:e.framework}},gK=()=>{const[t,e]=v.useState(null),[n,r]=v.useState(!0),[s,i]=v.useState(null),a=v.useCallback(async()=>{try{r(!0),i(null);const c=await pK(mK,{delaysMs:rA,onRetry:(u,f,h)=>{Lk.warn(`Server config fetch failed (attempt ${f}); retrying in ${h}ms`,u)}});return e(c),c}catch(c){const u=c instanceof Error?c.message:"Failed to fetch server config";throw i(u),Lk.warn("Error fetching server config:",c),c}finally{r(!1)}},[]);return{config:t,fetchConfig:a,isLoading:n,error:s}},vK="#1C1C20",Fi=[118,118,124],Dk=.85,yK=3,_K=.15,gp=36,xK=4.4,wK=.7,bK=3.5,SK=.8,jk=9,EK=11,CK=[1.35,1.12,.95,.85],kK=[0,1.1,2.3,3.1],PK=[0,.35,.16,.13],TK=[.9,.5,.4,.35],Ga=3,E1=[[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.14,y1:.13,x2:.86,y2:.23,level:1},{x1:.14,y1:.28,x2:.3,y2:.87,level:1},{x1:.34,y1:.28,x2:.86,y2:.87,level:1},{x1:.165,y1:.155,x2:.225,y2:.205,level:2},{x1:.7,y1:.155,x2:.755,y2:.205,level:2},{x1:.775,y1:.155,x2:.83,y2:.205,level:2},{x1:.165,y1:.32,x2:.275,y2:.375,level:2},{x1:.165,y1:.415,x2:.275,y2:.47,level:2},{x1:.165,y1:.51,x2:.275,y2:.565,level:2},{x1:.37,y1:.32,x2:.585,y2:.56,level:2},{x1:.615,y1:.32,x2:.83,y2:.56,level:2},{x1:.37,y1:.61,x2:.83,y2:.83,level:2},{hline:!0,x1:.39,x2:.81,y:.685,level:3},{hline:!0,x1:.39,x2:.75,y:.755,level:3}],[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.16,y1:.17,x2:.52,y2:.45,level:1},{x1:.58,y1:.17,x2:.685,y2:.29,level:1},{x1:.715,y1:.17,x2:.84,y2:.29,level:1},{x1:.58,y1:.33,x2:.685,y2:.45,level:1},{x1:.715,y1:.33,x2:.84,y2:.45,level:1},{x1:.16,y1:.55,x2:.84,y2:.85,level:1},{x1:.19,y1:.21,x2:.36,y2:.33,level:2},{hline:!0,x1:.19,x2:.48,y:.37,level:3},{hline:!0,x1:.19,x2:.42,y:.42,level:3},{x1:.19,y1:.6,x2:.49,y2:.8,level:2},{hline:!0,x1:.53,x2:.8,y:.63,level:3},{hline:!0,x1:.53,x2:.76,y:.7,level:3},{hline:!0,x1:.53,x2:.79,y:.77,level:3}],[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.14,y1:.13,x2:.86,y2:.22,level:1},{x1:.14,y1:.28,x2:.36,y2:.87,level:1},{x1:.39,y1:.28,x2:.61,y2:.87,level:1},{x1:.64,y1:.28,x2:.86,y2:.87,level:1},{x1:.165,y1:.15,x2:.225,y2:.2,level:2},{x1:.165,y1:.32,x2:.335,y2:.52,level:2},{x1:.415,y1:.32,x2:.585,y2:.52,level:2},{x1:.665,y1:.32,x2:.835,y2:.52,level:2},{hline:!0,x1:.165,x2:.335,y:.6,level:3},{hline:!0,x1:.165,x2:.3,y:.67,level:3},{hline:!0,x1:.415,x2:.585,y:.6,level:3},{hline:!0,x1:.415,x2:.55,y:.67,level:3},{hline:!0,x1:.665,x2:.835,y:.6,level:3},{hline:!0,x1:.665,x2:.8,y:.67,level:3}],[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.3,y1:.22,x2:.7,y2:.74,level:1},{x1:.34,y1:.27,x2:.55,y2:.34,level:2},{hline:!0,x1:.36,x2:.64,y:.42,level:3},{hline:!0,x1:.36,x2:.6,y:.49,level:3},{hline:!0,x1:.36,x2:.62,y:.56,level:3},{x1:.5,y1:.63,x2:.575,y2:.69,level:2},{x1:.595,y1:.63,x2:.66,y2:.69,level:2}]],vp=t=>{let e=t|0;return e=Math.imul(e^e>>>16,73244475),e=Math.imul(e^e>>>16,73244475),e^=e>>>16,(e>>>0)/4294967296},zp=t=>{const e=Math.min(1,Math.max(0,t));return e*e*(3-2*e)},Ka=(t,e)=>(Math.round(t/e-.5)+.5)*e,RK=Math.sin(Math.PI/3),Fk=(t,e,n,r,s)=>{if(t.beginPath(),e===0)t.arc(n,r,s,0,Math.PI*2);else if(e===1){const i=s*RK;t.moveTo(n,r-s),t.lineTo(n+i,r+s/2),t.lineTo(n-i,r+s/2),t.closePath()}else{const i=s*.85;t.rect(n-i,r-i,i*2,i*2)}t.fill()},AK=(t,e,n)=>{let r;if(n.hline){const s=Math.max(n.x1-t,t-n.x2,0),i=Math.abs(e-n.y1);r=Math.hypot(s,i)-jk}else{const s=Math.max(n.x1-t,t-n.x2,0),i=Math.max(n.y1-e,e-n.y2,0);s===0&&i===0?r=-Math.min(t-n.x1,n.x2-t,e-n.y1,n.y2-e):r=Math.hypot(s,i),r=Math.abs(r)-jk}return zp(.5-r/(2*EK))},sA=({className:t="",trackGlobalLoaderCount:e=!0})=>{const n=at(rR),r=v.useRef(null),s=v.useCallback(i=>{var N;if((N=r.current)==null||N.call(r),r.current=null,!i)return;const a=i.getContext("2d");if(!a)return;e&&n(j=>j+1);const c=window.matchMedia("(prefers-reduced-motion: reduce)").matches;let u=[],f=0,h=0,p=gp,m=gp,_=null,x=null,y=0,w=-1;const S=new Array(33),T=j=>{const F=Math.round(j*32);let K=S[F];if(!K){const X=F/32,W=Math.round(Fi[0]+(255-Fi[0])*X),G=Math.round(Fi[1]+(255-Fi[1])*X),q=Math.round(Fi[2]+(255-Fi[2])*X);K=`rgba(${W}, ${G}, ${q}, ${Dk})`,S[F]=K}return K},P=j=>{const F=1-.35*j,K=Math.round(Fi[0]*F),X=Math.round(Fi[1]*F),W=Math.round(Fi[2]*F);return`rgba(${K}, ${X}, ${W}, ${Dk})`},k=j=>{let F=Math.floor(Math.random()*E1.length);F===w&&(F=(F+1)%E1.length),w=F;const K=[0,0,0,0],X=E1[F].map((D,Y)=>{const ee=D.level,ie=K[ee]++,oe=kK[ee]+ie*PK[ee],ce=TK[ee]+vp(F*131+Y*17+5)*.2;if(D.hline){const se=Ka((D.y??0)*h,m);return{hline:!0,x1:Ka(D.x1*f,p),x2:Ka(D.x2*f,p),y1:se,y2:se,level:ee,start:oe,dur:ce}}const xe=Ka(D.x1*f,p),ae=Ka((D.y1??0)*h,m);return{hline:!1,x1:xe,y1:ae,x2:Math.max(Ka(D.x2*f,p),xe+p),y2:Math.max(Ka((D.y2??0)*h,m),ae+m),level:ee,start:oe,dur:ce}}),W=X.reduce((D,Y)=>Math.max(D,Y.start+Y.dur),0),G=u.length,q=new Float32Array(G*Ga),$=new Int16Array(G*Ga).fill(-1),ne=new Uint8Array(G),H=X[0];for(let D=0;D<G;D++){const Y=u[D];Y.x>H.x1&&Y.x<H.x2&&Y.y>H.y1&&Y.y<H.y2&&(ne[D]=1);const ee=D*Ga;for(let ie=0;ie<X.length;ie++){const oe=AK(Y.x,Y.y,X[ie]);if(oe<=.02)continue;let ce=ee;for(let xe=ee;xe<ee+Ga;xe++){if($[xe]===-1){ce=xe;break}q[xe]<q[ce]&&(ce=xe)}($[ce]===-1||oe>q[ce])&&(q[ce]=oe,$[ce]=ie)}}return{startT:j,buildEnd:W,els:X,frame:H,cellQ:q,cellEl:$,inFrame:ne}},R=()=>{const j=i.getBoundingClientRect();f=Math.max(1,j.width),h=Math.max(1,j.height);const F=Math.min(2,window.devicePixelRatio||1);i.width=Math.round(f*F),i.height=Math.round(h*F),a.setTransform(F,0,0,F,0,0);const K=Math.max(8,Math.round(f/gp)),X=Math.max(6,Math.round(h/gp));p=f/K,m=h/X,u=[];for(let W=0;W<X;W++){const G=X>1?W/(X-1):.5,q=xK*(1+wK*.4*(G*2-1));for(let $=0;$<K;$++){const ne=W*8191+$*131+1,H={x:($+.5)*p,y:(W+.5)*m,size:q,seed:ne,phase:vp(ne),kind:0};H.kind=Math.floor(vp(ne*97)*3),u.push(H)}}x=null,_=null},L=new Float32Array(32),O=j=>{a.fillStyle=vK,a.fillRect(0,0,f,h),_||(_=k(j+.2)),j>=_.startT+_.buildEnd+bK&&(x=_,y=j,_=k(j+.2));let F=0;x&&(F=1-zp((j-y)/SK),F<=0&&(x=null));const K=_;for(let H=0;H<K.els.length;H++){const D=K.els[H];L[H]=zp(Math.min(1,Math.max(0,(j-K.startT-D.start)/D.dur)))}const X=L[0],W=P(0),G=P(X),q=F>0?P(F):W,$=F>0?P(Math.max(X,F)):G,ne=u.length;for(let H=0;H<ne;H++){const D=u[H];let Y=0,ee=0;const ie=H*Ga;for(let De=ie;De<ie+Ga;De++){const Re=K.cellEl[De];if(Re<0)break;const Ye=K.cellQ[De]*L[Re];Ye>Y&&(Y=Ye,ee=K.els[Re].level)}if(x)for(let De=ie;De<ie+Ga;De++){const Re=x.cellEl[De];if(Re<0)break;const Ye=x.cellQ[De]*F;Ye>Y&&(Y=Ye,ee=x.els[Re].level)}const oe=j/yK+D.phase,ce=Math.floor(oe),xe=oe-ce,ae=zp(Math.min(xe,1-xe)/_K),se=Math.floor(vp(D.seed*97+ce*7919)*3);se!==D.kind&&Y<.02&&ae<.05&&(D.kind=se);const Ve=Math.max(ae*(1-Y),Y);if(!(Ve<.01))if(Y<.02){const De=K.inFrame[H]===1,Re=x?x.inFrame[H]===1:!1;De?a.fillStyle=Re?$:G:a.fillStyle=Re?q:W;const Ye=Math.max(De?X:0,Re?F:0);Fk(a,D.kind,D.x,D.y,D.size*Ve*(1-.2*Ye))}else{a.fillStyle=T(Y);const De=1+(CK[ee]-1)*Y;Fk(a,D.kind,D.x,D.y,D.size*Ve*De)}}};R();let A=0;if(c)_=k(-100),O(0);else{const j=performance.now(),F=K=>{O((K-j)/1e3),A=requestAnimationFrame(F)};A=requestAnimationFrame(F)}const I=new ResizeObserver(()=>{R(),c&&(_=k(-100),O(0))});I.observe(i),r.current=()=>{cancelAnimationFrame(A),I.disconnect(),e&&n(j=>j-1)}},[e,n]);return E.jsx("canvas",{ref:s,"aria-hidden":"true",className:`h-full w-full ${t}`.trim()})},IK=async(t=null)=>{if(t)return MK(t);let e;try{e=await fetch("/api/mcp/status")}catch{return{isOk:!1,unavailableReason:"rivet_unreachable",upstreamStatus:null}}if(e.status===404||!(e.headers.get("content-type")??"").toLowerCase().includes("application/json"))return yp();if(!e.ok)return{isOk:!1,unavailableReason:"rivet_unreachable",upstreamStatus:null};let r;try{r=await e.json()}catch{return yp()}const s=r.devServerHealth;return s?s.ownership==="none"?{isOk:!1,unavailableReason:"upstream_unreachable",upstreamStatus:null}:s.isReachable===!0?{isOk:!0,unavailableReason:"upstream_unreachable",upstreamStatus:null}:{isOk:!1,unavailableReason:s.reason==="rivet_unreachable"?"rivet_unreachable":"upstream_unreachable",upstreamStatus:null}:yp()},iA=async t=>{try{const e=await fetch(t);return{isOk:e.status!==502&&e.status!==503,unavailableReason:"upstream_unreachable",upstreamStatus:e.status}}catch{return{isOk:!1,unavailableReason:"rivet_unreachable",upstreamStatus:null}}},MK=t=>iA(t),yp=()=>iA("/"),C1=Es("usePreviewUpstreamHealth"),OK=500,LK=4e3,NK=15e3,DK=3,jK=(t,e={})=>{const n=v.useRef(null),r=v.useRef(null),s=e.probeMsWhileDown??OK,i=e.probeMsWhileUp??LK,a=e.firstUnreachableCaptureAfterMs??NK,c=e.rerunProbeImmediatelyOnVersion,u=e.probePath??null,f=e.skip??!1,h=v.useRef(e.onPersistentUpstreamServerErrors);h.current=e.onPersistentUpstreamServerErrors;const[p,m]=v.useState(t==="static"),[_,x]=v.useState(0),[y,w]=v.useState(null),[S,T]=v.useState(0),[P,k]=v.useState(!1),[R,L]=v.useState(!1),[O,A]=v.useState(t==="static"?null:"upstream_unreachable");return v.useEffect(()=>{if(t==="static"){m(!0),w(null),T(0),k(!1),L(!0),A(null);return}if(f){m(!1),w(null),T(0),k(!1),L(!0),A("upstream_unreachable"),n.current=null;return}let I=!0;const N=Date.now();w(N),T(0),k(!1),m(!1),L(!1),A("upstream_unreachable");const j={current:!1},F={current:!1},K={current:!1},X={current:null},W={current:!1},G={current:!1},q={current:0},$={current:!1},ne={current:null};let H=null;const D=()=>{K.current||(K.current=!0,I&&L(!0))},Y=()=>{H!==null&&(clearTimeout(H),H=null)},ee=(oe,ce)=>{Y(),H=setTimeout(ce,oe)},ie=async()=>{var Ye;if(!I)return;T(dt=>dt+1);const{isOk:oe,unavailableReason:ce,upstreamStatus:xe}=await IK(u);if(!I)return;D(),ne.current=xe;const ae=oe&&xe!==null&&xe>=500;ae&&G.current?q.current+=1:oe&&!ae&&(q.current=0);const se=q.current>=DK;if(se&&!$.current&&xe!==null&&($.current=!0,be==null||be.capture("preview_upstream_error_responses",{framework:t,upstream_status:xe,consecutive_count:q.current}),C1.warn(`Preview upstream is listening but has served ${q.current} consecutive ${xe} responses`),(Ye=h.current)==null||Ye.call(h,{upstreamStatus:xe,consecutiveCount:q.current})),oe&&!se){ae||(G.current=!0,$.current=!1);const dt=!W.current;W.current=!0,m(!0),A(null),X.current=null,F.current=!1,k(!1),j.current?dt&&(be==null||be.capture("preview_upstream_restored",{framework:t})):(j.current=!0,be==null||be.capture("preview_dev_server_ready",{framework:t,ready_after_ms:Date.now()-N})),ee(i,ie);return}const De=W.current;W.current=!1,m(!1),A(ce),X.current===null&&(X.current=Date.now(),F.current=!1,k(!1)),De&&(be==null||be.capture("preview_upstream_lost",{framework:t,upstream_status:xe}),x(dt=>dt+1),C1.warn("Preview upstream became unavailable after it was ready"));const Re=Date.now()-X.current;Re>=a&&!F.current&&(F.current=!0,k(!0),be==null||be.capture("preview_dev_server_unreachable",{framework:t,elapsed_ms:Re,upstream_status:ne.current}),C1.warn("Dev server did not become ready within timeout window")),ee(s,ie)};return n.current=()=>ee(0,ie),ee(0,ie),()=>{I=!1,n.current=null,Y()}},[t,s,i,a,u,f]),v.useEffect(()=>{var N;if(t==="static"||c===void 0)return;const I=r.current;r.current=c,I!==null&&I!==c&&((N=n.current)==null||N.call(n))},[t,c]),{isUpstreamReady:p,iframeRemountKey:_,probeStartedAt:y,probeAttemptCount:S,isFirstUnreachableWindowExceeded:P,initialProbeComplete:R,unavailableReason:O}};function FK(t){return t.enteringSplit&&t.isExistingSession&&t.hasActiveVariantProxy}const oA=t=>{var e;return t!=="embedded"||typeof window>"u"?"":((e=window.__RIVET_BOOTSTRAP__)==null?void 0:e.previewOrigin)??`${window.location.protocol}//localhost:${window.location.port}`},aA=({agentApplyMode:t,url:e})=>e.startsWith("/")?`${oA(t)}${e}`:e,VK="allow-scripts allow-same-origin allow-forms allow-popups allow-modals",$K=t=>VK,HK=Es("PreviewSurface"),Vk=(t,e)=>t==="about:blank"?"blank":t.includes("/api/variants/")?"static_artifact":e.kind==="variant"?"dev_server":"original",lA=({target:t,src:e,framework:n,remountKey:r})=>(et(p0),E.jsx("div",{className:"relative h-full w-full",children:E.jsx("iframe",{src:e,className:"h-full w-full border-none",title:"Project Preview",sandbox:$K(),onLoad:()=>{be==null||be.capture("preview_iframe_loaded",{framework:n,src:e}),t.kind==="variant"&&(be==null||be.capture("variants_panel.preview_displayed",{sessionId:t.sessionId,variantId:t.variantId,renderedTarget:"variant",iframeSrcKind:Vk(e,t),framework:n}))},onError:()=>{be==null||be.capture("preview_iframe_load_failed",{framework:n,src:e}),t.kind==="variant"&&(be==null||be.capture("variants_panel.preview_display_failed",{sessionId:t.sessionId,variantId:t.variantId,renderedTarget:"variant",iframeSrcKind:Vk(e,t),framework:n})),HK.warn("Preview iframe failed to load",{framework:n,src:e})}},r)})),zK="modulepreload",UK=function(t){return"/"+t},$k={},BK=function(e,n,r){let s=Promise.resolve();if(n&&n.length>0){let a=function(f){return Promise.all(f.map(h=>Promise.resolve(h).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),u=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));s=a(n.map(f=>{if(f=UK(f),f in $k)return;$k[f]=!0;const h=f.endsWith(".css"),p=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${p}`))return;const m=document.createElement("link");if(m.rel=h?"stylesheet":zK,h||(m.as="script"),m.crossOrigin="",m.href=f,u&&m.setAttribute("nonce",u),document.head.appendChild(m),h)return new Promise((_,x)=>{m.addEventListener("load",_),m.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${f}`)))})}))}function i(a){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=a,window.dispatchEvent(c),!c.defaultPrevented)throw a}return s.then(a=>{for(const c of a||[])c.status==="rejected"&&i(c.reason);return e().catch(i)})},WK=v.lazy(()=>BK(()=>Promise.resolve().then(()=>Sq),void 0)),GK={surface:"relative flex h-full w-full items-center justify-center bg-main px-6",overlay:"absolute inset-0 z-10 flex items-center justify-center bg-main/90 px-6",page:"relative flex h-screen w-full items-center justify-center bg-main px-6"},KK={sm:"text-lg font-semibold text-content",md:"text-2xl font-semibold text-content",lg:"text-3xl font-semibold text-content"},ZK={neutral:"rounded-md border border-divider bg-transparent px-5 py-2 text-sm font-medium text-content transition-colors hover:bg-surface-3",ghost:"rounded-md px-5 py-2 text-sm font-medium text-content-muted transition-colors hover:text-content"},Id=({backdrop:t,media:e,title:n,description:r,actions:s,tone:i="neutral",fill:a="surface",size:c="md",children:u,state:f,role:h="status",busy:p=!1,className:m=""})=>{const _=v.useCallback(y=>{y&&f&&(be==null||be.capture("status_surface_shown",{state:f,tone:i,fill:a}))},[f,i,a]),x=!!(e||n||r||u||s!=null&&s.length);return E.jsxs("div",{ref:_,className:`${GK[a]} ${m}`.trim(),role:h,"aria-live":"polite","aria-busy":p||void 0,"data-state":f,children:[t?E.jsx("div",{className:"absolute inset-0",children:t}):null,x?E.jsxs("div",{className:"relative z-10 flex max-w-sm flex-col items-center gap-5 text-center",children:[e,n?E.jsx("h2",{className:KK[c],children:n}):null,r?E.jsx("p",{className:"text-content-muted text-base leading-relaxed",children:r}):null,u,s!=null&&s.length?E.jsx("div",{className:"flex flex-row items-center gap-3",children:s.map(y=>E.jsx("button",{type:"button",onClick:y.onClick,className:ZK[y.variant??"neutral"],children:y.label},y.label))}):null]}):null]})},U_=({loader:t="coalesce",trackGlobalLoaderCount:e,size:n="lg",...r})=>t==="coalesce"?E.jsx(Id,{...r,size:n,busy:!0,backdrop:E.jsx(sA,{trackGlobalLoaderCount:e})}):t==="logo"?E.jsx(Id,{...r,size:n,busy:!0,backdrop:E.jsx(v.Suspense,{fallback:null,children:E.jsx(WK,{className:"absolute inset-0"})})}):E.jsx(Id,{...r,size:n,busy:!0,media:E.jsx(h0,{"aria-hidden":!0,className:"text-content h-8 w-8 shrink-0 animate-spin",weight:"bold"})}),cA=({icon:t,...e})=>E.jsx(Id,{...e,tone:"neutral",media:t?E.jsx("div",{className:"text-content-muted",children:t}):void 0}),Um=t=>E.jsx(Id,{...t,tone:"error",role:"alert"}),Hk="/static/",qK=t=>{try{return new URL(t,"http://localhost").pathname.endsWith(Hk)}catch{return t.endsWith(Hk)}},YK=({isInteractionDisabled:t=!1,framework:e,userPort:n})=>{var we;const r=et(I_),s=at(I_),i=et(jm),a=at(jm),c=et(Pf),u=et(p0),f=et(M_),h=et(O_),p=et(iR),m=et(oR),_=at(O_),x=et(lo),y=et(N_),w=at(M_),S=c.active&&c.projectContext.kind==="fresh",T=et(L_),P=c.active?c.variants.find(je=>je.workItemId===T&&(je.status==="pending"||je.status==="running"||je.status==="succeeded"&&!je.preview&&typeof je.port!="number"&&(!je.previewUnavailable||je.previewUnavailable.reason==="idle_timeout")))??null:null,k=c.active&&c.variants.some(je=>je.status==="pending"||je.status==="running"),R=S||k,L=c.active?c.variants.find(je=>{var ze;return je.workItemId===T&&je.status==="succeeded"&&!!je.previewUnavailable&&((ze=je.previewUnavailable)==null?void 0:ze.reason)!=="idle_timeout"})??null:null,O=e==="static"&&i!==null&&qK(i);v.useEffect(()=>{c.active||w(!1)},[c.active,w]);const A=v.useRef(!1);v.useEffect(()=>{const je=!!(x!=null&&x.left||x!=null&&x.right),ze=je&&!A.current;A.current=je;const it=c.active?c.sessionId:null;!it||!FK({enteringSplit:ze,isExistingSession:c.active&&c.projectContext.kind==="existing",hasActiveVariantProxy:f&&h!==null})||(w(!1),_(null),s(Tt=>Tt+1),fetch(`/api/variants/${encodeURIComponent(it)}/preview-port`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({variantId:null})}).catch(()=>{}))},[x,c,f,h,w,_,s]);const N=v.useMemo(()=>{var Xe;if(f||i&&!O||!c.active)return null;const{stage:je,variants:ze}=c,it=je==="ready"||je==="degraded",Tt=ze.some(It=>{var Un,In;return((Un=It.refinement)==null?void 0:Un.status)==="pending"||((In=It.refinement)==null?void 0:In.status)==="running"});if(!it&&!Tt)return null;const tt=ze.find(It=>{var Un;return It.status==="succeeded"&&((Un=It.preview)==null?void 0:Un.kind)==="static_artifact"});return((Xe=tt==null?void 0:tt.preview)==null?void 0:Xe.kind)==="static_artifact"?tt.preview.url:null},[O,i,f,c])??i,j=v.useMemo(()=>!c.active||!N?null:c.variants.find(je=>{var ze;return((ze=je.preview)==null?void 0:ze.kind)==="static_artifact"&&N.startsWith(je.preview.url)})??null,[N,c]),F=v.useMemo(()=>{if((y==null?void 0:y.previewKind)==="static")return{kind:"variant",sessionId:y.sessionId,variantId:y.variantId};if(!c.active)return Dm;if(j)return{kind:"variant",sessionId:c.sessionId,variantId:j.workItemId};if(N){const ze=N.match(/\/__rivet\/preview\/variant\/([^/]+)\/([^/?#]+)/),it=ze!=null&&ze[1]?decodeURIComponent(ze[1]):null,Tt=ze!=null&&ze[2]?decodeURIComponent(ze[2]):null;if(it===c.sessionId&&Tt&&c.variants.some(It=>It.workItemId===Tt))return{kind:"variant",sessionId:c.sessionId,variantId:Tt};const tt=N.match(/\/api\/variants\/[^/]+\/static\/([^/?#]+)/),Xe=tt!=null&&tt[1]?decodeURIComponent(tt[1]):null;if(Xe&&c.variants.some(It=>It.workItemId===Xe))return{kind:"variant",sessionId:c.sessionId,variantId:Xe}}const je=!!(x!=null&&x.left||x!=null&&x.right);return(!je||S)&&!N&&f&&h&&c.variants.some(ze=>ze.workItemId===h)?{kind:"variant",sessionId:c.sessionId,variantId:h}:(!je||S)&&!N&&T&&c.variants.some(ze=>ze.workItemId===T)?{kind:"variant",sessionId:c.sessionId,variantId:T}:Dm},[y,j,c,f,h,N,x,S,T]),K=v.useRef(null);v.useEffect(()=>{var Tt,tt;if(!j||((Tt=j.preview)==null?void 0:Tt.kind)!=="static_artifact"||((tt=j.refinement)==null?void 0:tt.status)!=="succeeded")return;const je=`${j.workItemId}:${j.refinement.workItemId}`;if(K.current===je)return;K.current=je;const ze=j.preview.url.includes("?")?"&":"?",it=`${j.preview.url}${ze}refinement=${encodeURIComponent(j.refinement.workItemId)}`;N!==it&&(a(it),s(Xe=>Xe+1))},[N,j,s,a,c]);const X=N!==null&&_G(N),W=N!==null&&!X||S&&!f&&!X,{isUpstreamReady:G,iframeRemountKey:q,probeAttemptCount:$,initialProbeComplete:ne}=jK(e,{rerunProbeImmediatelyOnVersion:r,probePath:X?N:null,skip:W}),[H,D]=v.useState(()=>p&&G?r:null),Y=v.useRef(null);v.useEffect(()=>{if(!p){Y.current=null,D(null);return}if(H===r){Y.current=null;return}const je=Y.current;if(!je||je.remountKey!==r){Y.current={remountKey:r,probeAttemptCount:$};return}G&&$>je.probeAttemptCount&&(Y.current=null,D(r))},[H,r,p,$,G]);const ie=N!==null&&!X||G,ce=m||p&&H!==r||p&&!ie,xe=`${q}:${r}`,ae=QR(window.location.pathname),se=e==="static"?`/static${ae??"/"}`:ae??"/",Ve=oA(u);let De=null;N&&(De=aA({agentApplyMode:u,url:N}));const Ye=P||ce?"about:blank":(X&&!ie?"about:blank":De)??(ie?`${Ve}${se}`:"about:blank"),dt=!!P||!!L||!ie&&ne;let Pt=null;return ce?Pt=E.jsx(U_,{fill:"overlay",loader:"coalesce",trackGlobalLoaderCount:!1,state:"preview_replay_boot"}):P?Pt=E.jsx(U_,{fill:"overlay",loader:"coalesce",trackGlobalLoaderCount:!1,state:"variant_building",children:E.jsx("span",{className:"sr-only",children:"Building your direction"})}):L?Pt=E.jsx(Um,{fill:"overlay",state:"preview_unavailable",title:"Preview couldn’t start",description:((we=L.previewUnavailable)==null?void 0:we.reason)==="missing_dev_script"?"This project has no dev script for Rivet to run.":"Its preview server didn’t start.",actions:[{label:"Reload",onClick:()=>window.location.reload()}]}):dt&&(Pt=R?E.jsx(cA,{fill:"overlay",state:"preview_no_selection",title:"Nothing to preview yet",description:"Pick a direction from the panel."}):E.jsx(Um,{fill:"overlay",state:"preview_offline",title:"Preview isn't connected",description:"Rivet lost connection to your project.",actions:[{label:"Reload",onClick:()=>window.location.reload()}]})),E.jsxs("div",{className:"relative h-full w-full",children:[Pt,E.jsx(lA,{target:F,src:Ye,framework:e,remountKey:xe})]})};function zk({side:t,sessionId:e,variantId:n,url:r,label:s,source:i,isFallback:a=!1}){var P;const c=et(lo),u=at(lo),f=r0(),h=et(Pf),p=et(p0),m=v.useRef(!1),_=v.useCallback(()=>{m.current||(m.current=!0,of({source:i,sessionId:e,variantId:n}))},[i,e,n]),x=v.useCallback(()=>{if(a){u(null);const O=zm("ended",c);f==null||f.capture(O.event,O.properties);return}_();const k={...c};delete k[t];const R=k.left||k.right?k:null;u(R);const L=zm(R?"updated":"ended",R??c);f==null||f.capture(L.event,L.properties)},[a,f,u,t,c,_]),y=v.useMemo(()=>({kind:"variant",sessionId:e,variantId:n}),[e,n]),w=v.useMemo(()=>!h.active||h.sessionId!==e?null:h.variants.find(k=>k.workItemId===n)??null,[e,n,h]),S=v.useMemo(()=>{var R,L;let k=r;if(((R=w==null?void 0:w.preview)==null?void 0:R.kind)==="static_artifact"&&((L=w.refinement)==null?void 0:L.status)==="succeeded"){const O=w.preview.url.includes("?")?"&":"?";k=`${w.preview.url}${O}refinement=${encodeURIComponent(w.refinement.workItemId)}`}return aA({agentApplyMode:p,url:k})},[p,w,r]),T=((P=w==null?void 0:w.refinement)==null?void 0:P.status)==="succeeded"?`${n}:${w.refinement.workItemId}`:n;return E.jsxs("div",{className:"variant-split-secondary","data-cy":"variant-split-pane","data-variant-id":n,children:[E.jsxs("div",{className:"variant-split-secondary-toolbar",children:[E.jsx("span",{className:"variant-split-secondary-label",title:s,children:s}),E.jsx(to,{label:"Collapse",children:E.jsx("button",{type:"button",className:"variant-split-secondary-close",onClick:x,"aria-label":"Collapse split view",children:E.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",focusable:"false",children:E.jsx("path",{d:"M2.5 2.5 L9.5 9.5 M9.5 2.5 L2.5 9.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})})})]}),E.jsx("div",{className:"variant-split-secondary-body relative min-h-0 flex-1",children:E.jsx(lA,{target:y,src:S,framework:"static",remountKey:T})})]})}const Uk=240;function XK(){const t=et(ef),e=et(Ax),n=v.useRef(null);return v.useEffect(()=>{if(!t||!e||!n.current)return;const r=e.x-Uk/2,s=e.y-22;n.current.style.transform=`translate3d(${r}px, ${s}px, 0)`},[t,e]),!t||!e?null:E.jsx("div",{ref:n,"aria-hidden":"true",className:"variant-drag-ghost",style:{width:Uk},children:E.jsxs("div",{className:"variant-drag-ghost-body",children:[E.jsxs("div",{className:"variant-drag-ghost-row",children:[E.jsx("div",{className:"variant-drag-ghost-title",children:t.label}),t.runLabel?E.jsx("div",{className:"variant-drag-ghost-tag",style:Z5(t.runLabel),children:t.runLabel}):null]}),t.description?E.jsx("div",{className:"variant-drag-ghost-desc",children:t.description}):null]})})}function QK(){const t=et(ef),e=et(Ax),n=et(lo),r=at(ef),s=at(lo),i=r0(),a=v.useRef(null),[c,u]=v.useState(null),[f,h]=v.useState("hidden");v.useEffect(()=>{if(!t){h("hidden"),u(null);return}const _=requestAnimationFrame(()=>h("visible"));return()=>cancelAnimationFrame(_)},[t]);const p=v.useCallback((_,x)=>{const y=a.current;if(!y)return null;const w=y.getBoundingClientRect();return _<w.left||_>w.right||x<w.top||x>w.bottom?null:_<(w.left+w.right)/2?"left":"right"},[]);if(v.useEffect(()=>{if(!t||!e)return;const _=p(e.x,e.y);u(x=>x===_?x:_)},[t,e,p]),v.useEffect(()=>{if(!t)return;const _=x=>{const y=p(x.clientX,x.clientY);if(y&&t.url){const w={sessionId:t.sessionId,variantId:t.variantId,label:t.label,url:t.url,source:t.source},S=n==null?void 0:n[y];S&&(S.sessionId!==w.sessionId||S.variantId!==w.variantId)&&of(S);const T={...n??{},[y]:w};s(T);const P=zm(n?"updated":"started",T);i==null||i.capture(P.event,P.properties),h("exiting"),window.setTimeout(()=>r(null),220)}else of(t),h("exiting"),window.setTimeout(()=>r(null),220)};return window.addEventListener("pointerup",_),window.addEventListener("pointercancel",_),()=>{window.removeEventListener("pointerup",_),window.removeEventListener("pointercancel",_)}},[t,p,i,r,s,n]),!t)return null;const m=["variant-drop-zones",f==="visible"&&"is-visible",f==="exiting"&&"is-exiting"].filter(Boolean).join(" ");return E.jsxs("div",{ref:a,className:m,"aria-hidden":"true",children:[E.jsx(Bk,{side:"left",hovered:c==="left",canDrop:!!t.url,label:t.label}),E.jsx(Bk,{side:"right",hovered:c==="right",canDrop:!!t.url,label:t.label})]})}function Bk({side:t,hovered:e,canDrop:n,label:r}){return E.jsxs("div",{className:["variant-drop-zone",`is-${t}`,e&&"is-hover",!n&&"is-disabled"].filter(Boolean).join(" "),children:[E.jsxs("div",{className:"variant-drop-zone-inner",children:[E.jsx("div",{className:`variant-drop-zone-icon is-${t}`}),E.jsx("div",{className:"variant-drop-zone-caption",children:n?`Add ${t} split`:"Split unavailable for this direction"})]}),E.jsx("div",{className:"variant-drop-zone-preview","aria-hidden":"true",children:E.jsx("div",{className:"variant-drop-zone-preview-label",children:r})}),E.jsx("div",{className:"variant-drop-zone-border"})]})}const uA=(t,e,n)=>{var i,a;if(!t.active||t.sessionId!==e)return null;const r=t.variants.find(c=>c.workItemId===n);if(((i=r==null?void 0:r.preview)==null?void 0:i.kind)!=="static_artifact")return null;if(((a=r.refinement)==null?void 0:a.status)!=="succeeded")return r.preview.url;const s=r.preview.url.includes("?")?"&":"?";return`${r.preview.url}${s}refinement=${encodeURIComponent(r.refinement.workItemId)}`},Wk=(t,e)=>{if(!t)return;const n=uA(e,t.sessionId,t.variantId);return!n||n===t.url?t:{...t,url:n}},JK=()=>E.jsx("div",{"data-testid":"preview-boot-skeleton",role:"status","aria-busy":"true","aria-label":"Loading preview",className:"bg-main flex h-full min-h-0 w-full flex-1 flex-col p-3",children:E.jsx("div",{className:"border-main-border relative min-h-0 flex-1 overflow-hidden rounded-lg border",children:E.jsx(sA,{trackGlobalLoaderCount:!1})})}),eZ=({isLoading:t=!1,isInteractionDisabled:e=!1})=>{const{config:n,fetchConfig:r,isLoading:s,error:i}=gK();return v.useEffect(()=>{r().catch(a=>{be==null||be.capture("preview_config_load_failed",{message:a instanceof Error?a.message:"unknown_error",attempts:Nk})})},[r]),s?E.jsx(JK,{}):i||!n?E.jsx(Um,{fill:"surface",size:"sm",state:"preview_config_error",title:"Couldn't load preview",description:"We couldn't load the preview configuration.",actions:[{label:"Retry",onClick:()=>{be==null||be.capture("preview_config_retry_clicked"),r().catch(a=>{be==null||be.capture("preview_config_load_failed",{message:a instanceof Error?a.message:"unknown_error",attempts:Nk})})}}]}):E.jsx(tZ,{isLoading:t,isInteractionDisabled:e,framework:n.framework,userPort:n.userPort})};function tZ(t){const e=et(lo),n=et(ef),r=et(Pf),s=et(jm),i=e==null?void 0:e.left,a=e==null?void 0:e.right,c=v.useMemo(()=>{var R,L;if(!r.active||r.projectContext.kind!=="fresh"||!(!!i!=!!a))return;const y=(R=i??a)==null?void 0:R.variantId,w=r.variants.filter(O=>{var A;return O.status==="succeeded"&&((A=O.preview)==null?void 0:A.kind)==="static_artifact"&&O.workItemId!==y}),S=s==null?void 0:s.replace(/[?&]refinement=[^&]*$/,""),P=w.find(O=>{var A;return((A=O.preview)==null?void 0:A.kind)==="static_artifact"&&O.preview.url===S})??w[0];if(((L=P==null?void 0:P.preview)==null?void 0:L.kind)!=="static_artifact")return;const k=uA(r,r.sessionId,P.workItemId);if(k)return{sessionId:r.sessionId,variantId:P.workItemId,label:P.label,url:k,source:"live"}},[r,i,a,s]),u=Wk(i,r)??(a?c:void 0),f=Wk(a,r)??(i?c:void 0),h=!i&&!!u,p=!a&&!!f,m=!!(u||f),_=E.jsx(YK,{isInteractionDisabled:t.isInteractionDisabled,framework:t.framework,userPort:t.userPort});return E.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 flex-col",children:E.jsxs("div",{className:`variant-preview-region relative flex h-full min-h-0 w-full flex-1 flex-col ${n?"is-dragging":""} ${m?"is-split":""}`,children:[E.jsxs("div",{className:"variant-preview-row flex h-full min-h-0 w-full flex-1",children:[u&&E.jsx(zk,{side:"left",sessionId:u.sessionId,variantId:u.variantId,url:u.url,label:u.label,source:u.source,isFallback:h},`left-${u.sessionId}:${u.variantId}:${u.url}`),!(u&&f)&&E.jsx("div",{className:"variant-preview-primary flex h-full min-h-0 flex-1 flex-col",children:_}),f&&E.jsx(zk,{side:"right",sessionId:f.sessionId,variantId:f.variantId,url:f.url,label:f.label,source:f.source,isFallback:p},`right-${f.sessionId}:${f.variantId}:${f.url}`)]}),E.jsx("div",{className:"variant-preview-atmosphere","aria-hidden":"true"}),E.jsx(QK,{}),E.jsx(XK,{})]})})}function Gi(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function dA(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}/*!
114
+ ${s}`:s},LG=({rows:t,activeVariantId:e,activePastKey:n,isOriginalSelected:r,busy:s,editingKey:i,onSelectActive:a,onSelectPast:c,onSelectOriginal:u,onActivePointerDown:f,onPastPointerDown:h,onHover:p,onRemove:m,onRemovePast:_,onStartRename:x,onCommitRename:y,onCancelRename:w,onCopyVariantContext:S,activeSessionId:T,projectPath:P})=>{const k=v.useRef(null),{activeIndex:R,itemRects:L,sessionRef:O,handlers:A,registerItem:I}=q5(k),N=(s==null?void 0:s.kind)==="switch",j=R!==null?L[R]:null;return E.jsxs("div",{ref:k,className:"relative",onMouseEnter:A.onMouseEnter,onMouseMove:A.onMouseMove,onMouseLeave:A.onMouseLeave,children:[E.jsx(ro,{children:j&&E.jsx(xl.div,{className:"bg-hover pointer-events-none absolute z-0 rounded-md",initial:{opacity:0,top:j.top,left:j.left,width:j.width,height:j.height},animate:{opacity:1,top:j.top,left:j.left,width:j.width,height:j.height},exit:{opacity:0,transition:{duration:.06}},transition:{...Yd.fast,opacity:{duration:.08}}},O.current)}),E.jsx("ul",{className:"relative",children:t.map((F,K)=>{const X=RG(F);let W=!1;return F.kind==="active"?W=F.variant.workItemId===e:F.kind==="past"?W=`${F.entry.sessionId}:${F.entry.variantId}`===n:W=r,E.jsx(NG,{rowKey:X,row:F,index:K,isSelected:W,isEditing:i===X,isSwitchInFlight:N,busy:s,registerItem:I,onSelectActive:a,onSelectPast:c,onSelectOriginal:u,onActivePointerDown:f,onPastPointerDown:h,onHover:p,onRemove:m,onRemovePast:_,onStartRename:x,onCommitRename:y,onCancelRename:w,onCopyVariantContext:S,activeSessionId:T,projectPath:P},X)})})]})},NG=({rowKey:t,row:e,index:n,isSelected:r,isEditing:s,isSwitchInFlight:i,busy:a,registerItem:c,onSelectActive:u,onSelectPast:f,onSelectOriginal:h,onActivePointerDown:p,onPastPointerDown:m,onHover:_,onRemove:x,onRemovePast:y,onStartRename:w,onCommitRename:S,onCancelRename:T,onCopyVariantContext:P,activeSessionId:k,projectPath:R})=>{var xe,ae;const L=v.useRef(null);UU(c,n,L);const O=e.kind==="active",A=e.kind==="original",I=e.kind==="active"?e.variant:null,N=e.kind==="past"?e.entry:null,j=O?I.status==="succeeded":!0,F=O?nl(I):!0,K=O?eA(I):!1,X=O&&(I.status==="pending"||I.status==="running"),W=O?j&&(F||K)||X:!0,G=O&&I.status==="failed",q=O&&I.status==="cancelled",$=O&&(!W||i),ne=O&&(a==null?void 0:a.kind)==="remove"&&a.variantId===I.workItemId,H=O&&(((xe=I.refinement)==null?void 0:xe.status)==="pending"||((ae=I.refinement)==null?void 0:ae.status)==="running");let D=Gx;O?D=I.label||`Direction ${n+1}`:N&&(D=N.label.trim()||"Untitled direction");let Y;O?Y=I.runLabel:N&&(Y=N.runLabel);let ee=Kx;O?ee=I.description:N&&(ee=N.brief);const ie=ee?IG(ee):null,oe=MG(e,k),ce=oe?"Copy variant reference":"Copy description";return s?E.jsx("li",{ref:L,"data-proximity-index":n,className:"group relative z-10",children:E.jsx("div",{className:"bg-main-input flex w-full items-start gap-2 rounded-md px-3 py-2",children:E.jsxs("span",{className:"min-w-0 flex-1",children:[E.jsx(DG,{initial:D,onCommit:se=>S(e,se),onCancel:T}),ie&&E.jsx("span",{className:"text-content-muted mt-1 line-clamp-2 block text-xs leading-snug",children:ie})]})})}):E.jsxs("li",{ref:L,"data-proximity-index":n,className:"group relative z-10",children:[E.jsx("div",{role:"button",tabIndex:W?0:-1,"data-variant-id":O?I.workItemId:void 0,"data-variant-key":t,onClick:()=>{if($)return;const se=window.getSelection();se&&!se.isCollapsed||(e.kind==="active"?u(e.variant):e.kind==="past"?f(e.entry):h())},onKeyDown:se=>{$||(se.key==="Enter"||se.key===" ")&&(se.preventDefault(),se.stopPropagation(),e.kind==="active"?u(e.variant):e.kind==="past"?f(e.entry):h())},onPointerDown:se=>{$||(e.kind==="active"?j&&p(e.variant.workItemId,se):e.kind==="past"&&m(e.entry,se))},"aria-pressed":W?r:void 0,"aria-disabled":O?!W:void 0,"aria-busy":X||H,onMouseEnter:O?()=>_(I.workItemId):void 0,onMouseLeave:O?()=>_(null):void 0,className:fr("focus-visible:ring-content-muted/40 flex w-full items-start gap-2 rounded-md px-3 py-2 text-left transition-colors focus:outline-none focus-visible:ring-1",r&&"bg-main-input ring-content-muted/40 ring-1 ring-inset",j&&F&&"cursor-grab active:cursor-grabbing",(X||K)&&"cursor-pointer",!j&&!X&&!K&&"cursor-not-allowed opacity-60",$&&"cursor-not-allowed opacity-50"),style:j?{touchAction:"none"}:void 0,children:E.jsxs("span",{className:"min-w-0 flex-1",children:[E.jsxs("span",{className:"flex items-center gap-2",children:[(X||H)&&E.jsx(Ix,{className:"text-content-muted shrink-0 text-sm","data-testid":H&&!X?"variant-refining":void 0}),E.jsx(to,{label:"Double-click to rename",disabled:A,children:E.jsx("span",{onDoubleClick:se=>{se.stopPropagation(),A||w(t)},className:fr("min-w-0 flex-1 truncate text-sm font-medium select-text",A?"cursor-default":"cursor-text",j||r?"text-content":"text-content-muted"),children:D})}),G&&E.jsx(to,{label:I.errorMessage??I.errorCode??"Failed",disabled:!I.errorMessage&&!I.errorCode,children:E.jsx("span",{className:"shrink-0",children:E.jsx(Pk,{label:"Failed"})})}),q&&E.jsx(Pk,{label:"Cancelled"}),Y&&E.jsx("span",{className:"ml-auto max-w-[8rem] shrink-0 truncate rounded px-1.5 py-0.5 text-[10px] font-medium opacity-100 transition-opacity duration-150 group-hover:opacity-0 group-has-[:focus-visible]:opacity-0",style:Z5(Y),children:Y})]}),ie&&E.jsx("span",{className:"text-content-muted mt-0.5 line-clamp-2 block cursor-text text-xs leading-snug select-text",children:ie})]})}),E.jsxs("div",{className:fr("absolute top-1.5 right-2 flex items-center gap-0.5 transition-opacity duration-150","pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 has-[:focus-visible]:pointer-events-auto has-[:focus-visible]:opacity-100"),children:[ee||oe?E.jsx(to,{label:ce,children:E.jsx("button",{type:"button","aria-label":ce,onClick:se=>{se.stopPropagation(),P(OG({label:D,description:ee,reference:oe,projectPath:R}))},onPointerDown:se=>se.stopPropagation(),className:"text-content-muted hover:bg-main-hover hover:text-content focus-visible:ring-content-muted/40 flex h-6 w-6 items-center justify-center rounded focus:outline-none focus-visible:ring-1",children:E.jsx(qd,{size:13,weight:"bold"})})}):null,!A&&E.jsx(to,{label:"Rename",children:E.jsx("button",{type:"button","aria-label":"Rename direction",onClick:se=>{se.stopPropagation(),w(t)},onPointerDown:se=>se.stopPropagation(),className:"text-content-muted hover:bg-main-hover hover:text-content focus-visible:ring-content-muted/40 flex h-6 w-6 items-center justify-center rounded focus:outline-none focus-visible:ring-1",children:E.jsx(Kz,{size:13,weight:"bold"})})}),!A&&E.jsx(to,{label:"Remove",children:E.jsx("button",{type:"button","data-variant-remove-id":e.kind==="active"?e.variant.workItemId:void 0,"aria-label":"Remove direction",disabled:ne,onClick:se=>{se.stopPropagation(),e.kind==="active"?x(e.variant):y(e.entry)},onPointerDown:se=>se.stopPropagation(),className:"text-content-muted hover:bg-main-hover hover:text-content focus-visible:ring-content-muted/40 ml-1 flex h-6 w-6 items-center justify-center rounded focus:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50",children:E.jsx(Yz,{size:13,weight:"bold"})})})]})]})},DG=({initial:t,onCommit:e,onCancel:n})=>{const[r,s]=v.useState(t),i=v.useRef(!1),a=v.useCallback(u=>{u&&(u.focus(),u.select())},[]),c=u=>{i.current||(i.current=!0,u?e(r):n())};return E.jsx("input",{ref:a,type:"text",value:r,maxLength:120,"aria-label":"Rename direction",onChange:u=>s(u.target.value),onKeyDown:u=>{u.stopPropagation(),u.key==="Enter"?(u.preventDefault(),c(!0)):u.key==="Escape"&&(u.preventDefault(),c(!1))},onBlur:()=>c(!0),onClick:u=>u.stopPropagation(),onPointerDown:u=>u.stopPropagation(),className:"border-content-muted/40 bg-main text-content focus:ring-content-muted/50 w-full rounded border px-1.5 py-0.5 text-sm font-medium focus:ring-1 focus:outline-none"})},Pk=({label:t})=>E.jsx("span",{className:"bg-main-input text-content-muted shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium tracking-wide uppercase",children:t}),jG=({entry:t,deploying:e,deployedUrl:n,onDeploy:r,isDeployDisabled:s=!1})=>{const a=e?"Deploying…":n?"Copy link":"Share";return E.jsxs("div",{className:"border-main-border bg-main-light flex shrink-0 items-center justify-between gap-3 border-t px-3 pt-2 pb-4",children:[E.jsxs("div",{className:"min-w-0",children:[E.jsx("div",{className:"text-content truncate text-sm font-medium",children:t.label.trim()||"Untitled direction"}),n?E.jsx("div",{className:"text-content-muted text-[11px]",children:"Deployed — share link ready"}):null]}),E.jsxs("button",{type:"button",onClick:()=>r(t),disabled:e||s,title:n?`Copy share link (${n})`:"Deploy this direction and get a public link to share",className:"border-main-border text-content hover:bg-main-input flex shrink-0 items-center gap-1 rounded-md border px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:[n&&!e?E.jsx(qd,{size:12,weight:"bold"}):null,a]})]})},FG={agent_browser:"Browser extracted",cache:"Cached",static:"Bundled catalog",manual:"Manual"},VG={design_context:"DESIGN.md",source_context:"Source",qa_report:"QA",asset:"Asset"},$G=({artifacts:t})=>{const[e,n]=v.useState(null),r=v.useMemo(()=>e&&t.some(i=>i.id===e)?e:null,[t,e]);if(t.length===0)return null;const s=i=>{n(a=>a===i?null:i)};return E.jsxs("section",{"aria-label":"Directions session artifacts",className:"mt-4",children:[E.jsx("div",{className:"flex shrink-0 items-center px-3 py-2",children:E.jsx("span",{className:"text-content truncate text-sm font-medium",children:"Artifacts"})}),E.jsx("ul",{className:"mt-2 space-y-1 px-1",children:t.map(i=>E.jsx(HG,{artifact:i,isExpanded:i.id===r,onToggle:()=>s(i.id)},i.id))})]})},HG=({artifact:t,isExpanded:e,onToggle:n})=>{const r=VG[t.kind],s=t.source?FG[t.source]:null,i=[t.kind==="design_context"?null:s,t.summary].filter(Boolean).join(" · "),a=t.kind==="design_context"&&!!t.viewUrl,c=`${e?"Hide":"View"} ${r} artifact${t.label?`: ${t.label}`:""}`;return a?E.jsx("li",{className:"border-main-border rounded-md border",children:E.jsxs("div",{className:"flex w-full items-center justify-between gap-2 px-3 py-2 text-left text-xs",children:[E.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[E.jsxs("span",{className:"flex items-center gap-2",children:[E.jsx("span",{className:"border-content-muted/30 bg-main-input text-content-muted shrink-0 rounded-full border px-2 py-0.5 text-[9px] font-semibold tracking-wide uppercase",children:r}),E.jsx("span",{className:"text-content truncate text-xs font-medium",children:t.label})]}),i?E.jsx("span",{className:"text-content-muted mt-0.5 truncate text-[11px]",children:i}):null]}),E.jsx("a",{href:t.viewUrl,target:"_blank",rel:"noreferrer",onClick:()=>{be.capture("visual_editor_design_context_opened",{context_kind:"design_system",artifact_source:t.source})},"aria-label":`Open ${r} artifact${t.label?`: ${t.label}`:""}`,className:"text-content-muted hover:bg-main-input hover:text-content focus-visible:ring-content-muted/40 shrink-0 rounded p-1 transition-colors focus:outline-none focus-visible:ring-1",children:E.jsx(zz,{className:"h-3.5 w-3.5",weight:"bold"})})]})}):E.jsxs("li",{className:"border-main-border rounded-md border",children:[E.jsxs("button",{type:"button",onClick:n,"aria-expanded":e,"aria-label":c,className:"hover:bg-main-input flex w-full items-center justify-between gap-2 px-3 py-2 text-left text-xs transition-colors",children:[E.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[E.jsxs("span",{className:"flex items-center gap-2",children:[E.jsx("span",{className:"text-content-muted text-[10px] font-semibold tracking-wide uppercase",children:r}),E.jsx("span",{className:"text-content truncate text-xs font-medium",children:t.label})]}),i?E.jsx("span",{className:"text-content-muted mt-0.5 truncate text-[11px]",children:i}):null]}),E.jsx("span",{className:"text-content-muted shrink-0 text-[11px]",children:e?"Hide":"View"})]}),e?E.jsx("div",{className:"border-main-border bg-main-light border-t px-3 py-2",children:E.jsx(zG,{artifact:t})}):null]})},zG=({artifact:t})=>E.jsxs("div",{className:"text-content-muted space-y-1 text-[11px]",children:[t.summary?E.jsx("p",{children:t.summary}):null,t.path?E.jsxs("p",{children:["Stored at ",t.path]}):null,!t.summary&&!t.path?E.jsx("p",{children:"No inline content available for this artifact."}):null]}),UG=({selectedVariant:t,busy:e,onSend:n,onDeploy:r,onDeployCanvas:s,canDeploy:i,canDeployCanvas:a,canSendToAgent:c,canvasVariantCount:u,canvasDeployedUrl:f,deployedUrl:h})=>{var O,A,I,N;const p=t?((A=(O=t.actions)==null?void 0:O.commit)==null?void 0:A.enabled)??t.status==="succeeded":!1,m=p&&e===null,_=(e==null?void 0:e.kind)==="commit"&&e.variantId===(t==null?void 0:t.workItemId),x=(e==null?void 0:e.kind)==="deploy"&&e.variantId===(t==null?void 0:t.workItemId),y=(e==null?void 0:e.kind)==="deploy-canvas",w=!i||!p||e!==null,S=a&&u>0,P=x?"Deploying…":h?"Copy link":"Share",R=y?"Sharing…":f?"Copy canvas link":"Share canvas",L=_?"Applying…":"Apply to project";return E.jsxs("div",{className:"border-main-border bg-main-light flex shrink-0 items-center justify-between gap-3 border-t px-3 pt-2 pb-4",children:[E.jsx("div",{className:"min-w-0",children:t?E.jsxs(E.Fragment,{children:[E.jsx("div",{className:"text-content truncate text-sm font-medium",children:t.label.trim()||"Untitled direction"}),h?E.jsx("div",{className:"text-content-muted text-[11px]",children:"Deployed — share link ready"}):null]}):null}),E.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[E.jsx(FR,{primaryLabel:P,primaryIcon:h&&!x?qd:void 0,primaryAction:()=>{t&&r(t)},isDisabled:w,isDropdownDisabled:e!==null,isLoading:x,loadingLabel:"Deploying…",dropdownAriaLabel:"More share actions",dropdownItems:S?[{label:R,icon:f&&!y?qd:void 0,onClick:s,isDisabled:e!==null}]:[]}),c?E.jsx("button",{type:"button",onClick:()=>{t&&n(t)},disabled:!m,title:(N=(I=t==null?void 0:t.actions)==null?void 0:I.commit)==null?void 0:N.reason,className:"bg-secondary text-secondary-foreground hover:bg-accent rounded-md px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:L}):null]})]})},tA=()=>E.jsx("div",{"data-testid":"direction-skeleton-row","aria-hidden":"true",className:"flex w-full items-start rounded-md px-3 py-2",children:E.jsxs("span",{className:"min-w-0 flex-1",children:[E.jsxs("span",{className:"flex items-center gap-2",children:[E.jsx(Ix,{className:"text-content-muted shrink-0 text-sm"}),E.jsx("span",{className:"bg-muted-foreground/15 h-3.5 w-28 animate-pulse rounded"})]}),E.jsx("span",{className:"mt-1.5 flex",children:E.jsx("span",{className:"bg-muted-foreground/10 h-2.5 w-full max-w-[14rem] animate-pulse rounded"})})]})}),BG=({groups:t})=>E.jsx("div",{className:"space-y-0.5",children:t.flatMap(e=>Array.from({length:Math.max(1,e.count)}).map((n,r)=>E.jsx(tA,{},`${e.requestId}-${r}`)))}),WG=()=>E.jsx("div",{"data-testid":"direction-boot-skeletons",className:"space-y-0.5",children:Array.from({length:3}).map((t,e)=>E.jsx(tA,{},e))}),GG=()=>E.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-center",children:[E.jsx("div",{className:"text-content text-sm",children:"No directions yet"}),E.jsx("div",{className:"text-content-muted text-xs",children:"They’ll appear here as they generate."})]}),Tk="Try different ways to create a dropdown that feels fluid and dynamic",KG=({isMCPSession:t=!1,mcpEditor:e=null})=>{const[n,r]=v.useState(!1),s=mB(e),i=t?s:"your coding agent",a=()=>{navigator.clipboard.writeText(Tk).then(()=>{r(!0),setTimeout(()=>r(!1),2e3)})};return E.jsxs("div",{className:"flex flex-col items-start gap-3 px-2 py-2",children:[E.jsx("p",{className:"text-content text-sm font-medium",children:"Create your first direction"}),E.jsxs("p",{className:"text-content-muted text-xs",children:["Use ",i," to generate directions."]}),E.jsxs("div",{className:"w-full",children:[E.jsx("p",{className:"text-content-muted mb-2 text-xs",children:"Here's a sample prompt to use:"}),E.jsxs("div",{className:"border-main-border bg-main-input relative rounded-md border px-3 py-2.5 pr-8",children:[E.jsxs("p",{className:"text-content-muted text-xs leading-snug",children:["“",Tk,"”"]}),E.jsx("button",{type:"button",onClick:a,className:"text-content-muted hover:bg-main-border hover:text-content absolute top-2 right-2 rounded p-0.5 transition-colors",title:"Copy to clipboard",children:n?E.jsx(x5,{className:"h-3.5 w-3.5 text-emerald-500",weight:"bold"}):E.jsx(qd,{className:"h-3.5 w-3.5",weight:"bold"})})]})]})]})},ZG=({onClose:t})=>{const e=et(nR);return t?E.jsxs("div",{className:"z-10 flex flex-shrink-0 items-center justify-between gap-2 border-b border-main-border bg-main-light px-2.5 py-2.5",children:[e?E.jsx("span",{className:"text-content min-w-0 truncate text-sm font-medium",title:e,children:e}):E.jsx("span",{}),E.jsx(to,{label:"Close panel",side:"bottom",children:E.jsx("button",{onClick:t,className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded p-1 text-content-subtle transition-colors hover:bg-main-input hover:text-content",children:E.jsx(Zz,{className:"h-4 w-4",weight:"bold"})})})]}):null},qG='[data-menu-item]:not([disabled]):not([aria-disabled="true"])',YG=({itemSelector:t=qG,loop:e=!1}={})=>{const n=v.useRef(null),r=v.useRef(null),s=v.useCallback(a=>{var c;n.current=a,a?r.current=hB():((c=r.current)==null||c.call(r),r.current=null)},[]),i=v.useCallback(a=>{var x;const{key:c}=a;if(c!=="ArrowDown"&&c!=="ArrowUp"&&c!=="Home"&&c!=="End")return;const u=n.current;if(!u)return;const f=Array.from(u.querySelectorAll(t));if(f.length===0)return;a.preventDefault(),a.stopPropagation();const h=f.indexOf(document.activeElement),p=f.length-1,m=y=>{if(h===-1)return y===1?0:p;const w=h+y;return e?(w+f.length)%f.length:Math.min(Math.max(w,0),p)};let _;c==="Home"?_=0:c==="End"?_=p:c==="ArrowDown"?_=m(1):_=m(-1),(x=f[_])==null||x.focus()},[t,e]);return{containerRef:s,onKeyDown:i}},Rk="/assets/arena-Db0j1set.png",XG=Es("useIntegrations"),b1=["integrations"],QG="rivet:connect-result",JG=t=>typeof t=="object"&&t!==null&&t.type===QG,eK=nt(null),Ak=async()=>{const t=await fetch("/api/integrations");if(!t.ok)throw new Error(`Failed to load integrations (${t.status})`);return(await t.json()).integrations??[]},tK=()=>{const t=Z8(),[e,n]=HP(eK),r=ry({queryKey:b1,queryFn:Ak,staleTime:1e4}),s=v.useCallback(async()=>(await t.invalidateQueries({queryKey:b1,refetchType:"none"}),t.fetchQuery({queryKey:b1,queryFn:Ak})),[t]),i=v.useCallback(async c=>{const u=window.open("","_blank","width=560,height=720");if(!u)throw new Error("Popup blocked. Allow popups to connect.");n(c);try{const f=await fetch(`/api/integrations/${c}/connect`,{method:"POST"}),h=await f.json().catch(()=>({}));if(!f.ok||!h.authUrl)throw u.close(),new Error(h.error||`Could not connect ${c}`);return u.location.href=h.authUrl,await new Promise(p=>{let m=!1,_=null;const x=async(w,S=!1)=>{if(!m){m=!0,window.removeEventListener("message",y),_&&clearInterval(_);try{const P=(await s()).some(k=>k.provider===c&&k.status==="connected");p(S&&P?"connected":w)}catch{p(w)}}},y=w=>{if(JG(w.data)&&w.data.provider===c){if(w.data.status==="error"){XG.warn(`Connect failed for ${c}:`,w.data.message),x("failed");return}x("connected")}};window.addEventListener("message",y),_=setInterval(()=>{u.closed&&x("closed",!0)},500)})}finally{n(null)}},[s,n]),a=v.useCallback(async c=>{n(c);try{const u=await fetch(`/api/integrations/${c}`,{method:"DELETE"});if(!u.ok){const f=await u.json().catch(()=>({}));throw new Error(f.error||`Could not disconnect ${c}`)}await s()}finally{n(null)}},[s,n]);return{integrations:r.data??[],isLoading:r.isPending,error:r.error instanceof Error?r.error.message:null,pendingProvider:e,connect:i,disconnect:a,refetch:s}},Ic=({onClick:t,title:e,shortcut:n,children:r,disabled:s=!1,className:i="",type:a="button","data-cy":c})=>{const u=E.jsx("button",{onClick:t,disabled:s,className:i,type:a,"data-cy":c,children:r});return e?E.jsx(Wx,{content:E.jsxs("div",{className:"flex flex-row items-center gap-2",children:[E.jsx("span",{children:e}),n?E.jsx("span",{className:"rounded bg-white/15 px-1.5 py-0.5 text-[11px]",children:n}):null]}),children:u}):u},Wa=({action:t,outcome:e,provider:n,entryPoint:r,durationMs:s,failureReason:i})=>({event:`visual_editor_reference_${t==="connect"?"connection":"disconnection"}_${e}`,properties:{provider:n,entry_point:r,...s!==void 0?{duration_ms:s}:{},...i?{failure_reason:i}:{}}}),Ik=Es("ConnectorsModal"),nK=()=>E.jsx("svg",{viewBox:"0 0 24 24",className:"h-6 w-6","aria-hidden":"true",children:E.jsx("path",{fill:"currentColor",d:"M12 0C5.373 0 0 5.372 0 12c0 5.084 3.163 9.426 7.627 11.174-.105-.949-.2-2.405.042-3.441.218-.937 1.407-5.965 1.407-5.965s-.359-.719-.359-1.781c0-1.669.967-2.915 2.171-2.915 1.024 0 1.518.769 1.518 1.69 0 1.029-.655 2.568-.994 3.995-.283 1.194.599 2.169 1.777 2.169 2.132 0 3.772-2.249 3.772-5.495 0-2.873-2.064-4.882-5.012-4.882-3.414 0-5.418 2.561-5.418 5.207 0 1.031.397 2.137.893 2.739.098.119.112.223.083.344-.091.379-.293 1.194-.333 1.361-.052.22-.174.266-.401.16-1.499-.698-2.436-2.889-2.436-4.649 0-3.785 2.75-7.262 7.929-7.262 4.163 0 7.398 2.967 7.398 6.931 0 4.136-2.607 7.464-6.227 7.464-1.216 0-2.36-.631-2.75-1.378l-.748 2.853c-.271 1.043-1.002 2.35-1.492 3.146A12.004 12.004 0 0 0 12 24c6.627 0 12-5.373 12-12C24 5.372 18.627 0 12 0z"})}),rK=()=>E.jsx("span",{"aria-hidden":"true",className:"h-6 w-6 bg-[#b1b1b1]",style:{WebkitMaskImage:`url(${Rk})`,maskImage:`url(${Rk})`,WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskPosition:"center",maskPosition:"center"}}),sK=[{provider:"pinterest",name:"Pinterest",description:"Pull boards and pins in as visual references.",tileClassName:"bg-[#e60023] text-white",icon:E.jsx(nK,{})},{provider:"arena",name:"Are.na",description:"Connect channels of collected blocks and links.",tileClassName:"bg-[#18181b] text-content",icon:E.jsx(rK,{})}],iK=({meta:t,integration:e,isPending:n,isHighlighted:r,onConnect:s,onDisconnect:i})=>{const a=(e==null?void 0:e.status)==="connected",c=e!=null&&e.externalUsername?`@${e.externalUsername}`:null;return E.jsxs("article",{className:`bg-main-light flex flex-col rounded-xl p-[18px] ${r?"ring-secondary ring-2":""}`,children:[E.jsx("span",{className:`grid h-[52px] w-[52px] flex-none place-items-center rounded-xl ${t.tileClassName}`,"aria-hidden":"true",children:t.icon}),E.jsxs("div",{className:"mt-4 flex-1",children:[E.jsxs("h2",{className:"text-content flex items-center gap-1.5 text-[15px] font-semibold",children:[t.name,a?E.jsx(x5,{className:"h-3.5 w-3.5",weight:"bold","aria-hidden":"true"}):null]}),E.jsx("p",{className:"text-content-subtle mt-1 text-[13px] leading-relaxed",children:t.description}),a&&c?E.jsx("p",{className:"text-content-muted mt-2.5 text-xs font-medium",children:c}):null]}),a?E.jsx("button",{type:"button",onClick:i,disabled:n,className:"active-push bg-main-input text-content-muted mt-[18px] inline-flex min-h-[38px] w-full items-center justify-center rounded-lg px-3.5 text-[13px] font-semibold transition-colors hover:bg-red-500/10 hover:text-red-300 disabled:cursor-not-allowed disabled:opacity-50",children:n?"Disconnecting…":"Disconnect"}):E.jsx("button",{type:"button",onClick:s,disabled:n,className:"active-push bg-secondary text-secondary-foreground hover:bg-accent mt-[18px] inline-flex min-h-[38px] w-full items-center justify-center rounded-lg px-3.5 text-[13px] font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:n?"Connecting…":"Connect"})]})},z_=({isOpen:t,onClose:e,context:n="menu",highlightProvider:r=null})=>{const{integrations:s,isLoading:i,error:a,pendingProvider:c,connect:u,disconnect:f}=tK(),h=r0(),[p,m]=v.useState(null),_=S=>s.find(T=>T.provider===S),x=v.useCallback(S=>{const T=Date.now(),P=Wa({action:"connect",outcome:"started",provider:S,entryPoint:n});h==null||h.capture(P.event,P.properties),u(S).then(k=>{const R=Date.now()-T;if(k==="connected"){const O=Wa({action:"connect",outcome:"completed",provider:S,entryPoint:n,durationMs:R});h==null||h.capture(O.event,O.properties);return}const L=Wa({action:"connect",outcome:"failed",provider:S,entryPoint:n,durationMs:R,failureReason:k==="closed"?"popup_closed":"provider_failed"});h==null||h.capture(L.event,L.properties)}).catch(k=>{const R=k instanceof Error?k.message:"Could not connect.",L=Wa({action:"connect",outcome:"failed",provider:S,entryPoint:n,durationMs:Date.now()-T,failureReason:R.includes("Popup blocked")?"popup_blocked":"request_failed"});h==null||h.capture(L.event,L.properties),Ik.warn(`Connect error for ${S}:`,R),mt.error(R)})},[u,n,h]),y=v.useCallback(S=>{const T=Date.now(),P=Wa({action:"disconnect",outcome:"started",provider:S,entryPoint:n});h==null||h.capture(P.event,P.properties),f(S).then(()=>{const k=Wa({action:"disconnect",outcome:"completed",provider:S,entryPoint:n,durationMs:Date.now()-T});h==null||h.capture(k.event,k.properties)}).catch(k=>{const R=k instanceof Error?k.message:"Could not disconnect.",L=Wa({action:"disconnect",outcome:"failed",provider:S,entryPoint:n,durationMs:Date.now()-T,failureReason:"request_failed"});h==null||h.capture(L.event,L.properties),Ik.warn(`Disconnect error for ${S}:`,R),mt.error(R)})},[n,f,h]),w=n==="onboarding";return E.jsx(wx,{open:t,onOpenChange:S=>!S&&e(),children:E.jsxs(bx,{children:[E.jsx(Sx,{className:"z-max fixed inset-0 bg-black/40"}),E.jsx(Ex,{ref:m,className:"z-max border-main-border bg-main font-main fixed top-1/2 left-1/2 w-[560px] -translate-x-1/2 -translate-y-1/2 rounded-lg border shadow-2xl outline-none",children:E.jsxs(YR,{value:p,children:[E.jsxs("div",{className:"border-main-border bg-main-light flex items-center justify-between rounded-t-lg border-b px-4 py-2",children:[E.jsx(Cx,{className:"text-content text-base font-medium",children:"Connect design references"}),E.jsx(Ic,{onClick:e,title:"Close",className:"text-content-subtle hover:bg-main-hover hover:text-content rounded p-1 transition-colors",children:E.jsx(M5,{className:"h-4 w-4",weight:"bold"})})]}),E.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[E.jsx(kx,{className:"text-content-subtle text-sm",children:"Connect your design references to use them with Rivet’s MCP."}),a?E.jsx("p",{className:"rounded-lg bg-red-500/10 px-4 py-3 text-[13px] font-medium text-red-300",children:a}):null,E.jsx("div",{className:"grid grid-cols-2 gap-4",children:sK.map(S=>E.jsx(iK,{meta:S,integration:_(S.provider),isPending:i||c===S.provider,isHighlighted:r===S.provider,onConnect:()=>x(S.provider),onDisconnect:()=>y(S.provider)},S.provider))}),w?E.jsxs("div",{className:"flex items-center justify-between gap-4",children:[E.jsx("p",{className:"text-content-subtle text-xs",children:"You can always do this later from the account menu."}),E.jsx("button",{type:"button",onClick:e,className:"active-push bg-secondary text-secondary-foreground hover:bg-accent flex-none rounded-lg px-3.5 py-2 text-[13px] font-medium transition-colors",children:"Skip for now"})]}):null]})]})})]})})},Mk=({className:t=""})=>E.jsx("span",{"aria-hidden":"true",className:`rivet-skeleton block rounded ${t}`.trim()}),oK=Es("SupportTicketModal"),Ok=5e3,S1="feedback",aK=t=>{var r;if(!t)return null;const e=(r=t.formErrors)==null?void 0:r[0];if(e)return e;const n=t.fieldErrors??{};for(const s of Object.values(n)){const i=s==null?void 0:s[0];if(i)return i}return null},lK=async t=>{let e;try{e=await t.json()}catch{e=void 0}if(t.status===400){if(typeof(e==null?void 0:e.details)=="string"&&e.details.trim())return e.details;if(typeof(e==null?void 0:e.details)=="object"&&e.details!==null){const n=aK(e.details);if(n)return n}return"Please check your feedback and try again."}return t.status>=500?typeof(e==null?void 0:e.details)=="string"&&e.details.trim()?e.details:"Could not send feedback right now. Please try again later.":typeof(e==null?void 0:e.error)=="string"&&e.error.trim()?e.error:`HTTP ${t.status}`},cK=({isOpen:t,onClose:e,contactEmail:n})=>{const r=r0(),[s,i]=v.useState(""),[a,c]=v.useState(!1),[u,f]=v.useState(null),h=v.useCallback(()=>{i("")},[]),p=v.useCallback(()=>{a||(h(),e())},[a,e,h]),m=v.useCallback(async()=>{const w=s.trim();if(!(!w||a)){c(!0);try{const S=typeof(r==null?void 0:r.get_session_id)=="function"?r.get_session_id():void 0,T=typeof(r==null?void 0:r.get_distinct_id)=="function"?r.get_distinct_id():void 0,P=n==null?void 0:n.trim(),k=await fetch("/api/support/tickets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:S1,message:w,contactEmail:P||void 0,metadata:{posthogSessionId:S??void 0,posthogDistinctId:T??void 0,appVersion:"0.14.17",appEnvironment:"production",pageUrl:window.location.href,userAgent:navigator.userAgent,submittedAt:new Date().toISOString()}})});if(!k.ok){const R=await lK(k);throw new Error(R)}r==null||r.capture("support_ticket_submitted",{ticket_type:S1,has_posthog_session_id:!!S}),mt.success("Feedback sent",{description:"Thanks for sharing this."}),h(),e()}catch(S){const T=S instanceof Error?S.message:"Failed to send message";r==null||r.capture("support_ticket_submit_failed",{ticket_type:S1,error:T}),oK.error("Failed to submit support ticket:",T),mt.error("Could not send feedback",{description:T})}finally{c(!1)}}},[n,a,s,e,r,h]),_=v.useCallback(w=>{w.key==="Enter"&&(w.metaKey||w.ctrlKey)&&(w.preventDefault(),m())},[m]),x=Ok-s.length,y=a||s.trim().length===0;return E.jsx(wx,{open:t,onOpenChange:w=>!w&&p(),children:E.jsxs(bx,{children:[E.jsx(Sx,{className:"fixed inset-0 z-max bg-black/40"}),E.jsx(Ex,{ref:f,className:"fixed left-1/2 top-1/2 z-max w-[440px] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-main-border bg-main font-main shadow-2xl outline-none",children:E.jsxs(YR,{value:u,children:[E.jsxs("div",{className:"flex items-center justify-between rounded-t-lg border-b border-main-border bg-main-light px-4 py-2",children:[E.jsx(Cx,{className:"text-base font-medium text-content",children:"Send feedback"}),E.jsx(Ic,{onClick:p,disabled:a,title:"Close",className:"rounded p-1 text-content-subtle transition-colors hover:bg-main-hover hover:text-content disabled:cursor-not-allowed disabled:opacity-50",children:E.jsx(M5,{className:"h-4 w-4",weight:"bold"})})]}),E.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[E.jsx(kx,{className:"text-sm text-content-subtle",children:"Tell us what happened or what we can improve."}),E.jsxs("div",{className:"rounded-lg bg-main-input outline outline-1 outline-transparent transition-[outline-color] focus-within:outline-white/20",children:[E.jsx("textarea",{id:"support-ticket-message","aria-label":"Your feedback",value:s,onChange:w=>i(w.target.value),onKeyDown:_,maxLength:Ok,rows:6,disabled:a,placeholder:"What happened?",className:"max-h-64 w-full resize-none overflow-y-auto bg-transparent pb-1 pl-3 pr-3 pt-3 text-sm text-content placeholder-content-subtle focus:outline-none disabled:opacity-50"}),E.jsxs("div",{className:"flex items-center justify-between px-3 pb-3 pt-1",children:[E.jsx("span",{className:"text-xs text-content-subtle",children:"Context details are included automatically."}),E.jsxs("div",{className:"flex items-center gap-2",children:[x<=500&&E.jsx("span",{className:"text-xs text-content-subtle",children:x}),E.jsx(Ic,{onClick:m,disabled:y,title:"Send feedback",shortcut:"⌘↵",className:"flex items-center justify-center rounded bg-primary p-1 text-content transition-colors hover:bg-primary-hover disabled:cursor-not-allowed disabled:opacity-80",children:a?E.jsx(h0,{className:"h-5 w-5 animate-spin",weight:"bold"}):E.jsx(Uz,{className:"h-5 w-5",weight:"bold"})})]})]})]})]})]})})]})})},uK=Es("ProfileAvatar"),nA=(t,e)=>{const n=(t??"").trim();if(n)return n.split(/\s+/).filter(Boolean)[0]??"";const s=((e??"").split("@")[0]??"").split(/[._\-+]/).filter(Boolean)[0]??"";return s?s[0].toUpperCase()+s.slice(1):""},dK=(t,e)=>nA(t,e).charAt(0).toUpperCase(),fK=({className:t="",side:e="bottom",align:n="end"})=>{const{name:r,email:s}=et(sR),i=et(cR),[a,c]=v.useState(!1),[u,f]=v.useState(!1),[h,p]=v.useState(!1),[m,_]=v.useState(!1),{containerRef:x,onKeyDown:y}=YG(),w=et(Tf),S=dK(r,s);if(!S)return w?E.jsxs("span",{"data-testid":"profile-avatar-skeleton","aria-hidden":"true",className:`flex shrink-0 items-center gap-2 ${t}`.trim(),children:[E.jsx(Mk,{className:"h-7 w-7 rounded-full"}),E.jsx(Mk,{className:"h-3 w-16"})]}):null;const T=nA(r,s),P=(r==null?void 0:r.trim())||null,k=(s==null?void 0:s.trim())||null,R=async()=>{_(!0);try{const L=await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin"});if(!L.ok)throw new Error(`Logout failed: ${L.status}`)}catch(L){uK.warn("Logout request failed",L),mt.error("Could not log out. Please try again."),_(!1);return}window.location.reload()};return E.jsxs(E.Fragment,{children:[E.jsxs(LR,{open:a,onOpenChange:c,children:[E.jsx(NR,{asChild:!0,children:E.jsxs("button",{type:"button","aria-label":"Account",className:`text-content-muted hover:text-content flex shrink-0 items-center gap-2 transition-colors select-none ${t}`,children:[E.jsx("span",{className:"border-main-border bg-main-input flex h-7 w-7 items-center justify-center rounded-full border text-[11px] leading-none font-semibold",children:S}),T?E.jsx("span",{className:"max-w-[8rem] truncate text-xs font-medium",children:T}):null]})}),E.jsx(DR,{children:E.jsxs(jR,{ref:x,onKeyDown:y,role:"menu",className:"bg-surface-2 z-[60] min-w-[180px] rounded-lg p-1 shadow-lg",side:e,sideOffset:6,align:n,children:[P||k?E.jsxs("div",{className:"border-main-border border-b px-3 py-2",children:[P?E.jsx("div",{className:"text-content truncate text-xs font-medium",children:P}):null,k?E.jsx("div",{className:"text-content-muted truncate text-[11px]",children:k}):null]}):null,E.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:()=>{c(!1),f(!0)},disabled:!i,className:"text-content hover:bg-hover focus:bg-hover mt-1 flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",children:[E.jsx(R5,{className:"h-3.5 w-3.5",weight:"bold"}),"Connect design references"]}),E.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:()=>{c(!1),p(!0)},className:"text-content hover:bg-hover focus:bg-hover mt-1 flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs transition-colors focus:outline-none",children:[E.jsx(Wz,{className:"h-3.5 w-3.5",weight:"bold"}),"Share feedback"]}),E.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:R,disabled:m,className:"text-content hover:bg-hover focus:bg-hover mt-1 flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",children:[E.jsx(qz,{className:"h-3.5 w-3.5",weight:"bold"}),m?"Logging out…":"Log out"]})]})})]}),E.jsx(z_,{isOpen:u,onClose:()=>f(!1)}),E.jsx(cK,{isOpen:h,onClose:()=>p(!1),contactEmail:s??void 0})]})},hK=({onClose:t})=>E.jsxs("div",{className:"bg-main font-main scrollbar-hide relative flex h-full w-full cursor-auto flex-col overflow-hidden shadow-2xl","data-cy":"element-inspector",children:[E.jsx(ZG,{onClose:t}),E.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:E.jsx(kG,{})}),E.jsx("div",{className:"border-main-border bg-main-light flex flex-shrink-0 items-center border-t px-2.5 py-1.5",children:E.jsx(fK,{side:"top",align:"start"})})]});async function pK(t,e){const{delaysMs:n,shouldRetry:r,onRetry:s}=e;for(let i=1;;i++)try{return await t(i)}catch(a){const c=n[i-1];if(c===void 0||r&&!r(a))throw a;s==null||s(a,i,c),await new Promise(u=>setTimeout(u,c))}}const Lk=Es("useServerConfig"),rA=[250,500,1e3,2e3,4e3],Nk=rA.length+1,mK=async()=>{var n;const t=await fetch("/api/health");if(!t.ok)throw new Error(`Failed to fetch config: ${t.status}`);const e=await t.json();if(!e.framework)throw new Error("Server did not return framework information");return{userPort:((n=e.ports)==null?void 0:n.userDevServer)||3e3,framework:e.framework}},gK=()=>{const[t,e]=v.useState(null),[n,r]=v.useState(!0),[s,i]=v.useState(null),a=v.useCallback(async()=>{try{r(!0),i(null);const c=await pK(mK,{delaysMs:rA,onRetry:(u,f,h)=>{Lk.warn(`Server config fetch failed (attempt ${f}); retrying in ${h}ms`,u)}});return e(c),c}catch(c){const u=c instanceof Error?c.message:"Failed to fetch server config";throw i(u),Lk.warn("Error fetching server config:",c),c}finally{r(!1)}},[]);return{config:t,fetchConfig:a,isLoading:n,error:s}},vK="#1C1C20",Fi=[118,118,124],Dk=.85,yK=3,_K=.15,gp=36,xK=4.4,wK=.7,bK=3.5,SK=.8,jk=9,EK=11,CK=[1.35,1.12,.95,.85],kK=[0,1.1,2.3,3.1],PK=[0,.35,.16,.13],TK=[.9,.5,.4,.35],Ga=3,E1=[[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.14,y1:.13,x2:.86,y2:.23,level:1},{x1:.14,y1:.28,x2:.3,y2:.87,level:1},{x1:.34,y1:.28,x2:.86,y2:.87,level:1},{x1:.165,y1:.155,x2:.225,y2:.205,level:2},{x1:.7,y1:.155,x2:.755,y2:.205,level:2},{x1:.775,y1:.155,x2:.83,y2:.205,level:2},{x1:.165,y1:.32,x2:.275,y2:.375,level:2},{x1:.165,y1:.415,x2:.275,y2:.47,level:2},{x1:.165,y1:.51,x2:.275,y2:.565,level:2},{x1:.37,y1:.32,x2:.585,y2:.56,level:2},{x1:.615,y1:.32,x2:.83,y2:.56,level:2},{x1:.37,y1:.61,x2:.83,y2:.83,level:2},{hline:!0,x1:.39,x2:.81,y:.685,level:3},{hline:!0,x1:.39,x2:.75,y:.755,level:3}],[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.16,y1:.17,x2:.52,y2:.45,level:1},{x1:.58,y1:.17,x2:.685,y2:.29,level:1},{x1:.715,y1:.17,x2:.84,y2:.29,level:1},{x1:.58,y1:.33,x2:.685,y2:.45,level:1},{x1:.715,y1:.33,x2:.84,y2:.45,level:1},{x1:.16,y1:.55,x2:.84,y2:.85,level:1},{x1:.19,y1:.21,x2:.36,y2:.33,level:2},{hline:!0,x1:.19,x2:.48,y:.37,level:3},{hline:!0,x1:.19,x2:.42,y:.42,level:3},{x1:.19,y1:.6,x2:.49,y2:.8,level:2},{hline:!0,x1:.53,x2:.8,y:.63,level:3},{hline:!0,x1:.53,x2:.76,y:.7,level:3},{hline:!0,x1:.53,x2:.79,y:.77,level:3}],[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.14,y1:.13,x2:.86,y2:.22,level:1},{x1:.14,y1:.28,x2:.36,y2:.87,level:1},{x1:.39,y1:.28,x2:.61,y2:.87,level:1},{x1:.64,y1:.28,x2:.86,y2:.87,level:1},{x1:.165,y1:.15,x2:.225,y2:.2,level:2},{x1:.165,y1:.32,x2:.335,y2:.52,level:2},{x1:.415,y1:.32,x2:.585,y2:.52,level:2},{x1:.665,y1:.32,x2:.835,y2:.52,level:2},{hline:!0,x1:.165,x2:.335,y:.6,level:3},{hline:!0,x1:.165,x2:.3,y:.67,level:3},{hline:!0,x1:.415,x2:.585,y:.6,level:3},{hline:!0,x1:.415,x2:.55,y:.67,level:3},{hline:!0,x1:.665,x2:.835,y:.6,level:3},{hline:!0,x1:.665,x2:.8,y:.67,level:3}],[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.3,y1:.22,x2:.7,y2:.74,level:1},{x1:.34,y1:.27,x2:.55,y2:.34,level:2},{hline:!0,x1:.36,x2:.64,y:.42,level:3},{hline:!0,x1:.36,x2:.6,y:.49,level:3},{hline:!0,x1:.36,x2:.62,y:.56,level:3},{x1:.5,y1:.63,x2:.575,y2:.69,level:2},{x1:.595,y1:.63,x2:.66,y2:.69,level:2}]],vp=t=>{let e=t|0;return e=Math.imul(e^e>>>16,73244475),e=Math.imul(e^e>>>16,73244475),e^=e>>>16,(e>>>0)/4294967296},zp=t=>{const e=Math.min(1,Math.max(0,t));return e*e*(3-2*e)},Ka=(t,e)=>(Math.round(t/e-.5)+.5)*e,RK=Math.sin(Math.PI/3),Fk=(t,e,n,r,s)=>{if(t.beginPath(),e===0)t.arc(n,r,s,0,Math.PI*2);else if(e===1){const i=s*RK;t.moveTo(n,r-s),t.lineTo(n+i,r+s/2),t.lineTo(n-i,r+s/2),t.closePath()}else{const i=s*.85;t.rect(n-i,r-i,i*2,i*2)}t.fill()},AK=(t,e,n)=>{let r;if(n.hline){const s=Math.max(n.x1-t,t-n.x2,0),i=Math.abs(e-n.y1);r=Math.hypot(s,i)-jk}else{const s=Math.max(n.x1-t,t-n.x2,0),i=Math.max(n.y1-e,e-n.y2,0);s===0&&i===0?r=-Math.min(t-n.x1,n.x2-t,e-n.y1,n.y2-e):r=Math.hypot(s,i),r=Math.abs(r)-jk}return zp(.5-r/(2*EK))},sA=({className:t="",trackGlobalLoaderCount:e=!0})=>{const n=at(rR),r=v.useRef(null),s=v.useCallback(i=>{var N;if((N=r.current)==null||N.call(r),r.current=null,!i)return;const a=i.getContext("2d");if(!a)return;e&&n(j=>j+1);const c=window.matchMedia("(prefers-reduced-motion: reduce)").matches;let u=[],f=0,h=0,p=gp,m=gp,_=null,x=null,y=0,w=-1;const S=new Array(33),T=j=>{const F=Math.round(j*32);let K=S[F];if(!K){const X=F/32,W=Math.round(Fi[0]+(255-Fi[0])*X),G=Math.round(Fi[1]+(255-Fi[1])*X),q=Math.round(Fi[2]+(255-Fi[2])*X);K=`rgba(${W}, ${G}, ${q}, ${Dk})`,S[F]=K}return K},P=j=>{const F=1-.35*j,K=Math.round(Fi[0]*F),X=Math.round(Fi[1]*F),W=Math.round(Fi[2]*F);return`rgba(${K}, ${X}, ${W}, ${Dk})`},k=j=>{let F=Math.floor(Math.random()*E1.length);F===w&&(F=(F+1)%E1.length),w=F;const K=[0,0,0,0],X=E1[F].map((D,Y)=>{const ee=D.level,ie=K[ee]++,oe=kK[ee]+ie*PK[ee],ce=TK[ee]+vp(F*131+Y*17+5)*.2;if(D.hline){const se=Ka((D.y??0)*h,m);return{hline:!0,x1:Ka(D.x1*f,p),x2:Ka(D.x2*f,p),y1:se,y2:se,level:ee,start:oe,dur:ce}}const xe=Ka(D.x1*f,p),ae=Ka((D.y1??0)*h,m);return{hline:!1,x1:xe,y1:ae,x2:Math.max(Ka(D.x2*f,p),xe+p),y2:Math.max(Ka((D.y2??0)*h,m),ae+m),level:ee,start:oe,dur:ce}}),W=X.reduce((D,Y)=>Math.max(D,Y.start+Y.dur),0),G=u.length,q=new Float32Array(G*Ga),$=new Int16Array(G*Ga).fill(-1),ne=new Uint8Array(G),H=X[0];for(let D=0;D<G;D++){const Y=u[D];Y.x>H.x1&&Y.x<H.x2&&Y.y>H.y1&&Y.y<H.y2&&(ne[D]=1);const ee=D*Ga;for(let ie=0;ie<X.length;ie++){const oe=AK(Y.x,Y.y,X[ie]);if(oe<=.02)continue;let ce=ee;for(let xe=ee;xe<ee+Ga;xe++){if($[xe]===-1){ce=xe;break}q[xe]<q[ce]&&(ce=xe)}($[ce]===-1||oe>q[ce])&&(q[ce]=oe,$[ce]=ie)}}return{startT:j,buildEnd:W,els:X,frame:H,cellQ:q,cellEl:$,inFrame:ne}},R=()=>{const j=i.getBoundingClientRect();f=Math.max(1,j.width),h=Math.max(1,j.height);const F=Math.min(2,window.devicePixelRatio||1);i.width=Math.round(f*F),i.height=Math.round(h*F),a.setTransform(F,0,0,F,0,0);const K=Math.max(8,Math.round(f/gp)),X=Math.max(6,Math.round(h/gp));p=f/K,m=h/X,u=[];for(let W=0;W<X;W++){const G=X>1?W/(X-1):.5,q=xK*(1+wK*.4*(G*2-1));for(let $=0;$<K;$++){const ne=W*8191+$*131+1,H={x:($+.5)*p,y:(W+.5)*m,size:q,seed:ne,phase:vp(ne),kind:0};H.kind=Math.floor(vp(ne*97)*3),u.push(H)}}x=null,_=null},L=new Float32Array(32),O=j=>{a.fillStyle=vK,a.fillRect(0,0,f,h),_||(_=k(j+.2)),j>=_.startT+_.buildEnd+bK&&(x=_,y=j,_=k(j+.2));let F=0;x&&(F=1-zp((j-y)/SK),F<=0&&(x=null));const K=_;for(let H=0;H<K.els.length;H++){const D=K.els[H];L[H]=zp(Math.min(1,Math.max(0,(j-K.startT-D.start)/D.dur)))}const X=L[0],W=P(0),G=P(X),q=F>0?P(F):W,$=F>0?P(Math.max(X,F)):G,ne=u.length;for(let H=0;H<ne;H++){const D=u[H];let Y=0,ee=0;const ie=H*Ga;for(let De=ie;De<ie+Ga;De++){const Re=K.cellEl[De];if(Re<0)break;const Ye=K.cellQ[De]*L[Re];Ye>Y&&(Y=Ye,ee=K.els[Re].level)}if(x)for(let De=ie;De<ie+Ga;De++){const Re=x.cellEl[De];if(Re<0)break;const Ye=x.cellQ[De]*F;Ye>Y&&(Y=Ye,ee=x.els[Re].level)}const oe=j/yK+D.phase,ce=Math.floor(oe),xe=oe-ce,ae=zp(Math.min(xe,1-xe)/_K),se=Math.floor(vp(D.seed*97+ce*7919)*3);se!==D.kind&&Y<.02&&ae<.05&&(D.kind=se);const Ve=Math.max(ae*(1-Y),Y);if(!(Ve<.01))if(Y<.02){const De=K.inFrame[H]===1,Re=x?x.inFrame[H]===1:!1;De?a.fillStyle=Re?$:G:a.fillStyle=Re?q:W;const Ye=Math.max(De?X:0,Re?F:0);Fk(a,D.kind,D.x,D.y,D.size*Ve*(1-.2*Ye))}else{a.fillStyle=T(Y);const De=1+(CK[ee]-1)*Y;Fk(a,D.kind,D.x,D.y,D.size*Ve*De)}}};R();let A=0;if(c)_=k(-100),O(0);else{const j=performance.now(),F=K=>{O((K-j)/1e3),A=requestAnimationFrame(F)};A=requestAnimationFrame(F)}const I=new ResizeObserver(()=>{R(),c&&(_=k(-100),O(0))});I.observe(i),r.current=()=>{cancelAnimationFrame(A),I.disconnect(),e&&n(j=>j-1)}},[e,n]);return E.jsx("canvas",{ref:s,"aria-hidden":"true",className:`h-full w-full ${t}`.trim()})},IK=async(t=null)=>{if(t)return MK(t);let e;try{e=await fetch("/api/mcp/status")}catch{return{isOk:!1,unavailableReason:"rivet_unreachable",upstreamStatus:null}}if(e.status===404||!(e.headers.get("content-type")??"").toLowerCase().includes("application/json"))return yp();if(!e.ok)return{isOk:!1,unavailableReason:"rivet_unreachable",upstreamStatus:null};let r;try{r=await e.json()}catch{return yp()}const s=r.devServerHealth;return s?s.ownership==="none"?{isOk:!1,unavailableReason:"upstream_unreachable",upstreamStatus:null}:s.isReachable===!0?{isOk:!0,unavailableReason:"upstream_unreachable",upstreamStatus:null}:{isOk:!1,unavailableReason:s.reason==="rivet_unreachable"?"rivet_unreachable":"upstream_unreachable",upstreamStatus:null}:yp()},iA=async t=>{try{const e=await fetch(t);return{isOk:e.status!==502&&e.status!==503,unavailableReason:"upstream_unreachable",upstreamStatus:e.status}}catch{return{isOk:!1,unavailableReason:"rivet_unreachable",upstreamStatus:null}}},MK=t=>iA(t),yp=()=>iA("/"),C1=Es("usePreviewUpstreamHealth"),OK=500,LK=4e3,NK=15e3,DK=3,jK=(t,e={})=>{const n=v.useRef(null),r=v.useRef(null),s=e.probeMsWhileDown??OK,i=e.probeMsWhileUp??LK,a=e.firstUnreachableCaptureAfterMs??NK,c=e.rerunProbeImmediatelyOnVersion,u=e.probePath??null,f=e.skip??!1,h=v.useRef(e.onPersistentUpstreamServerErrors);h.current=e.onPersistentUpstreamServerErrors;const[p,m]=v.useState(t==="static"),[_,x]=v.useState(0),[y,w]=v.useState(null),[S,T]=v.useState(0),[P,k]=v.useState(!1),[R,L]=v.useState(!1),[O,A]=v.useState(t==="static"?null:"upstream_unreachable");return v.useEffect(()=>{if(t==="static"){m(!0),w(null),T(0),k(!1),L(!0),A(null);return}if(f){m(!1),w(null),T(0),k(!1),L(!0),A("upstream_unreachable"),n.current=null;return}let I=!0;const N=Date.now();w(N),T(0),k(!1),m(!1),L(!1),A("upstream_unreachable");const j={current:!1},F={current:!1},K={current:!1},X={current:null},W={current:!1},G={current:!1},q={current:0},$={current:!1},ne={current:null};let H=null;const D=()=>{K.current||(K.current=!0,I&&L(!0))},Y=()=>{H!==null&&(clearTimeout(H),H=null)},ee=(oe,ce)=>{Y(),H=setTimeout(ce,oe)},ie=async()=>{var Ye;if(!I)return;T(dt=>dt+1);const{isOk:oe,unavailableReason:ce,upstreamStatus:xe}=await IK(u);if(!I)return;D(),ne.current=xe;const ae=oe&&xe!==null&&xe>=500;ae&&G.current?q.current+=1:oe&&!ae&&(q.current=0);const se=q.current>=DK;if(se&&!$.current&&xe!==null&&($.current=!0,be==null||be.capture("preview_upstream_error_responses",{framework:t,upstream_status:xe,consecutive_count:q.current}),C1.warn(`Preview upstream is listening but has served ${q.current} consecutive ${xe} responses`),(Ye=h.current)==null||Ye.call(h,{upstreamStatus:xe,consecutiveCount:q.current})),oe&&!se){ae||(G.current=!0,$.current=!1);const dt=!W.current;W.current=!0,m(!0),A(null),X.current=null,F.current=!1,k(!1),j.current?dt&&(be==null||be.capture("preview_upstream_restored",{framework:t})):(j.current=!0,be==null||be.capture("preview_dev_server_ready",{framework:t,ready_after_ms:Date.now()-N})),ee(i,ie);return}const De=W.current;W.current=!1,m(!1),A(ce),X.current===null&&(X.current=Date.now(),F.current=!1,k(!1)),De&&(be==null||be.capture("preview_upstream_lost",{framework:t,upstream_status:xe}),x(dt=>dt+1),C1.warn("Preview upstream became unavailable after it was ready"));const Re=Date.now()-X.current;Re>=a&&!F.current&&(F.current=!0,k(!0),be==null||be.capture("preview_dev_server_unreachable",{framework:t,elapsed_ms:Re,upstream_status:ne.current}),C1.warn("Dev server did not become ready within timeout window")),ee(s,ie)};return n.current=()=>ee(0,ie),ee(0,ie),()=>{I=!1,n.current=null,Y()}},[t,s,i,a,u,f]),v.useEffect(()=>{var N;if(t==="static"||c===void 0)return;const I=r.current;r.current=c,I!==null&&I!==c&&((N=n.current)==null||N.call(n))},[t,c]),{isUpstreamReady:p,iframeRemountKey:_,probeStartedAt:y,probeAttemptCount:S,isFirstUnreachableWindowExceeded:P,initialProbeComplete:R,unavailableReason:O}};function FK(t){return t.enteringSplit&&t.isExistingSession&&t.hasActiveVariantProxy}const oA=t=>{var e;return t!=="embedded"||typeof window>"u"?"":((e=window.__RIVET_BOOTSTRAP__)==null?void 0:e.previewOrigin)??`${window.location.protocol}//localhost:${window.location.port}`},aA=({agentApplyMode:t,url:e})=>e.startsWith("/")?`${oA(t)}${e}`:e,VK="allow-scripts allow-same-origin allow-forms allow-popups allow-modals",$K=t=>VK,HK=Es("PreviewSurface"),Vk=(t,e)=>t==="about:blank"?"blank":t.includes("/api/variants/")?"static_artifact":e.kind==="variant"?"dev_server":"original",lA=({target:t,src:e,framework:n,remountKey:r})=>(et(p0),E.jsx("div",{className:"relative h-full w-full",children:E.jsx("iframe",{src:e,className:"h-full w-full border-none",title:"Project Preview",sandbox:$K(),onLoad:()=>{be==null||be.capture("preview_iframe_loaded",{framework:n,src:e}),t.kind==="variant"&&(be==null||be.capture("variants_panel.preview_displayed",{sessionId:t.sessionId,variantId:t.variantId,renderedTarget:"variant",iframeSrcKind:Vk(e,t),framework:n}))},onError:()=>{be==null||be.capture("preview_iframe_load_failed",{framework:n,src:e}),t.kind==="variant"&&(be==null||be.capture("variants_panel.preview_display_failed",{sessionId:t.sessionId,variantId:t.variantId,renderedTarget:"variant",iframeSrcKind:Vk(e,t),framework:n})),HK.warn("Preview iframe failed to load",{framework:n,src:e})}},r)})),zK="modulepreload",UK=function(t){return"/"+t},$k={},BK=function(e,n,r){let s=Promise.resolve();if(n&&n.length>0){let a=function(f){return Promise.all(f.map(h=>Promise.resolve(h).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),u=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));s=a(n.map(f=>{if(f=UK(f),f in $k)return;$k[f]=!0;const h=f.endsWith(".css"),p=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${p}`))return;const m=document.createElement("link");if(m.rel=h?"stylesheet":zK,h||(m.as="script"),m.crossOrigin="",m.href=f,u&&m.setAttribute("nonce",u),document.head.appendChild(m),h)return new Promise((_,x)=>{m.addEventListener("load",_),m.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${f}`)))})}))}function i(a){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=a,window.dispatchEvent(c),!c.defaultPrevented)throw a}return s.then(a=>{for(const c of a||[])c.status==="rejected"&&i(c.reason);return e().catch(i)})},WK=v.lazy(()=>BK(()=>Promise.resolve().then(()=>Sq),void 0)),GK={surface:"relative flex h-full w-full items-center justify-center bg-main px-6",overlay:"absolute inset-0 z-10 flex items-center justify-center bg-main/90 px-6",page:"relative flex h-screen w-full items-center justify-center bg-main px-6"},KK={sm:"text-lg font-semibold text-content",md:"text-2xl font-semibold text-content",lg:"text-3xl font-semibold text-content"},ZK={neutral:"rounded-md border border-divider bg-transparent px-5 py-2 text-sm font-medium text-content transition-colors hover:bg-surface-3",ghost:"rounded-md px-5 py-2 text-sm font-medium text-content-muted transition-colors hover:text-content"},Id=({backdrop:t,media:e,title:n,description:r,actions:s,tone:i="neutral",fill:a="surface",size:c="md",children:u,state:f,role:h="status",busy:p=!1,className:m=""})=>{const _=v.useCallback(y=>{y&&f&&(be==null||be.capture("status_surface_shown",{state:f,tone:i,fill:a}))},[f,i,a]),x=!!(e||n||r||u||s!=null&&s.length);return E.jsxs("div",{ref:_,className:`${GK[a]} ${m}`.trim(),role:h,"aria-live":"polite","aria-busy":p||void 0,"data-state":f,children:[t?E.jsx("div",{className:"absolute inset-0",children:t}):null,x?E.jsxs("div",{className:"relative z-10 flex max-w-sm flex-col items-center gap-5 text-center",children:[e,n?E.jsx("h2",{className:KK[c],children:n}):null,r?E.jsx("p",{className:"text-content-muted text-base leading-relaxed",children:r}):null,u,s!=null&&s.length?E.jsx("div",{className:"flex flex-row items-center gap-3",children:s.map(y=>E.jsx("button",{type:"button",onClick:y.onClick,className:ZK[y.variant??"neutral"],children:y.label},y.label))}):null]}):null]})},U_=({loader:t="coalesce",trackGlobalLoaderCount:e,size:n="lg",...r})=>t==="coalesce"?E.jsx(Id,{...r,size:n,busy:!0,backdrop:E.jsx(sA,{trackGlobalLoaderCount:e})}):t==="logo"?E.jsx(Id,{...r,size:n,busy:!0,backdrop:E.jsx(v.Suspense,{fallback:null,children:E.jsx(WK,{className:"absolute inset-0"})})}):E.jsx(Id,{...r,size:n,busy:!0,media:E.jsx(h0,{"aria-hidden":!0,className:"text-content h-8 w-8 shrink-0 animate-spin",weight:"bold"})}),cA=({icon:t,...e})=>E.jsx(Id,{...e,tone:"neutral",media:t?E.jsx("div",{className:"text-content-muted",children:t}):void 0}),Um=t=>E.jsx(Id,{...t,tone:"error",role:"alert"}),Hk="/static/",qK=t=>{try{return new URL(t,"http://localhost").pathname.endsWith(Hk)}catch{return t.endsWith(Hk)}},YK=({isInteractionDisabled:t=!1,framework:e,userPort:n})=>{var we;const r=et(I_),s=at(I_),i=et(jm),a=at(jm),c=et(Pf),u=et(p0),f=et(M_),h=et(O_),p=et(iR),m=et(oR),_=at(O_),x=et(lo),y=et(N_),w=at(M_),S=c.active&&c.projectContext.kind==="fresh",T=et(L_),P=c.active?c.variants.find(je=>je.workItemId===T&&(je.status==="pending"||je.status==="running"||je.status==="succeeded"&&!je.preview&&typeof je.port!="number"&&(!je.previewUnavailable||je.previewUnavailable.reason==="idle_timeout")))??null:null,k=c.active&&c.variants.some(je=>je.status==="pending"||je.status==="running"),R=S||k,L=c.active?c.variants.find(je=>{var ze;return je.workItemId===T&&je.status==="succeeded"&&!!je.previewUnavailable&&((ze=je.previewUnavailable)==null?void 0:ze.reason)!=="idle_timeout"})??null:null,O=e==="static"&&i!==null&&qK(i);v.useEffect(()=>{c.active||w(!1)},[c.active,w]);const A=v.useRef(!1);v.useEffect(()=>{const je=!!(x!=null&&x.left||x!=null&&x.right),ze=je&&!A.current;A.current=je;const it=c.active?c.sessionId:null;!it||!FK({enteringSplit:ze,isExistingSession:c.active&&c.projectContext.kind==="existing",hasActiveVariantProxy:f&&h!==null})||(w(!1),_(null),s(Tt=>Tt+1),fetch(`/api/variants/${encodeURIComponent(it)}/preview-port`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({variantId:null})}).catch(()=>{}))},[x,c,f,h,w,_,s]);const N=v.useMemo(()=>{var Xe;if(f||i&&!O||!c.active)return null;const{stage:je,variants:ze}=c,it=je==="ready"||je==="degraded",Tt=ze.some(It=>{var Un,In;return((Un=It.refinement)==null?void 0:Un.status)==="pending"||((In=It.refinement)==null?void 0:In.status)==="running"});if(!it&&!Tt)return null;const tt=ze.find(It=>{var Un;return It.status==="succeeded"&&((Un=It.preview)==null?void 0:Un.kind)==="static_artifact"});return((Xe=tt==null?void 0:tt.preview)==null?void 0:Xe.kind)==="static_artifact"?tt.preview.url:null},[O,i,f,c])??i,j=v.useMemo(()=>!c.active||!N?null:c.variants.find(je=>{var ze;return((ze=je.preview)==null?void 0:ze.kind)==="static_artifact"&&N.startsWith(je.preview.url)})??null,[N,c]),F=v.useMemo(()=>{if((y==null?void 0:y.previewKind)==="static")return{kind:"variant",sessionId:y.sessionId,variantId:y.variantId};if(!c.active)return Dm;if(j)return{kind:"variant",sessionId:c.sessionId,variantId:j.workItemId};if(N){const ze=N.match(/\/__rivet\/preview\/variant\/([^/]+)\/([^/?#]+)/),it=ze!=null&&ze[1]?decodeURIComponent(ze[1]):null,Tt=ze!=null&&ze[2]?decodeURIComponent(ze[2]):null;if(it===c.sessionId&&Tt&&c.variants.some(It=>It.workItemId===Tt))return{kind:"variant",sessionId:c.sessionId,variantId:Tt};const tt=N.match(/\/api\/variants\/[^/]+\/static\/([^/?#]+)/),Xe=tt!=null&&tt[1]?decodeURIComponent(tt[1]):null;if(Xe&&c.variants.some(It=>It.workItemId===Xe))return{kind:"variant",sessionId:c.sessionId,variantId:Xe}}const je=!!(x!=null&&x.left||x!=null&&x.right);return(!je||S)&&!N&&f&&h&&c.variants.some(ze=>ze.workItemId===h)?{kind:"variant",sessionId:c.sessionId,variantId:h}:(!je||S)&&!N&&T&&c.variants.some(ze=>ze.workItemId===T)?{kind:"variant",sessionId:c.sessionId,variantId:T}:Dm},[y,j,c,f,h,N,x,S,T]),K=v.useRef(null);v.useEffect(()=>{var Tt,tt;if(!j||((Tt=j.preview)==null?void 0:Tt.kind)!=="static_artifact"||((tt=j.refinement)==null?void 0:tt.status)!=="succeeded")return;const je=`${j.workItemId}:${j.refinement.workItemId}`;if(K.current===je)return;K.current=je;const ze=j.preview.url.includes("?")?"&":"?",it=`${j.preview.url}${ze}refinement=${encodeURIComponent(j.refinement.workItemId)}`;N!==it&&(a(it),s(Xe=>Xe+1))},[N,j,s,a,c]);const X=N!==null&&_G(N),W=N!==null&&!X||S&&!f&&!X,{isUpstreamReady:G,iframeRemountKey:q,probeAttemptCount:$,initialProbeComplete:ne}=jK(e,{rerunProbeImmediatelyOnVersion:r,probePath:X?N:null,skip:W}),[H,D]=v.useState(()=>p&&G?r:null),Y=v.useRef(null);v.useEffect(()=>{if(!p){Y.current=null,D(null);return}if(H===r){Y.current=null;return}const je=Y.current;if(!je||je.remountKey!==r){Y.current={remountKey:r,probeAttemptCount:$};return}G&&$>je.probeAttemptCount&&(Y.current=null,D(r))},[H,r,p,$,G]);const ie=N!==null&&!X||G,ce=m||p&&H!==r||p&&!ie,xe=`${q}:${r}`,ae=QR(window.location.pathname),se=e==="static"?`/static${ae??"/"}`:ae??"/",Ve=oA(u);let De=null;N&&(De=aA({agentApplyMode:u,url:N}));const Ye=P||ce?"about:blank":(X&&!ie?"about:blank":De)??(ie?`${Ve}${se}`:"about:blank"),dt=!!P||!!L||!ie&&ne;let Pt=null;return ce?Pt=E.jsx(U_,{fill:"overlay",loader:"coalesce",trackGlobalLoaderCount:!1,state:"preview_replay_boot"}):P?Pt=E.jsx(U_,{fill:"overlay",loader:"coalesce",trackGlobalLoaderCount:!1,state:"variant_building",children:E.jsx("span",{className:"sr-only",children:"Building your direction"})}):L?Pt=E.jsx(Um,{fill:"overlay",state:"preview_unavailable",title:"Preview couldn’t start",description:((we=L.previewUnavailable)==null?void 0:we.reason)==="missing_dev_script"?"This project has no dev script for Rivet to run.":"Its preview server didn’t start.",actions:[{label:"Reload",onClick:()=>window.location.reload()}]}):dt&&(Pt=R?E.jsx(cA,{fill:"overlay",state:"preview_no_selection",title:"Nothing to preview yet",description:"Pick a direction from the panel."}):E.jsx(Um,{fill:"overlay",state:"preview_offline",title:"Preview isn't connected",description:"Rivet lost connection to your project.",actions:[{label:"Reload",onClick:()=>window.location.reload()}]})),E.jsxs("div",{className:"relative h-full w-full",children:[Pt,E.jsx(lA,{target:F,src:Ye,framework:e,remountKey:xe})]})};function zk({side:t,sessionId:e,variantId:n,url:r,label:s,source:i,isFallback:a=!1}){var P;const c=et(lo),u=at(lo),f=r0(),h=et(Pf),p=et(p0),m=v.useRef(!1),_=v.useCallback(()=>{m.current||(m.current=!0,of({source:i,sessionId:e,variantId:n}))},[i,e,n]),x=v.useCallback(()=>{if(a){u(null);const O=zm("ended",c);f==null||f.capture(O.event,O.properties);return}_();const k={...c};delete k[t];const R=k.left||k.right?k:null;u(R);const L=zm(R?"updated":"ended",R??c);f==null||f.capture(L.event,L.properties)},[a,f,u,t,c,_]),y=v.useMemo(()=>({kind:"variant",sessionId:e,variantId:n}),[e,n]),w=v.useMemo(()=>!h.active||h.sessionId!==e?null:h.variants.find(k=>k.workItemId===n)??null,[e,n,h]),S=v.useMemo(()=>{var R,L;let k=r;if(((R=w==null?void 0:w.preview)==null?void 0:R.kind)==="static_artifact"&&((L=w.refinement)==null?void 0:L.status)==="succeeded"){const O=w.preview.url.includes("?")?"&":"?";k=`${w.preview.url}${O}refinement=${encodeURIComponent(w.refinement.workItemId)}`}return aA({agentApplyMode:p,url:k})},[p,w,r]),T=((P=w==null?void 0:w.refinement)==null?void 0:P.status)==="succeeded"?`${n}:${w.refinement.workItemId}`:n;return E.jsxs("div",{className:"variant-split-secondary","data-cy":"variant-split-pane","data-variant-id":n,children:[E.jsxs("div",{className:"variant-split-secondary-toolbar",children:[E.jsx("span",{className:"variant-split-secondary-label",title:s,children:s}),E.jsx(to,{label:"Collapse",children:E.jsx("button",{type:"button",className:"variant-split-secondary-close",onClick:x,"aria-label":"Collapse split view",children:E.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",focusable:"false",children:E.jsx("path",{d:"M2.5 2.5 L9.5 9.5 M9.5 2.5 L2.5 9.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})})})]}),E.jsx("div",{className:"variant-split-secondary-body relative min-h-0 flex-1",children:E.jsx(lA,{target:y,src:S,framework:"static",remountKey:T})})]})}const Uk=240;function XK(){const t=et(ef),e=et(Ax),n=v.useRef(null);return v.useEffect(()=>{if(!t||!e||!n.current)return;const r=e.x-Uk/2,s=e.y-22;n.current.style.transform=`translate3d(${r}px, ${s}px, 0)`},[t,e]),!t||!e?null:E.jsx("div",{ref:n,"aria-hidden":"true",className:"variant-drag-ghost",style:{width:Uk},children:E.jsxs("div",{className:"variant-drag-ghost-body",children:[E.jsxs("div",{className:"variant-drag-ghost-row",children:[E.jsx("div",{className:"variant-drag-ghost-title",children:t.label}),t.runLabel?E.jsx("div",{className:"variant-drag-ghost-tag",style:Z5(t.runLabel),children:t.runLabel}):null]}),t.description?E.jsx("div",{className:"variant-drag-ghost-desc",children:t.description}):null]})})}function QK(){const t=et(ef),e=et(Ax),n=et(lo),r=at(ef),s=at(lo),i=r0(),a=v.useRef(null),[c,u]=v.useState(null),[f,h]=v.useState("hidden");v.useEffect(()=>{if(!t){h("hidden"),u(null);return}const _=requestAnimationFrame(()=>h("visible"));return()=>cancelAnimationFrame(_)},[t]);const p=v.useCallback((_,x)=>{const y=a.current;if(!y)return null;const w=y.getBoundingClientRect();return _<w.left||_>w.right||x<w.top||x>w.bottom?null:_<(w.left+w.right)/2?"left":"right"},[]);if(v.useEffect(()=>{if(!t||!e)return;const _=p(e.x,e.y);u(x=>x===_?x:_)},[t,e,p]),v.useEffect(()=>{if(!t)return;const _=x=>{const y=p(x.clientX,x.clientY);if(y&&t.url){const w={sessionId:t.sessionId,variantId:t.variantId,label:t.label,url:t.url,source:t.source},S=n==null?void 0:n[y];S&&(S.sessionId!==w.sessionId||S.variantId!==w.variantId)&&of(S);const T={...n??{},[y]:w};s(T);const P=zm(n?"updated":"started",T);i==null||i.capture(P.event,P.properties),h("exiting"),window.setTimeout(()=>r(null),220)}else of(t),h("exiting"),window.setTimeout(()=>r(null),220)};return window.addEventListener("pointerup",_),window.addEventListener("pointercancel",_),()=>{window.removeEventListener("pointerup",_),window.removeEventListener("pointercancel",_)}},[t,p,i,r,s,n]),!t)return null;const m=["variant-drop-zones",f==="visible"&&"is-visible",f==="exiting"&&"is-exiting"].filter(Boolean).join(" ");return E.jsxs("div",{ref:a,className:m,"aria-hidden":"true",children:[E.jsx(Bk,{side:"left",hovered:c==="left",canDrop:!!t.url,label:t.label}),E.jsx(Bk,{side:"right",hovered:c==="right",canDrop:!!t.url,label:t.label})]})}function Bk({side:t,hovered:e,canDrop:n,label:r}){return E.jsxs("div",{className:["variant-drop-zone",`is-${t}`,e&&"is-hover",!n&&"is-disabled"].filter(Boolean).join(" "),children:[E.jsxs("div",{className:"variant-drop-zone-inner",children:[E.jsx("div",{className:`variant-drop-zone-icon is-${t}`}),E.jsx("div",{className:"variant-drop-zone-caption",children:n?`Add ${t} split`:"Split unavailable for this direction"})]}),E.jsx("div",{className:"variant-drop-zone-preview","aria-hidden":"true",children:E.jsx("div",{className:"variant-drop-zone-preview-label",children:r})}),E.jsx("div",{className:"variant-drop-zone-border"})]})}const uA=(t,e,n)=>{var i,a;if(!t.active||t.sessionId!==e)return null;const r=t.variants.find(c=>c.workItemId===n);if(((i=r==null?void 0:r.preview)==null?void 0:i.kind)!=="static_artifact")return null;if(((a=r.refinement)==null?void 0:a.status)!=="succeeded")return r.preview.url;const s=r.preview.url.includes("?")?"&":"?";return`${r.preview.url}${s}refinement=${encodeURIComponent(r.refinement.workItemId)}`},Wk=(t,e)=>{if(!t)return;const n=uA(e,t.sessionId,t.variantId);return!n||n===t.url?t:{...t,url:n}},JK=()=>E.jsx("div",{"data-testid":"preview-boot-skeleton",role:"status","aria-busy":"true","aria-label":"Loading preview",className:"bg-main flex h-full min-h-0 w-full flex-1 flex-col p-3",children:E.jsx("div",{className:"border-main-border relative min-h-0 flex-1 overflow-hidden rounded-lg border",children:E.jsx(sA,{trackGlobalLoaderCount:!1})})}),eZ=({isLoading:t=!1,isInteractionDisabled:e=!1})=>{const{config:n,fetchConfig:r,isLoading:s,error:i}=gK();return v.useEffect(()=>{r().catch(a=>{be==null||be.capture("preview_config_load_failed",{message:a instanceof Error?a.message:"unknown_error",attempts:Nk})})},[r]),s?E.jsx(JK,{}):i||!n?E.jsx(Um,{fill:"surface",size:"sm",state:"preview_config_error",title:"Couldn't load preview",description:"We couldn't load the preview configuration.",actions:[{label:"Retry",onClick:()=>{be==null||be.capture("preview_config_retry_clicked"),r().catch(a=>{be==null||be.capture("preview_config_load_failed",{message:a instanceof Error?a.message:"unknown_error",attempts:Nk})})}}]}):E.jsx(tZ,{isLoading:t,isInteractionDisabled:e,framework:n.framework,userPort:n.userPort})};function tZ(t){const e=et(lo),n=et(ef),r=et(Pf),s=et(jm),i=e==null?void 0:e.left,a=e==null?void 0:e.right,c=v.useMemo(()=>{var R,L;if(!r.active||r.projectContext.kind!=="fresh"||!(!!i!=!!a))return;const y=(R=i??a)==null?void 0:R.variantId,w=r.variants.filter(O=>{var A;return O.status==="succeeded"&&((A=O.preview)==null?void 0:A.kind)==="static_artifact"&&O.workItemId!==y}),S=s==null?void 0:s.replace(/[?&]refinement=[^&]*$/,""),P=w.find(O=>{var A;return((A=O.preview)==null?void 0:A.kind)==="static_artifact"&&O.preview.url===S})??w[0];if(((L=P==null?void 0:P.preview)==null?void 0:L.kind)!=="static_artifact")return;const k=uA(r,r.sessionId,P.workItemId);if(k)return{sessionId:r.sessionId,variantId:P.workItemId,label:P.label,url:k,source:"live"}},[r,i,a,s]),u=Wk(i,r)??(a?c:void 0),f=Wk(a,r)??(i?c:void 0),h=!i&&!!u,p=!a&&!!f,m=!!(u||f),_=E.jsx(YK,{isInteractionDisabled:t.isInteractionDisabled,framework:t.framework,userPort:t.userPort});return E.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 flex-col",children:E.jsxs("div",{className:`variant-preview-region relative flex h-full min-h-0 w-full flex-1 flex-col ${n?"is-dragging":""} ${m?"is-split":""}`,children:[E.jsxs("div",{className:"variant-preview-row flex h-full min-h-0 w-full flex-1",children:[u&&E.jsx(zk,{side:"left",sessionId:u.sessionId,variantId:u.variantId,url:u.url,label:u.label,source:u.source,isFallback:h},`left-${u.sessionId}:${u.variantId}:${u.url}`),!(u&&f)&&E.jsx("div",{className:"variant-preview-primary flex h-full min-h-0 flex-1 flex-col",children:_}),f&&E.jsx(zk,{side:"right",sessionId:f.sessionId,variantId:f.variantId,url:f.url,label:f.label,source:f.source,isFallback:p},`right-${f.sessionId}:${f.variantId}:${f.url}`)]}),E.jsx("div",{className:"variant-preview-atmosphere","aria-hidden":"true"}),E.jsx(QK,{}),E.jsx(XK,{})]})})}function Gi(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function dA(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}/*!
115
115
  * GSAP 3.15.0
116
116
  * https://gsap.com
117
117
  *
@@ -419,4 +419,4 @@ ${s}`:s},LG=({rows:t,activeVariantId:e,activePastKey:n,isOriginalSelected:r,busy
419
419
  <body>
420
420
  <div class="panel">${E8}</div>
421
421
  </body>
422
- </html>`,c2=274,Qm=395,z1=Math.min(Qm,Math.round((c2+Qm)/2*1.1)),k8="rivet:panelWidth:v2",wJ=t=>{if(!(t instanceof HTMLElement))return!1;const e=t.tagName.toLowerCase();return t.isContentEditable||e==="input"||e==="textarea"||e==="select"},bJ=({projectPath:t})=>{const e=et(rR)>0,[n,r]=HP(tR),s=w$(),[i,a]=v.useState(()=>{if(typeof window>"u")return z1;const k=Number(window.localStorage.getItem(k8));return Number.isFinite(k)&&k>=c2&&k<=Qm?k:z1}),[c,u]=v.useState(!1),[f,h]=v.useState($q),p=n?i:0,[m,_]=v.useState(n);v.useEffect(()=>{if(!n){_(!1);return}h(k=>Vq({position:k,boundsLeftPx:i}))},[n,i]),v.useEffect(()=>{window.localStorage.setItem(k8,String(i))},[i]),v.useEffect(()=>{if(!n)return;const k=R=>{R.key==="Escape"&&(wJ(R.target)||(R.preventDefault(),r(!1)))};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[n,r]);const x=v.useCallback(k=>{k.preventDefault(),k.stopPropagation();const R=k.clientX,L=i;u(!0);const O=I=>{const N=Math.min(Qm,Math.max(c2,L+(I.clientX-R)));a(N)},A=()=>{window.removeEventListener("pointermove",O),window.removeEventListener("pointerup",A),window.removeEventListener("pointercancel",A),u(!1)};window.addEventListener("pointermove",O),window.addEventListener("pointerup",A),window.addEventListener("pointercancel",A)},[i]),y=v.useCallback(()=>a(z1),[]),w=Jq(),S=et(Tf);nY({enabled:!S});const T=w.isProcessing?"Completing authentication...":null,P=at(lR);return v.useEffect(()=>{P(t??null)},[t,P]),E.jsxs(xl.div,{className:"relative flex h-screen overflow-hidden",initial:!1,animate:{opacity:1},transition:{duration:.5,ease:"easeOut"},"data-cy":"rivet-app",children:[T!==null?E.jsx("div",{className:"absolute inset-0 z-50",children:E.jsx(kq,{message:T})}):null,E.jsx("div",{className:"relative flex min-w-0 flex-1 flex-col",children:E.jsx(eZ,{})}),E.jsx(E.Fragment,{children:e?null:E.jsxs(E.Fragment,{children:[E.jsx("div",{className:"relative order-first h-full flex-shrink-0",style:{width:m?i:0},children:E.jsxs(xl.div,{className:"absolute inset-y-0 left-0 z-30",initial:!1,animate:{x:n?0:-i},transition:s?{duration:0}:{duration:.2,ease:[.22,1,.36,1]},onAnimationComplete:()=>{n&&_(!0)},style:{width:i,willChange:"transform"},children:[E.jsx(hK,{onClose:()=>r(!1)}),E.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize panel",onPointerDown:x,onDoubleClick:y,className:"group/resize absolute inset-y-0 right-0 z-20 flex w-3 cursor-col-resize touch-none justify-end",children:E.jsx("span",{className:`h-full transition-all duration-150 ${c?"bg-content-muted w-0.5":"bg-divider group-hover/resize:bg-content-muted w-px group-hover/resize:w-0.5"}`})})]})}),c&&E.jsx("div",{className:"fixed inset-0 z-[100] cursor-col-resize"}),E.jsx(Uq,{isVisible:!0,isPanelOpen:n,isReducedMotion:!!s,position:f,dragBoundsLeftPx:p,onPositionChange:h,onToggle:()=>r(k=>!k)})]})}),E.jsx(q$,{duration:5e3,richColors:!0,toastOptions:{style:{maxHeight:"150px",overflow:"hidden"}}})]})},u2="rivet_connect_deep_link",SJ=()=>{if(typeof window>"u")return null;const t=new URLSearchParams(window.location.search),e=t.get("connect"),n=e??window.sessionStorage.getItem(u2);if(n!=="pinterest"&&n!=="arena")return null;if(window.sessionStorage.setItem(u2,n),e){t.delete("connect");const r=t.toString();window.history.replaceState(null,document.title,window.location.pathname+(r?`?${r}`:"")+window.location.hash)}return n},EJ=SJ(),CJ=()=>{const[t,e]=v.useState(window.location.hash),[n]=v.useState(()=>typeof window<"u"&&window.sessionStorage.getItem(Kp)==="1"),[r,s]=v.useState(!1),[i,a]=v.useState(EJ);v.useEffect(()=>{n&&window.sessionStorage.removeItem(Kp)},[n]);const{config:c,refetchConfig:u,loading:f,error:h}=Xq(),p=at(Tf),[m,_]=v.useState(!1),[x,y]=v.useState(null),[w,S]=v.useState(!1);v.useEffect(()=>{c!=null&&c.userId?(be.identify(c.userId,{...c.email?{email:c.email}:{}}),c.email&&be.alias(c.email,c.userId)):c!=null&&c.email&&be.identify(c.email,{email:c.email})},[c==null?void 0:c.userId,c==null?void 0:c.email]),v.useEffect(()=>{c&&be.register({source:"visual_editor",surface:"visual_editor"})},[c]);const T=v.useCallback(async()=>{var K;const I=globalThis.crypto.randomUUID(),N=Date.now();_(!0),y(null);const j=H1({outcome:"started",authAttemptId:I,startedAt:N,now:N});be.capture(j.event,j.properties);let F=null;try{if(F=window.open("","_blank"),!F)throw new Error("Pop-up blocked. Please allow pop-ups and try again.");try{F.document.open(),F.document.write(xJ),F.document.close()}catch(G){S8.warn("Failed to render loading state in auth popup:",G)}const X=await fetch(`${C8}/api/auth/google/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:"desktop"})}),W=await X.json();if(!X.ok||!W.success||!W.authUrl||!W.sessionId||!W.pollSecret)throw new Error(W.error||W.message||"Failed to start Google login");if(F.closed)throw new Error("Sign-in window was closed before Google login started.");F.location.href=W.authUrl;for(let G=0;G<_J;G+=1){if(F.closed)throw new Error("Sign-in window was closed before authentication completed.");const $=await(await fetch(`${C8}/api/auth/google/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session:W.sessionId,pollSecret:W.pollSecret})})).json();if($.success&&$.token&&((K=$.user)!=null&&K.email)){if(!(await fetch("/api/auth/store",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:$.user.email,token:$.token,refreshToken:$.refreshToken,userId:$.user.id})})).ok)throw new Error("Signed in, but failed to store session locally.");F.close(),window.sessionStorage.setItem(Kp,"1");const H=H1({outcome:"completed",authAttemptId:I,startedAt:N,now:Date.now()});be.capture(H.event,H.properties),window.location.reload();return}if($.error&&$.error!=="Pending")throw new Error($.error||"Google login failed");await new Promise(ne=>setTimeout(ne,yJ))}throw new Error("Authentication timed out. Please try again.")}catch(X){F&&!F.closed&&F.close();const W=X instanceof Error?X.message:"Failed to start login flow";S8.warn("Login failed:",W);const G=H1({outcome:"failed",authAttemptId:I,startedAt:N,now:Date.now(),failureReason:vJ(W)});be.capture(G.event,G.properties),y(W),_(!1)}},[]),P=c!=null&&c.agentModeAvailable!==!0,k=gJ(t),R=v.useCallback(async()=>{S(!0),p(!0);try{await u()}finally{p(!1),S(!1)}},[u,p]);if(v.useEffect(()=>{const I=()=>{const N=window.location.hash;e(N)};return window.addEventListener("hashchange",I),()=>window.removeEventListener("hashchange",I)},[]),k==="design-system")return E.jsx(mJ,{});if(!f&&c===null&&!w){const I=h||"Could not load Rivet configuration.";return E.jsx("div",{className:"bg-main flex h-screen items-center justify-center px-6",children:E.jsxs("div",{className:"border-divider bg-main w-full max-w-md rounded-lg border p-6 text-center shadow-lg",children:[E.jsx("p",{className:"text-content text-sm font-medium",children:"We could not start Rivet yet."}),E.jsx("p",{className:"text-content-dim mt-2 text-xs",children:I}),E.jsx("button",{type:"button",className:"border-divider text-content hover:bg-main/80 mt-4 rounded-md border px-3 py-1.5 text-xs",onClick:()=>{R()},children:"Retry"})]})})}if(P)return E.jsx(Eq,{isSigningIn:m,onStartSignIn:()=>{T()},errorMessage:x,displayMode:"full"});const O=(c==null?void 0:c.agentModeAvailable)===!0&&i!==null,A=(c==null?void 0:c.agentModeAvailable)===!0&&n&&!r&&!O;return E.jsxs(E.Fragment,{children:[E.jsx(bJ,{projectPath:c==null?void 0:c.projectPath}),E.jsx(z_,{context:"onboarding",isOpen:A,onClose:()=>s(!0)}),E.jsx(z_,{context:"menu",isOpen:O,highlightProvider:i,onClose:()=>{window.sessionStorage.removeItem(u2),a(null)}})]})},kJ="phc_Ntj9tXHbS64XgYxlTfhglRmFivFsfm0AERph4ZlnNH",PJ=new tL,TJ={session_recording:{maskAllInputs:!0,maskTextSelector:"[data-rivet-private]"}},RJ=()=>E.jsx("div",{style:{display:"flex",height:"100vh",alignItems:"center",justifyContent:"center"},children:E.jsx("p",{style:{fontSize:"14px",color:"#6b7280"},children:"Something went wrong. Please reload the page."})});GD.createRoot(document.getElementById("root")).render(E.jsx(ve.StrictMode,{children:E.jsx(DD,{apiKey:kJ,options:{api_host:"https://rivet-proxy.onrender.com/ingest",ui_host:"https://us.posthog.com",person_profiles:"always",capture_exceptions:!0,autocapture:!0,capture_pageview:!0,capture_performance:!0,persistence:"localStorage",...TJ,mask_all_text:!1,mask_all_element_attributes:!1,loaded:t=>{t.register({source:"visual_editor",surface:"visual_editor",telemetry_version:2,rivet_version:"0.14.16",env:"production"})}},children:E.jsx($D,{fallback:E.jsx(RJ,{}),children:E.jsx(nL,{client:PJ,children:E.jsx(mG,{defaultShape:"rounded",children:E.jsx(MQ,{defaultLibrary:"lucide",children:E.jsx(CJ,{})})})})})})}));
422
+ </html>`,c2=274,Qm=395,z1=Math.min(Qm,Math.round((c2+Qm)/2*1.1)),k8="rivet:panelWidth:v2",wJ=t=>{if(!(t instanceof HTMLElement))return!1;const e=t.tagName.toLowerCase();return t.isContentEditable||e==="input"||e==="textarea"||e==="select"},bJ=({projectPath:t})=>{const e=et(rR)>0,[n,r]=HP(tR),s=w$(),[i,a]=v.useState(()=>{if(typeof window>"u")return z1;const k=Number(window.localStorage.getItem(k8));return Number.isFinite(k)&&k>=c2&&k<=Qm?k:z1}),[c,u]=v.useState(!1),[f,h]=v.useState($q),p=n?i:0,[m,_]=v.useState(n);v.useEffect(()=>{if(!n){_(!1);return}h(k=>Vq({position:k,boundsLeftPx:i}))},[n,i]),v.useEffect(()=>{window.localStorage.setItem(k8,String(i))},[i]),v.useEffect(()=>{if(!n)return;const k=R=>{R.key==="Escape"&&(wJ(R.target)||(R.preventDefault(),r(!1)))};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[n,r]);const x=v.useCallback(k=>{k.preventDefault(),k.stopPropagation();const R=k.clientX,L=i;u(!0);const O=I=>{const N=Math.min(Qm,Math.max(c2,L+(I.clientX-R)));a(N)},A=()=>{window.removeEventListener("pointermove",O),window.removeEventListener("pointerup",A),window.removeEventListener("pointercancel",A),u(!1)};window.addEventListener("pointermove",O),window.addEventListener("pointerup",A),window.addEventListener("pointercancel",A)},[i]),y=v.useCallback(()=>a(z1),[]),w=Jq(),S=et(Tf);nY({enabled:!S});const T=w.isProcessing?"Completing authentication...":null,P=at(lR);return v.useEffect(()=>{P(t??null)},[t,P]),E.jsxs(xl.div,{className:"relative flex h-screen overflow-hidden",initial:!1,animate:{opacity:1},transition:{duration:.5,ease:"easeOut"},"data-cy":"rivet-app",children:[T!==null?E.jsx("div",{className:"absolute inset-0 z-50",children:E.jsx(kq,{message:T})}):null,E.jsx("div",{className:"relative flex min-w-0 flex-1 flex-col",children:E.jsx(eZ,{})}),E.jsx(E.Fragment,{children:e?null:E.jsxs(E.Fragment,{children:[E.jsx("div",{className:"relative order-first h-full flex-shrink-0",style:{width:m?i:0},children:E.jsxs(xl.div,{className:"absolute inset-y-0 left-0 z-30",initial:!1,animate:{x:n?0:-i},transition:s?{duration:0}:{duration:.2,ease:[.22,1,.36,1]},onAnimationComplete:()=>{n&&_(!0)},style:{width:i,willChange:"transform"},children:[E.jsx(hK,{onClose:()=>r(!1)}),E.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize panel",onPointerDown:x,onDoubleClick:y,className:"group/resize absolute inset-y-0 right-0 z-20 flex w-3 cursor-col-resize touch-none justify-end",children:E.jsx("span",{className:`h-full transition-all duration-150 ${c?"bg-content-muted w-0.5":"bg-divider group-hover/resize:bg-content-muted w-px group-hover/resize:w-0.5"}`})})]})}),c&&E.jsx("div",{className:"fixed inset-0 z-[100] cursor-col-resize"}),E.jsx(Uq,{isVisible:!0,isPanelOpen:n,isReducedMotion:!!s,position:f,dragBoundsLeftPx:p,onPositionChange:h,onToggle:()=>r(k=>!k)})]})}),E.jsx(q$,{duration:5e3,richColors:!0,toastOptions:{style:{maxHeight:"150px",overflow:"hidden"}}})]})},u2="rivet_connect_deep_link",SJ=()=>{if(typeof window>"u")return null;const t=new URLSearchParams(window.location.search),e=t.get("connect"),n=e??window.sessionStorage.getItem(u2);if(n!=="pinterest"&&n!=="arena")return null;if(window.sessionStorage.setItem(u2,n),e){t.delete("connect");const r=t.toString();window.history.replaceState(null,document.title,window.location.pathname+(r?`?${r}`:"")+window.location.hash)}return n},EJ=SJ(),CJ=()=>{const[t,e]=v.useState(window.location.hash),[n]=v.useState(()=>typeof window<"u"&&window.sessionStorage.getItem(Kp)==="1"),[r,s]=v.useState(!1),[i,a]=v.useState(EJ);v.useEffect(()=>{n&&window.sessionStorage.removeItem(Kp)},[n]);const{config:c,refetchConfig:u,loading:f,error:h}=Xq(),p=at(Tf),[m,_]=v.useState(!1),[x,y]=v.useState(null),[w,S]=v.useState(!1);v.useEffect(()=>{c!=null&&c.userId?(be.identify(c.userId,{...c.email?{email:c.email}:{}}),c.email&&be.alias(c.email,c.userId)):c!=null&&c.email&&be.identify(c.email,{email:c.email})},[c==null?void 0:c.userId,c==null?void 0:c.email]),v.useEffect(()=>{c&&be.register({source:"visual_editor",surface:"visual_editor"})},[c]);const T=v.useCallback(async()=>{var K;const I=globalThis.crypto.randomUUID(),N=Date.now();_(!0),y(null);const j=H1({outcome:"started",authAttemptId:I,startedAt:N,now:N});be.capture(j.event,j.properties);let F=null;try{if(F=window.open("","_blank"),!F)throw new Error("Pop-up blocked. Please allow pop-ups and try again.");try{F.document.open(),F.document.write(xJ),F.document.close()}catch(G){S8.warn("Failed to render loading state in auth popup:",G)}const X=await fetch(`${C8}/api/auth/google/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:"desktop"})}),W=await X.json();if(!X.ok||!W.success||!W.authUrl||!W.sessionId||!W.pollSecret)throw new Error(W.error||W.message||"Failed to start Google login");if(F.closed)throw new Error("Sign-in window was closed before Google login started.");F.location.href=W.authUrl;for(let G=0;G<_J;G+=1){if(F.closed)throw new Error("Sign-in window was closed before authentication completed.");const $=await(await fetch(`${C8}/api/auth/google/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session:W.sessionId,pollSecret:W.pollSecret})})).json();if($.success&&$.token&&((K=$.user)!=null&&K.email)){if(!(await fetch("/api/auth/store",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:$.user.email,token:$.token,refreshToken:$.refreshToken,userId:$.user.id})})).ok)throw new Error("Signed in, but failed to store session locally.");F.close(),window.sessionStorage.setItem(Kp,"1");const H=H1({outcome:"completed",authAttemptId:I,startedAt:N,now:Date.now()});be.capture(H.event,H.properties),window.location.reload();return}if($.error&&$.error!=="Pending")throw new Error($.error||"Google login failed");await new Promise(ne=>setTimeout(ne,yJ))}throw new Error("Authentication timed out. Please try again.")}catch(X){F&&!F.closed&&F.close();const W=X instanceof Error?X.message:"Failed to start login flow";S8.warn("Login failed:",W);const G=H1({outcome:"failed",authAttemptId:I,startedAt:N,now:Date.now(),failureReason:vJ(W)});be.capture(G.event,G.properties),y(W),_(!1)}},[]),P=c!=null&&c.agentModeAvailable!==!0,k=gJ(t),R=v.useCallback(async()=>{S(!0),p(!0);try{await u()}finally{p(!1),S(!1)}},[u,p]);if(v.useEffect(()=>{const I=()=>{const N=window.location.hash;e(N)};return window.addEventListener("hashchange",I),()=>window.removeEventListener("hashchange",I)},[]),k==="design-system")return E.jsx(mJ,{});if(!f&&c===null&&!w){const I=h||"Could not load Rivet configuration.";return E.jsx("div",{className:"bg-main flex h-screen items-center justify-center px-6",children:E.jsxs("div",{className:"border-divider bg-main w-full max-w-md rounded-lg border p-6 text-center shadow-lg",children:[E.jsx("p",{className:"text-content text-sm font-medium",children:"We could not start Rivet yet."}),E.jsx("p",{className:"text-content-dim mt-2 text-xs",children:I}),E.jsx("button",{type:"button",className:"border-divider text-content hover:bg-main/80 mt-4 rounded-md border px-3 py-1.5 text-xs",onClick:()=>{R()},children:"Retry"})]})})}if(P)return E.jsx(Eq,{isSigningIn:m,onStartSignIn:()=>{T()},errorMessage:x,displayMode:"full"});const O=(c==null?void 0:c.agentModeAvailable)===!0&&i!==null,A=(c==null?void 0:c.agentModeAvailable)===!0&&n&&!r&&!O;return E.jsxs(E.Fragment,{children:[E.jsx(bJ,{projectPath:c==null?void 0:c.projectPath}),E.jsx(z_,{context:"onboarding",isOpen:A,onClose:()=>s(!0)}),E.jsx(z_,{context:"menu",isOpen:O,highlightProvider:i,onClose:()=>{window.sessionStorage.removeItem(u2),a(null)}})]})},kJ="phc_Ntj9tXHbS64XgYxlTfhglRmFivFsfm0AERph4ZlnNH",PJ=new tL,TJ={session_recording:{maskAllInputs:!0,maskTextSelector:"[data-rivet-private]"}},RJ=()=>E.jsx("div",{style:{display:"flex",height:"100vh",alignItems:"center",justifyContent:"center"},children:E.jsx("p",{style:{fontSize:"14px",color:"#6b7280"},children:"Something went wrong. Please reload the page."})});GD.createRoot(document.getElementById("root")).render(E.jsx(ve.StrictMode,{children:E.jsx(DD,{apiKey:kJ,options:{api_host:"https://rivet-proxy.onrender.com/ingest",ui_host:"https://us.posthog.com",person_profiles:"always",capture_exceptions:!0,autocapture:!0,capture_pageview:!0,capture_performance:!0,persistence:"localStorage",...TJ,mask_all_text:!1,mask_all_element_attributes:!1,loaded:t=>{t.register({source:"visual_editor",surface:"visual_editor",telemetry_version:2,rivet_version:"0.14.17",env:"production"})}},children:E.jsx($D,{fallback:E.jsx(RJ,{}),children:E.jsx(nL,{client:PJ,children:E.jsx(mG,{defaultShape:"rounded",children:E.jsx(MQ,{defaultLibrary:"lucide",children:E.jsx(CJ,{})})})})})})}));