@tscircuit/runframe 0.0.2907 → 0.0.2909
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.
|
@@ -237,7 +237,7 @@ You might need to use a local HTTP server (instead of file://): https://react.de
|
|
|
237
237
|
|
|
238
238
|
let root = createRoot(domContainer);
|
|
239
239
|
root.render(<App />);`),v.unstable_strictMode===!0&&(L=!0),v.identifierPrefix!==void 0&&(j=v.identifierPrefix),v.onUncaughtError!==void 0&&(ae=v.onUncaughtError),v.onCaughtError!==void 0&&(fe=v.onCaughtError),v.onRecoverableError!==void 0&&(ze=v.onRecoverableError),v.unstable_transitionCallbacks!==void 0&&(at=v.unstable_transitionCallbacks)),v=Rt(b,1,!1,null,null,L,j,ae,fe,ze,at,null),b[q0]=v.current,ZE(b),new F1(v)},OK.hydrateRoot=function(b,v,L){if(!_(b))throw Error("Target container is not a DOM element.");gp(b),v===void 0&&console.error("Must provide initial children as second argument to hydrateRoot. Example usage: hydrateRoot(domContainer, <App />)");var j=!1,ae="",fe=f4,ze=z0,at=bm,Mt=null,Vt=null;return L!=null&&(L.unstable_strictMode===!0&&(j=!0),L.identifierPrefix!==void 0&&(ae=L.identifierPrefix),L.onUncaughtError!==void 0&&(fe=L.onUncaughtError),L.onCaughtError!==void 0&&(ze=L.onCaughtError),L.onRecoverableError!==void 0&&(at=L.onRecoverableError),L.unstable_transitionCallbacks!==void 0&&(Mt=L.unstable_transitionCallbacks),L.formState!==void 0&&(Vt=L.formState)),v=Rt(b,1,!0,v,L??null,j,ae,fe,ze,at,Mt,Vt),v.context=ln(null),L=v.current,j=Ud(L),j=At(j),ae=tp(j),ae.callback=null,C0(L,ae,j),L=j,v.current.lanes=L,He(v,L),Cu(v),b[q0]=v.current,ZE(b),new w_(v)},OK.version="19.1.0",typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})(),OK}var Mot;function pEn(){if(Mot)return bte.exports;Mot=1;var t={env:{}};function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function")){if(t.env.NODE_ENV!=="production")throw new Error("^_^");try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}}return t.env.NODE_ENV==="production"?(e(),bte.exports=dEn()):bte.exports=hEn(),bte.exports}var mEn=pEn(),te=w3();const ks=dy(te),h5=nx({__proto__:null,default:ks},[te]);var _En=Object.defineProperty,xk=(t,e)=>_En(t,"name",{value:e,configurable:!0}),Dot=!!(typeof window<"u"&&window.document&&window.document.createElement);function _r(t,e,{checkForDefaultPrevented:n=!0}={}){return xk(function(i){if(t?.(i),n===!1||!i||!i.defaultPrevented)return e?.(i)},"handleEvent")}xk(_r,"composeEventHandlers");function fEn(t){if(!Dot)throw new Error("Cannot access window outside of the DOM");return t?.ownerDocument?.defaultView??window}xk(fEn,"getOwnerWindow");function aye(t){if(!Dot)throw new Error("Cannot access document outside of the DOM");return t?.ownerDocument??document}xk(aye,"getOwnerDocument");function Not(t,e=!1){const{activeElement:n}=aye(t);if(!n?.nodeName)return null;if(Rot(n)&&n.contentDocument)return Not(n.contentDocument.body,e);if(e){const o=n.getAttribute("aria-activedescendant");if(o){const i=aye(n).getElementById(o);if(i)return i}}return n}xk(Not,"getActiveElement");function Rot(t){return t.tagName==="IFRAME"}xk(Rot,"isFrame");var IEn=Object.defineProperty,p5=(t,e)=>IEn(t,"name",{value:e,configurable:!0});function CEn(t,e){const n=te.createContext(e);n.displayName=t+"Context";const o=p5(r=>{const{children:s,...a}=r,A=te.useMemo(()=>a,Object.values(a));return V.jsx(n.Provider,{value:A,children:s})},"Provider");o.displayName=t+"Provider";function i(r,s={}){const{optional:a=!1}=s,A=te.useContext(n);if(A)return A;if(e!==void 0)return e;if(!a)throw new Error(`\`${r}\` must be used within \`${t}\``)}return p5(i,"useContext"),[o,i]}p5(CEn,"createContext");function P3(t,e=[]){let n=[];function o(r,s){const a=te.createContext(s);a.displayName=r+"Context";const A=n.length;n=[...n,s];const c=p5(g=>{const{scope:u,children:h,...d}=g,p=u?.[t]?.[A]||a,m=te.useMemo(()=>d,Object.values(d));return V.jsx(p.Provider,{value:m,children:h})},"Provider");c.displayName=r+"Provider";function l(g,u,h={}){const{optional:d=!1}=h,p=u?.[t]?.[A]||a,m=te.useContext(p);if(m)return m;if(s!==void 0)return s;if(!d)throw new Error(`\`${g}\` must be used within \`${r}\``)}return p5(l,"useContext"),[c,l]}p5(o,"createContext");const i=p5(()=>{const r=n.map(s=>te.createContext(s));return p5(function(a){const A=a?.[t]||r;return te.useMemo(()=>({[`__scope${t}`]:{...a,[t]:A}}),[a,A])},"useScope")},"createScope");return i.scopeName=t,[o,Tot(i,...e)]}p5(P3,"createContextScope");function Tot(...t){const e=t[0];if(t.length===1)return e;const n=p5(()=>{const o=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return p5(function(r){const s=o.reduce((a,{useScope:A,scopeName:c})=>{const g=A(r)[`__scope${c}`];return{...a,...g}},{});return te.useMemo(()=>({[`__scope${e.scopeName}`]:s}),[s])},"useComposedScopes")},"createScope");return n.scopeName=e.scopeName,n}p5(Tot,"composeContextScopes");var yEn=Object.defineProperty,Aye=(t,e)=>yEn(t,"name",{value:e,configurable:!0});function cye(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}Aye(cye,"setRef");function kot(...t){return e=>{let n=!1;const o=t.map(i=>{const r=cye(i,e);return!n&&typeof r=="function"&&(n=!0),r});if(n)return()=>{for(let i=0;i<o.length;i++){const r=o[i];typeof r=="function"?r():cye(t[i],null)}}}}Aye(kot,"composeRefs");function lc(...t){return te.useCallback(kot(...t),t)}Aye(lc,"useComposedRefs");var xEn=Object.defineProperty,D4=(t,e)=>xEn(t,"name",{value:e,configurable:!0});function I9(t){const e=te.forwardRef((n,o)=>{let{children:i,...r}=n,s=null,a=!1;const A=[];lye(i)&&typeof wte=="function"&&(i=wte(i._payload)),te.Children.forEach(i,u=>{if(Got(u)){a=!0;const h=u;let d="child"in h.props?h.props.child:h.props.children;lye(d)&&typeof wte=="function"&&(d=wte(d._payload)),s=BEn(h,d),A.push(s?.props?.children)}else A.push(u)}),s?s=te.cloneElement(s,void 0,A):!a&&te.Children.count(i)===1&&te.isValidElement(i)&&(s=i);const c=s?Oot(s):void 0,l=lc(o,c);if(!s){if(i||i===0)throw new Error(a?QEn(t):SEn(t));return i}const g=Hot(r,s.props??{});return s.type!==te.Fragment&&(g.ref=o?l:c),te.cloneElement(s,g)});return e.displayName=`${t}.Slot`,e}D4(I9,"createSlot");var EEn=I9("Slot"),Fot=Symbol.for("radix.slottable");function Lot(t){const e=D4(n=>"child"in n?n.children(n.child):n.children,"Slottable");return e.displayName=`${t}.Slottable`,e.__radixId=Fot,e}D4(Lot,"createSlottable");var BEn=D4((t,e)=>{if("child"in t.props){const n=t.props.child;return te.isValidElement(n)?te.cloneElement(n,void 0,t.props.children(n.props.children)):null}return te.isValidElement(e)?e:null},"getSlottableElementFromSlottable");function Hot(t,e){const n={...e};for(const o in e){const i=t[o],r=e[o];/^on[A-Z]/.test(o)?i&&r?n[o]=(...a)=>{const A=r(...a);return i(...a),A}:i&&(n[o]=i):o==="style"?n[o]={...i,...r}:o==="className"&&(n[o]=[i,r].filter(Boolean).join(" "))}return{...t,...n}}D4(Hot,"mergeProps");function Oot(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}D4(Oot,"getElementRef");function Got(t){return te.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Fot}D4(Got,"isSlottable");var bEn=Symbol.for("react.lazy");function lye(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===bEn&&"_payload"in t&&Yot(t._payload)}D4(lye,"isLazyComponent");function Yot(t){return typeof t=="object"&&t!==null&&"then"in t}D4(Yot,"isPromiseLike");var SEn=D4(t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),QEn=D4(t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),wte=h5[" use ".trim().toString()],vEn=Object.defineProperty,Uf=(t,e)=>vEn(t,"name",{value:e,configurable:!0});function Pte(t){const e=t+"CollectionProvider",[n,o]=P3(e),[i,r]=n(e,{collectionRef:{current:null},itemMap:new Map}),s=Uf(p=>{const{scope:m,children:_}=p,f=te.useRef(null),I=te.useRef(new Map).current;return V.jsx(i,{scope:m,itemMap:I,collectionRef:f,children:_})},"CollectionProvider");s.displayName=e;const a=t+"CollectionSlot",A=I9(a),c=te.forwardRef((p,m)=>{const{scope:_,children:f}=p,I=r(a,_),C=lc(m,I.collectionRef);return V.jsx(A,{ref:C,children:f})});c.displayName=a;const l=t+"CollectionItemSlot",g="data-radix-collection-item",u=I9(l),h=te.forwardRef((p,m)=>{const{scope:_,children:f,...I}=p,C=te.useRef(null),y=lc(m,C),x=r(l,_);return te.useEffect(()=>(x.itemMap.set(C,{ref:C,...I}),()=>{x.itemMap.delete(C)})),V.jsx(u,{[g]:"",ref:y,children:f})});h.displayName=l;function d(p){const m=r(t+"CollectionConsumer",p);return te.useCallback(()=>{const f=m.collectionRef.current;if(!f)return[];const I=Array.from(f.querySelectorAll(`[${g}]`));return Array.from(m.itemMap.values()).sort((x,E)=>I.indexOf(x.ref.current)-I.indexOf(E.ref.current))},[m.collectionRef,m.itemMap])}return Uf(d,"useCollection"),[{Provider:s,Slot:c,ItemSlot:h},d,o]}Uf(Pte,"createCollection");var Uot=new WeakMap,gye=(ME=class extends Map{constructor(n){super(n);qnt(this,u_);Ate(this,u_,[...super.keys()]),Uot.set(this,!0)}set(n,o){return Uot.get(this)&&(this.has(n)?v0(this,u_)[v0(this,u_).indexOf(n)]=n:v0(this,u_).push(n)),super.set(n,o),this}insert(n,o,i){const r=this.has(o),s=v0(this,u_).length,a=uye(n);let A=a>=0?a:s+a;const c=A<0||A>=s?-1:A;if(c===this.size||r&&c===this.size-1||c===-1)return this.set(o,i),this;const l=this.size+(r?0:1);a<0&&A++;const g=[...v0(this,u_)];let u,h=!1;for(let d=A;d<l;d++)if(A===d){let p=g[d];g[d]===o&&(p=g[d+1]),r&&this.delete(o),u=this.get(p),this.set(o,i)}else{!h&&g[d-1]===o&&(h=!0);const p=g[h?d:d-1],m=u;u=this.get(p),this.delete(p),this.set(p,m)}return this}with(n,o,i){const r=new ME(this);return r.insert(n,o,i),r}before(n){const o=v0(this,u_).indexOf(n)-1;if(!(o<0))return this.entryAt(o)}setBefore(n,o,i){const r=v0(this,u_).indexOf(n);return r===-1?this:this.insert(r,o,i)}after(n){let o=v0(this,u_).indexOf(n);if(o=o===-1||o===this.size-1?-1:o+1,o!==-1)return this.entryAt(o)}setAfter(n,o,i){const r=v0(this,u_).indexOf(n);return r===-1?this:this.insert(r+1,o,i)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return Ate(this,u_,[]),super.clear()}delete(n){const o=super.delete(n);return o&&v0(this,u_).splice(v0(this,u_).indexOf(n),1),o}deleteAt(n){const o=this.keyAt(n);return o!==void 0?this.delete(o):!1}at(n){const o=Mte(v0(this,u_),n);if(o!==void 0)return this.get(o)}entryAt(n){const o=Mte(v0(this,u_),n);if(o!==void 0)return[o,this.get(o)]}indexOf(n){return v0(this,u_).indexOf(n)}keyAt(n){return Mte(v0(this,u_),n)}from(n,o){const i=this.indexOf(n);if(i===-1)return;let r=i+o;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(n,o){const i=this.indexOf(n);if(i===-1)return;let r=i+o;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(n,o){let i=0;for(const r of this){if(Reflect.apply(n,o,[r,i,this]))return r;i++}}findIndex(n,o){let i=0;for(const r of this){if(Reflect.apply(n,o,[r,i,this]))return i;i++}return-1}filter(n,o){const i=[];let r=0;for(const s of this)Reflect.apply(n,o,[s,r,this])&&i.push(s),r++;return new ME(i)}map(n,o){const i=[];let r=0;for(const s of this)i.push([s[0],Reflect.apply(n,o,[s,r,this])]),r++;return new ME(i)}reduce(...n){const[o,i]=n;let r=0,s=i??this.at(0);for(const a of this)r===0&&n.length===1?s=a:s=Reflect.apply(o,this,[s,a,r,this]),r++;return s}reduceRight(...n){const[o,i]=n;let r=i??this.at(-1);for(let s=this.size-1;s>=0;s--){const a=this.at(s);s===this.size-1&&n.length===1?r=a:r=Reflect.apply(o,this,[r,a,s,this])}return r}toSorted(n){const o=[...this.entries()].sort(n);return new ME(o)}toReversed(){const n=new ME;for(let o=this.size-1;o>=0;o--){const i=this.keyAt(o),r=this.get(i);n.set(i,r)}return n}toSpliced(...n){const o=[...this.entries()];return o.splice(...n),new ME(o)}slice(n,o){const i=new ME;let r=this.size-1;if(n===void 0)return i;n<0&&(n=n+this.size),o!==void 0&&o>0&&(r=o-1);for(let s=n;s<=r;s++){const a=this.keyAt(s),A=this.get(a);i.set(a,A)}return i}every(n,o){let i=0;for(const r of this){if(!Reflect.apply(n,o,[r,i,this]))return!1;i++}return!0}some(n,o){let i=0;for(const r of this){if(Reflect.apply(n,o,[r,i,this]))return!0;i++}return!1}},u_=new WeakMap,Uf(ME,"OrderedDict"),ME);function Mte(t,e){if("at"in Array.prototype)return Array.prototype.at.call(t,e);const n=Kot(t,e);return n===-1?void 0:t[n]}Uf(Mte,"at");function Kot(t,e){const n=t.length,o=uye(e),i=o>=0?o:n+o;return i<0||i>=n?-1:i}Uf(Kot,"toSafeIndex");function uye(t){return t!==t||t===0?0:Math.trunc(t)}Uf(uye,"toSafeInteger");function wEn(t){const e=t+"CollectionProvider",[n,o]=P3(e),[i,r]=n(e,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new gye,setItemMap:Uf(()=>{},"setItemMap")}),s=Uf(({state:I,...C})=>I?V.jsx(A,{...C,state:I}):V.jsx(a,{...C}),"CollectionProvider");s.displayName=e;const a=Uf(I=>{const C=m();return V.jsx(A,{...I,state:C})},"CollectionInit");a.displayName=e+"Init";const A=Uf(I=>{const{scope:C,children:y,state:x}=I,E=te.useRef(null),[B,S]=te.useState(null),Q=lc(E,S),[w,M]=x;return te.useEffect(()=>{if(!B)return;const k=Jot(()=>{});return k.observe(B,{childList:!0,subtree:!0}),()=>{k.disconnect()}},[B]),V.jsx(i,{scope:C,itemMap:w,setItemMap:M,collectionRef:Q,collectionRefObject:E,collectionElement:B,children:y})},"CollectionProviderImpl");A.displayName=e+"Impl";const c=t+"CollectionSlot",l=I9(c),g=te.forwardRef((I,C)=>{const{scope:y,children:x}=I,E=r(c,y),B=lc(C,E.collectionRef);return V.jsx(l,{ref:B,children:x})});g.displayName=c;const u=t+"CollectionItemSlot",h="data-radix-collection-item",d=I9(u),p=te.forwardRef((I,C)=>{const{scope:y,children:x,...E}=I,B=te.useRef(null),[S,Q]=te.useState(null),w=lc(C,B,Q),M=r(u,y),{setItemMap:k}=M,R=te.useRef(E);Vot(R.current,E)||(R.current=E);const F=R.current;return te.useEffect(()=>{const O=F;return k(U=>S?U.has(S)?U.set(S,{...O,element:S}).toSorted(dye):(U.set(S,{...O,element:S}),U.toSorted(dye)):U),()=>{k(U=>!S||!U.has(S)?U:(U.delete(S),new gye(U)))}},[S,F,k]),V.jsx(d,{[h]:"",ref:w,children:x})});p.displayName=u;function m(){return te.useState(new gye)}Uf(m,"useInitCollection");function _(I){const{itemMap:C}=r(t+"CollectionConsumer",I);return C}return Uf(_,"useCollection"),[{Provider:s,Slot:g,ItemSlot:p},{createCollectionScope:o,useCollection:_,useInitCollection:m}]}Uf(wEn,"createCollection");function Vot(t,e){if(t===e)return!0;if(typeof t!="object"||typeof e!="object"||t==null||e==null)return!1;const n=Object.keys(t),o=Object.keys(e);if(n.length!==o.length)return!1;for(const i of n)if(!Object.prototype.hasOwnProperty.call(e,i)||t[i]!==e[i])return!1;return!0}Uf(Vot,"shallowEqual");function zot(t,e){return!!(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_PRECEDING)}Uf(zot,"isElementPreceding");function dye(t,e){return!t[1].element||!e[1].element?0:zot(t[1].element,e[1].element)?-1:1}Uf(dye,"sortByDocumentPosition");function Jot(t){return new MutationObserver(n=>{for(const o of n)if(o.type==="childList"){t();return}})}Uf(Jot,"getChildListObserver");var _p=globalThis?.document?te.useLayoutEffect:()=>{},PEn=Object.defineProperty,MEn=(t,e)=>PEn(t,"name",{value:e,configurable:!0}),DEn=h5[" useId ".trim().toString()]||(()=>{}),NEn=0;function M3(t){const[e,n]=te.useState(DEn());return _p(()=>{t||n(o=>o??String(NEn++))},[t]),t||(e?`radix-${e}`:"")}MEn(M3,"useId");var C9=sye();const Wot=dy(C9);var REn=Object.defineProperty,TEn=(t,e)=>REn(t,"name",{value:e,configurable:!0}),kEn=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],gc=kEn.reduce((t,e)=>{const n=I9(`Primitive.${e}`),o=te.forwardRef((i,r)=>{const{asChild:s,...a}=i,A=s?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),V.jsx(A,{...a,ref:r})});return o.displayName=`Primitive.${e}`,{...t,[e]:o}},{});function hye(t,e){t&&C9.flushSync(()=>t.dispatchEvent(e))}TEn(hye,"dispatchDiscreteCustomEvent");var FEn=Object.defineProperty,LEn=(t,e)=>FEn(t,"name",{value:e,configurable:!0});function D3(t){const e=te.useRef(t);return te.useEffect(()=>{e.current=t}),te.useMemo(()=>((...n)=>e.current?.(...n)),[])}LEn(D3,"useCallbackRef");var HEn=Object.defineProperty,OEn=(t,e)=>HEn(t,"name",{value:e,configurable:!0}),jot=h5[" useEffectEvent ".trim().toString()],Xot=h5[" useInsertionEffect ".trim().toString()];function qot(t){if(typeof jot=="function")return jot(t);const e=te.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof Xot=="function"?Xot(()=>{e.current=t}):_p(()=>{e.current=t}),te.useMemo(()=>((...n)=>e.current?.(...n)),[])}OEn(qot,"useEffectEvent");var GEn=Object.defineProperty,GK=(t,e)=>GEn(t,"name",{value:e,configurable:!0}),YEn=h5[" useInsertionEffect ".trim().toString()]||_p;function y9({prop:t,defaultProp:e,onChange:n=GK(()=>{},"onChange"),caller:o}){const[i,r,s]=$ot({defaultProp:e,onChange:n}),a=t!==void 0,A=a?t:i,c=te.useCallback(l=>{if(a){const g=Zot(l)?l(t):l;g!==t&&s.current?.(g)}else r(l)},[a,t,r,s]);return[A,c]}GK(y9,"useControllableState");function $ot({defaultProp:t,onChange:e}){const[n,o]=te.useState(t),i=te.useRef(n),r=te.useRef(e);return YEn(()=>{r.current=e},[e]),te.useEffect(()=>{i.current!==n&&(r.current?.(n),i.current=n)},[n,i]),[n,o,r]}GK($ot,"useUncontrolledState");function Zot(t){return typeof t=="function"}GK(Zot,"isFunction");var eit=Symbol("RADIX:SYNC_STATE");function UEn(t,e,n,o){const{prop:i,defaultProp:r,onChange:s,caller:a}=e,A=i!==void 0,c=qot(s),l=[{...n,state:r}];o&&l.push(o);const[g,u]=te.useReducer((m,_)=>{if(_.type===eit)return{...m,state:_.state};const f=t(m,_);return A&&!Object.is(f.state,m.state)&&c(f.state),f},...l),h=g.state,d=te.useRef(h);te.useEffect(()=>{d.current!==h&&(d.current=h,A||c(h))},[h,d,A]);const p=te.useMemo(()=>i!==void 0?{...g,state:i}:g,[g,i]);return te.useEffect(()=>{A&&!Object.is(i,g.state)&&u({type:eit,state:i})},[i,g.state,A]),[p,u]}GK(UEn,"useControllableStateReducer");var KEn=Object.defineProperty,VEn=(t,e)=>KEn(t,"name",{value:e,configurable:!0}),zEn=te.createContext(void 0);function YK(t){const e=te.useContext(zEn);return t||e||"ltr"}VEn(YK,"useDirection");var JEn=Object.defineProperty,pye=(t,e)=>JEn(t,"name",{value:e,configurable:!0}),mye=!1;function tit(){const[t,e]=te.useState(mye);return te.useEffect(()=>{mye||(mye=!0,e(!0))},[]),t}pye(tit,"useIsHydrated");var nit=h5[" useSyncExternalStore ".trim().toString()];function oit(){return()=>{}}pye(oit,"subscribe");function iit(){return nit(oit,()=>!0,()=>!1)}pye(iit,"useIsHydratedModern");var WEn=typeof nit=="function"?iit:tit,jEn=Object.defineProperty,MM=(t,e)=>jEn(t,"name",{value:e,configurable:!0}),_ye="rovingFocusGroup.onEntryFocus",XEn={bubbles:!1,cancelable:!0},Dte="RovingFocusGroup",[fye,rit,qEn]=Pte(Dte),[$En,Nte]=P3(Dte,[qEn]),[ZEn,e5n]=$En(Dte),t5n=te.forwardRef(MM(function(e,n){return V.jsx(fye.Provider,{scope:e.__scopeRovingFocusGroup,children:V.jsx(fye.Slot,{scope:e.__scopeRovingFocusGroup,children:V.jsx(n5n,{...e,ref:n})})})},"RovingFocusGroup")),n5n=te.forwardRef(MM(function(e,n){const{__scopeRovingFocusGroup:o,orientation:i,loop:r=!1,dir:s,currentTabStopId:a,defaultCurrentTabStopId:A,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:g=!1,...u}=e,h=te.useRef(null),d=lc(n,h),p=YK(s),[m,_]=y9({prop:a,defaultProp:A??null,onChange:c,caller:Dte}),[f,I]=te.useState(!1),C=D3(l),y=rit(o),x=te.useRef(!1),[E,B]=te.useState(0);return te.useEffect(()=>{const S=h.current;if(S)return S.addEventListener(_ye,C),()=>S.removeEventListener(_ye,C)},[C]),V.jsx(ZEn,{scope:o,orientation:i,dir:p,loop:r,currentTabStopId:m,onItemFocus:te.useCallback(S=>_(S),[_]),onItemShiftTab:te.useCallback(()=>I(!0),[]),onFocusableItemAdd:te.useCallback(()=>B(S=>S+1),[]),onFocusableItemRemove:te.useCallback(()=>B(S=>S-1),[]),children:V.jsx(gc.div,{tabIndex:f||E===0?-1:0,"data-orientation":i,...u,ref:d,style:{outline:"none",...e.style},onMouseDown:_r(e.onMouseDown,()=>{x.current=!0}),onFocus:_r(e.onFocus,S=>{const Q=!x.current;if(S.target===S.currentTarget&&Q&&!f){const w=new CustomEvent(_ye,XEn);if(S.currentTarget.dispatchEvent(w),!w.defaultPrevented){const M=y().filter(U=>U.focusable),k=M.find(U=>U.active),R=M.find(U=>U.id===m),O=[k,R,...M].filter(Boolean).map(U=>U.ref.current);Iye(O,g)}}x.current=!1}),onBlur:_r(e.onBlur,()=>I(!1))})})},"RovingFocusGroupImpl")),o5n="RovingFocusGroupItem",i5n=te.forwardRef(MM(function(e,n){const{__scopeRovingFocusGroup:o,focusable:i=!0,active:r=!1,tabStopId:s,children:a,...A}=e,c=M3(),l=s||c,g=e5n(o5n,o),u=g.currentTabStopId===l,h=rit(o),{onFocusableItemAdd:d,onFocusableItemRemove:p,currentTabStopId:m}=g,_=WEn();return _p(()=>{if(!(!_||!i))return d(),()=>p()},[_,i,d,p]),te.useEffect(()=>{if(!(_||!i))return d(),()=>p()},[_,i,d,p]),V.jsx(fye.ItemSlot,{scope:o,id:l,focusable:i,active:r,children:V.jsx(gc.span,{tabIndex:u?0:-1,"data-orientation":g.orientation,...A,ref:n,onMouseDown:_r(e.onMouseDown,f=>{i?g.onItemFocus(l):f.preventDefault()}),onFocus:_r(e.onFocus,()=>g.onItemFocus(l)),onKeyDown:_r(e.onKeyDown,f=>{if(f.key==="Tab"&&f.shiftKey){g.onItemShiftTab();return}if(f.target!==f.currentTarget)return;const I=ait(f,g.orientation,g.dir);if(I!==void 0){if(f.metaKey||f.ctrlKey||f.altKey||f.shiftKey)return;f.preventDefault();let y=h().filter(x=>x.focusable).map(x=>x.ref.current);if(I==="last")y.reverse();else if(I==="prev"||I==="next"){I==="prev"&&y.reverse();const x=y.indexOf(f.currentTarget);y=g.loop?Ait(y,x+1):y.slice(x+1)}setTimeout(()=>Iye(y))}}),children:typeof a=="function"?a({isCurrentTabStop:u,hasTabStop:m!=null}):a})})},"RovingFocusGroupItem")),r5n={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function sit(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}MM(sit,"getDirectionAwareKey");function ait(t,e,n){const o=sit(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return r5n[o]}MM(ait,"getFocusIntent");function Iye(t,e=!1){const n=document.activeElement;for(const o of t)if(o===n||(o.focus({preventScroll:e}),document.activeElement!==n))return}MM(Iye,"focusFirst");function Ait(t,e){return t.map((n,o)=>t[(e+o)%t.length])}MM(Ait,"wrapArray");var cit=t5n,lit=i5n,s5n=Object.defineProperty,m8=(t,e)=>s5n(t,"name",{value:e,configurable:!0});function git(t,e){return te.useReducer((n,o)=>e[n][o]??n,t)}m8(git,"useStateMachine");var N4=m8(t=>{const{present:e,children:n}=t,o=uit(e),i=typeof n=="function"?n({present:o.isPresent}):te.Children.only(n),r=dit(o.ref,hit(i));return typeof n=="function"||o.isPresent?te.cloneElement(i,{ref:r}):null},"Presence");function uit(t){const[e,n]=te.useState(),o=te.useRef(null),i=te.useRef(t),r=te.useRef("none"),s=te.useRef(void 0),a=t?"mounted":"unmounted",[A,c]=git(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return te.useEffect(()=>{A==="mounted"?(r.current=s.current??Ek(o.current),s.current=void 0):r.current="none"},[A]),_p(()=>{const l=o.current,g=i.current;if(g!==t){const h=r.current,d=Ek(l);t?(s.current=d,c("MOUNT")):d==="none"||l?.display==="none"?c("UNMOUNT"):c(g&&h!==d?"ANIMATION_OUT":"UNMOUNT"),i.current=t}},[t,c]),_p(()=>{if(e){let l;const g=e.ownerDocument.defaultView??window,u=m8(d=>{const m=Ek(o.current).includes(CSS.escape(d.animationName));if(d.target===e&&m&&(c("ANIMATION_END"),!i.current)){const _=e.style.animationFillMode;e.style.animationFillMode="forwards",l=g.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=_)})}},"handleAnimationEnd"),h=m8(d=>{d.target===e&&(r.current=Ek(o.current))},"handleAnimationStart");return e.addEventListener("animationstart",h),e.addEventListener("animationcancel",u),e.addEventListener("animationend",u),()=>{g.clearTimeout(l),e.removeEventListener("animationstart",h),e.removeEventListener("animationcancel",u),e.removeEventListener("animationend",u)}}else c("ANIMATION_END")},[e,c]),{isPresent:["mounted","unmountSuspended"].includes(A),ref:te.useCallback(l=>{if(l){const g=getComputedStyle(l);o.current=g,s.current=Ek(g)}else o.current=null;n(l)},[])}}m8(uit,"usePresence");function Cye(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}m8(Cye,"setRef");function dit(...t){const e=te.useRef(t);return e.current=t,te.useCallback(n=>{const o=e.current;let i=!1;const r=o.map(s=>{const a=Cye(s,n);return!i&&typeof a=="function"&&(i=!0),a});if(i)return()=>{for(let s=0;s<r.length;s++){const a=r[s];typeof a=="function"?a():Cye(o[s],null)}}},[])}m8(dit,"useStableComposedRefs");function Ek(t){return t?.animationName||"none"}m8(Ek,"getAnimationName");function hit(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}m8(hit,"getElementRef");var a5n=Object.defineProperty,Bk=(t,e)=>a5n(t,"name",{value:e,configurable:!0}),yye="Tabs",[A5n,icr]=P3(yye,[Nte]),pit=Nte(),[c5n,xye]=A5n(yye),l5n=te.forwardRef(Bk(function(e,n){const{__scopeTabs:o,value:i,onValueChange:r,defaultValue:s,orientation:a="horizontal",dir:A,activationMode:c="automatic",...l}=e,g=YK(A),[u,h]=y9({prop:i,onChange:r,defaultProp:s??"",caller:yye});return V.jsx(c5n,{scope:o,baseId:M3(),value:u,onValueChange:h,orientation:a,dir:g,activationMode:c,children:V.jsx(gc.div,{dir:g,"data-orientation":a,...l,ref:n})})},"Tabs")),g5n="TabsList",u5n=te.forwardRef(Bk(function(e,n){const{__scopeTabs:o,loop:i=!0,...r}=e,s=xye(g5n,o),a=pit(o);return V.jsx(cit,{asChild:!0,...a,orientation:s.orientation,dir:s.dir,loop:i,children:V.jsx(gc.div,{role:"tablist","aria-orientation":s.orientation,...r,ref:n})})},"TabsList")),d5n="TabsTrigger",h5n=te.forwardRef(Bk(function(e,n){const{__scopeTabs:o,value:i,disabled:r=!1,...s}=e,a=xye(d5n,o),A=pit(o),c=Eye(a.baseId,i),l=Bye(a.baseId,i),g=i===a.value;return V.jsx(lit,{asChild:!0,...A,focusable:!r,active:g,children:V.jsx(gc.button,{type:"button",role:"tab","aria-selected":g,"aria-controls":l,"data-state":g?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:c,...s,ref:n,onMouseDown:_r(e.onMouseDown,u=>{!r&&u.button===0&&u.ctrlKey===!1?a.onValueChange(i):u.preventDefault()}),onKeyDown:_r(e.onKeyDown,u=>{r||u.target!==u.currentTarget||[" ","Enter"].includes(u.key)&&a.onValueChange(i)}),onFocus:_r(e.onFocus,()=>{const u=a.activationMode!=="manual";!g&&!r&&u&&a.onValueChange(i)})})})},"TabsTrigger")),p5n="TabsContent",m5n=te.forwardRef(Bk(function(e,n){const{__scopeTabs:o,value:i,forceMount:r,children:s,...a}=e,A=xye(p5n,o),c=Eye(A.baseId,i),l=Bye(A.baseId,i),g=i===A.value,u=te.useRef(g);return te.useEffect(()=>{const h=requestAnimationFrame(()=>u.current=!1);return()=>cancelAnimationFrame(h)},[]),V.jsx(N4,{present:r||g,children:({present:h})=>V.jsx(gc.div,{"data-state":g?"active":"inactive","data-orientation":A.orientation,role:"tabpanel","aria-labelledby":c,hidden:!h,id:l,tabIndex:0,...a,ref:n,style:{...e.style,animationDuration:u.current?"0s":void 0},children:h&&s})})},"TabsContent"));function Eye(t,e){return`${t}-trigger-${e}`}Bk(Eye,"makeTriggerId");function Bye(t,e){return`${t}-content-${e}`}Bk(Bye,"makeContentId");var _5n=l5n,mit=u5n,_it=h5n,fit=m5n;function Iit(t){var e,n,o="";if(typeof t=="string"||typeof t=="number")o+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(n=Iit(t[e]))&&(o&&(o+=" "),o+=n)}else for(n in t)t[n]&&(o&&(o+=" "),o+=n);return o}function R4(){for(var t,e,n=0,o="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=Iit(t))&&(o&&(o+=" "),o+=e);return o}const bye="-",f5n=t=>{const e=C5n(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=t;return{getClassGroupId:s=>{const a=s.split(bye);return a[0]===""&&a.length!==1&&a.shift(),Cit(a,e)||I5n(s)},getConflictingClassGroupIds:(s,a)=>{const A=n[s]||[];return a&&o[s]?[...A,...o[s]]:A}}},Cit=(t,e)=>{if(t.length===0)return e.classGroupId;const n=t[0],o=e.nextPart.get(n),i=o?Cit(t.slice(1),o):void 0;if(i)return i;if(e.validators.length===0)return;const r=t.join(bye);return e.validators.find(({validator:s})=>s(r))?.classGroupId},yit=/^\[(.+)\]$/,I5n=t=>{if(yit.test(t)){const e=yit.exec(t)[1],n=e?.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},C5n=t=>{const{theme:e,prefix:n}=t,o={nextPart:new Map,validators:[]};return x5n(Object.entries(t.classGroups),n).forEach(([r,s])=>{Sye(s,o,r,e)}),o},Sye=(t,e,n,o)=>{t.forEach(i=>{if(typeof i=="string"){const r=i===""?e:xit(e,i);r.classGroupId=n;return}if(typeof i=="function"){if(y5n(i)){Sye(i(o),e,n,o);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([r,s])=>{Sye(s,xit(e,r),n,o)})})},xit=(t,e)=>{let n=t;return e.split(bye).forEach(o=>{n.nextPart.has(o)||n.nextPart.set(o,{nextPart:new Map,validators:[]}),n=n.nextPart.get(o)}),n},y5n=t=>t.isThemeGetter,x5n=(t,e)=>e?t.map(([n,o])=>{const i=o.map(r=>typeof r=="string"?e+r:typeof r=="object"?Object.fromEntries(Object.entries(r).map(([s,a])=>[e+s,a])):r);return[n,i]}):t,E5n=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,o=new Map;const i=(r,s)=>{n.set(r,s),e++,e>t&&(e=0,o=n,n=new Map)};return{get(r){let s=n.get(r);if(s!==void 0)return s;if((s=o.get(r))!==void 0)return i(r,s),s},set(r,s){n.has(r)?n.set(r,s):i(r,s)}}},Eit="!",B5n=t=>{const{separator:e,experimentalParseClassName:n}=t,o=e.length===1,i=e[0],r=e.length,s=a=>{const A=[];let c=0,l=0,g;for(let m=0;m<a.length;m++){let _=a[m];if(c===0){if(_===i&&(o||a.slice(m,m+r)===e)){A.push(a.slice(l,m)),l=m+r;continue}if(_==="/"){g=m;continue}}_==="["?c++:_==="]"&&c--}const u=A.length===0?a:a.substring(l),h=u.startsWith(Eit),d=h?u.substring(1):u,p=g&&g>l?g-l:void 0;return{modifiers:A,hasImportantModifier:h,baseClassName:d,maybePostfixModifierPosition:p}};return n?a=>n({className:a,parseClassName:s}):s},b5n=t=>{if(t.length<=1)return t;const e=[];let n=[];return t.forEach(o=>{o[0]==="["?(e.push(...n.sort(),o),n=[]):n.push(o)}),e.push(...n.sort()),e},S5n=t=>({cache:E5n(t.cacheSize),parseClassName:B5n(t),...f5n(t)}),Q5n=/\s+/,v5n=(t,e)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:i}=e,r=[],s=t.trim().split(Q5n);let a="";for(let A=s.length-1;A>=0;A-=1){const c=s[A],{modifiers:l,hasImportantModifier:g,baseClassName:u,maybePostfixModifierPosition:h}=n(c);let d=!!h,p=o(d?u.substring(0,h):u);if(!p){if(!d){a=c+(a.length>0?" "+a:a);continue}if(p=o(u),!p){a=c+(a.length>0?" "+a:a);continue}d=!1}const m=b5n(l).join(":"),_=g?m+Eit:m,f=_+p;if(r.includes(f))continue;r.push(f);const I=i(p,d);for(let C=0;C<I.length;++C){const y=I[C];r.push(_+y)}a=c+(a.length>0?" "+a:a)}return a};function w5n(){let t=0,e,n,o="";for(;t<arguments.length;)(e=arguments[t++])&&(n=Bit(e))&&(o&&(o+=" "),o+=n);return o}const Bit=t=>{if(typeof t=="string")return t;let e,n="";for(let o=0;o<t.length;o++)t[o]&&(e=Bit(t[o]))&&(n&&(n+=" "),n+=e);return n};function P5n(t,...e){let n,o,i,r=s;function s(A){const c=e.reduce((l,g)=>g(l),t());return n=S5n(c),o=n.cache.get,i=n.cache.set,r=a,a(A)}function a(A){const c=o(A);if(c)return c;const l=v5n(A,n);return i(A,l),l}return function(){return r(w5n.apply(null,arguments))}}const rd=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},bit=/^\[(?:([a-z-]+):)?(.+)\]$/i,M5n=/^\d+\/\d+$/,D5n=new Set(["px","full","screen"]),N5n=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,R5n=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,T5n=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,k5n=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,F5n=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,_8=t=>bk(t)||D5n.has(t)||M5n.test(t),sQ=t=>Sk(t,"length",V5n),bk=t=>!!t&&!Number.isNaN(Number(t)),Qye=t=>Sk(t,"number",bk),UK=t=>!!t&&Number.isInteger(Number(t)),L5n=t=>t.endsWith("%")&&bk(t.slice(0,-1)),RA=t=>bit.test(t),aQ=t=>N5n.test(t),H5n=new Set(["length","size","percentage"]),O5n=t=>Sk(t,H5n,Sit),G5n=t=>Sk(t,"position",Sit),Y5n=new Set(["image","url"]),U5n=t=>Sk(t,Y5n,J5n),K5n=t=>Sk(t,"",z5n),KK=()=>!0,Sk=(t,e,n)=>{const o=bit.exec(t);return o?o[1]?typeof e=="string"?o[1]===e:e.has(o[1]):n(o[2]):!1},V5n=t=>R5n.test(t)&&!T5n.test(t),Sit=()=>!1,z5n=t=>k5n.test(t),J5n=t=>F5n.test(t),W5n=P5n(()=>{const t=rd("colors"),e=rd("spacing"),n=rd("blur"),o=rd("brightness"),i=rd("borderColor"),r=rd("borderRadius"),s=rd("borderSpacing"),a=rd("borderWidth"),A=rd("contrast"),c=rd("grayscale"),l=rd("hueRotate"),g=rd("invert"),u=rd("gap"),h=rd("gradientColorStops"),d=rd("gradientColorStopPositions"),p=rd("inset"),m=rd("margin"),_=rd("opacity"),f=rd("padding"),I=rd("saturate"),C=rd("scale"),y=rd("sepia"),x=rd("skew"),E=rd("space"),B=rd("translate"),S=()=>["auto","contain","none"],Q=()=>["auto","hidden","clip","visible","scroll"],w=()=>["auto",RA,e],M=()=>[RA,e],k=()=>["",_8,sQ],R=()=>["auto",bk,RA],F=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],O=()=>["solid","dashed","dotted","double","none"],U=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Y=()=>["start","end","center","between","around","evenly","stretch"],J=()=>["","0",RA],ee=()=>["auto","avoid","all","avoid-page","page","left","right","column"],W=()=>[bk,RA];return{cacheSize:500,separator:":",theme:{colors:[KK],spacing:[_8,sQ],blur:["none","",aQ,RA],brightness:W(),borderColor:[t],borderRadius:["none","","full",aQ,RA],borderSpacing:M(),borderWidth:k(),contrast:W(),grayscale:J(),hueRotate:W(),invert:J(),gap:M(),gradientColorStops:[t],gradientColorStopPositions:[L5n,sQ],inset:w(),margin:w(),opacity:W(),padding:M(),saturate:W(),scale:W(),sepia:J(),skew:W(),space:M(),translate:M()},classGroups:{aspect:[{aspect:["auto","square","video",RA]}],container:["container"],columns:[{columns:[aQ]}],"break-after":[{"break-after":ee()}],"break-before":[{"break-before":ee()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...F(),RA]}],overflow:[{overflow:Q()}],"overflow-x":[{"overflow-x":Q()}],"overflow-y":[{"overflow-y":Q()}],overscroll:[{overscroll:S()}],"overscroll-x":[{"overscroll-x":S()}],"overscroll-y":[{"overscroll-y":S()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[p]}],"inset-x":[{"inset-x":[p]}],"inset-y":[{"inset-y":[p]}],start:[{start:[p]}],end:[{end:[p]}],top:[{top:[p]}],right:[{right:[p]}],bottom:[{bottom:[p]}],left:[{left:[p]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",UK,RA]}],basis:[{basis:w()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",RA]}],grow:[{grow:J()}],shrink:[{shrink:J()}],order:[{order:["first","last","none",UK,RA]}],"grid-cols":[{"grid-cols":[KK]}],"col-start-end":[{col:["auto",{span:["full",UK,RA]},RA]}],"col-start":[{"col-start":R()}],"col-end":[{"col-end":R()}],"grid-rows":[{"grid-rows":[KK]}],"row-start-end":[{row:["auto",{span:[UK,RA]},RA]}],"row-start":[{"row-start":R()}],"row-end":[{"row-end":R()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",RA]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",RA]}],gap:[{gap:[u]}],"gap-x":[{"gap-x":[u]}],"gap-y":[{"gap-y":[u]}],"justify-content":[{justify:["normal",...Y()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...Y(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...Y(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[f]}],px:[{px:[f]}],py:[{py:[f]}],ps:[{ps:[f]}],pe:[{pe:[f]}],pt:[{pt:[f]}],pr:[{pr:[f]}],pb:[{pb:[f]}],pl:[{pl:[f]}],m:[{m:[m]}],mx:[{mx:[m]}],my:[{my:[m]}],ms:[{ms:[m]}],me:[{me:[m]}],mt:[{mt:[m]}],mr:[{mr:[m]}],mb:[{mb:[m]}],ml:[{ml:[m]}],"space-x":[{"space-x":[E]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[E]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",RA,e]}],"min-w":[{"min-w":[RA,e,"min","max","fit"]}],"max-w":[{"max-w":[RA,e,"none","full","min","max","fit","prose",{screen:[aQ]},aQ]}],h:[{h:[RA,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[RA,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[RA,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[RA,e,"auto","min","max","fit"]}],"font-size":[{text:["base",aQ,sQ]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Qye]}],"font-family":[{font:[KK]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",RA]}],"line-clamp":[{"line-clamp":["none",bk,Qye]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",_8,RA]}],"list-image":[{"list-image":["none",RA]}],"list-style-type":[{list:["none","disc","decimal",RA]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[_]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[_]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...O(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",_8,sQ]}],"underline-offset":[{"underline-offset":["auto",_8,RA]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:M()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",RA]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",RA]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[_]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...F(),G5n]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",O5n]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},U5n]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[d]}],"gradient-via-pos":[{via:[d]}],"gradient-to-pos":[{to:[d]}],"gradient-from":[{from:[h]}],"gradient-via":[{via:[h]}],"gradient-to":[{to:[h]}],rounded:[{rounded:[r]}],"rounded-s":[{"rounded-s":[r]}],"rounded-e":[{"rounded-e":[r]}],"rounded-t":[{"rounded-t":[r]}],"rounded-r":[{"rounded-r":[r]}],"rounded-b":[{"rounded-b":[r]}],"rounded-l":[{"rounded-l":[r]}],"rounded-ss":[{"rounded-ss":[r]}],"rounded-se":[{"rounded-se":[r]}],"rounded-ee":[{"rounded-ee":[r]}],"rounded-es":[{"rounded-es":[r]}],"rounded-tl":[{"rounded-tl":[r]}],"rounded-tr":[{"rounded-tr":[r]}],"rounded-br":[{"rounded-br":[r]}],"rounded-bl":[{"rounded-bl":[r]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[_]}],"border-style":[{border:[...O(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[_]}],"divide-style":[{divide:O()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...O()]}],"outline-offset":[{"outline-offset":[_8,RA]}],"outline-w":[{outline:[_8,sQ]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:k()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[_]}],"ring-offset-w":[{"ring-offset":[_8,sQ]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",aQ,K5n]}],"shadow-color":[{shadow:[KK]}],opacity:[{opacity:[_]}],"mix-blend":[{"mix-blend":[...U(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":U()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[o]}],contrast:[{contrast:[A]}],"drop-shadow":[{"drop-shadow":["","none",aQ,RA]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[l]}],invert:[{invert:[g]}],saturate:[{saturate:[I]}],sepia:[{sepia:[y]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[o]}],"backdrop-contrast":[{"backdrop-contrast":[A]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[l]}],"backdrop-invert":[{"backdrop-invert":[g]}],"backdrop-opacity":[{"backdrop-opacity":[_]}],"backdrop-saturate":[{"backdrop-saturate":[I]}],"backdrop-sepia":[{"backdrop-sepia":[y]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[s]}],"border-spacing-x":[{"border-spacing-x":[s]}],"border-spacing-y":[{"border-spacing-y":[s]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",RA]}],duration:[{duration:W()}],ease:[{ease:["linear","in","out","in-out",RA]}],delay:[{delay:W()}],animate:[{animate:["none","spin","ping","pulse","bounce",RA]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[C]}],"scale-x":[{"scale-x":[C]}],"scale-y":[{"scale-y":[C]}],rotate:[{rotate:[UK,RA]}],"translate-x":[{"translate-x":[B]}],"translate-y":[{"translate-y":[B]}],"skew-x":[{"skew-x":[x]}],"skew-y":[{"skew-y":[x]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",RA]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",RA]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":M()}],"scroll-mx":[{"scroll-mx":M()}],"scroll-my":[{"scroll-my":M()}],"scroll-ms":[{"scroll-ms":M()}],"scroll-me":[{"scroll-me":M()}],"scroll-mt":[{"scroll-mt":M()}],"scroll-mr":[{"scroll-mr":M()}],"scroll-mb":[{"scroll-mb":M()}],"scroll-ml":[{"scroll-ml":M()}],"scroll-p":[{"scroll-p":M()}],"scroll-px":[{"scroll-px":M()}],"scroll-py":[{"scroll-py":M()}],"scroll-ps":[{"scroll-ps":M()}],"scroll-pe":[{"scroll-pe":M()}],"scroll-pt":[{"scroll-pt":M()}],"scroll-pr":[{"scroll-pr":M()}],"scroll-pb":[{"scroll-pb":M()}],"scroll-pl":[{"scroll-pl":M()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",RA]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[_8,sQ,Qye]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}}),Fn="u">typeof window?window:void 0,gC="u">typeof globalThis?globalThis:Fn,F_=gC?.navigator,No=gC?.document,sd=gC?.location,VK=gC?.fetch,vye=gC?.XMLHttpRequest&&"withCredentials"in new gC.XMLHttpRequest?gC.XMLHttpRequest:void 0,Qit=gC?.AbortController,j5n=gC?.CompressionStream,hy=F_?.userAgent;function vit(){return!(!Fn||Fn.navigator.onLine===!1)}const zK=typeof globalThis<"u"?globalThis:Fn;zK&&typeof self>"u"&&(zK.self=zK),zK&&typeof File>"u"&&(zK.File=function(){});const Ur=Fn??{},X5n="0.9.1",f8={DEBUG:!1,LIB_VERSION:X5n,LIB_NAME:"browser-common"};var x9=(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.AiCaptureQueue="ai_capture_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.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysInProgress="surveys_in_progress",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t})({}),wye=(function(t){return t.GZipJS="gzip-js",t.Base64="base64",t})({});const q5n=["$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"],$5n=["token"];function as(t,e){return t.indexOf(e)!==-1}const Rte=function(t){return t.trim()},Pye=function(t){return t.replace(/^\$/,"")};function wit(t){var e;const n=[];return(e=JSON.stringify(t,function(o,i){if(typeof i=="bigint")return i.toString();if(typeof i!="function"&&typeof i!="symbol"){if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&typeof i=="object"){for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(n.includes(i))return"[Circular]";n.push(i)}return i}}))!==null&&e!==void 0?e:"null"}const Pit=Object.prototype,Mye=Pit.hasOwnProperty,Tte=Pit.toString,As=Array.isArray||function(t){return Tte.call(t)==="[object Array]"},L_=t=>typeof t=="function",xA=t=>t===Object(t)&&!As(t),ox=t=>{if(xA(t)){for(const e in t)if(Mye.call(t,e))return!1;return!0}return!1},Eo=t=>t===void 0,nA=t=>Tte.call(t)=="[object String]",JK=t=>nA(t)&&t.trim().length===0,ad=t=>t===null,Fs=t=>Eo(t)||ad(t),qd=t=>Tte.call(t)=="[object Number]"&&t==t,I8=t=>qd(t)&&t>0,py=t=>Tte.call(t)==="[object Boolean]",Z5n=t=>as(q5n,t),e4n=t=>as($5n,t);function Mit(t){return t===null||typeof t!="object"}function kte(t,e){return{}.toString.call(t)===`[object ${e}]`}function Qk(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return Dit(t,Error)}}function Dye(t){return"u">typeof Event&&Dit(t,Event)}function Dit(t,e){try{return t instanceof e}catch{return!1}}const t4n=[!0,"true",1,"1","yes"],Nye=t=>as(t4n,t),n4n=[!1,"false",0,"0","no"];function Nit(t,e,n,o,i,r,s){try{var a=t[r](s),A=a.value}catch(c){return void n(c)}a.done?e(A):Promise.resolve(A).then(o,i)}function Wg(t){return function(){var e=this,n=arguments;return new Promise(function(o,i){var r=t.apply(e,n);function s(A){Nit(r,o,i,s,a,"next",A)}function a(A){Nit(r,o,i,s,a,"throw",A)}s(void 0)})}}const o4n=["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","pinterestbot","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"],Rit=function(t,e=[]){if(!t)return!1;const n=t.toLowerCase();return o4n.concat(e).some(o=>{const i=o.toLowerCase();return n.indexOf(i)!==-1})};function E9(t,e,n,o,i){return e>n&&(o.warn("min cannot be greater than max."),e=n),qd(t)?t>n?(o.warn(" cannot be greater than max: "+n+". Using max value instead."),n):e>t?(o.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(o.warn(" must be a number. using max or fallback. max: "+n+", fallback: "+i),E9(i??n,e,n,o))}var i4n=class{constructor(e){this.C={},this.I=e.I,this.R=E9(e.bucketSize,0,100,e.A),this.$=E9(e.refillRate,0,this.R,e.A),this.O=E9(e.refillInterval,0,864e5,e.A)}F(e,n){const o=Math.floor((n-e.lastAccess)/this.O);o>0&&(e.tokens=Math.min(e.tokens+o*this.$,this.R),e.lastAccess=e.lastAccess+o*this.O)}consumeRateLimit(e){var n;const o=Date.now(),i=String(e);let r=this.C[i];return r?this.F(r,o):(r={tokens:this.R,lastAccess:o},this.C[i]=r),r.tokens===0||(r.tokens--,r.tokens===0&&((n=this.I)===null||n===void 0||n.call(this,e)),r.tokens===0)}stop(){this.C={}}};const vk="Mobile",WK="Android",Fte="Tablet",Tit="Android Tablet",kit="iPad",Fit="Apple Watch",Lte="Safari",Hte="BlackBerry",Lit="Samsung Internet",Ote="Chrome",Hit="Chrome iOS",Oit="Internet Explorer",Git="Internet Explorer Mobile",Yit="Opera",Uit="Microsoft Edge",Gte="Firefox",Kit="Firefox iOS",Yte="Nintendo",Ute="PlayStation",Kte="Xbox",Vit="Android Mobile",zit="Mobile Safari",Rye="Windows",Jit="Windows Phone",Wit="Nokia",Tye="Ouya",r4n="Generic "+vk.toLowerCase(),jit="Generic "+Fte.toLowerCase(),kye="Konqueror",Xit="Oculus Browser",qit="Vivaldi",$it="Yandex",Zit="Whale",ert="DuckDuckGo",trt="Pale Moon",nrt="Waterfox",Fye="Brave",ort="Claude",irt="Codex",rrt="ChatGPT",srt="Google Search App",Lye=new RegExp("Version/(\\d+(\\.\\d+)?)"),Hye=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),s4n=new RegExp(Kte,"i"),a4n=new RegExp("PlayStation \\w+","i"),A4n=new RegExp("Nintendo \\w+","i"),Oye=new RegExp("BlackBerry|PlayBook|BB10","i"),c4n={"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"},art=function(t,e,n,o){return e=e||"",(function(r){return r?.brave?Fye:null})(n)||(o?.detectGoogleSearchApp&&as(t,"GSA/")?srt:as(t," OPR/")&&as(t,"Mini")?"Opera Mini":as(t," OPR/")?Yit:Oye.test(t)?Hte:as(t,"IEMobile")||as(t,"WPDesktop")?Git:as(t,"OculusBrowser")?Xit:as(t,"SamsungBrowser")?Lit:as(t,"Edge")||as(t,"Edg/")?Uit:as(t,"Vivaldi/")?qit:as(t,"YaBrowser/")?$it:as(t,"Whale/")?Zit:as(t,"DuckDuckGo/")||as(t,"Ddg/")?ert:as(t,"Claude/")?ort:as(t,"Codex/")?irt:as(t,"ChatGPT/")?rrt:as(t,"FBIOS")?"Facebook Mobile":as(t,"UCWEB")||as(t,"UCBrowser")?"UC Browser":as(t,"CriOS")?Hit:as(t,"CrMo")||as(t,Ote)?Ote:as(t,WK)&&as(t,Lte)?Vit:as(t,"FxiOS")?Kit:as(t.toLowerCase(),kye.toLowerCase())?kye:as(t,"Brave/")?Fye:((r,s)=>s&&as(s,"Apple")||(function(a){return as(a,Lte)&&!as(a,Ote)&&!as(a,WK)})(r))(t,e)?as(t,vk)?zit:Lte:as(t,"PaleMoon/")?trt:as(t,"Waterfox/")?nrt:as(t,Gte)?Gte:as(t,"MSIE")||as(t,"Trident/")?Oit:as(t,"Gecko")?Gte:"")},l4n={[Git]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[Uit]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[Ote]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[Hit]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[Lte]:[Lye],[zit]:[Lye],[Yit]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[Gte]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[Kit]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[kye]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[Hte]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),Lye],[Vit]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[Lit]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[Xit]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[qit]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[$it]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[Zit]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[Fye]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[ort]:[Hye],[irt]:[Hye],[rrt]:[Hye],[ert]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[trt]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[nrt]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[srt]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[Oit]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},g4n=function(t,e,n,o){const i=art(t,e,n,o),r=l4n[i];if(Eo(r))return null;for(let s=0;r.length>s;s++){const a=t.match(r[s]);if(a)return parseFloat(a[a.length-2])}return null},Art=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>[Kte,t&&t[1]||""]],[new RegExp(Yte,"i"),[Yte,""]],[new RegExp(Ute,"i"),[Ute,""]],[Oye,[Hte,""]],[new RegExp(Rye,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[Jit,""];if(new RegExp(vk).test(e)&&!/IEMobile\b/.test(e))return["Windows Mobile",""];const n=/Windows NT ([0-9.]+)/i.exec(e);if(n&&n[1]){let o=c4n[n[1]]||"";return/arm/i.test(e)&&(o="RT"),[Rye,o]}return[Rye,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?["iOS",[t[3],t[4],t[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{let e="";return t&&t.length>=3&&(e=Eo(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),t=>t&&t[2]?[WK,[t[2],t[3],t[4]||"0"].join(".")]:[WK,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{const 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/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],crt=function(t){for(let e=0;Art.length>e;e++){const[n,o]=Art[e],i=n.exec(t),r=i&&(L_(o)?o(i,t):o);if(r)return r}return["",""]},lrt=function(t){return A4n.test(t)?Yte:a4n.test(t)?Ute:s4n.test(t)?Kte:new RegExp(Tye,"i").test(t)?Tye:new RegExp("(Windows Phone|WPDesktop)","i").test(t)?Jit:/iPad/.test(t)?kit:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?Fit:Oye.test(t)?Hte:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(Wit,"i").test(t)?Wit:/(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(vk).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)?WK:Tit:new RegExp("(pda|Mobile)","i").test(t)?r4n:new RegExp(Fte,"i").test(t)&&!new RegExp("Tablet pc","i").test(t)?jit:""},u4n=function(t,e){var n;const o=lrt(t);return o===kit||o===Tit||o==="Kobo"||o==="Kindle Fire"||o===jit?Fte:o===Yte||o===Kte||o===Ute||o===Tye?"Console":o===Fit?"Wearable":o?vk:e?.userAgentDataPlatform==="Android"&&((n=e?.maxTouchPoints)!==null&&n!==void 0?n:0)>0?600>Math.min((i=e?.screenWidth)!==null&&i!==void 0?i:0,(r=e?.screenHeight)!==null&&r!==void 0?r:0)/((s=e?.devicePixelRatio)!==null&&s!==void 0?s:1)?vk:Fte:"Desktop";var i,r,s},Gye=/\bFBAV\/(\d+(?:\.\d+)*)/i,grt=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",Gye],[/\bFBAN\/EMA\b/i,"Facebook Lite",Gye],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",Gye],[/\bLinkedInApp(?:\]?\/(\d+(?:\.\d+)*))?\b/i,"LinkedIn"],[/\bTwitter(?:Android| for (?:iPhone|iPad|Android))(?:\/(\d+(?:\.\d+)*))?\b/i,"Twitter"],[/\b(?:musical_ly|trill)(?:[_/](\d+\.\d+(?:\.\d+)*))?(?=\b|_)/i,"TikTok",/\bapp_version\/(\d+(?:\.\d+)*)/i],[/\b(?:MicroMessenger|WeChat)\/(\d+(?:\.\d+)*)?/i,"WeChat"],[/\bLine\/(\d+(?:\.\d+)*)?/i,"Line"],[/\bGSA\/(\d+(?:\.\d+)*)?/i,"Google"],[/\[Pinterest\/(?:iOS|Android)\b|\bPinterest(?: for (?:Android(?: Tablet)?|iOS))?\/(\d+(?:\.\d+)*)/i,"Pinterest"],[/\b(?:WA4A|WAiOS)\/(\d+(?:\.\d+)*)?/i,"WhatsApp"],[/\bSnapchat[ /](\d+(?:\.\d+)*)?/i,"Snapchat"],[/\bBing(?:Web|Sapphire)\/(\d+(?:\.\d+)*)?/i,"Bing"],[/\bNAVER\(inapp; search;/i,"Naver",/\bNAVER\(inapp; search;[^;)]*; (\d+(?:\.\d+)*)/i],[/\bKAKAOTALK[ /](\d+\.\d+(?:\.\d+)*)?/i,"KakaoTalk"]],Yye="[Truncated]",jK="[Unserializable]";function wk(t){let e="";for(let n=0;t.length>n;n++){const o=t.charCodeAt(n);if(55296>o||o>56319)e+=56320>o||o>57343?t[n]:"�";else{const i=t.charCodeAt(n+1);56320>i||i>57343?e+="�":(e+=t[n]+t[n+1],n++)}}return e}function urt(t,e){if(!e)return t;let n=[];try{n=Object.keys(e)}catch{n=[]}for(const o of n){let i;try{i=e[o]}catch{i=jK}Object.defineProperty(t,o,{value:i,enumerable:!0,writable:!0,configurable:!0})}return t}const Vte=3e5;var drt=class{record(e){if(e.kind==="too-large")return;if(e.kind!=="retry-later")return void this.reset();if(!e.retryAfterMs)return;const n=this.isOpen(),o=Date.now(),i=Math.min(e.retryAfterMs,Vte);if(!n)return this.ts=o,void(this.es=o+i);this.es=Math.max(this.es,Math.min(o+i,this.ts+Vte))}remainingMs(){const e=Date.now();if(this.ts-5e3>e)return this.reset(),0;const n=Math.min(Vte,Math.max(0,this.es-e));return n===0&&this.reset(),n}isOpen(){return this.remainingMs()>0}reset(){this.es=0,this.ts=0}constructor(){this.es=0,this.ts=0}};const d4n=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function hrt(t,e){return typeof(n=t)=="string"&&d4n.test(n)?t:e();var n}function prt(t,e){const n=new Error(e);try{Object.defineProperty(n,"name",{value:t,writable:!0,enumerable:!0,configurable:!0})}catch{}return n}function AQ(t){return t&&t.split("#")[0]}function mrt(t){try{return t()}catch{return}}function _rt(t,e){const n=setTimeout(t,e);return n!=null&&n.unref&&n?.unref(),n}function frt(t,e,n){return Irt.apply(this,arguments)}function Irt(){return(Irt=Wg(function*(t,e,n){let o;try{return yield Promise.race([t,new Promise((i,r)=>{o=_rt(()=>{try{n?.(),i()}catch(s){r(s)}},e)})])}finally{clearTimeout(o)}})).apply(this,arguments)}let zte,Crt,Uye;function h4n(t){const e=globalThis._posthogChunkIds;if(!e)return;const n=Object.keys(e);return Uye&&n.length===Crt||(Crt=n.length,Uye=n.reduce((o,i)=>{zte||(zte={});const r=zte[i];if(r)o[r[0]]=r[1];else{const s=t(i);for(let a=s.length-1;a>=0;a--){const A=s[a],c=A?.filename,l=e[i];if(c&&l){o[c]=l,zte[i]=[c,l];break}}}return o},{})),Uye}function XK(t){return XK=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},XK(t)}function p4n(t,e,n){return(e=(function(o){var i=(function(r){if(XK(r)!="object"||!r)return r;var s=r[Symbol.toPrimitive];if(s!==void 0){var a=s.call(r,"string");if(XK(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)})(o);return XK(i)=="symbol"?i:i+""})(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yrt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,o)}return n}function sn(t){for(var e=1;arguments.length>e;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?yrt(Object(n),!0).forEach(function(o){p4n(t,o,n[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):yrt(Object(n)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(n,o))})}return t}var m4n=class{constructor(e,n,o=[]){this.coercers=e,this.stackParser=n,this.modifiers=o}buildFromUnknown(e,n={}){const o=n&&n.mechanism||{handled:!0,type:"generic"},i=this.buildCoercingContext(o,n,0).apply(e),r=this.buildParsingContext(n),s=this.parseStacktrace(i,r);return{$exception_list:this.convertToExceptionList(s,o),$exception_level:"error"}}modifyFrames(e){var n=this;return Wg(function*(){for(const o of e)o.stacktrace&&o.stacktrace.frames&&As(o.stacktrace.frames)&&(o.stacktrace.frames=yield n.applyModifiers(o.stacktrace.frames));return e})()}coerceFallback(e){var n;return{type:"Error",value:"Unknown error",stack:(n=e.syntheticException)===null||n===void 0?void 0:n.stack,synthetic:!0}}parseStacktrace(e,n){var o;let i,r;if(e.cause!=null&&(i=this.parseStacktrace(e.cause,n)),e.stack!=""&&e.stack!=null)try{r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?n.skipFirstLines:0),n.chunkIdMap)}catch{}return sn(sn({},e),{},{cause:i,stack:r,errors:(o=e.errors)===null||o===void 0?void 0:o.map(s=>this.parseStacktrace(s,n))})}applyChunkIds(e,n){return e.map(o=>(o.filename&&n&&(o.chunk_id=n[o.filename]),o))}applyCoercers(e,n){for(const o of this.coercers)if(o.match(e))return o.coerce(e,n);return this.coerceFallback(n)}applyModifiers(e){var n=this;return Wg(function*(){let o=e;for(const i of n.modifiers)o=yield i(o);return o})()}convertToExceptionList(e,n){const o=[],i=(r,s,a)=>{var A;const c=o.length,l=s===void 0?sn(sn({type:typeof n.type=="string"&&n.type.length>0?n.type:"generic"},typeof n.handled=="boolean"?{handled:n.handled}:n.handled===void 0?{handled:!0}:{}),{},{synthetic:typeof n.synthetic=="boolean"?n.synthetic:r.synthetic,exception_id:c}):{type:"chained",source:a,synthetic:r.synthetic,exception_id:c,parent_id:s},g={type:r.type,value:r.value,mechanism:l};r.stack&&(g.stacktrace={type:"raw",frames:r.stack}),o.push(g),r.cause&&i(r.cause,c,"cause");for(const u of(A=r.errors)!==null&&A!==void 0?A:[])i(u,c,"member")};return i(e),o}buildParsingContext(e){var n;return{chunkIdMap:h4n(this.stackParser),skipFirstLines:(n=e.skipFirstLines)!==null&&n!==void 0?n:1}}getAggregateErrors(e){try{if(Qk(e)){let o=Object.getPrototypeOf(e);for(let i=0;o&&100>i;i++){var n;const r=(n=Object.getOwnPropertyDescriptor(o,"constructor"))===null||n===void 0?void 0:n.value;if(typeof r=="function"&&r.name==="AggregateError"){const s=e.errors;return As(s)?s:void 0}o=Object.getPrototypeOf(o)}}}catch{}}buildCoercingContext(e,n,o=0){let i=0,r=0,s=!1;const a=new Set,A=[],c={},l=(h,d,p=0)=>{const m=g(d,p),_=m.apply;if(m.apply=E=>{A.push(h);try{return _(E)}finally{A.pop()}},p>4||p>0&&A.indexOf(h)!==-1)return this.coerceFallback(m);const f=typeof h=="object"&&h!==null||typeof h=="function";if(p===0&&i>=50||f&&a.has(h))return;f&&a.add(h),p===0&&i++;const I=this.getAggregateErrors(h);let C,y;s||(s=!!I);try{if(C=this.applyCoercers(h,m),!C)throw c}catch(E){if(E===c)return void(p===0&&i--);if(!s)throw E;C=this.coerceFallback(m)}if(!I||i>=50)return C;try{y=I.length}catch{return C}if(!Number.isInteger(y)||0>y||y>4294967295)return C;const x=[];for(let E=0;50>i&&1e3>r&&y>E;E++){let B;r++;try{B=m.next(I[E])}catch{i++,B=this.coerceFallback(g(d+1))}B&&x.push(B)}return sn(sn({},C),{},{errors:x})},g=(h,d=0)=>sn(sn({},n),{},{syntheticException:h==0?n.syntheticException:void 0,mechanism:h==0?e:{},apply(p){const m=l(p,h,d+1);if(!m)throw c;return m},next:p=>l(p,h+1)}),u=g(o);return sn(sn({},u),{},{apply:h=>{var d;return(d=l(h,o))!==null&&d!==void 0?d:this.coerceFallback(u)}})}};const _4n=/^([a-z][a-z0-9.+-]+):/i,f4n=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function I4n(t){if(!t||t==="<anonymous>")return!1;const e=_4n.exec(t);return!e||f4n.includes(e[1].toLowerCase())}function Kye(t,e,n,o,i){const r={platform:t,filename:e,function:n==="<anonymous>"?"?":n,in_app:I4n(e)};return Eo(o)||(r.lineno=o),Eo(i)||(r.colno=i),r}const xrt=(t,e)=>{const n=t.indexOf("safari-extension")!==-1,o=t.indexOf("safari-web-extension")!==-1;return n||o?[t.indexOf("@")!==-1?t.split("@")[0]:"?",n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]},C4n=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,y4n=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,x4n=/\((\S*)(?::(\d+))(?::(\d+))\)/,E4n=(t,e)=>{const n=C4n.exec(t);if(n){const[,i,r,s]=n;return Kye(e,i,"?",+r,+s)}const o=y4n.exec(t);if(o){if(o[2]&&o[2].indexOf("eval")===0){const s=x4n.exec(o[2]);s&&(o[2]=s[1],o[3]=s[2],o[4]=s[3])}const[i,r]=xrt(o[1]||"?",o[2]);return Kye(e,r,i,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},B4n=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,b4n=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,S4n=(t,e)=>{const n=B4n.exec(t);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){const r=b4n.exec(n[3]);r&&(n[1]=n[1]||"eval",n[3]=r[1],n[4]=r[2],n[5]="")}let o=n[3],i=n[1]||"?";return[i,o]=xrt(i,o),Kye(e,o,i,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},Ert=/\(error: (.*)\)/;function Vye(t,e){return t.filename===e.filename&&t.function===e.function&&t.module===e.module&&t.lineno===e.lineno&&t.colno===e.colno}function Q4n(t){for(let e=1;10>=e;e++){const n=t.length-2*e;if(0>n)break;let o=!0;for(let i=0;e>i;i++)if(!Vye(t[n+i],t[n+e+i])){o=!1;break}if(o){for(let i=0;e>i;i++)t[n+i]=t[n+e+i];return t.length=n+e,{start:n,length:e}}}}function v4n(t,e){const n=e.start+e.length,o=brt(t,e);o&&t.splice(n+o===t.length?n:e.start,o)}function Brt(t,e){let n=e.start;for(;n>0&&Vye(t[n-1],t[n-1+e.length]);)n--;return e.start-n}function brt(t,e){const n=e.start+e.length;let o=n;for(;t.length>o&&Vye(t[o],t[o-e.length]);)o++;return o-n}function w4n(t,e){const n=e[0];let o=t.length-(n?Brt(t,n):0);for(const i of e)o-=brt(t,i);return o}function P4n(t,e,n){for(let o=0;t.length>o;o++){const i=t[(e+o)%t.length],r=t[(n+o)%t.length];if(i!==r)return r>i}return!1}var M4n=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,n){const o=nA(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:o?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){const n=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?`${n}: ${e.message}`:n}isDOMException(e){return kte(e,"DOMException")}isDOMError(e){return kte(e,"DOMError")}},D4n=class{match(e){return Qk(e)}coerce(e,n){var o;const i=this.getStack(e),r=i===void 0?(o=n.syntheticException)===null||o===void 0?void 0:o.stack:void 0,s=!!r;return{type:this.getType(e),value:this.getMessage(e,n),stack:i??r,cause:e.cause?n.next(e.cause):void 0,synthetic:s}}getType(e){return e.name||e.constructor.name}getMessage(e,n){const o=e.message;return String(o.error&&typeof o.error.message=="string"?o.error.message:o)}getStack(e){try{const n=e.stacktrace;if(typeof n=="string"&&n.length>0)return n;const o=e.stack;return typeof o=="string"&&o.length>0?o:void 0}catch{return}}},N4n=class{match(e){return!!kte(e,"ErrorEvent")&&(e.error!=null||this.ar(e))}coerce(e,n){var o;if(e.error!=null)return n.apply(e.error);const i=n.apply(e.message);return sn(sn({},i),{},{stack:(o=this.lr(e))!==null&&o!==void 0?o:i.stack,synthetic:!0})}ar(e){return nA(e.message)&&e.message.length>0}lr(e){var n,o;const i=e,r=(n=i.lineno)!==null&&n!==void 0?n:0,s=(o=i.colno)!==null&&o!==void 0?o:0;if(nA(i.filename)&&i.filename.length!==0&&r!==0)return`Error
|
|
240
|
-
at ${i.filename}:${r}:${s}`}};const R4n=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var T4n=class{match(e){return typeof e=="string"}coerce(e,n){var o;const[i,r]=this.getInfos(e);return{type:i??"Error",value:r??e,stack:(o=n.syntheticException)===null||o===void 0?void 0:o.stack,synthetic:!0}}getInfos(e){let n="Error",o=e;const i=e.match(R4n);return i&&(n=i[1],o=i[2]),[n,o]}};const k4n=["fatal","error","warning","log","info","debug"];function Srt(t,e=40){const n=Object.keys(t);if(n.sort(),!n.length)return"[object has no keys]";for(let o=n.length;o>0;o--){const i=n.slice(0,o).join(", ");if(e>=i.length)return o===n.length?i:i.length>e?`${i.slice(0,e)}...`:i}return""}var F4n=class{match(e){return typeof e=="object"&&e!==null}coerce(e,n){var o,i;const r=this.getErrorPropertyFromObject(e);return r?n.apply(r):{type:this.getType(e),value:this.getValue(e),stack:(o=this.getStack(e))!==null&&o!==void 0?o:(i=n.syntheticException)===null||i===void 0?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){if(Dye(e))return e.constructor.name;const n="name"in e?e.name:void 0;return nA(n)&&!JK(n)?n:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){let o=`'${e.name}' captured as exception`;return"message"in e&&typeof e.message=="string"&&(o+=` with message: '${e.message}'`),o}if("message"in e&&typeof e.message=="string")return e.message;const n=this.getObjectClassName(e);return`${n&&n!=="Object"?`'${n}'`:"Object"} captured as exception with keys: ${Srt(e)}`}isSeverityLevel(e){return nA(e)&&!JK(e)&&k4n.indexOf(e)>=0}getStack(e){try{return nA(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:nA(e.stack)&&e.stack.length>0?e.stack:void 0}catch{return}}getErrorPropertyFromObject(e){for(const n in e)if({}.hasOwnProperty.call(e,n)){const o=e[n];if(Qk(o))return o}}getObjectClassName(e){try{const n=Object.getPrototypeOf(e);return n?n.constructor.name:void 0}catch{return}}},L4n=class{match(e){return Dye(e)}coerce(e,n){var o;const i=e.constructor.name;return{type:i,value:`${i} captured as exception with keys: ${Srt(e)}`,stack:(o=n.syntheticException)===null||o===void 0?void 0:o.stack,synthetic:!0}}},H4n=class{match(e){return Mit(e)}coerce(e,n){var o;return{type:"Error",value:`Primitive value captured as exception: ${String(e)}`,stack:(o=n.syntheticException)===null||o===void 0?void 0:o.stack,synthetic:!0}}},O4n=class{match(e){return kte(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Dye(e))return!1;try{const n=e.detail;return n!=null&&typeof n=="object"&&"reason"in n}catch{return!1}}coerce(e,n){var o;const i=this.getUnhandledRejectionReason(e);return Mit(i)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(i)}`,stack:(o=n.syntheticException)===null||o===void 0?void 0:o.stack,synthetic:!0}:n.apply(i)}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}};const Jte="$message",Wte="$timestamp",G4n=new Set([Jte,Wte]),zye={enabled:!0,max_bytes:32768};function jte(t){var e;return t?{enabled:(e=t.enabled)!==null&&e!==void 0?e:zye.enabled,max_bytes:U4n(t.max_bytes,zye.max_bytes)}:sn({},zye)}var Y4n=class{constructor(e){this.ns=[],this.ss=0,this.Mr=jte(e)}setConfig(e){this.Mr=jte(e),this.rs()}add(e){const n=(function(i){let r;try{r=wit(i)}catch{return}try{const s=JSON.parse(r);if(!xA(s))return;const a=s,A=a[Jte],c=a[Wte];return!nA(A)||A.trim().length===0||!nA(c)&&!qd(c)?void 0:{step:a,json:r}}catch{return}})(e);if(!n)return;const o=(function(i){if("u">typeof TextEncoder)return new TextEncoder().encode(i).length;const r=encodeURIComponent(i);let s=0;for(let a=0;r.length>a;a++)r[a]==="%"?(s+=1,a+=2):s+=1;return s})(n.json);o>this.Mr.max_bytes||(this.ns.push({step:n.step,bytes:o}),this.ss+=o,this.rs())}getAttachable(){return this.ns.map(e=>e.step)}clear(){this.ns=[],this.ss=0}size(){return this.ns.length}rs(){for(;this.ss>this.Mr.max_bytes&&this.ns.length>0;){const e=this.ns.shift();e&&(this.ss-=e.bytes)}}};function U4n(t,e){if(!qd(t)||t===1/0||t===-1/0)return e;const n=Math.floor(t);return 0>n?e:n}const Qrt=t=>{if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}};function vrt(t){return typeof t=="string"||t}function wrt(t){return typeof t=="string"?t:void 0}const K4n=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],Prt="NativeGzipValidationError",Jye=t=>t.length>=2&&t[0]===31&&t[1]===139,Mrt=(t,e)=>t===wye.GZipJS||e===wye.GZipJS||e==="gzip",Drt=t=>!(!t||typeof t!="object")&&("name"in t?String(t.name):"")==="NotReadableError";let qK;const Xte=t=>{throw prt(Prt,`Native gzip produced invalid output: ${t}`)},V4n=(Nrt=Wg(function*(t,e){18>t.size&&Xte("too-short");const n=new Uint8Array(yield t.slice(0,10).arrayBuffer());Jye(n)&&n[2]===8||Xte("invalid-header");const o=new DataView(yield t.slice(t.size-8).arrayBuffer());o.getUint32(0,!0)!==(r=>{const s=(()=>{if(qK)return qK;qK=[];for(let A=0;256>A;A++){let c=A;for(let l=0;8>l;l++)c=1&c?3988292384^c>>>1:c>>>1;qK[A]=c>>>0}return qK})();let a=4294967295;for(let A=0;r.length>A;A++)a=s[255&(a^r[A])]^a>>>8;return(4294967295^a)>>>0})(e)&&Xte("invalid-crc");const i=e.length>>>0;o.getUint32(4,!0)!==i&&Xte("invalid-size")}),function(t,e){return Nrt.apply(this,arguments)});var Nrt;function Wye(){return Wye=Wg(function*(t,e=!0,n){try{const i=new TextEncoder().encode(t),r=new globalThis.CompressionStream("gzip"),s=r.writable.getWriter(),a=s.write(i).then(()=>s.close()).catch((o=Wg(function*(l){try{yield s.abort(l)}catch{}throw l}),function(l){return o.apply(this,arguments)})),A=new Response(r.readable).blob(),[c]=yield Promise.all([A,a]);return yield V4n(c,i),c}catch(i){if(n?.rethrow)throw i;return e&&console.error("Failed to gzip compress data",i),null}var o}),Wye.apply(this,arguments)}function Rrt(t,e){if(t==null)return{};var n,o,i=(function(s,a){if(s==null)return{};var A={};for(var c in s)if({}.hasOwnProperty.call(s,c)){if(a.includes(c))continue;A[c]=s[c]}return A})(t,e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);for(o=0;r.length>o;o++)e.includes(n=r[o])||{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}const z4n={}.propertyIsEnumerable;function qte(t,e){try{return Trt(t,e,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch{return[]}}function jye(t,e,n,o){if(0>=n.remainingNodes)return{stringValue:Yye};if(n.remainingNodes--,py(t))return{boolValue:t};if(typeof t=="bigint")return(function(i,r){const s=i.toString(),a=BigInt("9223372036854775808");return i>=a||-a>i?(r?.debug(`Attribute ${s} is outside the int64 range; encoding it as a string`),{stringValue:s}):{intValue:s}})(t,e);if(typeof t=="number"){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if(typeof BigInt>"u")return{stringValue:String(t)};const i=BigInt(t).toString();return t>=9223372036854776e3||-9223372036854776e3>t?(e?.debug(`Attribute ${i} is outside the int64 range; encoding it as a string`),{stringValue:i}):{intValue:i}}return{doubleValue:t}}if(typeof t=="string")return{stringValue:wk(t)};if(typeof t=="function")return{stringValue:"[Function]"};if(typeof t=="symbol")return{stringValue:String(t)};if(typeof t=="object"&&t!==null){if(n.ancestors.has(t))return{stringValue:"[Circular]"};if(o>=20)return{stringValue:Yye};if(t instanceof Date){const i=t.getTime(),r=Number.isFinite(i)?t.toISOString():String(t);return{stringValue:typeof r=="string"?wk(r):String(r)}}n.ancestors.add(t);try{try{const i=t.toJSON;if(typeof i=="function")return jye(i.call(t),e,n,o+1)}catch{}return As(t)?{arrayValue:{values:J4n(t,e,n,o+1)}}:{kvlistValue:{values:Trt(t,e,n,o+1)}}}finally{n.ancestors.delete(t)}}return{stringValue:wk(String(t))}}function J4n(t,e,n,o){const i=[],r=Math.min(t.length,1e3);let s=0;for(;r>s&&n.remainingNodes>0;s++)try{const a=s in t?t[s]:void 0;if(Fs(a))continue;i.push(jye(a,e,n,o))}catch{i.push({stringValue:jK})}return t.length>s&&i.push({stringValue:Yye}),i}function Trt(t,e,n,o){const i=[];for(const r in t)if(z4n.call(t,r)){if(!r){e?.debug("Dropping an attribute with an empty key");continue}if(i.length>=1e3||0>=n.remainingNodes){e?.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{const s=t[r];if(ad(s)||Eo(s))continue;i.push({key:wk(r),value:jye(s,e,n,o)})}catch{i.push({key:wk(r),value:{stringValue:jK}})}}return i}function krt(t,e,n){return sn(sn(sn(sn({},urt({},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})}const W4n=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function Frt(t,e){const n=urt({},t),o={};for(const i of W4n)({}).hasOwnProperty.call(n,i)&&(o[i]=n[i],delete n[i]);return[...qte(n,e),...qte(o,e)]}const Lrt={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"},Hrt={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}},j4n=Hrt.info;function X4n(t){try{return wk(String(t))}catch{return jK}}function q4n(t,e,n,o){const i=t.level||"info",{text:r,number:s}=Hrt[i]||j4n,a=(function(u=Date.now()){return String(u)+"000000"})(qd(o)?o:void 0),A={};e.distinctId&&(A.posthogDistinctId=e.distinctId),e.sessionId&&(A.sessionId=e.sessionId),e.windowId&&(A["window.id"]=e.windowId),Fs(e.sessionStartTimestamp)||(A.sessionStartTimestamp=String(e.sessionStartTimestamp)),Fs(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);const c=sn({},A),l=t.attributes;if(l){let u=[];try{u=Object.keys(l)}catch{u=[]}for(const h of u){let d;try{d=l[h]}catch{d=jK}Object.defineProperty(c,h,{value:d,enumerable:!0,writable:!0,configurable:!0})}}const g={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:s,severityText:r,body:{stringValue:X4n(t.body)},attributes:qte(c,n)};return t.trace_id&&(g.traceId=t.trace_id),t.span_id&&(g.spanId=t.span_id),Eo(t.trace_flags)||(g.flags=t.trace_flags),g}function Ort(t,e,n){return krt(t,e,n)}function Grt(t,e,n,o){return{resourceLogs:[{resource:{attributes:Frt(e)},scopeLogs:[{scope:{name:n,version:o},logRecords:t}]}]}}var Yrt=class{constructor(e){this.ls=e,this.us=0}get pending(){return!!this.hs}arm(e){this.clear(),this.us=Date.now()+e,this.hs=_rt(()=>{this.hs=void 0,this.ls()},e)}armNoEarlierThan(e){this.hs&&Date.now()+e<=this.us||this.arm(e)}clear(){this.hs&&(clearTimeout(this.hs),this.hs=void 0)}};function Urt(){return .75+.5*Math.random()}function Krt(t,e,n,o){const i=Math.min(Math.max(0,e-1),6),r=t*Math.pow(2,i);return Math.round(Math.min(r,Math.max(o,t))*n)}var $4n=class{constructor(e,n,o,i,r,s=()=>Promise.resolve(),a){var A;this._instance=e,this.Mr=n,this.A=o,this.cs=i,this.ds=r,this.vs=s,this.fs=a,this.ps=new Yrt(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new drt,this.ks=0,this.Ss=1,this.xs=0,this.$s=0,this.Cs=!1,this.Ts=n.maxBufferSize,this.Is=Math.max((A=n.maxQueueSize)!==null&&A!==void 0?A:n.maxBufferSize,n.maxBufferSize),this.Ms=n.flushIntervalMs,this.Es=n.maxBatchRecordsPerPost,this.Ps=n.rateCapWindowMs,this.Rs=n.maxLogsPerInterval}clearQueue(){this._s++,this._instance.setPersistedProperty(x9.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.$s=0,this.Cs=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Es=this.Mr.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.As()&&this.Os():this.gs()}captureLog(e,n){var o;if(this._instance.isDisabled||this._instance.optedOut||!e?.body)return;const i=this.Fs(e);if(i===null)return;if(!i.body)return void this.A.info("Log was rejected in beforeSend function");if(!this.Ds())return;const r={record:q4n(i,(o=n?.context)!==null&&o!==void 0?o:this.cs(),this.A,n?.occurredAtMs)};this.ds(()=>this.Ls(r))}Fs(e){const n=this.Mr.beforeSend;if(!n)return e;const o=As(n)?n:[n];let i=e;for(const r of o)try{const s=r(i);if(!s)return this.A.info("Log was rejected in beforeSend function"),null;i=s}catch(s){return this.A.error("Error in beforeSend function for log:",s),null}return i}Ds(){if(this.Rs===void 0)return!0;const e=Date.now(),n=e-this.xs;return this.Ps>n&&n>=0||(this.xs=e,this.$s=0,this.Cs=!1),this.Rs>this.$s?(this.$s++,!0):(this.Cs||(this.A.warn(`captureLog dropping logs: exceeded ${this.Rs} logs per ${this.Ps}ms`),this.Cs=!0),!1)}flush(){var e=this;return Wg(function*(){if(!e._instance.isDisabled)return e.ys||(e.ys=e.Ns().finally(()=>{e.ys=null})),e.ys})()}Ns(){var e=this;return Wg(function*(){var n;e.ps.clear();let o=(n=e._instance.getPersistedProperty(x9.LogsQueue))!==null&&n!==void 0?n:[];if(o.length===0)return;const i=o.length;let r=0;for(;o.length>0&&i>r;){var s,a;const A=e._s;e.bs=0;const c=Math.min(o.length,e.Es),l=o.slice(0,c),g=Grt(l.map(h=>h.record),e.qs(),(s=e.fs)!==null&&s!==void 0?s:e._instance.getLibraryId(),e._instance.getLibraryVersion()),u=yield e._instance.js(g);if(e._s!==A)return;if(u.kind==="too-large"&&l.length>1)e.Es=Math.max(1,Math.floor(l.length/2)),e.A.warn(`Logs batch of size ${l.length} was too large for the ingestion endpoint, reducing batch size to ${e.Es}`);else if(e.ws.record(u),e.ps.pending&&e.ps.arm(Math.max(e.Ms,e.ws.remainingMs())),u.kind==="retry-later"||(u.kind==="too-large"?e.A.warn("Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further."):u.kind==="ok"&&e.Mr.maxBatchRecordsPerPost>e.Es&&(e.Es=Math.min(e.Mr.maxBatchRecordsPerPost,e.Es+1)),yield e.Bs(l.length),o=(a=e._instance.getPersistedProperty(x9.LogsQueue))!==null&&a!==void 0?a:[],r+=l.length,u.kind==="fatal"))throw u.error}})()}Bs(e){var n=this;return Wg(function*(){var o;const i=Math.max(0,e-n.bs),r=(o=n._instance.getPersistedProperty(x9.LogsQueue))!==null&&o!==void 0?o:[];n._instance.setPersistedProperty(x9.LogsQueue,r.slice(i)),yield n.vs()})()}qs(){return Ort(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(e){var n;if(this._instance.optedOut)return;const o=(n=this._instance.getPersistedProperty(x9.LogsQueue))!==null&&n!==void 0?n:[];this.Is>o.length||(o.shift(),this.bs++,this.A.info("Logs queue is full, dropping oldest record.")),o.push(e),this._instance.setPersistedProperty(x9.LogsQueue,o),this.Ts>o.length||this.ws.isOpen()?this.Os():this.gs()}Os(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}Hs(){return Math.max(Krt(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){const e=this._instance.getPersistedProperty(x9.LogsQueue);return!!e&&e.length>0}shutdown(e){var n=this;return Wg(function*(){n.ps.clear();const o=n.flush().catch(()=>{});e!==void 0?yield frt(o,e):yield o})()}flushWithTimeout(e){var n=this;return Wg(function*(){const o=n.flush();yield frt(o,e,()=>{o.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},e=>{this.ks++,this.Ss=Urt(),this.A.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.Hs())})}};const Xye=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Vrt(t){return String(t)+"000000"}function zrt(t,e,n,o){let i="";return o&&(i=Object.keys(o).sort().map(r=>`${JSON.stringify(r)}:${JSON.stringify(o[r])}`).join(",")),`${t}\0${e}\0${n??""}\0${i}`}var Z4n=class{constructor(e,n,o){this._instance=e,this.Mr=n,this.A=o,this.zs=new Map,this.ps=new Yrt(()=>this.flush().catch(i=>{this.A.error("Metrics flush failed:",i)})),this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.ws=new drt,this.ks=0,this.Ss=1,this.Gs=0}count(e,n=1,o){this.Qs({name:e,type:"count",value:n,unit:o?.unit,attributes:o?.attributes})}gauge(e,n,o){this.Qs({name:e,type:"gauge",value:n,unit:o?.unit,attributes:o?.attributes})}histogram(e,n,o){this.Qs({name:e,type:"histogram",value:n,unit:o?.unit,attributes:o?.attributes})}flush(){var e=this;const n=this.ys,o=(function(){var i=Wg(function*(){n&&(yield n.catch(()=>{})),yield e.Js()});return function(){return i.apply(this,arguments)}})()().finally(()=>{this.ys===o&&(this.ys=null)});return this.ys=o,o}drainWindow(){if(this.zs.size===0)return null;const e=this.zs;return this.zs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Zs(e)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.zs=new Map,this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set}Qs(e){if(this._instance.isDisabled||this._instance.optedOut)return;const n=this.Fs(e);if(n===null)return;if(!n.name||typeof n.name!="string")return void this.A.warn("Dropping metric with empty name");if(typeof n.value!="number"||!Number.isFinite(n.value))return void this.A.warn(`Dropping metric '${n.name}': value must be a finite number`);if(n.type==="count"&&0>n.value)return void this.A.warn(`Dropping count '${n.name}': counters are monotonic, value must be >= 0`);let o,i;try{o=n.attributes?sn({},n.attributes):void 0,i=zrt(n.type,n.name,n.unit,o)}catch(a){return void this.A.warn(`Dropping metric '${n.name}': attributes could not be serialized`,a)}let r=this.zs.get(i);if(!r){if(!this.Ks())return;r={name:n.name,type:n.type,unit:n.unit,attributes:o,windowStartMs:Date.now()},this.zs.set(i,r)}const s=this.Ws.get(n.name);s===void 0?this.Ws.set(n.name,n.type):s===n.type||this.Vs.has(n.name)||(this.Vs.add(n.name),this.A.warn(`Metric name '${n.name}' is already used as a ${s}; recording it as a ${n.type} too will blend both series in charts. Use a distinct name.`)),this.Xs(r,n.value),this.Os()}Ks(){return this.Mr.maxSeriesPerFlush>this.zs.size||(this.Us||(this.Us=!0,this.A.warn(`Metric series cap reached (${this.Mr.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}Xs(e,n){switch(e.type){case"count":var o;e.total=((o=e.total)!==null&&o!==void 0?o:0)+n;break;case"gauge":e.last=n;break;case"histogram":{e.hist||(e.hist={count:0,sum:0,min:n,max:n,bucketCounts:new Array(Xye.length+1).fill(0)});const i=e.hist;i.count+=1,i.sum+=n,i.min=Math.min(i.min,n),i.max=Math.max(i.max,n),i.bucketCounts[(function(r,s){for(let a=0;s.length>a;a++)if(s[a]>=r)return a;return s.length})(n,Xye)]+=1;break}}}Fs(e){const n=this.Mr.beforeSend;if(!n)return e;const o=As(n)?n:[n];let i=e;for(const r of o)try{const s=r(i);if(!s)return this.A.info("Metric was rejected in beforeSend function"),null;i=s}catch(s){return this.A.error("Error in beforeSend function for metric:",s),null}return i}Os(){this.ps.pending||this.ps.arm(this.Hs())}Hs(){return Math.max(Krt(this.Mr.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Js(){var e=this;return Wg(function*(){if(e.ps.clear(),e.zs.size===0)return;const n=e.zs;e.zs=new Map,e.Us=!1,e.Ws=new Map,e.Vs=new Set;const o=e.Gs,i=yield e._instance.Ys(e.Zs(n));if(o===e.Gs)switch(e.ws.record(i),i.kind==="retry-later"?(e.ks++,e.Ss=Urt()):(e.ks=0,e.Ss=1),e.ps.pending&&e.ps.arm(e.Hs()),i.kind){case"ok":return;case"retry-later":return e.ho(n),void e.ps.armNoEarlierThan(e.Hs());case"too-large":return void e.A.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e.A.error("Failed to send metrics batch:",i.error)}})()}Zs(e){return n=this.co(e),o=(function(s,a,A){return krt(s,a,A)})(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),i=this._instance.getLibraryId(),r=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Frt(o)},scopeMetrics:[{scope:{name:i,version:r},metrics:n}]}]};var n,o,i,r}co(e){const n=Vrt(Date.now()),o=new Map;for(const a of e.values()){var i;const A=zrt(a.type,a.name,a.unit,void 0);let c=o.get(A);c||(c=sn({name:a.name},a.unit&&{unit:a.unit}),a.type==="count"?c.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:a.type==="gauge"?c.gauge={dataPoints:[]}:c.histogram={aggregationTemporality:1,dataPoints:[]},o.set(A,c));const l=qte((i=a.attributes)!==null&&i!==void 0?i:{},this.A),g=Vrt(a.windowStartMs);if(a.type==="count"){var r;const u={attributes:l,startTimeUnixNano:g,timeUnixNano:n,asDouble:(r=a.total)!==null&&r!==void 0?r:0};c.sum.dataPoints.push(u)}else if(a.type==="gauge"){var s;const u={attributes:l,timeUnixNano:n,asDouble:(s=a.last)!==null&&s!==void 0?s:0};c.gauge.dataPoints.push(u)}else a.hist&&c.histogram.dataPoints.push({attributes:l,startTimeUnixNano:g,timeUnixNano:n,count:a.hist.count,sum:a.hist.sum,min:a.hist.min,max:a.hist.max,bucketCounts:a.hist.bucketCounts,explicitBounds:Xye})}return Array.from(o.values())}ho(e){for(const[i,r]of e){const s=this.zs.get(i);if(s)switch(s.windowStartMs=Math.min(s.windowStartMs,r.windowStartMs),s.type){case"count":var n,o;s.total=((n=s.total)!==null&&n!==void 0?n:0)+((o=r.total)!==null&&o!==void 0?o:0);break;case"gauge":break;case"histogram":if(r.hist)if(s.hist){s.hist.count+=r.hist.count,s.hist.sum+=r.hist.sum,s.hist.min=Math.min(s.hist.min,r.hist.min),s.hist.max=Math.max(s.hist.max,r.hist.max);for(let a=0;s.hist.bucketCounts.length>a;a++)s.hist.bucketCounts[a]+=r.hist.bucketCounts[a]}else s.hist=r.hist}else this.Ks()&&this.zs.set(i,r)}}};const Jrt=(t,{debugEnabled:e}={})=>{const n={N(o,...i){Fn&&(f8.DEBUG||Fn.POSTHOG_DEBUG||e)&&!Eo(Fn.console)&&Fn.console&&("__rrweb_original__"in Fn.console[o]?Fn.console[o].__rrweb_original__:Fn.console[o])(t,...i)},debug(...o){n.N("debug",...o)},info(...o){n.N("log",...o)},warn(...o){n.N("warn",...o)},error(...o){n.N("error",...o)},critical(...o){console.error(t,...o)},uninitializedWarning(o){n.error(`You must initialize PostHog before calling ${o}`)},createLogger:(o,i)=>Jrt(`${t} ${o}`,i)};return n},gi=Jrt("[PostHog.js]"),Ad=gi.createLogger,eBn=Ad("[ExternalScriptsLoader]"),$te=t=>{const e=No?.querySelectorAll("script");if(e){for(let n=0;e.length>n;n++)if(e[n].src===t||e[n].getAttribute("src")===t)return e[n]}},DM=(t,e,n)=>{if(t.config.disable_external_dependency_loading)return eBn.warn(`${e} was requested but loading of external scripts is disabled.`),n("Loading of external scripts is disabled");const o=$te(e);if(o){if(o.__posthog_loading_callback_fired)return n();const r=o.__posthog_loading_error;return r?n(r):(o.addEventListener("load",s=>{o.__posthog_loading_callback_fired=!0,n(void 0,s)}),void o.addEventListener("error",s=>{o.__posthog_loading_error=s,n(s)}))}const i=()=>{if(!No)return n("document not found");if($te(e))return DM(t,e,n);let r=No.createElement("script");if(r.type="text/javascript",r.crossOrigin="anonymous",r.src=e,r.onload=a=>{r.__posthog_loading_callback_fired=!0,n(void 0,a)},r.onerror=a=>{r.__posthog_loading_error=a,n(a)},t.config.prepare_external_dependency_script&&(r=t.config.prepare_external_dependency_script(r)),!r)return n("prepare_external_dependency_script returned null");if(t.config.external_scripts_inject_target==="head")No.head.appendChild(r);else{const a=No.querySelectorAll("body > script");var s;a.length>0?(s=a[0].parentNode)===null||s===void 0||s.insertBefore(r,a[0]):No.body.appendChild(r)}};No?.body?i():No?.addEventListener("DOMContentLoaded",i)},qye={},Wrt=(t,e)=>{let n=`/static/${e}.js?v=${t.version}`;return e==="toolbar"&&(n=`${n}&t=${Math.floor(Date.now()/3e5)*3e5}`),t.requestRouter.endpointFor("assets",n)};Ur.__PosthogExtensions__=Ur.__PosthogExtensions__||{},Ur.__PosthogExtensions__.loadExternalDependency=(t,e,n)=>{if(e==="remote-config"){const i=t.requestRouter.endpointFor("assets",`/array/${t.config.token}/config.js`);return void DM(t,i,n)}const o=t.config.strict_script_versioning;if(o){const i=t.requestRouter.endpointFor("assets",`/static/${t.version}/${e}.js`),r=qye[i];if(o==="fallback"&&r){if($te(r))return void DM(t,r,n);delete qye[i]}return void DM(t,i,o==="fallback"?(s,a)=>{if(s)if(typeof s=="string")n(s);else{var A;const c=Wrt(t,e);qye[i]=c;const l=$te(i);l==null||(A=l.parentNode)===null||A===void 0||A.removeChild(l),DM(t,c,n)}else n(void 0,a)}:n)}DM(t,Wrt(t,e),n)},Ur.__PosthogExtensions__.loadSiteApp=(t,e,n)=>{const o=t.requestRouter.endpointFor("api",e);DM(t,o,n)},f8.DEBUG=!1,f8.LIB_VERSION="1.435.8",f8.LIB_NAME="web";var Ym=f8;const tBn="$people_distinct_id",T4="distinct_id",$ye="$device_id",Zye="$device_model",Zte="__alias",nBn="__cmpns",jrt="$fbc",Pk="$fbc_persistence",Xrt="$fbp",$K="$fbp_persistence",e2e="__timers",qrt="$autocapture_disabled_server_side",t2e="$heatmaps_enabled_server_side",n2e="$exception_capture_enabled_server_side",$rt="$error_tracking_suppression_rules",o2e="$error_tracking_capture_extension_exceptions",i2e="$web_vitals_enabled_server_side",r2e="$dead_clicks_enabled_server_side",s2e="$product_tours_enabled_server_side",Zrt="$logs_capture_enabled_server_side",est="$web_vitals_allowed_metrics",ZK="$session_recording_remote_config",oBn="$session_recording_enabled_server_side",iBn="$replay_sample_rate",rBn="$replay_override_sampling",sBn="$replay_override_linked_flag",aBn="$replay_override_url_trigger",ABn="$replay_override_event_trigger",Mk="$sesid",tst="$session_is_sampled",cBn="$session_past_minimum_duration",lBn="$session_recording_url_trigger_activated_session",gBn="$session_recording_event_trigger_activated_session",uBn="$debug_first_full_snapshot_timestamp",dBn="$sess_rec_flush_size",k4="$enabled_feature_flags",C8="$active_feature_flags",a2e="$early_access_features",NM="$feature_flag_details",cQ="$feature_flag_payloads",RM="$feature_flag_request_id",eV="$minimal_flag_called_events",B9="$override_feature_flags",TM="$override_feature_flag_payloads",lQ="$stored_person_properties",gQ="$stored_group_properties",nst="$groups",tV="$surveys",ene="$surveys_loaded_at",ost="$surveys_activated",ist="$surveys_activated_session",rst="$surveys_activated_timestamps",A2e="ph_product_tours",hBn="$product_tours_activated",pBn="$product_tours_activated_session",mBn="$conversations_widget_session_id",_Bn="$conversations_ticket_id",fBn="$conversations_widget_state",IBn="$conversations_user_traits",uQ="$flag_call_reported",nV="$flag_call_reported_session_id",oV="$feature_flag_errors",dQ="$feature_flag_evaluated_at",my="$user_state",c2e="$client_session_props",CBn="$capture_rate_limit",sst="$initial_campaign_params",ast="$initial_referrer_info",Dk="$initial_person_info",l2e="$epp",g2e="$posthog_cookieless",Ast="$cookieless_mode",cst="$sdk_debug_extensions_init_method",lst="$sdk_debug_extensions_init_time_ms",u2e="$sdk_debug_recording_script_not_loaded",d2e="$sdk_debug_replay_stale_config",gst="$sdk_debug_replay_event_trigger_status",ust="$sdk_debug_replay_linked_flag_trigger_status",dst="$sdk_debug_replay_matched_recording_trigger_groups",hst="$sdk_debug_replay_pending_trigger_conditions",pst="$sdk_debug_replay_remote_trigger_matching_config",mst="$sdk_debug_replay_trigger_groups_count",_st="$sdk_debug_replay_url_trigger_status",yBn="$session_recording_start_reason",h2e="PostHog loadExternalDependency extension not found.",y8="anonymous",tne="identified",fst="identified_only",iV="visibilitychange",nne="beforeunload",p2e="$pageview",Ist="$pageleave",Cst="$identify",yst="$groupidentify";function Nk(t,e){As(t)&&t.forEach(e)}function vl(t,e){if(!Fs(t))if(As(t))t.forEach(e);else if((n=>n instanceof FormData)(t))t.forEach((n,o)=>e(n,o));else for(const n in t)Mye.call(t,n)&&e(t[n],n)}const jg=function(t,...e){for(const n of e)for(const o in n)n[o]!==void 0&&(t[o]=n[o]);return t};function one(t){const e=Object.keys(t);let n=e.length;const o=new Array(n);for(;n--;)o[n]=[e[n],t[e[n]]];return o}const xBn=function(t){return function(...e){try{return t.apply(this,e)}catch(n){gi.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),gi.critical(n)}}},m2e=function(t){const e={};return vl(t,function(n,o){(nA(n)&&n.length>0||qd(n))&&(e[o]=n)}),e};function xst(t){const e=sn({},t);for(const n of["name","message","stack","cause","errors"])try{n in t&&(e[n]=t[n])}catch{}return e}const EBn=["herokuapp.com","vercel.app","netlify.app"];function BBn(t){const e=t?.hostname;if(!nA(e))return!1;const n=e.split(".").slice(-2).join(".");for(const o of EBn)if(n===o)return!1;return!0}function jc(t,e,n,o){const{capture:i=!1,passive:r=!0}=o??{};t?.addEventListener(e,n,{capture:i,passive:r})}function _2e(t){return t.name==="ph_toolbar_internal"}const rV=t=>{if(No){try{const e=t+"=",n=No.cookie.split(";").filter(o=>o.length);for(let o=0;n.length>o;o++){let i=n[o];for(;i.charAt(0)==" ";)i=i.substring(1,i.length);if(i.indexOf(e)===0)return decodeURIComponent(i.substring(e.length,i.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 qd(t)&&isFinite(t)&&Math.floor(t)===t});var bBn=class $nt{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,n,o,i){if(!Number.isInteger(e)||!Number.isInteger(n)||!Number.isInteger(o)||!Number.isInteger(i)||0>e||0>n||0>o||0>i||e>0xffffffffffff||n>4095||o>1073741823||i>4294967295)throw new RangeError("invalid field value");const r=new Uint8Array(16);return r[0]=e/Math.pow(2,40),r[1]=e/Math.pow(2,32),r[2]=e/Math.pow(2,24),r[3]=e/Math.pow(2,16),r[4]=e/256,r[5]=e,r[6]=112|n>>>8,r[7]=n,r[8]=128|o>>>24,r[9]=o>>>16,r[10]=o>>>8,r[11]=o,r[12]=i>>>24,r[13]=i>>>16,r[14]=i>>>8,r[15]=i,new $nt(r)}toString(){let e="";for(let 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 $nt(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(let n=0;16>n;n++){const o=this.bytes[n]-e.bytes[n];if(o!==0)return Math.sign(o)}return 0}},SBn=class{generate(){const e=this.generateOrAbort();if(!Eo(e))return e;{this.Ct=0;const n=this.generateOrAbort();if(Eo(n))throw new Error("Could not generate UUID after timestamp reset");return n}}generateOrAbort(){const e=(()=>{const n=Date.now();return qd(n)&&isFinite(n)?Math.min(Math.max(Math.floor(n),0),0xffffffffffff):0})();if(e>this.Ct)this.Ct=e,this.It();else{if(this.Ct>=e+1e4)return;this.Mt++,this.Mt>4398046511103&&(this.Ct++,this.It())}return bBn.fromFieldsV7(this.Ct,Math.trunc(this.Mt/Math.pow(2,30)),this.Mt&Math.pow(2,30)-1,this.Tt.nextUint32())}It(){this.Mt=1024*this.Tt.nextUint32()+(1023&this.Tt.nextUint32())}constructor(){this.Ct=0,this.Mt=0,this.Tt=new QBn}};let Est=t=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(let e=0;t.length>e;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};Fn&&!Eo(Fn.crypto)&&crypto.getRandomValues&&(Est=t=>crypto.getRandomValues(t));var QBn=class{nextUint32(){return this.Rt.length>this.At||(Est(this.Rt),this.At=0),this.Rt[this.At++]}constructor(){this.Rt=new Uint32Array(8),this.At=1/0}};let Bst;const F4=()=>vBn().toString(),vBn=()=>(Bst||(Bst=new SBn)).generate();let sV="";const wBn=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let Rk=null;const cd={Et(){if(!ad(Rk))return Rk;if(Rk=!1,No)try{const t=`__ph_cookie_support_${F4()}`;cd.$t(t,"xyz"),Rk=rV(t)==='"xyz"',cd.Pt(t)}catch{Rk=!1}return Rk},Dt(t){gi.error("cookieStore error: "+t)},Ot:rV,Lt(t){let e;try{e=JSON.parse(cd.Ot(t))||{}}catch{}return e},$t(t,e,n,o,i){if(!No)return!1;try{let r="",s="";const a=(function(c,l){if(l){let g=(function(u,h=No){if(sV)return sV;if(!h||["localhost","127.0.0.1"].includes(u))return"";const d=u.split(".");let p=Math.min(d.length,8);const m="dmn_chk_"+F4();for(;!sV&&p--;){const _=d.slice(p).join("."),f=m+"=1;domain=."+_+";path=/";h.cookie=f+";max-age=3",h.cookie.includes(m)&&(h.cookie=f+";max-age=0",sV=_)}return sV})(c);if(!g){const u=(h=>{const d=h.match(wBn);return d?d[0]:""})(c);u!==g&&gi.info("Warning: cookie subdomain discovery mismatch",u,g),g=u}return g?"; domain=."+g:""}return""})(No.location.hostname,o);if(n){const c=new Date;c.setTime(c.getTime()+864e5*n),r="; expires="+c.toUTCString()}i&&(s="; secure");const A=t+"="+encodeURIComponent(JSON.stringify(e))+r+"; SameSite=Lax; path=/"+a+s;return A.length>3686.4&&gi.warn("cookieStore warning: large cookie, len="+A.length),No.cookie=A,!0}catch{return!1}},Pt(t,e){if(No?.cookie&&(!e||!ad(rV(t))))try{cd.$t(t,"",-1,e)}catch{return}}};let f2e=null;const uc={Et(){if(!ad(f2e))return f2e;let t=!0;if(Eo(Fn))t=!1;else try{const e="__mplssupport__";uc.$t(e,"xyz"),uc.Ot(e)!=='"xyz"'&&(t=!1),uc.Pt(e)}catch{t=!1}return t||gi.error("localStorage unsupported; falling back to cookie store"),f2e=t,t},Dt(t){gi.error("localStorage error: "+t)},Ot(t){try{return Fn?.localStorage.getItem(t)}catch(e){uc.Dt(e)}return null},Lt(t){try{return JSON.parse(uc.Ot(t))||{}}catch{}return null},$t(t,e){try{return Fn?.localStorage.setItem(t,JSON.stringify(e)),!0}catch(n){uc.Dt(n)}return!1},Pt(t){try{Fn?.localStorage.removeItem(t)}catch(e){uc.Dt(e)}}},I2e=[lQ,C8,k4,NM,cQ,RM,dQ,oV,uQ],kM=[$ye,T4,Mk,tst,l2e,Dk,Pk,my],ine=t=>t+"_cpm",PBn=["__proto__","constructor","prototype"],C2e=t=>{if(!xA(t))return{};const e={};return Object.keys(t).forEach(n=>{PBn.indexOf(n)===-1&&(e[n]=t[n])}),e},y2e=(t,e=[])=>{const n={};return[...kM,...e].forEach(o=>{const i=t[o];Eo(i)||ad(i)||i===""||(n[o]=i)}),n},bst=t=>{let e=5381,n=2166136261;for(let o=0;t.length>o;o++){const i=t.charCodeAt(o);e=33*e^i,n=Math.imul(n^i,16777619)}return t.length.toString(36)+"."+(e>>>0).toString(36)+"."+(n>>>0).toString(36)},Sst=(t,e)=>({p:e,f:bst(JSON.stringify(t))}),Qst=(t,e)=>{if(!e)return{properties:[],isValid:!1};try{const n=cd.Lt(ine(t)),o=n?.f===bst(e)&&As(n.p);return{properties:o?n.p:[],isValid:o}}catch{return{properties:[],isValid:!1}}},x2e=(t,e)=>e+"|"+(cd.Ot(ine(t))||""),Tk={},E2e={Et:()=>!0,Dt(t){gi.error("memoryStorage error: "+t)},Ot:t=>t in Tk?Tk[t]:null,Lt:t=>t in Tk?Tk[t]:null,$t:(t,e)=>(Tk[t]=e,!0),Pt(t){delete Tk[t]}};let FM=null;const Z0={Et(){if(!ad(FM))return FM;if(FM=!0,Eo(Fn))FM=!1;else try{const t="__support__";Z0.$t(t,"xyz"),Z0.Ot(t)!=='"xyz"'&&(FM=!1),Z0.Pt(t)}catch{FM=!1}return FM},Dt(t){gi.error("sessionStorage error: ",t)},Ot(t){try{return Fn?.sessionStorage.getItem(t)}catch(e){Z0.Dt(e)}return null},Lt(t){try{return JSON.parse(Z0.Ot(t))||null}catch{}return null},$t(t,e){try{return Fn?.sessionStorage.setItem(t,JSON.stringify(e)),!0}catch(n){Z0.Dt(n)}return!1},Pt(t){try{Fn?.sessionStorage.removeItem(t)}catch(e){Z0.Dt(e)}}};var MBn=class{constructor(e){this._instance=e}get Mr(){return this._instance.config}get consent(){return this.Do()?0:this.Lo}isOptedOut(){return this.Mr.cookieless_mode==="always"||this.isRejected()||this.consent===-1&&this.Mr.cookieless_mode==="on_reject"}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Mr.opt_out_capturing_by_default}optInOut(e){this.No.$t(this.qo,e?1:0,this.Mr.cookie_expiration,this.Mr.cross_subdomain_cookie,this.Mr.secure_cookie)}reset(){this.No.Pt(this.qo,this.Mr.cross_subdomain_cookie)}get qo(){const{token:e,opt_out_capturing_cookie_prefix:n,consent_persistence_name:o}=this._instance.config;return o||(n?n+e:"__ph_opt_in_out_"+e)}get Lo(){const e=this.No.Ot(this.qo);return Nye(e)?1:as(n4n,e)?0:-1}get No(){const e=this.Mr.opt_out_capturing_persistence_type,n=e==="localStorage"?uc:cd,o=n.Et()?n:E2e;if(!this.jo||this.jo!==o){this.jo=o;const i=e==="localStorage"?cd:uc;i.Ot(this.qo)&&(this.jo.Ot(this.qo)||this.optInOut(Nye(i.Ot(this.qo))),i.Pt(this.qo,this.Mr.cross_subdomain_cookie))}return this.jo}Do(){return!!this.Mr.respect_dnt&&[F_?.doNotTrack,F_?.msDoNotTrack,Ur.doNotTrack,F_?.globalPrivacyControl].some(e=>Nye(e))}};function vst(t,e){var n;const o=t==null||(n=t.config)===null||n===void 0?void 0:n.get_current_url;if(!L_(o))return e;try{const i=o(e);return nA(i)&&i?i:e}catch(i){return gi.error("Error in get_current_url, falling back to window.location.href",i),e}}function wst(t){var e;return t instanceof Element&&(t.id==="__POSTHOG_TOOLBAR__"||!!(!((e=t.closest)===null||e===void 0)&&e.call(t,".toolbar-global-fade-container")))}function b9(t){return!!t&&t.nodeType===1}function j1(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function Pst(t){return!!t&&t.nodeType===3}function B2e(t){return!!t&&t.nodeType===11&&b9(t.host)}function b2e(t){return t?Rte(t).split(/\s+/):[]}function Mst(t,e){const n=(function(o){var i;const r=Fn==null||(i=Fn.location)===null||i===void 0?void 0:i.href;return Eo(r)?void 0:vst(o,r)})(e);return!!(n&&t&&t.some(o=>n.match(o)))}function kk(t){let 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 b2e(e)}function Dst(t){return Fs(t)?null:Rte(t).split(/(\s+)/).filter(e=>lV(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function aV(t){let e="";return Fk(t)&&!cV(t)&&t.childNodes&&t.childNodes.length&&vl(t.childNodes,function(n){var o;Pst(n)&&n.textContent&&(e+=(o=Dst(n.textContent))!==null&&o!==void 0?o:"")}),Rte(e)}function AV(t){var e;return Eo(t.target)?t.srcElement||null:!((e=t.target)===null||e===void 0)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null}const S2e=["a","button","form","input","select","textarea","label"];function Q2e(t,e){const n=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!n&&n.call(t,e)}catch{return!1}}function v2e(t,e){if(Eo(e))return!0;for(const n of t)if(e.some(o=>Q2e(n,o)))return!0;return!1}function Nst(t){const e=t.parentNode;return!(!e||!b9(e))&&e}const w2e=[".ph-no-autocapture","[data-ph-no-autocapture]"],Rst=["next","previous","prev",">","<"],DBn=[...Rst,"+","-","−","–"],Tst=(t,e)=>/[a-z0-9]/i.test(e)?t.includes(e):t===e,kst=[".ph-no-rageclick",".ph-no-capture"],NBn=["","text","search","email","password","url","tel","number"];function Fst(t,e){if(!Fn||P2e(t))return!1;let n,o,i;var r,s;if(py(e)?(n=!!e&&kst,o=void 0,i=!1):(n=(r=e?.css_selector_ignorelist)!==null&&r!==void 0?r:kst,o=e?.content_ignorelist,i=(s=e?.ignore_text_selection)!==null&&s!==void 0&&s),n===!1||i&&(function(A){return!(!A||!b9(A))&&(!!j1(A,"textarea")||(j1(A,"input")?as(NBn,(A.getAttribute("type")||"").toLowerCase()):(function(c){var l;if(c.isContentEditable)return!0;const g=(l=c.getAttribute)===null||l===void 0?void 0:l.call(c,"contenteditable");return g==="true"||g===""})(A)))})(t))return!1;const{targetElementList:a}=Lst(t,!1);return!(function(A,c){if(A===!1||Eo(A))return!1;let l;if(A===!0)l=Rst;else{if(!As(A))return!1;if(A.length>10)return gi.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;l=A.map(g=>g.toLowerCase())}return c.some(({safeText:g,ariaLabel:u})=>l.some(h=>Tst(g,h)||Tst(u,h)))})(o,a.map(A=>{var c;return{safeText:aV(A).toLowerCase(),ariaLabel:((c=A.getAttribute("aria-label"))===null||c===void 0?void 0:c.toLowerCase().trim())||""}}))&&!v2e(a,n)}const P2e=t=>!t||j1(t,"html")||!b9(t),Lst=(t,e)=>{if(!Fn||P2e(t))return{parentIsUsefulElement:!1,targetElementList:[]};let n=!1;const o=[t];let i=t;for(;i.parentNode&&!j1(i,"body");){if(B2e(i.parentNode)){o.push(i.parentNode.host),i=i.parentNode.host;continue}const r=Nst(i);if(!r)break;if(e||S2e.indexOf(r.tagName.toLowerCase())>-1)n=!0;else try{const s=Fn.getComputedStyle(r);s&&s.getPropertyValue("cursor")==="pointer"&&(n=!0)}catch{}o.push(r),i=r}return{parentIsUsefulElement:n,targetElementList:o}};function Fk(t){const e=new Set;let n=0;for(let r=t;r.parentNode&&!j1(r,"body");r=r.parentNode){if(n++>=1e3||e.has(r))return!1;e.add(r);const s=kk(r);if(as(s,"ph-sensitive")||as(s,"ph-no-capture"))return!1}if(as(kk(t),"ph-include"))return!0;const o=t.type||"";if(nA(o))switch(o.toLowerCase()){case"hidden":case"password":return!1}const i=t.name||t.id||"";return!nA(i)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,""))}function cV(t){return!!(j1(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||j1(t,"select")||j1(t,"textarea")||t.getAttribute("contenteditable")==="true")}const Hst=new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),Ost=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,RBn=[16,15,14,13],TBn=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Gst=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Yst=/[0-9A-Za-z_]/;function kBn(t){let e=0,n=!1;for(let o=t.length-1;o>=0;o--){let i=t.charCodeAt(o)-48;n&&(i*=2,i>9&&(i-=9)),e+=i,n=!n}return e%10==0}function lV(t,e=!0){return!(Fs(t)||nA(t)&&(t=Rte(t),(e?Hst.test((t||"").replace(/[- ]/g,"")):(function(n){let o;for(Ost.lastIndex=0;o=Ost.exec(n);){const i=o[2];if(!i)continue;const r=i.replace(/[- ]/g,"");for(let s=0;r.length>s;s++)for(const a of RBn){const A=s+a;if(r.length>=A){const c=r.slice(s,A);if(Hst.test(c)&&kBn(c))return!0}}}return!1})(t))||(e?TBn.test(t):(function(n){let o;for(Gst.lastIndex=0;o=Gst.exec(n);){const i=o[1],r=o[3];if(!(i&&r&&Yst.test(i)&&Yst.test(r)))return!0}return!1})(t))))}function Ust(t){let e=aV(t);return e=`${e} ${Kst(t)}`.trim(),lV(e)?e:""}function Kst(t){let e="";return t&&t.childNodes&&t.childNodes.length&&vl(t.childNodes,function(n){var o;if(n&&((o=n.tagName)===null||o===void 0?void 0:o.toLowerCase())==="span")try{const i=aV(n);e=`${e} ${i}`.trim(),n.childNodes&&n.childNodes.length&&(e=`${e} ${Kst(n)}`.trim())}catch(i){gi.error("[AutoCapture]",i)}}),e}function Vst(t){return t.replace(/"|\\"/g,'\\"')}function FBn(t){const e=t.attr__class;if(e)return As(e)?e:b2e(e)}const rne=Ad("[Dead Clicks]"),LBn=()=>!0,HBn=t=>{var e;const n=!!(!((e=t.instance.persistence)===null||e===void 0)&&e.get_property(r2e)),o=t.instance.config.capture_dead_clicks;return py(o)?o:!!xA(o)||n};var zst=class{get lazyLoadedDeadClicksAutocapture(){return this.Bo}constructor(e,n,o){this.instance=e,this.isEnabled=n,this.onCapture=o,this.startIfEnabledOrStop()}onRemoteConfig(e){if(!e.ok)return;const n=e.config;"captureDeadClicks"in n&&(this.instance.persistence&&this.instance.persistence.register({[r2e]:n.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.Ho(()=>{this.zo()}):this.stop()}Ho(e){var n,o,i;!((n=Ur.__PosthogExtensions__)===null||n===void 0)&&n.initDeadClicksAutocapture?e():(o=Ur.__PosthogExtensions__)===null||o===void 0||(i=o.loadExternalDependency)===null||i===void 0||i.call(o,this.instance,"dead-clicks-autocapture",r=>{r?rne.error("failed to load script",r):e()})}zo(){var e;if(No){if(!this.Bo&&(!((e=Ur.__PosthogExtensions__)===null||e===void 0)&&e.initDeadClicksAutocapture)){const n=xA(this.instance.config.capture_dead_clicks)?sn({},this.instance.config.capture_dead_clicks):{};n.__onCapture=this.onCapture,this.onCapture&&(n.capture_dead_swipes=!1),this.Bo=Ur.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this.Bo.start(No),rne.info("starting...")}}else rne.error("`document` not found. Cannot start.")}stop(){this.Bo&&(this.Bo.stop(),this.Bo=void 0,rne.info("stopping..."))}};const gV=Ad("[SegmentIntegration]");function Jst(t,e,n=!0){const o=t.config.segment;if(!o)return e();const{analytics:i,filterProperties:r}=(a=>L_(a.register))(s=o)?{analytics:s}:s;var s;(function(a,A,c,l){const g=h=>{const d=()=>h.anonymousId()||F4();a.config.get_device_id=d,l&&h.id()&&(a.register({distinct_id:h.id(),$device_id:d()}),a.persistence.set_property(my,tne)),c(l?void 0:h.anonymousId()||void 0)},u=A.user();"then"in u&&L_(u.then)?u.then(g):g(u)})(t,i,a=>{i.register(((A,c,{filterProperties:l}={})=>{typeof Promise<"u"&&Promise.resolve||gV.warn("This browser does not have Promise support, and can not use the segment integration");const g=(u,h)=>{if(!h)return u;const d=!!c&&u.event.anonymousId===c&&!u.event.userId;d||u.event.userId||u.event.anonymousId===A.get_distinct_id()||(gV.info("No userId set, resetting PostHog"),A.reset()),d||(c=void 0),u.event.userId&&u.event.userId!==A.get_distinct_id()&&(gV.info("UserId set, identifying with PostHog"),A.identify(u.event.userId));let p=A.calculateEventProperties(h,u.event.properties);if(!Fs(l)){const m=u.event.properties||{},_={};for(const I of Object.keys(p))Mye.call(m,I)||(_[I]=p[I]);const f=((I,C)=>{const y=As(I)?I:[I];let x=sn({},C);for(const E of y)try{if(x=E(x),Fs(x))return null}catch(B){return gV.error("Error in Segment filterProperties:",B),null}return x})(l,_);if(Fs(f))return u;p=f}return u.event.properties=Object.assign({},p,u.event.properties),u};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(u){return g(u,u.event.event)},page(u){return g(u,p2e)},identify(u){return g(u,Cst)},screen(u){return g(u,"$screen")}}})(t,a,{filterProperties:r})).then(()=>{e()},A=>{gV.error("Failed to register the Segment integration",A),e()})},n)}const Wst="posthog-js";function jst(t,{organization:e,projectId:n,prefix:o,severityAllowList:i=["error"],sendExceptionsToPostHog:r=!0}={}){return s=>{var a,A,c,l,g;if(i!=="*"&&!i.includes(s.level)||!t.__loaded)return s;s.tags||(s.tags={});const u=t.requestRouter.endpointFor("ui",`/project/${t.config.token}/person/${t.get_distinct_id()}`);s.tags["PostHog Person URL"]=u,t.sessionRecordingStarted()&&(s.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));const h=((a=s.exception)===null||a===void 0?void 0:a.values)||[],d=h.map(_=>sn(sn({},_),{},{stacktrace:_.stacktrace?sn(sn({},_.stacktrace),{},{type:"raw",frames:(_.stacktrace.frames||[]).map(f=>sn(sn({},f),{},{platform:"web:javascript"}))}):void 0})),p={$exception_message:((A=h[0])===null||A===void 0?void 0:A.value)||s.message,$exception_type:(c=h[0])===null||c===void 0?void 0:c.type,$exception_level:s.level,$exception_list:d,$sentry_event_id:s.event_id,$sentry_exception:s.exception,$sentry_exception_message:((l=h[0])===null||l===void 0?void 0:l.value)||s.message,$sentry_exception_type:(g=h[0])===null||g===void 0?void 0:g.type,$sentry_tags:s.tags};var m;return e&&n&&(p.$sentry_url=(o||"https://sentry.io/organizations/")+e+"/issues/?project="+n+"&query="+s.event_id),r&&((m=t.exceptions)===null||m===void 0||m.sendExceptionEvent(p)),s}}var OBn=class{constructor(e,n,o,i,r,s){this.name=Wst,this.setupOnce=function(a){a(jst(e,{organization:n,projectId:o,prefix:i,severityAllowList:r,sendExceptionsToPostHog:s==null||s}))}}},Xst=class{constructor(e){this.Uo=(n,o,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(gi.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:n,changeReason:i}),this.Wo=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Vo()}Vo(){var e;this.Go=(e=this._instance.sessionManager)===null||e===void 0?void 0:e.onSessionId(this.Uo)}destroy(){var e;(e=this.Go)===null||e===void 0||e.call(this),this.Go=void 0}doPageView(e,n){var o;const i=this.Qo(e,n);return this.Wo={pathname:(o=Fn?.location.pathname)!==null&&o!==void 0?o:"",pageViewId:n,timestamp:e},this._instance.scrollManager.resetContext(),i}doPageLeave(e){var n;return this.Qo(e,(n=this.Wo)===null||n===void 0?void 0:n.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.Wo)===null||e===void 0?void 0:e.pageViewId}}Qo(e,n){const o=this.Wo;if(!o)return{$pageview_id:n};let i={$pageview_id:n,$prev_pageview_id:o.pageViewId};const r=this._instance.scrollManager.getContext();if(r&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:s,lastScrollY:a,maxScrollY:A,maxContentHeight:c,lastContentY:l,maxContentY:g}=r;if(!(Eo(s)||Eo(a)||Eo(A)||Eo(c)||Eo(l)||Eo(g))){s=Math.ceil(s),a=Math.ceil(a),A=Math.ceil(A),c=Math.ceil(c),l=Math.ceil(l),g=Math.ceil(g);const u=s>1?E9(a/s,0,1,gi):1,h=s>1?E9(A/s,0,1,gi):1,d=c>1?E9(l/c,0,1,gi):1,p=c>1?E9(g/c,0,1,gi):1;i=jg(i,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:u,$prev_pageview_max_scroll:A,$prev_pageview_max_scroll_percentage:h,$prev_pageview_last_content:l,$prev_pageview_last_content_percentage:d,$prev_pageview_max_content:g,$prev_pageview_max_content_percentage:p})}}return o.pathname&&(i.$prev_pageview_pathname=o.pathname),o.timestamp&&(i.$prev_pageview_duration=(e.getTime()-o.timestamp.getTime())/1e3),i}};const uV=["flags","surveys"],GBn={[tBn]:{exposure:"hidden"},[Zte]:{exposure:"hidden"},[nBn]:{exposure:"hidden"},[e2e]:{exposure:"hidden"},[Pk]:{exposure:"hidden"},[$K]:{exposure:"hidden"},[qrt]:{exposure:"event"},[t2e]:{exposure:"hidden"},[Zrt]:{exposure:"hidden"},[n2e]:{exposure:"event"},[$rt]:{exposure:"hidden"},[o2e]:{exposure:"event"},[i2e]:{exposure:"event"},[r2e]:{exposure:"event"},[s2e]:{exposure:"hidden"},[est]:{exposure:"event"},[ZK]:{exposure:"hidden"},[oBn]:{exposure:"hidden"},[Mk]:{exposure:"hidden"},[tst]:{exposure:"event"},[iBn]:{exposure:"event",shouldSkipFromEventProperties:t=>ad(t)},[cBn]:{exposure:"event"},[lBn]:{exposure:"event"},[gBn]:{exposure:"event"},[uBn]:{exposure:"event"},[dBn]:{exposure:"hidden"},[k4]:{exposure:"hidden",storageGroup:"flags"},[C8]:{exposure:"hidden",storageGroup:"flags"},[a2e]:{exposure:"hidden"},[NM]:{exposure:"hidden",storageGroup:"flags"},[cQ]:{exposure:"hidden",storageGroup:"flags"},[RM]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[eV]:{exposure:"hidden",storageGroup:"flags"},[B9]:{exposure:"hidden"},[TM]:{exposure:"hidden"},[lQ]:{exposure:"hidden"},[gQ]:{exposure:"hidden"},[tV]:{exposure:"hidden",storageGroup:"surveys"},[ene]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[ost]:{exposure:"event"},[ist]:{exposure:"hidden"},[rst]:{exposure:"hidden"},[A2e]:{exposure:"hidden"},[hBn]:{exposure:"hidden"},[pBn]:{exposure:"hidden"},[mBn]:{exposure:"event"},[_Bn]:{exposure:"event"},[fBn]:{exposure:"event"},[IBn]:{exposure:"event"},[uQ]:{exposure:"hidden"},[nV]:{exposure:"hidden"},[nst]:{exposure:"event"},[oV]:{exposure:"hidden"},[dQ]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[my]:{exposure:"hidden"},[c2e]:{exposure:"hidden"},[CBn]:{exposure:"hidden"},[sst]:{exposure:"hidden"},[ast]:{exposure:"hidden"},[Dk]:{exposure:"hidden"},[l2e]:{exposure:"hidden"},[rBn]:{exposure:"event"},[sBn]:{exposure:"event"},[aBn]:{exposure:"event"},[ABn]:{exposure:"event"},[cst]:{exposure:"event"},[lst]:{exposure:"event"},[u2e]:{exposure:"hidden"},[d2e]:{exposure:"hidden"},[gst]:{exposure:"hidden"},[ust]:{exposure:"hidden"},[dst]:{exposure:"hidden"},[hst]:{exposure:"hidden"},[pst]:{exposure:"hidden"},[mst]:{exposure:"hidden"},[_st]:{exposure:"hidden"},[yBn]:{exposure:"event"}},YBn=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],Kf=t=>{const e=GBn[t];if(e)return e;for(const[n,o]of YBn)if(t.indexOf(n)===0)return o},Lk=(t,e)=>{try{let n;return JSON.stringify(t,(o,i)=>{var r;return Qk(i)?((r=n)!==null&&r!==void 0||(n=new WeakMap),n.has(i)||n.set(i,xst(i)),n.get(i)):typeof i=="bigint"?i.toString():i},e)}catch{return wit(t)}},x8=t=>{const e=No?.createElement("a");return Eo(e)?null:(e.href=t,e)},Hk=function(t,e){const n=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&");let o;for(let i=0;n.length>i;i++){const r=n[i].split("=");if(r[0]===e){o=r;break}}if(!As(o)||2>o.length)return"";{let i=o[1];try{i=decodeURIComponent(i)}catch{gi.error("Skipping decoding for malformed query param: "+i)}return i.replace(/\+/g," ")}},dV=function(t,e,n){if(!t||!e||!e.length)return t;const o=t.split("#"),i=o[1],r=(o[0]||"").split("?"),s=r[1],a=r[0],A=(s||"").split("&"),c=[];for(let g=0;A.length>g;g++){const u=A[g].split("=");As(u)&&(e.includes(u[0])?c.push(u[0]+"="+n):c.push(A[g]))}let l=a;return s!=null&&(l+="?"+c.join("&")),i!=null&&(l+="#"+i),l},sne=function(t,e){const n=t.match(new RegExp(e+"=([^&]*)"));return n?n[1]:null},qst=(t,e)=>t>=e&&vit(),$st=(t,e,n,o)=>{if(t===0){if(vit()){const i=e+1;return i===n&&o(),i}return e}return 0},Ok=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","irclid","_kx"],UBn=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Ok],hV="<masked>",KBn=["li_fat_id"];function Zst(t,e,n){if(!No)return{};const o=e?[...Ok,...n||[]]:[],i=eat(dV(No.URL,o,hV),t),r=(function(){const s={};return vl(KBn,function(a){const A=rV(a);s[a]=A||null}),s})();return jg(r,i)}function eat(t,e){const n=UBn.concat(e||[]),o={};return vl(n,function(i){const r=Hk(t,i);o[i]=r||null}),o}function tat(t){const e=(function(i){return i?i.search("https?://(.*)google.([^/?]*)")===0?"google":i.search("https?://(.*)bing.com")===0?"bing":i.search("https?://(.*)yahoo.com")===0?"yahoo":i.search("https?://(.*)duckduckgo.com")===0?"duckduckgo":null:null})(t),n=e!="yahoo"?"q":"p",o={};if(!ad(e)){o.$search_engine=e;const i=No?Hk(No.referrer,n):"";i.length&&(o.ph_keyword=i)}return o}function nat(){return navigator.language||navigator.userLanguage}function VBn(){const t=nat();return typeof t=="string"?t.split("-")[0]:void 0}const ane="$direct";function oat(){return No?.referrer||ane}function iat(t,e,n=!1){const o=t?[...Ok,...e||[]]:[],i=n?AQ(sd?.href):sd?.href,r=i?.substring(0,1e3);return{r:oat().substring(0,1e3),u:r?dV(r,o,hV):void 0}}function rat(t,e=!1){var n;const{r:o,u:i}=t,r=e?AQ(i):i,s={$referrer:o,$referring_domain:o==null?void 0:o==ane?ane:(n=x8(o))===null||n===void 0?void 0:n.host};if(r){s.$current_url=r;const a=x8(r);s.$host=a?.host,s.$pathname=a?.pathname;const A=eat(r);jg(s,A)}if(o){const a=tat(o);jg(s,a)}return s}function sat(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function zBn(){try{return new Date().getTimezoneOffset()}catch{return}}const JBn={flags:dQ,surveys:ene},WBn=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Ane=t=>`${t}_cookie_identity_change_pending`,cne=t=>{let e="",n=0;for(const o of t){const i=encodeURIComponent(JSON.stringify(o).slice(1,-1)).length;if(n+i>1e3)break;e+=o,n+=i}return e},Um="main",E8=[k4,C8,NM,cQ,RM,dQ,eV,lQ],M2e=t=>E8.indexOf(t)!==-1,aat=[Pk,$K],Aat=t=>aat.indexOf(t)!==-1,hQ=(t,e)=>{try{return JSON.stringify(t)===JSON.stringify(e)}catch{return t===e}},Gk=t=>{if(!t)return{};const e=JSON.parse(t);return xA(e)?e:{}},cat=(t,e)=>{vl(t,(n,o)=>{const i=Kf(o);i&&i.exposure!=="event"||{}.hasOwnProperty.call(e,o)||delete t[o]})};var D2e=class{constructor(e,n,o=!0,i=!e.cookieless_mode){if(this.Jo={},this.Zo=!1,this.Ko=!1,this.Xo=!1,this.Yo=!1,this.ta=!1,this.ea=new Map,this.ia=!1,this.na=!1,this.sa=!1,this.ra=new Set,this.oa=new Set,this.Mr=e,this.aa=o,this.props={},this.la=void 0,this.ua=(r=>{let s="";return r.token&&(s=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),r.persistence_name?"ph_"+r.persistence_name:"ph_"+s+"_posthog"})(e),this.hi=e.disable_persistence||!!n,this.No=this.ha(e),this.Xo=this.ca(e),this.load(i),this.da(),e.debug&&gi.info("Persistence loaded",e.persistence,sn({},this.props)),this.update_config(e,e,n),this.save(),Fn){const r=()=>this.flush();jc(Fn,"beforeunload",r,{capture:!1}),jc(Fn,"pagehide",r,{capture:!1}),this.va=s=>{if(this.Zo&&(!s.storageArea||s.storageArea===Fn?.localStorage)&&s.key)if(s.key!==this.ua){if(this.Xo){const a=uV.find(A=>s.key===this.fa(A));a&&this.pa(s.key,a)}}else this.pa(s.key,Um)},jc(Fn,"storage",this.va)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([n,o])=>{const i=this.ea.get(n);if(!M2e(n)||i===!0)return;if(o===!0)return void this.ga(n,!0);const r=new Set(i||[]);o.forEach(s=>r.add(s)),r.size&&this.ga(n,r)})}onCrossTabFeatureFlagChange(e){return this.oa.add(e),()=>this.oa.delete(e)}destroy(){this.va&&Fn&&(Fn.removeEventListener("storage",this.va),this.va=void 0),this.oa.clear()}pa(e,n,o=!0){if(this.hi)return!1;let i,r;try{if(r=uc.Ot(e),ad(r)){const A=this.ma(n);return A.storageValue=null,n!==Um&&(A.persisted=!1),!1}i=Gk(r)}catch{return!1}const s=n===Um?i:uc.Lt(this.ua);if(s&&this.ya(s))return!1;const a=this.ba(i,n,o);return n===Um&&this.Xo&&!hQ(this._a().main,i)||this.wa(i,n,!0,r),a}ya(e){const n=this.props[T4],o=e[T4];return!Eo(n)&&!Eo(o)&&n!==o}wa(e,n,o,i){const r=this.ma(n);r.storageValue=i,n!==Um&&(r.persisted=o);try{r.fingerprint=this.ka(e,n)}catch{r.fingerprint=void 0}}ba(e,n,o){let i=!1;return E8.forEach(r=>{var s;const a=(s=Kf(r))===null||s===void 0?void 0:s.storageGroup;if(n===Um&&this.Xo&&a||n!==Um&&a!==n)return;const A=r in e,c=this.Sa(r,A?e[r]:void 0),l=this.ea.has(r)?r in this.props:A;l===r in this.props&&hQ(c,this.props[r])||(l?this.xa(r,c,!1):this.$a(r,!1),i=!0)}),i&&o&&this.oa.forEach(r=>r()),i}Ca(){if(!this.Zo)return!1;try{this.sa=!1;const e=uc.Ot(this.ua),n=this.ma(Um);let o,i=!1,r=!1;if(e!==n.storageValue)if(ad(e))n.storageValue=null;else{if(o=Gk(e),this.sa=!this.na&&this.ya(o),this.sa)return!1;r=this.ba(o,Um,!1),!this.Xo||hQ(this._a().main,o)?this.wa(o,Um,!0,e):n.storageValue=e,i=!0}return this.Xo&&uV.forEach(s=>{const a=uc.Ot(this.fa(s)),A=this.ma(s),c=o||{},l=i&&E8.some(u=>{var h;return((h=Kf(u))===null||h===void 0?void 0:h.storageGroup)===s&&u in c});if(a===A.storageValue&&!l)return;if(ad(a))return A.storageValue=null,A.persisted=!1,void(l&&(r=this.ba(c,s,!1)||r));const g=Gk(a);r=this.ba(g,s,!1)||r,this.wa(g,s,!0,a)}),r}catch{return!1}}ga(e,n){this.ea.set(e,n);const o=Kf(e);o?.volatile||(this.ma((this.Xo?o?.storageGroup:void 0)||Um).fingerprint=void 0,this.Ta(e))}Ia(){E8.forEach(e=>this.ea.set(e,!0))}da(){if(this.Zo)try{const e=uc.Ot(this.ua),n=Gk(e);this.ma(Um).storageValue=e,E8.forEach(o=>{var i;const r=this.Xo?(i=Kf(o))===null||i===void 0?void 0:i.storageGroup:void 0,s=r?uc.Ot(this.fa(r)):null;if(r){const A=this.ma(r);A.storageValue=s,A.persisted=!ad(s)}const a=r&&!ad(s)?Gk(s):n;o in this.props?this.Ma(o,a[o],this.props[o]):o in a&&this.ga(o,!0)})}catch{}}Sa(e,n){const o=this.ea.get(e);if(!o)return n;if(o===!0)return this.props[e];if(e==="$active_feature_flags"){const s=new Set(As(n)?n:[]),a=new Set(As(this.props[e])?this.props[e]:[]);return o.forEach(A=>a.has(A)?s.add(A):s.delete(A)),Array.from(s)}const i=xA(n)?sn({},n):{},r=xA(this.props[e])?this.props[e]:{};return o.forEach(s=>{s in r?i[s]=r[s]:delete i[s]}),i}Ma(e,n,o){if(!M2e(e))return;const i=this.ea.get(e);if(i===!0)return;let r=n;if(this.Zo)try{var s;const A=this.Xo?(s=Kf(e))===null||s===void 0?void 0:s.storageGroup:void 0,c=A?this.fa(A):this.ua;r=Gk(uc.Ot(c))[e]}catch{}const a=new Set(i||[]);if(e==="$active_feature_flags"){if(!Eo(n)&&!As(n)||!Eo(r)&&!As(r)||!As(o))return void this.ga(e,!0);const A=new Set(n||[]),c=new Set(r||[]),l=new Set(o);new Set([...A,...l]).forEach(g=>{A.has(g)!==l.has(g)&&a.add(g)}),a.forEach(g=>{c.has(g)===l.has(g)&&a.delete(g)})}else{if(!xA(o))return void(hQ(r,o)?this.ea.delete(e):this.ga(e,!0));{if(!Eo(n)&&!xA(n)||Eo(n)&&ox(o)&&Eo(r))return void this.ga(e,!0);const A=xA(n)?n:{},c=xA(r)?r:{};new Set([...Object.keys(A),...Object.keys(o)]).forEach(l=>{l in A==l in o&&hQ(A[l],o[l])||a.add(l)}),a.forEach(l=>{l in c==l in o&&hQ(c[l],o[l])&&a.delete(l)})}}a.size?this.ga(e,a):this.ea.delete(e)}Ea(){var e;const n=(e=this.Mr)===null||e===void 0?void 0:e.persistence_save_debounce_ms;return qd(n)&&n>0?n:0}Pa(e){if(this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie")if(e)try{const n=y2e(e,this.Mr.cookie_persisted_properties||[]),o=Sst(n,this.Mr.cookie_persisted_properties||[]),i=JSON.stringify(n)+"|"+JSON.stringify(o),r=cd.Ot(this.ua)||void 0;r&&x2e(this.ua,r)===i&&(this.Ra=i,this.Aa=r)}catch{}else try{const n=cd.Ot(this.ua)||void 0;this.Ra=n?x2e(this.ua,n):void 0,this.Aa=n}catch{}}syncCookieProperties(){return this.Oa(this.Mr)}Oa(e,n=!1){if(this.hi&&!n||this.ta||!e.cookieWinsOnConflict||e.persistence.toLowerCase()!=="localstorage+cookie")return!1;let o;try{o=cd.Ot(this.ua)||void 0}catch{}if(!o||o===this.Aa)return!1;const i=x2e(this.ua,o);let r;try{r=C2e(JSON.parse(o))}catch{return!1}if((cd.Ot(this.ua)||void 0)!==o)return!1;this.Ra=i,this.Aa=o;const s=Qst(this.ua,o),a=[...kM,...s.properties],A={};if(Object.keys(r).forEach(m=>{const _=r[m];(Eo(_)||ad(_)||_===""||m==="$user_state"&&_!=="anonymous"&&_!=="identified")&&(A[m]=!0,delete r[m])}),ox(r))return!1;const c="distinct_id"in r||r.$user_state==="anonymous"||r.$user_state==="identified",l=this.props,g=l[T4],u=l[my],h=jg({},l);[...kM,...e.cookie_persisted_properties||[]].forEach(m=>{if(a.indexOf(m)!==-1&&!(m in r)&&!A[m]&&(c||m!=="distinct_id"&&m!=="$user_state")){const _=h[m];(s.isValid||kM.indexOf(m)===-1||_!==!1&&_!==0)&&delete h[m]}}),this.props=jg(h,r),E8.forEach(m=>{const _=m in this.props;m in l===_&&hQ(l[m],this.props[m])||(_?this.Ma(m,l[m],this.props[m]):this.ga(m,!0))}),!c||"$user_state"in r||"$user_state"in this.props||this.xa(my,y8);const d=this.props[T4],p=this.props[my];return!c||d===g&&p===u||(this.na=!0,this.Yo=!0,Z0.$t(Ane(this.ua),!0),this.$a(lQ),this.$a(C8),this.$a(k4),this.$a(NM),this.$a(cQ),this.$a(RM),this.$a(dQ),this.$a(oV),this.$a(uQ),p!=="anonymous"||u!=="identified"&&r.$user_state!=="anonymous"&&(Eo(g)||d===g)||(cat(this.props,r),this.$a(gQ)),p==="identified"?this.props.$user_id=d:delete this.props.$user_id,this.$a(Zte)),!0}consumeCookieIdentityChange(){const e=Ane(this.ua),n=this.Yo||!!Z0.Ot(e);return this.Yo=!1,n&&Z0.Pt(e),n}Fa(e=!1){return!(this.ta||this.hi&&!e||!this.Mr.cookieWinsOnConflict||this.Mr.persistence.toLowerCase()!=="localstorage+cookie"||(this.ta=!0,0))}Da(){this.ta&&(Eo(this.La)||(clearTimeout(this.La),this.La=void 0),delete this.Jo[Um],this.Na(!0))}qa(e=!0){if(this.ta)try{e?this.Da():Eo(this.La)||(clearTimeout(this.La),this.La=void 0)}finally{this.ta=!1}}isDisabled(){return!!this.hi}ha(e){WBn.indexOf(e.persistence.toLowerCase())===-1&&(gi.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");const n=((a=[],A=!1,c=()=>!1)=>{const l=[...kM,...a];return sn(sn({},uc),{},{Lt(g){try{let h,d={};try{h=cd.Ot(g)||void 0,d=h?C2e(JSON.parse(h)):{}}catch{}const p=JSON.parse(uc.Ot(g)||"{}");let m;if(A){const _=Qst(g,h),f=[...kM,..._.properties],I={};Object.keys(d).forEach(y=>{const x=d[y];ad(x)||x===""||y==="$user_state"&&x!=="anonymous"&&x!=="identified"||(I[y]=x)});const C="distinct_id"in I||I.$user_state==="anonymous"||I.$user_state==="identified";if(Object.keys(I).length>0){var u;const y=p[T4],x=(u=p.$user_state)!==null&&u!==void 0?u:y8;l.forEach(E=>{if(f.indexOf(E)!==-1&&!(E in d)&&(C||E!=="distinct_id"&&E!=="$user_state")){const B=p[E];(_.isValid||kM.indexOf(E)===-1||B!==!1&&B!==0)&&delete p[E]}}),!C||"$user_state"in d||"$user_state"in p||(p[my]=y8),!C||("distinct_id"in I?I[T4]:p[T4])===y&&("$user_state"in I?I[my]:p[my])===x||(I2e.forEach(E=>delete p[E]),I.$user_state==="identified"&&"distinct_id"in I?p.$user_id=I[T4]:delete p.$user_id,I.$user_state!=="identified"&&(delete p[nst],delete p[gQ]),delete p.__alias)}m=jg(p,I)}else m=jg(d,p);return c()||uc.$t(g,m),m}catch{}return null},$t(g,u,h,d,p,m){const _=uc.$t(g,u,void 0,void 0,m);try{const f=y2e(u,a);if(Object.keys(f).length){if(A){const I=ine(g),C=Sst(f,a);if(cd.$t(I,C,h,d,p,m),cd.Ot(I)!==JSON.stringify(C)){cd.Pt(I,d);const y=y2e(u);return cd.$t(g,y,h,d,p,m),_}}cd.$t(g,f,h,d,p,m)}}catch(f){uc.Dt(f)}return _},Pt(g,u){try{Fn?.localStorage.removeItem(g),cd.Pt(g,u),cd.Pt(ine(g),u)}catch(h){uc.Dt(h)}}})})(e.cookie_persisted_properties||[],e.cookieWinsOnConflict,()=>!!this.hi);let o,i=!1,r=!1;const s=e.persistence.toLowerCase();return s==="localstorage"&&uc.Et()?(o=uc,r=!0):s==="localstorage+cookie"&&n.Et()?(o=n,r=!0,i=!0):s==="sessionstorage"&&Z0.Et()?o=Z0:s==="memory"?o=E2e:s==="cookie"&&cd.Et()?(o=cd,i=!0):n.Et()?(o=n,r=!0,i=!0):cd.Et()?(o=cd,i=!0):o=E2e,this.Zo=r,this.Ko=i,o}fa(e){return`${this.ua}__${e}`}ca(e){return this.Zo&&!!e.split_storage}properties(){const e={};return vl(this.props,(n,o)=>{const i=Kf(o);if(!i||i.exposure==="event"){var r;if(!(i==null||(r=i.shouldSkipFromEventProperties)===null||r===void 0)&&r.call(i,n))return;e[o]=n}}),e}load(e=!1){if(this.hi&&!e)return;const n=this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie",o=n?uc.Lt(this.ua):null;let i={};if(n)try{i=C2e(cd.Lt(this.ua)),vl(i,(A,c)=>{(Eo(A)||ad(A)||A==="")&&delete i[c]})}catch{}const r=this.No.Lt(this.ua);if(r&&(this.props=jg({},r)),this.Xo&&this.ja(),n&&r){var s,a;const A=o?.[T4],c=(s=o?.$user_state)!==null&&s!==void 0?s:y8,l=r[T4],g=(a=r.$user_state)!==null&&a!==void 0?a:y8;if(l!==A||g!==c){this.Yo=!0,this.hi||Z0.$t(Ane(this.ua),!0);const u=jg({},this.props);I2e.forEach(d=>delete u[d]),g!=="anonymous"||c!=="identified"&&i.$user_state!=="anonymous"&&(Eo(A)||l===A)||(cat(u,i),delete u[gQ]),this.props=u;const h=new Set;I2e.forEach(d=>{var p;const m=(p=Kf(d))===null||p===void 0?void 0:p.storageGroup;m&&h.add(m)}),h.forEach(d=>{if(this.hi)return;const p={};vl(this.props,(m,_)=>{var f;((f=Kf(_))===null||f===void 0?void 0:f.storageGroup)===d&&(p[_]=m)}),ox(p)?(uc.Pt(this.fa(d)),this.Jo[d]={}):uc.$t(this.fa(d),p)&&(this.Jo[d]={persisted:!0,fingerprint:this.ka(p,d)})})}}Z0.Ot(Ane(this.ua))&&(this.Yo=!0)}ja(){for(const e of uV){const n=uc.Lt(this.fa(e));if(n&&!ox(n)){const o=this.ma(e);o.persisted=!0,this.Ba(e)||(o.fingerprint=this.ka(n,e)),this.Ha(e,n)||jg(this.props,n)}}}Ba(e){return Object.keys(this.props).some(n=>{var o;return((o=Kf(n))===null||o===void 0?void 0:o.storageGroup)===e})}Ha(e,n){const o=JBn[e];if(!o)return!1;const i=n[o],r=this.props[o];return qd(i)&&qd(r)&&r>i}refreshKey(e){var n;if(this.hi||this.ra.has(e))return;const o=this.Xo?(n=Kf(e))===null||n===void 0?void 0:n.storageGroup:void 0,i=o?uc.Lt(this.fa(o)):this.No.Lt(this.ua);if(i&&e in i)this.xa(e,i[e],!1);else{if(o){const r=this.No.Lt(this.ua);if(r&&e in r)return void this.xa(e,r[e],!1)}this.$a(e,!1)}}save(){if(this.hi)return;const e=this.Ea();e>0?Eo(this.La)&&(this.La=setTimeout(()=>{this.La=void 0,this.Na()},e)):this.Na()}flush(){Eo(this.La)||(clearTimeout(this.La),this.La=void 0,this.Na())}Na(e=!1){if(this.hi||this.ta&&!e)return;e||(this.syncCookieProperties(),this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie"||aat.forEach(r=>this.refreshKey(r)));const n=!e&&!this.ia;n||(this.sa=!1);const o=!!n&&this.Ca();if(this.sa)return void(this.Mr.debug&&gi.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this.Xo)return this.za(),void(o&&this.oa.forEach(r=>r()));const i=this.Ua(this.No,this.ua,this.props,Um);i==="written"&&this.Pa(this.props),i!=="failed"&&(this.ea.clear(),this.na=!1,this.ra.clear()),o&&this.oa.forEach(r=>r())}za(){const{main:e,groups:n}=this._a(),o=this.Ua(this.No,this.ua,e,Um);o==="written"&&this.Pa(e),o!=="failed"&&(this.na=!1,this.ra.clear(),E8.forEach(r=>{var s;!((s=Kf(r))===null||s===void 0)&&s.storageGroup||this.ea.delete(r)}));for(const r of uV){var i;const s=n[r];if(ox(s)&&!(!((i=this.Jo[r])===null||i===void 0)&&i.persisted)){E8.forEach(A=>{var c;((c=Kf(A))===null||c===void 0?void 0:c.storageGroup)===r&&this.ea.delete(A)});continue}const a=this.Ua(uc,this.fa(r),s,r);a!=="failed"&&E8.forEach(A=>{const c=Kf(A);c?.storageGroup!==r||a!=="written"&&c.volatile||this.ea.delete(A)})}}_a(){const e={},n={flags:{},surveys:{}};return vl(this.props,(o,i)=>{var r;const s=(r=Kf(i))===null||r===void 0?void 0:r.storageGroup;s?n[s][i]=o:e[i]=o}),{main:e,groups:n}}ka(e,n){if(n===Um)return JSON.stringify(e)+"|"+this.Wa+"|"+this.Va+"|"+this.Ga;const o={};return vl(e,(i,r)=>{var s;o[r]=!((s=Kf(r))===null||s===void 0)&&s.volatile?"__volatile__":i}),JSON.stringify(o)}Ua(e,n,o,i){const r=this.ma(i);if(i!==Um&&!r.dirty&&!Eo(r.fingerprint))return"skipped";let s;try{if(s=this.ka(o,i),s===r.fingerprint)return r.dirty=!1,"skipped"}catch{s=void 0}return e.$t(n,o,this.Wa,this.Va,this.Ga,this.Mr.debug)?(r.dirty=!1,i!==Um&&(r.persisted=!0),Eo(s)||(r.fingerprint=s),this.Zo&&(r.storageValue=uc.Ot(n)),"written"):(this.Mr.debug&&gi.warn(`failed to persist storage entry "${n}"; will retry on next save`),"failed")}remove({keepGroupEntries:e=!1}={}){if(this.Ia(),Eo(this.La)||(clearTimeout(this.La),this.La=void 0),this.No.Pt(this.ua,!1),this.No.Pt(this.ua,!0),!e&&this.aa)for(const n of uV)uc.Pt(this.fa(n));e?delete this.Jo[Um]:this.Jo={},this.Ra=void 0,this.Aa=void 0}clear(){this.remove(),this.props={}}register_once(e,n,o){if(xA(e)){this.syncCookieProperties(),Eo(n)&&(n="None"),this.Wa=Eo(o)?this.Qa:o;let i=!1;if(vl(e,(r,s)=>{this.props.hasOwnProperty(s)&&this.props[s]!==n||(this.xa(s,r),i=!0)}),i)return this.save(),!0}return!1}register(e,n){if(xA(e)){this.syncCookieProperties(),this.Wa=Eo(n)?this.Qa:n;let o=!1;if(vl(e,(i,r)=>{e.hasOwnProperty(r)&&(this.props[r]!==i||xA(i)||As(i))&&(this.xa(r,i),o=!0)}),o)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();const n=typeof e=="string"?[e]:e;let o=!1;for(const i of n)i in this.props&&(this.$a(i),o=!0);o&&this.save()}update_campaign_params(){const e=No?.URL;if(e===this.la)return;const n=Zst(this.Mr.custom_campaign_params,this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties),o=!ox(m2e(n));return o&&this.register(n),this.la=e,o?n:void 0}update_search_keyword(){this.register((function(){const e=No?.referrer;return e?tat(e):{}})())}update_referrer_info(){var e;this.register_once({$referrer:oat(),$referring_domain:No?.referrer&&((e=x8(No.referrer))===null||e===void 0?void 0:e.host)||ane},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const e=iat(this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties,this.Mr.disable_capture_url_hashes);this.register_once({[Dk]:this.Ko?{r:cne(e.r),u:e.u?cne(e.u):void 0}:e},void 0)}get_initial_props(){const e={};vl([ast,sst],o=>{const i=this.props[o];i&&vl(i,function(r,s){e["$initial_"+Pye(s)]=r})});const n=this.props[Dk];if(n){const o=(function(i,r=!1){const s=rat(i,r),a={};return vl(s,function(A,c){a[`$initial_${Pye(c)}`]=A}),a})(n,this.Mr.disable_capture_url_hashes);jg(e,o)}return e}safe_merge(e){return vl(this.props,function(n,o){o in e||(e[o]=n)}),e}update_config(e,n,o){const i=e.persistence!==n.persistence,r=!((d,p)=>{if(d.length!==p.length)return!1;const m=[...d].sort(),_=[...p].sort();return m.every((f,I)=>f===_[I])})(e.cookie_persisted_properties||[],n.cookie_persisted_properties||[]),s=i||r,a=e.cookieWinsOnConflict!==n.cookieWinsOnConflict,A=e.disable_persistence||!!o,c=!!this.hi&&!A;A||this.Oa(n,c),this.Mr=e,!A&&(i||r||a)&&(this.Ra=void 0,this.Aa=void 0,this.Oa(sn(sn({},e),{},{cookie_persisted_properties:n.cookie_persisted_properties}),c));const l=s||a?this.ha(e):this.No;this.Ja();const g=this.ca(e),u=s||g!==this.Xo,h=!A&&(u||e.cross_subdomain_cookie!==this.Va||e.secure_cookie!==this.Ga)&&this.Fa(c);this.ia=u;try{if(this.Qa=this.Wa=e.cookie_expiration,this.set_disabled(A),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),u){const d=this.props;this.clear(),this.No=l,this.Xo=g,this.props=d,this.save()}else a&&(this.No=l,A||(delete this.Jo[Um],this.Na()))}finally{this.ia=!1,h&&this.qa()}}Ja(){const e=this.props[Dk];if(!this.Ko||!xA(e)||typeof e.r!="string")return;const n=cne(e.r),o=typeof e.u=="string"?cne(e.u):e.u;n===e.r&&o===e.u||this.xa(Dk,sn(sn({},e),{},{r:n,u:o}))}set_disabled(e){this.hi=e,this.hi?this.remove():this.save()}set_cross_subdomain(e){e!==this.Va&&(this.Va=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this.Ga&&(this.Ga=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,n){const o=this.props.__timers||{};o[e]=n,this.xa(e2e,o),this.save()}remove_event_timer(e){const n=this.props.__timers||{},o=n[e];return Eo(o)||(delete n[e],this.xa(e2e,n),this.save()),o}get_property(e){return this.props[e]}set_property(e,n){this.xa(e,n),this.save()}xa(e,n,o=!0){var i;const r=this.props[e];this.props[e]=n,o&&(e!=="distinct_id"&&e!=="$user_state"||r===n||(this.na=!0),Aat(e)&&!hQ(r,n)&&this.ra.add(e),this.Ma(e,r,n),!((i=Kf(e))===null||i===void 0)&&i.volatile||this.Ta(e))}$a(e,n=!0){delete this.props[e],n&&(M2e(e)&&this.ga(e,!0),Aat(e)&&this.ra.add(e),this.Ta(e))}Ta(e){var n;const o=(n=Kf(e))===null||n===void 0?void 0:n.storageGroup;o&&(this.ma(o).dirty=!0)}ma(e){return this.Jo[e]||(this.Jo[e]={})}};const N3={GZipJS:"gzip-js",Base64:"base64"},pV={Activation:"events",Cancellation:"cancelEvents"},N2e={Popover:"popover",API:"api",Widget:"widget"},R3={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},R2e={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},T2e={Popover:"popover",Inline:"inline"};function lne(t){let e=!0;return{dispose(){if(e){e=!1;const n=t();n&&L_(n.then)&&n.then(void 0,()=>{})}}}}const jBn={SHOWN:"product tour shown"},lat={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},gat=Ad("[RateLimiter]");var XBn=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=n=>{const o=n.text;if(o&&o.length)try{(JSON.parse(o).quota_limited||[]).forEach(i=>{gat.info(`${i||"events"} is quota limited.`),this.serverLimits[i]=new Date().getTime()+6e4})}catch(i){return void gat.warn(`could not rate limit - continuing. Error: "${i?.message}"`,{text:o})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)===null||e===void 0?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)===null||e===void 0?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e=!1){var n,o,i;const{captureEventsBurstLimit:r,captureEventsPerSecond:s}=this,a=new Date().getTime(),A=(n=(o=this.instance.persistence)===null||o===void 0?void 0:o.get_property("$capture_rate_limit"))!==null&&n!==void 0?n:{tokens:r,last:a};A.tokens+=(a-A.last)/1e3*s,A.last=a,A.tokens>r&&(A.tokens=r);const c=1>A.tokens;if(c||e||(A.tokens=Math.max(0,A.tokens-1)),c&&!e){const l=(qd(A.dropped)?A.dropped:0)+1;A.dropped=l,!this.lastEventRateLimited&&this.Za(l)&&(A.dropped=0)}return this.lastEventRateLimited=c,(i=this.instance.persistence)===null||i===void 0||i.set_property("$capture_rate_limit",A),{isRateLimited:c,remainingTokens:A.tokens}}Ka(e){const n=this.instance.config.property_denylist;return!As(n)||!n.includes(e)}Xa(){var e;if(this.Ka("$current_url")&&this.Ka("$pathname")&&sd?.pathname)return`${(e=sd.origin)!==null&&e!==void 0?e:""}${sd.pathname}`}Za(e){var n,o;const{captureEventsBurstLimit:i,captureEventsPerSecond:r}=this,s=this.Xa(),a=this.Ka("$session_id")?(n=(o=this.instance).get_session_id)===null||n===void 0?void 0:n.call(o):void 0,A=[`${e} event(s) dropped since the last warning`,s?`triggered on ${s}`:void 0,a?`session ${a}`:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:`posthog-js client rate limited: ${A}. Config is set to ${r} events per second and ${i} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(e){const n=this.serverLimits[e||"events"]||!1;return n!==!1&&new Date().getTime()<n}};const pQ=Ad("[RemoteConfig]");var uat=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=Ur._POSTHOG_REMOTE_CONFIG)===null||e===void 0||(e=e[this._instance.config.token])===null||e===void 0?void 0:e.config}Ya(e){var n,o,i;!((n=Ur.__PosthogExtensions__)===null||n===void 0)&&n.loadExternalDependency?(o=Ur.__PosthogExtensions__)===null||o===void 0||(i=o.loadExternalDependency)===null||i===void 0||i.call(o,this._instance,"remote-config",()=>e(this.remoteConfig)):e()}tl(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets",`/array/${this._instance.config.token}/config`),callback:e})}load(){try{if(this.remoteConfig)return pQ.info("Using preloaded remote config",this.remoteConfig),void this.el(this.remoteConfig);if(this._instance.il())return void pQ.warn("Remote config is disabled. Falling back to local config.");this.Ya(e=>{if(!e)return pQ.info("No config found after loading remote JS config. Falling back to JSON."),void this.tl(n=>{this.el(n.json,n)});this.el(e)})}catch(e){pQ.error("Error loading remote config",e),this.el()}}el(e,n){!e&&n&&(n.statusCode===0?n.error||pQ.warn("Failed to fetch remote config from PostHog."):pQ.error("Failed to fetch remote config from PostHog."));try{this._instance.el(e?{ok:!0,config:e}:{ok:!1})}catch(i){pQ.error("Error applying remote config",i)}if(e?.hasFeatureFlags!==!1&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var o;(o=this._instance.featureFlags)===null||o===void 0||o.ensureFlagsLoaded()}catch(i){pQ.error("Error loading feature flags",i)}}},m5=Uint8Array,ix=Uint16Array,Yk=Uint32Array,k2e=new m5([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]),F2e=new m5([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]),dat=new m5([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),hat=function(t,e){for(var n=new ix(31),o=0;31>o;++o)n[o]=e+=1<<t[o-1];var i=new Yk(n[30]);for(o=1;30>o;++o)for(var r=n[o];n[o+1]>r;++r)i[r]=r-n[o]<<5|o;return[n,i]},pat=hat(k2e,2),L2e=pat[1];pat[0][28]=258,L2e[258]=28;for(var mat=hat(F2e,0)[1],_at=new ix(32768),ld=0;32768>ld;++ld){var Uk=(43690&ld)>>>1|(21845&ld)<<1;_at[ld]=((65280&(Uk=(61680&(Uk=(52428&Uk)>>>2|(13107&Uk)<<2))>>>4|(3855&Uk)<<4))>>>8|(255&Uk)<<8)>>>1}var mV=function(t,e,n){for(var o=t.length,i=0,r=new ix(e);o>i;++i)++r[t[i]-1];var s,a=new ix(e);for(i=0;e>i;++i)a[i]=a[i-1]+r[i-1]<<1;for(s=new ix(o),i=0;o>i;++i)s[i]=_at[a[t[i]-1]++]>>>15-t[i];return s},LM=new m5(288);for(ld=0;144>ld;++ld)LM[ld]=8;for(ld=144;256>ld;++ld)LM[ld]=9;for(ld=256;280>ld;++ld)LM[ld]=7;for(ld=280;288>ld;++ld)LM[ld]=8;var gne=new m5(32);for(ld=0;32>ld;++ld)gne[ld]=5;var qBn=mV(LM,9),$Bn=mV(gne,5),fat=function(t){return(t/8|0)+(7&t&&1)},Iat=function(t,e,n){(n==null||n>t.length)&&(n=t.length);var o=new(t instanceof ix?ix:t instanceof Yk?Yk:m5)(n-e);return o.set(t.subarray(e,n)),o},B8=function(t,e,n){var o=e/8|0;t[o]|=n<<=7&e,t[o+1]|=n>>>8},_V=function(t,e,n){var o=e/8|0;t[o]|=n<<=7&e,t[o+1]|=n>>>8,t[o+2]|=n>>>16},H2e=function(t,e){for(var n=[],o=0;t.length>o;++o)t[o]&&n.push({s:o,f:t[o]});var i=n.length,r=n.slice();if(!i)return[new m5(0),0];if(i==1){var s=new m5(n[0].s+1);return s[n[0].s]=1,[s,1]}n.sort(function(y,x){return y.f-x.f}),n.push({s:-1,f:25001});var a=n[0],A=n[1],c=0,l=1,g=2;for(n[0]={s:-1,f:a.f+A.f,l:a,r:A};l!=i-1;)a=n[n[g].f>n[c].f?c++:g++],A=n[c!=l&&n[g].f>n[c].f?c++:g++],n[l++]={s:-1,f:a.f+A.f,l:a,r:A};var u=r[0].s;for(o=1;i>o;++o)r[o].s>u&&(u=r[o].s);var h=new ix(u+1),d=O2e(n[l-1],h,0);if(d>e){o=0;var p=0,m=d-e,_=1<<m;for(r.sort(function(y,x){return h[x.s]-h[y.s]||y.f-x.f});i>o;++o){var f=r[o].s;if(e>=h[f])break;p+=_-(1<<d-h[f]),h[f]=e}for(p>>>=m;p>0;){var I=r[o].s;e>h[I]?p-=1<<e-h[I]++-1:++o}for(;o>=0&&p;--o){var C=r[o].s;h[C]==e&&(--h[C],++p)}d=e}return[new m5(h),d]},O2e=function(t,e,n){return t.s==-1?Math.max(O2e(t.l,e,n+1),O2e(t.r,e,n+1)):e[t.s]=n},Cat=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new ix(++e),o=0,i=t[0],r=1,s=function(A){n[o++]=A},a=1;e>=a;++a)if(t[a]==i&&a!=e)++r;else{if(!i&&r>2){for(;r>138;r-=138)s(32754);r>2&&(s(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(s(i),--r;r>6;r-=6)s(8304);r>2&&(s(r-3<<5|8208),r=0)}for(;r--;)s(i);r=1,i=t[a]}return[n.subarray(0,o),e]},fV=function(t,e){for(var n=0,o=0;e.length>o;++o)n+=t[o]*e[o];return n},G2e=function(t,e,n){var o=n.length,i=fat(e+2);t[i]=255&o,t[i+1]=o>>>8,t[i+2]=255^t[i],t[i+3]=255^t[i+1];for(var r=0;o>r;++r)t[i+r+4]=n[r];return 8*(i+4+o)},yat=function(t,e,n,o,i,r,s,a,A,c,l){B8(e,l++,n),++i[256];for(var g=H2e(i,15),u=g[0],h=g[1],d=H2e(r,15),p=d[0],m=d[1],_=Cat(u),f=_[0],I=_[1],C=Cat(p),y=C[0],x=C[1],E=new ix(19),B=0;f.length>B;++B)E[31&f[B]]++;for(B=0;y.length>B;++B)E[31&y[B]]++;for(var S=H2e(E,7),Q=S[0],w=S[1],M=19;M>4&&!Q[dat[M-1]];--M);var k,R,F,O,U=c+5<<3,Y=fV(i,LM)+fV(r,gne)+s,J=fV(i,u)+fV(r,p)+s+14+3*M+fV(E,Q)+(2*E[16]+3*E[17]+7*E[18]);if(Y>=U&&J>=U)return G2e(e,l,t.subarray(A,A+c));if(B8(e,l,1+(Y>J)),l+=2,Y>J){k=mV(u,h),R=u,F=mV(p,m),O=p;var ee=mV(Q,w);for(B8(e,l,I-257),B8(e,l+5,x-1),B8(e,l+10,M-4),l+=14,B=0;M>B;++B)B8(e,l+3*B,Q[dat[B]]);l+=3*M;for(var W=[f,y],X=0;2>X;++X){var oe=W[X];for(B=0;oe.length>B;++B)B8(e,l,ee[se=31&oe[B]]),l+=Q[se],se>15&&(B8(e,l,oe[B]>>>5&127),l+=oe[B]>>>12)}}else k=qBn,R=LM,F=$Bn,O=gne;for(B=0;a>B;++B)if(o[B]>255){var se;_V(e,l,k[257+(se=o[B]>>>18&31)]),l+=R[se+257],se>7&&(B8(e,l,o[B]>>>23&31),l+=k2e[se]);var ie=31&o[B];_V(e,l,F[ie]),l+=O[ie],ie>3&&(_V(e,l,o[B]>>>5&8191),l+=F2e[ie])}else _V(e,l,k[o[B]]),l+=R[o[B]];return _V(e,l,k[256]),l+R[256]},ZBn=new Yk([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),e9n=(function(){for(var t=new Yk(256),e=0;256>e;++e){for(var n=e,o=9;--o;)n=(1&n&&3988292384)^n>>>1;t[e]=n}return t})(),Y2e=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8};function t9n(t,e){e===void 0&&(e={});var n=(function(){var g=4294967295;return{p(u){for(var h=g,d=0;u.length>d;++d)h=e9n[255&h^u[d]]^h>>>8;g=h},d(){return 4294967295^g}}})(),o=t.length;n.p(t);var i,r,s,a,A,c=(a=10+((i=e).filename&&i.filename.length+1||0),A=8,(function(g,u,h,d,p,m){var _=g.length,f=new m5(d+_+5*(1+Math.floor(_/7e3))+p),I=f.subarray(d,f.length-p),C=0;if(!u||8>_)for(var y=0;_>=y;y+=65535){var x=y+65535;_>x?C=G2e(I,C,g.subarray(y,x)):(I[y]=m,C=G2e(I,C,g.subarray(y,_)))}else{for(var E=ZBn[u-1],B=E>>>13,S=8191&E,Q=(1<<h)-1,w=new ix(32768),M=new ix(Q+1),k=Math.ceil(h/3),R=2*k,F=function(Ce){return(g[Ce]^g[Ce+1]<<k^g[Ce+2]<<R)&Q},O=new Yk(25e3),U=new ix(288),Y=new ix(32),J=0,ee=0,W=(y=0,0),X=0,oe=0;_>y;++y){var se=F(y),ie=32767&y,ge=M[se];if(w[ie]=ge,M[se]=ie,y>=X){var ue=_-y;if((J>7e3||W>24576)&&ue>423){C=yat(g,I,0,O,U,Y,ee,W,oe,y-oe,C),W=J=ee=0,oe=y;for(var Ie=0;286>Ie;++Ie)U[Ie]=0;for(Ie=0;30>Ie;++Ie)Y[Ie]=0}var le=2,_e=0,me=S,ye=ie-ge&32767;if(ue>2&&se==F(y-ye))for(var Me=Math.min(B,ue)-1,we=Math.min(32767,y),he=Math.min(258,ue);we>=ye&&--me&&ie!=ge;){if(g[y+le]==g[y+le-ye]){for(var Qe=0;he>Qe&&g[y+Qe]==g[y+Qe-ye];++Qe);if(Qe>le){if(le=Qe,_e=ye,Qe>Me)break;var ve=Math.min(ye,Qe-2),Pe=0;for(Ie=0;ve>Ie;++Ie){var Fe=y-ye+Ie+32768&32767,Re=Fe-w[Fe]+32768&32767;Re>Pe&&(Pe=Re,ge=Fe)}}}ye+=(ie=ge)-(ge=w[ie])+32768&32767}if(_e){O[W++]=268435456|L2e[le]<<18|mat[_e];var Be=31&L2e[le],ke=31&mat[_e];ee+=k2e[Be]+F2e[ke],++U[257+Be],++Y[ke],X=y+le,++J}else O[W++]=g[y],++U[g[y]]}}C=yat(g,I,m,O,U,Y,ee,W,oe,y-oe,C)}return Iat(f,0,d+fat(C)+p)})(r=t,(s=e).level==null?6:s.level,s.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(r.length)))):12+s.mem,a,A,!0)),l=c.length;return(function(g,u){var h=u.filename;if(g[0]=31,g[1]=139,g[2]=8,g[8]=2>u.level?4:u.level==9?2:0,g[9]=3,u.mtime!=0&&Y2e(g,4,Math.floor(new Date(u.mtime||Date.now())/1e3)),h){g[3]=8;for(var d=0;h.length>=d;++d)g[d+10]=h.charCodeAt(d)}})(c,e),Y2e(c,l-8,n.d()),Y2e(c,l-4,o),c}const n9n=!!vye||!!VK,xat=new WeakMap,Eat="text/plain";let U2e=0,une=!1;const Bat=(t,e)=>{const[n,o]=t.split("#"),[i,r]=n.split("?");if(!r)return t;const s=r.split("&").filter(a=>a.split("=")[0]!==e).join("&");return`${i}${s?`?${s}`:""}${o?`#${o}`:""}`},IV=(t,e,n=!0)=>{var o;const[i,r]=t.split("?"),s=sn({},e),a=(o=r?.split("&").map(c=>{var l;const[g,u]=c.split("="),h=n&&(l=s[g])!==null&&l!==void 0?l:u;return delete s[g],`${g}=${h}`}))!==null&&o!==void 0?o:[],A=(function(c,l="&"){let g,u;const h=[];return vl(c,function(d,p){Eo(d)||Eo(p)||p==="undefined"||(g=encodeURIComponent((m=>m instanceof File)(d)?d.name:d.toString()),u=encodeURIComponent(p),h[h.length]=u+"="+g)}),h.join(l)})(s);return A&&a.push(A),a.length>0?`${i}?${a.join("&")}`:i},K2e=t=>{if(t.nl)return t.nl;const{data:e,compression:n}=t;if(!e)return;if(n===N3.GZipJS){const i=t9n((function(r){var s=r.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(r);for(var a=new m5(r.length+(r.length>>>1)),A=0,c=function(h){a[A++]=h},l=0;s>l;++l){if(A+5>a.length){var g=new m5(A+8+(s-l<<1));g.set(a),a=g}var u=r.charCodeAt(l);128>u?c(u):2048>u?(c(192|u>>>6),c(128|63&u)):u>55295&&57344>u?(c(240|(u=65536+(1047552&u)|1023&r.charCodeAt(++l))>>>18),c(128|u>>>12&63),c(128|u>>>6&63),c(128|63&u)):(c(224|u>>>12),c(128|u>>>6&63),c(128|63&u))}return Iat(a,0,A)})(Lk(e)),{mtime:0});return{contentType:Eat,body:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),estimatedSize:i.byteLength}}if(n===N3.Base64){const i=(function(s){return s&&btoa(encodeURIComponent(s).replace(/%([0-9A-F]{2})/g,(a,A)=>String.fromCharCode(parseInt(A,16))))})(Lk(e)),r=(s=>"data="+encodeURIComponent(typeof s=="string"?s:Lk(s)))(i);return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}const o=Lk(e);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}},bat=t=>{const e=()=>t.transport==="sendBeacon"?{url:IV(t.url,{compression:N3.Base64}),encodedBody:K2e(sn(sn({},t),{},{compression:N3.Base64,nl:void 0}))}:{url:Bat(t.url,"compression"),encodedBody:K2e(sn(sn({},t),{},{compression:void 0,nl:void 0}))};let n;try{n=K2e(t)}catch(i){if(Mrt(t.compression,Hk(t.url,"compression")))return gi.error("Failed to gzip request body, sending uncompressed payload",i),e();throw i}return n&&Mrt(t.compression,Hk(t.url,"compression"))&&!((o=n.body)instanceof ArrayBuffer?Jye(new Uint8Array(o)):ArrayBuffer.isView(o)&&Jye(new Uint8Array(o.buffer,o.byteOffset,o.byteLength)))?(une=!0,e()):{url:t.url,encodedBody:n};var o},Sat=t=>{try{return bat(t)}catch(n){var e;return gi.error(n),void((e=t.callback)===null||e===void 0||e.call(t,{statusCode:0,error:n}))}},o9n=(function(){var t=Wg(function*(e){const n=yield(function(i){return Wye.apply(this,arguments)})(Lk(e.data),Ym.DEBUG,{rethrow:!0});if(!n)return e;const o=yield n.arrayBuffer();return sn(sn({},e),{},{nl:{contentType:Eat,body:o,estimatedSize:o.byteLength}})});return function(e){return t.apply(this,arguments)}})(),i9n=/Failed to fetch|NetworkError|Load failed/i,Qat=t=>t?.name==="TypeError"&&i9n.test(t?.message||""),vat=t=>{try{const e=(function(n,o=Date.now()){if(typeof n!="string"||!n)return;const i=n.trim(),r=/^\d+\s*,/.test(i)?i.slice(0,i.indexOf(",")).trim():i;if(/^\d+$/.test(r)){const A=1e3*Math.min(Number(r),300);return A>0?A:void 0}if(!/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(r))return;const s=/^\w{3} \w{3} /.test(r)?r+" GMT":r,a=Date.parse(s)-o;return Number.isFinite(a)&&a>0?Math.min(a,Vte):void 0})(t());return Eo(e)?void 0:Math.min(e,3e4)}catch{return}},wat=t=>{const e=Sat(t);if(!e)return;const n=new vye;xat.set(n,!0);const{url:o,encodedBody:i}=e;n.open(t.method||"GET",o,!0);const{contentType:r,body:s}=i??{};vl(t.headers,function(a,A){n.setRequestHeader(A,a)}),r&&n.setRequestHeader("Content-Type",r),t.timeout&&(n.timeout=t.timeout),n.onreadystatechange=()=>{if(n.readyState===4){var a;const A={statusCode:n.status,text:n.responseText};if(n.status===200)try{A.json=JSON.parse(n.responseText)}catch{}(a=t.callback)===null||a===void 0||a.call(t,A,vat(()=>n.getResponseHeader("Retry-After")))}},n.send(s)},Pat=t=>{const e=Sat(t);if(!e)return;const{url:n,encodedBody:o}=e,{contentType:i,body:r,estimatedSize:s}=o??{},a=new Headers;vl(t.headers,function(d,p){a.append(p,d)}),i&&a.append("Content-Type",i);let A=null,c=!1;if(Qit){const d=new Qit;A={signal:d.signal,timeout:setTimeout(()=>{c=!0;try{d.abort(prt("AbortError","PostHog request timed out"+((p=t.timeout)?` after ${p}ms`:"")))}catch(m){g(m)}var p},t.timeout)}}let l=!1;const g=d=>{var p;l||(l=!0,c&&d?.name==="AbortError"||Qat(d)?gi.warn(d):gi.error(d),(p=t.callback)===null||p===void 0||p.call(t,{statusCode:0,error:d}))};let u=0;const h=()=>{U2e-=u,u=0,A&&clearTimeout(A.timeout)};try{const d=sn({method:t?.method||"GET",headers:a,referrerPolicy:"strict-origin",body:r,signal:A?.signal},t.fetchOptions),p=s??(Eo(r)?0:void 0);d.keepalive=d.method==="POST"&&!t.sl&&d.keepalive!==!1&&d.body===r&&!Eo(p)&&p>=0&&52428.8>U2e+p,d.keepalive&&(u=p,U2e+=u),VK(n,d).then(m=>m.text().then(_=>{var f;if(l)return;const I={statusCode:m.status,text:_};if(m.status===200)try{I.json=JSON.parse(_)}catch(C){gi.error(C)}l=!0,h(),(f=t.callback)===null||f===void 0||f.call(t,I,vat(()=>m.headers.get("Retry-After")))})).catch(m=>{h(),g(m)}).finally(h)}catch(d){h(),g(d)}},V2e=t=>{try{var e;const{url:n,encodedBody:o}=bat(t),{contentType:i,body:r,estimatedSize:s}=o??{};if(!r)return;const a=r instanceof Blob?r:new Blob([r],{type:i});if(F_.sendBeacon(n,a))return;const A=As(t.data)?t.data:(e=t.data)===null||e===void 0?void 0:e.batch;if(As(A)&&A.length>1&&(s??0)>16384){const c=Math.ceil(A.length/2),l=g=>As(t.data)?g:sn(sn({},t.data),{},{batch:g});return V2e(sn(sn({},t),{},{data:l(A.slice(0,c))})),void V2e(sn(sn({},t),{},{data:l(A.slice(c))}))}gi.warn(`Beacon of ~${s??0} bytes was rejected by the browser, falling back to ${VK?"fetch":"XHR"}`),VK?Pat(sn(sn({},t),{},{sl:!0})):wat(t)}catch(n){gi.warn("Beacon send failed",n)}},Mat=(t,e,n,o)=>{const i=o==="query"?e==="POST"?"sent_at":"_":void 0;return IV(n===N3.GZipJS?Bat(t,"compression"):t,sn(sn({},i?{[i]:Date.now().toString()}:{}),n===N3.GZipJS?{}:{compression:n}))},r9n=(()=>{const t=[];return VK&&t.push({transport:"fetch",method:Pat}),vye&&t.push({transport:"XHR",method:wat}),F_?.sendBeacon&&t.push({transport:"sendBeacon",method:V2e}),t})();let Dat=!n9n&&hy?.indexOf("MSIE")===-1&&hy?.indexOf("Mozilla")===-1;function Nat(t,e,n){var o,i,r;n&&(e=sn(sn({},e),{},{callback:s=>n(s)})),t.__loaded?Dat?t.__request_queue.push(e):t.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&((i=e.callback)===null||i===void 0||i.call(e,{statusCode:429})):(e.transport=e.transport||t.config.api_transport,e.headers=sn(sn({},t.config.request_headers),e.headers),e.compression=e.compression==="best-available"?(o=t.compression)!==null&&o!==void 0?o:e.compressionFallback:e.compression,(Eo(t.config.disable_beacon)?t.config.__preview_disable_beacon:t.config.disable_beacon)&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||t.config.fetch_options,((s,a)=>{var A,c,l;const g=sn(sn({},s),{},{callback:a??(m=>{var _;return(_=s.callback)===null||_===void 0?void 0:_.call(s,m)})});g.timeout=g.timeout||6e4;const u=(A=g.transport)!==null&&A!==void 0?A:"fetch";u==="sendBeacon"&&Eo(g.compression)&&g.data&&(g.compression=N3.Base64),g.method==="POST"&&g.data&&(g.timestampMode==="capture-body"?g.data=(m=>{var _,f;const I=(As(m)?m:[m]).map(y=>sn(sn({},y),y.timestamp instanceof Date&&!isNaN(y.timestamp.getTime())?{timestamp:y.timestamp.toISOString()}:{})),C=I[0];return{api_key:(_=C==null||(f=C.properties)===null||f===void 0?void 0:f.token)!==null&&_!==void 0?_:C?.token,batch:I,sent_at:new Date().toISOString()}})(g.data):g.timestampMode==="body"&&(g.data=((m,_=new Date().toISOString())=>As(m)?m.map(f=>sn(sn({},f),{},{sent_at:_})):sn(sn({},m),{},{sent_at:_}))(g.data))),g.url=Mat(g.url,g.method,g.compression,g.timestampMode);const h=r9n.filter(m=>!g.disableTransport||!m.transport||!g.disableTransport.includes(m.transport)),d=(c=(l=(function(m,_){for(let f=0;m.length>f;f++)if(_(m[f]))return m[f]})(h,m=>m.transport===u))===null||l===void 0?void 0:l.method)!==null&&c!==void 0?c:h[0].method;if(!d)throw new Error("No available transport method");const p=m=>{try{d(m)}catch(f){var _;Qat(f)?gi.warn(f):gi.error(f),(_=g.callback)===null||_===void 0||_.call(g,{statusCode:0,error:f})}};u!=="sendBeacon"&&!g.preferSyncCompression&&g.data&&g.compression===N3.GZipJS&&j5n&&typeof Promise<"u"&&!une?o9n(g).then(m=>{p(m)}).catch(m=>{if(Drt(m))return une=!0,void p(sn(sn({},g),{},{compression:void 0,url:Mat(s.url,s.method,void 0,s.timestampMode)}));(_=>{if(!_||typeof _!="object")return!1;const f="name"in _?String(_.name):"";return Drt(_)||f===Prt})(m)&&(une=!0),p(g)}):p(g)})(e,(s,a)=>{var A,c,l;t.rateLimiter.checkForLimiting(s),400>s.statusCode||(A=(c=t.config).on_request_error)===null||A===void 0||A.call(c,s),n?n(s,a):(l=e.callback)===null||l===void 0||l.call(e,s)})):e.fireCallbackOnDrop&&((r=e.callback)===null||r===void 0||r.call(e,{statusCode:0}))}var s9n=class{constructor(e,n){this.rl=!0,this.ol=[],this.al=E9(n?.flush_interval_ms||3e3,250,5e3,gi.createLogger("flush interval"),3e3),this.ll=e}enqueue(e){this.ol.push(e),this.ul||this.hl()}unload(){this.cl();const e=this.ol.length>0?this.dl():{},n=Object.values(e);[...n.filter(o=>o.url.indexOf("/e")===0),...n.filter(o=>o.url.indexOf("/e")!==0)].map(o=>{this.vl(o,"sendBeacon")})}enable(){this.rl=!1,this.hl()}hl(){this.rl||(this.ul=setTimeout(()=>{if(this.cl(),this.ol.length>0){const e=this.dl();for(const n in e)this.vl(e[n])}},this.al))}vl(e,n){try{this.ll(e,n)}catch(o){gi.error(o)}}cl(){clearTimeout(this.ul),this.ul=void 0}dl(){const e={};return vl(this.ol,n=>{var o;const i=n,r=((i?i.batchKey:null)||i.url)+(i.batchGroup?`:${i.batchGroup}`:"");Eo(e[r])&&(e[r]=sn(sn({},i),{},{data:[]})),(o=e[r].data)===null||o===void 0||o.push(i.data)}),this.ol=[],e}};const a9n=["retriesPerformedSoFar"];var A9n=class{constructor(e){this._instance=e,this.fl=!1,this.pl=3e3,this.ol=[],this.ol=[],this.gl=!0,this.resume()}resume(){if(!Eo(Fn)&&"onLine"in Fn.navigator){if(this.gl=Fn.navigator.onLine,this.ml)return;this.ml=()=>{this.gl=!0,this.yl()},this.bl=()=>{this.gl=!1},jc(Fn,"online",this.ml),jc(Fn,"offline",this.bl)}}get length(){return this.ol.length}retriableRequest(e,n){let{retriesPerformedSoFar:o}=e,i=Rrt(e,a9n);I8(o)&&(i.url=IV(i.url,{retry_count:o})),Nat(this._instance,n?sn(sn({},i),{},{transport:n}):i,(r,s)=>{var a;if(r.statusCode!==200&&(400>r.statusCode||r.statusCode>=500)){if((r.statusCode===0?3:10)>(o??0))return void this.Ls(sn({retriesPerformedSoFar:o},i),s);r.statusCode===0&&gi.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after ${o??0} retries.`)}(a=i.callback)===null||a===void 0||a.call(i,r)})}Ls(e,n){const o=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=o+1;const i=Math.max((function(a){const A=3e3*Math.pow(2,a),c=A/2,l=Math.min(18e5,A),g=(Math.random()-.5)*(l-c);return Math.ceil(l+g)})(o),n??0),r=Date.now()+i;this.ol.push({retryAt:r,requestOptions:e});let s=`Enqueued failed request for retry in ${i}`;navigator.onLine||(s+=" (Browser is offline)"),gi.warn(s),this.fl||(this.fl=!0,this._l())}_l(){if(this.wl&&clearTimeout(this.wl),this.ol.length===0)return this.fl=!1,void(this.wl=void 0);this.wl=setTimeout(()=>{this.gl&&this.ol.length>0&&this.yl(),this._l()},this.pl)}yl(){const e=Date.now(),n=[],o=this.ol.filter(i=>e>i.retryAt||(n.push(i),!1));if(this.ol=n,o.length>0)for(const{requestOptions:i}of o)this.retriableRequest(i)}unload(){this.wl&&(clearTimeout(this.wl),this.wl=void 0),this.fl=!1,Eo(Fn)||(this.ml&&(Fn.removeEventListener("online",this.ml),this.ml=void 0),this.bl&&(Fn.removeEventListener("offline",this.bl),this.bl=void 0));for(const{requestOptions:e}of this.ol)try{this._instance._send_request(sn(sn({},e),{},{transport:"sendBeacon"}))}catch(n){gi.error(n)}this.ol=[]}},c9n=class{constructor(e){this._instance=e,this.kl=()=>{var n,o,i,r;this.Sl||(this.Sl={});const s=this.scrollElement(),a=this.scrollY(),A=s?Math.max(0,s.scrollHeight-s.clientHeight):0,c=a+(s?.clientHeight||0),l=s?.scrollHeight||0;this.Sl.lastScrollY=Math.ceil(a),this.Sl.maxScrollY=Math.max(a,(n=this.Sl.maxScrollY)!==null&&n!==void 0?n:0),this.Sl.maxScrollHeight=Math.max(A,(o=this.Sl.maxScrollHeight)!==null&&o!==void 0?o:0),this.Sl.lastContentY=c,this.Sl.maxContentY=Math.max(c,(i=this.Sl.maxContentY)!==null&&i!==void 0?i:0),this.Sl.maxContentHeight=Math.max(l,(r=this.Sl.maxContentHeight)!==null&&r!==void 0?r:0)}}get xl(){return this._instance.config.scroll_root_selector}getContext(){return this.Sl}resetContext(){const e=this.Sl;return this.Sl=void 0,setTimeout(this.kl,0),e}startMeasuringScrollPosition(){jc(Fn,"scroll",this.kl,{capture:!0}),jc(Fn,"scrollend",this.kl,{capture:!0}),jc(Fn,"resize",this.kl)}scrollElement(){if(this.xl){const o=As(this.xl)?this.xl:[this.xl];for(const i of o){var e;const r=Fn==null||(e=Fn.document)===null||e===void 0?void 0:e.querySelector(i);if(r)return r}return}var n;return Fn==null||(n=Fn.document)===null||n===void 0?void 0:n.documentElement}$l(e){var n,o;const i=e==="y"?"scrollTop":"scrollLeft";if(this.xl){const r=this.scrollElement();return r&&r[i]||0}return Fn?e==="y"?Fn.scrollY||Fn.pageYOffset||((n=Fn.document)===null||n===void 0||(n=n.documentElement)===null||n===void 0?void 0:n.scrollTop)||0:Fn.scrollX||Fn.pageXOffset||((o=Fn.document)===null||o===void 0||(o=o.documentElement)===null||o===void 0?void 0:o.scrollLeft)||0:0}scrollY(){return this.$l("y")}scrollX(){return this.$l("x")}};const l9n=t=>iat(t?.config.mask_personal_data_properties,t?.config.custom_personal_data_properties,t?.config.disable_capture_url_hashes);var Rat=class{constructor(e,n,o,i){this.qe=r=>{const s=this.Cl();if(s&&s.sessionId===r)return;const a={sessionId:r,props:this.Tl(this._instance)};this.Il.register({[c2e]:a})},this._instance=e,this.Ml=n,this.Il=o,this.Tl=i||l9n,this.Ml.onSessionId(this.qe)}Cl(){return this.Il.props[c2e]}getSetOnceProps(){var e;const n=(e=this.Cl())===null||e===void 0?void 0:e.props;return n?"r"in n?rat(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(){const e={};return vl(m2e(this.getSetOnceProps()),(n,o)=>{o==="$current_url"&&(o="url"),e[`$session_entry_${Pye(o)}`]=n}),e}},dne=class{on(e,n){return this.El[e]||(this.El[e]=[]),this.El[e].push(n),()=>{this.El[e]=this.El[e].filter(o=>o!==n)}}emit(e,n){for(const o of this.El[e]||[])o(n);for(const o of this.El["*"]||[])o(e,n)}constructor(){this.El={}}};const Kk=Ad("[SessionId]"),Tat=864e5;var kat=class{on(e,n){return this.Pl.on(e,n)}constructor(e,n,o){var i;if(this.Rl=null,this.Al=null,this.Ol=[],this.Fl=void 0,this.Dl=!1,this.Pl=new dne,this.Ll=(s,a)=>!(!I8(s)||!I8(a))&&Math.abs(s-a)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Mr=e.config,this.Il=e.persistence,this.je=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.Nl=void 0,this._sessionActivityTimestamp=null,this.ql=n||F4,this.jl=o||F4;const r=this.Mr.persistence_name||this.Mr.token;if(this._sessionTimeoutMs=1e3*E9(this.Mr.session_idle_timeout_seconds||1800,60,36e3,Kk.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Bl(),this.Hl="ph_"+r+"_window_id",this.zl="ph_"+r+"_primary_window_exists",this.Ul()){const s=Z0.Lt(this.Hl),a=Z0.Lt(this.zl);s&&!a?this.je=s:Z0.Pt(this.Hl),Z0.$t(this.zl,!0)}!((i=this.Mr.bootstrap)===null||i===void 0)&&i.sessionID&&this.setBootstrapSessionId(this.Mr.bootstrap.sessionID),this.Wl()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return Eo(this.Ol)&&(this.Ol=[]),this.Ol.push(e),this.Xt&&e(this.Xt,this.je),()=>{this.Ol=this.Ol.filter(n=>n!==e)}}Ul(){return this.Mr.persistence!=="memory"&&!this.Il.hi&&Z0.Et()}Vl(e){e!==this.je&&(this.je=e,this.Ul()&&Z0.$t(this.Hl,e))}Gl(){return this.je?this.je:this.Ul()?Z0.Lt(this.Hl):null}Ql(e){const n=this.Rl;return!ad(n)&&!ad(e)&&5e3>Math.abs(e-n)}Jl(e,n,o){const i=n!==this._sessionActivityTimestamp,r=!(e!==this.Xt||o!==this._sessionStartTimestamp);this._sessionStartTimestamp=o,this._sessionActivityTimestamp=n,this.Xt=e,r&&!i||r&&this.Ql(n)||(this.Rl=n,this.Il.register({[Mk]:[n,e,o]}))}Zl(){var e;const n=(e=this.Mr)===null||e===void 0?void 0:e.persistence_save_debounce_ms;return I8(n)&&n>0}Kl(){this.Zl()?this.Il.refreshKey(Mk):(this.Il.flush(),this.Il.load())}Xl(){var e;if(ad(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this.Rl)return;this.Kl();const[,n,o]=this.Yl();n===this.Xt&&o===this._sessionStartTimestamp&&(this.Rl=this._sessionActivityTimestamp,this.Il.register({[Mk]:[this._sessionActivityTimestamp,(e=this.Xt)!==null&&e!==void 0?e:null,this._sessionStartTimestamp]}),this.Il.flush())}tu(){const[e]=this.Yl(),n=I8(e)?e:0,o=I8(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(n,o)}eu(e){return this.Kl(),this.Ll(e,this.tu())}Yl(){const e=this.Il.props[Mk];return As(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.Rl=null,this.Nl=void 0,clearTimeout(this.iu),this.iu=void 0,this.Jl(null,null,null)}setBootstrapSessionId(e,n=!1){const o=((i,r=new Date().getTime())=>{try{const s=(a=>{const A=a.replace(/-/g,"");if(A.length!==32)throw new Error("Not a valid UUID");if(A[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(A.substring(0,12),16)})(i);return s>r+6e4?void Kk.error("Bootstrap sessionID cannot be in the future"):s}catch(s){return void Kk.error("Invalid sessionID in bootstrap",s)}})(e);return!Eo(o)&&(n?this.Nl={sessionId:e,sessionStartTimestamp:o}:this.Jl(e,new Date().getTime(),o),!0)}destroy(){this.Dl=!0,this.Xl(),clearTimeout(this.iu),this.iu=void 0,this.Fl&&Fn&&(Fn.removeEventListener(nne,this.Fl,{capture:!1}),this.Fl=void 0),this.Ol=[]}Wl(){this.Fl=()=>{this.Xl(),this.Ul()&&Z0.Pt(this.zl)},jc(Fn,nne,this.Fl,{capture:!1})}checkAndGetSessionAndWindowId(e=!1,n=null,o=!1){if(this.Mr.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');const i=n||new Date().getTime(),r=this.Xt;if(o)this.Al=i;else if(ad(this.Al)||this.Al>i||i-this.Al>=1e3){var s,a;(s=(a=this.Il).syncCookieProperties)===null||s===void 0||s.call(a),this.Al=i}let[,A,c]=this.Yl();const l=!Eo(r)&&A!==r,g=this.tu();let u=this.Gl();const h=this.Nl,d=!!h&&(h.sessionStartTimestamp>i+6e4||i-h.sessionStartTimestamp>Tat),p=h?d:I8(c)&&Math.abs(i-c)>Tat;let m=!1,_=l,f=!A||!!h;const I=A;let C=!f&&!e&&this.Ll(i,g);if(C&&(C=this.eu(i),C||Kk.info("cross-tab refresh kept the session alive",{sessionId:A}),[,A,c]=this.Yl(),C||(f=!A||!!h)),f||C||p){_=!1;const B=h&&!d;A=B?h.sessionId:this.ql(),u=this.jl(),Kk.info("new session ID assigned",{sessionId:A,windowId:u,bootstrapped:!!B,changeReason:{noSessionId:f,activityTimeout:C,sessionPastMaximumLength:p}}),c=B?h.sessionStartTimestamp:i,this.Nl=void 0,m=!0}else u||(u=this.jl(),m=!0),_=_||A!==I,_&&(Kk.info("adopted cross-tab session id",{sessionId:A,windowId:u}),m=!0);const y=I8(g)&&e&&!p?g:i,x=I8(c)?c:new Date().getTime();this.Vl(u),this.Jl(A,y,x),e||this.Bl();const E={noSessionId:f,activityTimeout:C,sessionPastMaximumLength:p,crossTabAdoption:_};return m&&this.Ol.forEach(B=>B(A,u,E)),{sessionId:A,windowId:u,sessionStartTimestamp:x,changeReason:m?E:void 0,lastActivityTimestamp:g}}Bl(){this.Dl||(clearTimeout(this.iu),this.iu=setTimeout(()=>{if(!this.Dl)if(this.eu(new Date().getTime())){const e=this.Xt;this.resetSessionId(),this.Pl.emit("forcedIdleReset",{idleSessionId:e})}else this.Bl()},1.1*this.sessionTimeoutMs))}};const Fat=function(t,e){if(!t)return!1;const n=t.userAgent;if(n&&Rit(n,e))return!0;try{const o=t?.userAgentData;if(o?.brands&&o.brands.some(i=>Rit(i?.brand,e)))return!0}catch{}return!!t.webdriver};function Lat(){return(Lat=Wg(function*(){const t=F_?.userAgentData;if(t?.getHighEntropyValues)try{const e=yield t.getHighEntropyValues(["model"]),n=e?.model;return nA(n)&&n.length>0?n:void 0}catch(e){return void gi.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}})).apply(this,arguments)}function g9n(t,e){let n=`$survey_${e}/${t.id}`;return t.current_iteration&&t.current_iteration>0&&(n=`$survey_${e}/${t.id}/${t.current_iteration}`),n}function Hat(t){var e;return!!(!((e=t.conditions)===null||e===void 0||(e=e.events)===null||e===void 0||(e=e.values)===null||e===void 0)&&e.length)}const hne=(t,e)=>{if(!(n=>{try{new RegExp(n)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(t)}catch{return!1}},pne=t=>t.toLowerCase(),Oat={exact:(t,e)=>e.some(n=>t.some(o=>n===o)),is_not:(t,e)=>e.every(n=>t.every(o=>n!==o)),regex:(t,e)=>e.some(n=>t.some(o=>hne(n,o))),not_regex:(t,e)=>e.every(n=>t.every(o=>!hne(n,o))),icontains:(t,e)=>e.map(pne).some(n=>t.map(pne).some(o=>n.includes(o))),not_icontains:(t,e)=>e.map(pne).every(n=>t.map(pne).every(o=>!n.includes(o))),gt:(t,e)=>e.some(n=>{const o=parseFloat(n);return!isNaN(o)&&t.some(i=>o>parseFloat(i))}),lt:(t,e)=>e.some(n=>{const o=parseFloat(n);return!isNaN(o)&&t.some(i=>o<parseFloat(i))})};function Gat(t,e){return!t||Object.entries(t).every(([n,o])=>{const i=e?.[n];if(i==null)return!1;const r=Oat[o.operator];return!!r&&r(o.values.map(String),[String(i)])})}function z2e(t,e,n){return Lk({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:n})}const J2e="custom",Yat="i.posthog.com",u9n=/^\/static\//,d9n=["/s/","/e/","/i/"];var h9n=class{constructor(e){this.nu={},this.instance=e}get apiHost(){const e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){const e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e;let n=(e=this.instance.config.ui_host)===null||e===void 0?void 0:e.replace(/\/$/,"");return n||(n=this.apiHost.replace(`.${Yat}`,".posthog.com")),n==="https://app.posthog.com"?"https://us.posthog.com":n}get region(){return this.nu[this.apiHost]||(this.nu[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":J2e),this.nu[this.apiHost]}su(e){if(!u9n.test(e))return;const n=this.instance.config.asset_host;return typeof n=="string"&&n.trim().replace(/\/$/,"")||void 0}ru(e){const n=x8(e);return n?n.protocol+"//"+n.host+n.pathname:void 0}ou(e,n,o){if(e==="ui")return o;let i=o;const r=this.instance.config.rewriteRequestPath;if(r){var s;const a=((s=x8(o))===null||s===void 0?void 0:s.href)||o;i=r(new URL(a)).toString()}if(r&&e==="api"&&d9n.some(a=>n.indexOf(a)===0)){const a=this.ru(i);if(a){const A=this.apiHost;let c=this.au;c?.apiHost===A&&c.rewriteRequestPath===r||(c={apiHost:A,rewriteRequestPath:r,urls:new Set},this.au=c),c.urls.add(a)}}return i}isIngestionEndpoint(e){const n=this.au,o=this.ru(e);return n?.apiHost===this.apiHost&&n.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!o&&n.urls.has(o)}endpointFor(e,n=""){if(n&&(n=n[0]==="/"?n:`/${n}`),e==="ui")return this.ou(e,n,this.uiHost+n);if(e==="flags")return this.ou(e,n,this.flagsApiHost+n);if(e==="assets"){const i=this.su(n);if(i)return this.ou(e,n,`${i}${n}`)}if(this.region===J2e)return this.ou(e,n,this.apiHost+n);const o=Yat+n;switch(e){case"assets":return this.ou(e,n,`https://${this.region}-assets.${o}`);case"api":return this.ou(e,n,`https://${this.region}.${o}`)}}};const _l=Ad("[Surveys]"),Uat=t=>{try{const e=(n=>((o,i)=>`seenSurvey_${(function(r){return r.current_iteration&&r.current_iteration>0?`${r.id}_${r.current_iteration}`:r.id})(i)}`)(0,n))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(e){_l.error("Failed to persist survey seen state",e)}},p9n=[N2e.Popover,N2e.Widget,N2e.API],m9n={ignoreConditions:!1,ignoreDelay:!1,displayType:T2e.Popover},_9n=Ad("[PostHog ExternalIntegrations]"),f9n={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var I9n=class{constructor(e){this._instance=e}Ho(e,n){var o,i;(o=Ur.__PosthogExtensions__)===null||o===void 0||(i=o.loadExternalDependency)===null||i===void 0||i.call(o,this._instance,e,r=>{if(r)return _9n.error("failed to load script",r);n()})}startIfEnabledOrStop(){var e;for(const[r,s]of Object.entries((e=this._instance.config.integrations)!==null&&e!==void 0?e:{})){var n,o,i;s&&!(!((n=Ur.__PosthogExtensions__)===null||n===void 0||(n=n.integrations)===null||n===void 0)&&n[r])&&this.Ho(f9n[r],()=>{var a;(a=Ur.__PosthogExtensions__)===null||a===void 0||(a=a.integrations)===null||a===void 0||(a=a[r])===null||a===void 0||a.start(this._instance)}),!s&&(!((o=Ur.__PosthogExtensions__)===null||o===void 0||(o=o.integrations)===null||o===void 0)&&o[r])&&((i=Ur.__PosthogExtensions__)===null||i===void 0||(i=i.integrations)===null||i===void 0||(i=i[r])===null||i===void 0||i.stop())}}},C9n=class{constructor(e,n){this.A=e,this.bo=n,this.lu=new Map,this.To=!1}add(e){var n=this;return Wg(function*(){if(n.To)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(n.lu.has(e.name))throw new Error(`Browser extension "${e.name}" is already registered`);n.lu.set(e.name,e);try{const o=e.setup(n.bo);o&&(yield o)}catch(o){const i=n.lu.get(e.name)===e;i&&n.lu.delete(e.name),n.A.error(`Failed to set up browser extension "${e.name}"`,o),i&&n.uu(e)}})()}getExtension(e){return this.lu.get(e)}dispose(){if(this.To)return;this.To=!0;const e=Array.from(this.lu.values()).reverse();this.lu.clear();for(const n of e)this.uu(n)}uu(e){try{var n;const o=(n=e.dispose)===null||n===void 0?void 0:n.call(e);o&&L_(o.then)&&o.then(void 0,i=>{this.A.error(`Failed to dispose browser extension "${e.name}"`,i)})}catch(o){this.A.error(`Failed to dispose browser extension "${e.name}"`,o)}}},y9n=class{constructor(e){this._instance=e}initialize(){}get(e){const n=this._instance.persistence;if(typeof e=="string")return n?.get_property(e);const o={};for(const i of e){const r=n?.get_property(i);Eo(r)||(o[i]=r)}return o}set(e,n){var o;(o=this._instance.persistence)===null||o===void 0||o.register(typeof e=="string"?{[e]:n}:e)}remove(e){var n;(n=this._instance.persistence)===null||n===void 0||n.unregister(e)}};const Kat="extensionsRemoteConfig";var x9n=class{constructor(e){this.instance=e,this.To=!1,this.A=gi,this.hu=e.cu,this.kv=new y9n(e),this.onEvent=n=>lne(this.instance.on("eventCaptured",o=>{try{n({event:o.event,properties:o.properties})}catch(i){this.A.error("Browser extension event listener failed",i)}})),this.onRemoteConfig=n=>{if(this.To)return lne(()=>{});const o=r=>{try{n(r)}catch(s){this.A.error("Browser extension remote config listener failed",s)}},i=this.instance.du.on(Kat,o);return this.hu&&o(this.hu),lne(i)},this.vu=new C9n(gi.createLogger("[BrowserExtensions]"),this)}get logger(){return this.A}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var e;return(e=this.instance.get_property("$device_id"))!==null&&e!==void 0?e:this.distinctId}get deviceId(){const e=this.instance.get_property($ye);return typeof e=="string"?e:void 0}get library(){return{name:Ym.LIB_NAME,version:Ym.LIB_VERSION}}get initialPersonProperties(){var e,n;return(e=(n=this.instance.persistence)===null||n===void 0?void 0:n.get_initial_props())!==null&&e!==void 0?e:{}}get groups(){return this.instance.getGroups()}get session(){try{var e,n,o,i;const r=(e=this.instance.sessionManager)===null||e===void 0?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:(n=r?.sessionId)!==null&&n!==void 0?n:"",windowId:(o=r?.windowId)!==null&&o!==void 0?o:"",sessionStartTimestamp:(i=r?.sessionStartTimestamp)!==null&&i!==void 0?i:0}}catch{return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(e){return this.vu.add(e)}getExtension(e){return this.vu.getExtension(e)}capture(e,n,o){o?this.instance.capture(e,n,{timestamp:o.timestamp,uuid:o.uuid,$set:o.set,$set_once:o.setOnce}):this.instance.capture(e,n)}registerDynamicEventProperties(e){return lne(this.instance.fu(e))}handleRemoteConfig(e){this.To||(this.hu=e,this.instance.du.emit(Kat,e))}sendRequest(e){var n=this;return Wg(function*(o,i={}){var r;const s=n.instance.requestRouter.endpointFor((r=i.target)!==null&&r!==void 0?r:"api",o),a={method:i.method,url:i.query?IV(s,i.query):s,data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,compressionFallback:i.target==="flags"&&i.compression==="best-available"?wye.Base64:void 0,timestampMode:i.sentAt};return i.transport==="sendBeacon"?(n.instance._send_request(a),{statusCode:202}):new Promise(A=>{a.callback=A,n.instance._send_request(a)})}).apply(this,arguments)}dispose(){this.To||(this.To=!0,this.vu.dispose())}};const CV={};let W2e=0;const yV=()=>{},Vat='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Vk="Surveys module not available",zat="sanitize_properties is deprecated. Use before_send instead",Jat="Invalid value for property_denylist config: ",E9n=["$recording_status","$sdk_debug_recording_script_not_loaded","$sdk_debug_replay_url_trigger_status","$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_rrweb_error","$sdk_debug_replay_internal_buffer_length","$sdk_debug_replay_flushed_size"],B9n=["$feature_flag_called","$$heatmap","$snapshot"],Wat=t=>t.charAt(0)==="$"&&!as(B9n,t),b9n=/^[A-Za-z0-9_-]{1,400}$/,jat=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,Xat=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,S9n=["token","distinct_id",Ast],xV="posthog",Q9n=t=>{const e={};return t&&t!=="unset"&&("2025-11-30">t||(e.strictMinimumDuration=!0),"2026-05-30">t||(e.canvasCapture={resolutionScale:.6}),"2026-06-25">t||(e.streamNetworkBody=!0),"2026-08-30">t||(e.captureJsonLd=!0)),e},j2e=t=>{var e;return sn({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:BBn(No?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:yV,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:sd&&nA(sd?.search)&&sd.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,reuseAnonymousId:!1,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:(Fn==null||(e=Fn.location)===null||e===void 0?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,feature_flag_request_max_retries:1,surveys_request_timeout_ms:1e4,on_request_error(n){gi.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:fst,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:yV},(n=>({rageclick:n&&n>="2026-05-30"?{content_ignorelist:DBn,ignore_text_selection:!0}:!n||"2025-11-30">n||{content_ignorelist:!0},capture_pageview:!n||"2025-05-24">n||"history_change",session_recording:Q9n(n),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),cookieWinsOnConflict:!(!n||n==="unset"||"2026-08-29">n)}))(t))},v9n=[["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"],["__preview_cookie_wins_on_conflict","cookieWinsOnConflict"]],qat=t=>{const e={};for(const[i,r]of v9n)Eo(t[i])||(e[r]=t[i]);const n=jg({},e,t),o=t.__preview_external_dependency_versioned_paths;return Eo(o)||(Eo(t.strict_script_versioning)&&(n.strict_script_versioning=!!o),nA(o)&&Eo(t.asset_host)&&(n.asset_host=o)),As(t.property_blacklist)&&(Eo(t.property_denylist)?n.property_denylist=t.property_blacklist:As(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:gi.error(Jat+t.property_denylist)),n};var w9n=class{constructor(){this.__forceAllowLocalhost=!1}get pu(){return this.__forceAllowLocalhost}set pu(e){gi.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},EV=class SM{gu(e){if(!e)return;const n=this.lu.indexOf(e);n!==-1&&this.lu.splice(n,1)}mu(e,n){var o;return this.gu(e),this.lu.push(n),(o=n.initialize)===null||o===void 0||o.call(n),n}yu(){return this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isRejected()}bu(){if(this._u||this.config.reuseAnonymousId||this.config.segment||this.yu())return;const e=this.config.persistence==="memory"||this.config.persistence==="sessionStorage";if(!e&&!this.config.disable_persistence||this.wu)return;let n,o,i;e?(n=`persistence is set to '${this.config.persistence}'`,o=this.config.persistence==="memory"?"on every page load":"for every new browser tab or window",i="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(n="persistence is disabled (disable_persistence is true)",o="on every page load",i="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this._u=!0,console.warn("[PostHog.js]",`${n} but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID ${o}, so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. ${i}`)}ku(){const e=this.persistence;if(!e||this.Su)return;if(this.yu())return void(this.config.cookieless_mode==="on_reject"&&this.get_distinct_id()!=="$posthog_cookieless"&&(this.xu(),this.$u()));if(this.get_distinct_id()!=="$posthog_cookieless")return;this.Cu()||e.load(!0);const n=this.get_distinct_id();if(!n||n==="$posthog_cookieless"){const o=this.config.get_device_id(F4());this.register({distinct_id:o,$device_id:o}),e.set_property(my,y8)}this.xu()}get decideEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)===null||n===void 0?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)===null||n===void 0?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){var e;this.Tu=!1,this.Iu=!1,this.webPerformance=new w9n,this.Mu=!1,this.version=Ym.LIB_VERSION,this.Eu=new Set,this.Pu="",this.du=new dne,this.lu=[],this.Ru=[],this.Au=!1,this.wu=!1,this._u=!1,this.Su=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=j2e(),this.SentryIntegration=OBn,this.sentryIntegration=o=>(function(i,r){const s=jst(i,r);return{name:Wst,processEvent:a=>s(a)}})(this,o),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Ou=!1,this.Fu=null,this.Du=null,this.Lu=null,this.scrollManager=new c9n(this),this.pageViewManager=new Xst(this),this.rateLimiter=new XBn(this),this.requestRouter=new h9n(this),this.consent=new MBn(this),this.externalIntegrations=new I9n(this);const n=(e=SM.__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:(o,i,r)=>{const s=nA(o)?{[o]:i}:o;this.setPersonProperties(s),r?.({})},set_once:(o,i,r)=>{const s=nA(o)?{[o]:i}:o;this.setPersonProperties(void 0,s),r?.({})}},this.on("eventCaptured",o=>gi.info(`send "${o?.event}"`,o))}init(e,n,o){if(o&&o!==xV){var i;const r=(i=CV[o])!==null&&i!==void 0?i:new SM;return r._init(e,n,o),CV[o]=r,CV[xV][o]=r,r}return this._init(e,n,o)}_init(e,n={},o){var i,r,s;const a=nA(e)?e.trim():"";if(!a)return gi.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;var A;if(this.__loaded)return a!==((A=this.config)===null||A===void 0?void 0:A.token)?console.warn("[PostHog.js]",`You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('${a}', { ... }, 'project2')`):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=j2e(n.defaults),n.debug=this.Nu(n.debug),this.qu=n,this.ju=[],n.person_profiles?this.Du=n.person_profiles:n.process_person&&(this.Du=n.process_person);const c=j2e(n.defaults),l=qat(n),g=jg({},c,l,{name:o,token:a});xA(c.rageclick)&&xA(l.rageclick)&&(g.rageclick=jg({},c.rageclick,l.rageclick)),xA(c.session_recording)&&xA(l.session_recording)&&(g.session_recording=jg({},c.session_recording,l.session_recording)),this.set_config(g),this.config.on_xhr_error&&gi.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:N3.GZipJS;const u=this.Cu(),h=!this.yu();if(this.persistence=new D2e(this.config,u,!0,h),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new D2e(sn(sn({},this.config),{},{persistence:"sessionStorage"}),u,!1,h),this.Pu="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!u&&Z0.Et()){const f=Z0.Lt(this.Pu);As(f)&&f.forEach(I=>{nA(I)&&this.Eu.add(I)})}else Z0.Pt(this.Pu);const d=sn({},this.persistence.props),p=sn({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Bu=new s9n((f,I)=>this.Hu(f,I),this.config.request_queue_config),this.zu=new A9n(this),this.__request_queue=[];const m=this.yu();m||(this.sessionManager=new kat(this),this.sessionPropsManager=new Rat(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((f,I,C)=>{(C?.activityTimeout||C?.sessionPastMaximumLength||C?.crossTabAdoption)&&this.Uu()})),this.Wu(),this.config.__preview_deferred_init_extensions?(gi.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.Vu(m)},0)):(gi.info("Initializing extensions synchronously"),this.Vu(m)),Ym.DEBUG=Ym.DEBUG||this.config.debug,Ym.DEBUG&&gi.info("Starting in debug mode",{this:this,config:n,thisC:sn({},this.config),p:d,s:p}),this.config.identity_distinct_id&&!(!((i=n.bootstrap)===null||i===void 0)&&i.distinctID)&&(n.bootstrap=sn(sn({},n.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const _=(r=n.bootstrap)===null||r===void 0?void 0:r.distinctID;if(this.wu=!!_&&!JK(_),(s=n.bootstrap)===null||s===void 0?void 0:s.distinctID){const f=n.bootstrap.distinctID,I=this.get_distinct_id(),C=this.persistence.get_property(my);if(n.bootstrap.isIdentifiedID&&I!=null&&I!==f&&C==="anonymous")this.identify(f);else if(n.bootstrap.isIdentifiedID&&I!=null&&I!==f&&C==="identified")gi.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{const y=this.config.get_device_id(F4()),x=n.bootstrap.isIdentifiedID?y:f;this.persistence.set_property(my,n.bootstrap.isIdentifiedID?tne:y8),this.register({distinct_id:f,$device_id:x})}}if(m)this.register_once({distinct_id:g2e,$device_id:null},"");else if(!this.get_distinct_id()){const f=this.config.get_device_id(F4());this.register_once({distinct_id:f,$device_id:f},""),this.persistence.set_property(my,y8)}return jc(Fn,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),jc(Fn,"pageshow",()=>{var f;this.Tu=!1,this.Iu||(f=this.zu)===null||f===void 0||f.resume()}),n.segment?Jst(this,()=>this.Gu()):this.Gu(),L_(this.config._onCapture)&&this.config._onCapture!==yV&&(gi.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",f=>this.config._onCapture(f.event,f))),this.config.ip&&gi.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 Lat.apply(this,arguments)})().then(f=>{f&&this.register({[Zye]:f})}).catch(yV),this}Qu(e){const n=e;return nA(n.name)&&L_(n.setup)}Ju(e,n){this.Qu(e)?n.push(()=>{this.Zu().add(e).catch(()=>{var o;return(o=e.dispose)===null||o===void 0?void 0:o.call(e)}).catch(o=>{gi.error(`Failed to dispose browser extension "${e.name}"`,o)})}):this.lu.push(e)}Wu(){var e,n,o;const i=(e=(n=this.config.__extensionClasses)===null||n===void 0?void 0:n.featureFlags)!==null&&e!==void 0?e:(o=SM.__defaultExtensionClasses)===null||o===void 0?void 0:o.featureFlags;var r,s,a;i&&(this.featureFlags&&this.featureFlags instanceof i||((r=this.Ku)===null||r===void 0||r.call(this),this.Ku=void 0,this.featureFlags=new i(this)),L_(this.featureFlags.onReloading)&&L_(this.featureFlags.setup)?this.Ku||(this.Ku=this.featureFlags.onReloading(()=>{this.du.emit("featureFlagsReloading",!0)}),this.Zu().add(this.featureFlags)):(s=(a=this.featureFlags).initialize)===null||s===void 0||s.call(a))}Vu(e){const n=performance.now(),o=sn(sn({},SM.__defaultExtensionClasses),this.config.__extensionClasses),i=[];var r,s,a,A,c,l,g;o.exceptions&&this.lu.push(this.exceptions=(r=this.exceptions)!==null&&r!==void 0?r:new o.exceptions(this)),o.historyAutocapture&&this.lu.push(this.historyAutocapture=new o.historyAutocapture(this)),o.tracingHeaders&&this.lu.push(this.tracingHeaders=new o.tracingHeaders(this)),o.siteApps&&this.lu.push(this.siteApps=new o.siteApps(this)),o.sessionRecording&&!e&&this.lu.push(this.sessionRecording=new o.sessionRecording(this)),this.config.disable_scroll_properties||i.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),o.autocapture&&this.Ju(this.autocapture=new o.autocapture(this),i),o.surveys&&this.Ju(this.surveys=(s=this.surveys)!==null&&s!==void 0?s:new o.surveys(this),i),o.logs&&this.Ju(this.logs=(a=this.logs)!==null&&a!==void 0?a:new o.logs(this),i),o.metrics&&this.lu.push(this.metrics=(A=this.metrics)!==null&&A!==void 0?A:new o.metrics(this)),o.conversations&&this.lu.push(this.conversations=(c=this.conversations)!==null&&c!==void 0?c:new o.conversations(this)),o.productTours&&this.lu.push(this.productTours=new o.productTours(this)),o.heatmaps&&this.lu.push(this.heatmaps=new o.heatmaps(this)),o.webVitalsAutocapture&&this.lu.push(this.webVitalsAutocapture=new o.webVitalsAutocapture(this)),o.exceptionObserver&&this.lu.push(this.exceptionObserver=new o.exceptionObserver(this)),o.deadClicksAutocapture&&this.lu.push(this.deadClicksAutocapture=new o.deadClicksAutocapture(this,HBn)),o.toolbar&&this.lu.push(this.toolbar=(l=this.toolbar)!==null&&l!==void 0?l:new o.toolbar(this)),o.experiments&&this.lu.push(this.experiments=(g=this.experiments)!==null&&g!==void 0?g:new o.experiments(this)),this.lu.forEach(u=>{u.initialize&&i.push(()=>{var h;(h=u.initialize)===null||h===void 0||h.call(u)})}),i.push(()=>{if(this.Xu){const u=this.Xu;this.Xu=void 0,this.lu.forEach(h=>{var d;return(d=h.onRemoteConfig)===null||d===void 0?void 0:d.call(h,u)})}}),this.Yu(i,n)}Yu(e,n){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-n>=30&&e.length>0)return void setTimeout(()=>{this.Yu(e,n)},0);const i=e.shift();if(i)try{i()}catch(r){gi.error("Error initializing extension:",r)}}const o=Math.round(performance.now()-n);this.register_for_session({[cst]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[lst]:o}),this.config.__preview_deferred_init_extensions&&gi.info(`PostHog extensions initialized (${o}ms)`)}el(e){var n;if(!No||!No.body)return gi.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.el(e)},500);if(this.config.__preview_deferred_init_extensions&&(this.Xu=e),this.cu=e,this.compression=void 0,e.ok){var o;const i=e.config;i.supportedCompression&&!this.config.disable_compression&&(this.compression=as(i.supportedCompression,N3.GZipJS)?N3.GZipJS:as(i.supportedCompression,N3.Base64)?N3.Base64:void 0),!((o=i.analytics)===null||o===void 0)&&o.endpoint&&(this.analyticsDefaultEndpoint=i.analytics.endpoint)}this.set_config({person_profiles:this.Du?this.Du:fst}),(n=this.th)===null||n===void 0||n.handleRemoteConfig(e),this.lu.forEach(i=>{var r;return(r=i.onRemoteConfig)===null||r===void 0?void 0:r.call(i,e)})}Gu(){try{this.config.loaded(this)}catch(e){gi.critical("`loaded` function failed",e)}if(this.eh(),this.config.internal_or_test_user_hostname&&sd?.hostname){const e=sd.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.yu())&&this.ih()},1),this.nh=new uat(this),this.nh.load()}eh(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Bu)===null||e===void 0||e.enable())}_dom_loaded(){this.is_capturing()&&Nk(this.__request_queue,e=>this.Hu(e)),this.__request_queue=[],this.eh()}_handle_unload(){var e,n,o,i,r,s;this.Tu=!0,(e=this.surveys)===null||e===void 0||(n=e.handlePageUnload)===null||n===void 0||n.call(e),(o=this.metrics)===null||o===void 0||o.flush("sendBeacon"),this.config.request_batching?(this.sh()&&this.capture(Ist),(i=this.logs)===null||i===void 0||i.flushLogs("sendBeacon"),(r=this.Bu)===null||r===void 0||r.unload(),(s=this.zu)===null||s===void 0||s.unload()):this.sh()&&this.capture(Ist,null,{transport:"sendBeacon"})}_send_request(e){Nat(this,e)}Hu(e,n){this.zu?this.zu.retriableRequest(e,n):this._send_request(n?sn(sn({},e),{},{transport:n}):e)}_execute_array(e){W2e++;try{let n;const o=[],i=[],r=[];Nk(e,a=>{if(a)if(n=a[0],As(n))r.push(a);else if(L_(a))try{a.call(this)}catch(A){gi.error("Error executing queued PostHog call",a,A)}else As(a)&&n==="alias"?o.push(a):As(a)&&n.indexOf("capture")!==-1&&L_(this[n])?r.push(a):i.push(a)});const s=function(a,A){Nk(a,function(c){try{if(As(c[0])){let l=A;vl(c,function(g){l=l[g[0]].apply(l,g.slice(1))})}else A[c[0]].apply(A,c.slice(1))}catch(l){gi.error("Error executing queued PostHog call",c,l)}})};s(o,this),s(i,this),s(r,this)}finally{W2e--}}push(e){if(W2e>0&&As(e)&&nA(e[0])){const n=SM.prototype[e[0]];return void(L_(n)&&n.apply(this,e.slice(1)))}this._execute_array([e])}get rh(){return{property:jrt,persistenceKey:Pk,cookieName:"_fbc",pattern:jat,register:(e,n)=>{var o;return(o=this.persistence)===null||o===void 0?void 0:o.register({[Pk]:{value:e,delivered:n}})},unregister:()=>{var e;return(e=this.persistence)===null||e===void 0?void 0:e.unregister(Pk)}}}get oh(){return{property:Xrt,persistenceKey:$K,cookieName:"_fbp",pattern:Xat,register:(e,n)=>{var o;return(o=this.persistence)===null||o===void 0?void 0:o.register({[$K]:{value:e,delivered:n}})},unregister:()=>{var e;return(e=this.persistence)===null||e===void 0?void 0:e.unregister($K)}}}ah(e){var n;const o=(n=this.persistence)===null||n===void 0?void 0:n.get_property(e.persistenceKey);return nA(o)&&e.pattern.test(o)?{value:o,delivered:!1}:xA(o)&&nA(o.value)&&e.pattern.test(o.value)?{value:o.value,delivered:o.delivered===!0}:void 0}uh(e,n,o){return n===o?.value?{value:n,pending:!o.delivered}:(e.register(n,!1),{value:n,pending:!0})}hh(e){if(!this.config.save_campaign_params||this.yu())return;const n=rV(e.cookieName);return nA(n)&&e.pattern.test(n)?n:void 0}dh(e,n,o,i){if(!this.persistence)return;const r=this.rh;this.persistence.refreshKey(r.persistenceKey);const s=this.ah(r);if(i)return void r.unregister();if(o)return nA(n)&&jat.test(n)?this.uh(r,n,s):void r.unregister();const a=nA(e)&&b9n.test(e)?e:void 0,A=this.hh(r);return A&&((c,l,g)=>{const u=c.split(".");if(l)return u[3]===l;if(!g)return!0;const h=g.value.split(".");return u[3]===h[3]||Number(u[2])>Number(h[2])})(A,a,s)?this.uh(r,A,s):a?s?.value.split(".")[3]===a?{value:s.value,pending:!s.delivered}:this.uh(r,`fb.1.${Date.now()}.${a}`,s):s?{value:s.value,pending:!s.delivered}:void 0}fh(e,n,o){if(!this.persistence)return;const i=this.oh;this.persistence.refreshKey(i.persistenceKey);const r=this.ah(i);if(o)return void i.unregister();if(n)return nA(e)&&Xat.test(e)?this.uh(i,e,r):void i.unregister();const s=this.hh(i);return s?this.uh(i,s,r):r?{value:r.value,pending:!r.delivered}:void 0}ph(e,n){if(!this.persistence)return;this.persistence.refreshKey(e.persistenceKey);const o=this.ah(e);o?.value!==n||o.delivered||e.register(n,!0)}capture(e,n,o){var i,r;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Bu))return void gi.uninitializedWarning("posthog.capture");if(!this.is_capturing())return;if(Eo(e)||!nA(e))return void gi.error("No event name provided to posthog.capture");if(this.ku(),e==="$snapshot"&&this.yu())return;const s=!this.config.opt_out_useragent_filter&&this._is_bot();if(s&&!this.config.__preview_capture_bot_pageviews)return;const a=o?.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(a?.isRateLimited)return void gi.critical("This capture call is ignored due to client rate limiting.");let A;n?.$current_url&&!nA(n?.$current_url)&&(gi.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"||o?.gh||gi.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&&(A=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();const c=new Date,l=o?.timestamp||c,g=hrt(o?.uuid,F4);let u={uuid:g,event:e,properties:this.calculateEventProperties(e,n||{},l,g)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&s&&(u.event="$bot_pageview",u.properties.$browser_type="bot"),a&&(u.properties.$lib_rate_limit_remaining_tokens=a.remainingTokens);const h=e==="$feature_flag_called"&&u.properties.$feature_flag_has_experiment===!1&&this.get_property("$minimal_flag_called_events")===!0;o?.$set&&!h&&(u.$set=o?.$set);const d=xA(n?.$set)?n.$set:void 0,p=As(n?.$unset)?n.$unset:[],m=o?.$unset||[],_=R=>{var F;const O=!!o?.$set&&R in o.$set;return{hasProvided:O||!!d&&R in d,provided:O?o==null||(F=o.$set)===null||F===void 0?void 0:F[R]:d?.[R],unset:p.indexOf(R)!==-1||m.indexOf(R)!==-1}},f=_(jrt),I=_(Xrt),C=[{channel:this.rh,hasProvided:f.hasProvided,update:this.dh(A?.fbclid,f.provided,f.hasProvided,f.unset)},{channel:this.oh,hasProvided:I.hasProvided,update:this.fh(I.provided,I.hasProvided,I.unset)}];for(const{channel:R,hasProvided:F,update:O}of C)O&&u.properties.$process_person_profile===!0&&O.pending&&!F&&!h&&(u.$set=sn({[R.property]:O.value},u.$set));const y=o?.$unset;y&&(u.$unset=y);const x=h?void 0:this.mh(o?.$set_once,e!==yst,e===Cst);if(x&&(u.$set_once=x),o?._noTruncate||(E=this.config.properties_string_max_length,u=(function(R,F){const O=new Set;return(function U(Y,J){if(Y!==Object(Y))return F?F(Y):Y;if(O.has(Y))return;let ee;if(O.add(Y),As(Y))ee=[],Nk(Y,W=>{ee.push(U(W))});else{const W={};vl(Qk(Y)?xst(Y):Y,(X,oe)=>{O.has(X)||(W[oe]=U(X))}),ee=W}return ee})(R)})(u,R=>nA(R)?R.slice(0,E):R)),u.timestamp=l,Eo(o?.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=c),h&&(u.properties=((R,F=[])=>{const O={},U=Y=>{R[Y]!==void 0&&(O[Y]=R[Y])};return K4n.forEach(U),F.forEach(U),O})(u.properties,S9n)),e===R3.DISMISSED||e===R3.SENT){const R=n?.[R2e.SURVEY_ID],F=n?.[R2e.SURVEY_ITERATION];Uat({id:R,current_iteration:F}),u.$set=sn(sn({},u.$set),{},{[g9n({id:R,current_iteration:F},e===R3.SENT?"responded":"dismissed")]:!0})}else e===R3.SHOWN&&(u.$set=sn(sn({},u.$set),{},{[R2e.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var E;if(e===jBn.SHOWN){const R=n?.[lat.TOUR_TYPE];R&&(u.$set=sn(sn({},u.$set),{},{[`${lat.TOUR_LAST_SEEN_DATE}/${R}`]:new Date().toISOString()}))}const B=sn(sn({},u.properties.$set),u.$set);if(ox(B)||this.setPersonPropertiesForFlags(B),!Fs(this.config.before_send)){const R=this.Fs(u);if(!R)return;u=R,u.uuid=hrt(u.uuid,F4)}this.sessionRecording&&!this.Au&&Wat(e)&&(this.Au=!0,setTimeout(()=>this.Au=!1,3e4));const S=C.filter(({channel:R,update:F})=>{var O,U,Y;const J=(O=(U=u.$set)===null||U===void 0?void 0:U[R.property])!==null&&O!==void 0?O:xA((Y=u.properties)===null||Y===void 0?void 0:Y.$set)?u.properties.$set[R.property]:void 0;return F?.pending&&J===F.value});this.du.emit("eventCaptured",u);const Q=(i=o?._url)!==null&&i!==void 0?i:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),w=o?._batchKey==="recordings"||/\/s\/(?:\?|$)/.test(Q),M=sn(sn(sn({method:"POST",url:Q,data:u,compression:"best-available",preferSyncCompression:o?.send_instantly,timestampMode:w?"body":"capture-body",batchKey:o?._batchKey},w&&(!((r=u.properties)===null||r===void 0)&&r.$session_id)?{batchGroup:u.properties.$session_id+(u.properties.$window_id?`-${u.properties.$window_id}`:"")}:{}),o?.transport?{transport:o.transport}:{}),S.length?{fireCallbackOnDrop:!0,callback:R=>{if(R.statusCode>=200&&300>R.statusCode)for(const{channel:F,update:O}of S)this.ph(F,O.value)}}:{});if(!this.config.request_batching||o&&!o?._batchKey||o?.send_instantly||S.length){var k;let R;!M.transport&&!M.callback&&ox((k=this.config.request_headers)!==null&&k!==void 0?k:{})&&this.Tu&&(R="sendBeacon"),this.Hu(M,R)}else this.Bu.enqueue(M);return u}_addCaptureHook(e){return this.on("eventCaptured",n=>e(n.event,n))}getExtension(e){var n;return(n=this.th)===null||n===void 0?void 0:n.getExtension(e)}Zu(){var e;return(e=this.th)!==null&&e!==void 0?e:this.th=new x9n(this)}fu(e){this.Ru.push(e);let n=!0;return()=>{if(!n)return;n=!1;const o=this.Ru.indexOf(e);o!==-1&&this.Ru.splice(o,1)}}yh(e=!0){var n,o,i;return!!(!((n=this.persistence)===null||n===void 0)&&n.consumeCookieIdentityChange())&&(this.Lu=null,this.persistence.get_property("$user_state")==="anonymous"&&((i=this.sessionPersistence)===null||i===void 0||i.clear(),this.Eu.clear(),this.bh()),(o=this.featureFlags)===null||o===void 0||o.reset(),e&&this.reloadFeatureFlags(),!0)}calculateEventProperties(e,n,o,i,r){if(o=o||new Date,!this.persistence||!this.sessionPersistence)return n;this.ku(),this.persistence.syncCookieProperties(),this.yh();const s=r?void 0:this.persistence.remove_event_timer(e);let a=sn({},n);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,this.yu()&&(a[Ast]=!0),e==="$snapshot"){const f=sn(sn({},this.persistence.properties()),this.sessionPersistence.properties());return a.distinct_id=f.distinct_id,(!nA(a.distinct_id)&&!qd(a.distinct_id)||JK(a.distinct_id))&&gi.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}const A=(function(f,I,C,y=!1){var x,E,B,S;if(!hy)return{};const Q=f?[...Ok,...I||[]]:[],[w,M]=crt(hy),[k,R]=(function(se){for(let ie=0;grt.length>ie;ie++){const[ge,ue,Ie]=grt[ie],le=se.match(ge);if(le){const _e=Ie&&se.match(Ie)||le;return[ue,_e?.[1]||""]}}return["",""]})(hy),F=(function(){const se="u">typeof navigator?navigator:void 0;return se?.brave?{brave:!0}:{}})(),O={};Eo(C)||(O.detectGoogleSearchApp=C);const U={},Y=(x=navigator)===null||x===void 0||(x=x.userAgentData)===null||x===void 0?void 0:x.platform,J=(E=navigator)===null||E===void 0?void 0:E.maxTouchPoints,ee=Fn==null||(B=Fn.screen)===null||B===void 0?void 0:B.width,W=Fn==null||(S=Fn.screen)===null||S===void 0?void 0:S.height,X=Fn?.devicePixelRatio;Eo(Y)||(U.userAgentDataPlatform=Y),Eo(J)||(U.maxTouchPoints=J),Eo(ee)||(U.screenWidth=ee),Eo(W)||(U.screenHeight=W),Eo(X)||(U.devicePixelRatio=X);const oe=jg(m2e({$os:w,$os_version:M,$browser:art(hy,navigator.vendor,F,O),$webview_app:k,$webview_app_version:R,$device:lrt(hy),$device_type:u4n(hy,U),$timezone:sat(),$timezone_offset:zBn()}),{$current_url:dV(y?AQ(sd?.href):sd?.href,Q,hV),$host:sd?.host,$pathname:sd?.pathname,$raw_user_agent:hy.length>1e3?hy.substring(0,997)+"...":hy,$browser_version:g4n(hy,navigator.vendor,F,O),$browser_language:nat(),$browser_language_prefix:VBn(),$screen_height:Fn?.screen.height,$screen_width:Fn?.screen.width,$viewport_height:Fn?.innerHeight,$viewport_width:Fn?.innerWidth,$lib:f8.LIB_NAME,$lib_version:f8.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return f8.SDK_DIST_CHANNEL&&(oe.$sdk_dist_channel=f8.SDK_DIST_CHANNEL),oe})(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){const{sessionId:f,windowId:I}=this.sessionManager.checkAndGetSessionAndWindowId(r,o.getTime(),!0);a.$session_id=f,a.$window_id=I}this.sessionPropsManager&&jg(a,this.sessionPropsManager.getSessionProps());try{var c;if(this.sessionRecording){const f=this.sessionRecording.sdkDebugProperties,I=!this.Au&&Wat(e);for(const C in f)(I||as(E9n,C))&&(a[C]=f[C])}a.$sdk_debug_retry_queue_size=(c=this.zu)===null||c===void 0?void 0:c.length}catch(f){a.$sdk_debug_error_capturing_properties=String(f)}let l;if(this.requestRouter.region===J2e&&(a.$lib_custom_api_host=this.config.api_host),l=e!=="$pageview"||r?e!=="$pageleave"||r?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(o):this.pageViewManager.doPageView(o,i),a=jg(a,l),e==="$pageview"&&No&&(a.title=No.title),!Eo(s)){const f=o.getTime()-s;a.$duration=parseFloat((f/1e3).toFixed(3))}hy&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser");const g=this.persistence.properties(),u=this.sessionPersistence.properties(),h=a.$groups,d=g.$groups;xA(h)&&!ox(h)&&(a.$groups=sn(sn({},xA(d)?d:{}),h)),vl(["$referrer","$referring_domain"],f=>{f in g&&delete u[f]});const p={};if(this.Ru.length>0)for(const f of this.Ru.slice())try{jg(p,f())}catch(I){gi.error("Failed to produce browser extension event properties",I)}a=jg({},A,g,u,sn(sn({},p),a)),a.$is_identified=this._isIdentified(),As(this.config.property_denylist)?vl(this.config.property_denylist,function(f){delete a[f]}):gi.error(Jat+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const m=this.config.sanitize_properties;m&&(gi.error(zat),a=m(a,e));const _=this._h();return a.$process_person_profile=_,_&&!r&&this.wh("_calculate_event_properties"),a}mh(e,n=!0,o=!1){var i;if(!this.persistence||!this._h()||this.Mu&&!o)return e;const r=this.persistence.get_initial_props(),s=(i=this.sessionPropsManager)===null||i===void 0?void 0:i.getSetOnceProps();let a=jg({},r,s||{},e||{});const A=this.config.sanitize_properties;return A&&(gi.error(zat),a=A(a,"$set_once")),n&&(this.Mu=!0),ox(a)?void 0:a}register(e,n){var o;(o=this.persistence)===null||o===void 0||o.register(e,n)}register_once(e,n,o){var i;(i=this.persistence)===null||i===void 0||i.register_once(e,n,o)}register_for_session(e){var n,o;(n=this.persistence)===null||n===void 0||n.syncCookieProperties(),this.yh(),(o=this.sessionPersistence)===null||o===void 0||o.register(e),Object.keys(e).forEach(i=>this.Eu.add(i)),this.bh()}unregister(e){var n;(n=this.persistence)===null||n===void 0||n.unregister(e)}unregister_for_session(e){var n;(n=this.sessionPersistence)===null||n===void 0||n.unregister(e),this.Eu.delete(e),this.bh()}kh(e,n){this.register({[e]:n})}Uu(){this.Eu.forEach(e=>{var n;(n=this.sessionPersistence)===null||n===void 0||n.unregister(e)}),this.Eu.clear(),this.bh()}bh(){var e;if(!this.Pu)return;if(this.config.persistence==="memory"||!((e=this.sessionPersistence)===null||e===void 0)&&e.hi||!Z0.Et())return void Z0.Pt(this.Pu);const n=[];this.Eu.forEach(o=>n.push(o)),n.length>0?Z0.$t(this.Pu,n):Z0.Pt(this.Pu)}getFeatureFlag(e,n){var o;return(o=this.featureFlags)===null||o===void 0?void 0:o.getFeatureFlag(e,n)}getFeatureFlagPayload(e){var n;return(n=this.featureFlags)===null||n===void 0?void 0:n.getFeatureFlagPayload(e)}getFeatureFlagResult(e,n){var o;return(o=this.featureFlags)===null||o===void 0?void 0:o.getFeatureFlagResult(e,n)}getAllFeatureFlags(){var e,n;return(e=(n=this.featureFlags)===null||n===void 0?void 0:n.getAllFeatureFlags())!==null&&e!==void 0?e:[]}isFeatureEnabled(e,n){var o,i;return(o=(i=this.featureFlags)===null||i===void 0?void 0:i.isFeatureEnabled(e,n))!==null&&o!==void 0?o:n?.defaultValue}reloadFeatureFlags(){var e;(e=this.featureFlags)===null||e===void 0||e.reloadFeatureFlags()}updateFlags(e,n,o){var i;(i=this.featureFlags)===null||i===void 0||i.updateFlags(e,n,o)}updateEarlyAccessFeatureEnrollment(e,n,o){var i;(i=this.featureFlags)===null||i===void 0||i.updateEarlyAccessFeatureEnrollment(e,n,o)}getEarlyAccessFeatures(e,n=!1,o){var i;return(i=this.featureFlags)===null||i===void 0?void 0:i.getEarlyAccessFeatures(e,n,o)}on(e,n){return this.du.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:Vk}),()=>{})}onSessionId(e){var n,o;return(n=(o=this.sessionManager)===null||o===void 0?void 0:o.onSessionId(e))!==null&&n!==void 0?n:()=>{}}getSurveys(e,n=!1){this.surveys?this.surveys.getSurveys(e,n):e([],{isLoaded:!1,error:Vk})}getActiveMatchingSurveys(e,n=!1){this.surveys?this.surveys.getActiveMatchingSurveys(e,n):e([],{isLoaded:!1,error:Vk})}onActiveMatchingSurveysChanged(e){return this.surveys?this.surveys.onActiveMatchingSurveysChanged(e):(e([],{isLoaded:!1,error:Vk}),()=>{})}renderSurvey(e,n){var o;(o=this.surveys)===null||o===void 0||o.renderSurvey(e,n)}displaySurvey(e,n=m9n){var o;(o=this.surveys)===null||o===void 0||o.displaySurvey(e,n)}cancelPendingSurvey(e){var n;(n=this.surveys)===null||n===void 0||n.cancelPendingSurvey(e)}canRenderSurvey(e){var n,o;return(n=(o=this.surveys)===null||o===void 0?void 0:o.canRenderSurvey(e))!==null&&n!==void 0?n:{visible:!1,disabledReason:Vk}}canRenderSurveyAsync(e,n=!1){var o,i;return(o=(i=this.surveys)===null||i===void 0?void 0:i.canRenderSurveyAsync(e,n))!==null&&o!==void 0?o:Promise.resolve({visible:!1,disabledReason:Vk})}Sh(e){return!e||JK(e)?(gi.critical("Unique user id has not been set in posthog.identify"),!1):e==="$posthog_cookieless"?(gi.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())||(gi.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,o){if(!this.__loaded||!this.persistence)return gi.uninitializedWarning("posthog.identify");if(qd(e)&&(e=e.toString(),gi.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!this.Sh(e)||!this.wh("posthog.identify"))return;this.ku();const i=this.get_distinct_id(),r=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==i,s=this.yh(!1),a=this.persistence.Fa();let A=!1;try{const l=this.get_distinct_id();this.register({$user_id:e}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:l},""),e!==l&&e!==this.get_property("__alias")&&(this.unregister(Zte),this.register({distinct_id:e}));const g=(this.persistence.get_property("$user_state")||"anonymous")===y8,u=e!==l,h=!u&&g;if(u&&g){var c;const d=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:l};this.persistence.set_property(my,tne),this.setPersonPropertiesForFlags({$set:n||{},$set_once:o||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.Da(),this.capture("$identify",d,{$set:n||{},$set_once:o||{}})&&(this.Lu=z2e(e,n,o)),(c=this.featureFlags)===null||c===void 0||c.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:l)}else if(h){this.persistence.set_property(my,tne);const d=n||{},p=o||{};this.setPersonPropertiesForFlags({$set:d,$set_once:p},!1),this.config.cookieWinsOnConflict&&this.persistence.Da(),this.capture("$set",{$set:d,$set_once:p})&&(this.Lu=z2e(e,n,o))}else(n||o)&&this.setPersonProperties(n,o);u||r||s?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(uQ)):h&&(n||o)&&this.reloadFeatureFlags(),A=!0}finally{a&&this.persistence.qa(A)}}setPersonProperties(e,n){if(!e&&!n||!this.wh("posthog.setPersonProperties"))return;const o=z2e(this.get_distinct_id(),e,n);this.Lu!==o?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:n||{}},!0),this.capture("$set",{$set:e||{},$set_once:n||{}})&&(this.Lu=o)):gi.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(e){var n;const o=(As(e)?e:[e]).filter(i=>nA(i)&&i.length>0);o.length!==0&&this.wh("posthog.unsetPersonProperties")&&((n=this.featureFlags)===null||n===void 0||n.unsetPersonPropertiesForFlags(o,!0),this.capture("$set",{$unset:o}),this.Lu=null)}group(e,n,o){var i;if(!e||!n)return void gi.error("posthog.group requires a group type and group key");(i=this.persistence)===null||i===void 0||i.syncCookieProperties(),this.yh();const r=this.getGroups(),s=r[e]!==n;if(s&&this.resetGroupPropertiesForFlags(e),this.register({$groups:sn(sn({},r),{},{[e]:n})}),(s||o)&&this._h()){const a={$group_type:e,$group_key:n};o&&(a.$group_set=o),this.capture(yst,a)}o&&this.setGroupPropertiesForFlags({[e]:o}),s&&!o&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,n=!0){var o;(o=this.featureFlags)===null||o===void 0||o.setPersonPropertiesForFlags(e,n)}resetPersonPropertiesForFlags(e=!0){var n;(n=this.featureFlags)===null||n===void 0||n.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,n=!0){var o;this.wh("posthog.setGroupPropertiesForFlags")&&((o=this.featureFlags)===null||o===void 0||o.setGroupPropertiesForFlags(e,n))}resetGroupPropertiesForFlags(e){var n;(n=this.featureFlags)===null||n===void 0||n.resetGroupPropertiesForFlags(e)}reset(e){const n=py(e)?e:e?.resetDeviceID,o=py(e)||e==null?void 0:e.bootstrap;this.xh(n,!1,o)}xh(e,n=!1,o){var i,r,s,a,A,c;if(gi.info("reset"),!this.__loaded)return gi.uninitializedWarning("posthog.reset");const l=o?.sessionID;this.config.bootstrap=o||((i=this.qu)===null||i===void 0?void 0:i.bootstrap)||{},(r=this.featureFlags)===null||r===void 0||(s=r.updateConfig)===null||s===void 0||s.call(r,this.config,this.il());const g=this.get_property($ye),u=this.get_property(Zye),h=this.get_property(ZK);(a=this.sessionRecording)===null||a===void 0||a.flushBeforeIdentityReset();const d=this.is_capturing();n||this.consent.reset(),n||!d||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");const p=(A=this.persistence)===null||A===void 0||(c=A.Fa)===null||c===void 0?void 0:c.call(A),m=this.Su;this.Su=m||n;let _=!1;try{var f,I,C,y,x,E,B,S,Q,w,M,k,R;if((f=this.persistence)===null||f===void 0||f.clear(),(I=this.sessionPersistence)===null||I===void 0||I.clear(),this.Eu.clear(),this.bh(),Eo(h)||(w=this.persistence)===null||w===void 0||w.register({$session_recording_remote_config:h}),(C=this.surveys)===null||C===void 0||C.reset(),(y=this.featureFlags)===null||y===void 0||y.reset(),(x=this.conversations)===null||x===void 0||x.reset(),(E=this.logs)===null||E===void 0||E.reset(),(B=this.metrics)===null||B===void 0||B.reset(),(S=this.persistence)===null||S===void 0||S.set_property("$user_state","anonymous"),(Q=this.sessionManager)===null||Q===void 0||Q.resetSessionId(),this.Lu=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:g2e,$device_id:null},"");else{const U=this.config.get_device_id(F4());this.register_once({distinct_id:U,$device_id:e?U:g},""),e||Eo(u)||this.register({[Zye]:u})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),o&&(o.distinctID&&!this.yu()&&((R=this.persistence)===null||R===void 0||R.set_property("$user_state",o.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:o.distinctID})),(M=this.featureFlags)===null||M===void 0||M.initialize(),!Fs(l)&&!(!((k=this.sessionManager)===null||k===void 0)&&k.setBootstrapSessionId(l,!0)))){const U=sn({},o);delete U.sessionID,this.config.bootstrap=U}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,_=!0}finally{var F,O;this.Su=m,p&&((F=this.persistence)===null||F===void 0||(O=F.qa)===null||O===void 0||O.call(F,_))}this.reloadFeatureFlags()}shutdown(e){var n=this;return Wg(function*(){var o,i,r,s,a,A,c,l;if(n.__loaded){n.Iu=!0,n.Zu().dispose(),(o=n.sessionRecording)===null||o===void 0||o.dispose(),(i=n.logs)===null||i===void 0||i.flushLogs("sendBeacon"),(r=n.metrics)===null||r===void 0||r.flush("sendBeacon"),(s=n.metrics)===null||s===void 0||s.dispose(),(a=n.Bu)===null||a===void 0||a.unload(),(A=n.zu)===null||A===void 0||A.unload();try{var g;(g=n.featureFlags)===null||g===void 0||g.destroy()}catch(u){gi.error("Error while destroying feature flags",u)}(c=n.persistence)===null||c===void 0||c.destroy(),(l=n.sessionPersistence)===null||l===void 0||l.destroy()}else gi.uninitializedWarning("posthog.shutdown")})()}setIdentity(e,n){var o;delete this.config.identity_claims,this.config.identity_distinct_id=e,this.config.identity_hash=n,this.alias(e),(o=this.conversations)===null||o===void 0||o.$h()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,(e=this.conversations)===null||e===void 0||e.Ch()}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||n===void 0?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";const{sessionId:n,sessionStartTimestamp:o}=this.sessionManager.checkAndGetSessionAndWindowId(!0);let i=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${n}`);if(e?.withTimestamp&&o){var r;const s=(r=e.timestampLookBack)!==null&&r!==void 0?r:10;if(!o)return i;i+=`?t=${Math.max(Math.floor((new Date().getTime()-o)/1e3)-s,0)}`}return i}alias(e,n){return e===this.get_property("$people_distinct_id")?(gi.critical("Attempting to create alias for existing People user - aborting."),-2):this.wh("posthog.alias")?(Eo(n)&&(n=this.get_distinct_id()),e!==n?(this.kh(Zte,e),this.capture("$create_alias",{alias:e,distinct_id:n})):(gi.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){const n=sn({},this.config);if(xA(e)){var o,i,r,s,a,A,c,l,g,u,h,d,p;jg(this.config,qat(e));const C=this.Cu();if(this.persistence){const x=this.config.persistence==="sessionStorage"||this.config.persistence==="memory";var m,_;if(x&&this.sessionPersistence!==this.persistence&&((m=this.sessionPersistence)===null||m===void 0||m.remove(),(_=this.sessionPersistence)===null||_===void 0||_.destroy()),this.persistence.update_config(this.config,n,C),x)this.sessionPersistence=this.persistence;else if(this.sessionPersistence===this.persistence)this.sessionPersistence=new D2e(sn(sn({},this.config),{},{persistence:"sessionStorage"}),C,!1);else{var f;(f=this.sessionPersistence)===null||f===void 0||f.update_config(sn(sn({},this.config),{},{persistence:"sessionStorage"}),sn(sn({},n),{},{persistence:"sessionStorage"}),C)}}const y=this.Nu(this.config.debug);var I;py(y)&&(this.config.debug=y),py(this.config.debug)&&(this.config.debug?(Ym.DEBUG=!0,uc.Et()&&uc.$t("ph_debug",!0),gi.info("set_config",{config:e,oldConfig:n,newConfig:sn({},this.config)})):(Ym.DEBUG=!1,uc.Et()&&uc.Pt("ph_debug"))),(o=this.featureFlags)===null||o===void 0||(i=o.updateConfig)===null||i===void 0||i.call(o,this.config,this.il()),(r=this.exceptionObserver)===null||r===void 0||r.onConfigChange(),(s=this.exceptions)===null||s===void 0||s.onConfigChange(),(a=this.metrics)===null||a===void 0||a.onConfigChange(),(A=this.sessionRecording)===null||A===void 0||A.startIfEnabledOrStop(),(c=this.tracingHeaders)===null||c===void 0||c.startIfEnabledOrStop(),(l=this.autocapture)===null||l===void 0||l.startIfEnabled(),(g=this.heatmaps)===null||g===void 0||g.startIfEnabled(),("capture_pageview"in e||"disable_capture_url_hashes"in e)&&((I=this.historyAutocapture)===null||I===void 0||I.startIfEnabledOrStop()),(u=this.exceptionObserver)===null||u===void 0||u.startIfEnabledOrStop(),(h=this.deadClicksAutocapture)===null||h===void 0||h.startIfEnabledOrStop(),(d=this.surveys)===null||d===void 0||d.loadIfEnabled(),this.xu(),(p=this.externalIntegrations)===null||p===void 0||p.startIfEnabledOrStop(),!n.segment&&this.config.segment&&this.persistence&&Jst(this,yV,!1)}}_overrideSDKInfo(e,n){Ym.LIB_NAME=e,Ym.LIB_VERSION=n}startSessionRecording(e){const n=e===!0,o={sampling:n||!!e?.sampling,linked_flag:n||!!e?.linked_flag,url_trigger:n||!!e?.url_trigger,event_trigger:n||!!e?.event_trigger};var i,r,s,a,A;Object.values(o).some(Boolean)&&((i=this.sessionManager)===null||i===void 0||i.checkAndGetSessionAndWindowId(),o.sampling&&((r=this.sessionRecording)===null||r===void 0||r.overrideSampling()),o.linked_flag&&((s=this.sessionRecording)===null||s===void 0||s.overrideLinkedFlag()),o.url_trigger&&((a=this.sessionRecording)===null||a===void 0||a.overrideTrigger("url")),o.event_trigger&&((A=this.sessionRecording)===null||A===void 0||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===void 0)&&e.started)}captureException(e,n){try{if(!this.exceptions)return;const o=this.exceptions.buildProperties(e,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(sn(sn({},o),n))}catch{return}}addExceptionStep(e,n){var o;(o=this.exceptions)===null||o===void 0||o.addExceptionStep(e,n)}captureLog(e){var n;(n=this.logs)===null||n===void 0||n.captureLog(e)}get logger(){var e,n;return(e=(n=this.logs)===null||n===void 0?void 0:n.logger)!==null&&e!==void 0?e:SM.Th}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var n,o;return(n=(o=this.toolbar)===null||o===void 0?void 0:o.loadToolbar(e))!==null&&n!==void 0&&n}get_property(e){var n;return(n=this.persistence)===null||n===void 0?void 0:n.props[e]}getSessionProperty(e){var n;return(n=this.sessionPersistence)===null||n===void 0?void 0:n.props[e]}toString(){var e;let n=(e=this.config.name)!==null&&e!==void 0?e:xV;return n!==xV&&(n="posthog."+n),n}_isIdentified(){var e,n;return((e=this.persistence)===null||e===void 0?void 0:e.get_property("$user_state"))==="identified"||((n=this.sessionPersistence)===null||n===void 0?void 0:n.get_property("$user_state"))==="identified"}_h(){var e,n;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&ox(this.getGroups())&&!(!((e=this.persistence)===null||e===void 0||(e=e.props)===null||e===void 0)&&e.__alias)&&!(!((n=this.persistence)===null||n===void 0||(n=n.props)===null||n===void 0)&&n.$epp))}sh(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&!!this.config.capture_pageview}createPersonProfile(){this._h()||this.wh("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.wh("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}wh(e){return this.config.person_profiles==="never"?(gi.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.bu(),this.kh(l2e,!0),!0)}Cu(){if(this.config.cookieless_mode==="always")return!0;const e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!=="on_reject")}xu(){var e,n;const o=this.Cu();var i,r,s;return this.is_capturing()||(i=this.logs)===null||i===void 0||i.Ih(),((e=this.persistence)===null||e===void 0?void 0:e.hi)!==o&&((r=this.persistence)===null||r===void 0||r.set_disabled(o)),((n=this.sessionPersistence)===null||n===void 0?void 0:n.hi)!==o&&((s=this.sessionPersistence)===null||s===void 0||s.set_disabled(o)),this.bh(),o}opt_in_capturing(e){var n;if(this.config.cookieless_mode!=="always"){if(this.yu()){var o,i,r,s,a,A;(o=this.sessionRecording)===null||o===void 0||o.dispose({discardBufferedEvents:!0}),this.xh(!0,!0),(i=this.sessionManager)===null||i===void 0||i.destroy(),(r=this.pageViewManager)===null||r===void 0||r.destroy(),this.sessionManager=new kat(this),this.pageViewManager=new Xst(this),this.persistence&&(this.sessionPropsManager=new Rat(this,this.sessionManager,this.persistence));const h=(s=(a=this.config.__extensionClasses)===null||a===void 0?void 0:a.sessionRecording)!==null&&s!==void 0?s:(A=SM.__defaultExtensionClasses)===null||A===void 0?void 0:A.sessionRecording;var c,l;h&&(this.sessionRecording=this.mu(this.sessionRecording,new h(this)),this.cu&&((c=this.sessionRecording)===null||c===void 0||(l=c.onRemoteConfig)===null||l===void 0||l.call(c,this.cu)))}var g,u;this.consent.optInOut(!0),this.xu(),this.eh(),(n=this.sessionRecording)===null||n===void 0||n.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&((g=this.surveys)===null||g===void 0||g.loadIfEnabled()),(Eo(e?.captureEventName)||e?.captureEventName)&&this.capture((u=e?.captureEventName)!==null&&u!==void 0?u:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.ih()}else gi.warn(Vat)}opt_out_capturing(){this.config.cookieless_mode!=="always"?(this.consent.optInOut(!1),this.xu(),this.config.cookieless_mode==="on_reject"&&this.$u()):gi.warn(Vat)}$u(){var e,n;const o=this.sessionRecording;o?.dispose({discardBufferedEvents:!0}),this.get_distinct_id()!=="$posthog_cookieless"&&this.xh(!0,!0),this.register({distinct_id:g2e,$device_id:null}),this.gu(o),this.sessionRecording=void 0,(e=this.sessionManager)===null||e===void 0||e.destroy(),(n=this.pageViewManager)===null||n===void 0||n.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.ih(),this.eh()}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){const e=this.consent.consent;return e===1?"granted":e===0?"denied":"pending"}is_capturing(){return!this.Su&&(this.config.cookieless_mode==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing()))}clear_opt_in_out_capturing(){this.consent.reset(),this.xu()}_is_bot(){return F_?Fat(F_,this.config.custom_blocked_useragents):void 0}ih(){No&&(No.visibilityState==="visible"?this.Ou||(this.Ou=!0,this.capture(p2e,{title:No.title},{send_instantly:!0}),this.Fu&&(No.removeEventListener(iV,this.Fu),this.Fu=null)):this.Fu||(this.Fu=this.ih.bind(this),jc(No,iV,this.Fu)))}debug(e){e===!1?(Fn?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(Fn?.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}))}il(){const e=this.qu||{};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?(gi.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,o,i,r,s){const a=o in n&&!Fs(n[o]),A=i in n&&!Fs(n[i]);return a?n[o]:!!A&&(s&&s.warn(`Config field '${i}' is deprecated. Please use '${o}' instead. The old field will be removed in a future major version.`),n[i])})(e,"advanced_disable_flags","advanced_disable_decide",0,gi)}Fs(e){var n;if(Fs(this.config.before_send))return e;const o=Object.keys((n=e.properties)!==null&&n!==void 0?n:{}).filter(e4n),i=As(this.config.before_send)?this.config.before_send:[this.config.before_send];let r=e;for(const s of i)try{if(r=s(r),Fs(r)){const a=`Event '${e.event}' was rejected in beforeSend function`;return Z5n(e.event)?gi.warn(`${a}. This can cause unexpected behavior.`):gi.info(a),null}r.properties&&!ox(r.properties)||gi.warn(`Event '${e.event}' has no properties after beforeSend function, this is likely an error.`)}catch(a){return gi.error(`Error in beforeSend function for event '${e.event}':`,a),null}for(const s of o)if(r.properties&&Fs(r.properties[s]))return gi.warn(`Event '${e.event}' had its '${s}' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return r}getPageViewId(){var e;return(e=this.pageViewManager.Wo)===null||e===void 0?void 0:e.pageViewId}captureTraceFeedback(e,n){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:n})}captureTraceMetric(e,n,o){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:n,$ai_metric_value:String(o)})}Nu(e){const n=py(e)&&!e,o=uc.Et()&&uc.Ot("ph_debug")==="true";return!n&&(!!o||e)}};EV.__defaultExtensionClasses={},EV.Th=(()=>{const t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),(function(t,e){for(let n=0;e.length>n;n++)t.prototype[e[n]]=xBn(t.prototype[e[n]])})(EV,["identify"]);var $at=class{constructor(e){this.disabled=e===!1;const n=xA(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,o){if(this.disabled)return!1;const i=this.clicks[this.clicks.length-1];if(i&&Math.abs(e-i.x)+Math.abs(n-i.y)<this.thresholdPx&&this.timeoutMs>o-i.timestamp){if(this.clicks.push({x:e,y:n,timestamp:o}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:n,timestamp:o}];return!1}};const X2e="$copy_autocapture",q2e=Ad("[AutoCapture]");function $2e(t,e){return e.length>t?e.slice(0,t)+"...":e}function P9n(t){if(t.previousElementSibling)return t.previousElementSibling;let e=t;do e=e.previousSibling;while(e&&!b9(e));return e}function M9n(t,{e,maskAllElementAttributes:n,maskAllText:o,elementAttributeIgnoreList:i,elementsChainAsString:r,disableCaptureUrlHashes:s}){var a,A;if(!b9(t))return{props:{}};const c=[t],l=new Set([t]);let g=t;for(;g.parentNode&&!j1(g,"body")&&1e3>c.length;){if(B2e(g.parentNode)){const x=g.parentNode.host;if(l.has(x))break;l.add(x),c.push(x),g=x;continue}if(!b9(g.parentNode)||l.has(g.parentNode))break;l.add(g.parentNode),c.push(g.parentNode),g=g.parentNode}const u=e.type==="click"&&t.namespaceURI==="http://www.w3.org/2000/svg"?c.findIndex(x=>j1(x,"button")||j1(x,"a")):-1;u>0&&(o=o||c.slice(0,u+1).some(x=>!Fk(x)||cV(x)));const h=[],d={};let p,m=!1,_=!1;if(vl(c,x=>{const E=Fk(x);if(j1(x,"a")&&!n&&!i?.includes("href")){const B=x.getAttribute("href");m=!!(E&&B&&lV(B))&&(s?AQ(B):B)}as(kk(x),"ph-no-capture")&&(_=!0),h.push((function(B,S,Q,w,M=!1){const k=B.tagName.toLowerCase(),R={tag_name:k};S2e.indexOf(k)>-1&&!Q&&(R.$el_text=k.toLowerCase()==="a"||k.toLowerCase()==="button"?$2e(1024,Ust(B)):$2e(1024,aV(B)));const F=kk(B);S||w?.includes("class")||0>=F.length||(R.classes=F.filter(function(J){return J!==""})),vl(B.attributes,function(J){var ee;if((!cV(B)||["name","id","class","aria-label"].indexOf(J.name)!==-1)&&!w?.includes(J.name)&&!S&&lV(J.value)&&(!nA(ee=J.name)||ee.substring(0,10)!=="_ngcontent"&&ee.substring(0,7)!=="_nghost")){let W=J.value;J.name==="class"&&(W=b2e(W).join(" ")),R["attr__"+J.name]=$2e(1024,J.name==="href"&&M?AQ(W):W)}});let O=1,U=1,Y=B;for(;Y=P9n(Y);)O++,Y.tagName===B.tagName&&U++;return R.nth_child=O,R.nth_of_type=U,R})(x,n,o,i,s)),vl((function(B){if(!Fk(B))return{};const S={};return vl(B.attributes,function(Q){if(Q.name&&Q.name.indexOf("data-ph-capture-attribute")===0){const w=Q.name.replace("data-ph-capture-attribute-",""),M=Q.value;w&&M&&lV(M)&&(S[w]=M)}}),S})(x),(B,S)=>{({}).hasOwnProperty.call(d,S)||(d[S]=B)})}),_)return{props:{},explicitNoCapture:_};if(u>0&&(t=c[u],h.splice(0,u)),o||(h[0].$el_text=j1(t,"a")||j1(t,"button")?Ust(t):aV(t)),m){var f,I;h[0].attr__href=m;const x=(f=x8(m))===null||f===void 0?void 0:f.host,E=Fn==null||(I=Fn.location)===null||I===void 0?void 0:I.host;x&&E&&x!==E&&(p=m)}return{props:jg((y=e.type,{$event_type:y,$ce_version:1}),r?{}:{$elements:h},{$elements_chain:(C=h,As(C)?(function(x){return x.map(E=>{var B,S;let Q="";if(E.tag_name&&(Q+=E.tag_name),E.attr_class){E.attr_class.sort();for(const k of E.attr_class)Q+=`.${k.replace(/"/g,"")}`}const w=sn(sn(sn(sn({},E.text?{text:E.text}:{}),{},{"nth-child":(B=E.nth_child)!==null&&B!==void 0?B:0,"nth-of-type":(S=E.nth_of_type)!==null&&S!==void 0?S:0},E.href?{href:E.href}:{}),E.attr_id?{attr_id:E.attr_id}:{}),E.attributes),M={};return one(w).sort(([k],[R])=>(function(F,O){return O>F?-1:F>O?1:0})(k,R)).forEach(([k,R])=>M[Vst(k.toString())]=Vst(R.toString())),Q+=":",Q+=one(M).map(([k,R])=>`${k}="${R}"`).join(""),Q}).join(";")})((function(x){return x.map(E=>{var B,S;const Q={text:(B=E.$el_text)===null||B===void 0?void 0:B.slice(0,400),tag_name:E.tag_name,href:(S=E.attr__href)===null||S===void 0?void 0:S.slice(0,2048),attr_class:FBn(E),attr_id:E.attr__id,nth_child:E.nth_child,nth_of_type:E.nth_of_type,attributes:{}};return one(E).filter(([w])=>w.indexOf("attr__")===0).forEach(([w,M])=>Q.attributes[w]=M),Q})})(C)):"")},!((a=h[0])===null||a===void 0)&&a.$el_text?{$el_text:(A=h[0])===null||A===void 0?void 0:A.$el_text}:{},p&&e.type==="click"?{$external_click_url:p}:{},d),target:t};var C,y}var D9n=class{do(){this.vo=void 0,clearTimeout(this.fo),this.fo=void 0}po(e){var n;if(!Fk(e))return!0;const o=(n=this.mo().css_selector_ignorelist)!==null&&n!==void 0?n:w2e,i=new Set;let r=e;for(;r;){if(i.size>=1e3||i.has(r))return!0;i.add(r);const s=r,a=kk(s);if(as(a,"ph-no-capture")||as(a,"ph-sensitive")||cV(s)||o.some(c=>Q2e(s,c)))return!0;const A=r.parentNode;r=B2e(A)?A.host:A&&b9(A)?A:null}return!1}yo(e){if(!this.isEnabled||e.type==="pointercancel")return void this.do();if(e.type==="pointerdown"){this.do();const i=AV(e);var n;return void(e.isPrimary&&e.button===0&&!e.ctrlKey&&i&&b9(i)&&(this.vo={target:i,excluded:this.po(i),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:(n=this.bo)===null||n===void 0?void 0:n.distinctId}))}const o=this.vo;o&&(e.pointerId!==o.id||Math.abs(e.clientX-o.x)>5||Math.abs(e.clientY-o.y)>5?this.do():e.type==="pointerup"&&(o.released=!0,this.fo=setTimeout(()=>this.do(),0)))}_o(e){var n;const o=this.vo;this.do();const i=AV(e);if(o?.released&&o.target.isConnected&&o.distinctId===((n=this.bo)===null||n===void 0?void 0:n.distinctId)&&e.pointerId===o.id&&(e.detail>0||e.pointerType==="touch"||e.pointerType==="pen")&&e.button===0&&5>=Math.abs(e.clientX-o.x)&&5>=Math.abs(e.clientY-o.y)&&i&&(j1(i,"html")||j1(i,"body"))){var r;if(o.excluded)return null;const s=(r=this.mo().css_selector_ignorelist)!==null&&r!==void 0?r:w2e;return[i,No?.documentElement,No?.body].some(a=>{if(!a)return!1;const A=kk(a);return as(A,"ph-no-capture")||as(A,"ph-sensitive")||!Fk(a)||cV(a)||s.some(c=>Q2e(a,c))})?null:o.target}}constructor(e){this.wo=e,this.name="autocapture",this.ko=!1,this.So=null,this.xo=!1,this.$o=new Map,this.Co=!1,this.Mr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.To=!1,this.wo.refresh(this.Mr),this.rageclicks=new $at(this.Mr.rageclick),this.Io=null}setup(e){this.Mo(),this.bo=e;const n=e.onRemoteConfig(this.onRemoteConfig.bind(this));this.To?n.dispose():(this.Eo=n,this.startIfEnabled())}dispose(){var e;this.To||(this.To=!0,this.bo=void 0,(e=this.Eo)===null||e===void 0||e.dispose(),this.Eo=void 0,this.$o.clear(),this.Io=null,this.Po())}mo(){return this.wo.refresh(this.Mr),this.Mr}Mo(){var e,n;return this.mo(),this.Mr.url_allowlist=(e=this.Mr.url_allowlist)===null||e===void 0?void 0:e.map(o=>new RegExp(o)),this.Mr.url_ignorelist=(n=this.Mr.url_ignorelist)===null||n===void 0?void 0:n.map(o=>new RegExp(o)),this.Mr}Ro(){if(!this.isBrowserSupported())return void q2e.info("Disabling Automatic Event Collection because this browser is not supported");if(!Fn||!No)return;const e=this.Ao=n=>{n=n||Fn?.event;try{if(n.type==="blur")return void this.do();if(n.type.indexOf("pointer")===0)return void this.yo(n);const o=n.type==="click"?this._o(n):void 0;if(ad(o))return;this.Oo(n,"$autocapture",o)}catch(o){q2e.error("Failed to capture event",o)}};if(jc(Fn,"blur",e),jc(No,"submit",e,{capture:!0}),jc(No,"change",e,{capture:!0}),jc(No,"click",e,{capture:!0}),vl(["pointerdown","pointermove","pointerup","pointercancel"],n=>{jc(No,n,e,{capture:!0})}),this.mo().capture_copied_text){const n=this.Fo=o=>{o=o||Fn?.event;try{this.Oo(o,X2e)}catch(i){q2e.error("Failed to capture clipboard event",i)}};jc(No,"copy",n,{capture:!0}),jc(No,"cut",n,{capture:!0}),jc(No,"paste",n,{capture:!0})}}Po(){this.do(),this.Ao&&(Fn?.removeEventListener("blur",this.Ao),vl(["pointerdown","pointermove","pointerup","pointercancel"],e=>{No?.removeEventListener(e,this.Ao,!0)}),No?.removeEventListener("submit",this.Ao,!0),No?.removeEventListener("change",this.Ao,!0),No?.removeEventListener("click",this.Ao,!0),this.Ao=void 0),this.Fo&&(No?.removeEventListener("copy",this.Fo,!0),No?.removeEventListener("cut",this.Fo,!0),No?.removeEventListener("paste",this.Fo,!0),this.Fo=void 0),this.ko=!1}startIfEnabled(){this.isEnabled||this.do(),!this.To&&this.bo&&this.isEnabled&&!this.ko&&(this.Ro(),this.ko=!0)}onRemoteConfig(e){if(this.To)return;if(this.xo=!0,!e.ok)return void this.startIfEnabled();const n=e.config;n.elementsChainAsString&&(this.Co=n.elementsChainAsString);const o=n.autocapture_opt_out;var i;py(o)&&((i=this.bo)===null||i===void 0||i.kv.set("$autocapture_disabled_server_side",o),this.So=o),this.startIfEnabled()}setElementSelectors(e,n=this){if(this.To)return;e.size?this.$o.set(n,new Set(e)):this.$o.delete(n);const o=new Set;this.$o.forEach(i=>{i.forEach(r=>o.add(r))}),this.Io=o}getElementSelectors(e,n){var o;const i=[];return(o=this.Io)===null||o===void 0||o.forEach(r=>{const s=No?.querySelectorAll(r);s?.forEach(a=>{e!==a&&n!==a||as(i,r)||i.push(r)})}),i}get isEnabled(){var e,n;if(this.To)return!1;const o=(e=this.bo)===null||e===void 0?void 0:e.kv.get(qrt),i=this.So,r=this.mo();if(!r.remoteRequestsDisabled&&!this.xo)return!1;const s=r.remoteRequestsDisabled&&!this.xo;if(ad(i)&&!py(o)&&!s)return!1;const a=(n=this.So)!==null&&n!==void 0?n:!!o;return!!r.enabled&&!a}Oo(e,n="$autocapture",o){if(!this.isEnabled)return void this.do();let i=o||AV(e);Pst(i)&&(i=i.parentNode||null);const r=this.Mo();var s;n==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&r.rageclick&&(!((s=this.rageclicks)===null||s===void 0)&&s.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime()))&&Fst(i,r.rageclick)&&this.Oo(e,"$rageclick",o);const a=n===X2e,A=a?sn(sn({},r),{},{dom_event_allowlist:void 0}):r;if(i&&(function(u,h,d,p,m,_){var f;if(!Fn||P2e(u)||d?.url_allowlist&&!Mst(d.url_allowlist,_)||d?.url_ignorelist&&Mst(d.url_ignorelist,_))return!1;if(d?.dom_event_allowlist){const x=d.dom_event_allowlist;if(x&&!x.some(E=>h.type===E))return!1}const{parentIsUsefulElement:I,targetElementList:C}=Lst(u,p);if(!(function(x,E){const B=E?.element_allowlist;if(Eo(B))return!0;for(const S of x)if(B.some(Q=>S.tagName.toLowerCase()===Q))return!0;return!1})(C,d)||!v2e(C,d?.css_selector_allowlist)||v2e(C,(f=d?.css_selector_ignorelist)!==null&&f!==void 0?f:w2e))return!1;try{const x=Fn.getComputedStyle(u);if(x&&x.getPropertyValue("cursor")==="pointer"&&h.type==="click")return!0}catch{}const y=u.tagName.toLowerCase();switch(y){case"html":return!1;case"form":return(m||["submit"]).indexOf(h.type)>=0;case"input":case"select":case"textarea":return(m||["change","click"]).indexOf(h.type)>=0;default:return I?(m||["click"]).indexOf(h.type)>=0:(m||["click"]).indexOf(h.type)>=0&&(S2e.indexOf(y)>-1||u.getAttribute("contenteditable")==="true")}})(i,e,A,a,a?["copy","cut","paste"]:void 0,{config:{get_current_url:r.getCurrentUrl}})){var c;const{props:u,explicitNoCapture:h,target:d}=M9n(i,{e,maskAllElementAttributes:r.maskAllElementAttributes,maskAllText:r.maskAllText,elementAttributeIgnoreList:r.element_attribute_ignorelist,elementsChainAsString:this.Co,disableCaptureUrlHashes:r.disableCaptureUrlHashes});if(h)return!1;const p=this.getElementSelectors(i,d);if(p&&p.length>0&&(u.$element_selectors=p),n===X2e){const m=e.type||"clipboard";if(m!=="paste"){var l,g;const _=Fn==null||(l=Fn.getSelection())===null||l===void 0?void 0:l.toString(),f=Dst(_);if(!f)return!1;u.$selected_content=f,u.$clipboard_text_length=(g=_?.length)!==null&&g!==void 0?g:0}u.$copy_type=m}return(c=this.bo)===null||c===void 0||c.capture(n,u),!0}}isBrowserSupported(){return L_(No?.querySelectorAll)}},N9n=class{constructor(e){this._instance=e}refresh(e){const n=this._instance.config,o=xA(n.autocapture)?n.autocapture:void 0;e.enabled=!!n.autocapture,e.rageclick=n.rageclick,e.maskAllElementAttributes=n.mask_all_element_attributes,e.maskAllText=n.mask_all_text,e.disableCaptureUrlHashes=n.disable_capture_url_hashes,e.getCurrentUrl=n.get_current_url,e.remoteRequestsDisabled=this._instance.il(),e.url_allowlist=o?.url_allowlist,e.url_ignorelist=o?.url_ignorelist,e.dom_event_allowlist=o?.dom_event_allowlist,e.element_allowlist=o?.element_allowlist,e.css_selector_allowlist=o?.css_selector_allowlist,e.css_selector_ignorelist=o?.css_selector_ignorelist,e.element_attribute_ignorelist=o?.element_attribute_ignorelist,e.capture_copied_text=o?.capture_copied_text}};const BV=Ad("[ExceptionAutocapture]"),Zat=()=>{},eAt=t=>{var e;if(L_(t))return(e=t.__posthog_layer__)!==null&&e!==void 0?e:t.__rrweb_layer__};function bV(t,e,n){try{if(!(e in t))return Zat;const o={next:t[e]},i=n(function(...r){return o.next.apply(this,r)});return L_(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:o}})),t[e]=i,()=>{if(t[e]===i)return void(t[e]=o.next);let r=t[e],s=eAt(r);for(;s;){if(s.next===i)return void(s.next=o.next);r=s.next,s=eAt(r)}}}catch{return Zat}}const R9n=Ad("[TracingHeaders]"),HM=Ad("[Web Vitals]"),tAt=9e5,nAt=["CLS","FCP","INP","LCP"],T9n=["INP","LCP"],k9n=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Z2e="disabled",oAt="lazy_loading",b8=Ad("[SessionRecording]"),F9n=[u2e,d2e,gst,ust,dst,hst,pst,mst,_st],L9n=Ad("[Heatmaps]");function exe(t){return xA(t)&&"clientX"in t&&"clientY"in t&&qd(t.clientX)&&qd(t.clientY)}const mne=Ad("[Product Tours]"),txe=t=>{var e;return!t.config.disable_product_tours&&!!(!((e=t.persistence)===null||e===void 0)&&e.get_property(s2e))},H9n=["$set_once","$set"],S9=Ad("[SiteApps]"),iAt="Error while initializing PostHog app with config id ",rAt=(t,e)=>t?.then?t.then(e):e(t),zk="SDK is not enabled or survey functionality is not yet loaded",sAt="Disabled. Not loading surveys.";var O9n=class{constructor(e,n){this.wo=e,this.Mh=n,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Eh=!1,this.Ph=!1,this.Rh=[],this.Ah=[],this.Oh=null,this.Fh=null,this.To=!1,this.Dh=new Set,this.onRemoteConfig=o=>{if(this.To||this.Mr.disableSurveys)return;if(!o.ok)return this.Ph=!0,this.Lh({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),_l.warn("Remote config unavailable. Not loading surveys.");const i=o.config.surveys;if(Fs(i))return _l.warn("Flags not loaded yet. Not loading surveys.");this.Nh=py(i)?i:i.length>0,_l.info(`flags response received, isSurveysEnabled: ${this.Nh}`),this.loadIfEnabled()},this.Lh=o=>{this.Ah.slice().forEach(i=>this.qh(i,o))}}setup(e){if(!this.To)return this.jh=e,rAt(e.kv.initialize(),()=>{if(this.jh!==e||this.To)return;this.jh=void 0,this.bo=e;const n=e.onRemoteConfig(this.onRemoteConfig);this.To?n.dispose():(this.Eo=n,this.loadIfEnabled())})}dispose(){var e,n,o,i,r;this.To||(this.To=!0,this.jh=void 0,this.bo=void 0,(e=this.Eo)===null||e===void 0||e.dispose(),this.Eo=void 0,(n=this._surveyEventReceiver)===null||n===void 0||n.dispose(),this._surveyEventReceiver=null,(o=this._surveyManager)===null||o===void 0||(i=o.dispose)===null||i===void 0||i.call(o),this._surveyManager=null,this.Rh=[],this.Ah.forEach(s=>{s.active=!1}),this.Ah=[],(r=this.Bh)===null||r===void 0||r.call(this),this.Bh=void 0,this.Oh=null,this.Dh.forEach(s=>clearTimeout(s)),this.Dh.clear())}get Mr(){return this.wo.get()}initialize(){this.loadIfEnabled()}reset(){var e,n;(e=this._surveyManager)===null||e===void 0||(n=e.clearInMemoryInProgressSurveyState)===null||n===void 0||n.call(e);try{var o;(o=this._surveyEventReceiver)===null||o===void 0||o.reset(),localStorage.removeItem("lastSeenSurveyDate");const i=[];for(let r=0;r<localStorage.length;r++){const s=localStorage.key(r);(s?.startsWith("seenSurvey_")||s?.startsWith("inProgressSurvey_"))&&i.push(s)}i.forEach(r=>localStorage.removeItem(r))}catch{}this.Lh()}loadIfEnabled(){if(this.To||!this.bo)return;const e=this.Mr;if(this._surveyManager)return;if(this.Eh)return void _l.info("Already initializing surveys, skipping...");if(e.disableSurveys)return void _l.info(sAt);if(e.cookielessMode&&this.wo.isOptedOut())return void _l.info("Not loading surveys in cookieless mode without consent.");const n=this.wo.getExtensions();if(!n)return void this.Hh("PostHog Extensions not found.");if(Eo(this.Nh)&&!e.advancedEnableSurveys)return;const o=this.Nh||e.advancedEnableSurveys;this.Eh=!0,this.Ph=!1;try{const i=n.generateSurveys;if(i)return this.zh(i,o),void(this.Eh=!1);const r=n.loadExternalDependency;if(!r)return this.Hh(h2e),void(this.Eh=!1);r(s=>{try{if(this.To)return;const a=this.wo.getExtensions();s||!a?.generateSurveys?this.Hh("Could not load surveys script",s):this.zh(a.generateSurveys,o)}finally{this.Eh=!1}})}catch(i){throw this.Eh=!1,this.Hh("Error initializing surveys",i),i}}zh(e,n){var o,i;if(this.To)return;this._surveyManager=e(n),this._surveyEventReceiver=this.wo.createEventReceiver(this.Lh);const r=(o=(i=this.bo)!==null&&i!==void 0?i:this.Mh)===null||o===void 0?void 0:o.kv.get(tV);r&&this.Uh(r),_l.info("Surveys loaded successfully"),this.Wh(),this.Lh(),this.Vh({isLoaded:!0})}Hh(e,n){this.Ph=!0,_l.error(e,n),this.Lh({isLoaded:!1,error:e}),this.Vh({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.Rh.push(e),this._surveyManager&&this.Vh({isLoaded:!0}),()=>{this.Rh=this.Rh.filter(n=>n!==e)}}getSurveys(e,n=!1){var o;const i=(o=this.bo)!==null&&o!==void 0?o:this.Mh;if(!i||this.To)return;if(this.Mr.disableSurveys)return _l.info(sAt),e([]);const r=i.kv.get(tV);if(r&&!n)return e(r,{isLoaded:!0}),void(this.Gh()&&this.getSurveys(()=>{},!0));if(this.Oh)return void this.Oh.then(({surveys:A,context:c})=>{this.To||e(A,c)}).catch(A=>_l.error("Error in survey callback",A));const s=this.Qh("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.Mr.requestTimeoutMs}).then(A=>{try{return this.Jh(i,A)}catch(c){return _l.error("Error processing surveys response",c),this.Jh(i,{statusCode:0,error:c})}},A=>this.Jh(i,{statusCode:0,error:A}));this.Oh=s;const a=()=>{this.Oh===s&&(this.Oh=null)};s.then(A=>{a(),this.To||(this.Lh(A.context),e(A.surveys,A.context))},a).catch(A=>_l.error("Error in survey callback",A))}Qh(e,n){const o=this.bo;return o?o.sendRequest(e,n):new Promise(i=>i({statusCode:0,error:new Error(zk)}))}Jh(e,n){if(this.To)return{surveys:[],context:{isLoaded:!1,error:zk}};const o=n.statusCode;if(o!==200||!n.json){const r=`Surveys API could not be loaded, status: ${o}`;return o!==0?_l.error(r):n.error||_l.warn(r),this.Fh=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Fh=null;const i=n.json.surveys||[];return e.kv.set({[tV]:i,[ene]:Date.now()}),this.Uh(i),{surveys:i,context:{isLoaded:!0}}}Uh(e){var n;const o=e.filter(i=>(function(r){return!(!r.start_date||r.end_date)})(i)&&(Hat(i)||(function(r){var s;return!!(!((s=r.conditions)===null||s===void 0||(s=s.actions)===null||s===void 0||(s=s.values)===null||s===void 0)&&s.length)})(i)));(n=this._surveyEventReceiver)===null||n===void 0||n.replace(o)}Gh(){return this.Zh()&&!this.Oh&&!this.Kh()}Zh(){var e,n;const o=(e=(n=this.bo)!==null&&n!==void 0?n:this.Mh)===null||e===void 0?void 0:e.kv.get(ene);return qd(o)&&Date.now()-o>3e5}Kh(){return qd(this.Fh)&&3e5>Date.now()-this.Fh}markSurveyAsSeen(e,n){var o;const i={id:e,current_iteration:(o=n?.iteration)!==null&&o!==void 0?o:null};Uat(i);try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}this.Lh()}Vh(e){for(const n of this.Rh)try{if(!e.isLoaded)return n([],e);this.getSurveys(n)}catch(o){_l.error("Error in survey callback",o)}}getActiveMatchingSurveys(e,n=!1){if(!Fs(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,n);_l.warn("init was not called")}onActiveMatchingSurveysChanged(e){var n,o;if(this.To)return()=>{};const i={callback:e,active:!0,revision:0};this.Ah.push(i),this.Wh();const r=(n=(o=this.bo)!==null&&o!==void 0?o:this.Mh)===null||n===void 0?void 0:n.kv.get(tV);return this.Mr.disableSurveys||!this._surveyManager&&this.Ph&&!this.Eh||!r&&!Fs(this.Fh)&&!this.Oh?this.qh(i,{isLoaded:!1}):this._surveyManager&&this.qh(i),()=>{var s;i.active=!1,this.Ah=this.Ah.filter(a=>a!==i),this.Ah.length===0&&((s=this.Bh)===null||s===void 0||s.call(this),this.Bh=void 0)}}Wh(){var e,n,o;this._surveyManager&&this.Ah.length>0&&((e=this.Bh)!==null&&e!==void 0||(this.Bh=(n=(o=this.wo).onMatchingConditionsChanged)===null||n===void 0?void 0:n.call(o,this.Lh)))}qh(e,n){if(this.To||!e.active)return;const o=++e.revision,i=r=>{if(!this.To&&e.active&&o===e.revision)try{const s=n??{isLoaded:!0},a=JSON.stringify([r,s]);if(a===e.lastResult)return;e.lastResult=a,e.callback(r,s)}catch(s){_l.error("Error in active matching surveys callback",s)}};try{n&&!n.isLoaded?i([]):this.getActiveMatchingSurveys(i)}catch(r){_l.error("Error in active matching surveys callback",r)}}Xh(e){let n=null;return this.getSurveys(o=>{var i;n=(i=o.find(r=>r.id===e))!==null&&i!==void 0?i:null}),n}Yh(e){if(Fs(this._surveyManager))return{eligible:!1,reason:zk};const n=typeof e=="string"?this.Xh(e):e;return n?this._surveyManager.checkSurveyEligibility(n):{eligible:!1,reason:"Survey not found"}}tc(e){if(!this.wo.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(Fs(this._surveyManager))return{eligible:!1,reason:zk};const n=typeof e=="string"?this.Xh(e):e;return n?this._surveyManager.checkSurveyRenderability(n):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(Fs(this._surveyManager))return _l.warn("init was not called"),{visible:!1,disabledReason:zk};const n=this.tc(e);return{visible:n.eligible,disabledReason:n.reason}}canRenderSurveyAsync(e,n){return Fs(this._surveyManager)?(_l.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:zk})):new Promise(o=>{this.getSurveys(i=>{var r;const s=(r=i.find(a=>a.id===e))!==null&&r!==void 0?r:null;if(s){const a=this.tc(s);o({visible:a.eligible,disabledReason:a.reason})}else o({visible:!1,disabledReason:"Survey not found"})},n)})}renderSurvey(e,n,o){var i;if(!this.wo.isCapturing())return;if(Fs(this._surveyManager))return void _l.warn("init was not called");const r=typeof e=="string"?this.Xh(e):e;if(!r?.id)return void _l.warn("Survey not found");if(!p9n.includes(r.type))return void _l.warn(`Surveys of type ${r.type} cannot be rendered in the app`);const s=No?.querySelector(n);if(s){if(!((i=r.appearance)===null||i===void 0)&&i.surveyPopupDelaySeconds){_l.info(`Rendering survey ${r.id} with delay of ${r.appearance.surveyPopupDelaySeconds} seconds`);const a=setTimeout(()=>{var A,c;this.Dh.delete(a),!this.To&&this.wo.isCapturing()&&(_l.info(`Rendering survey ${r.id} with delay of ${(A=r.appearance)===null||A===void 0?void 0:A.surveyPopupDelaySeconds} seconds`),(c=this._surveyManager)===null||c===void 0||c.renderSurvey(r,s,o),_l.info(`Survey ${r.id} rendered`))},1e3*r.appearance.surveyPopupDelaySeconds);return void this.Dh.add(a)}this._surveyManager.renderSurvey(r,s,o)}else _l.warn("Survey element not found")}displaySurvey(e,n){var o;if(!this.wo.isCapturing())return;if(Fs(this._surveyManager))return void _l.warn("init was not called");const i=this.Xh(e);if(!i)return void _l.warn("Survey not found");let r=i;if(!((o=i.appearance)===null||o===void 0)&&o.surveyPopupDelaySeconds&&n.ignoreDelay&&(r=sn(sn({},i),{},{appearance:sn(sn({},i.appearance),{},{surveyPopupDelaySeconds:0})})),n.displayType!==T2e.Popover&&n.initialResponses&&_l.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),n.ignoreConditions===!1){const s=this.Yh(i);if(!s.eligible)return void _l.warn("Survey is not eligible to be displayed: ",s.reason)}n.displayType!==T2e.Inline?this._surveyManager.handlePopoverSurvey(r,n):this.renderSurvey(r,n.selector,n.properties)}cancelPendingSurvey(e){Fs(this._surveyManager)?_l.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e,n;(e=this._surveyManager)===null||e===void 0||(n=e.handlePageUnload)===null||n===void 0||n.call(e)}};function Jk(t,e,n){if(Fs(t))return!1;switch(n){case"exact":return t===e;case"contains":{const o=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(o,"i").test(t)}case"regex":try{return new RegExp(e).test(t)}catch{return!1}default:return!1}}var G9n=class{constructor(e){this._instance=e,this.ec=new Set,this.nc=new Set,this.sc=new dne,this.rc=(n,o)=>this.oc(n,o)&&this.ac(n,o)&&this.lc(n,o)&&this.uc(n,o),this.oc=(n,o)=>!o?.event||n?.event===o?.event}init(){var e,n;Eo((e=this._instance)===null||e===void 0?void 0:e._addCaptureHook)||(this.hc=(n=this._instance)===null||n===void 0?void 0:n._addCaptureHook((o,i)=>{this.on(o,i)}))}dispose(){var e,n;(e=this.hc)===null||e===void 0||e.call(this),this.hc=void 0,(n=this._instance)===null||n===void 0||(n=n.autocapture)===null||n===void 0||n.setElementSelectors(new Set,this),this.sc=new dne}register(e){var n,o;if(!Eo((n=this._instance)===null||n===void 0?void 0:n._addCaptureHook)&&(e.forEach(i=>{var r;this.ec.add(i),(r=i.steps)===null||r===void 0||r.forEach(s=>{this.nc.add(s?.event||"")})}),(o=this._instance)===null||o===void 0?void 0:o.autocapture)){const i=new Set;this.ec.forEach(r=>{var s;(s=r.steps)===null||s===void 0||s.forEach(a=>{a?.selector&&i.add(a.selector)})}),this._instance.autocapture.setElementSelectors(i,this)}}replace(e){this.ec.clear(),this.nc.clear(),this.register(e)}on(e,n){n!=null&&e.length!=0&&(this.nc.has(e)||this.nc.has(n.event))&&this.ec.forEach(o=>{this.cc(n,o)&&this.sc.emit("actionCaptured",o.name)})}dc(e){this.onAction("actionCaptured",n=>e(n))}cc(e,n){if(n?.steps==null)return!1;for(const o of n.steps)if(this.rc(e,o))return!0;return!1}onAction(e,n){return this.sc.on(e,n)}ac(e,n){if(n?.url){var o;const i=e==null||(o=e.properties)===null||o===void 0?void 0:o.$current_url;if(!i||typeof i!="string"||!Jk(i,n.url,n.url_matching||"contains"))return!1}return!0}lc(e,n){return!!this.vc(e,n)&&!!this.fc(e,n)&&!!this.gc(e,n)}vc(e,n){var o;if(!n?.href)return!0;const i=this.mc(e);if(i.length>0)return i.some(s=>Jk(s.href,n.href,n.href_matching||"exact"));const r=(e==null||(o=e.properties)===null||o===void 0?void 0:o.$elements_chain)||"";return!!r&&Jk((function(s){const a=s.match(/(?::|")href="(.*?)"/);return a?a[1]:""})(r),n.href,n.href_matching||"exact")}fc(e,n){var o;if(!n?.text)return!0;const i=this.mc(e);if(i.length>0)return i.some(c=>Jk(c.text,n.text,n.text_matching||"exact")||Jk(c.$el_text,n.text,n.text_matching||"exact"));const r=(e==null||(o=e.properties)===null||o===void 0?void 0:o.$elements_chain)||"";return!!r&&(s=(function(c){const l=[],g=/(?::|")text="(.*?)"/g;let u;for(;!Fs(u=g.exec(c));)l.includes(u[1])||l.push(u[1]);return l})(r),a=n.text,A=n.text_matching||"exact",s.some(c=>Jk(c,a,A)));var s,a,A}gc(e,n){var o,i;if(!n?.selector)return!0;const r=e==null||(o=e.properties)===null||o===void 0?void 0:o.$element_selectors;if(r?.includes(n.selector))return!0;const s=(e==null||(i=e.properties)===null||i===void 0?void 0:i.$elements_chain)||"";if(n.selector_regex&&s)try{return new RegExp(n.selector_regex).test(s)}catch{return!1}return!1}mc(e){var n;return(e==null||(n=e.properties)===null||n===void 0?void 0:n.$elements)==null?[]:e?.properties.$elements}uc(e,n){return!n?.properties||n.properties.length===0||Gat(n.properties.reduce((o,i)=>{const r=As(i.value)?i.value.map(String):i.value!=null?[String(i.value)]:[];return o[i.key]={values:r,operator:i.operator||"exact"},o},{}),e?.properties)}},Y9n=class{constructor(e,n){var o,i;this.yc=[],this._instance=e,this.bc=n,this._c=new Map,this.wc=new Map,this.kc=new Map,this.Sc=(o=this._instance)===null||o===void 0||(i=o.onSessionId)===null||i===void 0?void 0:i.call(o,r=>this.xc(r))}$c(e){return!1}Cc(){return null}Tc(e){}Ic(){}Mc(e,n){return!!e&&Gat(e.propertyFilters,n?.properties)}Ec(e,n){const o=new Map;return e.forEach(i=>{var r;(r=i.conditions)===null||r===void 0||(r=r[n])===null||r===void 0||(r=r.values)===null||r===void 0||r.forEach(s=>{if(s?.name){const a=o.get(s.name)||[];a.push(i.id),o.set(s.name,a)}})}),o}Pc(e,n,o){const i=(o===pV.Activation?this._c:this.wc).get(e);let r=[];return this.Rc(s=>{r=s.filter(a=>i?.includes(a.id))}),r.filter(s=>{var a;const A=(a=s.conditions)===null||a===void 0||(a=a[o])===null||a===void 0||(a=a.values)===null||a===void 0?void 0:a.find(c=>c.name===e);return this.Mc(A,n)})}register(e){this.Ac(e,!1)}replace(e){this.Ac(e,!0)}Ac(e,n){var o;Eo((o=this._instance)===null||o===void 0?void 0:o._addCaptureHook)||(this.Oc(e,n),this.Fc(e,n))}Fc(e,n){const o=e.filter(s=>{var a;return(a=s.conditions)===null||a===void 0||(a=a.actions)===null||a===void 0||(a=a.values)===null||a===void 0?void 0:a.length});var i;if(n&&this.kc.clear(),o.length===0)return void(n&&((i=this.Dc)===null||i===void 0||i.replace([])));this.Dc||(this.Dc=new G9n(this._instance),this.Dc.init(),this.Dc.dc(s=>this.onAction(s)));const r=[];o.forEach(s=>{var a;(a=s.conditions)===null||a===void 0||(a=a.actions)===null||a===void 0||a.values.forEach(A=>{if(r.push(A),A.name){var c;const l=(c=this.kc.get(A.name))!==null&&c!==void 0?c:[];l.includes(s.id)||l.push(s.id),this.kc.set(A.name,l)}})}),n?this.Dc.replace(r):this.Dc.register(r)}Lc(e,n){n.forEach((o,i)=>{var r;const s=(r=e.get(i))!==null&&r!==void 0?r:[];o.forEach(a=>{s.includes(a)||s.push(a)}),e.set(i,s)})}Oc(e,n){var o,i;const r=e.filter(c=>{var l,g;return((l=c.conditions)===null||l===void 0?void 0:l.events)&&((g=c.conditions)===null||g===void 0||(g=g.events)===null||g===void 0||(g=g.values)===null||g===void 0?void 0:g.length)>0}),s=e.filter(c=>{var l,g;return((l=c.conditions)===null||l===void 0?void 0:l.cancelEvents)&&((g=c.conditions)===null||g===void 0||(g=g.cancelEvents)===null||g===void 0||(g=g.values)===null||g===void 0?void 0:g.length)>0}),a=this.Ec(e,pV.Activation),A=this.Ec(e,pV.Cancellation);n?(this._c=a,this.wc=A):(this.Lc(this._c,a),this.Lc(this.wc,A)),(r.length!==0||s.length!==0||e.some(c=>{var l;return(l=c.conditions)===null||l===void 0||(l=l.actions)===null||l===void 0||(l=l.values)===null||l===void 0?void 0:l.length}))&&((o=this.hc)!==null&&o!==void 0||(this.hc=(i=this._instance)===null||i===void 0?void 0:i._addCaptureHook((c,l)=>{this.onEvent(c,l)})))}onEvent(e,n){var o,i;const r=this.Nc(),s=(n==null||(o=n.properties)===null||o===void 0?void 0:o.$survey_id)||(n==null||(i=n.properties)===null||i===void 0?void 0:i.$product_tour_id);if(s&&this.getActivatedIds().includes(s)){const A=this.qc(e,s,n);if(A==="consume")return r.info("event consumed activated item, removing it",{event:e,itemId:s}),void this.jc([s]);if(A==="persist")return r.info("shown item promoted to persisted activation",{event:e,itemId:s}),this.Bc(s),void this.Hc([s])}if(this.wc.has(e)){const A=this.Pc(e,n,pV.Cancellation);A.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:A.map(c=>c.id)}),this.jc(A.map(c=>c.id)),A.forEach(c=>this.zc(c.id)))}if(!this._c.has(e))return;r.info("event name matched",{event:e,eventPayload:n,items:this._c.get(e)});const a=this.Pc(e,n,pV.Activation);this.Uc(a.map(A=>A.id))}onAction(e){this.kc.has(e)&&this.Uc(this.kc.get(e)||[])}Uc(e){var n,o;if(e.length===0)return;const i=!!(!((n=this._instance)===null||n===void 0||(o=n.get_session_id)===null||o===void 0)&&o.call(n)),r=[];for(const s of e)i&&this.$c(s)?this.Bc(s)&&this.Wc(s):r.push(s);r.length>0&&(this.yc=[...new Set([...this.yc,...r])]),this.Nc().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.Vc()}Bc(e){this.yc=this.yc.filter(o=>o!==e);const n=this.Gc();return!n.includes(e)&&(this.Qc([...n,e]),this.Jc(),!0)}jc(e){const n=new Set(e);this.yc=this.yc.filter(r=>!n.has(r));const o=this.Zc(),i=o.filter(r=>!n.has(r));i.length!==o.length&&(this.Qc(i),i.length===0&&this.Kc()),this.Hc(e),this.Vc()}Vc(){try{var e;(e=this.bc)===null||e===void 0||e.call(this)}catch(n){this.Nc().error("Error while handling activated items change",n)}}Xc(){var e;const n=this.Cc();if(!n)return{};const o=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[n];return o&&typeof o=="object"?o:{}}Wc(e){if(!this.Cc())return;const n=this.Xc();this.Tc(sn(sn({},n),{},{[e]:Date.now()}))}Hc(e){if(!this.Cc())return;const n=this.Xc(),o={};let i=!1;for(const[r,s]of Object.entries(n))e.includes(r)?i=!0:o[r]=s;i&&(ox(o)?this.Ic():this.Tc(o))}Yc(){this.Cc()&&this.Ic()}getActivationTimestamp(e){if(!this.Gc().includes(e))return;const n=this.Xc()[e];return qd(n)?n:void 0}Zc(){var e;const n=this.td();return((e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[n])||[]}Gc(){var e,n,o;const i=this.Zc();if(i.length===0)return[];const r=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[this.ed()],s=(n=this._instance)===null||n===void 0||(o=n.get_session_id)===null||o===void 0?void 0:o.call(n);return s&&r===s?i:[]}Jc(){var e,n;const o=(e=this._instance)===null||e===void 0||(n=e.get_session_id)===null||n===void 0?void 0:n.call(e);o&&this.nd(o)}Kc(){this.sd()}xc(e){var n;const o=(n=this._instance)===null||n===void 0||(n=n.persistence)===null||n===void 0?void 0:n.props[this.ed()];if(o&&o!==e){const i=this.Zc(),r=this.Xc();i.length>0&&(this.Qc([]),i.filter(s=>qd(r[s])).forEach(s=>this.zc(s))),this.Kc(),this.Yc(),i.length>0&&this.Vc()}}getActivatedIds(){return[...new Set([...this.Gc(),...this.yc])].filter(e=>!this.rd(e))}dispose(){var e,n,o;(e=this.Sc)===null||e===void 0||e.call(this),this.Sc=void 0,(n=this.hc)===null||n===void 0||n.call(this),this.hc=void 0,(o=this.Dc)===null||o===void 0||o.dispose(),this.Dc=void 0}reset(){this.yc=[],this.Zc().length>0&&this.Qc([]),this.Kc(),this.Yc(),this.Vc()}getEventToItemsMap(){return this._c}od(){return this.Dc}},U9n=class extends Y9n{constructor(e,n){super(e,n)}td(){return ost}ed(){return ist}Cc(){return rst}Tc(e){var n;(n=this._instance)===null||n===void 0||(n=n.persistence)===null||n===void 0||n.register({$surveys_activated_timestamps:e})}Ic(){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.unregister("$surveys_activated_timestamps")}$c(e){var n;let o;this.Rc(r=>{o=r.find(s=>s.id===e)});const i=o==null||(n=o.appearance)===null||n===void 0?void 0:n.surveyPopupDelaySeconds;return qd(i)&&i>0}ad(){return R3.SHOWN}Rc(e){var n;(n=this._instance)===null||n===void 0||n.getSurveys(e)}zc(e){var n;(n=this._instance)===null||n===void 0||n.cancelPendingSurvey(e)}Nc(){return _l}Qc(e){var n;(n=this._instance)===null||n===void 0||(n=n.persistence)===null||n===void 0||n.register({$surveys_activated:e})}nd(e){var n;(n=this._instance)===null||n===void 0||(n=n.persistence)===null||n===void 0||n.register({$surveys_activated_session:e})}sd(){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.unregister("$surveys_activated_session")}rd(){return!1}qc(e,n,o){var i;if(e===R3.SENT&&(o==null||(i=o.properties)===null||i===void 0?void 0:i.$survey_completed)===!1)return"ignore";let r;return this.Rc(s=>{r=s.find(a=>a.id===n)}),!r||(function(s){var a;return Hat(s)&&!!(!((a=s.conditions)===null||a===void 0||(a=a.events)===null||a===void 0)&&a.repeatedActivation)||s.schedule==="always"})(r)?e===R3.SHOWN?"consume":"ignore":e===R3.SHOWN?"persist":e===R3.DISMISSED||e===R3.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},K9n=class{constructor(e){this._instance=e}initialize(){}get(e){if(typeof e=="string")return this._instance.get_property(e);const n={};for(const o of e){const i=this._instance.get_property(o);Eo(i)||(n[o]=i)}return n}set(e,n){this._instance.register(typeof e=="string"?{[e]:n}:e)}remove(e){typeof e!="string"?e.forEach(n=>this._instance.unregister(n)):this._instance.unregister(e)}},V9n=class{constructor(e){this._instance=e}get(){const e=this._instance.config;return{disableSurveys:e.disable_surveys,cookielessMode:!!e.cookieless_mode,advancedEnableSurveys:e.advanced_enable_surveys,requestTimeoutMs:e.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}isCapturing(){return this._instance.is_capturing()}getExtensions(){const e=Ur?.__PosthogExtensions__;if(!e)return;const{generateSurveys:n,loadExternalDependency:o}=e;return{generateSurveys:n?i=>n(this._instance,i):void 0,loadExternalDependency:o?i=>o(this._instance,"surveys",i):void 0}}createEventReceiver(e){return new U9n(this._instance,e)}onMatchingConditionsChanged(e){const n=this._instance._addCaptureHook(s=>{s!=="$pageview"&&s!==R3.SHOWN&&s!==R3.DISMISSED&&s!==R3.SENT||e()}),o=()=>e();jc(Fn,"PHSurveyShown",o);let i=!1;const r=this._instance.onFeatureFlags(()=>{i&&e()});return i=!0,()=>{i=!1,n(),r(),Fn?.removeEventListener("PHSurveyShown",o)}}};const z9n=Fn?.location?sne(Fn.location.hash,"__posthog")||sne(location.hash,"state"):null,aAt="_postHogToolbarParams",AAt=Ad("[Toolbar]"),cAt=Ad("[FeatureFlags]");var J9n=class{constructor(e,n=!1){this.ld=!1,this.update(e,n)}update(e,n){this.ud=((o,i)=>{var r,s,a,A,c,l,g,u;return{bootstrap:{featureFlags:(r=(s=o.bootstrap)===null||s===void 0?void 0:s.featureFlags)!==null&&r!==void 0?r:void 0,featureFlagPayloads:(a=(A=o.bootstrap)===null||A===void 0?void 0:A.featureFlagPayloads)!==null&&a!==void 0?a:void 0},remoteRequestsDisabled:i,featureFlagsDisabled:!!o.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!o.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!o.advanced_feature_flags_dedup_per_session,cacheTtlMs:o.feature_flag_cache_ttl_ms,refreshIntervalMs:(c=o.remote_config_refresh_interval_ms)!==null&&c!==void 0?c:3e5,idleRefreshBackoff:Eo(o.remote_config_refresh_interval_ms),requestTimeoutMs:o.feature_flag_request_timeout_ms,requestMaxRetries:Math.max(0,(l=o.feature_flag_request_max_retries)!==null&&l!==void 0?l:1),compression:o.disable_compression?void 0:"best-available",evaluationContexts:(g=(u=o.evaluation_contexts)!==null&&u!==void 0?u:o.evaluation_environments)!==null&&g!==void 0?g:[],flagKeys:As(o.flag_keys)?o.flag_keys:void 0}})(e,n),!e.evaluation_environments||e.evaluation_contexts||this.ld||(cAt.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ld=!0),Eo(e.flag_keys)||As(e.flag_keys)||cAt.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this.ud}};const lAt=Ad("[FeatureFlags]"),OM=Ad("[FeatureFlags]",{debugEnabled:!0}),nxe=`" failed. Feature flags didn't load in time.`,W9n=[502,504],gAt=["click","keydown","wheel","touchstart","pointerdown"],uAt="connection_error",dAt=t=>{const e={};for(let n=0;t.length>n;n++)e[t[n]]=!0;return e},hAt=t=>{const e={};for(const[n,o]of one(t||{}))o&&(e[n]=o);return e},pAt=t=>Qk(t)&&(t.name==="RangeError"&&t.message.indexOf("Maximum call stack size exceeded")===0||t.name==="InternalError"&&t.message==="too much recursion"),L4=Ad("[Error tracking]"),oxe="webkit-masked-url:",j9n=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],X9n=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",oxe],q9n=["__firefox__","__gCrWeb"],mAt="Refusing to render web experiment since the viewer is a likely bot",$9n={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>hne(e,t),not_regex:(t,e)=>!hne(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t},_5=Ad("[Conversations]"),GM="Conversations not available yet.";function _At(t,e){var n,o,i,r,s,a,A;const c=(n=t?.flushIntervalMs)!==null&&n!==void 0?n:3e3,l=(o=t?.maxBufferSize)!==null&&o!==void 0?o:100,g=e?.consoleCapture?void 0:(i=t?.maxLogsPerInterval)!==null&&i!==void 0?i:1e3,u=Eo(g)?Math.max(l,2048):Math.max(l,g),h=sn(sn({},(function(){let d="",p="";try{const m=F_?.userAgent;m&&([d,p]=crt(m))}catch{}return(function(m,_){const f=(function(I){if(I)return{}.hasOwnProperty.call(Lrt,I)?Lrt[I]:I})(m);return sn(sn({},f?{"os.name":f}:{}),_?{"os.version":_}:{})})(d,p)})()),t?.resourceAttributes);return{serviceName:(r=(s=h?.["service.name"])!==null&&s!==void 0?s:t?.serviceName)!==null&&r!==void 0?r:e?.serviceNameDefault,serviceVersion:(a=h?.["service.version"])!==null&&a!==void 0?a:t?.serviceVersion,environment:(A=h?.["deployment.environment"])!==null&&A!==void 0?A:t?.environment,resourceAttributes:h,beforeSend:t?.beforeSend,flushIntervalMs:c,maxBufferSize:l,maxQueueSize:u,maxBatchRecordsPerPost:100,rateCapWindowMs:c,maxLogsPerInterval:g,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const Z9n=["debug","log","warn","error","info"],e7n=t=>{for(;t?.__rrweb_original__;)t=t.__rrweb_original__;return t},fAt="console",IAt="__posthogHandledLogsRequestError",ixe=(t,e)=>{const n=t instanceof Error?t:new Error(e);return n[IAt]=!0,n},CAt=t=>!!t&&typeof t=="object"&&t[IAt]===!0,_ne=Ad("[NetworkMetrics]"),rxe=()=>{var t;return!(Fn==null||(t=Fn.performance)===null||t===void 0)&&t.now?Fn.performance.now():Date.now()},t7n={"http:":80,"https:":443},n7n=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),yAt=(t,e)=>{var n;const o=String(e);return{method:String(t).toUpperCase(),url:((n=x8(o))===null||n===void 0?void 0:n.href)||o}},sxe=(t,e,n,o,i,r,s=!1)=>{try{var a,A;const c=i();if(!c)return;const l=n||void 0,g=rxe()-o,u=x8(e.url);if(u&&u.protocol!=="http:"&&u.protocol!=="https:")return;const h={url:u?.href||e.url,method:e.method},d=L_(c.name)?c.name(h):nA(c.name)?c.name:"http.client.request.duration";if(!d)return;const p=s&&!l?void 0:((_,f)=>_?400>_?void 0:String(_):f?.name||"_OTHER")(l,r),m=sn(sn(sn(sn(sn({},(_=>{const f=n7n.has(_)?_:"_OTHER";return sn({"http.request.method":f},f==="_OTHER"&&_!==f?{"http.request.method_original":_}:{})})(h.method)),u?(_=>{return{"server.address":_.hostname.startsWith("[")&&_.hostname.endsWith("]")?_.hostname.slice(1,-1):_.hostname,"server.port":Number(_.port)||t7n[_.protocol],"url.scheme":_.protocol.slice(0,-1),"url.template":(f=_.pathname,f.split("/").map(I=>(C=>/^\d+$/.test(C)||C.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(C))(I)?":id":I).join("/"))};var f})(u):{}),l?{"http.response.status_code":l}:{}),p?{"error.type":p}:{}),(a=c.attributes)===null||a===void 0?void 0:a.call(c,h,{status:l,durationMs:g}));(A=t.metrics)===null||A===void 0||A.histogram(d,g,{unit:"ms",attributes:m})}catch(c){_ne.error("Failed to record network metric",c)}},xAt=()=>{},o7n=(t,e)=>L_(Fn?.fetch)?bV(Fn,"fetch",n=>function(...o){const i=rxe(),r=n.apply(this,o);if(!e())return r;try{var s,a,A;const[c,l]=o,g=yAt((s=(a=l?.method)!==null&&a!==void 0?a:c?.method)!==null&&s!==void 0?s:"GET",(A=c?.url)!==null&&A!==void 0?A:c);return r.then(u=>(sxe(t,g,u?.status,i,e,void 0,!0),u),u=>{throw sxe(t,g,void 0,i,e,u),u})}catch(c){return _ne.error("Failed to observe fetch",c),r}}):xAt,i7n=(t,e)=>{var n;const o=Fn==null||(n=Fn.XMLHttpRequest)===null||n===void 0?void 0:n.prototype;if(!o)return xAt;const i=new WeakMap,r=bV(o,"open",a=>function(...A){try{xat.has(this)||i.set(this,yAt(A[0],A[1]))}catch(c){_ne.error("Failed to observe XHR open",c)}return a.apply(this,A)}),s=bV(o,"send",a=>function(...A){let c;try{const l=i.get(this);if(l&&e()){const g=rxe();c=()=>{this.removeEventListener("loadend",c),sxe(t,l,this.status,g,e)},jc(this,"loadend",c)}}catch(l){_ne.error("Failed to observe XHR send",l)}try{return a.apply(this,A)}catch(l){throw c&&this.removeEventListener("loadend",c),l}});return()=>{r(),s()}},fne={featureFlags:class{constructor(t){this.name="featureFlags",this.hd=!1,this.featureFlagEventHandlers=[],this.A=lAt,this.dd={},this.vd={},this.fd=[],this.pd=!1,this.gd=!1,this.md=0,this.yd=!1,this.bd=!1,this._d=!1,this.wd=!1,this.kd=0,this.Sd=!1,this.rn=()=>{const e=this.xd();this.kd=0,e&&this.reloadFeatureFlags()},this.$d=()=>{var e,n;const o=this.Cd,i=(e=this.Td)!==null&&e!==void 0?e:o;Eo(o)||Eo(i)||this.Mr.remoteRequestsDisabled||!No||No.visibilityState==="hidden"||Date.now()-((n=this.Id)!==null&&n!==void 0?n:0)<i||(this.Td=this.Sd||!this.Mr.idleRefreshBackoff?o:Math.min(2*i,36e5),this.Sd=!1,this.reloadFeatureFlags(),this.Md())},this.Ed=()=>{this.Sd&&this.Td===this.Cd||this.Pd()},this.sn=()=>{No?.visibilityState==="visible"&&this.Pd()},"get"in t?this.wo=t:(this._instance=t,this.Rd=new J9n(t.config,t.il()),this.wo=this.Rd)}updateConfig(t,e){var n;(n=this.Rd)===null||n===void 0||n.update(t,e),this.bo&&this.Ad()}setup(t){return this.jh=t,this.A=t.logger.createLogger("[FeatureFlags]"),rAt(t.kv.initialize(),()=>{this.jh===t&&(this.jh=void 0,this.bo=t,this.Od(t))})}Od(t){var e;if(this.bo===t)return Fn&&jc(Fn,"online",this.rn),this.Ad(),this.Fd=t.registerDynamicEventProperties(()=>this.Dd()?this.dd:this.vd),this.Ld=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.onCrossTabFeatureFlagChange(()=>{this.Nd(),this.qd(),this.jd()}),this.qd(),this.initialize()}Pd(){this.Sd=!0,this.Td=this.Cd,this.$d()}Ad(){const t=this.Mr.refreshIntervalMs,e=!this.Mr.remoteRequestsDisabled&&No&&!Eo(t)&&t>0?t:void 0;this.Mr.idleRefreshBackoff||(this.Td=e),e!==this.Cd&&(this.Bd(),Eo(e)||(this.Cd=e,this.Td=e,this.Md(),No?.addEventListener&&(jc(No,iV,this.sn),Nk(gAt,n=>{jc(No,n,this.Ed,{capture:!0})}))))}Md(){Eo(this.Cd)||(Eo(this.Hd)||clearInterval(this.Hd),this.Id=Date.now(),this.Hd=setInterval(this.$d,this.Cd))}Bd(){var t;Eo(this.Hd)||(clearInterval(this.Hd),this.Hd=void 0,No==null||(t=No.removeEventListener)===null||t===void 0||t.call(No,"visibilitychange",this.sn),Nk(gAt,e=>{var n;No==null||(n=No.removeEventListener)===null||n===void 0||n.call(No,e,this.Ed,{capture:!0})})),this.Cd=void 0,this.Td=void 0,this.Sd=!1,this.Id=void 0}destroy(){this.zd()}dispose(){this.zd()}zd(){var t,e;this.Bd(),this.md++,this.bd=!1,this.jh=void 0,this.bo&&(this.Ud(),(t=this.Fd)===null||t===void 0||t.dispose(),this.Fd=void 0,(e=this.Ld)===null||e===void 0||e.call(this),this.Ld=void 0,this.fd=[],Fn?.removeEventListener("online",this.rn),this.bo=void 0)}get Mr(){return this.wo.get()}Wd(t){var e;return this.Vd&&t in this.Vd?this.Vd[t]:(e=this.bo)===null||e===void 0?void 0:e.kv.get(t)}Nd(){return!!this.Vd&&(this.Vd=void 0,!0)}Gd(){var t;return!Eo((t=this.bo)===null||t===void 0?void 0:t.kv.get("$enabled_feature_flags"))&&this.Nd()}$t(t){this.Qd(()=>{var e;return(e=this.bo)===null||e===void 0?void 0:e.kv.set(t)})}Jd(t,e,n){var o;if(!(!((o=this._instance)===null||o===void 0)&&o.persistence)||!t.$enabled_feature_flags)return;const i=this.Wd("$enabled_feature_flags")||{},r=t.$enabled_feature_flags||{},s=e.flags||e.featureFlags,a=e.flags?Object.entries(e.flags).filter(([,_])=>!_?.failed).map(([_])=>_):[],A=!!e.errorsWhileComputingFlags&&!!e.flags,c=A?a:n&&!As(s)?Object.keys(s||{}):Array.from(new Set([...Object.keys(i),...Object.keys(r)])),l=this.Wd("$feature_flag_payloads")||{},g=t.$feature_flag_payloads||{},u=A||n?c:Array.from(new Set([...Object.keys(l),...Object.keys(g)])),h=!A&&!n,d=!!h||c,p=!!h||u,m={[C8]:d,[k4]:d,[cQ]:p};t.$feature_flag_details&&(m[NM]=d);for(const _ of[RM,dQ,eV])Eo(t[_])||(m[_]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(m)}Pt(t){this.Qd(()=>{var e;return(e=this.bo)===null||e===void 0?void 0:e.kv.remove(t)})}Qd(t){try{t()}catch(e){this.A.error("Failed to update feature flag persistence",e)}}qd(){const t={};for(const o of[C8,cQ,RM,B9]){const i=this.Wd(o);Eo(i)||(t[o]=i)}this.dd=t;const e=sn({},t),n=this.Wd(k4);if(n)for(const[o,i]of Object.entries(n))e[`$feature/${o}`]=i;this.vd=e}Dd(){const t=this.Mr.cacheTtlMs;if(!t||0>=t)return!1;const e=this.Wd(dQ);return typeof e!="number"||Date.now()-e>t}Zd(){return!!this.Dd()&&(this.wd||this.gd||(this.wd=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Kd(){const t=this.Mr.evaluationContexts;return t?.length?t.filter(e=>{const n=e&&typeof e=="string"&&e.trim().length>0;return n||this.A.error("Invalid evaluation context found:",e,"Expected non-empty string"),n}):[]}Xd(){const t=this.Mr.flagKeys;if(!Eo(t))return t.filter(e=>{const n=e&&typeof e=="string"&&e.trim().length>0;return n||this.A.error("Invalid flag key found:",e,"Expected non-empty string"),n})}initialize(){var t,e;const n=this.Mr,o=(t=(e=n.bootstrap)===null||e===void 0?void 0:e.featureFlags)!==null&&t!==void 0?t:{};if(Object.keys(o).length){var i,r;const s=(i=(r=n.bootstrap)===null||r===void 0?void 0:r.featureFlagPayloads)!==null&&i!==void 0?i:{},a=Object.keys(o).filter(c=>!Eo(o[c])).reduce((c,l)=>(c[l]=o[l],c),{}),A=Object.keys(s).filter(c=>a[c]).reduce((c,l)=>(c[l]=s[l],c),{});return this.Yd({featureFlags:a,featureFlagPayloads:A},void 0,{persist:!1})}}updateFlags(t,e,n){var o,i;const r=n?.merge&&(o=this.Wd("$enabled_feature_flags"))!==null&&o!==void 0?o:{},s=n?.merge&&(i=this.Wd("$feature_flag_payloads"))!==null&&i!==void 0?i:{},a=sn(sn({},r),t),A=sn(sn({},s),e),c={};for(const[l,g]of Object.entries(a))c[l]={key:l,enabled:vrt(g),variant:wrt(g),reason:void 0,metadata:Eo(A?.[l])?void 0:{id:0,version:void 0,description:void 0,payload:A[l]}};this.Yd({flags:c})}get hasLoadedFlags(){return this.pd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const t=this.Wd(NM),e=this.Wd(B9),n=this.Wd(TM);if(!n&&!e)return t||{};const o=jg({},t||{}),i=[...new Set([...Object.keys(n||{}),...Object.keys(e||{})])];for(const a of i){var r;const A=o[a],c=e?.[a],l=Eo(c)?(r=A?.enabled)!==null&&r!==void 0&&r:!!c,g=Eo(c)?A?.variant:typeof c=="string"?c:void 0,u=n?.[a],h=sn(sn({},A),{},{enabled:l,variant:l?g??A?.variant:void 0});var s;l!==A?.enabled&&(h.original_enabled=A?.enabled),g!==A?.variant&&(h.original_variant=A?.variant),u&&(h.metadata=sn(sn({},A?.metadata),{},{payload:u,original_payload:A==null||(s=A.metadata)===null||s===void 0?void 0:s.payload})),o[a]=h}return this.hd||(this.A.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:n,finalDetails:o}),this.hd=!0),o}getAllFeatureFlags(){const t=this.getFlagVariants(),e=this.getFlagPayloads();return Object.keys(t).map(n=>{const o=t[n];return{key:n,enabled:vrt(o),variant:wrt(o),payload:Qrt(e[n])}})}getFlagVariants(){const t=this.Wd(k4),e=this.Wd(B9);if(!e)return t||{};const n=jg({},t||{}),o=Object.keys(e);for(let i=0;o.length>i;i++)n[o[i]]=e[o[i]];return this.hd||(this.A.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:n}),this.hd=!0),n}getFlagPayloads(){const t=this.Wd(cQ),e=this.Wd(TM);if(!e)return t||{};const n=jg({},t||{}),o=Object.keys(e);for(let i=0;o.length>i;i++)n[o[i]]=e[o[i]];return this.hd||(this.A.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:n}),this.hd=!0),n}reloadFeatureFlags(){this.yd||this.Mr.featureFlagsDisabled||this.xd()||(this.gd&&(this.bd=!0),this.tv||(this.fd.slice().forEach(t=>{try{t()}catch(e){this.A.error("Error while running feature flags reloading callback",e)}}),this.tv=setTimeout(()=>{this.ev()},5)))}Ud(){clearTimeout(this.tv),this.tv=void 0}onReloading(t){return this.fd.push(t),()=>{this.fd=this.fd.filter(e=>e!==t)}}ensureFlagsLoaded(){this.pd||this.gd||this.tv||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.yd=t}resetFlagCallReported(){this.Pt(uQ)}ev(t){this.Ud();const e=this.bo;if(!e||this.Mr.remoteRequestsDisabled||this.xd())return;if(this.gd)return void(this.bd=!0);const n={token:e.projectToken,distinct_id:e.distinctId,groups:e.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:sn(sn(sn({},e.initialPersonProperties),this.Wd("$stored_person_properties")||{}),{},{$lib:e.library.name,$lib_version:e.library.version}),group_properties:this.Wd(gQ),timezone:sat()};Eo(e.deviceId)||(n.$device_id=e.deviceId),(t?.disableFlags||this.Mr.featureFlagsDisabled)&&(n.disable_flags=!0);const o=this.Kd();o.length&&(n.evaluation_contexts=o);const i=this.Xd();Eo(i)||(n.flag_keys=i);const r=this.Mr.onlyEvaluateSurveyFeatureFlags,s="/flags/?v=2"+(r?"&only_evaluate_survey_feature_flags=true":""),a=this.md;this.gd=!0;const A=()=>{this.bd&&(this.bd=!1,this.ev())},c=d=>{var p,m;const _=(p=d.json)!==null&&p!==void 0?p:{},f=d.statusCode!==200;if(this.gd=!1,a!==this.md)return void A();if(this.iv(d.statusCode),f||this.bd||(this.$anon_distinct_id=void 0),n.disable_flags&&!this.bd)return;this._d=!f;const I=[];d.error?I.push(d.error instanceof Error&&d.error.name==="AbortError"?"timeout":d.error instanceof Error?uAt:"unknown_error"):d.statusCode!==200&&I.push(`api_error_${d.statusCode}`),_.errorsWhileComputingFlags&&I.push("errors_while_computing_flags");const C=!!(!((m=_.quotaLimited)===null||m===void 0)&&m.includes("feature_flags"));C&&I.push("quota_limited"),this.$t({[oV]:I}),C?this.A.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."):n.disable_flags||this.Yd(_,f,{partialResponse:r}),A()},l=d=>{this.gd=!1,a===this.md&&(this.$t({[oV]:[uAt]}),this.A.error("Feature flag request failed",d),this.Gd()&&this.jd(!0)),A()};let g=this.Mr.requestMaxRetries;const u=()=>g>0&&a===this.md,h=()=>{if(a!==this.md||!this.bo||this.Mr.remoteRequestsDisabled)return this.gd=!1,void A();try{e.sendRequest(s,{target:"flags",method:"POST",body:n,compression:this.Mr.compression,sentAt:"body",timeoutMs:this.Mr.requestTimeoutMs}).then(d=>{if((p=>W9n.includes(p.statusCode)||(m=>m.statusCode===0&&m.error instanceof Error&&m.error.name==="AbortError")(p))(d)&&u())return g--,void setTimeout(h,500);c(d)}).catch(l)}catch(d){l(d)}};h()}xd(){return qst(this.kd,3)}iv(t){this.kd=$st(t,this.kd,3,()=>this.A.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.fresh&&!this._d)return;if(!(this.pd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlag for key "'+t+nxe);if(this.Zd())return;const o=this.getFeatureFlagResult(t,e);return(n=o?.variant)!==null&&n!==void 0?n:o?.enabled}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){const e=this.getFeatureFlagResult(t,{send_event:!1});return e?.payload}getFeatureFlagResult(t,e={}){if(e.fresh&&!this._d)return;if(!(this.pd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlagResult for key "'+t+nxe);if(this.Zd())return;const n=this.getFlagVariants(),o=t in n,i=n[t],r=this.getFlagPayloads()[t],s=String(i),a=this.Wd("$feature_flag_request_id")||void 0,A=this.Wd("$feature_flag_evaluated_at")||void 0;let c,l=this.Wd("$flag_call_reported")||{};if(this.Mr.deduplicateCallsPerSession){var g;const S=(g=this.bo)===null||g===void 0?void 0:g.session.sessionId,Q=this.Wd(nV);S&&S!==Q&&(l={},c=S)}if(e.send_event||!("send_event"in e))if(t in l&&l[t].includes(s))c&&this.$t({[uQ]:l,[nV]:c});else{var u,h,d,p,m,_,f,I,C,y,x,E;As(l[t])?l[t].push(s):l[t]=[s],this.$t(sn({[uQ]:l},c?{[nV]:c}:{}));const S=this.getFeatureFlagDetails(t),Q=[...(u=this.Wd("$feature_flag_errors"))!==null&&u!==void 0?u:[]];Eo(i)&&Q.push("flag_missing");const w={$feature_flag:t,$feature_flag_response:i,$feature_flag_payload:r??null,$feature_flag_request_id:a,$feature_flag_evaluated_at:A,$feature_flag_bootstrapped_response:(h=(d=this.Mr.bootstrap)===null||d===void 0||(d=d.featureFlags)===null||d===void 0?void 0:d[t])!==null&&h!==void 0?h:null,$feature_flag_bootstrapped_payload:(p=(m=this.Mr.bootstrap)===null||m===void 0||(m=m.featureFlagPayloads)===null||m===void 0?void 0:m[t])!==null&&p!==void 0?p:null,$used_bootstrap_value:!this._d};Eo(S==null||(_=S.metadata)===null||_===void 0?void 0:_.has_experiment)||(w.$feature_flag_has_experiment=S.metadata.has_experiment),Eo(S==null||(f=S.metadata)===null||f===void 0?void 0:f.version)||(w.$feature_flag_version=S.metadata.version);const M=(I=S==null||(C=S.reason)===null||C===void 0?void 0:C.description)!==null&&I!==void 0?I:S==null||(y=S.reason)===null||y===void 0?void 0:y.code;var B;M&&(w.$feature_flag_reason=M),!(S==null||(x=S.metadata)===null||x===void 0)&&x.id&&(w.$feature_flag_id=S.metadata.id),Eo(S?.original_variant)&&Eo(S?.original_enabled)||(w.$feature_flag_original_response=Eo(S.original_variant)?S.original_enabled:S.original_variant),!(S==null||(E=S.metadata)===null||E===void 0)&&E.original_payload&&(w.$feature_flag_original_payload=S==null||(B=S.metadata)===null||B===void 0?void 0:B.original_payload),Q.length&&(w.$feature_flag_error=Q.join(",")),this.nv(w)}else c&&this.$t({[uQ]:l,[nV]:c});return o?{key:t,enabled:!!i,variant:typeof i=="string"?i:void 0,payload:Qrt(r)}:void 0}nv(t){try{var e;(e=this.bo)===null||e===void 0||e.capture("$feature_flag_called",t)}catch(n){this.A.error("Failed to capture feature flag call",n)}}getRemoteConfigPayload(t,e){this.sv(t,e)}sv(t,e){var n=this;return Wg(function*(){const o=n.bo;if(!o)return;const i={distinct_id:o.distinctId,token:o.projectToken,person_properties:{$lib:o.library.name,$lib_version:o.library.version}},r=n.Kd();r.length&&(i.evaluation_contexts=r);const s=n.Xd();let a;Eo(s)||(i.flag_keys=s);try{var A;const c=(A=(yield o.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:i,compression:n.Mr.compression,sentAt:"body",timeoutMs:n.Mr.requestTimeoutMs})).json)===null||A===void 0?void 0:A.featureFlagPayloads;a=c?.[t]||void 0}catch(c){return void n.A.error("Remote config feature flag request failed",c)}try{e(a)}catch(c){n.A.error("Remote config feature flag callback failed",c)}})()}isFeatureEnabled(t,e={}){if(e.fresh&&!this._d)return e.defaultValue;if(!(this.pd||this.getFlags()&&this.getFlags().length>0))return this.A.warn('isFeatureEnabled for key "'+t+nxe),e.defaultValue;const n=this.getFeatureFlag(t,e);return Eo(n)?e.defaultValue:!!n}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(e=>e!==t)}receivedFeatureFlags(t,e,n){this.Yd(t,e,n)}Yd(t,e,n){if(!this.bo)return;this.pd=!0;const o=((i,r={},s={},a={},A,c=lAt)=>{const l=((I,C)=>{const y=I.flags;if(y){const x=Object.fromEntries(Object.keys(y).map(B=>{var S;return[B,(S=y[B].variant)!==null&&S!==void 0?S:y[B].enabled]})),E=Object.fromEntries(Object.keys(y).filter(B=>y[B].enabled).filter(B=>{var S;return!Eo((S=y[B].metadata)===null||S===void 0?void 0:S.payload)}).map(B=>{var S;return[B,(S=y[B].metadata)===null||S===void 0?void 0:S.payload]}));return sn(sn({},I),{},{featureFlags:x,featureFlagPayloads:E})}return I.featureFlags&&C.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),I})(i,c),g=l.flags,u=l.featureFlags,h=l.featureFlagPayloads;if(!u)return;const d=i.requestId,p=i.evaluatedAt;if(As(u)){c.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const I={};if(u)for(let C=0;u.length>C;C++)I[u[C]]=!0;return{[C8]:u,[k4]:I,[eV]:!1}}let m=u,_=h,f=g;if(A?.partialResponse){const I=Object.keys(m),C=_||{};m=sn(sn({},r),m),_=sn(sn({},s),C),I.forEach(y=>{y in C||_==null||delete _[y]}),f=sn(sn({},a),f)}else if(i.errorsWhileComputingFlags)if(g){const I=new Set(Object.keys(g).filter(y=>{var x;return!(!((x=g[y])===null||x===void 0)&&x.failed)}));m=sn(sn({},r),Object.fromEntries(Object.entries(m).filter(([y])=>I.has(y))));const C=Object.fromEntries(Object.entries(_||{}).filter(([y])=>I.has(y)));_=sn(sn({},s),C),I.forEach(y=>{y in C||_==null||delete _[y]}),f=sn(sn({},a),Object.fromEntries(Object.entries(f||{}).filter(([y])=>I.has(y))))}else m=sn(sn({},r),m),_=sn(sn({},s),_),f=sn(sn({},a),f);return sn(sn({[C8]:Object.keys(hAt(m)),[k4]:m||{},[cQ]:_||{},[NM]:f||{},[eV]:i.minimalFlagCalledEvents===!0},d?{[RM]:d}:{}),p?{[dQ]:p}:{})})(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),n,this.A);if(o)if(n?.persist===!1){const i=!Eo(this.bo.kv.get(k4));this.Vd=o,i||this.$t(o)}else this.Nd(),this.Jd(o,t,!!n?.partialResponse),this.$t(o);else e&&this.Gd();e||(this.wd=!1),this.jd(e)}override(t,e=!1){this.A.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){this.rv(t)}rv(t){if(this.bo){if(t===!1)return this.Pt([B9,TM]),this.jd(),void OM.info("All overrides cleared");if(As(t))return this.$t({[B9]:dAt(t)}),this.jd(),void OM.info("Flag overrides set",{flags:t});if(t&&typeof t=="object"&&("flags"in t||"payloads"in t)){var e;const n=t;this.hd=!!((e=n.suppressWarning)!==null&&e!==void 0&&e);const o={},i=n.flags,r=n.payloads;return i&&(o[B9]=As(i)?dAt(i):i),r&&(o[TM]=r),Object.keys(o).length&&this.$t(o),i===!1&&r===!1?this.Pt([B9,TM]):i===!1?this.Pt(B9):r===!1&&this.Pt(TM),this.jd(),i===!1?OM.info("Flag overrides cleared"):i&&OM.info("Flag overrides set",{flags:i}),void(r===!1?OM.info("Payload overrides cleared"):r&&OM.info("Payload overrides set",{payloads:r}))}if(t&&typeof t=="object")return this.$t({[B9]:t}),this.jd(),void OM.info("Flag overrides set",{flags:t});this.A.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.A.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.pd){const{flags:e,flagVariants:n}=this.ov();try{t(e,n)}catch(o){this.A.error("Error while running feature flags callback",o)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,n){var o;const i=(this.Wd("$early_access_features")||[]).find(c=>c.flagKey===t),r={[`$feature_enrollment/${t}`]:e},s={$feature_flag:t,$feature_enrollment:e,$set:r};i&&(s.$early_access_feature_name=i.name),n&&(s.$feature_enrollment_stage=n);const a=sn(sn({},this.getFlagVariants()),{},{[t]:e});(o=this._instance)===null||o===void 0||(o=o.persistence)===null||o===void 0||o.markCrossTabFeatureFlagChanges({$active_feature_flags:[t],$enabled_feature_flags:[t],$stored_person_properties:Object.keys(r)}),this.$t({[C8]:Object.keys(hAt(a)),[k4]:a,[lQ]:sn(sn({},this.Wd("$stored_person_properties")||{}),r)}),this.jd();try{var A;(A=this.bo)===null||A===void 0||A.capture("$feature_enrollment_update",s)}catch(c){this.A.error("Failed to capture early access feature enrollment",c)}}getEarlyAccessFeatures(t,e=!1,n){const o=this.Wd(a2e);!o||e?this.av(t,n):t(o)}av(t,e){var n=this;return Wg(function*(){const o=n.bo;if(!o)return;const i=e?`&${e.map(s=>`stage=${s}`).join("&")}`:"";let r;try{const s=yield o.sendRequest(`/api/early_access_features/?token=${o.projectToken}${i}`,{target:"api",method:"GET",sentAt:"query"});if(!s.json)return;r=s.json.earlyAccessFeatures,n.$t({[a2e]:r})}catch(s){return void n.A.error("Early access feature request failed",s)}try{t(r)}catch(s){n.A.error("Early access feature callback failed",s)}})()}ov(){const t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter(n=>e[n]),flagVariants:Object.keys(e).filter(n=>e[n]).reduce((n,o)=>(n[o]=e[o],n),{})}}jd(t){this.qd();const{flags:e,flagVariants:n}=this.ov();this.featureFlagEventHandlers.forEach(o=>{try{o(e,n,{errorsLoading:t})}catch(i){this.A.error("Error while running feature flags callback",i)}})}setPersonPropertiesForFlags(t,e=!0){this.lv(t,e)}lv(t,e=!0){const n=this.Wd("$stored_person_properties")||{},o=t?.$set||(t?.$set_once?{}:t),i=t?.$set_once,r={};if(i)for(const s in i)({}).hasOwnProperty.call(i,s)&&(s in n||(r[s]=i[s]));this.$t({[lQ]:sn(sn(sn({},n),r),o)}),e&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e=!0){const n=sn({},this.Wd("$stored_person_properties")||{});t.forEach(o=>{delete n[o]}),this.$t({[lQ]:n}),e&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t=!0){this.Pt(lQ),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e=!0){const n=this.Wd("$stored_group_properties")||{},o=sn({},n);for(const i of Object.keys(t))o[i]=sn(sn({},n[i]),t[i]);this.$t({[gQ]:o}),e&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){const e=this.Wd("$stored_group_properties")||{};this.$t({[gQ]:sn(sn({},e),{},{[t]:{}})})}else this.Pt(gQ)}reset(){this.md++,this.bd=!1,this.dd={},this.vd={},this.Vd=void 0,this.pd=!1,this.yd=!1,this._d=!1,this.$anon_distinct_id=void 0,this.Ud(),this.hd=!1,this.kd=0}}},r7n={sessionRecording:class{get Mr(){return this._instance.config}get Il(){return this._instance.persistence}get started(){var t;return!!(!((t=this.uv)===null||t===void 0)&&t.isStarted)}get status(){var t,e;return this.hv==="awaiting_config"||this.hv==="missing_config"?this.hv:(t=(e=this.uv)===null||e===void 0?void 0:e.status)!==null&&t!==void 0?t:this.hv}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.hv=Z2e,this.dv=void 0,this.vv=!1,this.Je=(()=>{var e,n;if(!No?.visibilityState||No.visibilityState==="visible")return!0;const o=Fn==null||(e=Fn.performance)===null||e===void 0||(n=e.getEntriesByType)===null||n===void 0?void 0:n.call(e,"visibility-state");return!o?.length||o.some(i=>i.name==="visible")})(),this.sn=()=>{var e,n;No?.visibilityState==="visible"&&(this.Je=!0,(e=this.uv)===null||e===void 0||(n=e.setDocumentWasEverVisible)===null||n===void 0||n.call(e,!0))},!this._instance.sessionManager)throw b8.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if(this.Mr.cookieless_mode==="always")throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');No?.addEventListener&&jc(No,"visibilitychange",this.sn)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:t=!1}={}){var e;this.vv=!0,No==null||(e=No.removeEventListener)===null||e===void 0||e.call(No,"visibilitychange",this.sn),t?this.fv(!0):this.stopRecording()}get pv(){var t;const e=!!(!((t=this._instance.get_property("$session_recording_remote_config"))===null||t===void 0)&&t.enabled),n=!this.Mr.disable_session_recording,o=this.Mr.disable_session_recording||this._instance.consent.isOptedOut();return Fn&&e&&n&&!o}startIfEnabledOrStop(t){var e;if(this.vv||this.pv&&(!((e=this.uv)===null||e===void 0)&&e.isStarted))return;const n=!Eo(Object.assign)&&!Eo(Array.from);this.pv&&n?(this.gv(t),b8.info("starting")):(this.hv=Z2e,this.stopRecording())}gv(t){var e,n;if(this.pv)if(this.hv!=="awaiting_config"&&this.hv!=="missing_config"&&(this.hv=oAt),(Ur==null||(e=Ur.__PosthogExtensions__)===null||e===void 0||(e=e.rrweb)===null||e===void 0?void 0:e.record)&&((n=Ur.__PosthogExtensions__)===null||n===void 0?void 0:n.initSessionRecording))this.mv(t);else{var o,i;const r=this._instance.sessionManager;(o=Ur.__PosthogExtensions__)===null||o===void 0||(i=o.loadExternalDependency)===null||i===void 0||i.call(o,this._instance,this.yv,s=>{if(!this.vv&&this.pv&&this._instance.sessionManager===r)return s?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),b8.error("could not load recorder",s)):void this.mv(t);this.hv="disabled"})}}stopRecording(){var t,e;(t=this.dv)===null||t===void 0||t.call(this),this.dv=void 0,(e=this.uv)===null||e===void 0||e.stop()}fv(t=!1){var e,n;(e=this.dv)===null||e===void 0||e.call(this),this.dv=void 0,(n=this.uv)===null||n===void 0||n.discard({discardProducerEvents:t})}bv(){var t,e;(t=this.Il)===null||t===void 0||t.unregister("$session_is_sampled"),(e=this.Il)===null||e===void 0||e.unregister("$replay_sample_rate")}_v(t,e){if(Fs(t))return null;const n=qd(t)?t:parseFloat(t);return typeof(o=n)!="number"||!Number.isFinite(o)||0>o||o>1?(b8.warn(`${e} must be between 0 and 1. Ignoring invalid value:`,t),null):n;var o}wv(t){if(this.Il){var e,n;const o=this.Il,i=()=>{var r;const s=t.sessionRecording===!1?void 0:t.sessionRecording,a=this._v((r=this.Mr.session_recording)===null||r===void 0?void 0:r.sampleRate,"session_recording.sampleRate"),A=this._v(s?.sampleRate,"remote config sampleRate"),c=a??A;Fs(c)&&this.bv();const l=s?.minimumDurationMilliseconds;o.register({[ZK]:sn(sn({cache_timestamp:Date.now(),enabled:!!s},s),{},{networkPayloadCapture:sn({capturePerformance:t.capturePerformance},s?.networkPayloadCapture),canvasRecording:{enabled:s?.recordCanvas,fps:s?.canvasFps,quality:s?.canvasQuality},sampleRate:c,minimumDurationMilliseconds:Eo(l)?null:l,endpoint:s?.endpoint,triggerMatchType:s?.triggerMatchType,masking:s?.masking,urlTriggers:s?.urlTriggers,version:s?.version,triggerGroups:s?.triggerGroups})})};i(),(e=this.dv)===null||e===void 0||e.call(this),this.dv=(n=this._instance.sessionManager)===null||n===void 0?void 0:n.onSessionId(i)}}onRemoteConfig(t){const e=t.ok?t.config:void 0;return e&&"sessionRecording"in e?e.sessionRecording===!1?(this.wv(e),void this.fv()):(this.wv(e),void this.startIfEnabledOrStop()):(this.hv==="awaiting_config"&&(this.hv="missing_config",this._instance.register_for_session({[d2e]:!0}),b8.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e="log"){var n;!((n=this.uv)===null||n===void 0)&&n.log?this.uv.log(t,e):b8.warn("log called before recorder was ready")}get yv(){var t,e;const n=(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0?void 0:t.get_property(ZK);return(n==null||(e=n.scriptConfig)===null||e===void 0?void 0:e.script)||"lazy-recorder"}Sv(){const t=this._instance.get_property(ZK);if(!t)return!1;let e;try{e=typeof t=="object"?t:JSON.parse(t)}catch(n){return b8.warn("persisted remote config for session recording is invalid and will be ignored",n),!1}return!Fs(e.cache_timestamp)&&36e5>=Date.now()-e.cache_timestamp}mv(t){var e,n,o;if(!this.vv&&this.pv&&this._instance.sessionManager){if(!(!((e=Ur.__PosthogExtensions__)===null||e===void 0)&&e.initSessionRecording))return b8.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[u2e]:!0});var i;if(this.uv||(this.uv=(i=Ur.__PosthogExtensions__)===null||i===void 0?void 0:i.initSessionRecording(this._instance,this.Je),this.uv._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Sv())return this.hv==="missing_config"||this.hv==="awaiting_config"?void 0:(this.hv="awaiting_config",b8.info("persisted remote config is stale, requesting fresh config before starting"),void new uat(this._instance).load());this.hv=oAt,(n=(o=this.uv).setDocumentWasEverVisible)===null||n===void 0||n.call(o,this.Je),this.uv.start(t)}else this.hv=Z2e}onRRwebEmit(t){var e,n;(e=this.uv)===null||e===void 0||(n=e.onRRwebEmit)===null||n===void 0||n.call(e,t)}overrideLinkedFlag(){var t,e;this.uv||(e=this.Il)===null||e===void 0||e.register({$replay_override_linked_flag:!0}),(t=this.uv)===null||t===void 0||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.uv||(e=this.Il)===null||e===void 0||e.register({$replay_override_sampling:!0}),(t=this.uv)===null||t===void 0||t.overrideSampling()}overrideTrigger(t){var e,n;this.uv||(n=this.Il)===null||n===void 0||n.register({[t==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(e=this.uv)===null||e===void 0||e.overrideTrigger(t)}get sdkDebugProperties(){var t;const e={};for(const o of F9n){var n;const i=(n=this._instance.sessionPersistence)===null||n===void 0?void 0:n.get_property(o);Eo(i)||(e[o]=i)}return sn(sn({},e),((t=this.uv)===null||t===void 0?void 0:t.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(t,e){var n;return!!(!((n=this.uv)===null||n===void 0)&&n.tryAddCustomEvent(t,e))}flushBeforeIdentityReset(){var t,e;(t=this.uv)===null||t===void 0||(e=t.flushBeforeIdentityReset)===null||e===void 0||e.call(t)}}},s7n={autocapture:class extends D9n{constructor(t){super(new N9n(t)),this.instance=t}},historyAutocapture:class{constructor(t){this.xv=!1,this._instance=t,this.$v=this.Cv()}initialize(){this.startIfEnabled()}get isEnabled(){const t=this.Tv();return!!(t.path||t.search||this.Iv(t))}startIfEnabled(){this.isEnabled&&(gi.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.$v=this.Cv(),this.startIfEnabled()}stop(){this.Mv&&this.Mv(),this.Mv=void 0,this.Ev&&this.Ev(),this.Ev=void 0,gi.info("History API monitoring stopped")}monitorHistoryChanges(){Fn&&Fn.history&&(this.Pv("pushState"),this.Pv("replaceState"),this.Rv(),this.Iv()&&this.Av())}Pv(t){var e;if(!Fn||!((e=Fn.history[t])===null||e===void 0)&&e.__posthog_wrapped__)return;const n=this;bV(Fn.history,t,o=>function(i,r,s){var a;n.Ov(s)&&n.Fv(),o.call(this,i,r,s),n.Dv(t,!n.xv&&(Fn==null||(a=Fn.event)===null||a===void 0?void 0:a.type)!=="popstate")})}Cv(){const t=Fn?.location;if(t?.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}Tv(){const t=this._instance.config.capture_pageview;return t==="history_change"?{path:!0}:xA(t)?t:{}}Iv(t=this.Tv()){return!!t.hash&&!this._instance.config.disable_capture_url_hashes}Lv(t){const e=this.Tv(),n=this.$v;return!(!n||!(e.path&&t.pathname!==n.pathname||e.search&&t.search!==n.search||this.Iv(e)&&t.hash!==n.hash))}Dv(t,e=!1){try{e||this.Fv();const n=this.Cv();if(!n)return;if(this.Lv(n)){const o=()=>this._instance.capture(p2e,{navigation_type:t});e?(this.Nv=o,Promise.resolve().then(()=>this.Fv())):o()}this.$v=n}catch(n){gi.error(`Error capturing ${t} pageview`,n)}}Ov(t){var e,n;return!(Fs(t)||!Fn)&&((e=x8(String(t)))===null||e===void 0?void 0:e.href)!==((n=Fn.location)===null||n===void 0?void 0:n.href)}Fv(){const t=this.Nv;if(t){this.Nv=void 0,this.xv=!0;try{t()}catch(e){gi.error("Error capturing deferred pageview",e)}finally{this.xv=!1}this.$v=this.Cv()}}Rv(){if(this.Mv)return;const t=()=>{this.Dv("popstate")};jc(Fn,"popstate",t),this.Mv=()=>{Fn&&Fn.removeEventListener("popstate",t)}}Av(){if(this.Ev)return;const t=()=>{this.Dv("hashchange")};jc(Fn,"hashchange",t),this.Ev=()=>{Fn&&Fn.removeEventListener("hashchange",t)}}},heatmaps:class{get Mr(){return this.instance.config}constructor(t){var e;this.qv=!1,this.ko=!1,this.jv=null,this.instance=t,this.qv=!!(!((e=this.instance.persistence)===null||e===void 0)&&e.props[t2e]),this.rageclicks=new $at(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let t=5e3;return xA(this.Mr.capture_heatmaps)&&this.Mr.capture_heatmaps.flush_interval_milliseconds&&(t=this.Mr.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return Fs(this.Mr.capture_heatmaps)?Fs(this.Mr.enable_heatmaps)?this.qv:this.Mr.enable_heatmaps:this.Mr.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.ko)return;L9n.info("starting..."),this.Bv(),this.sn()}else{var t;clearInterval((t=this.jv)!==null&&t!==void 0?t:void 0),this.Hv(),this.getAndClearBuffer()}}onRemoteConfig(t){if(!t.ok)return;const e=t.config;if(!("heatmaps"in e))return;const n=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[t2e]:n}),this.qv=n,this.startIfEnabled()}getAndClearBuffer(){const t=this.Rt;return this.Rt=void 0,t}zv(t){exe(t.originalEvent)&&this.Ir(t.originalEvent,"deadclick")}sn(){this.jv&&clearInterval(this.jv),this.jv=No?.visibilityState==="visible"?setInterval(this.yl.bind(this),this.flushIntervalMilliseconds):null}Bv(){Fn&&No&&(this.Uv=this.yl.bind(this),jc(Fn,nne,this.Uv),this.Wv=t=>this.Ir(t||Fn?.event),jc(No,"click",this.Wv,{capture:!0}),this.Vv=t=>this.Gv(t||Fn?.event),jc(No,"mousemove",this.Vv,{capture:!0}),this.Qv=new zst(this.instance,LBn,this.zv.bind(this)),this.Qv.startIfEnabledOrStop(),this.Jv=this.sn.bind(this),jc(No,iV,this.Jv),this.ko=!0)}Hv(){var t;Fn&&No&&(this.Uv&&Fn.removeEventListener(nne,this.Uv),this.Wv&&No.removeEventListener("click",this.Wv,{capture:!0}),this.Vv&&No.removeEventListener("mousemove",this.Vv,{capture:!0}),this.Jv&&No.removeEventListener(iV,this.Jv),clearTimeout(this.Zv),(t=this.Qv)===null||t===void 0||t.stop(),this.ko=!1)}Kv(t,e){const n=this.instance.scrollManager.scrollY(),o=this.instance.scrollManager.scrollX(),i=this.instance.scrollManager.scrollElement(),r=(function(s,a,A){let c=s;for(;c&&b9(c)&&!j1(c,"body");){if(c===A)return!1;let h;try{var l,g,u;h=(l=(g=(u=c.ownerDocument)===null||u===void 0?void 0:u.defaultView)!==null&&g!==void 0?g:Fn)===null||l===void 0?void 0:l.getComputedStyle(c).position}catch{return!1}if(as(a,h))return!0;c=Nst(c)}return!1})(AV(t),["fixed","sticky"],i);return{x:t.clientX+(r?0:o),y:t.clientY+(r?0:n),target_fixed:r,type:e}}Ir(t,e="click"){var n;if(wst(t.target)||!exe(t))return;const o=this.Kv(t,e);!((n=this.rageclicks)===null||n===void 0)&&n.isRageClick(t.clientX,t.clientY,new Date().getTime())&&Fst(AV(t),this.instance.config.rageclick)&&this.Qs(sn(sn({},o),{},{type:"rageclick"})),this.Qs(o)}Gv(t){!wst(t.target)&&exe(t)&&(clearTimeout(this.Zv),this.Zv=setTimeout(()=>{this.Qs(this.Kv(t,"mousemove"))},500))}Qs(t){if(!Fn)return;const e=this.Mr.disable_capture_url_hashes?AQ(Fn.location.href):Fn.location.href,n=this.Mr.custom_personal_data_properties,o=this.Mr.mask_personal_data_properties?[...Ok,...n||[]]:[],i=dV(e,o,hV);this.Rt=this.Rt||{},this.Rt[i]||(this.Rt[i]=[]),this.Rt[i].push(t)}yl(){this.Rt&&!ox(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:zst,webVitalsAutocapture:class{constructor(t){var e;this._instance=t,this.qv=!1,this.ko=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Xv=()=>{clearTimeout(this.Yv),this.Yv=void 0,this.Rt.metrics.length!==0&&(this._instance.capture("$web_vitals",sn({$current_url:this.Rt.url},this.Rt.metrics.reduce((n,o)=>sn(sn({},n),{},{[`$web_vitals_${o.name}_event`]:sn({},o),[`$web_vitals_${o.name}_value`]:o.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.tf=n=>{var o;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},Fs(n?.name)||Fs(n?.value))return void HM.error("Invalid metric received",n);const i=typeof n.navigationURL=="string"?n.navigationURL:void 0,r=this.ef(i);if(Eo(r))return;const s=qd(n.navigationId)||typeof n.navigationId=="string"?`navigation:${n.navigationId}`:`url:${r}`;if(this.if&&n.value>=this.if)return void HM.error("Ignoring metric with value >= "+this.if,n);this.Rt.navigationKey!==s&&(this.Xv(),this.Yv=setTimeout(this.Xv,this.flushToCaptureTimeoutMs)),Eo(this.Rt.navigationKey)&&(this.Rt.navigationKey=s,this.Rt.url=r),this.Rt.firstMetricTimestamp=Eo(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;const a=(o=this._instance.sessionManager)===null||o===void 0?void 0:o.checkAndGetSessionAndWindowId(!0),A=sn(sn(sn({},n),i?{navigationURL:r}:{}),{},{$current_url:r,timestamp:Date.now()});if(delete A.entries,xA(n.attribution)&&this.attributionMetrics.indexOf(n.name)>-1){const c={};for(const l of k9n){const g=l==="url"&&typeof n.attribution[l]=="string"?this.ef(n.attribution[l]):n.attribution[l];Eo(g)||(c[l]=g)}A.attribution=c}else delete A.attribution;Eo(a)||(A.$session_id=a.sessionId,A.$window_id=a.windowId),this.Rt.metrics.push(A),this.Rt.metrics.length===this.allowedMetrics.length&&this.Xv()},this.nf=()=>{if(this.ko)return;let n,o,i,r,s=!1;const a=Ur.__PosthogExtensions__,A=a?.postHogWebVitalsCallbacksByFlavor,c=A?.[this.sf]||(this.sf==="web-vitals"&&Eo(A)?a?.postHogWebVitalsCallbacks:void 0);if(!Eo(c)){const u=c.withoutAttribution,h=this.attributionMetrics;s=!Eo(u),n=h.indexOf("LCP")>-1?c.onLCP:u?.onLCP||c.onLCP,o=h.indexOf("CLS")>-1?c.onCLS:u?.onCLS||c.onCLS,i=h.indexOf("FCP")>-1?c.onFCP:u?.onFCP||c.onFCP,r=h.indexOf("INP")>-1?c.onINP:u?.onINP||c.onINP}if(!(n&&o&&i&&r))return void HM.error("web vitals callbacks not loaded - not starting");const l={reportSoftNavs:this.useSoftNavs},g=s&&this.attributionMetrics.indexOf("INP")>-1?sn(sn({},l),{},{includeProcessedEventEntries:!1}):l;this.allowedMetrics.indexOf("LCP")>-1&&n(this.tf.bind(this),l),this.allowedMetrics.indexOf("CLS")>-1&&o(this.tf.bind(this),l),this.allowedMetrics.indexOf("FCP")>-1&&i(this.tf.bind(this),l),this.allowedMetrics.indexOf("INP")>-1&&r(this.tf.bind(this),g),this.ko=!0},this.qv=!!(!((e=this._instance.persistence)===null||e===void 0)&&e.props[i2e]),this.startIfEnabled()}get rf(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e;const n=xA(this.rf)?(t=this.rf)===null||t===void 0?void 0:t.web_vitals_allowed_metrics:void 0;return Fs(n)?((e=this._instance.persistence)===null||e===void 0?void 0:e.props.$web_vitals_allowed_metrics)||nAt:n}get flushToCaptureTimeoutMs(){return(xA(this.rf)?this.rf.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const t=xA(this.rf)?this.rf.web_vitals_attribution:void 0;return py(t)?t?nAt:[]:As(t)?t:T9n}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const t=xA(this.rf)?this.rf.__preview_web_vitals_soft_navs:void 0;return t!=null&&t}get if(){const t=xA(this.rf)&&qd(this.rf.__web_vitals_max_value)?this.rf.__web_vitals_max_value:tAt;return t>0&&6e4>=t?tAt:t}get isEnabled(){const t=sd?.protocol;if(t!=="http:"&&t!=="https:")return HM.info("Web Vitals are disabled on non-http/https protocols"),!1;const e=xA(this.rf)?this.rf.web_vitals:py(this.rf)?this.rf:void 0;return py(e)?e:this.qv}startIfEnabled(){this.isEnabled&&!this.ko&&(HM.info("enabled, starting..."),this.Ho(this.nf))}onRemoteConfig(t){if(!t.ok)return;const e=t.config;if(!("capturePerformance"in e))return;const n=xA(e.capturePerformance)&&!!e.capturePerformance.web_vitals,o=xA(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[i2e]:n}),this._instance.persistence.register({[est]:o})),this.qv=n,this.startIfEnabled()}get sf(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Ho(t){var e;const n=Ur.__PosthogExtensions__,o=this.sf,i=n?.postHogWebVitalsCallbacksByFlavor;i?.[o]||o==="web-vitals"&&Eo(i)&&n?.postHogWebVitalsCallbacks?t():n==null||(e=n.loadExternalDependency)===null||e===void 0||e.call(n,this._instance,o,r=>{r?HM.error("failed to load script",r):t()})}ef(t){const e=t||Fn?.location.href;if(!e)return void HM.error("Could not determine current URL");const n=this._instance.config.disable_capture_url_hashes?AQ(e):e,o=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...Ok,...o||[]]:[];return dV(n,i,hV)}}},a7n={exceptionObserver:class{constructor(t){var e;this.nf=()=>{var n;if(!Fn||!this.isEnabled||!(!((n=Ur.__PosthogExtensions__)===null||n===void 0)&&n.errorWrappingFunctions))return;const o=Ur.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Ur.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=Ur.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.af&&this.Mr.capture_unhandled_errors&&(this.af=o(this.captureException.bind(this))),!this.lf&&this.Mr.capture_unhandled_rejections&&(this.lf=i(this.captureException.bind(this))),!this.uf&&this.Mr.capture_console_errors&&(this.uf=r(this.captureException.bind(this)))}catch(s){BV.error("failed to start",s),this.hf()}},this._instance=t,this.cf=!!(!((e=this._instance.persistence)===null||e===void 0)&&e.props[n2e]),this.wt=new i4n(sn(sn({},(function(n={}){var o,i,r,s;return{refillRate:(o=(i=n.exceptionRateLimiterRefillRate)!==null&&i!==void 0?i:n.__exceptionRateLimiterRefillRate)!==null&&o!==void 0?o:1,bucketSize:(r=(s=n.exceptionRateLimiterBucketSize)!==null&&s!==void 0?s:n.__exceptionRateLimiterBucketSize)!==null&&r!==void 0?r:10}})(this._instance.config.error_tracking)),{},{refillInterval:1e4,A:BV})),this.Mr=this.df(),this.startIfEnabledOrStop()}df(){const t=this._instance.config.capture_exceptions;let e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return xA(t)?e=sn(sn({},e),t):(Eo(t)?this.cf:t)&&(e=sn(sn({},e),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Mr.capture_console_errors||this.Mr.capture_unhandled_errors||this.Mr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(BV.info("enabled"),this.hf(),this.Ho(this.nf)):this.hf()}Ho(t){var e,n,o;!((e=Ur.__PosthogExtensions__)===null||e===void 0)&&e.errorWrappingFunctions?t():(n=Ur.__PosthogExtensions__)===null||n===void 0||(o=n.loadExternalDependency)===null||o===void 0||o.call(n,this._instance,"exception-autocapture",i=>{if(i)return BV.error("failed to load script",i);t()})}hf(){var t,e,n;(t=this.af)===null||t===void 0||t.call(this),this.af=void 0,(e=this.lf)===null||e===void 0||e.call(this),this.lf=void 0,(n=this.uf)===null||n===void 0||n.call(this),this.uf=void 0}onRemoteConfig(t){if(!t.ok)return;const e=t.config;"autocaptureExceptions"in e&&(this.cf=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[n2e]:this.cf}),this.Mr=this.df(),this.startIfEnabledOrStop())}onConfigChange(){this.Mr=this.df()}captureException(t){try{var e,n,o;const i=(e=t==null||(n=t.$exception_list)===null||n===void 0||(n=n[0])===null||n===void 0?void 0:n.type)!==null&&e!==void 0?e:"Exception";if(this.wt.consumeRateLimit(i))return void BV.info("Skipping exception capture because of client rate limiting.",{exception:i});(o=this._instance.exceptions)===null||o===void 0||o.sendExceptionEvent(t)}catch{}}},exceptions:class{constructor(t){var e,n;this.vf=[],this.ff=new m4n([new M4n,new O4n,new N4n,new D4n,new L4n,new F4n,new T4n,new H4n],(function(o,...i){return(r,s=0)=>{const a=[],A=r.split(`
|
|
240
|
+
at ${i.filename}:${r}:${s}`}};const R4n=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var T4n=class{match(e){return typeof e=="string"}coerce(e,n){var o;const[i,r]=this.getInfos(e);return{type:i??"Error",value:r??e,stack:(o=n.syntheticException)===null||o===void 0?void 0:o.stack,synthetic:!0}}getInfos(e){let n="Error",o=e;const i=e.match(R4n);return i&&(n=i[1],o=i[2]),[n,o]}};const k4n=["fatal","error","warning","log","info","debug"];function Srt(t,e=40){const n=Object.keys(t);if(n.sort(),!n.length)return"[object has no keys]";for(let o=n.length;o>0;o--){const i=n.slice(0,o).join(", ");if(e>=i.length)return o===n.length?i:i.length>e?`${i.slice(0,e)}...`:i}return""}var F4n=class{match(e){return typeof e=="object"&&e!==null}coerce(e,n){var o,i;const r=this.getErrorPropertyFromObject(e);return r?n.apply(r):{type:this.getType(e),value:this.getValue(e),stack:(o=this.getStack(e))!==null&&o!==void 0?o:(i=n.syntheticException)===null||i===void 0?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){if(Dye(e))return e.constructor.name;const n="name"in e?e.name:void 0;return nA(n)&&!JK(n)?n:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){let o=`'${e.name}' captured as exception`;return"message"in e&&typeof e.message=="string"&&(o+=` with message: '${e.message}'`),o}if("message"in e&&typeof e.message=="string")return e.message;const n=this.getObjectClassName(e);return`${n&&n!=="Object"?`'${n}'`:"Object"} captured as exception with keys: ${Srt(e)}`}isSeverityLevel(e){return nA(e)&&!JK(e)&&k4n.indexOf(e)>=0}getStack(e){try{return nA(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:nA(e.stack)&&e.stack.length>0?e.stack:void 0}catch{return}}getErrorPropertyFromObject(e){for(const n in e)if({}.hasOwnProperty.call(e,n)){const o=e[n];if(Qk(o))return o}}getObjectClassName(e){try{const n=Object.getPrototypeOf(e);return n?n.constructor.name:void 0}catch{return}}},L4n=class{match(e){return Dye(e)}coerce(e,n){var o;const i=e.constructor.name;return{type:i,value:`${i} captured as exception with keys: ${Srt(e)}`,stack:(o=n.syntheticException)===null||o===void 0?void 0:o.stack,synthetic:!0}}},H4n=class{match(e){return Mit(e)}coerce(e,n){var o;return{type:"Error",value:`Primitive value captured as exception: ${String(e)}`,stack:(o=n.syntheticException)===null||o===void 0?void 0:o.stack,synthetic:!0}}},O4n=class{match(e){return kte(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Dye(e))return!1;try{const n=e.detail;return n!=null&&typeof n=="object"&&"reason"in n}catch{return!1}}coerce(e,n){var o;const i=this.getUnhandledRejectionReason(e);return Mit(i)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(i)}`,stack:(o=n.syntheticException)===null||o===void 0?void 0:o.stack,synthetic:!0}:n.apply(i)}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}};const Jte="$message",Wte="$timestamp",G4n=new Set([Jte,Wte]),zye={enabled:!0,max_bytes:32768};function jte(t){var e;return t?{enabled:(e=t.enabled)!==null&&e!==void 0?e:zye.enabled,max_bytes:U4n(t.max_bytes,zye.max_bytes)}:sn({},zye)}var Y4n=class{constructor(e){this.ns=[],this.ss=0,this.Mr=jte(e)}setConfig(e){this.Mr=jte(e),this.rs()}add(e){const n=(function(i){let r;try{r=wit(i)}catch{return}try{const s=JSON.parse(r);if(!xA(s))return;const a=s,A=a[Jte],c=a[Wte];return!nA(A)||A.trim().length===0||!nA(c)&&!qd(c)?void 0:{step:a,json:r}}catch{return}})(e);if(!n)return;const o=(function(i){if("u">typeof TextEncoder)return new TextEncoder().encode(i).length;const r=encodeURIComponent(i);let s=0;for(let a=0;r.length>a;a++)r[a]==="%"?(s+=1,a+=2):s+=1;return s})(n.json);o>this.Mr.max_bytes||(this.ns.push({step:n.step,bytes:o}),this.ss+=o,this.rs())}getAttachable(){return this.ns.map(e=>e.step)}clear(){this.ns=[],this.ss=0}size(){return this.ns.length}rs(){for(;this.ss>this.Mr.max_bytes&&this.ns.length>0;){const e=this.ns.shift();e&&(this.ss-=e.bytes)}}};function U4n(t,e){if(!qd(t)||t===1/0||t===-1/0)return e;const n=Math.floor(t);return 0>n?e:n}const Qrt=t=>{if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}};function vrt(t){return typeof t=="string"||t}function wrt(t){return typeof t=="string"?t:void 0}const K4n=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],Prt="NativeGzipValidationError",Jye=t=>t.length>=2&&t[0]===31&&t[1]===139,Mrt=(t,e)=>t===wye.GZipJS||e===wye.GZipJS||e==="gzip",Drt=t=>!(!t||typeof t!="object")&&("name"in t?String(t.name):"")==="NotReadableError";let qK;const Xte=t=>{throw prt(Prt,`Native gzip produced invalid output: ${t}`)},V4n=(Nrt=Wg(function*(t,e){18>t.size&&Xte("too-short");const n=new Uint8Array(yield t.slice(0,10).arrayBuffer());Jye(n)&&n[2]===8||Xte("invalid-header");const o=new DataView(yield t.slice(t.size-8).arrayBuffer());o.getUint32(0,!0)!==(r=>{const s=(()=>{if(qK)return qK;qK=[];for(let A=0;256>A;A++){let c=A;for(let l=0;8>l;l++)c=1&c?3988292384^c>>>1:c>>>1;qK[A]=c>>>0}return qK})();let a=4294967295;for(let A=0;r.length>A;A++)a=s[255&(a^r[A])]^a>>>8;return(4294967295^a)>>>0})(e)&&Xte("invalid-crc");const i=e.length>>>0;o.getUint32(4,!0)!==i&&Xte("invalid-size")}),function(t,e){return Nrt.apply(this,arguments)});var Nrt;function Wye(){return Wye=Wg(function*(t,e=!0,n){try{const i=new TextEncoder().encode(t),r=new globalThis.CompressionStream("gzip"),s=r.writable.getWriter(),a=s.write(i).then(()=>s.close()).catch((o=Wg(function*(l){try{yield s.abort(l)}catch{}throw l}),function(l){return o.apply(this,arguments)})),A=new Response(r.readable).blob(),[c]=yield Promise.all([A,a]);return yield V4n(c,i),c}catch(i){if(n?.rethrow)throw i;return e&&console.error("Failed to gzip compress data",i),null}var o}),Wye.apply(this,arguments)}function Rrt(t,e){if(t==null)return{};var n,o,i=(function(s,a){if(s==null)return{};var A={};for(var c in s)if({}.hasOwnProperty.call(s,c)){if(a.includes(c))continue;A[c]=s[c]}return A})(t,e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);for(o=0;r.length>o;o++)e.includes(n=r[o])||{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}const z4n={}.propertyIsEnumerable;function qte(t,e){try{return Trt(t,e,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch{return[]}}function jye(t,e,n,o){if(0>=n.remainingNodes)return{stringValue:Yye};if(n.remainingNodes--,py(t))return{boolValue:t};if(typeof t=="bigint")return(function(i,r){const s=i.toString(),a=BigInt("9223372036854775808");return i>=a||-a>i?(r?.debug(`Attribute ${s} is outside the int64 range; encoding it as a string`),{stringValue:s}):{intValue:s}})(t,e);if(typeof t=="number"){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if(typeof BigInt>"u")return{stringValue:String(t)};const i=BigInt(t).toString();return t>=9223372036854776e3||-9223372036854776e3>t?(e?.debug(`Attribute ${i} is outside the int64 range; encoding it as a string`),{stringValue:i}):{intValue:i}}return{doubleValue:t}}if(typeof t=="string")return{stringValue:wk(t)};if(typeof t=="function")return{stringValue:"[Function]"};if(typeof t=="symbol")return{stringValue:String(t)};if(typeof t=="object"&&t!==null){if(n.ancestors.has(t))return{stringValue:"[Circular]"};if(o>=20)return{stringValue:Yye};if(t instanceof Date){const i=t.getTime(),r=Number.isFinite(i)?t.toISOString():String(t);return{stringValue:typeof r=="string"?wk(r):String(r)}}n.ancestors.add(t);try{try{const i=t.toJSON;if(typeof i=="function")return jye(i.call(t),e,n,o+1)}catch{}return As(t)?{arrayValue:{values:J4n(t,e,n,o+1)}}:{kvlistValue:{values:Trt(t,e,n,o+1)}}}finally{n.ancestors.delete(t)}}return{stringValue:wk(String(t))}}function J4n(t,e,n,o){const i=[],r=Math.min(t.length,1e3);let s=0;for(;r>s&&n.remainingNodes>0;s++)try{const a=s in t?t[s]:void 0;if(Fs(a))continue;i.push(jye(a,e,n,o))}catch{i.push({stringValue:jK})}return t.length>s&&i.push({stringValue:Yye}),i}function Trt(t,e,n,o){const i=[];for(const r in t)if(z4n.call(t,r)){if(!r){e?.debug("Dropping an attribute with an empty key");continue}if(i.length>=1e3||0>=n.remainingNodes){e?.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{const s=t[r];if(ad(s)||Eo(s))continue;i.push({key:wk(r),value:jye(s,e,n,o)})}catch{i.push({key:wk(r),value:{stringValue:jK}})}}return i}function krt(t,e,n){return sn(sn(sn(sn({},urt({},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})}const W4n=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function Frt(t,e){const n=urt({},t),o={};for(const i of W4n)({}).hasOwnProperty.call(n,i)&&(o[i]=n[i],delete n[i]);return[...qte(n,e),...qte(o,e)]}const Lrt={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"},Hrt={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}},j4n=Hrt.info;function X4n(t){try{return wk(String(t))}catch{return jK}}function q4n(t,e,n,o){const i=t.level||"info",{text:r,number:s}=Hrt[i]||j4n,a=(function(u=Date.now()){return String(u)+"000000"})(qd(o)?o:void 0),A={};e.distinctId&&(A.posthogDistinctId=e.distinctId),e.sessionId&&(A.sessionId=e.sessionId),e.windowId&&(A["window.id"]=e.windowId),Fs(e.sessionStartTimestamp)||(A.sessionStartTimestamp=String(e.sessionStartTimestamp)),Fs(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);const c=sn({},A),l=t.attributes;if(l){let u=[];try{u=Object.keys(l)}catch{u=[]}for(const h of u){let d;try{d=l[h]}catch{d=jK}Object.defineProperty(c,h,{value:d,enumerable:!0,writable:!0,configurable:!0})}}const g={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:s,severityText:r,body:{stringValue:X4n(t.body)},attributes:qte(c,n)};return t.trace_id&&(g.traceId=t.trace_id),t.span_id&&(g.spanId=t.span_id),Eo(t.trace_flags)||(g.flags=t.trace_flags),g}function Ort(t,e,n){return krt(t,e,n)}function Grt(t,e,n,o){return{resourceLogs:[{resource:{attributes:Frt(e)},scopeLogs:[{scope:{name:n,version:o},logRecords:t}]}]}}var Yrt=class{constructor(e){this.ls=e,this.us=0}get pending(){return!!this.hs}arm(e){this.clear(),this.us=Date.now()+e,this.hs=_rt(()=>{this.hs=void 0,this.ls()},e)}armNoEarlierThan(e){this.hs&&Date.now()+e<=this.us||this.arm(e)}clear(){this.hs&&(clearTimeout(this.hs),this.hs=void 0)}};function Urt(){return .75+.5*Math.random()}function Krt(t,e,n,o){const i=Math.min(Math.max(0,e-1),6),r=t*Math.pow(2,i);return Math.round(Math.min(r,Math.max(o,t))*n)}var $4n=class{constructor(e,n,o,i,r,s=()=>Promise.resolve(),a){var A;this._instance=e,this.Mr=n,this.A=o,this.cs=i,this.ds=r,this.vs=s,this.fs=a,this.ps=new Yrt(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new drt,this.ks=0,this.Ss=1,this.xs=0,this.$s=0,this.Cs=!1,this.Ts=n.maxBufferSize,this.Is=Math.max((A=n.maxQueueSize)!==null&&A!==void 0?A:n.maxBufferSize,n.maxBufferSize),this.Ms=n.flushIntervalMs,this.Es=n.maxBatchRecordsPerPost,this.Ps=n.rateCapWindowMs,this.Rs=n.maxLogsPerInterval}clearQueue(){this._s++,this._instance.setPersistedProperty(x9.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.$s=0,this.Cs=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Es=this.Mr.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.As()&&this.Os():this.gs()}captureLog(e,n){var o;if(this._instance.isDisabled||this._instance.optedOut||!e?.body)return;const i=this.Fs(e);if(i===null)return;if(!i.body)return void this.A.info("Log was rejected in beforeSend function");if(!this.Ds())return;const r={record:q4n(i,(o=n?.context)!==null&&o!==void 0?o:this.cs(),this.A,n?.occurredAtMs)};this.ds(()=>this.Ls(r))}Fs(e){const n=this.Mr.beforeSend;if(!n)return e;const o=As(n)?n:[n];let i=e;for(const r of o)try{const s=r(i);if(!s)return this.A.info("Log was rejected in beforeSend function"),null;i=s}catch(s){return this.A.error("Error in beforeSend function for log:",s),null}return i}Ds(){if(this.Rs===void 0)return!0;const e=Date.now(),n=e-this.xs;return this.Ps>n&&n>=0||(this.xs=e,this.$s=0,this.Cs=!1),this.Rs>this.$s?(this.$s++,!0):(this.Cs||(this.A.warn(`captureLog dropping logs: exceeded ${this.Rs} logs per ${this.Ps}ms`),this.Cs=!0),!1)}flush(){var e=this;return Wg(function*(){if(!e._instance.isDisabled)return e.ys||(e.ys=e.Ns().finally(()=>{e.ys=null})),e.ys})()}Ns(){var e=this;return Wg(function*(){var n;e.ps.clear();let o=(n=e._instance.getPersistedProperty(x9.LogsQueue))!==null&&n!==void 0?n:[];if(o.length===0)return;const i=o.length;let r=0;for(;o.length>0&&i>r;){var s,a;const A=e._s;e.bs=0;const c=Math.min(o.length,e.Es),l=o.slice(0,c),g=Grt(l.map(h=>h.record),e.qs(),(s=e.fs)!==null&&s!==void 0?s:e._instance.getLibraryId(),e._instance.getLibraryVersion()),u=yield e._instance.js(g);if(e._s!==A)return;if(u.kind==="too-large"&&l.length>1)e.Es=Math.max(1,Math.floor(l.length/2)),e.A.warn(`Logs batch of size ${l.length} was too large for the ingestion endpoint, reducing batch size to ${e.Es}`);else if(e.ws.record(u),e.ps.pending&&e.ps.arm(Math.max(e.Ms,e.ws.remainingMs())),u.kind==="retry-later"||(u.kind==="too-large"?e.A.warn("Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further."):u.kind==="ok"&&e.Mr.maxBatchRecordsPerPost>e.Es&&(e.Es=Math.min(e.Mr.maxBatchRecordsPerPost,e.Es+1)),yield e.Bs(l.length),o=(a=e._instance.getPersistedProperty(x9.LogsQueue))!==null&&a!==void 0?a:[],r+=l.length,u.kind==="fatal"))throw u.error}})()}Bs(e){var n=this;return Wg(function*(){var o;const i=Math.max(0,e-n.bs),r=(o=n._instance.getPersistedProperty(x9.LogsQueue))!==null&&o!==void 0?o:[];n._instance.setPersistedProperty(x9.LogsQueue,r.slice(i)),yield n.vs()})()}qs(){return Ort(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(e){var n;if(this._instance.optedOut)return;const o=(n=this._instance.getPersistedProperty(x9.LogsQueue))!==null&&n!==void 0?n:[];this.Is>o.length||(o.shift(),this.bs++,this.A.info("Logs queue is full, dropping oldest record.")),o.push(e),this._instance.setPersistedProperty(x9.LogsQueue,o),this.Ts>o.length||this.ws.isOpen()?this.Os():this.gs()}Os(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}Hs(){return Math.max(Krt(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){const e=this._instance.getPersistedProperty(x9.LogsQueue);return!!e&&e.length>0}shutdown(e){var n=this;return Wg(function*(){n.ps.clear();const o=n.flush().catch(()=>{});e!==void 0?yield frt(o,e):yield o})()}flushWithTimeout(e){var n=this;return Wg(function*(){const o=n.flush();yield frt(o,e,()=>{o.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},e=>{this.ks++,this.Ss=Urt(),this.A.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.Hs())})}};const Xye=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Vrt(t){return String(t)+"000000"}function zrt(t,e,n,o){let i="";return o&&(i=Object.keys(o).sort().map(r=>`${JSON.stringify(r)}:${JSON.stringify(o[r])}`).join(",")),`${t}\0${e}\0${n??""}\0${i}`}var Z4n=class{constructor(e,n,o){this._instance=e,this.Mr=n,this.A=o,this.zs=new Map,this.ps=new Yrt(()=>this.flush().catch(i=>{this.A.error("Metrics flush failed:",i)})),this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.ws=new drt,this.ks=0,this.Ss=1,this.Gs=0}count(e,n=1,o){this.Qs({name:e,type:"count",value:n,unit:o?.unit,attributes:o?.attributes})}gauge(e,n,o){this.Qs({name:e,type:"gauge",value:n,unit:o?.unit,attributes:o?.attributes})}histogram(e,n,o){this.Qs({name:e,type:"histogram",value:n,unit:o?.unit,attributes:o?.attributes})}flush(){var e=this;const n=this.ys,o=(function(){var i=Wg(function*(){n&&(yield n.catch(()=>{})),yield e.Js()});return function(){return i.apply(this,arguments)}})()().finally(()=>{this.ys===o&&(this.ys=null)});return this.ys=o,o}drainWindow(){if(this.zs.size===0)return null;const e=this.zs;return this.zs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Zs(e)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.zs=new Map,this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set}Qs(e){if(this._instance.isDisabled||this._instance.optedOut)return;const n=this.Fs(e);if(n===null)return;if(!n.name||typeof n.name!="string")return void this.A.warn("Dropping metric with empty name");if(typeof n.value!="number"||!Number.isFinite(n.value))return void this.A.warn(`Dropping metric '${n.name}': value must be a finite number`);if(n.type==="count"&&0>n.value)return void this.A.warn(`Dropping count '${n.name}': counters are monotonic, value must be >= 0`);let o,i;try{o=n.attributes?sn({},n.attributes):void 0,i=zrt(n.type,n.name,n.unit,o)}catch(a){return void this.A.warn(`Dropping metric '${n.name}': attributes could not be serialized`,a)}let r=this.zs.get(i);if(!r){if(!this.Ks())return;r={name:n.name,type:n.type,unit:n.unit,attributes:o,windowStartMs:Date.now()},this.zs.set(i,r)}const s=this.Ws.get(n.name);s===void 0?this.Ws.set(n.name,n.type):s===n.type||this.Vs.has(n.name)||(this.Vs.add(n.name),this.A.warn(`Metric name '${n.name}' is already used as a ${s}; recording it as a ${n.type} too will blend both series in charts. Use a distinct name.`)),this.Xs(r,n.value),this.Os()}Ks(){return this.Mr.maxSeriesPerFlush>this.zs.size||(this.Us||(this.Us=!0,this.A.warn(`Metric series cap reached (${this.Mr.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}Xs(e,n){switch(e.type){case"count":var o;e.total=((o=e.total)!==null&&o!==void 0?o:0)+n;break;case"gauge":e.last=n;break;case"histogram":{e.hist||(e.hist={count:0,sum:0,min:n,max:n,bucketCounts:new Array(Xye.length+1).fill(0)});const i=e.hist;i.count+=1,i.sum+=n,i.min=Math.min(i.min,n),i.max=Math.max(i.max,n),i.bucketCounts[(function(r,s){for(let a=0;s.length>a;a++)if(s[a]>=r)return a;return s.length})(n,Xye)]+=1;break}}}Fs(e){const n=this.Mr.beforeSend;if(!n)return e;const o=As(n)?n:[n];let i=e;for(const r of o)try{const s=r(i);if(!s)return this.A.info("Metric was rejected in beforeSend function"),null;i=s}catch(s){return this.A.error("Error in beforeSend function for metric:",s),null}return i}Os(){this.ps.pending||this.ps.arm(this.Hs())}Hs(){return Math.max(Krt(this.Mr.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Js(){var e=this;return Wg(function*(){if(e.ps.clear(),e.zs.size===0)return;const n=e.zs;e.zs=new Map,e.Us=!1,e.Ws=new Map,e.Vs=new Set;const o=e.Gs,i=yield e._instance.Ys(e.Zs(n));if(o===e.Gs)switch(e.ws.record(i),i.kind==="retry-later"?(e.ks++,e.Ss=Urt()):(e.ks=0,e.Ss=1),e.ps.pending&&e.ps.arm(e.Hs()),i.kind){case"ok":return;case"retry-later":return e.ho(n),void e.ps.armNoEarlierThan(e.Hs());case"too-large":return void e.A.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e.A.error("Failed to send metrics batch:",i.error)}})()}Zs(e){return n=this.co(e),o=(function(s,a,A){return krt(s,a,A)})(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),i=this._instance.getLibraryId(),r=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Frt(o)},scopeMetrics:[{scope:{name:i,version:r},metrics:n}]}]};var n,o,i,r}co(e){const n=Vrt(Date.now()),o=new Map;for(const a of e.values()){var i;const A=zrt(a.type,a.name,a.unit,void 0);let c=o.get(A);c||(c=sn({name:a.name},a.unit&&{unit:a.unit}),a.type==="count"?c.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:a.type==="gauge"?c.gauge={dataPoints:[]}:c.histogram={aggregationTemporality:1,dataPoints:[]},o.set(A,c));const l=qte((i=a.attributes)!==null&&i!==void 0?i:{},this.A),g=Vrt(a.windowStartMs);if(a.type==="count"){var r;const u={attributes:l,startTimeUnixNano:g,timeUnixNano:n,asDouble:(r=a.total)!==null&&r!==void 0?r:0};c.sum.dataPoints.push(u)}else if(a.type==="gauge"){var s;const u={attributes:l,timeUnixNano:n,asDouble:(s=a.last)!==null&&s!==void 0?s:0};c.gauge.dataPoints.push(u)}else a.hist&&c.histogram.dataPoints.push({attributes:l,startTimeUnixNano:g,timeUnixNano:n,count:a.hist.count,sum:a.hist.sum,min:a.hist.min,max:a.hist.max,bucketCounts:a.hist.bucketCounts,explicitBounds:Xye})}return Array.from(o.values())}ho(e){for(const[i,r]of e){const s=this.zs.get(i);if(s)switch(s.windowStartMs=Math.min(s.windowStartMs,r.windowStartMs),s.type){case"count":var n,o;s.total=((n=s.total)!==null&&n!==void 0?n:0)+((o=r.total)!==null&&o!==void 0?o:0);break;case"gauge":break;case"histogram":if(r.hist)if(s.hist){s.hist.count+=r.hist.count,s.hist.sum+=r.hist.sum,s.hist.min=Math.min(s.hist.min,r.hist.min),s.hist.max=Math.max(s.hist.max,r.hist.max);for(let a=0;s.hist.bucketCounts.length>a;a++)s.hist.bucketCounts[a]+=r.hist.bucketCounts[a]}else s.hist=r.hist}else this.Ks()&&this.zs.set(i,r)}}};const Jrt=(t,{debugEnabled:e}={})=>{const n={N(o,...i){Fn&&(f8.DEBUG||Fn.POSTHOG_DEBUG||e)&&!Eo(Fn.console)&&Fn.console&&("__rrweb_original__"in Fn.console[o]?Fn.console[o].__rrweb_original__:Fn.console[o])(t,...i)},debug(...o){n.N("debug",...o)},info(...o){n.N("log",...o)},warn(...o){n.N("warn",...o)},error(...o){n.N("error",...o)},critical(...o){console.error(t,...o)},uninitializedWarning(o){n.error(`You must initialize PostHog before calling ${o}`)},createLogger:(o,i)=>Jrt(`${t} ${o}`,i)};return n},gi=Jrt("[PostHog.js]"),Ad=gi.createLogger,eBn=Ad("[ExternalScriptsLoader]"),$te=t=>{const e=No?.querySelectorAll("script");if(e){for(let n=0;e.length>n;n++)if(e[n].src===t||e[n].getAttribute("src")===t)return e[n]}},DM=(t,e,n)=>{if(t.config.disable_external_dependency_loading)return eBn.warn(`${e} was requested but loading of external scripts is disabled.`),n("Loading of external scripts is disabled");const o=$te(e);if(o){if(o.__posthog_loading_callback_fired)return n();const r=o.__posthog_loading_error;return r?n(r):(o.addEventListener("load",s=>{o.__posthog_loading_callback_fired=!0,n(void 0,s)}),void o.addEventListener("error",s=>{o.__posthog_loading_error=s,n(s)}))}const i=()=>{if(!No)return n("document not found");if($te(e))return DM(t,e,n);let r=No.createElement("script");if(r.type="text/javascript",r.crossOrigin="anonymous",r.src=e,r.onload=a=>{r.__posthog_loading_callback_fired=!0,n(void 0,a)},r.onerror=a=>{r.__posthog_loading_error=a,n(a)},t.config.prepare_external_dependency_script&&(r=t.config.prepare_external_dependency_script(r)),!r)return n("prepare_external_dependency_script returned null");if(t.config.external_scripts_inject_target==="head")No.head.appendChild(r);else{const a=No.querySelectorAll("body > script");var s;a.length>0?(s=a[0].parentNode)===null||s===void 0||s.insertBefore(r,a[0]):No.body.appendChild(r)}};No?.body?i():No?.addEventListener("DOMContentLoaded",i)},qye={},Wrt=(t,e)=>{let n=`/static/${e}.js?v=${t.version}`;return e==="toolbar"&&(n=`${n}&t=${Math.floor(Date.now()/3e5)*3e5}`),t.requestRouter.endpointFor("assets",n)};Ur.__PosthogExtensions__=Ur.__PosthogExtensions__||{},Ur.__PosthogExtensions__.loadExternalDependency=(t,e,n)=>{if(e==="remote-config"){const i=t.requestRouter.endpointFor("assets",`/array/${t.config.token}/config.js`);return void DM(t,i,n)}const o=t.config.strict_script_versioning;if(o){const i=t.requestRouter.endpointFor("assets",`/static/${t.version}/${e}.js`),r=qye[i];if(o==="fallback"&&r){if($te(r))return void DM(t,r,n);delete qye[i]}return void DM(t,i,o==="fallback"?(s,a)=>{if(s)if(typeof s=="string")n(s);else{var A;const c=Wrt(t,e);qye[i]=c;const l=$te(i);l==null||(A=l.parentNode)===null||A===void 0||A.removeChild(l),DM(t,c,n)}else n(void 0,a)}:n)}DM(t,Wrt(t,e),n)},Ur.__PosthogExtensions__.loadSiteApp=(t,e,n)=>{const o=t.requestRouter.endpointFor("api",e);DM(t,o,n)},f8.DEBUG=!1,f8.LIB_VERSION="1.435.9",f8.LIB_NAME="web";var Ym=f8;const tBn="$people_distinct_id",T4="distinct_id",$ye="$device_id",Zye="$device_model",Zte="__alias",nBn="__cmpns",jrt="$fbc",Pk="$fbc_persistence",Xrt="$fbp",$K="$fbp_persistence",e2e="__timers",qrt="$autocapture_disabled_server_side",t2e="$heatmaps_enabled_server_side",n2e="$exception_capture_enabled_server_side",$rt="$error_tracking_suppression_rules",o2e="$error_tracking_capture_extension_exceptions",i2e="$web_vitals_enabled_server_side",r2e="$dead_clicks_enabled_server_side",s2e="$product_tours_enabled_server_side",Zrt="$logs_capture_enabled_server_side",est="$web_vitals_allowed_metrics",ZK="$session_recording_remote_config",oBn="$session_recording_enabled_server_side",iBn="$replay_sample_rate",rBn="$replay_override_sampling",sBn="$replay_override_linked_flag",aBn="$replay_override_url_trigger",ABn="$replay_override_event_trigger",Mk="$sesid",tst="$session_is_sampled",cBn="$session_past_minimum_duration",lBn="$session_recording_url_trigger_activated_session",gBn="$session_recording_event_trigger_activated_session",uBn="$debug_first_full_snapshot_timestamp",dBn="$sess_rec_flush_size",k4="$enabled_feature_flags",C8="$active_feature_flags",a2e="$early_access_features",NM="$feature_flag_details",cQ="$feature_flag_payloads",RM="$feature_flag_request_id",eV="$minimal_flag_called_events",B9="$override_feature_flags",TM="$override_feature_flag_payloads",lQ="$stored_person_properties",gQ="$stored_group_properties",nst="$groups",tV="$surveys",ene="$surveys_loaded_at",ost="$surveys_activated",ist="$surveys_activated_session",rst="$surveys_activated_timestamps",A2e="ph_product_tours",hBn="$product_tours_activated",pBn="$product_tours_activated_session",mBn="$conversations_widget_session_id",_Bn="$conversations_ticket_id",fBn="$conversations_widget_state",IBn="$conversations_user_traits",uQ="$flag_call_reported",nV="$flag_call_reported_session_id",oV="$feature_flag_errors",dQ="$feature_flag_evaluated_at",my="$user_state",c2e="$client_session_props",CBn="$capture_rate_limit",sst="$initial_campaign_params",ast="$initial_referrer_info",Dk="$initial_person_info",l2e="$epp",g2e="$posthog_cookieless",Ast="$cookieless_mode",cst="$sdk_debug_extensions_init_method",lst="$sdk_debug_extensions_init_time_ms",u2e="$sdk_debug_recording_script_not_loaded",d2e="$sdk_debug_replay_stale_config",gst="$sdk_debug_replay_event_trigger_status",ust="$sdk_debug_replay_linked_flag_trigger_status",dst="$sdk_debug_replay_matched_recording_trigger_groups",hst="$sdk_debug_replay_pending_trigger_conditions",pst="$sdk_debug_replay_remote_trigger_matching_config",mst="$sdk_debug_replay_trigger_groups_count",_st="$sdk_debug_replay_url_trigger_status",yBn="$session_recording_start_reason",h2e="PostHog loadExternalDependency extension not found.",y8="anonymous",tne="identified",fst="identified_only",iV="visibilitychange",nne="beforeunload",p2e="$pageview",Ist="$pageleave",Cst="$identify",yst="$groupidentify";function Nk(t,e){As(t)&&t.forEach(e)}function vl(t,e){if(!Fs(t))if(As(t))t.forEach(e);else if((n=>n instanceof FormData)(t))t.forEach((n,o)=>e(n,o));else for(const n in t)Mye.call(t,n)&&e(t[n],n)}const jg=function(t,...e){for(const n of e)for(const o in n)n[o]!==void 0&&(t[o]=n[o]);return t};function one(t){const e=Object.keys(t);let n=e.length;const o=new Array(n);for(;n--;)o[n]=[e[n],t[e[n]]];return o}const xBn=function(t){return function(...e){try{return t.apply(this,e)}catch(n){gi.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),gi.critical(n)}}},m2e=function(t){const e={};return vl(t,function(n,o){(nA(n)&&n.length>0||qd(n))&&(e[o]=n)}),e};function xst(t){const e=sn({},t);for(const n of["name","message","stack","cause","errors"])try{n in t&&(e[n]=t[n])}catch{}return e}const EBn=["herokuapp.com","vercel.app","netlify.app"];function BBn(t){const e=t?.hostname;if(!nA(e))return!1;const n=e.split(".").slice(-2).join(".");for(const o of EBn)if(n===o)return!1;return!0}function jc(t,e,n,o){const{capture:i=!1,passive:r=!0}=o??{};t?.addEventListener(e,n,{capture:i,passive:r})}function _2e(t){return t.name==="ph_toolbar_internal"}const rV=t=>{if(No){try{const e=t+"=",n=No.cookie.split(";").filter(o=>o.length);for(let o=0;n.length>o;o++){let i=n[o];for(;i.charAt(0)==" ";)i=i.substring(1,i.length);if(i.indexOf(e)===0)return decodeURIComponent(i.substring(e.length,i.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 qd(t)&&isFinite(t)&&Math.floor(t)===t});var bBn=class $nt{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,n,o,i){if(!Number.isInteger(e)||!Number.isInteger(n)||!Number.isInteger(o)||!Number.isInteger(i)||0>e||0>n||0>o||0>i||e>0xffffffffffff||n>4095||o>1073741823||i>4294967295)throw new RangeError("invalid field value");const r=new Uint8Array(16);return r[0]=e/Math.pow(2,40),r[1]=e/Math.pow(2,32),r[2]=e/Math.pow(2,24),r[3]=e/Math.pow(2,16),r[4]=e/256,r[5]=e,r[6]=112|n>>>8,r[7]=n,r[8]=128|o>>>24,r[9]=o>>>16,r[10]=o>>>8,r[11]=o,r[12]=i>>>24,r[13]=i>>>16,r[14]=i>>>8,r[15]=i,new $nt(r)}toString(){let e="";for(let 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 $nt(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(let n=0;16>n;n++){const o=this.bytes[n]-e.bytes[n];if(o!==0)return Math.sign(o)}return 0}},SBn=class{generate(){const e=this.generateOrAbort();if(!Eo(e))return e;{this.Ct=0;const n=this.generateOrAbort();if(Eo(n))throw new Error("Could not generate UUID after timestamp reset");return n}}generateOrAbort(){const e=(()=>{const n=Date.now();return qd(n)&&isFinite(n)?Math.min(Math.max(Math.floor(n),0),0xffffffffffff):0})();if(e>this.Ct)this.Ct=e,this.It();else{if(this.Ct>=e+1e4)return;this.Mt++,this.Mt>4398046511103&&(this.Ct++,this.It())}return bBn.fromFieldsV7(this.Ct,Math.trunc(this.Mt/Math.pow(2,30)),this.Mt&Math.pow(2,30)-1,this.Tt.nextUint32())}It(){this.Mt=1024*this.Tt.nextUint32()+(1023&this.Tt.nextUint32())}constructor(){this.Ct=0,this.Mt=0,this.Tt=new QBn}};let Est=t=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(let e=0;t.length>e;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};Fn&&!Eo(Fn.crypto)&&crypto.getRandomValues&&(Est=t=>crypto.getRandomValues(t));var QBn=class{nextUint32(){return this.Rt.length>this.At||(Est(this.Rt),this.At=0),this.Rt[this.At++]}constructor(){this.Rt=new Uint32Array(8),this.At=1/0}};let Bst;const F4=()=>vBn().toString(),vBn=()=>(Bst||(Bst=new SBn)).generate();let sV="";const wBn=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let Rk=null;const cd={Et(){if(!ad(Rk))return Rk;if(Rk=!1,No)try{const t=`__ph_cookie_support_${F4()}`;cd.$t(t,"xyz"),Rk=rV(t)==='"xyz"',cd.Pt(t)}catch{Rk=!1}return Rk},Dt(t){gi.error("cookieStore error: "+t)},Ot:rV,Lt(t){let e;try{e=JSON.parse(cd.Ot(t))||{}}catch{}return e},$t(t,e,n,o,i){if(!No)return!1;try{let r="",s="";const a=(function(c,l){if(l){let g=(function(u,h=No){if(sV)return sV;if(!h||["localhost","127.0.0.1"].includes(u))return"";const d=u.split(".");let p=Math.min(d.length,8);const m="dmn_chk_"+F4();for(;!sV&&p--;){const _=d.slice(p).join("."),f=m+"=1;domain=."+_+";path=/";h.cookie=f+";max-age=3",h.cookie.includes(m)&&(h.cookie=f+";max-age=0",sV=_)}return sV})(c);if(!g){const u=(h=>{const d=h.match(wBn);return d?d[0]:""})(c);u!==g&&gi.info("Warning: cookie subdomain discovery mismatch",u,g),g=u}return g?"; domain=."+g:""}return""})(No.location.hostname,o);if(n){const c=new Date;c.setTime(c.getTime()+864e5*n),r="; expires="+c.toUTCString()}i&&(s="; secure");const A=t+"="+encodeURIComponent(JSON.stringify(e))+r+"; SameSite=Lax; path=/"+a+s;return A.length>3686.4&&gi.warn("cookieStore warning: large cookie, len="+A.length),No.cookie=A,!0}catch{return!1}},Pt(t,e){if(No?.cookie&&(!e||!ad(rV(t))))try{cd.$t(t,"",-1,e)}catch{return}}};let f2e=null;const uc={Et(){if(!ad(f2e))return f2e;let t=!0;if(Eo(Fn))t=!1;else try{const e="__mplssupport__";uc.$t(e,"xyz"),uc.Ot(e)!=='"xyz"'&&(t=!1),uc.Pt(e)}catch{t=!1}return t||gi.error("localStorage unsupported; falling back to cookie store"),f2e=t,t},Dt(t){gi.error("localStorage error: "+t)},Ot(t){try{return Fn?.localStorage.getItem(t)}catch(e){uc.Dt(e)}return null},Lt(t){try{return JSON.parse(uc.Ot(t))||{}}catch{}return null},$t(t,e){try{return Fn?.localStorage.setItem(t,JSON.stringify(e)),!0}catch(n){uc.Dt(n)}return!1},Pt(t){try{Fn?.localStorage.removeItem(t)}catch(e){uc.Dt(e)}}},I2e=[lQ,C8,k4,NM,cQ,RM,dQ,oV,uQ],kM=[$ye,T4,Mk,tst,l2e,Dk,Pk,my],ine=t=>t+"_cpm",PBn=["__proto__","constructor","prototype"],C2e=t=>{if(!xA(t))return{};const e={};return Object.keys(t).forEach(n=>{PBn.indexOf(n)===-1&&(e[n]=t[n])}),e},y2e=(t,e=[])=>{const n={};return[...kM,...e].forEach(o=>{const i=t[o];Eo(i)||ad(i)||i===""||(n[o]=i)}),n},bst=t=>{let e=5381,n=2166136261;for(let o=0;t.length>o;o++){const i=t.charCodeAt(o);e=33*e^i,n=Math.imul(n^i,16777619)}return t.length.toString(36)+"."+(e>>>0).toString(36)+"."+(n>>>0).toString(36)},Sst=(t,e)=>({p:e,f:bst(JSON.stringify(t))}),Qst=(t,e)=>{if(!e)return{properties:[],isValid:!1};try{const n=cd.Lt(ine(t)),o=n?.f===bst(e)&&As(n.p);return{properties:o?n.p:[],isValid:o}}catch{return{properties:[],isValid:!1}}},x2e=(t,e)=>e+"|"+(cd.Ot(ine(t))||""),Tk={},E2e={Et:()=>!0,Dt(t){gi.error("memoryStorage error: "+t)},Ot:t=>t in Tk?Tk[t]:null,Lt:t=>t in Tk?Tk[t]:null,$t:(t,e)=>(Tk[t]=e,!0),Pt(t){delete Tk[t]}};let FM=null;const Z0={Et(){if(!ad(FM))return FM;if(FM=!0,Eo(Fn))FM=!1;else try{const t="__support__";Z0.$t(t,"xyz"),Z0.Ot(t)!=='"xyz"'&&(FM=!1),Z0.Pt(t)}catch{FM=!1}return FM},Dt(t){gi.error("sessionStorage error: ",t)},Ot(t){try{return Fn?.sessionStorage.getItem(t)}catch(e){Z0.Dt(e)}return null},Lt(t){try{return JSON.parse(Z0.Ot(t))||null}catch{}return null},$t(t,e){try{return Fn?.sessionStorage.setItem(t,JSON.stringify(e)),!0}catch(n){Z0.Dt(n)}return!1},Pt(t){try{Fn?.sessionStorage.removeItem(t)}catch(e){Z0.Dt(e)}}};var MBn=class{constructor(e){this._instance=e}get Mr(){return this._instance.config}get consent(){return this.Do()?0:this.Lo}isOptedOut(){return this.Mr.cookieless_mode==="always"||this.isRejected()||this.consent===-1&&this.Mr.cookieless_mode==="on_reject"}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Mr.opt_out_capturing_by_default}optInOut(e){this.No.$t(this.qo,e?1:0,this.Mr.cookie_expiration,this.Mr.cross_subdomain_cookie,this.Mr.secure_cookie)}reset(){this.No.Pt(this.qo,this.Mr.cross_subdomain_cookie)}get qo(){const{token:e,opt_out_capturing_cookie_prefix:n,consent_persistence_name:o}=this._instance.config;return o||(n?n+e:"__ph_opt_in_out_"+e)}get Lo(){const e=this.No.Ot(this.qo);return Nye(e)?1:as(n4n,e)?0:-1}get No(){const e=this.Mr.opt_out_capturing_persistence_type,n=e==="localStorage"?uc:cd,o=n.Et()?n:E2e;if(!this.jo||this.jo!==o){this.jo=o;const i=e==="localStorage"?cd:uc;i.Ot(this.qo)&&(this.jo.Ot(this.qo)||this.optInOut(Nye(i.Ot(this.qo))),i.Pt(this.qo,this.Mr.cross_subdomain_cookie))}return this.jo}Do(){return!!this.Mr.respect_dnt&&[F_?.doNotTrack,F_?.msDoNotTrack,Ur.doNotTrack,F_?.globalPrivacyControl].some(e=>Nye(e))}};function vst(t,e){var n;const o=t==null||(n=t.config)===null||n===void 0?void 0:n.get_current_url;if(!L_(o))return e;try{const i=o(e);return nA(i)&&i?i:e}catch(i){return gi.error("Error in get_current_url, falling back to window.location.href",i),e}}function wst(t){var e;return t instanceof Element&&(t.id==="__POSTHOG_TOOLBAR__"||!!(!((e=t.closest)===null||e===void 0)&&e.call(t,".toolbar-global-fade-container")))}function b9(t){return!!t&&t.nodeType===1}function j1(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function Pst(t){return!!t&&t.nodeType===3}function B2e(t){return!!t&&t.nodeType===11&&b9(t.host)}function b2e(t){return t?Rte(t).split(/\s+/):[]}function Mst(t,e){const n=(function(o){var i;const r=Fn==null||(i=Fn.location)===null||i===void 0?void 0:i.href;return Eo(r)?void 0:vst(o,r)})(e);return!!(n&&t&&t.some(o=>n.match(o)))}function kk(t){let 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 b2e(e)}function Dst(t){return Fs(t)?null:Rte(t).split(/(\s+)/).filter(e=>lV(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function aV(t){let e="";return Fk(t)&&!cV(t)&&t.childNodes&&t.childNodes.length&&vl(t.childNodes,function(n){var o;Pst(n)&&n.textContent&&(e+=(o=Dst(n.textContent))!==null&&o!==void 0?o:"")}),Rte(e)}function AV(t){var e;return Eo(t.target)?t.srcElement||null:!((e=t.target)===null||e===void 0)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null}const S2e=["a","button","form","input","select","textarea","label"];function Q2e(t,e){const n=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!n&&n.call(t,e)}catch{return!1}}function v2e(t,e){if(Eo(e))return!0;for(const n of t)if(e.some(o=>Q2e(n,o)))return!0;return!1}function Nst(t){const e=t.parentNode;return!(!e||!b9(e))&&e}const w2e=[".ph-no-autocapture","[data-ph-no-autocapture]"],Rst=["next","previous","prev",">","<"],DBn=[...Rst,"+","-","−","–"],Tst=(t,e)=>/[a-z0-9]/i.test(e)?t.includes(e):t===e,kst=[".ph-no-rageclick",".ph-no-capture"],NBn=["","text","search","email","password","url","tel","number"];function Fst(t,e){if(!Fn||P2e(t))return!1;let n,o,i;var r,s;if(py(e)?(n=!!e&&kst,o=void 0,i=!1):(n=(r=e?.css_selector_ignorelist)!==null&&r!==void 0?r:kst,o=e?.content_ignorelist,i=(s=e?.ignore_text_selection)!==null&&s!==void 0&&s),n===!1||i&&(function(A){return!(!A||!b9(A))&&(!!j1(A,"textarea")||(j1(A,"input")?as(NBn,(A.getAttribute("type")||"").toLowerCase()):(function(c){var l;if(c.isContentEditable)return!0;const g=(l=c.getAttribute)===null||l===void 0?void 0:l.call(c,"contenteditable");return g==="true"||g===""})(A)))})(t))return!1;const{targetElementList:a}=Lst(t,!1);return!(function(A,c){if(A===!1||Eo(A))return!1;let l;if(A===!0)l=Rst;else{if(!As(A))return!1;if(A.length>10)return gi.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;l=A.map(g=>g.toLowerCase())}return c.some(({safeText:g,ariaLabel:u})=>l.some(h=>Tst(g,h)||Tst(u,h)))})(o,a.map(A=>{var c;return{safeText:aV(A).toLowerCase(),ariaLabel:((c=A.getAttribute("aria-label"))===null||c===void 0?void 0:c.toLowerCase().trim())||""}}))&&!v2e(a,n)}const P2e=t=>!t||j1(t,"html")||!b9(t),Lst=(t,e)=>{if(!Fn||P2e(t))return{parentIsUsefulElement:!1,targetElementList:[]};let n=!1;const o=[t];let i=t;for(;i.parentNode&&!j1(i,"body");){if(B2e(i.parentNode)){o.push(i.parentNode.host),i=i.parentNode.host;continue}const r=Nst(i);if(!r)break;if(e||S2e.indexOf(r.tagName.toLowerCase())>-1)n=!0;else try{const s=Fn.getComputedStyle(r);s&&s.getPropertyValue("cursor")==="pointer"&&(n=!0)}catch{}o.push(r),i=r}return{parentIsUsefulElement:n,targetElementList:o}};function Fk(t){const e=new Set;let n=0;for(let r=t;r.parentNode&&!j1(r,"body");r=r.parentNode){if(n++>=1e3||e.has(r))return!1;e.add(r);const s=kk(r);if(as(s,"ph-sensitive")||as(s,"ph-no-capture"))return!1}if(as(kk(t),"ph-include"))return!0;const o=t.type||"";if(nA(o))switch(o.toLowerCase()){case"hidden":case"password":return!1}const i=t.name||t.id||"";return!nA(i)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,""))}function cV(t){return!!(j1(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||j1(t,"select")||j1(t,"textarea")||t.getAttribute("contenteditable")==="true")}const Hst=new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),Ost=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,RBn=[16,15,14,13],TBn=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Gst=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Yst=/[0-9A-Za-z_]/;function kBn(t){let e=0,n=!1;for(let o=t.length-1;o>=0;o--){let i=t.charCodeAt(o)-48;n&&(i*=2,i>9&&(i-=9)),e+=i,n=!n}return e%10==0}function lV(t,e=!0){return!(Fs(t)||nA(t)&&(t=Rte(t),(e?Hst.test((t||"").replace(/[- ]/g,"")):(function(n){let o;for(Ost.lastIndex=0;o=Ost.exec(n);){const i=o[2];if(!i)continue;const r=i.replace(/[- ]/g,"");for(let s=0;r.length>s;s++)for(const a of RBn){const A=s+a;if(r.length>=A){const c=r.slice(s,A);if(Hst.test(c)&&kBn(c))return!0}}}return!1})(t))||(e?TBn.test(t):(function(n){let o;for(Gst.lastIndex=0;o=Gst.exec(n);){const i=o[1],r=o[3];if(!(i&&r&&Yst.test(i)&&Yst.test(r)))return!0}return!1})(t))))}function Ust(t){let e=aV(t);return e=`${e} ${Kst(t)}`.trim(),lV(e)?e:""}function Kst(t){let e="";return t&&t.childNodes&&t.childNodes.length&&vl(t.childNodes,function(n){var o;if(n&&((o=n.tagName)===null||o===void 0?void 0:o.toLowerCase())==="span")try{const i=aV(n);e=`${e} ${i}`.trim(),n.childNodes&&n.childNodes.length&&(e=`${e} ${Kst(n)}`.trim())}catch(i){gi.error("[AutoCapture]",i)}}),e}function Vst(t){return t.replace(/"|\\"/g,'\\"')}function FBn(t){const e=t.attr__class;if(e)return As(e)?e:b2e(e)}const rne=Ad("[Dead Clicks]"),LBn=()=>!0,HBn=t=>{var e;const n=!!(!((e=t.instance.persistence)===null||e===void 0)&&e.get_property(r2e)),o=t.instance.config.capture_dead_clicks;return py(o)?o:!!xA(o)||n};var zst=class{get lazyLoadedDeadClicksAutocapture(){return this.Bo}constructor(e,n,o){this.instance=e,this.isEnabled=n,this.onCapture=o,this.startIfEnabledOrStop()}onRemoteConfig(e){if(!e.ok)return;const n=e.config;"captureDeadClicks"in n&&(this.instance.persistence&&this.instance.persistence.register({[r2e]:n.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.Ho(()=>{this.zo()}):this.stop()}Ho(e){var n,o,i;!((n=Ur.__PosthogExtensions__)===null||n===void 0)&&n.initDeadClicksAutocapture?e():(o=Ur.__PosthogExtensions__)===null||o===void 0||(i=o.loadExternalDependency)===null||i===void 0||i.call(o,this.instance,"dead-clicks-autocapture",r=>{r?rne.error("failed to load script",r):e()})}zo(){var e;if(No){if(!this.Bo&&(!((e=Ur.__PosthogExtensions__)===null||e===void 0)&&e.initDeadClicksAutocapture)){const n=xA(this.instance.config.capture_dead_clicks)?sn({},this.instance.config.capture_dead_clicks):{};n.__onCapture=this.onCapture,this.onCapture&&(n.capture_dead_swipes=!1),this.Bo=Ur.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this.Bo.start(No),rne.info("starting...")}}else rne.error("`document` not found. Cannot start.")}stop(){this.Bo&&(this.Bo.stop(),this.Bo=void 0,rne.info("stopping..."))}};const gV=Ad("[SegmentIntegration]");function Jst(t,e,n=!0){const o=t.config.segment;if(!o)return e();const{analytics:i,filterProperties:r}=(a=>L_(a.register))(s=o)?{analytics:s}:s;var s;(function(a,A,c,l){const g=h=>{const d=()=>h.anonymousId()||F4();a.config.get_device_id=d,l&&h.id()&&(a.register({distinct_id:h.id(),$device_id:d()}),a.persistence.set_property(my,tne)),c(l?void 0:h.anonymousId()||void 0)},u=A.user();"then"in u&&L_(u.then)?u.then(g):g(u)})(t,i,a=>{i.register(((A,c,{filterProperties:l}={})=>{typeof Promise<"u"&&Promise.resolve||gV.warn("This browser does not have Promise support, and can not use the segment integration");const g=(u,h)=>{if(!h)return u;const d=!!c&&u.event.anonymousId===c&&!u.event.userId;d||u.event.userId||u.event.anonymousId===A.get_distinct_id()||(gV.info("No userId set, resetting PostHog"),A.reset()),d||(c=void 0),u.event.userId&&u.event.userId!==A.get_distinct_id()&&(gV.info("UserId set, identifying with PostHog"),A.identify(u.event.userId));let p=A.calculateEventProperties(h,u.event.properties);if(!Fs(l)){const m=u.event.properties||{},_={};for(const I of Object.keys(p))Mye.call(m,I)||(_[I]=p[I]);const f=((I,C)=>{const y=As(I)?I:[I];let x=sn({},C);for(const E of y)try{if(x=E(x),Fs(x))return null}catch(B){return gV.error("Error in Segment filterProperties:",B),null}return x})(l,_);if(Fs(f))return u;p=f}return u.event.properties=Object.assign({},p,u.event.properties),u};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(u){return g(u,u.event.event)},page(u){return g(u,p2e)},identify(u){return g(u,Cst)},screen(u){return g(u,"$screen")}}})(t,a,{filterProperties:r})).then(()=>{e()},A=>{gV.error("Failed to register the Segment integration",A),e()})},n)}const Wst="posthog-js";function jst(t,{organization:e,projectId:n,prefix:o,severityAllowList:i=["error"],sendExceptionsToPostHog:r=!0}={}){return s=>{var a,A,c,l,g;if(i!=="*"&&!i.includes(s.level)||!t.__loaded)return s;s.tags||(s.tags={});const u=t.requestRouter.endpointFor("ui",`/project/${t.config.token}/person/${t.get_distinct_id()}`);s.tags["PostHog Person URL"]=u,t.sessionRecordingStarted()&&(s.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));const h=((a=s.exception)===null||a===void 0?void 0:a.values)||[],d=h.map(_=>sn(sn({},_),{},{stacktrace:_.stacktrace?sn(sn({},_.stacktrace),{},{type:"raw",frames:(_.stacktrace.frames||[]).map(f=>sn(sn({},f),{},{platform:"web:javascript"}))}):void 0})),p={$exception_message:((A=h[0])===null||A===void 0?void 0:A.value)||s.message,$exception_type:(c=h[0])===null||c===void 0?void 0:c.type,$exception_level:s.level,$exception_list:d,$sentry_event_id:s.event_id,$sentry_exception:s.exception,$sentry_exception_message:((l=h[0])===null||l===void 0?void 0:l.value)||s.message,$sentry_exception_type:(g=h[0])===null||g===void 0?void 0:g.type,$sentry_tags:s.tags};var m;return e&&n&&(p.$sentry_url=(o||"https://sentry.io/organizations/")+e+"/issues/?project="+n+"&query="+s.event_id),r&&((m=t.exceptions)===null||m===void 0||m.sendExceptionEvent(p)),s}}var OBn=class{constructor(e,n,o,i,r,s){this.name=Wst,this.setupOnce=function(a){a(jst(e,{organization:n,projectId:o,prefix:i,severityAllowList:r,sendExceptionsToPostHog:s==null||s}))}}},Xst=class{constructor(e){this.Uo=(n,o,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(gi.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:n,changeReason:i}),this.Wo=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Vo()}Vo(){var e;this.Go=(e=this._instance.sessionManager)===null||e===void 0?void 0:e.onSessionId(this.Uo)}destroy(){var e;(e=this.Go)===null||e===void 0||e.call(this),this.Go=void 0}doPageView(e,n){var o;const i=this.Qo(e,n);return this.Wo={pathname:(o=Fn?.location.pathname)!==null&&o!==void 0?o:"",pageViewId:n,timestamp:e},this._instance.scrollManager.resetContext(),i}doPageLeave(e){var n;return this.Qo(e,(n=this.Wo)===null||n===void 0?void 0:n.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.Wo)===null||e===void 0?void 0:e.pageViewId}}Qo(e,n){const o=this.Wo;if(!o)return{$pageview_id:n};let i={$pageview_id:n,$prev_pageview_id:o.pageViewId};const r=this._instance.scrollManager.getContext();if(r&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:s,lastScrollY:a,maxScrollY:A,maxContentHeight:c,lastContentY:l,maxContentY:g}=r;if(!(Eo(s)||Eo(a)||Eo(A)||Eo(c)||Eo(l)||Eo(g))){s=Math.ceil(s),a=Math.ceil(a),A=Math.ceil(A),c=Math.ceil(c),l=Math.ceil(l),g=Math.ceil(g);const u=s>1?E9(a/s,0,1,gi):1,h=s>1?E9(A/s,0,1,gi):1,d=c>1?E9(l/c,0,1,gi):1,p=c>1?E9(g/c,0,1,gi):1;i=jg(i,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:u,$prev_pageview_max_scroll:A,$prev_pageview_max_scroll_percentage:h,$prev_pageview_last_content:l,$prev_pageview_last_content_percentage:d,$prev_pageview_max_content:g,$prev_pageview_max_content_percentage:p})}}return o.pathname&&(i.$prev_pageview_pathname=o.pathname),o.timestamp&&(i.$prev_pageview_duration=(e.getTime()-o.timestamp.getTime())/1e3),i}};const uV=["flags","surveys"],GBn={[tBn]:{exposure:"hidden"},[Zte]:{exposure:"hidden"},[nBn]:{exposure:"hidden"},[e2e]:{exposure:"hidden"},[Pk]:{exposure:"hidden"},[$K]:{exposure:"hidden"},[qrt]:{exposure:"event"},[t2e]:{exposure:"hidden"},[Zrt]:{exposure:"hidden"},[n2e]:{exposure:"event"},[$rt]:{exposure:"hidden"},[o2e]:{exposure:"event"},[i2e]:{exposure:"event"},[r2e]:{exposure:"event"},[s2e]:{exposure:"hidden"},[est]:{exposure:"event"},[ZK]:{exposure:"hidden"},[oBn]:{exposure:"hidden"},[Mk]:{exposure:"hidden"},[tst]:{exposure:"event"},[iBn]:{exposure:"event",shouldSkipFromEventProperties:t=>ad(t)},[cBn]:{exposure:"event"},[lBn]:{exposure:"event"},[gBn]:{exposure:"event"},[uBn]:{exposure:"event"},[dBn]:{exposure:"hidden"},[k4]:{exposure:"hidden",storageGroup:"flags"},[C8]:{exposure:"hidden",storageGroup:"flags"},[a2e]:{exposure:"hidden"},[NM]:{exposure:"hidden",storageGroup:"flags"},[cQ]:{exposure:"hidden",storageGroup:"flags"},[RM]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[eV]:{exposure:"hidden",storageGroup:"flags"},[B9]:{exposure:"hidden"},[TM]:{exposure:"hidden"},[lQ]:{exposure:"hidden"},[gQ]:{exposure:"hidden"},[tV]:{exposure:"hidden",storageGroup:"surveys"},[ene]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[ost]:{exposure:"event"},[ist]:{exposure:"hidden"},[rst]:{exposure:"hidden"},[A2e]:{exposure:"hidden"},[hBn]:{exposure:"hidden"},[pBn]:{exposure:"hidden"},[mBn]:{exposure:"event"},[_Bn]:{exposure:"event"},[fBn]:{exposure:"event"},[IBn]:{exposure:"event"},[uQ]:{exposure:"hidden"},[nV]:{exposure:"hidden"},[nst]:{exposure:"event"},[oV]:{exposure:"hidden"},[dQ]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[my]:{exposure:"hidden"},[c2e]:{exposure:"hidden"},[CBn]:{exposure:"hidden"},[sst]:{exposure:"hidden"},[ast]:{exposure:"hidden"},[Dk]:{exposure:"hidden"},[l2e]:{exposure:"hidden"},[rBn]:{exposure:"event"},[sBn]:{exposure:"event"},[aBn]:{exposure:"event"},[ABn]:{exposure:"event"},[cst]:{exposure:"event"},[lst]:{exposure:"event"},[u2e]:{exposure:"hidden"},[d2e]:{exposure:"hidden"},[gst]:{exposure:"hidden"},[ust]:{exposure:"hidden"},[dst]:{exposure:"hidden"},[hst]:{exposure:"hidden"},[pst]:{exposure:"hidden"},[mst]:{exposure:"hidden"},[_st]:{exposure:"hidden"},[yBn]:{exposure:"event"}},YBn=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],Kf=t=>{const e=GBn[t];if(e)return e;for(const[n,o]of YBn)if(t.indexOf(n)===0)return o},Lk=(t,e)=>{try{let n;return JSON.stringify(t,(o,i)=>{var r;return Qk(i)?((r=n)!==null&&r!==void 0||(n=new WeakMap),n.has(i)||n.set(i,xst(i)),n.get(i)):typeof i=="bigint"?i.toString():i},e)}catch{return wit(t)}},x8=t=>{const e=No?.createElement("a");return Eo(e)?null:(e.href=t,e)},Hk=function(t,e){const n=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&");let o;for(let i=0;n.length>i;i++){const r=n[i].split("=");if(r[0]===e){o=r;break}}if(!As(o)||2>o.length)return"";{let i=o[1];try{i=decodeURIComponent(i)}catch{gi.error("Skipping decoding for malformed query param: "+i)}return i.replace(/\+/g," ")}},dV=function(t,e,n){if(!t||!e||!e.length)return t;const o=t.split("#"),i=o[1],r=(o[0]||"").split("?"),s=r[1],a=r[0],A=(s||"").split("&"),c=[];for(let g=0;A.length>g;g++){const u=A[g].split("=");As(u)&&(e.includes(u[0])?c.push(u[0]+"="+n):c.push(A[g]))}let l=a;return s!=null&&(l+="?"+c.join("&")),i!=null&&(l+="#"+i),l},sne=function(t,e){const n=t.match(new RegExp(e+"=([^&]*)"));return n?n[1]:null},qst=(t,e)=>t>=e&&vit(),$st=(t,e,n,o)=>{if(t===0){if(vit()){const i=e+1;return i===n&&o(),i}return e}return 0},Ok=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","irclid","_kx"],UBn=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Ok],hV="<masked>",KBn=["li_fat_id"];function Zst(t,e,n){if(!No)return{};const o=e?[...Ok,...n||[]]:[],i=eat(dV(No.URL,o,hV),t),r=(function(){const s={};return vl(KBn,function(a){const A=rV(a);s[a]=A||null}),s})();return jg(r,i)}function eat(t,e){const n=UBn.concat(e||[]),o={};return vl(n,function(i){const r=Hk(t,i);o[i]=r||null}),o}function tat(t){const e=(function(i){return i?i.search("https?://(.*)google.([^/?]*)")===0?"google":i.search("https?://(.*)bing.com")===0?"bing":i.search("https?://(.*)yahoo.com")===0?"yahoo":i.search("https?://(.*)duckduckgo.com")===0?"duckduckgo":null:null})(t),n=e!="yahoo"?"q":"p",o={};if(!ad(e)){o.$search_engine=e;const i=No?Hk(No.referrer,n):"";i.length&&(o.ph_keyword=i)}return o}function nat(){return navigator.language||navigator.userLanguage}function VBn(){const t=nat();return typeof t=="string"?t.split("-")[0]:void 0}const ane="$direct";function oat(){return No?.referrer||ane}function iat(t,e,n=!1){const o=t?[...Ok,...e||[]]:[],i=n?AQ(sd?.href):sd?.href,r=i?.substring(0,1e3);return{r:oat().substring(0,1e3),u:r?dV(r,o,hV):void 0}}function rat(t,e=!1){var n;const{r:o,u:i}=t,r=e?AQ(i):i,s={$referrer:o,$referring_domain:o==null?void 0:o==ane?ane:(n=x8(o))===null||n===void 0?void 0:n.host};if(r){s.$current_url=r;const a=x8(r);s.$host=a?.host,s.$pathname=a?.pathname;const A=eat(r);jg(s,A)}if(o){const a=tat(o);jg(s,a)}return s}function sat(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function zBn(){try{return new Date().getTimezoneOffset()}catch{return}}const JBn={flags:dQ,surveys:ene},WBn=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Ane=t=>`${t}_cookie_identity_change_pending`,cne=t=>{let e="",n=0;for(const o of t){const i=encodeURIComponent(JSON.stringify(o).slice(1,-1)).length;if(n+i>1e3)break;e+=o,n+=i}return e},Um="main",E8=[k4,C8,NM,cQ,RM,dQ,eV,lQ],M2e=t=>E8.indexOf(t)!==-1,aat=[Pk,$K],Aat=t=>aat.indexOf(t)!==-1,hQ=(t,e)=>{try{return JSON.stringify(t)===JSON.stringify(e)}catch{return t===e}},Gk=t=>{if(!t)return{};const e=JSON.parse(t);return xA(e)?e:{}},cat=(t,e)=>{vl(t,(n,o)=>{const i=Kf(o);i&&i.exposure!=="event"||{}.hasOwnProperty.call(e,o)||delete t[o]})};var D2e=class{constructor(e,n,o=!0,i=!e.cookieless_mode){if(this.Jo={},this.Zo=!1,this.Ko=!1,this.Xo=!1,this.Yo=!1,this.ta=!1,this.ea=new Map,this.ia=!1,this.na=!1,this.sa=!1,this.ra=new Set,this.oa=new Set,this.Mr=e,this.aa=o,this.props={},this.la=void 0,this.ua=(r=>{let s="";return r.token&&(s=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),r.persistence_name?"ph_"+r.persistence_name:"ph_"+s+"_posthog"})(e),this.hi=e.disable_persistence||!!n,this.No=this.ha(e),this.Xo=this.ca(e),this.load(i),this.da(),e.debug&&gi.info("Persistence loaded",e.persistence,sn({},this.props)),this.update_config(e,e,n),this.save(),Fn){const r=()=>this.flush();jc(Fn,"beforeunload",r,{capture:!1}),jc(Fn,"pagehide",r,{capture:!1}),this.va=s=>{if(this.Zo&&(!s.storageArea||s.storageArea===Fn?.localStorage)&&s.key)if(s.key!==this.ua){if(this.Xo){const a=uV.find(A=>s.key===this.fa(A));a&&this.pa(s.key,a)}}else this.pa(s.key,Um)},jc(Fn,"storage",this.va)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([n,o])=>{const i=this.ea.get(n);if(!M2e(n)||i===!0)return;if(o===!0)return void this.ga(n,!0);const r=new Set(i||[]);o.forEach(s=>r.add(s)),r.size&&this.ga(n,r)})}onCrossTabFeatureFlagChange(e){return this.oa.add(e),()=>this.oa.delete(e)}destroy(){this.va&&Fn&&(Fn.removeEventListener("storage",this.va),this.va=void 0),this.oa.clear()}pa(e,n,o=!0){if(this.hi)return!1;let i,r;try{if(r=uc.Ot(e),ad(r)){const A=this.ma(n);return A.storageValue=null,n!==Um&&(A.persisted=!1),!1}i=Gk(r)}catch{return!1}const s=n===Um?i:uc.Lt(this.ua);if(s&&this.ya(s))return!1;const a=this.ba(i,n,o);return n===Um&&this.Xo&&!hQ(this._a().main,i)||this.wa(i,n,!0,r),a}ya(e){const n=this.props[T4],o=e[T4];return!Eo(n)&&!Eo(o)&&n!==o}wa(e,n,o,i){const r=this.ma(n);r.storageValue=i,n!==Um&&(r.persisted=o);try{r.fingerprint=this.ka(e,n)}catch{r.fingerprint=void 0}}ba(e,n,o){let i=!1;return E8.forEach(r=>{var s;const a=(s=Kf(r))===null||s===void 0?void 0:s.storageGroup;if(n===Um&&this.Xo&&a||n!==Um&&a!==n)return;const A=r in e,c=this.Sa(r,A?e[r]:void 0),l=this.ea.has(r)?r in this.props:A;l===r in this.props&&hQ(c,this.props[r])||(l?this.xa(r,c,!1):this.$a(r,!1),i=!0)}),i&&o&&this.oa.forEach(r=>r()),i}Ca(){if(!this.Zo)return!1;try{this.sa=!1;const e=uc.Ot(this.ua),n=this.ma(Um);let o,i=!1,r=!1;if(e!==n.storageValue)if(ad(e))n.storageValue=null;else{if(o=Gk(e),this.sa=!this.na&&this.ya(o),this.sa)return!1;r=this.ba(o,Um,!1),!this.Xo||hQ(this._a().main,o)?this.wa(o,Um,!0,e):n.storageValue=e,i=!0}return this.Xo&&uV.forEach(s=>{const a=uc.Ot(this.fa(s)),A=this.ma(s),c=o||{},l=i&&E8.some(u=>{var h;return((h=Kf(u))===null||h===void 0?void 0:h.storageGroup)===s&&u in c});if(a===A.storageValue&&!l)return;if(ad(a))return A.storageValue=null,A.persisted=!1,void(l&&(r=this.ba(c,s,!1)||r));const g=Gk(a);r=this.ba(g,s,!1)||r,this.wa(g,s,!0,a)}),r}catch{return!1}}ga(e,n){this.ea.set(e,n);const o=Kf(e);o?.volatile||(this.ma((this.Xo?o?.storageGroup:void 0)||Um).fingerprint=void 0,this.Ta(e))}Ia(){E8.forEach(e=>this.ea.set(e,!0))}da(){if(this.Zo)try{const e=uc.Ot(this.ua),n=Gk(e);this.ma(Um).storageValue=e,E8.forEach(o=>{var i;const r=this.Xo?(i=Kf(o))===null||i===void 0?void 0:i.storageGroup:void 0,s=r?uc.Ot(this.fa(r)):null;if(r){const A=this.ma(r);A.storageValue=s,A.persisted=!ad(s)}const a=r&&!ad(s)?Gk(s):n;o in this.props?this.Ma(o,a[o],this.props[o]):o in a&&this.ga(o,!0)})}catch{}}Sa(e,n){const o=this.ea.get(e);if(!o)return n;if(o===!0)return this.props[e];if(e==="$active_feature_flags"){const s=new Set(As(n)?n:[]),a=new Set(As(this.props[e])?this.props[e]:[]);return o.forEach(A=>a.has(A)?s.add(A):s.delete(A)),Array.from(s)}const i=xA(n)?sn({},n):{},r=xA(this.props[e])?this.props[e]:{};return o.forEach(s=>{s in r?i[s]=r[s]:delete i[s]}),i}Ma(e,n,o){if(!M2e(e))return;const i=this.ea.get(e);if(i===!0)return;let r=n;if(this.Zo)try{var s;const A=this.Xo?(s=Kf(e))===null||s===void 0?void 0:s.storageGroup:void 0,c=A?this.fa(A):this.ua;r=Gk(uc.Ot(c))[e]}catch{}const a=new Set(i||[]);if(e==="$active_feature_flags"){if(!Eo(n)&&!As(n)||!Eo(r)&&!As(r)||!As(o))return void this.ga(e,!0);const A=new Set(n||[]),c=new Set(r||[]),l=new Set(o);new Set([...A,...l]).forEach(g=>{A.has(g)!==l.has(g)&&a.add(g)}),a.forEach(g=>{c.has(g)===l.has(g)&&a.delete(g)})}else{if(!xA(o))return void(hQ(r,o)?this.ea.delete(e):this.ga(e,!0));{if(!Eo(n)&&!xA(n)||Eo(n)&&ox(o)&&Eo(r))return void this.ga(e,!0);const A=xA(n)?n:{},c=xA(r)?r:{};new Set([...Object.keys(A),...Object.keys(o)]).forEach(l=>{l in A==l in o&&hQ(A[l],o[l])||a.add(l)}),a.forEach(l=>{l in c==l in o&&hQ(c[l],o[l])&&a.delete(l)})}}a.size?this.ga(e,a):this.ea.delete(e)}Ea(){var e;const n=(e=this.Mr)===null||e===void 0?void 0:e.persistence_save_debounce_ms;return qd(n)&&n>0?n:0}Pa(e){if(this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie")if(e)try{const n=y2e(e,this.Mr.cookie_persisted_properties||[]),o=Sst(n,this.Mr.cookie_persisted_properties||[]),i=JSON.stringify(n)+"|"+JSON.stringify(o),r=cd.Ot(this.ua)||void 0;r&&x2e(this.ua,r)===i&&(this.Ra=i,this.Aa=r)}catch{}else try{const n=cd.Ot(this.ua)||void 0;this.Ra=n?x2e(this.ua,n):void 0,this.Aa=n}catch{}}syncCookieProperties(){return this.Oa(this.Mr)}Oa(e,n=!1){if(this.hi&&!n||this.ta||!e.cookieWinsOnConflict||e.persistence.toLowerCase()!=="localstorage+cookie")return!1;let o;try{o=cd.Ot(this.ua)||void 0}catch{}if(!o||o===this.Aa)return!1;const i=x2e(this.ua,o);let r;try{r=C2e(JSON.parse(o))}catch{return!1}if((cd.Ot(this.ua)||void 0)!==o)return!1;this.Ra=i,this.Aa=o;const s=Qst(this.ua,o),a=[...kM,...s.properties],A={};if(Object.keys(r).forEach(m=>{const _=r[m];(Eo(_)||ad(_)||_===""||m==="$user_state"&&_!=="anonymous"&&_!=="identified")&&(A[m]=!0,delete r[m])}),ox(r))return!1;const c="distinct_id"in r||r.$user_state==="anonymous"||r.$user_state==="identified",l=this.props,g=l[T4],u=l[my],h=jg({},l);[...kM,...e.cookie_persisted_properties||[]].forEach(m=>{if(a.indexOf(m)!==-1&&!(m in r)&&!A[m]&&(c||m!=="distinct_id"&&m!=="$user_state")){const _=h[m];(s.isValid||kM.indexOf(m)===-1||_!==!1&&_!==0)&&delete h[m]}}),this.props=jg(h,r),E8.forEach(m=>{const _=m in this.props;m in l===_&&hQ(l[m],this.props[m])||(_?this.Ma(m,l[m],this.props[m]):this.ga(m,!0))}),!c||"$user_state"in r||"$user_state"in this.props||this.xa(my,y8);const d=this.props[T4],p=this.props[my];return!c||d===g&&p===u||(this.na=!0,this.Yo=!0,Z0.$t(Ane(this.ua),!0),this.$a(lQ),this.$a(C8),this.$a(k4),this.$a(NM),this.$a(cQ),this.$a(RM),this.$a(dQ),this.$a(oV),this.$a(uQ),p!=="anonymous"||u!=="identified"&&r.$user_state!=="anonymous"&&(Eo(g)||d===g)||(cat(this.props,r),this.$a(gQ)),p==="identified"?this.props.$user_id=d:delete this.props.$user_id,this.$a(Zte)),!0}consumeCookieIdentityChange(){const e=Ane(this.ua),n=this.Yo||!!Z0.Ot(e);return this.Yo=!1,n&&Z0.Pt(e),n}Fa(e=!1){return!(this.ta||this.hi&&!e||!this.Mr.cookieWinsOnConflict||this.Mr.persistence.toLowerCase()!=="localstorage+cookie"||(this.ta=!0,0))}Da(){this.ta&&(Eo(this.La)||(clearTimeout(this.La),this.La=void 0),delete this.Jo[Um],this.Na(!0))}qa(e=!0){if(this.ta)try{e?this.Da():Eo(this.La)||(clearTimeout(this.La),this.La=void 0)}finally{this.ta=!1}}isDisabled(){return!!this.hi}ha(e){WBn.indexOf(e.persistence.toLowerCase())===-1&&(gi.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");const n=((a=[],A=!1,c=()=>!1)=>{const l=[...kM,...a];return sn(sn({},uc),{},{Lt(g){try{let h,d={};try{h=cd.Ot(g)||void 0,d=h?C2e(JSON.parse(h)):{}}catch{}const p=JSON.parse(uc.Ot(g)||"{}");let m;if(A){const _=Qst(g,h),f=[...kM,..._.properties],I={};Object.keys(d).forEach(y=>{const x=d[y];ad(x)||x===""||y==="$user_state"&&x!=="anonymous"&&x!=="identified"||(I[y]=x)});const C="distinct_id"in I||I.$user_state==="anonymous"||I.$user_state==="identified";if(Object.keys(I).length>0){var u;const y=p[T4],x=(u=p.$user_state)!==null&&u!==void 0?u:y8;l.forEach(E=>{if(f.indexOf(E)!==-1&&!(E in d)&&(C||E!=="distinct_id"&&E!=="$user_state")){const B=p[E];(_.isValid||kM.indexOf(E)===-1||B!==!1&&B!==0)&&delete p[E]}}),!C||"$user_state"in d||"$user_state"in p||(p[my]=y8),!C||("distinct_id"in I?I[T4]:p[T4])===y&&("$user_state"in I?I[my]:p[my])===x||(I2e.forEach(E=>delete p[E]),I.$user_state==="identified"&&"distinct_id"in I?p.$user_id=I[T4]:delete p.$user_id,I.$user_state!=="identified"&&(delete p[nst],delete p[gQ]),delete p.__alias)}m=jg(p,I)}else m=jg(d,p);return c()||uc.$t(g,m),m}catch{}return null},$t(g,u,h,d,p,m){const _=uc.$t(g,u,void 0,void 0,m);try{const f=y2e(u,a);if(Object.keys(f).length){if(A){const I=ine(g),C=Sst(f,a);if(cd.$t(I,C,h,d,p,m),cd.Ot(I)!==JSON.stringify(C)){cd.Pt(I,d);const y=y2e(u);return cd.$t(g,y,h,d,p,m),_}}cd.$t(g,f,h,d,p,m)}}catch(f){uc.Dt(f)}return _},Pt(g,u){try{Fn?.localStorage.removeItem(g),cd.Pt(g,u),cd.Pt(ine(g),u)}catch(h){uc.Dt(h)}}})})(e.cookie_persisted_properties||[],e.cookieWinsOnConflict,()=>!!this.hi);let o,i=!1,r=!1;const s=e.persistence.toLowerCase();return s==="localstorage"&&uc.Et()?(o=uc,r=!0):s==="localstorage+cookie"&&n.Et()?(o=n,r=!0,i=!0):s==="sessionstorage"&&Z0.Et()?o=Z0:s==="memory"?o=E2e:s==="cookie"&&cd.Et()?(o=cd,i=!0):n.Et()?(o=n,r=!0,i=!0):cd.Et()?(o=cd,i=!0):o=E2e,this.Zo=r,this.Ko=i,o}fa(e){return`${this.ua}__${e}`}ca(e){return this.Zo&&!!e.split_storage}properties(){const e={};return vl(this.props,(n,o)=>{const i=Kf(o);if(!i||i.exposure==="event"){var r;if(!(i==null||(r=i.shouldSkipFromEventProperties)===null||r===void 0)&&r.call(i,n))return;e[o]=n}}),e}load(e=!1){if(this.hi&&!e)return;const n=this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie",o=n?uc.Lt(this.ua):null;let i={};if(n)try{i=C2e(cd.Lt(this.ua)),vl(i,(A,c)=>{(Eo(A)||ad(A)||A==="")&&delete i[c]})}catch{}const r=this.No.Lt(this.ua);if(r&&(this.props=jg({},r)),this.Xo&&this.ja(),n&&r){var s,a;const A=o?.[T4],c=(s=o?.$user_state)!==null&&s!==void 0?s:y8,l=r[T4],g=(a=r.$user_state)!==null&&a!==void 0?a:y8;if(l!==A||g!==c){this.Yo=!0,this.hi||Z0.$t(Ane(this.ua),!0);const u=jg({},this.props);I2e.forEach(d=>delete u[d]),g!=="anonymous"||c!=="identified"&&i.$user_state!=="anonymous"&&(Eo(A)||l===A)||(cat(u,i),delete u[gQ]),this.props=u;const h=new Set;I2e.forEach(d=>{var p;const m=(p=Kf(d))===null||p===void 0?void 0:p.storageGroup;m&&h.add(m)}),h.forEach(d=>{if(this.hi)return;const p={};vl(this.props,(m,_)=>{var f;((f=Kf(_))===null||f===void 0?void 0:f.storageGroup)===d&&(p[_]=m)}),ox(p)?(uc.Pt(this.fa(d)),this.Jo[d]={}):uc.$t(this.fa(d),p)&&(this.Jo[d]={persisted:!0,fingerprint:this.ka(p,d)})})}}Z0.Ot(Ane(this.ua))&&(this.Yo=!0)}ja(){for(const e of uV){const n=uc.Lt(this.fa(e));if(n&&!ox(n)){const o=this.ma(e);o.persisted=!0,this.Ba(e)||(o.fingerprint=this.ka(n,e)),this.Ha(e,n)||jg(this.props,n)}}}Ba(e){return Object.keys(this.props).some(n=>{var o;return((o=Kf(n))===null||o===void 0?void 0:o.storageGroup)===e})}Ha(e,n){const o=JBn[e];if(!o)return!1;const i=n[o],r=this.props[o];return qd(i)&&qd(r)&&r>i}refreshKey(e){var n;if(this.hi||this.ra.has(e))return;const o=this.Xo?(n=Kf(e))===null||n===void 0?void 0:n.storageGroup:void 0,i=o?uc.Lt(this.fa(o)):this.No.Lt(this.ua);if(i&&e in i)this.xa(e,i[e],!1);else{if(o){const r=this.No.Lt(this.ua);if(r&&e in r)return void this.xa(e,r[e],!1)}this.$a(e,!1)}}save(){if(this.hi)return;const e=this.Ea();e>0?Eo(this.La)&&(this.La=setTimeout(()=>{this.La=void 0,this.Na()},e)):this.Na()}flush(){Eo(this.La)||(clearTimeout(this.La),this.La=void 0,this.Na())}Na(e=!1){if(this.hi||this.ta&&!e)return;e||(this.syncCookieProperties(),this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie"||aat.forEach(r=>this.refreshKey(r)));const n=!e&&!this.ia;n||(this.sa=!1);const o=!!n&&this.Ca();if(this.sa)return void(this.Mr.debug&&gi.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this.Xo)return this.za(),void(o&&this.oa.forEach(r=>r()));const i=this.Ua(this.No,this.ua,this.props,Um);i==="written"&&this.Pa(this.props),i!=="failed"&&(this.ea.clear(),this.na=!1,this.ra.clear()),o&&this.oa.forEach(r=>r())}za(){const{main:e,groups:n}=this._a(),o=this.Ua(this.No,this.ua,e,Um);o==="written"&&this.Pa(e),o!=="failed"&&(this.na=!1,this.ra.clear(),E8.forEach(r=>{var s;!((s=Kf(r))===null||s===void 0)&&s.storageGroup||this.ea.delete(r)}));for(const r of uV){var i;const s=n[r];if(ox(s)&&!(!((i=this.Jo[r])===null||i===void 0)&&i.persisted)){E8.forEach(A=>{var c;((c=Kf(A))===null||c===void 0?void 0:c.storageGroup)===r&&this.ea.delete(A)});continue}const a=this.Ua(uc,this.fa(r),s,r);a!=="failed"&&E8.forEach(A=>{const c=Kf(A);c?.storageGroup!==r||a!=="written"&&c.volatile||this.ea.delete(A)})}}_a(){const e={},n={flags:{},surveys:{}};return vl(this.props,(o,i)=>{var r;const s=(r=Kf(i))===null||r===void 0?void 0:r.storageGroup;s?n[s][i]=o:e[i]=o}),{main:e,groups:n}}ka(e,n){if(n===Um)return JSON.stringify(e)+"|"+this.Wa+"|"+this.Va+"|"+this.Ga;const o={};return vl(e,(i,r)=>{var s;o[r]=!((s=Kf(r))===null||s===void 0)&&s.volatile?"__volatile__":i}),JSON.stringify(o)}Ua(e,n,o,i){const r=this.ma(i);if(i!==Um&&!r.dirty&&!Eo(r.fingerprint))return"skipped";let s;try{if(s=this.ka(o,i),s===r.fingerprint)return r.dirty=!1,"skipped"}catch{s=void 0}return e.$t(n,o,this.Wa,this.Va,this.Ga,this.Mr.debug)?(r.dirty=!1,i!==Um&&(r.persisted=!0),Eo(s)||(r.fingerprint=s),this.Zo&&(r.storageValue=uc.Ot(n)),"written"):(this.Mr.debug&&gi.warn(`failed to persist storage entry "${n}"; will retry on next save`),"failed")}remove({keepGroupEntries:e=!1}={}){if(this.Ia(),Eo(this.La)||(clearTimeout(this.La),this.La=void 0),this.No.Pt(this.ua,!1),this.No.Pt(this.ua,!0),!e&&this.aa)for(const n of uV)uc.Pt(this.fa(n));e?delete this.Jo[Um]:this.Jo={},this.Ra=void 0,this.Aa=void 0}clear(){this.remove(),this.props={}}register_once(e,n,o){if(xA(e)){this.syncCookieProperties(),Eo(n)&&(n="None"),this.Wa=Eo(o)?this.Qa:o;let i=!1;if(vl(e,(r,s)=>{this.props.hasOwnProperty(s)&&this.props[s]!==n||(this.xa(s,r),i=!0)}),i)return this.save(),!0}return!1}register(e,n){if(xA(e)){this.syncCookieProperties(),this.Wa=Eo(n)?this.Qa:n;let o=!1;if(vl(e,(i,r)=>{e.hasOwnProperty(r)&&(this.props[r]!==i||xA(i)||As(i))&&(this.xa(r,i),o=!0)}),o)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();const n=typeof e=="string"?[e]:e;let o=!1;for(const i of n)i in this.props&&(this.$a(i),o=!0);o&&this.save()}update_campaign_params(){const e=No?.URL;if(e===this.la)return;const n=Zst(this.Mr.custom_campaign_params,this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties),o=!ox(m2e(n));return o&&this.register(n),this.la=e,o?n:void 0}update_search_keyword(){this.register((function(){const e=No?.referrer;return e?tat(e):{}})())}update_referrer_info(){var e;this.register_once({$referrer:oat(),$referring_domain:No?.referrer&&((e=x8(No.referrer))===null||e===void 0?void 0:e.host)||ane},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const e=iat(this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties,this.Mr.disable_capture_url_hashes);this.register_once({[Dk]:this.Ko?{r:cne(e.r),u:e.u?cne(e.u):void 0}:e},void 0)}get_initial_props(){const e={};vl([ast,sst],o=>{const i=this.props[o];i&&vl(i,function(r,s){e["$initial_"+Pye(s)]=r})});const n=this.props[Dk];if(n){const o=(function(i,r=!1){const s=rat(i,r),a={};return vl(s,function(A,c){a[`$initial_${Pye(c)}`]=A}),a})(n,this.Mr.disable_capture_url_hashes);jg(e,o)}return e}safe_merge(e){return vl(this.props,function(n,o){o in e||(e[o]=n)}),e}update_config(e,n,o){const i=e.persistence!==n.persistence,r=!((d,p)=>{if(d.length!==p.length)return!1;const m=[...d].sort(),_=[...p].sort();return m.every((f,I)=>f===_[I])})(e.cookie_persisted_properties||[],n.cookie_persisted_properties||[]),s=i||r,a=e.cookieWinsOnConflict!==n.cookieWinsOnConflict,A=e.disable_persistence||!!o,c=!!this.hi&&!A;A||this.Oa(n,c),this.Mr=e,!A&&(i||r||a)&&(this.Ra=void 0,this.Aa=void 0,this.Oa(sn(sn({},e),{},{cookie_persisted_properties:n.cookie_persisted_properties}),c));const l=s||a?this.ha(e):this.No;this.Ja();const g=this.ca(e),u=s||g!==this.Xo,h=!A&&(u||e.cross_subdomain_cookie!==this.Va||e.secure_cookie!==this.Ga)&&this.Fa(c);this.ia=u;try{if(this.Qa=this.Wa=e.cookie_expiration,this.set_disabled(A),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),u){const d=this.props;this.clear(),this.No=l,this.Xo=g,this.props=d,this.save()}else a&&(this.No=l,A||(delete this.Jo[Um],this.Na()))}finally{this.ia=!1,h&&this.qa()}}Ja(){const e=this.props[Dk];if(!this.Ko||!xA(e)||typeof e.r!="string")return;const n=cne(e.r),o=typeof e.u=="string"?cne(e.u):e.u;n===e.r&&o===e.u||this.xa(Dk,sn(sn({},e),{},{r:n,u:o}))}set_disabled(e){this.hi=e,this.hi?this.remove():this.save()}set_cross_subdomain(e){e!==this.Va&&(this.Va=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this.Ga&&(this.Ga=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,n){const o=this.props.__timers||{};o[e]=n,this.xa(e2e,o),this.save()}remove_event_timer(e){const n=this.props.__timers||{},o=n[e];return Eo(o)||(delete n[e],this.xa(e2e,n),this.save()),o}get_property(e){return this.props[e]}set_property(e,n){this.xa(e,n),this.save()}xa(e,n,o=!0){var i;const r=this.props[e];this.props[e]=n,o&&(e!=="distinct_id"&&e!=="$user_state"||r===n||(this.na=!0),Aat(e)&&!hQ(r,n)&&this.ra.add(e),this.Ma(e,r,n),!((i=Kf(e))===null||i===void 0)&&i.volatile||this.Ta(e))}$a(e,n=!0){delete this.props[e],n&&(M2e(e)&&this.ga(e,!0),Aat(e)&&this.ra.add(e),this.Ta(e))}Ta(e){var n;const o=(n=Kf(e))===null||n===void 0?void 0:n.storageGroup;o&&(this.ma(o).dirty=!0)}ma(e){return this.Jo[e]||(this.Jo[e]={})}};const N3={GZipJS:"gzip-js",Base64:"base64"},pV={Activation:"events",Cancellation:"cancelEvents"},N2e={Popover:"popover",API:"api",Widget:"widget"},R3={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},R2e={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},T2e={Popover:"popover",Inline:"inline"};function lne(t){let e=!0;return{dispose(){if(e){e=!1;const n=t();n&&L_(n.then)&&n.then(void 0,()=>{})}}}}const jBn={SHOWN:"product tour shown"},lat={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},gat=Ad("[RateLimiter]");var XBn=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=n=>{const o=n.text;if(o&&o.length)try{(JSON.parse(o).quota_limited||[]).forEach(i=>{gat.info(`${i||"events"} is quota limited.`),this.serverLimits[i]=new Date().getTime()+6e4})}catch(i){return void gat.warn(`could not rate limit - continuing. Error: "${i?.message}"`,{text:o})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)===null||e===void 0?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)===null||e===void 0?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e=!1){var n,o,i;const{captureEventsBurstLimit:r,captureEventsPerSecond:s}=this,a=new Date().getTime(),A=(n=(o=this.instance.persistence)===null||o===void 0?void 0:o.get_property("$capture_rate_limit"))!==null&&n!==void 0?n:{tokens:r,last:a};A.tokens+=(a-A.last)/1e3*s,A.last=a,A.tokens>r&&(A.tokens=r);const c=1>A.tokens;if(c||e||(A.tokens=Math.max(0,A.tokens-1)),c&&!e){const l=(qd(A.dropped)?A.dropped:0)+1;A.dropped=l,!this.lastEventRateLimited&&this.Za(l)&&(A.dropped=0)}return this.lastEventRateLimited=c,(i=this.instance.persistence)===null||i===void 0||i.set_property("$capture_rate_limit",A),{isRateLimited:c,remainingTokens:A.tokens}}Ka(e){const n=this.instance.config.property_denylist;return!As(n)||!n.includes(e)}Xa(){var e;if(this.Ka("$current_url")&&this.Ka("$pathname")&&sd?.pathname)return`${(e=sd.origin)!==null&&e!==void 0?e:""}${sd.pathname}`}Za(e){var n,o;const{captureEventsBurstLimit:i,captureEventsPerSecond:r}=this,s=this.Xa(),a=this.Ka("$session_id")?(n=(o=this.instance).get_session_id)===null||n===void 0?void 0:n.call(o):void 0,A=[`${e} event(s) dropped since the last warning`,s?`triggered on ${s}`:void 0,a?`session ${a}`:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:`posthog-js client rate limited: ${A}. Config is set to ${r} events per second and ${i} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(e){const n=this.serverLimits[e||"events"]||!1;return n!==!1&&new Date().getTime()<n}};const pQ=Ad("[RemoteConfig]");var uat=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=Ur._POSTHOG_REMOTE_CONFIG)===null||e===void 0||(e=e[this._instance.config.token])===null||e===void 0?void 0:e.config}Ya(e){var n,o,i;!((n=Ur.__PosthogExtensions__)===null||n===void 0)&&n.loadExternalDependency?(o=Ur.__PosthogExtensions__)===null||o===void 0||(i=o.loadExternalDependency)===null||i===void 0||i.call(o,this._instance,"remote-config",()=>e(this.remoteConfig)):e()}tl(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets",`/array/${this._instance.config.token}/config`),callback:e})}load(){try{if(this.remoteConfig)return pQ.info("Using preloaded remote config",this.remoteConfig),void this.el(this.remoteConfig);if(this._instance.il())return void pQ.warn("Remote config is disabled. Falling back to local config.");this.Ya(e=>{if(!e)return pQ.info("No config found after loading remote JS config. Falling back to JSON."),void this.tl(n=>{this.el(n.json,n)});this.el(e)})}catch(e){pQ.error("Error loading remote config",e),this.el()}}el(e,n){!e&&n&&(n.statusCode===0?n.error||pQ.warn("Failed to fetch remote config from PostHog."):pQ.error("Failed to fetch remote config from PostHog."));try{this._instance.el(e?{ok:!0,config:e}:{ok:!1})}catch(i){pQ.error("Error applying remote config",i)}if(e?.hasFeatureFlags!==!1&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var o;(o=this._instance.featureFlags)===null||o===void 0||o.ensureFlagsLoaded()}catch(i){pQ.error("Error loading feature flags",i)}}},m5=Uint8Array,ix=Uint16Array,Yk=Uint32Array,k2e=new m5([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]),F2e=new m5([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]),dat=new m5([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),hat=function(t,e){for(var n=new ix(31),o=0;31>o;++o)n[o]=e+=1<<t[o-1];var i=new Yk(n[30]);for(o=1;30>o;++o)for(var r=n[o];n[o+1]>r;++r)i[r]=r-n[o]<<5|o;return[n,i]},pat=hat(k2e,2),L2e=pat[1];pat[0][28]=258,L2e[258]=28;for(var mat=hat(F2e,0)[1],_at=new ix(32768),ld=0;32768>ld;++ld){var Uk=(43690&ld)>>>1|(21845&ld)<<1;_at[ld]=((65280&(Uk=(61680&(Uk=(52428&Uk)>>>2|(13107&Uk)<<2))>>>4|(3855&Uk)<<4))>>>8|(255&Uk)<<8)>>>1}var mV=function(t,e,n){for(var o=t.length,i=0,r=new ix(e);o>i;++i)++r[t[i]-1];var s,a=new ix(e);for(i=0;e>i;++i)a[i]=a[i-1]+r[i-1]<<1;for(s=new ix(o),i=0;o>i;++i)s[i]=_at[a[t[i]-1]++]>>>15-t[i];return s},LM=new m5(288);for(ld=0;144>ld;++ld)LM[ld]=8;for(ld=144;256>ld;++ld)LM[ld]=9;for(ld=256;280>ld;++ld)LM[ld]=7;for(ld=280;288>ld;++ld)LM[ld]=8;var gne=new m5(32);for(ld=0;32>ld;++ld)gne[ld]=5;var qBn=mV(LM,9),$Bn=mV(gne,5),fat=function(t){return(t/8|0)+(7&t&&1)},Iat=function(t,e,n){(n==null||n>t.length)&&(n=t.length);var o=new(t instanceof ix?ix:t instanceof Yk?Yk:m5)(n-e);return o.set(t.subarray(e,n)),o},B8=function(t,e,n){var o=e/8|0;t[o]|=n<<=7&e,t[o+1]|=n>>>8},_V=function(t,e,n){var o=e/8|0;t[o]|=n<<=7&e,t[o+1]|=n>>>8,t[o+2]|=n>>>16},H2e=function(t,e){for(var n=[],o=0;t.length>o;++o)t[o]&&n.push({s:o,f:t[o]});var i=n.length,r=n.slice();if(!i)return[new m5(0),0];if(i==1){var s=new m5(n[0].s+1);return s[n[0].s]=1,[s,1]}n.sort(function(y,x){return y.f-x.f}),n.push({s:-1,f:25001});var a=n[0],A=n[1],c=0,l=1,g=2;for(n[0]={s:-1,f:a.f+A.f,l:a,r:A};l!=i-1;)a=n[n[g].f>n[c].f?c++:g++],A=n[c!=l&&n[g].f>n[c].f?c++:g++],n[l++]={s:-1,f:a.f+A.f,l:a,r:A};var u=r[0].s;for(o=1;i>o;++o)r[o].s>u&&(u=r[o].s);var h=new ix(u+1),d=O2e(n[l-1],h,0);if(d>e){o=0;var p=0,m=d-e,_=1<<m;for(r.sort(function(y,x){return h[x.s]-h[y.s]||y.f-x.f});i>o;++o){var f=r[o].s;if(e>=h[f])break;p+=_-(1<<d-h[f]),h[f]=e}for(p>>>=m;p>0;){var I=r[o].s;e>h[I]?p-=1<<e-h[I]++-1:++o}for(;o>=0&&p;--o){var C=r[o].s;h[C]==e&&(--h[C],++p)}d=e}return[new m5(h),d]},O2e=function(t,e,n){return t.s==-1?Math.max(O2e(t.l,e,n+1),O2e(t.r,e,n+1)):e[t.s]=n},Cat=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new ix(++e),o=0,i=t[0],r=1,s=function(A){n[o++]=A},a=1;e>=a;++a)if(t[a]==i&&a!=e)++r;else{if(!i&&r>2){for(;r>138;r-=138)s(32754);r>2&&(s(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(s(i),--r;r>6;r-=6)s(8304);r>2&&(s(r-3<<5|8208),r=0)}for(;r--;)s(i);r=1,i=t[a]}return[n.subarray(0,o),e]},fV=function(t,e){for(var n=0,o=0;e.length>o;++o)n+=t[o]*e[o];return n},G2e=function(t,e,n){var o=n.length,i=fat(e+2);t[i]=255&o,t[i+1]=o>>>8,t[i+2]=255^t[i],t[i+3]=255^t[i+1];for(var r=0;o>r;++r)t[i+r+4]=n[r];return 8*(i+4+o)},yat=function(t,e,n,o,i,r,s,a,A,c,l){B8(e,l++,n),++i[256];for(var g=H2e(i,15),u=g[0],h=g[1],d=H2e(r,15),p=d[0],m=d[1],_=Cat(u),f=_[0],I=_[1],C=Cat(p),y=C[0],x=C[1],E=new ix(19),B=0;f.length>B;++B)E[31&f[B]]++;for(B=0;y.length>B;++B)E[31&y[B]]++;for(var S=H2e(E,7),Q=S[0],w=S[1],M=19;M>4&&!Q[dat[M-1]];--M);var k,R,F,O,U=c+5<<3,Y=fV(i,LM)+fV(r,gne)+s,J=fV(i,u)+fV(r,p)+s+14+3*M+fV(E,Q)+(2*E[16]+3*E[17]+7*E[18]);if(Y>=U&&J>=U)return G2e(e,l,t.subarray(A,A+c));if(B8(e,l,1+(Y>J)),l+=2,Y>J){k=mV(u,h),R=u,F=mV(p,m),O=p;var ee=mV(Q,w);for(B8(e,l,I-257),B8(e,l+5,x-1),B8(e,l+10,M-4),l+=14,B=0;M>B;++B)B8(e,l+3*B,Q[dat[B]]);l+=3*M;for(var W=[f,y],X=0;2>X;++X){var oe=W[X];for(B=0;oe.length>B;++B)B8(e,l,ee[se=31&oe[B]]),l+=Q[se],se>15&&(B8(e,l,oe[B]>>>5&127),l+=oe[B]>>>12)}}else k=qBn,R=LM,F=$Bn,O=gne;for(B=0;a>B;++B)if(o[B]>255){var se;_V(e,l,k[257+(se=o[B]>>>18&31)]),l+=R[se+257],se>7&&(B8(e,l,o[B]>>>23&31),l+=k2e[se]);var ie=31&o[B];_V(e,l,F[ie]),l+=O[ie],ie>3&&(_V(e,l,o[B]>>>5&8191),l+=F2e[ie])}else _V(e,l,k[o[B]]),l+=R[o[B]];return _V(e,l,k[256]),l+R[256]},ZBn=new Yk([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),e9n=(function(){for(var t=new Yk(256),e=0;256>e;++e){for(var n=e,o=9;--o;)n=(1&n&&3988292384)^n>>>1;t[e]=n}return t})(),Y2e=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8};function t9n(t,e){e===void 0&&(e={});var n=(function(){var g=4294967295;return{p(u){for(var h=g,d=0;u.length>d;++d)h=e9n[255&h^u[d]]^h>>>8;g=h},d(){return 4294967295^g}}})(),o=t.length;n.p(t);var i,r,s,a,A,c=(a=10+((i=e).filename&&i.filename.length+1||0),A=8,(function(g,u,h,d,p,m){var _=g.length,f=new m5(d+_+5*(1+Math.floor(_/7e3))+p),I=f.subarray(d,f.length-p),C=0;if(!u||8>_)for(var y=0;_>=y;y+=65535){var x=y+65535;_>x?C=G2e(I,C,g.subarray(y,x)):(I[y]=m,C=G2e(I,C,g.subarray(y,_)))}else{for(var E=ZBn[u-1],B=E>>>13,S=8191&E,Q=(1<<h)-1,w=new ix(32768),M=new ix(Q+1),k=Math.ceil(h/3),R=2*k,F=function(Ce){return(g[Ce]^g[Ce+1]<<k^g[Ce+2]<<R)&Q},O=new Yk(25e3),U=new ix(288),Y=new ix(32),J=0,ee=0,W=(y=0,0),X=0,oe=0;_>y;++y){var se=F(y),ie=32767&y,ge=M[se];if(w[ie]=ge,M[se]=ie,y>=X){var ue=_-y;if((J>7e3||W>24576)&&ue>423){C=yat(g,I,0,O,U,Y,ee,W,oe,y-oe,C),W=J=ee=0,oe=y;for(var Ie=0;286>Ie;++Ie)U[Ie]=0;for(Ie=0;30>Ie;++Ie)Y[Ie]=0}var le=2,_e=0,me=S,ye=ie-ge&32767;if(ue>2&&se==F(y-ye))for(var Me=Math.min(B,ue)-1,we=Math.min(32767,y),he=Math.min(258,ue);we>=ye&&--me&&ie!=ge;){if(g[y+le]==g[y+le-ye]){for(var Qe=0;he>Qe&&g[y+Qe]==g[y+Qe-ye];++Qe);if(Qe>le){if(le=Qe,_e=ye,Qe>Me)break;var ve=Math.min(ye,Qe-2),Pe=0;for(Ie=0;ve>Ie;++Ie){var Fe=y-ye+Ie+32768&32767,Re=Fe-w[Fe]+32768&32767;Re>Pe&&(Pe=Re,ge=Fe)}}}ye+=(ie=ge)-(ge=w[ie])+32768&32767}if(_e){O[W++]=268435456|L2e[le]<<18|mat[_e];var Be=31&L2e[le],ke=31&mat[_e];ee+=k2e[Be]+F2e[ke],++U[257+Be],++Y[ke],X=y+le,++J}else O[W++]=g[y],++U[g[y]]}}C=yat(g,I,m,O,U,Y,ee,W,oe,y-oe,C)}return Iat(f,0,d+fat(C)+p)})(r=t,(s=e).level==null?6:s.level,s.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(r.length)))):12+s.mem,a,A,!0)),l=c.length;return(function(g,u){var h=u.filename;if(g[0]=31,g[1]=139,g[2]=8,g[8]=2>u.level?4:u.level==9?2:0,g[9]=3,u.mtime!=0&&Y2e(g,4,Math.floor(new Date(u.mtime||Date.now())/1e3)),h){g[3]=8;for(var d=0;h.length>=d;++d)g[d+10]=h.charCodeAt(d)}})(c,e),Y2e(c,l-8,n.d()),Y2e(c,l-4,o),c}const n9n=!!vye||!!VK,xat=new WeakMap,Eat="text/plain";let U2e=0,une=!1;const Bat=(t,e)=>{const[n,o]=t.split("#"),[i,r]=n.split("?");if(!r)return t;const s=r.split("&").filter(a=>a.split("=")[0]!==e).join("&");return`${i}${s?`?${s}`:""}${o?`#${o}`:""}`},IV=(t,e,n=!0)=>{var o;const[i,r]=t.split("?"),s=sn({},e),a=(o=r?.split("&").map(c=>{var l;const[g,u]=c.split("="),h=n&&(l=s[g])!==null&&l!==void 0?l:u;return delete s[g],`${g}=${h}`}))!==null&&o!==void 0?o:[],A=(function(c,l="&"){let g,u;const h=[];return vl(c,function(d,p){Eo(d)||Eo(p)||p==="undefined"||(g=encodeURIComponent((m=>m instanceof File)(d)?d.name:d.toString()),u=encodeURIComponent(p),h[h.length]=u+"="+g)}),h.join(l)})(s);return A&&a.push(A),a.length>0?`${i}?${a.join("&")}`:i},K2e=t=>{if(t.nl)return t.nl;const{data:e,compression:n}=t;if(!e)return;if(n===N3.GZipJS){const i=t9n((function(r){var s=r.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(r);for(var a=new m5(r.length+(r.length>>>1)),A=0,c=function(h){a[A++]=h},l=0;s>l;++l){if(A+5>a.length){var g=new m5(A+8+(s-l<<1));g.set(a),a=g}var u=r.charCodeAt(l);128>u?c(u):2048>u?(c(192|u>>>6),c(128|63&u)):u>55295&&57344>u?(c(240|(u=65536+(1047552&u)|1023&r.charCodeAt(++l))>>>18),c(128|u>>>12&63),c(128|u>>>6&63),c(128|63&u)):(c(224|u>>>12),c(128|u>>>6&63),c(128|63&u))}return Iat(a,0,A)})(Lk(e)),{mtime:0});return{contentType:Eat,body:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),estimatedSize:i.byteLength}}if(n===N3.Base64){const i=(function(s){return s&&btoa(encodeURIComponent(s).replace(/%([0-9A-F]{2})/g,(a,A)=>String.fromCharCode(parseInt(A,16))))})(Lk(e)),r=(s=>"data="+encodeURIComponent(typeof s=="string"?s:Lk(s)))(i);return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}const o=Lk(e);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}},bat=t=>{const e=()=>t.transport==="sendBeacon"?{url:IV(t.url,{compression:N3.Base64}),encodedBody:K2e(sn(sn({},t),{},{compression:N3.Base64,nl:void 0}))}:{url:Bat(t.url,"compression"),encodedBody:K2e(sn(sn({},t),{},{compression:void 0,nl:void 0}))};let n;try{n=K2e(t)}catch(i){if(Mrt(t.compression,Hk(t.url,"compression")))return gi.error("Failed to gzip request body, sending uncompressed payload",i),e();throw i}return n&&Mrt(t.compression,Hk(t.url,"compression"))&&!((o=n.body)instanceof ArrayBuffer?Jye(new Uint8Array(o)):ArrayBuffer.isView(o)&&Jye(new Uint8Array(o.buffer,o.byteOffset,o.byteLength)))?(une=!0,e()):{url:t.url,encodedBody:n};var o},Sat=t=>{try{return bat(t)}catch(n){var e;return gi.error(n),void((e=t.callback)===null||e===void 0||e.call(t,{statusCode:0,error:n}))}},o9n=(function(){var t=Wg(function*(e){const n=yield(function(i){return Wye.apply(this,arguments)})(Lk(e.data),Ym.DEBUG,{rethrow:!0});if(!n)return e;const o=yield n.arrayBuffer();return sn(sn({},e),{},{nl:{contentType:Eat,body:o,estimatedSize:o.byteLength}})});return function(e){return t.apply(this,arguments)}})(),i9n=/Failed to fetch|NetworkError|Load failed/i,Qat=t=>t?.name==="TypeError"&&i9n.test(t?.message||""),vat=t=>{try{const e=(function(n,o=Date.now()){if(typeof n!="string"||!n)return;const i=n.trim(),r=/^\d+\s*,/.test(i)?i.slice(0,i.indexOf(",")).trim():i;if(/^\d+$/.test(r)){const A=1e3*Math.min(Number(r),300);return A>0?A:void 0}if(!/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(r))return;const s=/^\w{3} \w{3} /.test(r)?r+" GMT":r,a=Date.parse(s)-o;return Number.isFinite(a)&&a>0?Math.min(a,Vte):void 0})(t());return Eo(e)?void 0:Math.min(e,3e4)}catch{return}},wat=t=>{const e=Sat(t);if(!e)return;const n=new vye;xat.set(n,!0);const{url:o,encodedBody:i}=e;n.open(t.method||"GET",o,!0);const{contentType:r,body:s}=i??{};vl(t.headers,function(a,A){n.setRequestHeader(A,a)}),r&&n.setRequestHeader("Content-Type",r),t.timeout&&(n.timeout=t.timeout),n.onreadystatechange=()=>{if(n.readyState===4){var a;const A={statusCode:n.status,text:n.responseText};if(n.status===200)try{A.json=JSON.parse(n.responseText)}catch{}(a=t.callback)===null||a===void 0||a.call(t,A,vat(()=>n.getResponseHeader("Retry-After")))}},n.send(s)},Pat=t=>{const e=Sat(t);if(!e)return;const{url:n,encodedBody:o}=e,{contentType:i,body:r,estimatedSize:s}=o??{},a=new Headers;vl(t.headers,function(d,p){a.append(p,d)}),i&&a.append("Content-Type",i);let A=null,c=!1;if(Qit){const d=new Qit;A={signal:d.signal,timeout:setTimeout(()=>{c=!0;try{d.abort(prt("AbortError","PostHog request timed out"+((p=t.timeout)?` after ${p}ms`:"")))}catch(m){g(m)}var p},t.timeout)}}let l=!1;const g=d=>{var p;l||(l=!0,c&&d?.name==="AbortError"||Qat(d)?gi.warn(d):gi.error(d),(p=t.callback)===null||p===void 0||p.call(t,{statusCode:0,error:d}))};let u=0;const h=()=>{U2e-=u,u=0,A&&clearTimeout(A.timeout)};try{const d=sn({method:t?.method||"GET",headers:a,referrerPolicy:"strict-origin",body:r,signal:A?.signal},t.fetchOptions),p=s??(Eo(r)?0:void 0);d.keepalive=d.method==="POST"&&!t.sl&&d.keepalive!==!1&&d.body===r&&!Eo(p)&&p>=0&&52428.8>U2e+p,d.keepalive&&(u=p,U2e+=u),VK(n,d).then(m=>m.text().then(_=>{var f;if(l)return;const I={statusCode:m.status,text:_};if(m.status===200)try{I.json=JSON.parse(_)}catch(C){gi.error(C)}l=!0,h(),(f=t.callback)===null||f===void 0||f.call(t,I,vat(()=>m.headers.get("Retry-After")))})).catch(m=>{h(),g(m)}).finally(h)}catch(d){h(),g(d)}},V2e=t=>{try{var e;const{url:n,encodedBody:o}=bat(t),{contentType:i,body:r,estimatedSize:s}=o??{};if(!r)return;const a=r instanceof Blob?r:new Blob([r],{type:i});if(F_.sendBeacon(n,a))return;const A=As(t.data)?t.data:(e=t.data)===null||e===void 0?void 0:e.batch;if(As(A)&&A.length>1&&(s??0)>16384){const c=Math.ceil(A.length/2),l=g=>As(t.data)?g:sn(sn({},t.data),{},{batch:g});return V2e(sn(sn({},t),{},{data:l(A.slice(0,c))})),void V2e(sn(sn({},t),{},{data:l(A.slice(c))}))}gi.warn(`Beacon of ~${s??0} bytes was rejected by the browser, falling back to ${VK?"fetch":"XHR"}`),VK?Pat(sn(sn({},t),{},{sl:!0})):wat(t)}catch(n){gi.warn("Beacon send failed",n)}},Mat=(t,e,n,o)=>{const i=o==="query"?e==="POST"?"sent_at":"_":void 0;return IV(n===N3.GZipJS?Bat(t,"compression"):t,sn(sn({},i?{[i]:Date.now().toString()}:{}),n===N3.GZipJS?{}:{compression:n}))},r9n=(()=>{const t=[];return VK&&t.push({transport:"fetch",method:Pat}),vye&&t.push({transport:"XHR",method:wat}),F_?.sendBeacon&&t.push({transport:"sendBeacon",method:V2e}),t})();let Dat=!n9n&&hy?.indexOf("MSIE")===-1&&hy?.indexOf("Mozilla")===-1;function Nat(t,e,n){var o,i,r;n&&(e=sn(sn({},e),{},{callback:s=>n(s)})),t.__loaded?Dat?t.__request_queue.push(e):t.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&((i=e.callback)===null||i===void 0||i.call(e,{statusCode:429})):(e.transport=e.transport||t.config.api_transport,e.headers=sn(sn({},t.config.request_headers),e.headers),e.compression=e.compression==="best-available"?(o=t.compression)!==null&&o!==void 0?o:e.compressionFallback:e.compression,(Eo(t.config.disable_beacon)?t.config.__preview_disable_beacon:t.config.disable_beacon)&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||t.config.fetch_options,((s,a)=>{var A,c,l;const g=sn(sn({},s),{},{callback:a??(m=>{var _;return(_=s.callback)===null||_===void 0?void 0:_.call(s,m)})});g.timeout=g.timeout||6e4;const u=(A=g.transport)!==null&&A!==void 0?A:"fetch";u==="sendBeacon"&&Eo(g.compression)&&g.data&&(g.compression=N3.Base64),g.method==="POST"&&g.data&&(g.timestampMode==="capture-body"?g.data=(m=>{var _,f;const I=(As(m)?m:[m]).map(y=>sn(sn({},y),y.timestamp instanceof Date&&!isNaN(y.timestamp.getTime())?{timestamp:y.timestamp.toISOString()}:{})),C=I[0];return{api_key:(_=C==null||(f=C.properties)===null||f===void 0?void 0:f.token)!==null&&_!==void 0?_:C?.token,batch:I,sent_at:new Date().toISOString()}})(g.data):g.timestampMode==="body"&&(g.data=((m,_=new Date().toISOString())=>As(m)?m.map(f=>sn(sn({},f),{},{sent_at:_})):sn(sn({},m),{},{sent_at:_}))(g.data))),g.url=Mat(g.url,g.method,g.compression,g.timestampMode);const h=r9n.filter(m=>!g.disableTransport||!m.transport||!g.disableTransport.includes(m.transport)),d=(c=(l=(function(m,_){for(let f=0;m.length>f;f++)if(_(m[f]))return m[f]})(h,m=>m.transport===u))===null||l===void 0?void 0:l.method)!==null&&c!==void 0?c:h[0].method;if(!d)throw new Error("No available transport method");const p=m=>{try{d(m)}catch(f){var _;Qat(f)?gi.warn(f):gi.error(f),(_=g.callback)===null||_===void 0||_.call(g,{statusCode:0,error:f})}};u!=="sendBeacon"&&!g.preferSyncCompression&&g.data&&g.compression===N3.GZipJS&&j5n&&typeof Promise<"u"&&!une?o9n(g).then(m=>{p(m)}).catch(m=>{if(Drt(m))return une=!0,void p(sn(sn({},g),{},{compression:void 0,url:Mat(s.url,s.method,void 0,s.timestampMode)}));(_=>{if(!_||typeof _!="object")return!1;const f="name"in _?String(_.name):"";return Drt(_)||f===Prt})(m)&&(une=!0),p(g)}):p(g)})(e,(s,a)=>{var A,c,l;t.rateLimiter.checkForLimiting(s),400>s.statusCode||(A=(c=t.config).on_request_error)===null||A===void 0||A.call(c,s),n?n(s,a):(l=e.callback)===null||l===void 0||l.call(e,s)})):e.fireCallbackOnDrop&&((r=e.callback)===null||r===void 0||r.call(e,{statusCode:0}))}var s9n=class{constructor(e,n){this.rl=!0,this.ol=[],this.al=E9(n?.flush_interval_ms||3e3,250,5e3,gi.createLogger("flush interval"),3e3),this.ll=e}enqueue(e){this.ol.push(e),this.ul||this.hl()}unload(){this.cl();const e=this.ol.length>0?this.dl():{},n=Object.values(e);[...n.filter(o=>o.url.indexOf("/e")===0),...n.filter(o=>o.url.indexOf("/e")!==0)].map(o=>{this.vl(o,"sendBeacon")})}enable(){this.rl=!1,this.hl()}hl(){this.rl||(this.ul=setTimeout(()=>{if(this.cl(),this.ol.length>0){const e=this.dl();for(const n in e)this.vl(e[n])}},this.al))}vl(e,n){try{this.ll(e,n)}catch(o){gi.error(o)}}cl(){clearTimeout(this.ul),this.ul=void 0}dl(){const e={};return vl(this.ol,n=>{var o;const i=n,r=((i?i.batchKey:null)||i.url)+(i.batchGroup?`:${i.batchGroup}`:"");Eo(e[r])&&(e[r]=sn(sn({},i),{},{data:[]})),(o=e[r].data)===null||o===void 0||o.push(i.data)}),this.ol=[],e}};const a9n=["retriesPerformedSoFar"];var A9n=class{constructor(e){this._instance=e,this.fl=!1,this.pl=3e3,this.ol=[],this.ol=[],this.gl=!0,this.resume()}resume(){if(!Eo(Fn)&&"onLine"in Fn.navigator){if(this.gl=Fn.navigator.onLine,this.ml)return;this.ml=()=>{this.gl=!0,this.yl()},this.bl=()=>{this.gl=!1},jc(Fn,"online",this.ml),jc(Fn,"offline",this.bl)}}get length(){return this.ol.length}retriableRequest(e,n){let{retriesPerformedSoFar:o}=e,i=Rrt(e,a9n);I8(o)&&(i.url=IV(i.url,{retry_count:o})),Nat(this._instance,n?sn(sn({},i),{},{transport:n}):i,(r,s)=>{var a;if(r.statusCode!==200&&(400>r.statusCode||r.statusCode>=500)){if((r.statusCode===0?3:10)>(o??0))return void this.Ls(sn({retriesPerformedSoFar:o},i),s);r.statusCode===0&&gi.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after ${o??0} retries.`)}(a=i.callback)===null||a===void 0||a.call(i,r)})}Ls(e,n){const o=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=o+1;const i=Math.max((function(a){const A=3e3*Math.pow(2,a),c=A/2,l=Math.min(18e5,A),g=(Math.random()-.5)*(l-c);return Math.ceil(l+g)})(o),n??0),r=Date.now()+i;this.ol.push({retryAt:r,requestOptions:e});let s=`Enqueued failed request for retry in ${i}`;navigator.onLine||(s+=" (Browser is offline)"),gi.warn(s),this.fl||(this.fl=!0,this._l())}_l(){if(this.wl&&clearTimeout(this.wl),this.ol.length===0)return this.fl=!1,void(this.wl=void 0);this.wl=setTimeout(()=>{this.gl&&this.ol.length>0&&this.yl(),this._l()},this.pl)}yl(){const e=Date.now(),n=[],o=this.ol.filter(i=>e>i.retryAt||(n.push(i),!1));if(this.ol=n,o.length>0)for(const{requestOptions:i}of o)this.retriableRequest(i)}unload(){this.wl&&(clearTimeout(this.wl),this.wl=void 0),this.fl=!1,Eo(Fn)||(this.ml&&(Fn.removeEventListener("online",this.ml),this.ml=void 0),this.bl&&(Fn.removeEventListener("offline",this.bl),this.bl=void 0));for(const{requestOptions:e}of this.ol)try{this._instance._send_request(sn(sn({},e),{},{transport:"sendBeacon"}))}catch(n){gi.error(n)}this.ol=[]}},c9n=class{constructor(e){this._instance=e,this.kl=()=>{var n,o,i,r;this.Sl||(this.Sl={});const s=this.scrollElement(),a=this.scrollY(),A=s?Math.max(0,s.scrollHeight-s.clientHeight):0,c=a+(s?.clientHeight||0),l=s?.scrollHeight||0;this.Sl.lastScrollY=Math.ceil(a),this.Sl.maxScrollY=Math.max(a,(n=this.Sl.maxScrollY)!==null&&n!==void 0?n:0),this.Sl.maxScrollHeight=Math.max(A,(o=this.Sl.maxScrollHeight)!==null&&o!==void 0?o:0),this.Sl.lastContentY=c,this.Sl.maxContentY=Math.max(c,(i=this.Sl.maxContentY)!==null&&i!==void 0?i:0),this.Sl.maxContentHeight=Math.max(l,(r=this.Sl.maxContentHeight)!==null&&r!==void 0?r:0)}}get xl(){return this._instance.config.scroll_root_selector}getContext(){return this.Sl}resetContext(){const e=this.Sl;return this.Sl=void 0,setTimeout(this.kl,0),e}startMeasuringScrollPosition(){jc(Fn,"scroll",this.kl,{capture:!0}),jc(Fn,"scrollend",this.kl,{capture:!0}),jc(Fn,"resize",this.kl)}scrollElement(){if(this.xl){const o=As(this.xl)?this.xl:[this.xl];for(const i of o){var e;const r=Fn==null||(e=Fn.document)===null||e===void 0?void 0:e.querySelector(i);if(r)return r}return}var n;return Fn==null||(n=Fn.document)===null||n===void 0?void 0:n.documentElement}$l(e){var n,o;const i=e==="y"?"scrollTop":"scrollLeft";if(this.xl){const r=this.scrollElement();return r&&r[i]||0}return Fn?e==="y"?Fn.scrollY||Fn.pageYOffset||((n=Fn.document)===null||n===void 0||(n=n.documentElement)===null||n===void 0?void 0:n.scrollTop)||0:Fn.scrollX||Fn.pageXOffset||((o=Fn.document)===null||o===void 0||(o=o.documentElement)===null||o===void 0?void 0:o.scrollLeft)||0:0}scrollY(){return this.$l("y")}scrollX(){return this.$l("x")}};const l9n=t=>iat(t?.config.mask_personal_data_properties,t?.config.custom_personal_data_properties,t?.config.disable_capture_url_hashes);var Rat=class{constructor(e,n,o,i){this.qe=r=>{const s=this.Cl();if(s&&s.sessionId===r)return;const a={sessionId:r,props:this.Tl(this._instance)};this.Il.register({[c2e]:a})},this._instance=e,this.Ml=n,this.Il=o,this.Tl=i||l9n,this.Ml.onSessionId(this.qe)}Cl(){return this.Il.props[c2e]}getSetOnceProps(){var e;const n=(e=this.Cl())===null||e===void 0?void 0:e.props;return n?"r"in n?rat(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(){const e={};return vl(m2e(this.getSetOnceProps()),(n,o)=>{o==="$current_url"&&(o="url"),e[`$session_entry_${Pye(o)}`]=n}),e}},dne=class{on(e,n){return this.El[e]||(this.El[e]=[]),this.El[e].push(n),()=>{this.El[e]=this.El[e].filter(o=>o!==n)}}emit(e,n){for(const o of this.El[e]||[])o(n);for(const o of this.El["*"]||[])o(e,n)}constructor(){this.El={}}};const Kk=Ad("[SessionId]"),Tat=864e5;var kat=class{on(e,n){return this.Pl.on(e,n)}constructor(e,n,o){var i;if(this.Rl=null,this.Al=null,this.Ol=[],this.Fl=void 0,this.Dl=!1,this.Pl=new dne,this.Ll=(s,a)=>!(!I8(s)||!I8(a))&&Math.abs(s-a)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Mr=e.config,this.Il=e.persistence,this.je=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.Nl=void 0,this._sessionActivityTimestamp=null,this.ql=n||F4,this.jl=o||F4;const r=this.Mr.persistence_name||this.Mr.token;if(this._sessionTimeoutMs=1e3*E9(this.Mr.session_idle_timeout_seconds||1800,60,36e3,Kk.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Bl(),this.Hl="ph_"+r+"_window_id",this.zl="ph_"+r+"_primary_window_exists",this.Ul()){const s=Z0.Lt(this.Hl),a=Z0.Lt(this.zl);s&&!a?this.je=s:Z0.Pt(this.Hl),Z0.$t(this.zl,!0)}!((i=this.Mr.bootstrap)===null||i===void 0)&&i.sessionID&&this.setBootstrapSessionId(this.Mr.bootstrap.sessionID),this.Wl()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return Eo(this.Ol)&&(this.Ol=[]),this.Ol.push(e),this.Xt&&e(this.Xt,this.je),()=>{this.Ol=this.Ol.filter(n=>n!==e)}}Ul(){return this.Mr.persistence!=="memory"&&!this.Il.hi&&Z0.Et()}Vl(e){e!==this.je&&(this.je=e,this.Ul()&&Z0.$t(this.Hl,e))}Gl(){return this.je?this.je:this.Ul()?Z0.Lt(this.Hl):null}Ql(e){const n=this.Rl;return!ad(n)&&!ad(e)&&5e3>Math.abs(e-n)}Jl(e,n,o){const i=n!==this._sessionActivityTimestamp,r=!(e!==this.Xt||o!==this._sessionStartTimestamp);this._sessionStartTimestamp=o,this._sessionActivityTimestamp=n,this.Xt=e,r&&!i||r&&this.Ql(n)||(this.Rl=n,this.Il.register({[Mk]:[n,e,o]}))}Zl(){var e;const n=(e=this.Mr)===null||e===void 0?void 0:e.persistence_save_debounce_ms;return I8(n)&&n>0}Kl(){this.Zl()?this.Il.refreshKey(Mk):(this.Il.flush(),this.Il.load())}Xl(){var e;if(ad(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this.Rl)return;this.Kl();const[,n,o]=this.Yl();n===this.Xt&&o===this._sessionStartTimestamp&&(this.Rl=this._sessionActivityTimestamp,this.Il.register({[Mk]:[this._sessionActivityTimestamp,(e=this.Xt)!==null&&e!==void 0?e:null,this._sessionStartTimestamp]}),this.Il.flush())}tu(){const[e]=this.Yl(),n=I8(e)?e:0,o=I8(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(n,o)}eu(e){return this.Kl(),this.Ll(e,this.tu())}Yl(){const e=this.Il.props[Mk];return As(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.Rl=null,this.Nl=void 0,clearTimeout(this.iu),this.iu=void 0,this.Jl(null,null,null)}setBootstrapSessionId(e,n=!1){const o=((i,r=new Date().getTime())=>{try{const s=(a=>{const A=a.replace(/-/g,"");if(A.length!==32)throw new Error("Not a valid UUID");if(A[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(A.substring(0,12),16)})(i);return s>r+6e4?void Kk.error("Bootstrap sessionID cannot be in the future"):s}catch(s){return void Kk.error("Invalid sessionID in bootstrap",s)}})(e);return!Eo(o)&&(n?this.Nl={sessionId:e,sessionStartTimestamp:o}:this.Jl(e,new Date().getTime(),o),!0)}destroy(){this.Dl=!0,this.Xl(),clearTimeout(this.iu),this.iu=void 0,this.Fl&&Fn&&(Fn.removeEventListener(nne,this.Fl,{capture:!1}),this.Fl=void 0),this.Ol=[]}Wl(){this.Fl=()=>{this.Xl(),this.Ul()&&Z0.Pt(this.zl)},jc(Fn,nne,this.Fl,{capture:!1})}checkAndGetSessionAndWindowId(e=!1,n=null,o=!1){if(this.Mr.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');const i=n||new Date().getTime(),r=this.Xt;if(o)this.Al=i;else if(ad(this.Al)||this.Al>i||i-this.Al>=1e3){var s,a;(s=(a=this.Il).syncCookieProperties)===null||s===void 0||s.call(a),this.Al=i}let[,A,c]=this.Yl();const l=!Eo(r)&&A!==r,g=this.tu();let u=this.Gl();const h=this.Nl,d=!!h&&(h.sessionStartTimestamp>i+6e4||i-h.sessionStartTimestamp>Tat),p=h?d:I8(c)&&Math.abs(i-c)>Tat;let m=!1,_=l,f=!A||!!h;const I=A;let C=!f&&!e&&this.Ll(i,g);if(C&&(C=this.eu(i),C||Kk.info("cross-tab refresh kept the session alive",{sessionId:A}),[,A,c]=this.Yl(),C||(f=!A||!!h)),f||C||p){_=!1;const B=h&&!d;A=B?h.sessionId:this.ql(),u=this.jl(),Kk.info("new session ID assigned",{sessionId:A,windowId:u,bootstrapped:!!B,changeReason:{noSessionId:f,activityTimeout:C,sessionPastMaximumLength:p}}),c=B?h.sessionStartTimestamp:i,this.Nl=void 0,m=!0}else u||(u=this.jl(),m=!0),_=_||A!==I,_&&(Kk.info("adopted cross-tab session id",{sessionId:A,windowId:u}),m=!0);const y=I8(g)&&e&&!p?g:i,x=I8(c)?c:new Date().getTime();this.Vl(u),this.Jl(A,y,x),e||this.Bl();const E={noSessionId:f,activityTimeout:C,sessionPastMaximumLength:p,crossTabAdoption:_};return m&&this.Ol.forEach(B=>B(A,u,E)),{sessionId:A,windowId:u,sessionStartTimestamp:x,changeReason:m?E:void 0,lastActivityTimestamp:g}}Bl(){this.Dl||(clearTimeout(this.iu),this.iu=setTimeout(()=>{if(!this.Dl)if(this.eu(new Date().getTime())){const e=this.Xt;this.resetSessionId(),this.Pl.emit("forcedIdleReset",{idleSessionId:e})}else this.Bl()},1.1*this.sessionTimeoutMs))}};const Fat=function(t,e){if(!t)return!1;const n=t.userAgent;if(n&&Rit(n,e))return!0;try{const o=t?.userAgentData;if(o?.brands&&o.brands.some(i=>Rit(i?.brand,e)))return!0}catch{}return!!t.webdriver};function Lat(){return(Lat=Wg(function*(){const t=F_?.userAgentData;if(t?.getHighEntropyValues)try{const e=yield t.getHighEntropyValues(["model"]),n=e?.model;return nA(n)&&n.length>0?n:void 0}catch(e){return void gi.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}})).apply(this,arguments)}function g9n(t,e){let n=`$survey_${e}/${t.id}`;return t.current_iteration&&t.current_iteration>0&&(n=`$survey_${e}/${t.id}/${t.current_iteration}`),n}function Hat(t){var e;return!!(!((e=t.conditions)===null||e===void 0||(e=e.events)===null||e===void 0||(e=e.values)===null||e===void 0)&&e.length)}const hne=(t,e)=>{if(!(n=>{try{new RegExp(n)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(t)}catch{return!1}},pne=t=>t.toLowerCase(),Oat={exact:(t,e)=>e.some(n=>t.some(o=>n===o)),is_not:(t,e)=>e.every(n=>t.every(o=>n!==o)),regex:(t,e)=>e.some(n=>t.some(o=>hne(n,o))),not_regex:(t,e)=>e.every(n=>t.every(o=>!hne(n,o))),icontains:(t,e)=>e.map(pne).some(n=>t.map(pne).some(o=>n.includes(o))),not_icontains:(t,e)=>e.map(pne).every(n=>t.map(pne).every(o=>!n.includes(o))),gt:(t,e)=>e.some(n=>{const o=parseFloat(n);return!isNaN(o)&&t.some(i=>o>parseFloat(i))}),lt:(t,e)=>e.some(n=>{const o=parseFloat(n);return!isNaN(o)&&t.some(i=>o<parseFloat(i))})};function Gat(t,e){return!t||Object.entries(t).every(([n,o])=>{const i=e?.[n];if(i==null)return!1;const r=Oat[o.operator];return!!r&&r(o.values.map(String),[String(i)])})}function z2e(t,e,n){return Lk({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:n})}const J2e="custom",Yat="i.posthog.com",u9n=/^\/static\//,d9n=["/s/","/e/","/i/"];var h9n=class{constructor(e){this.nu={},this.instance=e}get apiHost(){const e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){const e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e;let n=(e=this.instance.config.ui_host)===null||e===void 0?void 0:e.replace(/\/$/,"");return n||(n=this.apiHost.replace(`.${Yat}`,".posthog.com")),n==="https://app.posthog.com"?"https://us.posthog.com":n}get region(){return this.nu[this.apiHost]||(this.nu[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":J2e),this.nu[this.apiHost]}su(e){if(!u9n.test(e))return;const n=this.instance.config.asset_host;return typeof n=="string"&&n.trim().replace(/\/$/,"")||void 0}ru(e){const n=x8(e);return n?n.protocol+"//"+n.host+n.pathname:void 0}ou(e,n,o){if(e==="ui")return o;let i=o;const r=this.instance.config.rewriteRequestPath;if(r){var s;const a=((s=x8(o))===null||s===void 0?void 0:s.href)||o;i=r(new URL(a)).toString()}if(r&&e==="api"&&d9n.some(a=>n.indexOf(a)===0)){const a=this.ru(i);if(a){const A=this.apiHost;let c=this.au;c?.apiHost===A&&c.rewriteRequestPath===r||(c={apiHost:A,rewriteRequestPath:r,urls:new Set},this.au=c),c.urls.add(a)}}return i}isIngestionEndpoint(e){const n=this.au,o=this.ru(e);return n?.apiHost===this.apiHost&&n.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!o&&n.urls.has(o)}endpointFor(e,n=""){if(n&&(n=n[0]==="/"?n:`/${n}`),e==="ui")return this.ou(e,n,this.uiHost+n);if(e==="flags")return this.ou(e,n,this.flagsApiHost+n);if(e==="assets"){const i=this.su(n);if(i)return this.ou(e,n,`${i}${n}`)}if(this.region===J2e)return this.ou(e,n,this.apiHost+n);const o=Yat+n;switch(e){case"assets":return this.ou(e,n,`https://${this.region}-assets.${o}`);case"api":return this.ou(e,n,`https://${this.region}.${o}`)}}};const _l=Ad("[Surveys]"),Uat=t=>{try{const e=(n=>((o,i)=>`seenSurvey_${(function(r){return r.current_iteration&&r.current_iteration>0?`${r.id}_${r.current_iteration}`:r.id})(i)}`)(0,n))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(e){_l.error("Failed to persist survey seen state",e)}},p9n=[N2e.Popover,N2e.Widget,N2e.API],m9n={ignoreConditions:!1,ignoreDelay:!1,displayType:T2e.Popover},_9n=Ad("[PostHog ExternalIntegrations]"),f9n={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var I9n=class{constructor(e){this._instance=e}Ho(e,n){var o,i;(o=Ur.__PosthogExtensions__)===null||o===void 0||(i=o.loadExternalDependency)===null||i===void 0||i.call(o,this._instance,e,r=>{if(r)return _9n.error("failed to load script",r);n()})}startIfEnabledOrStop(){var e;for(const[r,s]of Object.entries((e=this._instance.config.integrations)!==null&&e!==void 0?e:{})){var n,o,i;s&&!(!((n=Ur.__PosthogExtensions__)===null||n===void 0||(n=n.integrations)===null||n===void 0)&&n[r])&&this.Ho(f9n[r],()=>{var a;(a=Ur.__PosthogExtensions__)===null||a===void 0||(a=a.integrations)===null||a===void 0||(a=a[r])===null||a===void 0||a.start(this._instance)}),!s&&(!((o=Ur.__PosthogExtensions__)===null||o===void 0||(o=o.integrations)===null||o===void 0)&&o[r])&&((i=Ur.__PosthogExtensions__)===null||i===void 0||(i=i.integrations)===null||i===void 0||(i=i[r])===null||i===void 0||i.stop())}}},C9n=class{constructor(e,n){this.A=e,this.bo=n,this.lu=new Map,this.To=!1}add(e){var n=this;return Wg(function*(){if(n.To)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(n.lu.has(e.name))throw new Error(`Browser extension "${e.name}" is already registered`);n.lu.set(e.name,e);try{const o=e.setup(n.bo);o&&(yield o)}catch(o){const i=n.lu.get(e.name)===e;i&&n.lu.delete(e.name),n.A.error(`Failed to set up browser extension "${e.name}"`,o),i&&n.uu(e)}})()}getExtension(e){return this.lu.get(e)}dispose(){if(this.To)return;this.To=!0;const e=Array.from(this.lu.values()).reverse();this.lu.clear();for(const n of e)this.uu(n)}uu(e){try{var n;const o=(n=e.dispose)===null||n===void 0?void 0:n.call(e);o&&L_(o.then)&&o.then(void 0,i=>{this.A.error(`Failed to dispose browser extension "${e.name}"`,i)})}catch(o){this.A.error(`Failed to dispose browser extension "${e.name}"`,o)}}},y9n=class{constructor(e){this._instance=e}initialize(){}get(e){const n=this._instance.persistence;if(typeof e=="string")return n?.get_property(e);const o={};for(const i of e){const r=n?.get_property(i);Eo(r)||(o[i]=r)}return o}set(e,n){var o;(o=this._instance.persistence)===null||o===void 0||o.register(typeof e=="string"?{[e]:n}:e)}remove(e){var n;(n=this._instance.persistence)===null||n===void 0||n.unregister(e)}};const Kat="extensionsRemoteConfig";var x9n=class{constructor(e){this.instance=e,this.To=!1,this.A=gi,this.hu=e.cu,this.kv=new y9n(e),this.onEvent=n=>lne(this.instance.on("eventCaptured",o=>{try{n({event:o.event,properties:o.properties})}catch(i){this.A.error("Browser extension event listener failed",i)}})),this.onRemoteConfig=n=>{if(this.To)return lne(()=>{});const o=r=>{try{n(r)}catch(s){this.A.error("Browser extension remote config listener failed",s)}},i=this.instance.du.on(Kat,o);return this.hu&&o(this.hu),lne(i)},this.vu=new C9n(gi.createLogger("[BrowserExtensions]"),this)}get logger(){return this.A}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var e;return(e=this.instance.get_property("$device_id"))!==null&&e!==void 0?e:this.distinctId}get deviceId(){const e=this.instance.get_property($ye);return typeof e=="string"?e:void 0}get library(){return{name:Ym.LIB_NAME,version:Ym.LIB_VERSION}}get initialPersonProperties(){var e,n;return(e=(n=this.instance.persistence)===null||n===void 0?void 0:n.get_initial_props())!==null&&e!==void 0?e:{}}get groups(){return this.instance.getGroups()}get session(){try{var e,n,o,i;const r=(e=this.instance.sessionManager)===null||e===void 0?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:(n=r?.sessionId)!==null&&n!==void 0?n:"",windowId:(o=r?.windowId)!==null&&o!==void 0?o:"",sessionStartTimestamp:(i=r?.sessionStartTimestamp)!==null&&i!==void 0?i:0}}catch{return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(e){return this.vu.add(e)}getExtension(e){return this.vu.getExtension(e)}capture(e,n,o){o?this.instance.capture(e,n,{timestamp:o.timestamp,uuid:o.uuid,$set:o.set,$set_once:o.setOnce}):this.instance.capture(e,n)}registerDynamicEventProperties(e){return lne(this.instance.fu(e))}handleRemoteConfig(e){this.To||(this.hu=e,this.instance.du.emit(Kat,e))}sendRequest(e){var n=this;return Wg(function*(o,i={}){var r;const s=n.instance.requestRouter.endpointFor((r=i.target)!==null&&r!==void 0?r:"api",o),a={method:i.method,url:i.query?IV(s,i.query):s,data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,compressionFallback:i.target==="flags"&&i.compression==="best-available"?wye.Base64:void 0,timestampMode:i.sentAt};return i.transport==="sendBeacon"?(n.instance._send_request(a),{statusCode:202}):new Promise(A=>{a.callback=A,n.instance._send_request(a)})}).apply(this,arguments)}dispose(){this.To||(this.To=!0,this.vu.dispose())}};const CV={};let W2e=0;const yV=()=>{},Vat='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Vk="Surveys module not available",zat="sanitize_properties is deprecated. Use before_send instead",Jat="Invalid value for property_denylist config: ",E9n=["$recording_status","$sdk_debug_recording_script_not_loaded","$sdk_debug_replay_url_trigger_status","$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_rrweb_error","$sdk_debug_replay_internal_buffer_length","$sdk_debug_replay_flushed_size"],B9n=["$feature_flag_called","$$heatmap","$snapshot"],Wat=t=>t.charAt(0)==="$"&&!as(B9n,t),b9n=/^[A-Za-z0-9_-]{1,400}$/,jat=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,Xat=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,S9n=["token","distinct_id",Ast],xV="posthog",Q9n=t=>{const e={};return t&&t!=="unset"&&("2025-11-30">t||(e.strictMinimumDuration=!0),"2026-05-30">t||(e.canvasCapture={resolutionScale:.6}),"2026-06-25">t||(e.streamNetworkBody=!0),"2026-08-30">t||(e.captureJsonLd=!0)),e},j2e=t=>{var e;return sn({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:BBn(No?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:yV,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:sd&&nA(sd?.search)&&sd.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,reuseAnonymousId:!1,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:(Fn==null||(e=Fn.location)===null||e===void 0?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,feature_flag_request_max_retries:1,surveys_request_timeout_ms:1e4,on_request_error(n){gi.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:fst,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:yV},(n=>({rageclick:n&&n>="2026-05-30"?{content_ignorelist:DBn,ignore_text_selection:!0}:!n||"2025-11-30">n||{content_ignorelist:!0},capture_pageview:!n||"2025-05-24">n||"history_change",session_recording:Q9n(n),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),cookieWinsOnConflict:!(!n||n==="unset"||"2026-08-29">n)}))(t))},v9n=[["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"],["__preview_cookie_wins_on_conflict","cookieWinsOnConflict"]],qat=t=>{const e={};for(const[i,r]of v9n)Eo(t[i])||(e[r]=t[i]);const n=jg({},e,t),o=t.__preview_external_dependency_versioned_paths;return Eo(o)||(Eo(t.strict_script_versioning)&&(n.strict_script_versioning=!!o),nA(o)&&Eo(t.asset_host)&&(n.asset_host=o)),As(t.property_blacklist)&&(Eo(t.property_denylist)?n.property_denylist=t.property_blacklist:As(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:gi.error(Jat+t.property_denylist)),n};var w9n=class{constructor(){this.__forceAllowLocalhost=!1}get pu(){return this.__forceAllowLocalhost}set pu(e){gi.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},EV=class SM{gu(e){if(!e)return;const n=this.lu.indexOf(e);n!==-1&&this.lu.splice(n,1)}mu(e,n){var o;return this.gu(e),this.lu.push(n),(o=n.initialize)===null||o===void 0||o.call(n),n}yu(){return this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isRejected()}bu(){if(this._u||this.config.reuseAnonymousId||this.config.segment||this.yu())return;const e=this.config.persistence==="memory"||this.config.persistence==="sessionStorage";if(!e&&!this.config.disable_persistence||this.wu)return;let n,o,i;e?(n=`persistence is set to '${this.config.persistence}'`,o=this.config.persistence==="memory"?"on every page load":"for every new browser tab or window",i="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(n="persistence is disabled (disable_persistence is true)",o="on every page load",i="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this._u=!0,console.warn("[PostHog.js]",`${n} but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID ${o}, so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. ${i}`)}ku(){const e=this.persistence;if(!e||this.Su)return;if(this.yu())return void(this.config.cookieless_mode==="on_reject"&&this.get_distinct_id()!=="$posthog_cookieless"&&(this.xu(),this.$u()));if(this.get_distinct_id()!=="$posthog_cookieless")return;this.Cu()||e.load(!0);const n=this.get_distinct_id();if(!n||n==="$posthog_cookieless"){const o=this.config.get_device_id(F4());this.register({distinct_id:o,$device_id:o}),e.set_property(my,y8)}this.xu()}get decideEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)===null||n===void 0?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)===null||n===void 0?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){var e;this.Tu=!1,this.Iu=!1,this.webPerformance=new w9n,this.Mu=!1,this.version=Ym.LIB_VERSION,this.Eu=new Set,this.Pu="",this.du=new dne,this.lu=[],this.Ru=[],this.Au=!1,this.wu=!1,this._u=!1,this.Su=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=j2e(),this.SentryIntegration=OBn,this.sentryIntegration=o=>(function(i,r){const s=jst(i,r);return{name:Wst,processEvent:a=>s(a)}})(this,o),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Ou=!1,this.Fu=null,this.Du=null,this.Lu=null,this.scrollManager=new c9n(this),this.pageViewManager=new Xst(this),this.rateLimiter=new XBn(this),this.requestRouter=new h9n(this),this.consent=new MBn(this),this.externalIntegrations=new I9n(this);const n=(e=SM.__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:(o,i,r)=>{const s=nA(o)?{[o]:i}:o;this.setPersonProperties(s),r?.({})},set_once:(o,i,r)=>{const s=nA(o)?{[o]:i}:o;this.setPersonProperties(void 0,s),r?.({})}},this.on("eventCaptured",o=>gi.info(`send "${o?.event}"`,o))}init(e,n,o){if(o&&o!==xV){var i;const r=(i=CV[o])!==null&&i!==void 0?i:new SM;return r._init(e,n,o),CV[o]=r,CV[xV][o]=r,r}return this._init(e,n,o)}_init(e,n={},o){var i,r,s;const a=nA(e)?e.trim():"";if(!a)return gi.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;var A;if(this.__loaded)return a!==((A=this.config)===null||A===void 0?void 0:A.token)?console.warn("[PostHog.js]",`You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('${a}', { ... }, 'project2')`):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=j2e(n.defaults),n.debug=this.Nu(n.debug),this.qu=n,this.ju=[],n.person_profiles?this.Du=n.person_profiles:n.process_person&&(this.Du=n.process_person);const c=j2e(n.defaults),l=qat(n),g=jg({},c,l,{name:o,token:a});xA(c.rageclick)&&xA(l.rageclick)&&(g.rageclick=jg({},c.rageclick,l.rageclick)),xA(c.session_recording)&&xA(l.session_recording)&&(g.session_recording=jg({},c.session_recording,l.session_recording)),this.set_config(g),this.config.on_xhr_error&&gi.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:N3.GZipJS;const u=this.Cu(),h=!this.yu();if(this.persistence=new D2e(this.config,u,!0,h),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new D2e(sn(sn({},this.config),{},{persistence:"sessionStorage"}),u,!1,h),this.Pu="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!u&&Z0.Et()){const f=Z0.Lt(this.Pu);As(f)&&f.forEach(I=>{nA(I)&&this.Eu.add(I)})}else Z0.Pt(this.Pu);const d=sn({},this.persistence.props),p=sn({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Bu=new s9n((f,I)=>this.Hu(f,I),this.config.request_queue_config),this.zu=new A9n(this),this.__request_queue=[];const m=this.yu();m||(this.sessionManager=new kat(this),this.sessionPropsManager=new Rat(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((f,I,C)=>{(C?.activityTimeout||C?.sessionPastMaximumLength||C?.crossTabAdoption)&&this.Uu()})),this.Wu(),this.config.__preview_deferred_init_extensions?(gi.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.Vu(m)},0)):(gi.info("Initializing extensions synchronously"),this.Vu(m)),Ym.DEBUG=Ym.DEBUG||this.config.debug,Ym.DEBUG&&gi.info("Starting in debug mode",{this:this,config:n,thisC:sn({},this.config),p:d,s:p}),this.config.identity_distinct_id&&!(!((i=n.bootstrap)===null||i===void 0)&&i.distinctID)&&(n.bootstrap=sn(sn({},n.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const _=(r=n.bootstrap)===null||r===void 0?void 0:r.distinctID;if(this.wu=!!_&&!JK(_),(s=n.bootstrap)===null||s===void 0?void 0:s.distinctID){const f=n.bootstrap.distinctID,I=this.get_distinct_id(),C=this.persistence.get_property(my);if(n.bootstrap.isIdentifiedID&&I!=null&&I!==f&&C==="anonymous")this.identify(f);else if(n.bootstrap.isIdentifiedID&&I!=null&&I!==f&&C==="identified")gi.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{const y=this.config.get_device_id(F4()),x=n.bootstrap.isIdentifiedID?y:f;this.persistence.set_property(my,n.bootstrap.isIdentifiedID?tne:y8),this.register({distinct_id:f,$device_id:x})}}if(m)this.register_once({distinct_id:g2e,$device_id:null},"");else if(!this.get_distinct_id()){const f=this.config.get_device_id(F4());this.register_once({distinct_id:f,$device_id:f},""),this.persistence.set_property(my,y8)}return jc(Fn,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),jc(Fn,"pageshow",()=>{var f;this.Tu=!1,this.Iu||(f=this.zu)===null||f===void 0||f.resume()}),n.segment?Jst(this,()=>this.Gu()):this.Gu(),L_(this.config._onCapture)&&this.config._onCapture!==yV&&(gi.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",f=>this.config._onCapture(f.event,f))),this.config.ip&&gi.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 Lat.apply(this,arguments)})().then(f=>{f&&this.register({[Zye]:f})}).catch(yV),this}Qu(e){const n=e;return nA(n.name)&&L_(n.setup)}Ju(e,n){this.Qu(e)?n.push(()=>{this.Zu().add(e).catch(()=>{var o;return(o=e.dispose)===null||o===void 0?void 0:o.call(e)}).catch(o=>{gi.error(`Failed to dispose browser extension "${e.name}"`,o)})}):this.lu.push(e)}Wu(){var e,n,o;const i=(e=(n=this.config.__extensionClasses)===null||n===void 0?void 0:n.featureFlags)!==null&&e!==void 0?e:(o=SM.__defaultExtensionClasses)===null||o===void 0?void 0:o.featureFlags;var r,s,a;i&&(this.featureFlags&&this.featureFlags instanceof i||((r=this.Ku)===null||r===void 0||r.call(this),this.Ku=void 0,this.featureFlags=new i(this)),L_(this.featureFlags.onReloading)&&L_(this.featureFlags.setup)?this.Ku||(this.Ku=this.featureFlags.onReloading(()=>{this.du.emit("featureFlagsReloading",!0)}),this.Zu().add(this.featureFlags)):(s=(a=this.featureFlags).initialize)===null||s===void 0||s.call(a))}Vu(e){const n=performance.now(),o=sn(sn({},SM.__defaultExtensionClasses),this.config.__extensionClasses),i=[];var r,s,a,A,c,l,g;o.exceptions&&this.lu.push(this.exceptions=(r=this.exceptions)!==null&&r!==void 0?r:new o.exceptions(this)),o.historyAutocapture&&this.lu.push(this.historyAutocapture=new o.historyAutocapture(this)),o.tracingHeaders&&this.lu.push(this.tracingHeaders=new o.tracingHeaders(this)),o.siteApps&&this.lu.push(this.siteApps=new o.siteApps(this)),o.sessionRecording&&!e&&this.lu.push(this.sessionRecording=new o.sessionRecording(this)),this.config.disable_scroll_properties||i.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),o.autocapture&&this.Ju(this.autocapture=new o.autocapture(this),i),o.surveys&&this.Ju(this.surveys=(s=this.surveys)!==null&&s!==void 0?s:new o.surveys(this),i),o.logs&&this.Ju(this.logs=(a=this.logs)!==null&&a!==void 0?a:new o.logs(this),i),o.metrics&&this.lu.push(this.metrics=(A=this.metrics)!==null&&A!==void 0?A:new o.metrics(this)),o.conversations&&this.lu.push(this.conversations=(c=this.conversations)!==null&&c!==void 0?c:new o.conversations(this)),o.productTours&&this.lu.push(this.productTours=new o.productTours(this)),o.heatmaps&&this.lu.push(this.heatmaps=new o.heatmaps(this)),o.webVitalsAutocapture&&this.lu.push(this.webVitalsAutocapture=new o.webVitalsAutocapture(this)),o.exceptionObserver&&this.lu.push(this.exceptionObserver=new o.exceptionObserver(this)),o.deadClicksAutocapture&&this.lu.push(this.deadClicksAutocapture=new o.deadClicksAutocapture(this,HBn)),o.toolbar&&this.lu.push(this.toolbar=(l=this.toolbar)!==null&&l!==void 0?l:new o.toolbar(this)),o.experiments&&this.lu.push(this.experiments=(g=this.experiments)!==null&&g!==void 0?g:new o.experiments(this)),this.lu.forEach(u=>{u.initialize&&i.push(()=>{var h;(h=u.initialize)===null||h===void 0||h.call(u)})}),i.push(()=>{if(this.Xu){const u=this.Xu;this.Xu=void 0,this.lu.forEach(h=>{var d;return(d=h.onRemoteConfig)===null||d===void 0?void 0:d.call(h,u)})}}),this.Yu(i,n)}Yu(e,n){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-n>=30&&e.length>0)return void setTimeout(()=>{this.Yu(e,n)},0);const i=e.shift();if(i)try{i()}catch(r){gi.error("Error initializing extension:",r)}}const o=Math.round(performance.now()-n);this.register_for_session({[cst]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[lst]:o}),this.config.__preview_deferred_init_extensions&&gi.info(`PostHog extensions initialized (${o}ms)`)}el(e){var n;if(!No||!No.body)return gi.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.el(e)},500);if(this.config.__preview_deferred_init_extensions&&(this.Xu=e),this.cu=e,this.compression=void 0,e.ok){var o;const i=e.config;i.supportedCompression&&!this.config.disable_compression&&(this.compression=as(i.supportedCompression,N3.GZipJS)?N3.GZipJS:as(i.supportedCompression,N3.Base64)?N3.Base64:void 0),!((o=i.analytics)===null||o===void 0)&&o.endpoint&&(this.analyticsDefaultEndpoint=i.analytics.endpoint)}this.set_config({person_profiles:this.Du?this.Du:fst}),(n=this.th)===null||n===void 0||n.handleRemoteConfig(e),this.lu.forEach(i=>{var r;return(r=i.onRemoteConfig)===null||r===void 0?void 0:r.call(i,e)})}Gu(){try{this.config.loaded(this)}catch(e){gi.critical("`loaded` function failed",e)}if(this.eh(),this.config.internal_or_test_user_hostname&&sd?.hostname){const e=sd.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.yu())&&this.ih()},1),this.nh=new uat(this),this.nh.load()}eh(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Bu)===null||e===void 0||e.enable())}_dom_loaded(){this.is_capturing()&&Nk(this.__request_queue,e=>this.Hu(e)),this.__request_queue=[],this.eh()}_handle_unload(){var e,n,o,i,r,s;this.Tu=!0,(e=this.surveys)===null||e===void 0||(n=e.handlePageUnload)===null||n===void 0||n.call(e),(o=this.metrics)===null||o===void 0||o.flush("sendBeacon"),this.config.request_batching?(this.sh()&&this.capture(Ist),(i=this.logs)===null||i===void 0||i.flushLogs("sendBeacon"),(r=this.Bu)===null||r===void 0||r.unload(),(s=this.zu)===null||s===void 0||s.unload()):this.sh()&&this.capture(Ist,null,{transport:"sendBeacon"})}_send_request(e){Nat(this,e)}Hu(e,n){this.zu?this.zu.retriableRequest(e,n):this._send_request(n?sn(sn({},e),{},{transport:n}):e)}_execute_array(e){W2e++;try{let n;const o=[],i=[],r=[];Nk(e,a=>{if(a)if(n=a[0],As(n))r.push(a);else if(L_(a))try{a.call(this)}catch(A){gi.error("Error executing queued PostHog call",a,A)}else As(a)&&n==="alias"?o.push(a):As(a)&&n.indexOf("capture")!==-1&&L_(this[n])?r.push(a):i.push(a)});const s=function(a,A){Nk(a,function(c){try{if(As(c[0])){let l=A;vl(c,function(g){l=l[g[0]].apply(l,g.slice(1))})}else A[c[0]].apply(A,c.slice(1))}catch(l){gi.error("Error executing queued PostHog call",c,l)}})};s(o,this),s(i,this),s(r,this)}finally{W2e--}}push(e){if(W2e>0&&As(e)&&nA(e[0])){const n=SM.prototype[e[0]];return void(L_(n)&&n.apply(this,e.slice(1)))}this._execute_array([e])}get rh(){return{property:jrt,persistenceKey:Pk,cookieName:"_fbc",pattern:jat,register:(e,n)=>{var o;return(o=this.persistence)===null||o===void 0?void 0:o.register({[Pk]:{value:e,delivered:n}})},unregister:()=>{var e;return(e=this.persistence)===null||e===void 0?void 0:e.unregister(Pk)}}}get oh(){return{property:Xrt,persistenceKey:$K,cookieName:"_fbp",pattern:Xat,register:(e,n)=>{var o;return(o=this.persistence)===null||o===void 0?void 0:o.register({[$K]:{value:e,delivered:n}})},unregister:()=>{var e;return(e=this.persistence)===null||e===void 0?void 0:e.unregister($K)}}}ah(e){var n;const o=(n=this.persistence)===null||n===void 0?void 0:n.get_property(e.persistenceKey);return nA(o)&&e.pattern.test(o)?{value:o,delivered:!1}:xA(o)&&nA(o.value)&&e.pattern.test(o.value)?{value:o.value,delivered:o.delivered===!0}:void 0}uh(e,n,o){return n===o?.value?{value:n,pending:!o.delivered}:(e.register(n,!1),{value:n,pending:!0})}hh(e){if(!this.config.save_campaign_params||this.yu())return;const n=rV(e.cookieName);return nA(n)&&e.pattern.test(n)?n:void 0}dh(e,n,o,i){if(!this.persistence)return;const r=this.rh;this.persistence.refreshKey(r.persistenceKey);const s=this.ah(r);if(i)return void r.unregister();if(o)return nA(n)&&jat.test(n)?this.uh(r,n,s):void r.unregister();const a=nA(e)&&b9n.test(e)?e:void 0,A=this.hh(r);return A&&((c,l,g)=>{const u=c.split(".");if(l)return u[3]===l;if(!g)return!0;const h=g.value.split(".");return u[3]===h[3]||Number(u[2])>Number(h[2])})(A,a,s)?this.uh(r,A,s):a?s?.value.split(".")[3]===a?{value:s.value,pending:!s.delivered}:this.uh(r,`fb.1.${Date.now()}.${a}`,s):s?{value:s.value,pending:!s.delivered}:void 0}fh(e,n,o){if(!this.persistence)return;const i=this.oh;this.persistence.refreshKey(i.persistenceKey);const r=this.ah(i);if(o)return void i.unregister();if(n)return nA(e)&&Xat.test(e)?this.uh(i,e,r):void i.unregister();const s=this.hh(i);return s?this.uh(i,s,r):r?{value:r.value,pending:!r.delivered}:void 0}ph(e,n){if(!this.persistence)return;this.persistence.refreshKey(e.persistenceKey);const o=this.ah(e);o?.value!==n||o.delivered||e.register(n,!0)}capture(e,n,o){var i,r;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Bu))return void gi.uninitializedWarning("posthog.capture");if(!this.is_capturing())return;if(Eo(e)||!nA(e))return void gi.error("No event name provided to posthog.capture");if(this.ku(),e==="$snapshot"&&this.yu())return;const s=!this.config.opt_out_useragent_filter&&this._is_bot();if(s&&!this.config.__preview_capture_bot_pageviews)return;const a=o?.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(a?.isRateLimited)return void gi.critical("This capture call is ignored due to client rate limiting.");let A;n?.$current_url&&!nA(n?.$current_url)&&(gi.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"||o?.gh||gi.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&&(A=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();const c=new Date,l=o?.timestamp||c,g=hrt(o?.uuid,F4);let u={uuid:g,event:e,properties:this.calculateEventProperties(e,n||{},l,g)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&s&&(u.event="$bot_pageview",u.properties.$browser_type="bot"),a&&(u.properties.$lib_rate_limit_remaining_tokens=a.remainingTokens);const h=e==="$feature_flag_called"&&u.properties.$feature_flag_has_experiment===!1&&this.get_property("$minimal_flag_called_events")===!0;o?.$set&&!h&&(u.$set=o?.$set);const d=xA(n?.$set)?n.$set:void 0,p=As(n?.$unset)?n.$unset:[],m=o?.$unset||[],_=R=>{var F;const O=!!o?.$set&&R in o.$set;return{hasProvided:O||!!d&&R in d,provided:O?o==null||(F=o.$set)===null||F===void 0?void 0:F[R]:d?.[R],unset:p.indexOf(R)!==-1||m.indexOf(R)!==-1}},f=_(jrt),I=_(Xrt),C=[{channel:this.rh,hasProvided:f.hasProvided,update:this.dh(A?.fbclid,f.provided,f.hasProvided,f.unset)},{channel:this.oh,hasProvided:I.hasProvided,update:this.fh(I.provided,I.hasProvided,I.unset)}];for(const{channel:R,hasProvided:F,update:O}of C)O&&u.properties.$process_person_profile===!0&&O.pending&&!F&&!h&&(u.$set=sn({[R.property]:O.value},u.$set));const y=o?.$unset;y&&(u.$unset=y);const x=h?void 0:this.mh(o?.$set_once,e!==yst,e===Cst);if(x&&(u.$set_once=x),o?._noTruncate||(E=this.config.properties_string_max_length,u=(function(R,F){const O=new Set;return(function U(Y,J){if(Y!==Object(Y))return F?F(Y):Y;if(O.has(Y))return;let ee;if(O.add(Y),As(Y))ee=[],Nk(Y,W=>{ee.push(U(W))});else{const W={};vl(Qk(Y)?xst(Y):Y,(X,oe)=>{O.has(X)||(W[oe]=U(X))}),ee=W}return ee})(R)})(u,R=>nA(R)?R.slice(0,E):R)),u.timestamp=l,Eo(o?.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=c),h&&(u.properties=((R,F=[])=>{const O={},U=Y=>{R[Y]!==void 0&&(O[Y]=R[Y])};return K4n.forEach(U),F.forEach(U),O})(u.properties,S9n)),e===R3.DISMISSED||e===R3.SENT){const R=n?.[R2e.SURVEY_ID],F=n?.[R2e.SURVEY_ITERATION];Uat({id:R,current_iteration:F}),u.$set=sn(sn({},u.$set),{},{[g9n({id:R,current_iteration:F},e===R3.SENT?"responded":"dismissed")]:!0})}else e===R3.SHOWN&&(u.$set=sn(sn({},u.$set),{},{[R2e.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var E;if(e===jBn.SHOWN){const R=n?.[lat.TOUR_TYPE];R&&(u.$set=sn(sn({},u.$set),{},{[`${lat.TOUR_LAST_SEEN_DATE}/${R}`]:new Date().toISOString()}))}const B=sn(sn({},u.properties.$set),u.$set);if(ox(B)||this.setPersonPropertiesForFlags(B),!Fs(this.config.before_send)){const R=this.Fs(u);if(!R)return;u=R,u.uuid=hrt(u.uuid,F4)}this.sessionRecording&&!this.Au&&Wat(e)&&(this.Au=!0,setTimeout(()=>this.Au=!1,3e4));const S=C.filter(({channel:R,update:F})=>{var O,U,Y;const J=(O=(U=u.$set)===null||U===void 0?void 0:U[R.property])!==null&&O!==void 0?O:xA((Y=u.properties)===null||Y===void 0?void 0:Y.$set)?u.properties.$set[R.property]:void 0;return F?.pending&&J===F.value});this.du.emit("eventCaptured",u);const Q=(i=o?._url)!==null&&i!==void 0?i:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),w=o?._batchKey==="recordings"||/\/s\/(?:\?|$)/.test(Q),M=sn(sn(sn({method:"POST",url:Q,data:u,compression:"best-available",preferSyncCompression:o?.send_instantly,timestampMode:w?"body":"capture-body",batchKey:o?._batchKey},w&&(!((r=u.properties)===null||r===void 0)&&r.$session_id)?{batchGroup:u.properties.$session_id+(u.properties.$window_id?`-${u.properties.$window_id}`:"")}:{}),o?.transport?{transport:o.transport}:{}),S.length?{fireCallbackOnDrop:!0,callback:R=>{if(R.statusCode>=200&&300>R.statusCode)for(const{channel:F,update:O}of S)this.ph(F,O.value)}}:{});if(!this.config.request_batching||o&&!o?._batchKey||o?.send_instantly||S.length){var k;let R;!M.transport&&!M.callback&&ox((k=this.config.request_headers)!==null&&k!==void 0?k:{})&&this.Tu&&(R="sendBeacon"),this.Hu(M,R)}else this.Bu.enqueue(M);return u}_addCaptureHook(e){return this.on("eventCaptured",n=>e(n.event,n))}getExtension(e){var n;return(n=this.th)===null||n===void 0?void 0:n.getExtension(e)}Zu(){var e;return(e=this.th)!==null&&e!==void 0?e:this.th=new x9n(this)}fu(e){this.Ru.push(e);let n=!0;return()=>{if(!n)return;n=!1;const o=this.Ru.indexOf(e);o!==-1&&this.Ru.splice(o,1)}}yh(e=!0){var n,o,i;return!!(!((n=this.persistence)===null||n===void 0)&&n.consumeCookieIdentityChange())&&(this.Lu=null,this.persistence.get_property("$user_state")==="anonymous"&&((i=this.sessionPersistence)===null||i===void 0||i.clear(),this.Eu.clear(),this.bh()),(o=this.featureFlags)===null||o===void 0||o.reset(),e&&this.reloadFeatureFlags(),!0)}calculateEventProperties(e,n,o,i,r){if(o=o||new Date,!this.persistence||!this.sessionPersistence)return n;this.ku(),this.persistence.syncCookieProperties(),this.yh();const s=r?void 0:this.persistence.remove_event_timer(e);let a=sn({},n);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,this.yu()&&(a[Ast]=!0),e==="$snapshot"){const f=sn(sn({},this.persistence.properties()),this.sessionPersistence.properties());return a.distinct_id=f.distinct_id,(!nA(a.distinct_id)&&!qd(a.distinct_id)||JK(a.distinct_id))&&gi.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}const A=(function(f,I,C,y=!1){var x,E,B,S;if(!hy)return{};const Q=f?[...Ok,...I||[]]:[],[w,M]=crt(hy),[k,R]=(function(se){for(let ie=0;grt.length>ie;ie++){const[ge,ue,Ie]=grt[ie],le=se.match(ge);if(le){const _e=Ie&&se.match(Ie)||le;return[ue,_e?.[1]||""]}}return["",""]})(hy),F=(function(){const se="u">typeof navigator?navigator:void 0;return se?.brave?{brave:!0}:{}})(),O={};Eo(C)||(O.detectGoogleSearchApp=C);const U={},Y=(x=navigator)===null||x===void 0||(x=x.userAgentData)===null||x===void 0?void 0:x.platform,J=(E=navigator)===null||E===void 0?void 0:E.maxTouchPoints,ee=Fn==null||(B=Fn.screen)===null||B===void 0?void 0:B.width,W=Fn==null||(S=Fn.screen)===null||S===void 0?void 0:S.height,X=Fn?.devicePixelRatio;Eo(Y)||(U.userAgentDataPlatform=Y),Eo(J)||(U.maxTouchPoints=J),Eo(ee)||(U.screenWidth=ee),Eo(W)||(U.screenHeight=W),Eo(X)||(U.devicePixelRatio=X);const oe=jg(m2e({$os:w,$os_version:M,$browser:art(hy,navigator.vendor,F,O),$webview_app:k,$webview_app_version:R,$device:lrt(hy),$device_type:u4n(hy,U),$timezone:sat(),$timezone_offset:zBn()}),{$current_url:dV(y?AQ(sd?.href):sd?.href,Q,hV),$host:sd?.host,$pathname:sd?.pathname,$raw_user_agent:hy.length>1e3?hy.substring(0,997)+"...":hy,$browser_version:g4n(hy,navigator.vendor,F,O),$browser_language:nat(),$browser_language_prefix:VBn(),$screen_height:Fn?.screen.height,$screen_width:Fn?.screen.width,$viewport_height:Fn?.innerHeight,$viewport_width:Fn?.innerWidth,$lib:f8.LIB_NAME,$lib_version:f8.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return f8.SDK_DIST_CHANNEL&&(oe.$sdk_dist_channel=f8.SDK_DIST_CHANNEL),oe})(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){const{sessionId:f,windowId:I}=this.sessionManager.checkAndGetSessionAndWindowId(r,o.getTime(),!0);a.$session_id=f,a.$window_id=I}this.sessionPropsManager&&jg(a,this.sessionPropsManager.getSessionProps());try{var c;if(this.sessionRecording){const f=this.sessionRecording.sdkDebugProperties,I=!this.Au&&Wat(e);for(const C in f)(I||as(E9n,C))&&(a[C]=f[C])}a.$sdk_debug_retry_queue_size=(c=this.zu)===null||c===void 0?void 0:c.length}catch(f){a.$sdk_debug_error_capturing_properties=String(f)}let l;if(this.requestRouter.region===J2e&&(a.$lib_custom_api_host=this.config.api_host),l=e!=="$pageview"||r?e!=="$pageleave"||r?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(o):this.pageViewManager.doPageView(o,i),a=jg(a,l),e==="$pageview"&&No&&(a.title=No.title),!Eo(s)){const f=o.getTime()-s;a.$duration=parseFloat((f/1e3).toFixed(3))}hy&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser");const g=this.persistence.properties(),u=this.sessionPersistence.properties(),h=a.$groups,d=g.$groups;xA(h)&&!ox(h)&&(a.$groups=sn(sn({},xA(d)?d:{}),h)),vl(["$referrer","$referring_domain"],f=>{f in g&&delete u[f]});const p={};if(this.Ru.length>0)for(const f of this.Ru.slice())try{jg(p,f())}catch(I){gi.error("Failed to produce browser extension event properties",I)}a=jg({},A,g,u,sn(sn({},p),a)),a.$is_identified=this._isIdentified(),As(this.config.property_denylist)?vl(this.config.property_denylist,function(f){delete a[f]}):gi.error(Jat+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const m=this.config.sanitize_properties;m&&(gi.error(zat),a=m(a,e));const _=this._h();return a.$process_person_profile=_,_&&!r&&this.wh("_calculate_event_properties"),a}mh(e,n=!0,o=!1){var i;if(!this.persistence||!this._h()||this.Mu&&!o)return e;const r=this.persistence.get_initial_props(),s=(i=this.sessionPropsManager)===null||i===void 0?void 0:i.getSetOnceProps();let a=jg({},r,s||{},e||{});const A=this.config.sanitize_properties;return A&&(gi.error(zat),a=A(a,"$set_once")),n&&(this.Mu=!0),ox(a)?void 0:a}register(e,n){var o;(o=this.persistence)===null||o===void 0||o.register(e,n)}register_once(e,n,o){var i;(i=this.persistence)===null||i===void 0||i.register_once(e,n,o)}register_for_session(e){var n,o;(n=this.persistence)===null||n===void 0||n.syncCookieProperties(),this.yh(),(o=this.sessionPersistence)===null||o===void 0||o.register(e),Object.keys(e).forEach(i=>this.Eu.add(i)),this.bh()}unregister(e){var n;(n=this.persistence)===null||n===void 0||n.unregister(e)}unregister_for_session(e){var n;(n=this.sessionPersistence)===null||n===void 0||n.unregister(e),this.Eu.delete(e),this.bh()}kh(e,n){this.register({[e]:n})}Uu(){this.Eu.forEach(e=>{var n;(n=this.sessionPersistence)===null||n===void 0||n.unregister(e)}),this.Eu.clear(),this.bh()}bh(){var e;if(!this.Pu)return;if(this.config.persistence==="memory"||!((e=this.sessionPersistence)===null||e===void 0)&&e.hi||!Z0.Et())return void Z0.Pt(this.Pu);const n=[];this.Eu.forEach(o=>n.push(o)),n.length>0?Z0.$t(this.Pu,n):Z0.Pt(this.Pu)}getFeatureFlag(e,n){var o;return(o=this.featureFlags)===null||o===void 0?void 0:o.getFeatureFlag(e,n)}getFeatureFlagPayload(e){var n;return(n=this.featureFlags)===null||n===void 0?void 0:n.getFeatureFlagPayload(e)}getFeatureFlagResult(e,n){var o;return(o=this.featureFlags)===null||o===void 0?void 0:o.getFeatureFlagResult(e,n)}getAllFeatureFlags(){var e,n;return(e=(n=this.featureFlags)===null||n===void 0?void 0:n.getAllFeatureFlags())!==null&&e!==void 0?e:[]}isFeatureEnabled(e,n){var o,i;return(o=(i=this.featureFlags)===null||i===void 0?void 0:i.isFeatureEnabled(e,n))!==null&&o!==void 0?o:n?.defaultValue}reloadFeatureFlags(){var e;(e=this.featureFlags)===null||e===void 0||e.reloadFeatureFlags()}updateFlags(e,n,o){var i;(i=this.featureFlags)===null||i===void 0||i.updateFlags(e,n,o)}updateEarlyAccessFeatureEnrollment(e,n,o){var i;(i=this.featureFlags)===null||i===void 0||i.updateEarlyAccessFeatureEnrollment(e,n,o)}getEarlyAccessFeatures(e,n=!1,o){var i;return(i=this.featureFlags)===null||i===void 0?void 0:i.getEarlyAccessFeatures(e,n,o)}on(e,n){return this.du.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:Vk}),()=>{})}onSessionId(e){var n,o;return(n=(o=this.sessionManager)===null||o===void 0?void 0:o.onSessionId(e))!==null&&n!==void 0?n:()=>{}}getSurveys(e,n=!1){this.surveys?this.surveys.getSurveys(e,n):e([],{isLoaded:!1,error:Vk})}getActiveMatchingSurveys(e,n=!1){this.surveys?this.surveys.getActiveMatchingSurveys(e,n):e([],{isLoaded:!1,error:Vk})}onActiveMatchingSurveysChanged(e){return this.surveys?this.surveys.onActiveMatchingSurveysChanged(e):(e([],{isLoaded:!1,error:Vk}),()=>{})}renderSurvey(e,n){var o;(o=this.surveys)===null||o===void 0||o.renderSurvey(e,n)}displaySurvey(e,n=m9n){var o;(o=this.surveys)===null||o===void 0||o.displaySurvey(e,n)}cancelPendingSurvey(e){var n;(n=this.surveys)===null||n===void 0||n.cancelPendingSurvey(e)}canRenderSurvey(e){var n,o;return(n=(o=this.surveys)===null||o===void 0?void 0:o.canRenderSurvey(e))!==null&&n!==void 0?n:{visible:!1,disabledReason:Vk}}canRenderSurveyAsync(e,n=!1){var o,i;return(o=(i=this.surveys)===null||i===void 0?void 0:i.canRenderSurveyAsync(e,n))!==null&&o!==void 0?o:Promise.resolve({visible:!1,disabledReason:Vk})}Sh(e){return!e||JK(e)?(gi.critical("Unique user id has not been set in posthog.identify"),!1):e==="$posthog_cookieless"?(gi.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())||(gi.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,o){if(!this.__loaded||!this.persistence)return gi.uninitializedWarning("posthog.identify");if(qd(e)&&(e=e.toString(),gi.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!this.Sh(e)||!this.wh("posthog.identify"))return;this.ku();const i=this.get_distinct_id(),r=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==i,s=this.yh(!1),a=this.persistence.Fa();let A=!1;try{const l=this.get_distinct_id();this.register({$user_id:e}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:l},""),e!==l&&e!==this.get_property("__alias")&&(this.unregister(Zte),this.register({distinct_id:e}));const g=(this.persistence.get_property("$user_state")||"anonymous")===y8,u=e!==l,h=!u&&g;if(u&&g){var c;const d=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:l};this.persistence.set_property(my,tne),this.setPersonPropertiesForFlags({$set:n||{},$set_once:o||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.Da(),this.capture("$identify",d,{$set:n||{},$set_once:o||{}})&&(this.Lu=z2e(e,n,o)),(c=this.featureFlags)===null||c===void 0||c.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:l)}else if(h){this.persistence.set_property(my,tne);const d=n||{},p=o||{};this.setPersonPropertiesForFlags({$set:d,$set_once:p},!1),this.config.cookieWinsOnConflict&&this.persistence.Da(),this.capture("$set",{$set:d,$set_once:p})&&(this.Lu=z2e(e,n,o))}else(n||o)&&this.setPersonProperties(n,o);u||r||s?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(uQ)):h&&(n||o)&&this.reloadFeatureFlags(),A=!0}finally{a&&this.persistence.qa(A)}}setPersonProperties(e,n){if(!e&&!n||!this.wh("posthog.setPersonProperties"))return;const o=z2e(this.get_distinct_id(),e,n);this.Lu!==o?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:n||{}},!0),this.capture("$set",{$set:e||{},$set_once:n||{}})&&(this.Lu=o)):gi.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(e){var n;const o=(As(e)?e:[e]).filter(i=>nA(i)&&i.length>0);o.length!==0&&this.wh("posthog.unsetPersonProperties")&&((n=this.featureFlags)===null||n===void 0||n.unsetPersonPropertiesForFlags(o,!0),this.capture("$set",{$unset:o}),this.Lu=null)}group(e,n,o){var i;if(!e||!n)return void gi.error("posthog.group requires a group type and group key");(i=this.persistence)===null||i===void 0||i.syncCookieProperties(),this.yh();const r=this.getGroups(),s=r[e]!==n;if(s&&this.resetGroupPropertiesForFlags(e),this.register({$groups:sn(sn({},r),{},{[e]:n})}),(s||o)&&this._h()){const a={$group_type:e,$group_key:n};o&&(a.$group_set=o),this.capture(yst,a)}o&&this.setGroupPropertiesForFlags({[e]:o}),s&&!o&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,n=!0){var o;(o=this.featureFlags)===null||o===void 0||o.setPersonPropertiesForFlags(e,n)}resetPersonPropertiesForFlags(e=!0){var n;(n=this.featureFlags)===null||n===void 0||n.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,n=!0){var o;this.wh("posthog.setGroupPropertiesForFlags")&&((o=this.featureFlags)===null||o===void 0||o.setGroupPropertiesForFlags(e,n))}resetGroupPropertiesForFlags(e){var n;(n=this.featureFlags)===null||n===void 0||n.resetGroupPropertiesForFlags(e)}reset(e){const n=py(e)?e:e?.resetDeviceID,o=py(e)||e==null?void 0:e.bootstrap;this.xh(n,!1,o)}xh(e,n=!1,o){var i,r,s,a,A,c;if(gi.info("reset"),!this.__loaded)return gi.uninitializedWarning("posthog.reset");const l=o?.sessionID;this.config.bootstrap=o||((i=this.qu)===null||i===void 0?void 0:i.bootstrap)||{},(r=this.featureFlags)===null||r===void 0||(s=r.updateConfig)===null||s===void 0||s.call(r,this.config,this.il());const g=this.get_property($ye),u=this.get_property(Zye),h=this.get_property(ZK);(a=this.sessionRecording)===null||a===void 0||a.flushBeforeIdentityReset();const d=this.is_capturing();n||this.consent.reset(),n||!d||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");const p=(A=this.persistence)===null||A===void 0||(c=A.Fa)===null||c===void 0?void 0:c.call(A),m=this.Su;this.Su=m||n;let _=!1;try{var f,I,C,y,x,E,B,S,Q,w,M,k,R;if((f=this.persistence)===null||f===void 0||f.clear(),(I=this.sessionPersistence)===null||I===void 0||I.clear(),this.Eu.clear(),this.bh(),Eo(h)||(w=this.persistence)===null||w===void 0||w.register({$session_recording_remote_config:h}),(C=this.surveys)===null||C===void 0||C.reset(),(y=this.featureFlags)===null||y===void 0||y.reset(),(x=this.conversations)===null||x===void 0||x.reset(),(E=this.logs)===null||E===void 0||E.reset(),(B=this.metrics)===null||B===void 0||B.reset(),(S=this.persistence)===null||S===void 0||S.set_property("$user_state","anonymous"),(Q=this.sessionManager)===null||Q===void 0||Q.resetSessionId(),this.Lu=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:g2e,$device_id:null},"");else{const U=this.config.get_device_id(F4());this.register_once({distinct_id:U,$device_id:e?U:g},""),e||Eo(u)||this.register({[Zye]:u})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),o&&(o.distinctID&&!this.yu()&&((R=this.persistence)===null||R===void 0||R.set_property("$user_state",o.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:o.distinctID})),(M=this.featureFlags)===null||M===void 0||M.initialize(),!Fs(l)&&!(!((k=this.sessionManager)===null||k===void 0)&&k.setBootstrapSessionId(l,!0)))){const U=sn({},o);delete U.sessionID,this.config.bootstrap=U}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,_=!0}finally{var F,O;this.Su=m,p&&((F=this.persistence)===null||F===void 0||(O=F.qa)===null||O===void 0||O.call(F,_))}this.reloadFeatureFlags()}shutdown(e){var n=this;return Wg(function*(){var o,i,r,s,a,A,c,l;if(n.__loaded){n.Iu=!0,n.Zu().dispose(),(o=n.sessionRecording)===null||o===void 0||o.dispose(),(i=n.logs)===null||i===void 0||i.flushLogs("sendBeacon"),(r=n.metrics)===null||r===void 0||r.flush("sendBeacon"),(s=n.metrics)===null||s===void 0||s.dispose(),(a=n.Bu)===null||a===void 0||a.unload(),(A=n.zu)===null||A===void 0||A.unload();try{var g;(g=n.featureFlags)===null||g===void 0||g.destroy()}catch(u){gi.error("Error while destroying feature flags",u)}(c=n.persistence)===null||c===void 0||c.destroy(),(l=n.sessionPersistence)===null||l===void 0||l.destroy()}else gi.uninitializedWarning("posthog.shutdown")})()}setIdentity(e,n){var o;delete this.config.identity_claims,this.config.identity_distinct_id=e,this.config.identity_hash=n,this.alias(e),(o=this.conversations)===null||o===void 0||o.$h()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,(e=this.conversations)===null||e===void 0||e.Ch()}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||n===void 0?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";const{sessionId:n,sessionStartTimestamp:o}=this.sessionManager.checkAndGetSessionAndWindowId(!0);let i=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${n}`);if(e?.withTimestamp&&o){var r;const s=(r=e.timestampLookBack)!==null&&r!==void 0?r:10;if(!o)return i;i+=`?t=${Math.max(Math.floor((new Date().getTime()-o)/1e3)-s,0)}`}return i}alias(e,n){return e===this.get_property("$people_distinct_id")?(gi.critical("Attempting to create alias for existing People user - aborting."),-2):this.wh("posthog.alias")?(Eo(n)&&(n=this.get_distinct_id()),e!==n?(this.kh(Zte,e),this.capture("$create_alias",{alias:e,distinct_id:n})):(gi.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){const n=sn({},this.config);if(xA(e)){var o,i,r,s,a,A,c,l,g,u,h,d,p;jg(this.config,qat(e));const C=this.Cu();if(this.persistence){const x=this.config.persistence==="sessionStorage"||this.config.persistence==="memory";var m,_;if(x&&this.sessionPersistence!==this.persistence&&((m=this.sessionPersistence)===null||m===void 0||m.remove(),(_=this.sessionPersistence)===null||_===void 0||_.destroy()),this.persistence.update_config(this.config,n,C),x)this.sessionPersistence=this.persistence;else if(this.sessionPersistence===this.persistence)this.sessionPersistence=new D2e(sn(sn({},this.config),{},{persistence:"sessionStorage"}),C,!1);else{var f;(f=this.sessionPersistence)===null||f===void 0||f.update_config(sn(sn({},this.config),{},{persistence:"sessionStorage"}),sn(sn({},n),{},{persistence:"sessionStorage"}),C)}}const y=this.Nu(this.config.debug);var I;py(y)&&(this.config.debug=y),py(this.config.debug)&&(this.config.debug?(Ym.DEBUG=!0,uc.Et()&&uc.$t("ph_debug",!0),gi.info("set_config",{config:e,oldConfig:n,newConfig:sn({},this.config)})):(Ym.DEBUG=!1,uc.Et()&&uc.Pt("ph_debug"))),(o=this.featureFlags)===null||o===void 0||(i=o.updateConfig)===null||i===void 0||i.call(o,this.config,this.il()),(r=this.exceptionObserver)===null||r===void 0||r.onConfigChange(),(s=this.exceptions)===null||s===void 0||s.onConfigChange(),(a=this.metrics)===null||a===void 0||a.onConfigChange(),(A=this.sessionRecording)===null||A===void 0||A.startIfEnabledOrStop(),(c=this.tracingHeaders)===null||c===void 0||c.startIfEnabledOrStop(),(l=this.autocapture)===null||l===void 0||l.startIfEnabled(),(g=this.heatmaps)===null||g===void 0||g.startIfEnabled(),("capture_pageview"in e||"disable_capture_url_hashes"in e)&&((I=this.historyAutocapture)===null||I===void 0||I.startIfEnabledOrStop()),(u=this.exceptionObserver)===null||u===void 0||u.startIfEnabledOrStop(),(h=this.deadClicksAutocapture)===null||h===void 0||h.startIfEnabledOrStop(),(d=this.surveys)===null||d===void 0||d.loadIfEnabled(),this.xu(),(p=this.externalIntegrations)===null||p===void 0||p.startIfEnabledOrStop(),!n.segment&&this.config.segment&&this.persistence&&Jst(this,yV,!1)}}_overrideSDKInfo(e,n){Ym.LIB_NAME=e,Ym.LIB_VERSION=n}startSessionRecording(e){const n=e===!0,o={sampling:n||!!e?.sampling,linked_flag:n||!!e?.linked_flag,url_trigger:n||!!e?.url_trigger,event_trigger:n||!!e?.event_trigger};var i,r,s,a,A;Object.values(o).some(Boolean)&&((i=this.sessionManager)===null||i===void 0||i.checkAndGetSessionAndWindowId(),o.sampling&&((r=this.sessionRecording)===null||r===void 0||r.overrideSampling()),o.linked_flag&&((s=this.sessionRecording)===null||s===void 0||s.overrideLinkedFlag()),o.url_trigger&&((a=this.sessionRecording)===null||a===void 0||a.overrideTrigger("url")),o.event_trigger&&((A=this.sessionRecording)===null||A===void 0||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===void 0)&&e.started)}captureException(e,n){try{if(!this.exceptions)return;const o=this.exceptions.buildProperties(e,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(sn(sn({},o),n))}catch{return}}addExceptionStep(e,n){var o;(o=this.exceptions)===null||o===void 0||o.addExceptionStep(e,n)}captureLog(e){var n;(n=this.logs)===null||n===void 0||n.captureLog(e)}get logger(){var e,n;return(e=(n=this.logs)===null||n===void 0?void 0:n.logger)!==null&&e!==void 0?e:SM.Th}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var n,o;return(n=(o=this.toolbar)===null||o===void 0?void 0:o.loadToolbar(e))!==null&&n!==void 0&&n}get_property(e){var n;return(n=this.persistence)===null||n===void 0?void 0:n.props[e]}getSessionProperty(e){var n;return(n=this.sessionPersistence)===null||n===void 0?void 0:n.props[e]}toString(){var e;let n=(e=this.config.name)!==null&&e!==void 0?e:xV;return n!==xV&&(n="posthog."+n),n}_isIdentified(){var e,n;return((e=this.persistence)===null||e===void 0?void 0:e.get_property("$user_state"))==="identified"||((n=this.sessionPersistence)===null||n===void 0?void 0:n.get_property("$user_state"))==="identified"}_h(){var e,n;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&ox(this.getGroups())&&!(!((e=this.persistence)===null||e===void 0||(e=e.props)===null||e===void 0)&&e.__alias)&&!(!((n=this.persistence)===null||n===void 0||(n=n.props)===null||n===void 0)&&n.$epp))}sh(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&!!this.config.capture_pageview}createPersonProfile(){this._h()||this.wh("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.wh("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}wh(e){return this.config.person_profiles==="never"?(gi.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.bu(),this.kh(l2e,!0),!0)}Cu(){if(this.config.cookieless_mode==="always")return!0;const e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!=="on_reject")}xu(){var e,n;const o=this.Cu();var i,r,s;return this.is_capturing()||(i=this.logs)===null||i===void 0||i.Ih(),((e=this.persistence)===null||e===void 0?void 0:e.hi)!==o&&((r=this.persistence)===null||r===void 0||r.set_disabled(o)),((n=this.sessionPersistence)===null||n===void 0?void 0:n.hi)!==o&&((s=this.sessionPersistence)===null||s===void 0||s.set_disabled(o)),this.bh(),o}opt_in_capturing(e){var n;if(this.config.cookieless_mode!=="always"){if(this.yu()){var o,i,r,s,a,A;(o=this.sessionRecording)===null||o===void 0||o.dispose({discardBufferedEvents:!0}),this.xh(!0,!0),(i=this.sessionManager)===null||i===void 0||i.destroy(),(r=this.pageViewManager)===null||r===void 0||r.destroy(),this.sessionManager=new kat(this),this.pageViewManager=new Xst(this),this.persistence&&(this.sessionPropsManager=new Rat(this,this.sessionManager,this.persistence));const h=(s=(a=this.config.__extensionClasses)===null||a===void 0?void 0:a.sessionRecording)!==null&&s!==void 0?s:(A=SM.__defaultExtensionClasses)===null||A===void 0?void 0:A.sessionRecording;var c,l;h&&(this.sessionRecording=this.mu(this.sessionRecording,new h(this)),this.cu&&((c=this.sessionRecording)===null||c===void 0||(l=c.onRemoteConfig)===null||l===void 0||l.call(c,this.cu)))}var g,u;this.consent.optInOut(!0),this.xu(),this.eh(),(n=this.sessionRecording)===null||n===void 0||n.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&((g=this.surveys)===null||g===void 0||g.loadIfEnabled()),(Eo(e?.captureEventName)||e?.captureEventName)&&this.capture((u=e?.captureEventName)!==null&&u!==void 0?u:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.ih()}else gi.warn(Vat)}opt_out_capturing(){this.config.cookieless_mode!=="always"?(this.consent.optInOut(!1),this.xu(),this.config.cookieless_mode==="on_reject"&&this.$u()):gi.warn(Vat)}$u(){var e,n;const o=this.sessionRecording;o?.dispose({discardBufferedEvents:!0}),this.get_distinct_id()!=="$posthog_cookieless"&&this.xh(!0,!0),this.register({distinct_id:g2e,$device_id:null}),this.gu(o),this.sessionRecording=void 0,(e=this.sessionManager)===null||e===void 0||e.destroy(),(n=this.pageViewManager)===null||n===void 0||n.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.ih(),this.eh()}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){const e=this.consent.consent;return e===1?"granted":e===0?"denied":"pending"}is_capturing(){return!this.Su&&(this.config.cookieless_mode==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing()))}clear_opt_in_out_capturing(){this.consent.reset(),this.xu()}_is_bot(){return F_?Fat(F_,this.config.custom_blocked_useragents):void 0}ih(){No&&(No.visibilityState==="visible"?this.Ou||(this.Ou=!0,this.capture(p2e,{title:No.title},{send_instantly:!0}),this.Fu&&(No.removeEventListener(iV,this.Fu),this.Fu=null)):this.Fu||(this.Fu=this.ih.bind(this),jc(No,iV,this.Fu)))}debug(e){e===!1?(Fn?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(Fn?.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}))}il(){const e=this.qu||{};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?(gi.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,o,i,r,s){const a=o in n&&!Fs(n[o]),A=i in n&&!Fs(n[i]);return a?n[o]:!!A&&(s&&s.warn(`Config field '${i}' is deprecated. Please use '${o}' instead. The old field will be removed in a future major version.`),n[i])})(e,"advanced_disable_flags","advanced_disable_decide",0,gi)}Fs(e){var n;if(Fs(this.config.before_send))return e;const o=Object.keys((n=e.properties)!==null&&n!==void 0?n:{}).filter(e4n),i=As(this.config.before_send)?this.config.before_send:[this.config.before_send];let r=e;for(const s of i)try{if(r=s(r),Fs(r)){const a=`Event '${e.event}' was rejected in beforeSend function`;return Z5n(e.event)?gi.warn(`${a}. This can cause unexpected behavior.`):gi.info(a),null}r.properties&&!ox(r.properties)||gi.warn(`Event '${e.event}' has no properties after beforeSend function, this is likely an error.`)}catch(a){return gi.error(`Error in beforeSend function for event '${e.event}':`,a),null}for(const s of o)if(r.properties&&Fs(r.properties[s]))return gi.warn(`Event '${e.event}' had its '${s}' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return r}getPageViewId(){var e;return(e=this.pageViewManager.Wo)===null||e===void 0?void 0:e.pageViewId}captureTraceFeedback(e,n){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:n})}captureTraceMetric(e,n,o){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:n,$ai_metric_value:String(o)})}Nu(e){const n=py(e)&&!e,o=uc.Et()&&uc.Ot("ph_debug")==="true";return!n&&(!!o||e)}};EV.__defaultExtensionClasses={},EV.Th=(()=>{const t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),(function(t,e){for(let n=0;e.length>n;n++)t.prototype[e[n]]=xBn(t.prototype[e[n]])})(EV,["identify"]);var $at=class{constructor(e){this.disabled=e===!1;const n=xA(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,o){if(this.disabled)return!1;const i=this.clicks[this.clicks.length-1];if(i&&Math.abs(e-i.x)+Math.abs(n-i.y)<this.thresholdPx&&this.timeoutMs>o-i.timestamp){if(this.clicks.push({x:e,y:n,timestamp:o}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:n,timestamp:o}];return!1}};const X2e="$copy_autocapture",q2e=Ad("[AutoCapture]");function $2e(t,e){return e.length>t?e.slice(0,t)+"...":e}function P9n(t){if(t.previousElementSibling)return t.previousElementSibling;let e=t;do e=e.previousSibling;while(e&&!b9(e));return e}function M9n(t,{e,maskAllElementAttributes:n,maskAllText:o,elementAttributeIgnoreList:i,elementsChainAsString:r,disableCaptureUrlHashes:s}){var a,A;if(!b9(t))return{props:{}};const c=[t],l=new Set([t]);let g=t;for(;g.parentNode&&!j1(g,"body")&&1e3>c.length;){if(B2e(g.parentNode)){const x=g.parentNode.host;if(l.has(x))break;l.add(x),c.push(x),g=x;continue}if(!b9(g.parentNode)||l.has(g.parentNode))break;l.add(g.parentNode),c.push(g.parentNode),g=g.parentNode}const u=e.type==="click"&&t.namespaceURI==="http://www.w3.org/2000/svg"?c.findIndex(x=>j1(x,"button")||j1(x,"a")):-1;u>0&&(o=o||c.slice(0,u+1).some(x=>!Fk(x)||cV(x)));const h=[],d={};let p,m=!1,_=!1;if(vl(c,x=>{const E=Fk(x);if(j1(x,"a")&&!n&&!i?.includes("href")){const B=x.getAttribute("href");m=!!(E&&B&&lV(B))&&(s?AQ(B):B)}as(kk(x),"ph-no-capture")&&(_=!0),h.push((function(B,S,Q,w,M=!1){const k=B.tagName.toLowerCase(),R={tag_name:k};S2e.indexOf(k)>-1&&!Q&&(R.$el_text=k.toLowerCase()==="a"||k.toLowerCase()==="button"?$2e(1024,Ust(B)):$2e(1024,aV(B)));const F=kk(B);S||w?.includes("class")||0>=F.length||(R.classes=F.filter(function(J){return J!==""})),vl(B.attributes,function(J){var ee;if((!cV(B)||["name","id","class","aria-label"].indexOf(J.name)!==-1)&&!w?.includes(J.name)&&!S&&lV(J.value)&&(!nA(ee=J.name)||ee.substring(0,10)!=="_ngcontent"&&ee.substring(0,7)!=="_nghost")){let W=J.value;J.name==="class"&&(W=b2e(W).join(" ")),R["attr__"+J.name]=$2e(1024,J.name==="href"&&M?AQ(W):W)}});let O=1,U=1,Y=B;for(;Y=P9n(Y);)O++,Y.tagName===B.tagName&&U++;return R.nth_child=O,R.nth_of_type=U,R})(x,n,o,i,s)),vl((function(B){if(!Fk(B))return{};const S={};return vl(B.attributes,function(Q){if(Q.name&&Q.name.indexOf("data-ph-capture-attribute")===0){const w=Q.name.replace("data-ph-capture-attribute-",""),M=Q.value;w&&M&&lV(M)&&(S[w]=M)}}),S})(x),(B,S)=>{({}).hasOwnProperty.call(d,S)||(d[S]=B)})}),_)return{props:{},explicitNoCapture:_};if(u>0&&(t=c[u],h.splice(0,u)),o||(h[0].$el_text=j1(t,"a")||j1(t,"button")?Ust(t):aV(t)),m){var f,I;h[0].attr__href=m;const x=(f=x8(m))===null||f===void 0?void 0:f.host,E=Fn==null||(I=Fn.location)===null||I===void 0?void 0:I.host;x&&E&&x!==E&&(p=m)}return{props:jg((y=e.type,{$event_type:y,$ce_version:1}),r?{}:{$elements:h},{$elements_chain:(C=h,As(C)?(function(x){return x.map(E=>{var B,S;let Q="";if(E.tag_name&&(Q+=E.tag_name),E.attr_class){E.attr_class.sort();for(const k of E.attr_class)Q+=`.${k.replace(/"/g,"")}`}const w=sn(sn(sn(sn({},E.text?{text:E.text}:{}),{},{"nth-child":(B=E.nth_child)!==null&&B!==void 0?B:0,"nth-of-type":(S=E.nth_of_type)!==null&&S!==void 0?S:0},E.href?{href:E.href}:{}),E.attr_id?{attr_id:E.attr_id}:{}),E.attributes),M={};return one(w).sort(([k],[R])=>(function(F,O){return O>F?-1:F>O?1:0})(k,R)).forEach(([k,R])=>M[Vst(k.toString())]=Vst(R.toString())),Q+=":",Q+=one(M).map(([k,R])=>`${k}="${R}"`).join(""),Q}).join(";")})((function(x){return x.map(E=>{var B,S;const Q={text:(B=E.$el_text)===null||B===void 0?void 0:B.slice(0,400),tag_name:E.tag_name,href:(S=E.attr__href)===null||S===void 0?void 0:S.slice(0,2048),attr_class:FBn(E),attr_id:E.attr__id,nth_child:E.nth_child,nth_of_type:E.nth_of_type,attributes:{}};return one(E).filter(([w])=>w.indexOf("attr__")===0).forEach(([w,M])=>Q.attributes[w]=M),Q})})(C)):"")},!((a=h[0])===null||a===void 0)&&a.$el_text?{$el_text:(A=h[0])===null||A===void 0?void 0:A.$el_text}:{},p&&e.type==="click"?{$external_click_url:p}:{},d),target:t};var C,y}var D9n=class{do(){this.vo=void 0,clearTimeout(this.fo),this.fo=void 0}po(e){var n;if(!Fk(e))return!0;const o=(n=this.mo().css_selector_ignorelist)!==null&&n!==void 0?n:w2e,i=new Set;let r=e;for(;r;){if(i.size>=1e3||i.has(r))return!0;i.add(r);const s=r,a=kk(s);if(as(a,"ph-no-capture")||as(a,"ph-sensitive")||cV(s)||o.some(c=>Q2e(s,c)))return!0;const A=r.parentNode;r=B2e(A)?A.host:A&&b9(A)?A:null}return!1}yo(e){if(!this.isEnabled||e.type==="pointercancel")return void this.do();if(e.type==="pointerdown"){this.do();const i=AV(e);var n;return void(e.isPrimary&&e.button===0&&!e.ctrlKey&&i&&b9(i)&&(this.vo={target:i,excluded:this.po(i),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:(n=this.bo)===null||n===void 0?void 0:n.distinctId}))}const o=this.vo;o&&(e.pointerId!==o.id||Math.abs(e.clientX-o.x)>5||Math.abs(e.clientY-o.y)>5?this.do():e.type==="pointerup"&&(o.released=!0,this.fo=setTimeout(()=>this.do(),0)))}_o(e){var n;const o=this.vo;this.do();const i=AV(e);if(o?.released&&o.target.isConnected&&o.distinctId===((n=this.bo)===null||n===void 0?void 0:n.distinctId)&&e.pointerId===o.id&&(e.detail>0||e.pointerType==="touch"||e.pointerType==="pen")&&e.button===0&&5>=Math.abs(e.clientX-o.x)&&5>=Math.abs(e.clientY-o.y)&&i&&(j1(i,"html")||j1(i,"body"))){var r;if(o.excluded)return null;const s=(r=this.mo().css_selector_ignorelist)!==null&&r!==void 0?r:w2e;return[i,No?.documentElement,No?.body].some(a=>{if(!a)return!1;const A=kk(a);return as(A,"ph-no-capture")||as(A,"ph-sensitive")||!Fk(a)||cV(a)||s.some(c=>Q2e(a,c))})?null:o.target}}constructor(e){this.wo=e,this.name="autocapture",this.ko=!1,this.So=null,this.xo=!1,this.$o=new Map,this.Co=!1,this.Mr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.To=!1,this.wo.refresh(this.Mr),this.rageclicks=new $at(this.Mr.rageclick),this.Io=null}setup(e){this.Mo(),this.bo=e;const n=e.onRemoteConfig(this.onRemoteConfig.bind(this));this.To?n.dispose():(this.Eo=n,this.startIfEnabled())}dispose(){var e;this.To||(this.To=!0,this.bo=void 0,(e=this.Eo)===null||e===void 0||e.dispose(),this.Eo=void 0,this.$o.clear(),this.Io=null,this.Po())}mo(){return this.wo.refresh(this.Mr),this.Mr}Mo(){var e,n;return this.mo(),this.Mr.url_allowlist=(e=this.Mr.url_allowlist)===null||e===void 0?void 0:e.map(o=>new RegExp(o)),this.Mr.url_ignorelist=(n=this.Mr.url_ignorelist)===null||n===void 0?void 0:n.map(o=>new RegExp(o)),this.Mr}Ro(){if(!this.isBrowserSupported())return void q2e.info("Disabling Automatic Event Collection because this browser is not supported");if(!Fn||!No)return;const e=this.Ao=n=>{n=n||Fn?.event;try{if(n.type==="blur")return void this.do();if(n.type.indexOf("pointer")===0)return void this.yo(n);const o=n.type==="click"?this._o(n):void 0;if(ad(o))return;this.Oo(n,"$autocapture",o)}catch(o){q2e.error("Failed to capture event",o)}};if(jc(Fn,"blur",e),jc(No,"submit",e,{capture:!0}),jc(No,"change",e,{capture:!0}),jc(No,"click",e,{capture:!0}),vl(["pointerdown","pointermove","pointerup","pointercancel"],n=>{jc(No,n,e,{capture:!0})}),this.mo().capture_copied_text){const n=this.Fo=o=>{o=o||Fn?.event;try{this.Oo(o,X2e)}catch(i){q2e.error("Failed to capture clipboard event",i)}};jc(No,"copy",n,{capture:!0}),jc(No,"cut",n,{capture:!0}),jc(No,"paste",n,{capture:!0})}}Po(){this.do(),this.Ao&&(Fn?.removeEventListener("blur",this.Ao),vl(["pointerdown","pointermove","pointerup","pointercancel"],e=>{No?.removeEventListener(e,this.Ao,!0)}),No?.removeEventListener("submit",this.Ao,!0),No?.removeEventListener("change",this.Ao,!0),No?.removeEventListener("click",this.Ao,!0),this.Ao=void 0),this.Fo&&(No?.removeEventListener("copy",this.Fo,!0),No?.removeEventListener("cut",this.Fo,!0),No?.removeEventListener("paste",this.Fo,!0),this.Fo=void 0),this.ko=!1}startIfEnabled(){this.isEnabled||this.do(),!this.To&&this.bo&&this.isEnabled&&!this.ko&&(this.Ro(),this.ko=!0)}onRemoteConfig(e){if(this.To)return;if(this.xo=!0,!e.ok)return void this.startIfEnabled();const n=e.config;n.elementsChainAsString&&(this.Co=n.elementsChainAsString);const o=n.autocapture_opt_out;var i;py(o)&&((i=this.bo)===null||i===void 0||i.kv.set("$autocapture_disabled_server_side",o),this.So=o),this.startIfEnabled()}setElementSelectors(e,n=this){if(this.To)return;e.size?this.$o.set(n,new Set(e)):this.$o.delete(n);const o=new Set;this.$o.forEach(i=>{i.forEach(r=>o.add(r))}),this.Io=o}getElementSelectors(e,n){var o;const i=[];return(o=this.Io)===null||o===void 0||o.forEach(r=>{const s=No?.querySelectorAll(r);s?.forEach(a=>{e!==a&&n!==a||as(i,r)||i.push(r)})}),i}get isEnabled(){var e,n;if(this.To)return!1;const o=(e=this.bo)===null||e===void 0?void 0:e.kv.get(qrt),i=this.So,r=this.mo();if(!r.remoteRequestsDisabled&&!this.xo)return!1;const s=r.remoteRequestsDisabled&&!this.xo;if(ad(i)&&!py(o)&&!s)return!1;const a=(n=this.So)!==null&&n!==void 0?n:!!o;return!!r.enabled&&!a}Oo(e,n="$autocapture",o){if(!this.isEnabled)return void this.do();let i=o||AV(e);Pst(i)&&(i=i.parentNode||null);const r=this.Mo();var s;n==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&r.rageclick&&(!((s=this.rageclicks)===null||s===void 0)&&s.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime()))&&Fst(i,r.rageclick)&&this.Oo(e,"$rageclick",o);const a=n===X2e,A=a?sn(sn({},r),{},{dom_event_allowlist:void 0}):r;if(i&&(function(u,h,d,p,m,_){var f;if(!Fn||P2e(u)||d?.url_allowlist&&!Mst(d.url_allowlist,_)||d?.url_ignorelist&&Mst(d.url_ignorelist,_))return!1;if(d?.dom_event_allowlist){const x=d.dom_event_allowlist;if(x&&!x.some(E=>h.type===E))return!1}const{parentIsUsefulElement:I,targetElementList:C}=Lst(u,p);if(!(function(x,E){const B=E?.element_allowlist;if(Eo(B))return!0;for(const S of x)if(B.some(Q=>S.tagName.toLowerCase()===Q))return!0;return!1})(C,d)||!v2e(C,d?.css_selector_allowlist)||v2e(C,(f=d?.css_selector_ignorelist)!==null&&f!==void 0?f:w2e))return!1;try{const x=Fn.getComputedStyle(u);if(x&&x.getPropertyValue("cursor")==="pointer"&&h.type==="click")return!0}catch{}const y=u.tagName.toLowerCase();switch(y){case"html":return!1;case"form":return(m||["submit"]).indexOf(h.type)>=0;case"input":case"select":case"textarea":return(m||["change","click"]).indexOf(h.type)>=0;default:return I?(m||["click"]).indexOf(h.type)>=0:(m||["click"]).indexOf(h.type)>=0&&(S2e.indexOf(y)>-1||u.getAttribute("contenteditable")==="true")}})(i,e,A,a,a?["copy","cut","paste"]:void 0,{config:{get_current_url:r.getCurrentUrl}})){var c;const{props:u,explicitNoCapture:h,target:d}=M9n(i,{e,maskAllElementAttributes:r.maskAllElementAttributes,maskAllText:r.maskAllText,elementAttributeIgnoreList:r.element_attribute_ignorelist,elementsChainAsString:this.Co,disableCaptureUrlHashes:r.disableCaptureUrlHashes});if(h)return!1;const p=this.getElementSelectors(i,d);if(p&&p.length>0&&(u.$element_selectors=p),n===X2e){const m=e.type||"clipboard";if(m!=="paste"){var l,g;const _=Fn==null||(l=Fn.getSelection())===null||l===void 0?void 0:l.toString(),f=Dst(_);if(!f)return!1;u.$selected_content=f,u.$clipboard_text_length=(g=_?.length)!==null&&g!==void 0?g:0}u.$copy_type=m}return(c=this.bo)===null||c===void 0||c.capture(n,u),!0}}isBrowserSupported(){return L_(No?.querySelectorAll)}},N9n=class{constructor(e){this._instance=e}refresh(e){const n=this._instance.config,o=xA(n.autocapture)?n.autocapture:void 0;e.enabled=!!n.autocapture,e.rageclick=n.rageclick,e.maskAllElementAttributes=n.mask_all_element_attributes,e.maskAllText=n.mask_all_text,e.disableCaptureUrlHashes=n.disable_capture_url_hashes,e.getCurrentUrl=n.get_current_url,e.remoteRequestsDisabled=this._instance.il(),e.url_allowlist=o?.url_allowlist,e.url_ignorelist=o?.url_ignorelist,e.dom_event_allowlist=o?.dom_event_allowlist,e.element_allowlist=o?.element_allowlist,e.css_selector_allowlist=o?.css_selector_allowlist,e.css_selector_ignorelist=o?.css_selector_ignorelist,e.element_attribute_ignorelist=o?.element_attribute_ignorelist,e.capture_copied_text=o?.capture_copied_text}};const BV=Ad("[ExceptionAutocapture]"),Zat=()=>{},eAt=t=>{var e;if(L_(t))return(e=t.__posthog_layer__)!==null&&e!==void 0?e:t.__rrweb_layer__};function bV(t,e,n){try{if(!(e in t))return Zat;const o={next:t[e]},i=n(function(...r){return o.next.apply(this,r)});return L_(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:o}})),t[e]=i,()=>{if(t[e]===i)return void(t[e]=o.next);let r=t[e],s=eAt(r);for(;s;){if(s.next===i)return void(s.next=o.next);r=s.next,s=eAt(r)}}}catch{return Zat}}const R9n=Ad("[TracingHeaders]"),HM=Ad("[Web Vitals]"),tAt=9e5,nAt=["CLS","FCP","INP","LCP"],T9n=["INP","LCP"],k9n=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Z2e="disabled",oAt="lazy_loading",b8=Ad("[SessionRecording]"),F9n=[u2e,d2e,gst,ust,dst,hst,pst,mst,_st],L9n=Ad("[Heatmaps]");function exe(t){return xA(t)&&"clientX"in t&&"clientY"in t&&qd(t.clientX)&&qd(t.clientY)}const mne=Ad("[Product Tours]"),txe=t=>{var e;return!t.config.disable_product_tours&&!!(!((e=t.persistence)===null||e===void 0)&&e.get_property(s2e))},H9n=["$set_once","$set"],S9=Ad("[SiteApps]"),iAt="Error while initializing PostHog app with config id ",rAt=(t,e)=>t?.then?t.then(e):e(t),zk="SDK is not enabled or survey functionality is not yet loaded",sAt="Disabled. Not loading surveys.";var O9n=class{constructor(e,n){this.wo=e,this.Mh=n,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Eh=!1,this.Ph=!1,this.Rh=[],this.Ah=[],this.Oh=null,this.Fh=null,this.To=!1,this.Dh=new Set,this.onRemoteConfig=o=>{if(this.To||this.Mr.disableSurveys)return;if(!o.ok)return this.Ph=!0,this.Lh({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),_l.warn("Remote config unavailable. Not loading surveys.");const i=o.config.surveys;if(Fs(i))return _l.warn("Flags not loaded yet. Not loading surveys.");this.Nh=py(i)?i:i.length>0,_l.info(`flags response received, isSurveysEnabled: ${this.Nh}`),this.loadIfEnabled()},this.Lh=o=>{this.Ah.slice().forEach(i=>this.qh(i,o))}}setup(e){if(!this.To)return this.jh=e,rAt(e.kv.initialize(),()=>{if(this.jh!==e||this.To)return;this.jh=void 0,this.bo=e;const n=e.onRemoteConfig(this.onRemoteConfig);this.To?n.dispose():(this.Eo=n,this.loadIfEnabled())})}dispose(){var e,n,o,i,r;this.To||(this.To=!0,this.jh=void 0,this.bo=void 0,(e=this.Eo)===null||e===void 0||e.dispose(),this.Eo=void 0,(n=this._surveyEventReceiver)===null||n===void 0||n.dispose(),this._surveyEventReceiver=null,(o=this._surveyManager)===null||o===void 0||(i=o.dispose)===null||i===void 0||i.call(o),this._surveyManager=null,this.Rh=[],this.Ah.forEach(s=>{s.active=!1}),this.Ah=[],(r=this.Bh)===null||r===void 0||r.call(this),this.Bh=void 0,this.Oh=null,this.Dh.forEach(s=>clearTimeout(s)),this.Dh.clear())}get Mr(){return this.wo.get()}initialize(){this.loadIfEnabled()}reset(){var e,n;(e=this._surveyManager)===null||e===void 0||(n=e.clearInMemoryInProgressSurveyState)===null||n===void 0||n.call(e);try{var o;(o=this._surveyEventReceiver)===null||o===void 0||o.reset(),localStorage.removeItem("lastSeenSurveyDate");const i=[];for(let r=0;r<localStorage.length;r++){const s=localStorage.key(r);(s?.startsWith("seenSurvey_")||s?.startsWith("inProgressSurvey_"))&&i.push(s)}i.forEach(r=>localStorage.removeItem(r))}catch{}this.Lh()}loadIfEnabled(){if(this.To||!this.bo)return;const e=this.Mr;if(this._surveyManager)return;if(this.Eh)return void _l.info("Already initializing surveys, skipping...");if(e.disableSurveys)return void _l.info(sAt);if(e.cookielessMode&&this.wo.isOptedOut())return void _l.info("Not loading surveys in cookieless mode without consent.");const n=this.wo.getExtensions();if(!n)return void this.Hh("PostHog Extensions not found.");if(Eo(this.Nh)&&!e.advancedEnableSurveys)return;const o=this.Nh||e.advancedEnableSurveys;this.Eh=!0,this.Ph=!1;try{const i=n.generateSurveys;if(i)return this.zh(i,o),void(this.Eh=!1);const r=n.loadExternalDependency;if(!r)return this.Hh(h2e),void(this.Eh=!1);r(s=>{try{if(this.To)return;const a=this.wo.getExtensions();s||!a?.generateSurveys?this.Hh("Could not load surveys script",s):this.zh(a.generateSurveys,o)}finally{this.Eh=!1}})}catch(i){throw this.Eh=!1,this.Hh("Error initializing surveys",i),i}}zh(e,n){var o,i;if(this.To)return;this._surveyManager=e(n),this._surveyEventReceiver=this.wo.createEventReceiver(this.Lh);const r=(o=(i=this.bo)!==null&&i!==void 0?i:this.Mh)===null||o===void 0?void 0:o.kv.get(tV);r&&this.Uh(r),_l.info("Surveys loaded successfully"),this.Wh(),this.Lh(),this.Vh({isLoaded:!0})}Hh(e,n){this.Ph=!0,_l.error(e,n),this.Lh({isLoaded:!1,error:e}),this.Vh({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.Rh.push(e),this._surveyManager&&this.Vh({isLoaded:!0}),()=>{this.Rh=this.Rh.filter(n=>n!==e)}}getSurveys(e,n=!1){var o;const i=(o=this.bo)!==null&&o!==void 0?o:this.Mh;if(!i||this.To)return;if(this.Mr.disableSurveys)return _l.info(sAt),e([]);const r=i.kv.get(tV);if(r&&!n)return e(r,{isLoaded:!0}),void(this.Gh()&&this.getSurveys(()=>{},!0));if(this.Oh)return void this.Oh.then(({surveys:A,context:c})=>{this.To||e(A,c)}).catch(A=>_l.error("Error in survey callback",A));const s=this.Qh("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.Mr.requestTimeoutMs}).then(A=>{try{return this.Jh(i,A)}catch(c){return _l.error("Error processing surveys response",c),this.Jh(i,{statusCode:0,error:c})}},A=>this.Jh(i,{statusCode:0,error:A}));this.Oh=s;const a=()=>{this.Oh===s&&(this.Oh=null)};s.then(A=>{a(),this.To||(this.Lh(A.context),e(A.surveys,A.context))},a).catch(A=>_l.error("Error in survey callback",A))}Qh(e,n){const o=this.bo;return o?o.sendRequest(e,n):new Promise(i=>i({statusCode:0,error:new Error(zk)}))}Jh(e,n){if(this.To)return{surveys:[],context:{isLoaded:!1,error:zk}};const o=n.statusCode;if(o!==200||!n.json){const r=`Surveys API could not be loaded, status: ${o}`;return o!==0?_l.error(r):n.error||_l.warn(r),this.Fh=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Fh=null;const i=n.json.surveys||[];return e.kv.set({[tV]:i,[ene]:Date.now()}),this.Uh(i),{surveys:i,context:{isLoaded:!0}}}Uh(e){var n;const o=e.filter(i=>(function(r){return!(!r.start_date||r.end_date)})(i)&&(Hat(i)||(function(r){var s;return!!(!((s=r.conditions)===null||s===void 0||(s=s.actions)===null||s===void 0||(s=s.values)===null||s===void 0)&&s.length)})(i)));(n=this._surveyEventReceiver)===null||n===void 0||n.replace(o)}Gh(){return this.Zh()&&!this.Oh&&!this.Kh()}Zh(){var e,n;const o=(e=(n=this.bo)!==null&&n!==void 0?n:this.Mh)===null||e===void 0?void 0:e.kv.get(ene);return qd(o)&&Date.now()-o>3e5}Kh(){return qd(this.Fh)&&3e5>Date.now()-this.Fh}markSurveyAsSeen(e,n){var o;const i={id:e,current_iteration:(o=n?.iteration)!==null&&o!==void 0?o:null};Uat(i);try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}this.Lh()}Vh(e){for(const n of this.Rh)try{if(!e.isLoaded)return n([],e);this.getSurveys(n)}catch(o){_l.error("Error in survey callback",o)}}getActiveMatchingSurveys(e,n=!1){if(!Fs(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,n);_l.warn("init was not called")}onActiveMatchingSurveysChanged(e){var n,o;if(this.To)return()=>{};const i={callback:e,active:!0,revision:0};this.Ah.push(i),this.Wh();const r=(n=(o=this.bo)!==null&&o!==void 0?o:this.Mh)===null||n===void 0?void 0:n.kv.get(tV);return this.Mr.disableSurveys||!this._surveyManager&&this.Ph&&!this.Eh||!r&&!Fs(this.Fh)&&!this.Oh?this.qh(i,{isLoaded:!1}):this._surveyManager&&this.qh(i),()=>{var s;i.active=!1,this.Ah=this.Ah.filter(a=>a!==i),this.Ah.length===0&&((s=this.Bh)===null||s===void 0||s.call(this),this.Bh=void 0)}}Wh(){var e,n,o;this._surveyManager&&this.Ah.length>0&&((e=this.Bh)!==null&&e!==void 0||(this.Bh=(n=(o=this.wo).onMatchingConditionsChanged)===null||n===void 0?void 0:n.call(o,this.Lh)))}qh(e,n){if(this.To||!e.active)return;const o=++e.revision,i=r=>{if(!this.To&&e.active&&o===e.revision)try{const s=n??{isLoaded:!0},a=JSON.stringify([r,s]);if(a===e.lastResult)return;e.lastResult=a,e.callback(r,s)}catch(s){_l.error("Error in active matching surveys callback",s)}};try{n&&!n.isLoaded?i([]):this.getActiveMatchingSurveys(i)}catch(r){_l.error("Error in active matching surveys callback",r)}}Xh(e){let n=null;return this.getSurveys(o=>{var i;n=(i=o.find(r=>r.id===e))!==null&&i!==void 0?i:null}),n}Yh(e){if(Fs(this._surveyManager))return{eligible:!1,reason:zk};const n=typeof e=="string"?this.Xh(e):e;return n?this._surveyManager.checkSurveyEligibility(n):{eligible:!1,reason:"Survey not found"}}tc(e){if(!this.wo.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(Fs(this._surveyManager))return{eligible:!1,reason:zk};const n=typeof e=="string"?this.Xh(e):e;return n?this._surveyManager.checkSurveyRenderability(n):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(Fs(this._surveyManager))return _l.warn("init was not called"),{visible:!1,disabledReason:zk};const n=this.tc(e);return{visible:n.eligible,disabledReason:n.reason}}canRenderSurveyAsync(e,n){return Fs(this._surveyManager)?(_l.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:zk})):new Promise(o=>{this.getSurveys(i=>{var r;const s=(r=i.find(a=>a.id===e))!==null&&r!==void 0?r:null;if(s){const a=this.tc(s);o({visible:a.eligible,disabledReason:a.reason})}else o({visible:!1,disabledReason:"Survey not found"})},n)})}renderSurvey(e,n,o){var i;if(!this.wo.isCapturing())return;if(Fs(this._surveyManager))return void _l.warn("init was not called");const r=typeof e=="string"?this.Xh(e):e;if(!r?.id)return void _l.warn("Survey not found");if(!p9n.includes(r.type))return void _l.warn(`Surveys of type ${r.type} cannot be rendered in the app`);const s=No?.querySelector(n);if(s){if(!((i=r.appearance)===null||i===void 0)&&i.surveyPopupDelaySeconds){_l.info(`Rendering survey ${r.id} with delay of ${r.appearance.surveyPopupDelaySeconds} seconds`);const a=setTimeout(()=>{var A,c;this.Dh.delete(a),!this.To&&this.wo.isCapturing()&&(_l.info(`Rendering survey ${r.id} with delay of ${(A=r.appearance)===null||A===void 0?void 0:A.surveyPopupDelaySeconds} seconds`),(c=this._surveyManager)===null||c===void 0||c.renderSurvey(r,s,o),_l.info(`Survey ${r.id} rendered`))},1e3*r.appearance.surveyPopupDelaySeconds);return void this.Dh.add(a)}this._surveyManager.renderSurvey(r,s,o)}else _l.warn("Survey element not found")}displaySurvey(e,n){var o;if(!this.wo.isCapturing())return;if(Fs(this._surveyManager))return void _l.warn("init was not called");const i=this.Xh(e);if(!i)return void _l.warn("Survey not found");let r=i;if(!((o=i.appearance)===null||o===void 0)&&o.surveyPopupDelaySeconds&&n.ignoreDelay&&(r=sn(sn({},i),{},{appearance:sn(sn({},i.appearance),{},{surveyPopupDelaySeconds:0})})),n.displayType!==T2e.Popover&&n.initialResponses&&_l.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),n.ignoreConditions===!1){const s=this.Yh(i);if(!s.eligible)return void _l.warn("Survey is not eligible to be displayed: ",s.reason)}n.displayType!==T2e.Inline?this._surveyManager.handlePopoverSurvey(r,n):this.renderSurvey(r,n.selector,n.properties)}cancelPendingSurvey(e){Fs(this._surveyManager)?_l.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e,n;(e=this._surveyManager)===null||e===void 0||(n=e.handlePageUnload)===null||n===void 0||n.call(e)}};function Jk(t,e,n){if(Fs(t))return!1;switch(n){case"exact":return t===e;case"contains":{const o=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(o,"i").test(t)}case"regex":try{return new RegExp(e).test(t)}catch{return!1}default:return!1}}var G9n=class{constructor(e){this._instance=e,this.ec=new Set,this.nc=new Set,this.sc=new dne,this.rc=(n,o)=>this.oc(n,o)&&this.ac(n,o)&&this.lc(n,o)&&this.uc(n,o),this.oc=(n,o)=>!o?.event||n?.event===o?.event}init(){var e,n;Eo((e=this._instance)===null||e===void 0?void 0:e._addCaptureHook)||(this.hc=(n=this._instance)===null||n===void 0?void 0:n._addCaptureHook((o,i)=>{this.on(o,i)}))}dispose(){var e,n;(e=this.hc)===null||e===void 0||e.call(this),this.hc=void 0,(n=this._instance)===null||n===void 0||(n=n.autocapture)===null||n===void 0||n.setElementSelectors(new Set,this),this.sc=new dne}register(e){var n,o;if(!Eo((n=this._instance)===null||n===void 0?void 0:n._addCaptureHook)&&(e.forEach(i=>{var r;this.ec.add(i),(r=i.steps)===null||r===void 0||r.forEach(s=>{this.nc.add(s?.event||"")})}),(o=this._instance)===null||o===void 0?void 0:o.autocapture)){const i=new Set;this.ec.forEach(r=>{var s;(s=r.steps)===null||s===void 0||s.forEach(a=>{a?.selector&&i.add(a.selector)})}),this._instance.autocapture.setElementSelectors(i,this)}}replace(e){this.ec.clear(),this.nc.clear(),this.register(e)}on(e,n){n!=null&&e.length!=0&&(this.nc.has(e)||this.nc.has(n.event))&&this.ec.forEach(o=>{this.cc(n,o)&&this.sc.emit("actionCaptured",o.name)})}dc(e){this.onAction("actionCaptured",n=>e(n))}cc(e,n){if(n?.steps==null)return!1;for(const o of n.steps)if(this.rc(e,o))return!0;return!1}onAction(e,n){return this.sc.on(e,n)}ac(e,n){if(n?.url){var o;const i=e==null||(o=e.properties)===null||o===void 0?void 0:o.$current_url;if(!i||typeof i!="string"||!Jk(i,n.url,n.url_matching||"contains"))return!1}return!0}lc(e,n){return!!this.vc(e,n)&&!!this.fc(e,n)&&!!this.gc(e,n)}vc(e,n){var o;if(!n?.href)return!0;const i=this.mc(e);if(i.length>0)return i.some(s=>Jk(s.href,n.href,n.href_matching||"exact"));const r=(e==null||(o=e.properties)===null||o===void 0?void 0:o.$elements_chain)||"";return!!r&&Jk((function(s){const a=s.match(/(?::|")href="(.*?)"/);return a?a[1]:""})(r),n.href,n.href_matching||"exact")}fc(e,n){var o;if(!n?.text)return!0;const i=this.mc(e);if(i.length>0)return i.some(c=>Jk(c.text,n.text,n.text_matching||"exact")||Jk(c.$el_text,n.text,n.text_matching||"exact"));const r=(e==null||(o=e.properties)===null||o===void 0?void 0:o.$elements_chain)||"";return!!r&&(s=(function(c){const l=[],g=/(?::|")text="(.*?)"/g;let u;for(;!Fs(u=g.exec(c));)l.includes(u[1])||l.push(u[1]);return l})(r),a=n.text,A=n.text_matching||"exact",s.some(c=>Jk(c,a,A)));var s,a,A}gc(e,n){var o,i;if(!n?.selector)return!0;const r=e==null||(o=e.properties)===null||o===void 0?void 0:o.$element_selectors;if(r?.includes(n.selector))return!0;const s=(e==null||(i=e.properties)===null||i===void 0?void 0:i.$elements_chain)||"";if(n.selector_regex&&s)try{return new RegExp(n.selector_regex).test(s)}catch{return!1}return!1}mc(e){var n;return(e==null||(n=e.properties)===null||n===void 0?void 0:n.$elements)==null?[]:e?.properties.$elements}uc(e,n){return!n?.properties||n.properties.length===0||Gat(n.properties.reduce((o,i)=>{const r=As(i.value)?i.value.map(String):i.value!=null?[String(i.value)]:[];return o[i.key]={values:r,operator:i.operator||"exact"},o},{}),e?.properties)}},Y9n=class{constructor(e,n){var o,i;this.yc=[],this._instance=e,this.bc=n,this._c=new Map,this.wc=new Map,this.kc=new Map,this.Sc=(o=this._instance)===null||o===void 0||(i=o.onSessionId)===null||i===void 0?void 0:i.call(o,r=>this.xc(r))}$c(e){return!1}Cc(){return null}Tc(e){}Ic(){}Mc(e,n){return!!e&&Gat(e.propertyFilters,n?.properties)}Ec(e,n){const o=new Map;return e.forEach(i=>{var r;(r=i.conditions)===null||r===void 0||(r=r[n])===null||r===void 0||(r=r.values)===null||r===void 0||r.forEach(s=>{if(s?.name){const a=o.get(s.name)||[];a.push(i.id),o.set(s.name,a)}})}),o}Pc(e,n,o){const i=(o===pV.Activation?this._c:this.wc).get(e);let r=[];return this.Rc(s=>{r=s.filter(a=>i?.includes(a.id))}),r.filter(s=>{var a;const A=(a=s.conditions)===null||a===void 0||(a=a[o])===null||a===void 0||(a=a.values)===null||a===void 0?void 0:a.find(c=>c.name===e);return this.Mc(A,n)})}register(e){this.Ac(e,!1)}replace(e){this.Ac(e,!0)}Ac(e,n){var o;Eo((o=this._instance)===null||o===void 0?void 0:o._addCaptureHook)||(this.Oc(e,n),this.Fc(e,n))}Fc(e,n){const o=e.filter(s=>{var a;return(a=s.conditions)===null||a===void 0||(a=a.actions)===null||a===void 0||(a=a.values)===null||a===void 0?void 0:a.length});var i;if(n&&this.kc.clear(),o.length===0)return void(n&&((i=this.Dc)===null||i===void 0||i.replace([])));this.Dc||(this.Dc=new G9n(this._instance),this.Dc.init(),this.Dc.dc(s=>this.onAction(s)));const r=[];o.forEach(s=>{var a;(a=s.conditions)===null||a===void 0||(a=a.actions)===null||a===void 0||a.values.forEach(A=>{if(r.push(A),A.name){var c;const l=(c=this.kc.get(A.name))!==null&&c!==void 0?c:[];l.includes(s.id)||l.push(s.id),this.kc.set(A.name,l)}})}),n?this.Dc.replace(r):this.Dc.register(r)}Lc(e,n){n.forEach((o,i)=>{var r;const s=(r=e.get(i))!==null&&r!==void 0?r:[];o.forEach(a=>{s.includes(a)||s.push(a)}),e.set(i,s)})}Oc(e,n){var o,i;const r=e.filter(c=>{var l,g;return((l=c.conditions)===null||l===void 0?void 0:l.events)&&((g=c.conditions)===null||g===void 0||(g=g.events)===null||g===void 0||(g=g.values)===null||g===void 0?void 0:g.length)>0}),s=e.filter(c=>{var l,g;return((l=c.conditions)===null||l===void 0?void 0:l.cancelEvents)&&((g=c.conditions)===null||g===void 0||(g=g.cancelEvents)===null||g===void 0||(g=g.values)===null||g===void 0?void 0:g.length)>0}),a=this.Ec(e,pV.Activation),A=this.Ec(e,pV.Cancellation);n?(this._c=a,this.wc=A):(this.Lc(this._c,a),this.Lc(this.wc,A)),(r.length!==0||s.length!==0||e.some(c=>{var l;return(l=c.conditions)===null||l===void 0||(l=l.actions)===null||l===void 0||(l=l.values)===null||l===void 0?void 0:l.length}))&&((o=this.hc)!==null&&o!==void 0||(this.hc=(i=this._instance)===null||i===void 0?void 0:i._addCaptureHook((c,l)=>{this.onEvent(c,l)})))}onEvent(e,n){var o,i;const r=this.Nc(),s=(n==null||(o=n.properties)===null||o===void 0?void 0:o.$survey_id)||(n==null||(i=n.properties)===null||i===void 0?void 0:i.$product_tour_id);if(s&&this.getActivatedIds().includes(s)){const A=this.qc(e,s,n);if(A==="consume")return r.info("event consumed activated item, removing it",{event:e,itemId:s}),void this.jc([s]);if(A==="persist")return r.info("shown item promoted to persisted activation",{event:e,itemId:s}),this.Bc(s),void this.Hc([s])}if(this.wc.has(e)){const A=this.Pc(e,n,pV.Cancellation);A.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:A.map(c=>c.id)}),this.jc(A.map(c=>c.id)),A.forEach(c=>this.zc(c.id)))}if(!this._c.has(e))return;r.info("event name matched",{event:e,eventPayload:n,items:this._c.get(e)});const a=this.Pc(e,n,pV.Activation);this.Uc(a.map(A=>A.id))}onAction(e){this.kc.has(e)&&this.Uc(this.kc.get(e)||[])}Uc(e){var n,o;if(e.length===0)return;const i=!!(!((n=this._instance)===null||n===void 0||(o=n.get_session_id)===null||o===void 0)&&o.call(n)),r=[];for(const s of e)i&&this.$c(s)?this.Bc(s)&&this.Wc(s):r.push(s);r.length>0&&(this.yc=[...new Set([...this.yc,...r])]),this.Nc().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.Vc()}Bc(e){this.yc=this.yc.filter(o=>o!==e);const n=this.Gc();return!n.includes(e)&&(this.Qc([...n,e]),this.Jc(),!0)}jc(e){const n=new Set(e);this.yc=this.yc.filter(r=>!n.has(r));const o=this.Zc(),i=o.filter(r=>!n.has(r));i.length!==o.length&&(this.Qc(i),i.length===0&&this.Kc()),this.Hc(e),this.Vc()}Vc(){try{var e;(e=this.bc)===null||e===void 0||e.call(this)}catch(n){this.Nc().error("Error while handling activated items change",n)}}Xc(){var e;const n=this.Cc();if(!n)return{};const o=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[n];return o&&typeof o=="object"?o:{}}Wc(e){if(!this.Cc())return;const n=this.Xc();this.Tc(sn(sn({},n),{},{[e]:Date.now()}))}Hc(e){if(!this.Cc())return;const n=this.Xc(),o={};let i=!1;for(const[r,s]of Object.entries(n))e.includes(r)?i=!0:o[r]=s;i&&(ox(o)?this.Ic():this.Tc(o))}Yc(){this.Cc()&&this.Ic()}getActivationTimestamp(e){if(!this.Gc().includes(e))return;const n=this.Xc()[e];return qd(n)?n:void 0}Zc(){var e;const n=this.td();return((e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[n])||[]}Gc(){var e,n,o;const i=this.Zc();if(i.length===0)return[];const r=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[this.ed()],s=(n=this._instance)===null||n===void 0||(o=n.get_session_id)===null||o===void 0?void 0:o.call(n);return s&&r===s?i:[]}Jc(){var e,n;const o=(e=this._instance)===null||e===void 0||(n=e.get_session_id)===null||n===void 0?void 0:n.call(e);o&&this.nd(o)}Kc(){this.sd()}xc(e){var n;const o=(n=this._instance)===null||n===void 0||(n=n.persistence)===null||n===void 0?void 0:n.props[this.ed()];if(o&&o!==e){const i=this.Zc(),r=this.Xc();i.length>0&&(this.Qc([]),i.filter(s=>qd(r[s])).forEach(s=>this.zc(s))),this.Kc(),this.Yc(),i.length>0&&this.Vc()}}getActivatedIds(){return[...new Set([...this.Gc(),...this.yc])].filter(e=>!this.rd(e))}dispose(){var e,n,o;(e=this.Sc)===null||e===void 0||e.call(this),this.Sc=void 0,(n=this.hc)===null||n===void 0||n.call(this),this.hc=void 0,(o=this.Dc)===null||o===void 0||o.dispose(),this.Dc=void 0}reset(){this.yc=[],this.Zc().length>0&&this.Qc([]),this.Kc(),this.Yc(),this.Vc()}getEventToItemsMap(){return this._c}od(){return this.Dc}},U9n=class extends Y9n{constructor(e,n){super(e,n)}td(){return ost}ed(){return ist}Cc(){return rst}Tc(e){var n;(n=this._instance)===null||n===void 0||(n=n.persistence)===null||n===void 0||n.register({$surveys_activated_timestamps:e})}Ic(){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.unregister("$surveys_activated_timestamps")}$c(e){var n;let o;this.Rc(r=>{o=r.find(s=>s.id===e)});const i=o==null||(n=o.appearance)===null||n===void 0?void 0:n.surveyPopupDelaySeconds;return qd(i)&&i>0}ad(){return R3.SHOWN}Rc(e){var n;(n=this._instance)===null||n===void 0||n.getSurveys(e)}zc(e){var n;(n=this._instance)===null||n===void 0||n.cancelPendingSurvey(e)}Nc(){return _l}Qc(e){var n;(n=this._instance)===null||n===void 0||(n=n.persistence)===null||n===void 0||n.register({$surveys_activated:e})}nd(e){var n;(n=this._instance)===null||n===void 0||(n=n.persistence)===null||n===void 0||n.register({$surveys_activated_session:e})}sd(){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.unregister("$surveys_activated_session")}rd(){return!1}qc(e,n,o){var i;if(e===R3.SENT&&(o==null||(i=o.properties)===null||i===void 0?void 0:i.$survey_completed)===!1)return"ignore";let r;return this.Rc(s=>{r=s.find(a=>a.id===n)}),!r||(function(s){var a;return Hat(s)&&!!(!((a=s.conditions)===null||a===void 0||(a=a.events)===null||a===void 0)&&a.repeatedActivation)||s.schedule==="always"})(r)?e===R3.SHOWN?"consume":"ignore":e===R3.SHOWN?"persist":e===R3.DISMISSED||e===R3.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},K9n=class{constructor(e){this._instance=e}initialize(){}get(e){if(typeof e=="string")return this._instance.get_property(e);const n={};for(const o of e){const i=this._instance.get_property(o);Eo(i)||(n[o]=i)}return n}set(e,n){this._instance.register(typeof e=="string"?{[e]:n}:e)}remove(e){typeof e!="string"?e.forEach(n=>this._instance.unregister(n)):this._instance.unregister(e)}},V9n=class{constructor(e){this._instance=e}get(){const e=this._instance.config;return{disableSurveys:e.disable_surveys,cookielessMode:!!e.cookieless_mode,advancedEnableSurveys:e.advanced_enable_surveys,requestTimeoutMs:e.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}isCapturing(){return this._instance.is_capturing()}getExtensions(){const e=Ur?.__PosthogExtensions__;if(!e)return;const{generateSurveys:n,loadExternalDependency:o}=e;return{generateSurveys:n?i=>n(this._instance,i):void 0,loadExternalDependency:o?i=>o(this._instance,"surveys",i):void 0}}createEventReceiver(e){return new U9n(this._instance,e)}onMatchingConditionsChanged(e){const n=this._instance._addCaptureHook(s=>{s!=="$pageview"&&s!==R3.SHOWN&&s!==R3.DISMISSED&&s!==R3.SENT||e()}),o=()=>e();jc(Fn,"PHSurveyShown",o);let i=!1;const r=this._instance.onFeatureFlags(()=>{i&&e()});return i=!0,()=>{i=!1,n(),r(),Fn?.removeEventListener("PHSurveyShown",o)}}};const z9n=Fn?.location?sne(Fn.location.hash,"__posthog")||sne(location.hash,"state"):null,aAt="_postHogToolbarParams",AAt=Ad("[Toolbar]"),cAt=Ad("[FeatureFlags]");var J9n=class{constructor(e,n=!1){this.ld=!1,this.update(e,n)}update(e,n){this.ud=((o,i)=>{var r,s,a,A,c,l,g,u;return{bootstrap:{featureFlags:(r=(s=o.bootstrap)===null||s===void 0?void 0:s.featureFlags)!==null&&r!==void 0?r:void 0,featureFlagPayloads:(a=(A=o.bootstrap)===null||A===void 0?void 0:A.featureFlagPayloads)!==null&&a!==void 0?a:void 0},remoteRequestsDisabled:i,featureFlagsDisabled:!!o.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!o.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!o.advanced_feature_flags_dedup_per_session,cacheTtlMs:o.feature_flag_cache_ttl_ms,refreshIntervalMs:(c=o.remote_config_refresh_interval_ms)!==null&&c!==void 0?c:3e5,idleRefreshBackoff:Eo(o.remote_config_refresh_interval_ms),requestTimeoutMs:o.feature_flag_request_timeout_ms,requestMaxRetries:Math.max(0,(l=o.feature_flag_request_max_retries)!==null&&l!==void 0?l:1),compression:o.disable_compression?void 0:"best-available",evaluationContexts:(g=(u=o.evaluation_contexts)!==null&&u!==void 0?u:o.evaluation_environments)!==null&&g!==void 0?g:[],flagKeys:As(o.flag_keys)?o.flag_keys:void 0}})(e,n),!e.evaluation_environments||e.evaluation_contexts||this.ld||(cAt.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ld=!0),Eo(e.flag_keys)||As(e.flag_keys)||cAt.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this.ud}};const lAt=Ad("[FeatureFlags]"),OM=Ad("[FeatureFlags]",{debugEnabled:!0}),nxe=`" failed. Feature flags didn't load in time.`,W9n=[502,504],gAt=["click","keydown","wheel","touchstart","pointerdown"],uAt="connection_error",dAt=t=>{const e={};for(let n=0;t.length>n;n++)e[t[n]]=!0;return e},hAt=t=>{const e={};for(const[n,o]of one(t||{}))o&&(e[n]=o);return e},pAt=t=>Qk(t)&&(t.name==="RangeError"&&t.message.indexOf("Maximum call stack size exceeded")===0||t.name==="InternalError"&&t.message==="too much recursion"),L4=Ad("[Error tracking]"),oxe="webkit-masked-url:",j9n=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],X9n=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",oxe],q9n=["__firefox__","__gCrWeb"],mAt="Refusing to render web experiment since the viewer is a likely bot",$9n={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>hne(e,t),not_regex:(t,e)=>!hne(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t},_5=Ad("[Conversations]"),GM="Conversations not available yet.";function _At(t,e){var n,o,i,r,s,a,A;const c=(n=t?.flushIntervalMs)!==null&&n!==void 0?n:3e3,l=(o=t?.maxBufferSize)!==null&&o!==void 0?o:100,g=e?.consoleCapture?void 0:(i=t?.maxLogsPerInterval)!==null&&i!==void 0?i:1e3,u=Eo(g)?Math.max(l,2048):Math.max(l,g),h=sn(sn({},(function(){let d="",p="";try{const m=F_?.userAgent;m&&([d,p]=crt(m))}catch{}return(function(m,_){const f=(function(I){if(I)return{}.hasOwnProperty.call(Lrt,I)?Lrt[I]:I})(m);return sn(sn({},f?{"os.name":f}:{}),_?{"os.version":_}:{})})(d,p)})()),t?.resourceAttributes);return{serviceName:(r=(s=h?.["service.name"])!==null&&s!==void 0?s:t?.serviceName)!==null&&r!==void 0?r:e?.serviceNameDefault,serviceVersion:(a=h?.["service.version"])!==null&&a!==void 0?a:t?.serviceVersion,environment:(A=h?.["deployment.environment"])!==null&&A!==void 0?A:t?.environment,resourceAttributes:h,beforeSend:t?.beforeSend,flushIntervalMs:c,maxBufferSize:l,maxQueueSize:u,maxBatchRecordsPerPost:100,rateCapWindowMs:c,maxLogsPerInterval:g,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const Z9n=["debug","log","warn","error","info"],e7n=t=>{for(;t?.__rrweb_original__;)t=t.__rrweb_original__;return t},fAt="console",IAt="__posthogHandledLogsRequestError",ixe=(t,e)=>{const n=t instanceof Error?t:new Error(e);return n[IAt]=!0,n},CAt=t=>!!t&&typeof t=="object"&&t[IAt]===!0,_ne=Ad("[NetworkMetrics]"),rxe=()=>{var t;return!(Fn==null||(t=Fn.performance)===null||t===void 0)&&t.now?Fn.performance.now():Date.now()},t7n={"http:":80,"https:":443},n7n=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),yAt=(t,e)=>{var n;const o=String(e);return{method:String(t).toUpperCase(),url:((n=x8(o))===null||n===void 0?void 0:n.href)||o}},sxe=(t,e,n,o,i,r,s=!1)=>{try{var a,A;const c=i();if(!c)return;const l=n||void 0,g=rxe()-o,u=x8(e.url);if(u&&u.protocol!=="http:"&&u.protocol!=="https:")return;const h={url:u?.href||e.url,method:e.method},d=L_(c.name)?c.name(h):nA(c.name)?c.name:"http.client.request.duration";if(!d)return;const p=s&&!l?void 0:((_,f)=>_?400>_?void 0:String(_):f?.name||"_OTHER")(l,r),m=sn(sn(sn(sn(sn({},(_=>{const f=n7n.has(_)?_:"_OTHER";return sn({"http.request.method":f},f==="_OTHER"&&_!==f?{"http.request.method_original":_}:{})})(h.method)),u?(_=>{return{"server.address":_.hostname.startsWith("[")&&_.hostname.endsWith("]")?_.hostname.slice(1,-1):_.hostname,"server.port":Number(_.port)||t7n[_.protocol],"url.scheme":_.protocol.slice(0,-1),"url.template":(f=_.pathname,f.split("/").map(I=>(C=>/^\d+$/.test(C)||C.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(C))(I)?":id":I).join("/"))};var f})(u):{}),l?{"http.response.status_code":l}:{}),p?{"error.type":p}:{}),(a=c.attributes)===null||a===void 0?void 0:a.call(c,h,{status:l,durationMs:g}));(A=t.metrics)===null||A===void 0||A.histogram(d,g,{unit:"ms",attributes:m})}catch(c){_ne.error("Failed to record network metric",c)}},xAt=()=>{},o7n=(t,e)=>L_(Fn?.fetch)?bV(Fn,"fetch",n=>function(...o){const i=rxe(),r=n.apply(this,o);if(!e())return r;try{var s,a,A;const[c,l]=o,g=yAt((s=(a=l?.method)!==null&&a!==void 0?a:c?.method)!==null&&s!==void 0?s:"GET",(A=c?.url)!==null&&A!==void 0?A:c);return r.then(u=>(sxe(t,g,u?.status,i,e,void 0,!0),u),u=>{throw sxe(t,g,void 0,i,e,u),u})}catch(c){return _ne.error("Failed to observe fetch",c),r}}):xAt,i7n=(t,e)=>{var n;const o=Fn==null||(n=Fn.XMLHttpRequest)===null||n===void 0?void 0:n.prototype;if(!o)return xAt;const i=new WeakMap,r=bV(o,"open",a=>function(...A){try{xat.has(this)||i.set(this,yAt(A[0],A[1]))}catch(c){_ne.error("Failed to observe XHR open",c)}return a.apply(this,A)}),s=bV(o,"send",a=>function(...A){let c;try{const l=i.get(this);if(l&&e()){const g=rxe();c=()=>{this.removeEventListener("loadend",c),sxe(t,l,this.status,g,e)},jc(this,"loadend",c)}}catch(l){_ne.error("Failed to observe XHR send",l)}try{return a.apply(this,A)}catch(l){throw c&&this.removeEventListener("loadend",c),l}});return()=>{r(),s()}},fne={featureFlags:class{constructor(t){this.name="featureFlags",this.hd=!1,this.featureFlagEventHandlers=[],this.A=lAt,this.dd={},this.vd={},this.fd=[],this.pd=!1,this.gd=!1,this.md=0,this.yd=!1,this.bd=!1,this._d=!1,this.wd=!1,this.kd=0,this.Sd=!1,this.rn=()=>{const e=this.xd();this.kd=0,e&&this.reloadFeatureFlags()},this.$d=()=>{var e,n;const o=this.Cd,i=(e=this.Td)!==null&&e!==void 0?e:o;Eo(o)||Eo(i)||this.Mr.remoteRequestsDisabled||!No||No.visibilityState==="hidden"||Date.now()-((n=this.Id)!==null&&n!==void 0?n:0)<i||(this.Td=this.Sd||!this.Mr.idleRefreshBackoff?o:Math.min(2*i,36e5),this.Sd=!1,this.reloadFeatureFlags(),this.Md())},this.Ed=()=>{this.Sd&&this.Td===this.Cd||this.Pd()},this.sn=()=>{No?.visibilityState==="visible"&&this.Pd()},"get"in t?this.wo=t:(this._instance=t,this.Rd=new J9n(t.config,t.il()),this.wo=this.Rd)}updateConfig(t,e){var n;(n=this.Rd)===null||n===void 0||n.update(t,e),this.bo&&this.Ad()}setup(t){return this.jh=t,this.A=t.logger.createLogger("[FeatureFlags]"),rAt(t.kv.initialize(),()=>{this.jh===t&&(this.jh=void 0,this.bo=t,this.Od(t))})}Od(t){var e;if(this.bo===t)return Fn&&jc(Fn,"online",this.rn),this.Ad(),this.Fd=t.registerDynamicEventProperties(()=>this.Dd()?this.dd:this.vd),this.Ld=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.onCrossTabFeatureFlagChange(()=>{this.Nd(),this.qd(),this.jd()}),this.qd(),this.initialize()}Pd(){this.Sd=!0,this.Td=this.Cd,this.$d()}Ad(){const t=this.Mr.refreshIntervalMs,e=!this.Mr.remoteRequestsDisabled&&No&&!Eo(t)&&t>0?t:void 0;this.Mr.idleRefreshBackoff||(this.Td=e),e!==this.Cd&&(this.Bd(),Eo(e)||(this.Cd=e,this.Td=e,this.Md(),No?.addEventListener&&(jc(No,iV,this.sn),Nk(gAt,n=>{jc(No,n,this.Ed,{capture:!0})}))))}Md(){Eo(this.Cd)||(Eo(this.Hd)||clearInterval(this.Hd),this.Id=Date.now(),this.Hd=setInterval(this.$d,this.Cd))}Bd(){var t;Eo(this.Hd)||(clearInterval(this.Hd),this.Hd=void 0,No==null||(t=No.removeEventListener)===null||t===void 0||t.call(No,"visibilitychange",this.sn),Nk(gAt,e=>{var n;No==null||(n=No.removeEventListener)===null||n===void 0||n.call(No,e,this.Ed,{capture:!0})})),this.Cd=void 0,this.Td=void 0,this.Sd=!1,this.Id=void 0}destroy(){this.zd()}dispose(){this.zd()}zd(){var t,e;this.Bd(),this.md++,this.bd=!1,this.jh=void 0,this.bo&&(this.Ud(),(t=this.Fd)===null||t===void 0||t.dispose(),this.Fd=void 0,(e=this.Ld)===null||e===void 0||e.call(this),this.Ld=void 0,this.fd=[],Fn?.removeEventListener("online",this.rn),this.bo=void 0)}get Mr(){return this.wo.get()}Wd(t){var e;return this.Vd&&t in this.Vd?this.Vd[t]:(e=this.bo)===null||e===void 0?void 0:e.kv.get(t)}Nd(){return!!this.Vd&&(this.Vd=void 0,!0)}Gd(){var t;return!Eo((t=this.bo)===null||t===void 0?void 0:t.kv.get("$enabled_feature_flags"))&&this.Nd()}$t(t){this.Qd(()=>{var e;return(e=this.bo)===null||e===void 0?void 0:e.kv.set(t)})}Jd(t,e,n){var o;if(!(!((o=this._instance)===null||o===void 0)&&o.persistence)||!t.$enabled_feature_flags)return;const i=this.Wd("$enabled_feature_flags")||{},r=t.$enabled_feature_flags||{},s=e.flags||e.featureFlags,a=e.flags?Object.entries(e.flags).filter(([,_])=>!_?.failed).map(([_])=>_):[],A=!!e.errorsWhileComputingFlags&&!!e.flags,c=A?a:n&&!As(s)?Object.keys(s||{}):Array.from(new Set([...Object.keys(i),...Object.keys(r)])),l=this.Wd("$feature_flag_payloads")||{},g=t.$feature_flag_payloads||{},u=A||n?c:Array.from(new Set([...Object.keys(l),...Object.keys(g)])),h=!A&&!n,d=!!h||c,p=!!h||u,m={[C8]:d,[k4]:d,[cQ]:p};t.$feature_flag_details&&(m[NM]=d);for(const _ of[RM,dQ,eV])Eo(t[_])||(m[_]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(m)}Pt(t){this.Qd(()=>{var e;return(e=this.bo)===null||e===void 0?void 0:e.kv.remove(t)})}Qd(t){try{t()}catch(e){this.A.error("Failed to update feature flag persistence",e)}}qd(){const t={};for(const o of[C8,cQ,RM,B9]){const i=this.Wd(o);Eo(i)||(t[o]=i)}this.dd=t;const e=sn({},t),n=this.Wd(k4);if(n)for(const[o,i]of Object.entries(n))e[`$feature/${o}`]=i;this.vd=e}Dd(){const t=this.Mr.cacheTtlMs;if(!t||0>=t)return!1;const e=this.Wd(dQ);return typeof e!="number"||Date.now()-e>t}Zd(){return!!this.Dd()&&(this.wd||this.gd||(this.wd=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Kd(){const t=this.Mr.evaluationContexts;return t?.length?t.filter(e=>{const n=e&&typeof e=="string"&&e.trim().length>0;return n||this.A.error("Invalid evaluation context found:",e,"Expected non-empty string"),n}):[]}Xd(){const t=this.Mr.flagKeys;if(!Eo(t))return t.filter(e=>{const n=e&&typeof e=="string"&&e.trim().length>0;return n||this.A.error("Invalid flag key found:",e,"Expected non-empty string"),n})}initialize(){var t,e;const n=this.Mr,o=(t=(e=n.bootstrap)===null||e===void 0?void 0:e.featureFlags)!==null&&t!==void 0?t:{};if(Object.keys(o).length){var i,r;const s=(i=(r=n.bootstrap)===null||r===void 0?void 0:r.featureFlagPayloads)!==null&&i!==void 0?i:{},a=Object.keys(o).filter(c=>!Eo(o[c])).reduce((c,l)=>(c[l]=o[l],c),{}),A=Object.keys(s).filter(c=>a[c]).reduce((c,l)=>(c[l]=s[l],c),{});return this.Yd({featureFlags:a,featureFlagPayloads:A},void 0,{persist:!1})}}updateFlags(t,e,n){var o,i;const r=n?.merge&&(o=this.Wd("$enabled_feature_flags"))!==null&&o!==void 0?o:{},s=n?.merge&&(i=this.Wd("$feature_flag_payloads"))!==null&&i!==void 0?i:{},a=sn(sn({},r),t),A=sn(sn({},s),e),c={};for(const[l,g]of Object.entries(a))c[l]={key:l,enabled:vrt(g),variant:wrt(g),reason:void 0,metadata:Eo(A?.[l])?void 0:{id:0,version:void 0,description:void 0,payload:A[l]}};this.Yd({flags:c})}get hasLoadedFlags(){return this.pd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const t=this.Wd(NM),e=this.Wd(B9),n=this.Wd(TM);if(!n&&!e)return t||{};const o=jg({},t||{}),i=[...new Set([...Object.keys(n||{}),...Object.keys(e||{})])];for(const a of i){var r;const A=o[a],c=e?.[a],l=Eo(c)?(r=A?.enabled)!==null&&r!==void 0&&r:!!c,g=Eo(c)?A?.variant:typeof c=="string"?c:void 0,u=n?.[a],h=sn(sn({},A),{},{enabled:l,variant:l?g??A?.variant:void 0});var s;l!==A?.enabled&&(h.original_enabled=A?.enabled),g!==A?.variant&&(h.original_variant=A?.variant),u&&(h.metadata=sn(sn({},A?.metadata),{},{payload:u,original_payload:A==null||(s=A.metadata)===null||s===void 0?void 0:s.payload})),o[a]=h}return this.hd||(this.A.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:n,finalDetails:o}),this.hd=!0),o}getAllFeatureFlags(){const t=this.getFlagVariants(),e=this.getFlagPayloads();return Object.keys(t).map(n=>{const o=t[n];return{key:n,enabled:vrt(o),variant:wrt(o),payload:Qrt(e[n])}})}getFlagVariants(){const t=this.Wd(k4),e=this.Wd(B9);if(!e)return t||{};const n=jg({},t||{}),o=Object.keys(e);for(let i=0;o.length>i;i++)n[o[i]]=e[o[i]];return this.hd||(this.A.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:n}),this.hd=!0),n}getFlagPayloads(){const t=this.Wd(cQ),e=this.Wd(TM);if(!e)return t||{};const n=jg({},t||{}),o=Object.keys(e);for(let i=0;o.length>i;i++)n[o[i]]=e[o[i]];return this.hd||(this.A.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:n}),this.hd=!0),n}reloadFeatureFlags(){this.yd||this.Mr.featureFlagsDisabled||this.xd()||(this.gd&&(this.bd=!0),this.tv||(this.fd.slice().forEach(t=>{try{t()}catch(e){this.A.error("Error while running feature flags reloading callback",e)}}),this.tv=setTimeout(()=>{this.ev()},5)))}Ud(){clearTimeout(this.tv),this.tv=void 0}onReloading(t){return this.fd.push(t),()=>{this.fd=this.fd.filter(e=>e!==t)}}ensureFlagsLoaded(){this.pd||this.gd||this.tv||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.yd=t}resetFlagCallReported(){this.Pt(uQ)}ev(t){this.Ud();const e=this.bo;if(!e||this.Mr.remoteRequestsDisabled||this.xd())return;if(this.gd)return void(this.bd=!0);const n={token:e.projectToken,distinct_id:e.distinctId,groups:e.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:sn(sn(sn({},e.initialPersonProperties),this.Wd("$stored_person_properties")||{}),{},{$lib:e.library.name,$lib_version:e.library.version}),group_properties:this.Wd(gQ),timezone:sat()};Eo(e.deviceId)||(n.$device_id=e.deviceId),(t?.disableFlags||this.Mr.featureFlagsDisabled)&&(n.disable_flags=!0);const o=this.Kd();o.length&&(n.evaluation_contexts=o);const i=this.Xd();Eo(i)||(n.flag_keys=i);const r=this.Mr.onlyEvaluateSurveyFeatureFlags,s="/flags/?v=2"+(r?"&only_evaluate_survey_feature_flags=true":""),a=this.md;this.gd=!0;const A=()=>{this.bd&&(this.bd=!1,this.ev())},c=d=>{var p,m;const _=(p=d.json)!==null&&p!==void 0?p:{},f=d.statusCode!==200;if(this.gd=!1,a!==this.md)return void A();if(this.iv(d.statusCode),f||this.bd||(this.$anon_distinct_id=void 0),n.disable_flags&&!this.bd)return;this._d=!f;const I=[];d.error?I.push(d.error instanceof Error&&d.error.name==="AbortError"?"timeout":d.error instanceof Error?uAt:"unknown_error"):d.statusCode!==200&&I.push(`api_error_${d.statusCode}`),_.errorsWhileComputingFlags&&I.push("errors_while_computing_flags");const C=!!(!((m=_.quotaLimited)===null||m===void 0)&&m.includes("feature_flags"));C&&I.push("quota_limited"),this.$t({[oV]:I}),C?this.A.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."):n.disable_flags||this.Yd(_,f,{partialResponse:r}),A()},l=d=>{this.gd=!1,a===this.md&&(this.$t({[oV]:[uAt]}),this.A.error("Feature flag request failed",d),this.Gd()&&this.jd(!0)),A()};let g=this.Mr.requestMaxRetries;const u=()=>g>0&&a===this.md,h=()=>{if(a!==this.md||!this.bo||this.Mr.remoteRequestsDisabled)return this.gd=!1,void A();try{e.sendRequest(s,{target:"flags",method:"POST",body:n,compression:this.Mr.compression,sentAt:"body",timeoutMs:this.Mr.requestTimeoutMs}).then(d=>{if((p=>W9n.includes(p.statusCode)||(m=>m.statusCode===0&&m.error instanceof Error&&m.error.name==="AbortError")(p))(d)&&u())return g--,void setTimeout(h,500);c(d)}).catch(l)}catch(d){l(d)}};h()}xd(){return qst(this.kd,3)}iv(t){this.kd=$st(t,this.kd,3,()=>this.A.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.fresh&&!this._d)return;if(!(this.pd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlag for key "'+t+nxe);if(this.Zd())return;const o=this.getFeatureFlagResult(t,e);return(n=o?.variant)!==null&&n!==void 0?n:o?.enabled}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){const e=this.getFeatureFlagResult(t,{send_event:!1});return e?.payload}getFeatureFlagResult(t,e={}){if(e.fresh&&!this._d)return;if(!(this.pd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlagResult for key "'+t+nxe);if(this.Zd())return;const n=this.getFlagVariants(),o=t in n,i=n[t],r=this.getFlagPayloads()[t],s=String(i),a=this.Wd("$feature_flag_request_id")||void 0,A=this.Wd("$feature_flag_evaluated_at")||void 0;let c,l=this.Wd("$flag_call_reported")||{};if(this.Mr.deduplicateCallsPerSession){var g;const S=(g=this.bo)===null||g===void 0?void 0:g.session.sessionId,Q=this.Wd(nV);S&&S!==Q&&(l={},c=S)}if(e.send_event||!("send_event"in e))if(t in l&&l[t].includes(s))c&&this.$t({[uQ]:l,[nV]:c});else{var u,h,d,p,m,_,f,I,C,y,x,E;As(l[t])?l[t].push(s):l[t]=[s],this.$t(sn({[uQ]:l},c?{[nV]:c}:{}));const S=this.getFeatureFlagDetails(t),Q=[...(u=this.Wd("$feature_flag_errors"))!==null&&u!==void 0?u:[]];Eo(i)&&Q.push("flag_missing");const w={$feature_flag:t,$feature_flag_response:i,$feature_flag_payload:r??null,$feature_flag_request_id:a,$feature_flag_evaluated_at:A,$feature_flag_bootstrapped_response:(h=(d=this.Mr.bootstrap)===null||d===void 0||(d=d.featureFlags)===null||d===void 0?void 0:d[t])!==null&&h!==void 0?h:null,$feature_flag_bootstrapped_payload:(p=(m=this.Mr.bootstrap)===null||m===void 0||(m=m.featureFlagPayloads)===null||m===void 0?void 0:m[t])!==null&&p!==void 0?p:null,$used_bootstrap_value:!this._d};Eo(S==null||(_=S.metadata)===null||_===void 0?void 0:_.has_experiment)||(w.$feature_flag_has_experiment=S.metadata.has_experiment),Eo(S==null||(f=S.metadata)===null||f===void 0?void 0:f.version)||(w.$feature_flag_version=S.metadata.version);const M=(I=S==null||(C=S.reason)===null||C===void 0?void 0:C.description)!==null&&I!==void 0?I:S==null||(y=S.reason)===null||y===void 0?void 0:y.code;var B;M&&(w.$feature_flag_reason=M),!(S==null||(x=S.metadata)===null||x===void 0)&&x.id&&(w.$feature_flag_id=S.metadata.id),Eo(S?.original_variant)&&Eo(S?.original_enabled)||(w.$feature_flag_original_response=Eo(S.original_variant)?S.original_enabled:S.original_variant),!(S==null||(E=S.metadata)===null||E===void 0)&&E.original_payload&&(w.$feature_flag_original_payload=S==null||(B=S.metadata)===null||B===void 0?void 0:B.original_payload),Q.length&&(w.$feature_flag_error=Q.join(",")),this.nv(w)}else c&&this.$t({[uQ]:l,[nV]:c});return o?{key:t,enabled:!!i,variant:typeof i=="string"?i:void 0,payload:Qrt(r)}:void 0}nv(t){try{var e;(e=this.bo)===null||e===void 0||e.capture("$feature_flag_called",t)}catch(n){this.A.error("Failed to capture feature flag call",n)}}getRemoteConfigPayload(t,e){this.sv(t,e)}sv(t,e){var n=this;return Wg(function*(){const o=n.bo;if(!o)return;const i={distinct_id:o.distinctId,token:o.projectToken,person_properties:{$lib:o.library.name,$lib_version:o.library.version}},r=n.Kd();r.length&&(i.evaluation_contexts=r);const s=n.Xd();let a;Eo(s)||(i.flag_keys=s);try{var A;const c=(A=(yield o.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:i,compression:n.Mr.compression,sentAt:"body",timeoutMs:n.Mr.requestTimeoutMs})).json)===null||A===void 0?void 0:A.featureFlagPayloads;a=c?.[t]||void 0}catch(c){return void n.A.error("Remote config feature flag request failed",c)}try{e(a)}catch(c){n.A.error("Remote config feature flag callback failed",c)}})()}isFeatureEnabled(t,e={}){if(e.fresh&&!this._d)return e.defaultValue;if(!(this.pd||this.getFlags()&&this.getFlags().length>0))return this.A.warn('isFeatureEnabled for key "'+t+nxe),e.defaultValue;const n=this.getFeatureFlag(t,e);return Eo(n)?e.defaultValue:!!n}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(e=>e!==t)}receivedFeatureFlags(t,e,n){this.Yd(t,e,n)}Yd(t,e,n){if(!this.bo)return;this.pd=!0;const o=((i,r={},s={},a={},A,c=lAt)=>{const l=((I,C)=>{const y=I.flags;if(y){const x=Object.fromEntries(Object.keys(y).map(B=>{var S;return[B,(S=y[B].variant)!==null&&S!==void 0?S:y[B].enabled]})),E=Object.fromEntries(Object.keys(y).filter(B=>y[B].enabled).filter(B=>{var S;return!Eo((S=y[B].metadata)===null||S===void 0?void 0:S.payload)}).map(B=>{var S;return[B,(S=y[B].metadata)===null||S===void 0?void 0:S.payload]}));return sn(sn({},I),{},{featureFlags:x,featureFlagPayloads:E})}return I.featureFlags&&C.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),I})(i,c),g=l.flags,u=l.featureFlags,h=l.featureFlagPayloads;if(!u)return;const d=i.requestId,p=i.evaluatedAt;if(As(u)){c.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const I={};if(u)for(let C=0;u.length>C;C++)I[u[C]]=!0;return{[C8]:u,[k4]:I,[eV]:!1}}let m=u,_=h,f=g;if(A?.partialResponse){const I=Object.keys(m),C=_||{};m=sn(sn({},r),m),_=sn(sn({},s),C),I.forEach(y=>{y in C||_==null||delete _[y]}),f=sn(sn({},a),f)}else if(i.errorsWhileComputingFlags)if(g){const I=new Set(Object.keys(g).filter(y=>{var x;return!(!((x=g[y])===null||x===void 0)&&x.failed)}));m=sn(sn({},r),Object.fromEntries(Object.entries(m).filter(([y])=>I.has(y))));const C=Object.fromEntries(Object.entries(_||{}).filter(([y])=>I.has(y)));_=sn(sn({},s),C),I.forEach(y=>{y in C||_==null||delete _[y]}),f=sn(sn({},a),Object.fromEntries(Object.entries(f||{}).filter(([y])=>I.has(y))))}else m=sn(sn({},r),m),_=sn(sn({},s),_),f=sn(sn({},a),f);return sn(sn({[C8]:Object.keys(hAt(m)),[k4]:m||{},[cQ]:_||{},[NM]:f||{},[eV]:i.minimalFlagCalledEvents===!0},d?{[RM]:d}:{}),p?{[dQ]:p}:{})})(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),n,this.A);if(o)if(n?.persist===!1){const i=!Eo(this.bo.kv.get(k4));this.Vd=o,i||this.$t(o)}else this.Nd(),this.Jd(o,t,!!n?.partialResponse),this.$t(o);else e&&this.Gd();e||(this.wd=!1),this.jd(e)}override(t,e=!1){this.A.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){this.rv(t)}rv(t){if(this.bo){if(t===!1)return this.Pt([B9,TM]),this.jd(),void OM.info("All overrides cleared");if(As(t))return this.$t({[B9]:dAt(t)}),this.jd(),void OM.info("Flag overrides set",{flags:t});if(t&&typeof t=="object"&&("flags"in t||"payloads"in t)){var e;const n=t;this.hd=!!((e=n.suppressWarning)!==null&&e!==void 0&&e);const o={},i=n.flags,r=n.payloads;return i&&(o[B9]=As(i)?dAt(i):i),r&&(o[TM]=r),Object.keys(o).length&&this.$t(o),i===!1&&r===!1?this.Pt([B9,TM]):i===!1?this.Pt(B9):r===!1&&this.Pt(TM),this.jd(),i===!1?OM.info("Flag overrides cleared"):i&&OM.info("Flag overrides set",{flags:i}),void(r===!1?OM.info("Payload overrides cleared"):r&&OM.info("Payload overrides set",{payloads:r}))}if(t&&typeof t=="object")return this.$t({[B9]:t}),this.jd(),void OM.info("Flag overrides set",{flags:t});this.A.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.A.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.pd){const{flags:e,flagVariants:n}=this.ov();try{t(e,n)}catch(o){this.A.error("Error while running feature flags callback",o)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,n){var o;const i=(this.Wd("$early_access_features")||[]).find(c=>c.flagKey===t),r={[`$feature_enrollment/${t}`]:e},s={$feature_flag:t,$feature_enrollment:e,$set:r};i&&(s.$early_access_feature_name=i.name),n&&(s.$feature_enrollment_stage=n);const a=sn(sn({},this.getFlagVariants()),{},{[t]:e});(o=this._instance)===null||o===void 0||(o=o.persistence)===null||o===void 0||o.markCrossTabFeatureFlagChanges({$active_feature_flags:[t],$enabled_feature_flags:[t],$stored_person_properties:Object.keys(r)}),this.$t({[C8]:Object.keys(hAt(a)),[k4]:a,[lQ]:sn(sn({},this.Wd("$stored_person_properties")||{}),r)}),this.jd();try{var A;(A=this.bo)===null||A===void 0||A.capture("$feature_enrollment_update",s)}catch(c){this.A.error("Failed to capture early access feature enrollment",c)}}getEarlyAccessFeatures(t,e=!1,n){const o=this.Wd(a2e);!o||e?this.av(t,n):t(o)}av(t,e){var n=this;return Wg(function*(){const o=n.bo;if(!o)return;const i=e?`&${e.map(s=>`stage=${s}`).join("&")}`:"";let r;try{const s=yield o.sendRequest(`/api/early_access_features/?token=${o.projectToken}${i}`,{target:"api",method:"GET",sentAt:"query"});if(!s.json)return;r=s.json.earlyAccessFeatures,n.$t({[a2e]:r})}catch(s){return void n.A.error("Early access feature request failed",s)}try{t(r)}catch(s){n.A.error("Early access feature callback failed",s)}})()}ov(){const t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter(n=>e[n]),flagVariants:Object.keys(e).filter(n=>e[n]).reduce((n,o)=>(n[o]=e[o],n),{})}}jd(t){this.qd();const{flags:e,flagVariants:n}=this.ov();this.featureFlagEventHandlers.forEach(o=>{try{o(e,n,{errorsLoading:t})}catch(i){this.A.error("Error while running feature flags callback",i)}})}setPersonPropertiesForFlags(t,e=!0){this.lv(t,e)}lv(t,e=!0){const n=this.Wd("$stored_person_properties")||{},o=t?.$set||(t?.$set_once?{}:t),i=t?.$set_once,r={};if(i)for(const s in i)({}).hasOwnProperty.call(i,s)&&(s in n||(r[s]=i[s]));this.$t({[lQ]:sn(sn(sn({},n),r),o)}),e&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e=!0){const n=sn({},this.Wd("$stored_person_properties")||{});t.forEach(o=>{delete n[o]}),this.$t({[lQ]:n}),e&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t=!0){this.Pt(lQ),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e=!0){const n=this.Wd("$stored_group_properties")||{},o=sn({},n);for(const i of Object.keys(t))o[i]=sn(sn({},n[i]),t[i]);this.$t({[gQ]:o}),e&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){const e=this.Wd("$stored_group_properties")||{};this.$t({[gQ]:sn(sn({},e),{},{[t]:{}})})}else this.Pt(gQ)}reset(){this.md++,this.bd=!1,this.dd={},this.vd={},this.Vd=void 0,this.pd=!1,this.yd=!1,this._d=!1,this.$anon_distinct_id=void 0,this.Ud(),this.hd=!1,this.kd=0}}},r7n={sessionRecording:class{get Mr(){return this._instance.config}get Il(){return this._instance.persistence}get started(){var t;return!!(!((t=this.uv)===null||t===void 0)&&t.isStarted)}get status(){var t,e;return this.hv==="awaiting_config"||this.hv==="missing_config"?this.hv:(t=(e=this.uv)===null||e===void 0?void 0:e.status)!==null&&t!==void 0?t:this.hv}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.hv=Z2e,this.dv=void 0,this.vv=!1,this.Je=(()=>{var e,n;if(!No?.visibilityState||No.visibilityState==="visible")return!0;const o=Fn==null||(e=Fn.performance)===null||e===void 0||(n=e.getEntriesByType)===null||n===void 0?void 0:n.call(e,"visibility-state");return!o?.length||o.some(i=>i.name==="visible")})(),this.sn=()=>{var e,n;No?.visibilityState==="visible"&&(this.Je=!0,(e=this.uv)===null||e===void 0||(n=e.setDocumentWasEverVisible)===null||n===void 0||n.call(e,!0))},!this._instance.sessionManager)throw b8.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if(this.Mr.cookieless_mode==="always")throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');No?.addEventListener&&jc(No,"visibilitychange",this.sn)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:t=!1}={}){var e;this.vv=!0,No==null||(e=No.removeEventListener)===null||e===void 0||e.call(No,"visibilitychange",this.sn),t?this.fv(!0):this.stopRecording()}get pv(){var t;const e=!!(!((t=this._instance.get_property("$session_recording_remote_config"))===null||t===void 0)&&t.enabled),n=!this.Mr.disable_session_recording,o=this.Mr.disable_session_recording||this._instance.consent.isOptedOut();return Fn&&e&&n&&!o}startIfEnabledOrStop(t){var e;if(this.vv||this.pv&&(!((e=this.uv)===null||e===void 0)&&e.isStarted))return;const n=!Eo(Object.assign)&&!Eo(Array.from);this.pv&&n?(this.gv(t),b8.info("starting")):(this.hv=Z2e,this.stopRecording())}gv(t){var e,n;if(this.pv)if(this.hv!=="awaiting_config"&&this.hv!=="missing_config"&&(this.hv=oAt),(Ur==null||(e=Ur.__PosthogExtensions__)===null||e===void 0||(e=e.rrweb)===null||e===void 0?void 0:e.record)&&((n=Ur.__PosthogExtensions__)===null||n===void 0?void 0:n.initSessionRecording))this.mv(t);else{var o,i;const r=this._instance.sessionManager;(o=Ur.__PosthogExtensions__)===null||o===void 0||(i=o.loadExternalDependency)===null||i===void 0||i.call(o,this._instance,this.yv,s=>{if(!this.vv&&this.pv&&this._instance.sessionManager===r)return s?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),b8.error("could not load recorder",s)):void this.mv(t);this.hv="disabled"})}}stopRecording(){var t,e;(t=this.dv)===null||t===void 0||t.call(this),this.dv=void 0,(e=this.uv)===null||e===void 0||e.stop()}fv(t=!1){var e,n;(e=this.dv)===null||e===void 0||e.call(this),this.dv=void 0,(n=this.uv)===null||n===void 0||n.discard({discardProducerEvents:t})}bv(){var t,e;(t=this.Il)===null||t===void 0||t.unregister("$session_is_sampled"),(e=this.Il)===null||e===void 0||e.unregister("$replay_sample_rate")}_v(t,e){if(Fs(t))return null;const n=qd(t)?t:parseFloat(t);return typeof(o=n)!="number"||!Number.isFinite(o)||0>o||o>1?(b8.warn(`${e} must be between 0 and 1. Ignoring invalid value:`,t),null):n;var o}wv(t){if(this.Il){var e,n;const o=this.Il,i=()=>{var r;const s=t.sessionRecording===!1?void 0:t.sessionRecording,a=this._v((r=this.Mr.session_recording)===null||r===void 0?void 0:r.sampleRate,"session_recording.sampleRate"),A=this._v(s?.sampleRate,"remote config sampleRate"),c=a??A;Fs(c)&&this.bv();const l=s?.minimumDurationMilliseconds;o.register({[ZK]:sn(sn({cache_timestamp:Date.now(),enabled:!!s},s),{},{networkPayloadCapture:sn({capturePerformance:t.capturePerformance},s?.networkPayloadCapture),canvasRecording:{enabled:s?.recordCanvas,fps:s?.canvasFps,quality:s?.canvasQuality},sampleRate:c,minimumDurationMilliseconds:Eo(l)?null:l,endpoint:s?.endpoint,triggerMatchType:s?.triggerMatchType,masking:s?.masking,urlTriggers:s?.urlTriggers,version:s?.version,triggerGroups:s?.triggerGroups})})};i(),(e=this.dv)===null||e===void 0||e.call(this),this.dv=(n=this._instance.sessionManager)===null||n===void 0?void 0:n.onSessionId(i)}}onRemoteConfig(t){const e=t.ok?t.config:void 0;return e&&"sessionRecording"in e?e.sessionRecording===!1?(this.wv(e),void this.fv()):(this.wv(e),void this.startIfEnabledOrStop()):(this.hv==="awaiting_config"&&(this.hv="missing_config",this._instance.register_for_session({[d2e]:!0}),b8.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e="log"){var n;!((n=this.uv)===null||n===void 0)&&n.log?this.uv.log(t,e):b8.warn("log called before recorder was ready")}get yv(){var t,e;const n=(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0?void 0:t.get_property(ZK);return(n==null||(e=n.scriptConfig)===null||e===void 0?void 0:e.script)||"lazy-recorder"}Sv(){const t=this._instance.get_property(ZK);if(!t)return!1;let e;try{e=typeof t=="object"?t:JSON.parse(t)}catch(n){return b8.warn("persisted remote config for session recording is invalid and will be ignored",n),!1}return!Fs(e.cache_timestamp)&&36e5>=Date.now()-e.cache_timestamp}mv(t){var e,n,o;if(!this.vv&&this.pv&&this._instance.sessionManager){if(!(!((e=Ur.__PosthogExtensions__)===null||e===void 0)&&e.initSessionRecording))return b8.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[u2e]:!0});var i;if(this.uv||(this.uv=(i=Ur.__PosthogExtensions__)===null||i===void 0?void 0:i.initSessionRecording(this._instance,this.Je),this.uv._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Sv())return this.hv==="missing_config"||this.hv==="awaiting_config"?void 0:(this.hv="awaiting_config",b8.info("persisted remote config is stale, requesting fresh config before starting"),void new uat(this._instance).load());this.hv=oAt,(n=(o=this.uv).setDocumentWasEverVisible)===null||n===void 0||n.call(o,this.Je),this.uv.start(t)}else this.hv=Z2e}onRRwebEmit(t){var e,n;(e=this.uv)===null||e===void 0||(n=e.onRRwebEmit)===null||n===void 0||n.call(e,t)}overrideLinkedFlag(){var t,e;this.uv||(e=this.Il)===null||e===void 0||e.register({$replay_override_linked_flag:!0}),(t=this.uv)===null||t===void 0||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.uv||(e=this.Il)===null||e===void 0||e.register({$replay_override_sampling:!0}),(t=this.uv)===null||t===void 0||t.overrideSampling()}overrideTrigger(t){var e,n;this.uv||(n=this.Il)===null||n===void 0||n.register({[t==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(e=this.uv)===null||e===void 0||e.overrideTrigger(t)}get sdkDebugProperties(){var t;const e={};for(const o of F9n){var n;const i=(n=this._instance.sessionPersistence)===null||n===void 0?void 0:n.get_property(o);Eo(i)||(e[o]=i)}return sn(sn({},e),((t=this.uv)===null||t===void 0?void 0:t.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(t,e){var n;return!!(!((n=this.uv)===null||n===void 0)&&n.tryAddCustomEvent(t,e))}flushBeforeIdentityReset(){var t,e;(t=this.uv)===null||t===void 0||(e=t.flushBeforeIdentityReset)===null||e===void 0||e.call(t)}}},s7n={autocapture:class extends D9n{constructor(t){super(new N9n(t)),this.instance=t}},historyAutocapture:class{constructor(t){this.xv=!1,this._instance=t,this.$v=this.Cv()}initialize(){this.startIfEnabled()}get isEnabled(){const t=this.Tv();return!!(t.path||t.search||this.Iv(t))}startIfEnabled(){this.isEnabled&&(gi.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.$v=this.Cv(),this.startIfEnabled()}stop(){this.Mv&&this.Mv(),this.Mv=void 0,this.Ev&&this.Ev(),this.Ev=void 0,gi.info("History API monitoring stopped")}monitorHistoryChanges(){Fn&&Fn.history&&(this.Pv("pushState"),this.Pv("replaceState"),this.Rv(),this.Iv()&&this.Av())}Pv(t){var e;if(!Fn||!((e=Fn.history[t])===null||e===void 0)&&e.__posthog_wrapped__)return;const n=this;bV(Fn.history,t,o=>function(i,r,s){var a;n.Ov(s)&&n.Fv(),o.call(this,i,r,s),n.Dv(t,!n.xv&&(Fn==null||(a=Fn.event)===null||a===void 0?void 0:a.type)!=="popstate")})}Cv(){const t=Fn?.location;if(t?.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}Tv(){const t=this._instance.config.capture_pageview;return t==="history_change"?{path:!0}:xA(t)?t:{}}Iv(t=this.Tv()){return!!t.hash&&!this._instance.config.disable_capture_url_hashes}Lv(t){const e=this.Tv(),n=this.$v;return!(!n||!(e.path&&t.pathname!==n.pathname||e.search&&t.search!==n.search||this.Iv(e)&&t.hash!==n.hash))}Dv(t,e=!1){try{e||this.Fv();const n=this.Cv();if(!n)return;if(this.Lv(n)){const o=()=>this._instance.capture(p2e,{navigation_type:t});e?(this.Nv=o,Promise.resolve().then(()=>this.Fv())):o()}this.$v=n}catch(n){gi.error(`Error capturing ${t} pageview`,n)}}Ov(t){var e,n;return!(Fs(t)||!Fn)&&((e=x8(String(t)))===null||e===void 0?void 0:e.href)!==((n=Fn.location)===null||n===void 0?void 0:n.href)}Fv(){const t=this.Nv;if(t){this.Nv=void 0,this.xv=!0;try{t()}catch(e){gi.error("Error capturing deferred pageview",e)}finally{this.xv=!1}this.$v=this.Cv()}}Rv(){if(this.Mv)return;const t=()=>{this.Dv("popstate")};jc(Fn,"popstate",t),this.Mv=()=>{Fn&&Fn.removeEventListener("popstate",t)}}Av(){if(this.Ev)return;const t=()=>{this.Dv("hashchange")};jc(Fn,"hashchange",t),this.Ev=()=>{Fn&&Fn.removeEventListener("hashchange",t)}}},heatmaps:class{get Mr(){return this.instance.config}constructor(t){var e;this.qv=!1,this.ko=!1,this.jv=null,this.instance=t,this.qv=!!(!((e=this.instance.persistence)===null||e===void 0)&&e.props[t2e]),this.rageclicks=new $at(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let t=5e3;return xA(this.Mr.capture_heatmaps)&&this.Mr.capture_heatmaps.flush_interval_milliseconds&&(t=this.Mr.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return Fs(this.Mr.capture_heatmaps)?Fs(this.Mr.enable_heatmaps)?this.qv:this.Mr.enable_heatmaps:this.Mr.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.ko)return;L9n.info("starting..."),this.Bv(),this.sn()}else{var t;clearInterval((t=this.jv)!==null&&t!==void 0?t:void 0),this.Hv(),this.getAndClearBuffer()}}onRemoteConfig(t){if(!t.ok)return;const e=t.config;if(!("heatmaps"in e))return;const n=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[t2e]:n}),this.qv=n,this.startIfEnabled()}getAndClearBuffer(){const t=this.Rt;return this.Rt=void 0,t}zv(t){exe(t.originalEvent)&&this.Ir(t.originalEvent,"deadclick")}sn(){this.jv&&clearInterval(this.jv),this.jv=No?.visibilityState==="visible"?setInterval(this.yl.bind(this),this.flushIntervalMilliseconds):null}Bv(){Fn&&No&&(this.Uv=this.yl.bind(this),jc(Fn,nne,this.Uv),this.Wv=t=>this.Ir(t||Fn?.event),jc(No,"click",this.Wv,{capture:!0}),this.Vv=t=>this.Gv(t||Fn?.event),jc(No,"mousemove",this.Vv,{capture:!0}),this.Qv=new zst(this.instance,LBn,this.zv.bind(this)),this.Qv.startIfEnabledOrStop(),this.Jv=this.sn.bind(this),jc(No,iV,this.Jv),this.ko=!0)}Hv(){var t;Fn&&No&&(this.Uv&&Fn.removeEventListener(nne,this.Uv),this.Wv&&No.removeEventListener("click",this.Wv,{capture:!0}),this.Vv&&No.removeEventListener("mousemove",this.Vv,{capture:!0}),this.Jv&&No.removeEventListener(iV,this.Jv),clearTimeout(this.Zv),(t=this.Qv)===null||t===void 0||t.stop(),this.ko=!1)}Kv(t,e){const n=this.instance.scrollManager.scrollY(),o=this.instance.scrollManager.scrollX(),i=this.instance.scrollManager.scrollElement(),r=(function(s,a,A){let c=s;for(;c&&b9(c)&&!j1(c,"body");){if(c===A)return!1;let h;try{var l,g,u;h=(l=(g=(u=c.ownerDocument)===null||u===void 0?void 0:u.defaultView)!==null&&g!==void 0?g:Fn)===null||l===void 0?void 0:l.getComputedStyle(c).position}catch{return!1}if(as(a,h))return!0;c=Nst(c)}return!1})(AV(t),["fixed","sticky"],i);return{x:t.clientX+(r?0:o),y:t.clientY+(r?0:n),target_fixed:r,type:e}}Ir(t,e="click"){var n;if(wst(t.target)||!exe(t))return;const o=this.Kv(t,e);!((n=this.rageclicks)===null||n===void 0)&&n.isRageClick(t.clientX,t.clientY,new Date().getTime())&&Fst(AV(t),this.instance.config.rageclick)&&this.Qs(sn(sn({},o),{},{type:"rageclick"})),this.Qs(o)}Gv(t){!wst(t.target)&&exe(t)&&(clearTimeout(this.Zv),this.Zv=setTimeout(()=>{this.Qs(this.Kv(t,"mousemove"))},500))}Qs(t){if(!Fn)return;const e=this.Mr.disable_capture_url_hashes?AQ(Fn.location.href):Fn.location.href,n=this.Mr.custom_personal_data_properties,o=this.Mr.mask_personal_data_properties?[...Ok,...n||[]]:[],i=dV(e,o,hV);this.Rt=this.Rt||{},this.Rt[i]||(this.Rt[i]=[]),this.Rt[i].push(t)}yl(){this.Rt&&!ox(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:zst,webVitalsAutocapture:class{constructor(t){var e;this._instance=t,this.qv=!1,this.ko=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Xv=()=>{clearTimeout(this.Yv),this.Yv=void 0,this.Rt.metrics.length!==0&&(this._instance.capture("$web_vitals",sn({$current_url:this.Rt.url},this.Rt.metrics.reduce((n,o)=>sn(sn({},n),{},{[`$web_vitals_${o.name}_event`]:sn({},o),[`$web_vitals_${o.name}_value`]:o.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.tf=n=>{var o;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},Fs(n?.name)||Fs(n?.value))return void HM.error("Invalid metric received",n);const i=typeof n.navigationURL=="string"?n.navigationURL:void 0,r=this.ef(i);if(Eo(r))return;const s=qd(n.navigationId)||typeof n.navigationId=="string"?`navigation:${n.navigationId}`:`url:${r}`;if(this.if&&n.value>=this.if)return void HM.error("Ignoring metric with value >= "+this.if,n);this.Rt.navigationKey!==s&&(this.Xv(),this.Yv=setTimeout(this.Xv,this.flushToCaptureTimeoutMs)),Eo(this.Rt.navigationKey)&&(this.Rt.navigationKey=s,this.Rt.url=r),this.Rt.firstMetricTimestamp=Eo(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;const a=(o=this._instance.sessionManager)===null||o===void 0?void 0:o.checkAndGetSessionAndWindowId(!0),A=sn(sn(sn({},n),i?{navigationURL:r}:{}),{},{$current_url:r,timestamp:Date.now()});if(delete A.entries,xA(n.attribution)&&this.attributionMetrics.indexOf(n.name)>-1){const c={};for(const l of k9n){const g=l==="url"&&typeof n.attribution[l]=="string"?this.ef(n.attribution[l]):n.attribution[l];Eo(g)||(c[l]=g)}A.attribution=c}else delete A.attribution;Eo(a)||(A.$session_id=a.sessionId,A.$window_id=a.windowId),this.Rt.metrics.push(A),this.Rt.metrics.length===this.allowedMetrics.length&&this.Xv()},this.nf=()=>{if(this.ko)return;let n,o,i,r,s=!1;const a=Ur.__PosthogExtensions__,A=a?.postHogWebVitalsCallbacksByFlavor,c=A?.[this.sf]||(this.sf==="web-vitals"&&Eo(A)?a?.postHogWebVitalsCallbacks:void 0);if(!Eo(c)){const u=c.withoutAttribution,h=this.attributionMetrics;s=!Eo(u),n=h.indexOf("LCP")>-1?c.onLCP:u?.onLCP||c.onLCP,o=h.indexOf("CLS")>-1?c.onCLS:u?.onCLS||c.onCLS,i=h.indexOf("FCP")>-1?c.onFCP:u?.onFCP||c.onFCP,r=h.indexOf("INP")>-1?c.onINP:u?.onINP||c.onINP}if(!(n&&o&&i&&r))return void HM.error("web vitals callbacks not loaded - not starting");const l={reportSoftNavs:this.useSoftNavs},g=s&&this.attributionMetrics.indexOf("INP")>-1?sn(sn({},l),{},{includeProcessedEventEntries:!1}):l;this.allowedMetrics.indexOf("LCP")>-1&&n(this.tf.bind(this),l),this.allowedMetrics.indexOf("CLS")>-1&&o(this.tf.bind(this),l),this.allowedMetrics.indexOf("FCP")>-1&&i(this.tf.bind(this),l),this.allowedMetrics.indexOf("INP")>-1&&r(this.tf.bind(this),g),this.ko=!0},this.qv=!!(!((e=this._instance.persistence)===null||e===void 0)&&e.props[i2e]),this.startIfEnabled()}get rf(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e;const n=xA(this.rf)?(t=this.rf)===null||t===void 0?void 0:t.web_vitals_allowed_metrics:void 0;return Fs(n)?((e=this._instance.persistence)===null||e===void 0?void 0:e.props.$web_vitals_allowed_metrics)||nAt:n}get flushToCaptureTimeoutMs(){return(xA(this.rf)?this.rf.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const t=xA(this.rf)?this.rf.web_vitals_attribution:void 0;return py(t)?t?nAt:[]:As(t)?t:T9n}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const t=xA(this.rf)?this.rf.__preview_web_vitals_soft_navs:void 0;return t!=null&&t}get if(){const t=xA(this.rf)&&qd(this.rf.__web_vitals_max_value)?this.rf.__web_vitals_max_value:tAt;return t>0&&6e4>=t?tAt:t}get isEnabled(){const t=sd?.protocol;if(t!=="http:"&&t!=="https:")return HM.info("Web Vitals are disabled on non-http/https protocols"),!1;const e=xA(this.rf)?this.rf.web_vitals:py(this.rf)?this.rf:void 0;return py(e)?e:this.qv}startIfEnabled(){this.isEnabled&&!this.ko&&(HM.info("enabled, starting..."),this.Ho(this.nf))}onRemoteConfig(t){if(!t.ok)return;const e=t.config;if(!("capturePerformance"in e))return;const n=xA(e.capturePerformance)&&!!e.capturePerformance.web_vitals,o=xA(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[i2e]:n}),this._instance.persistence.register({[est]:o})),this.qv=n,this.startIfEnabled()}get sf(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Ho(t){var e;const n=Ur.__PosthogExtensions__,o=this.sf,i=n?.postHogWebVitalsCallbacksByFlavor;i?.[o]||o==="web-vitals"&&Eo(i)&&n?.postHogWebVitalsCallbacks?t():n==null||(e=n.loadExternalDependency)===null||e===void 0||e.call(n,this._instance,o,r=>{r?HM.error("failed to load script",r):t()})}ef(t){const e=t||Fn?.location.href;if(!e)return void HM.error("Could not determine current URL");const n=this._instance.config.disable_capture_url_hashes?AQ(e):e,o=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...Ok,...o||[]]:[];return dV(n,i,hV)}}},a7n={exceptionObserver:class{constructor(t){var e;this.nf=()=>{var n;if(!Fn||!this.isEnabled||!(!((n=Ur.__PosthogExtensions__)===null||n===void 0)&&n.errorWrappingFunctions))return;const o=Ur.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Ur.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=Ur.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.af&&this.Mr.capture_unhandled_errors&&(this.af=o(this.captureException.bind(this))),!this.lf&&this.Mr.capture_unhandled_rejections&&(this.lf=i(this.captureException.bind(this))),!this.uf&&this.Mr.capture_console_errors&&(this.uf=r(this.captureException.bind(this)))}catch(s){BV.error("failed to start",s),this.hf()}},this._instance=t,this.cf=!!(!((e=this._instance.persistence)===null||e===void 0)&&e.props[n2e]),this.wt=new i4n(sn(sn({},(function(n={}){var o,i,r,s;return{refillRate:(o=(i=n.exceptionRateLimiterRefillRate)!==null&&i!==void 0?i:n.__exceptionRateLimiterRefillRate)!==null&&o!==void 0?o:1,bucketSize:(r=(s=n.exceptionRateLimiterBucketSize)!==null&&s!==void 0?s:n.__exceptionRateLimiterBucketSize)!==null&&r!==void 0?r:10}})(this._instance.config.error_tracking)),{},{refillInterval:1e4,A:BV})),this.Mr=this.df(),this.startIfEnabledOrStop()}df(){const t=this._instance.config.capture_exceptions;let e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return xA(t)?e=sn(sn({},e),t):(Eo(t)?this.cf:t)&&(e=sn(sn({},e),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Mr.capture_console_errors||this.Mr.capture_unhandled_errors||this.Mr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(BV.info("enabled"),this.hf(),this.Ho(this.nf)):this.hf()}Ho(t){var e,n,o;!((e=Ur.__PosthogExtensions__)===null||e===void 0)&&e.errorWrappingFunctions?t():(n=Ur.__PosthogExtensions__)===null||n===void 0||(o=n.loadExternalDependency)===null||o===void 0||o.call(n,this._instance,"exception-autocapture",i=>{if(i)return BV.error("failed to load script",i);t()})}hf(){var t,e,n;(t=this.af)===null||t===void 0||t.call(this),this.af=void 0,(e=this.lf)===null||e===void 0||e.call(this),this.lf=void 0,(n=this.uf)===null||n===void 0||n.call(this),this.uf=void 0}onRemoteConfig(t){if(!t.ok)return;const e=t.config;"autocaptureExceptions"in e&&(this.cf=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[n2e]:this.cf}),this.Mr=this.df(),this.startIfEnabledOrStop())}onConfigChange(){this.Mr=this.df()}captureException(t){try{var e,n,o;const i=(e=t==null||(n=t.$exception_list)===null||n===void 0||(n=n[0])===null||n===void 0?void 0:n.type)!==null&&e!==void 0?e:"Exception";if(this.wt.consumeRateLimit(i))return void BV.info("Skipping exception capture because of client rate limiting.",{exception:i});(o=this._instance.exceptions)===null||o===void 0||o.sendExceptionEvent(t)}catch{}}},exceptions:class{constructor(t){var e,n;this.vf=[],this.ff=new m4n([new M4n,new O4n,new N4n,new D4n,new L4n,new F4n,new T4n,new H4n],(function(o,...i){return(r,s=0)=>{const a=[],A=r.split(`
|
|
241
241
|
`),c=Math.min(A.length,s+1e3),l=[];for(let h=s;c>h;h++){const d=A[h];if(d.length>1024)continue;const p=Ert.test(d)?d.replace(Ert,"$1"):d;if(!p.match(/\S*Error: /)){for(const m of i){const _=m(p,o);if(_){a.push(_);const f=Q4n(a);if(f){for(let I=l.length-1;I>=0;I--){const C=l[I];if(f.start>=C.start+C.length)break;l.pop()}l.push(f)}break}}if(w4n(a,l)>=50)break}}const g=[...l].sort((h,d)=>d.start-h.start),u=g[g.length-1];if(u){const h=Brt(a,u);a.splice(u.start-h,h);for(const d of g)d.start-=h}for(const h of g)v4n(a,h);return l.some(h=>h.start===0&&a.length===h.length)&&(function(h){const d=h.map(m=>`${m.function}|${m.filename}|${m.lineno}|${m.colno}|${m.module}`);let p=0;for(let m=1;d.length>m;m++)P4n(d,m,p)&&(p=m);h.push(...h.splice(0,p))})(a),(function(h){if(!h.length)return[];const d=Array.from(h);return d.reverse(),d.slice(0,50).map(p=>{return sn(sn({},p),{},{filename:p.filename||(m=d,m[m.length-1]||{}).filename,function:p.function||"?"});var m})})(a)}})("web:javascript",E4n,S4n)),this._instance=t,this.vf=(e=(n=this._instance.persistence)===null||n===void 0?void 0:n.get_property("$error_tracking_suppression_rules"))!==null&&e!==void 0?e:[],this.pf=jte(this.gf()),this.mf=new Y4n(this.pf)}onConfigChange(){this.pf=jte(this.gf()),this.mf.setConfig(this.pf)}onRemoteConfig(t){var e,n,o;if(!t.ok)return;const i=t.config;if(!("errorTracking"in i))return;const r=(e=(n=i.errorTracking)===null||n===void 0?void 0:n.suppressionRules)!==null&&e!==void 0?e:[],s=(o=i.errorTracking)===null||o===void 0?void 0:o.captureExtensionExceptions;this.vf=r,this._instance.persistence&&this._instance.persistence.register({[$rt]:this.vf,[o2e]:s})}get yf(){var t;const e=!!this._instance.get_property(o2e),n=this._instance.config.error_tracking.captureExtensionExceptions;return(t=n??e)!==null&&t!==void 0&&t}buildProperties(t,e){return this.ff.buildFromUnknown(t,{syntheticException:e?.syntheticException,mechanism:{handled:e?.handled}})}addExceptionStep(t,e){if(this.pf.enabled)try{if(!nA(t)||t.trim().length===0)return void L4.warn("Ignoring exception step because message must be a non-empty string");const{sanitizedProperties:n,droppedKeys:o}=(function(i){if(!i)return{sanitizedProperties:{},droppedKeys:[]};const r=[];return{sanitizedProperties:Object.keys(i).reduce((s,a)=>G4n.has(a)?(r.push(a),s):(s[a]=i[a],s),{}),droppedKeys:r}})(this.bf(e));o.length>0&&L4.warn("Ignoring reserved exception step fields",{droppedKeys:o}),this.mf.add(sn({[Jte]:t,[Wte]:new Date().toISOString()},n))}catch(n){L4.error("Failed to add exception step. Ignoring breadcrumb.",n)}}sendExceptionEvent(t){try{const e=t.$exception_list;if(this._f(e)){if(this.wf(e))return this.kf("Exception dropped: matched a suppression rule"),void L4.info("Skipping exception capture because a suppression rule matched");if(!this.yf&&this.Sf(e))return this.kf("Exception dropped: thrown by a browser extension"),void L4.info("Skipping exception capture because it was thrown by an extension");if(!this.yf&&this.xf(e))return this.kf("Exception dropped: thrown by an injected browser script"),void L4.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.$f(e))return this.kf("Exception dropped: thrown by the PostHog SDK"),void L4.info("Skipping exception capture because it was thrown by the PostHog SDK")}const n=this.pf.enabled&&Fs(t.$exception_steps)?this.Cf(t):t,o=(function(){const i=globalThis._posthogReleaseId;return typeof i=="string"&&i.length>0?i:void 0})();o&&(n.$release_id=o);try{const i=this._instance.capture("$exception",n,{_noTruncate:!0,_batchKey:"exceptionEvent",gh:!0});return i&&this.mf.clear(),i}catch(i){return pAt(i)||L4.error("Failed to capture exception event. Dropping this exception.",i),void this.mf.clear()}}catch(e){return void(pAt(e)||L4.error("Failed to process exception event. Ignoring this exception.",e))}}Cf(t){try{const e=this.mf.getAttachable();return e.length===0?t:sn(sn({},t),{},{$exception_steps:e})}catch(e){return L4.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}kf(t){this.pf.enabled&&this.mf.add({[Jte]:t,[Wte]:new Date().toISOString()})}bf(t){return xA(t)?sn({},t):{}}gf(){var t,e;return(t=(e=this._instance.config.error_tracking)===null||e===void 0?void 0:e.exception_steps)!==null&&t!==void 0?t:{}}wf(t){if(t.length===0)return!1;try{const e=t.reduce((n,{type:o,value:i})=>(nA(o)&&o.length>0&&n.$exception_types.push(o),nA(i)&&i.length>0&&n.$exception_values.push(i),n),{$exception_types:[],$exception_values:[]});return this.vf.some(n=>{const o=n.values.map(i=>{const r=Oat[i.operator],s=e[i.key];if(!r||!s)return!1;const a=As(i.value)?i.value:[i.value];return a.length>0&&r(a,s)});return n.type==="OR"?o.some(Boolean):o.every(Boolean)})}catch(e){return L4.warn("Failed to evaluate suppression rules. Capturing the exception.",e),!1}}Sf(t){const e=t.flatMap(o=>{var i,r;return(i=(r=o.stacktrace)===null||r===void 0?void 0:r.frames)!==null&&i!==void 0?i:[]}),n=e.filter(({filename:o})=>!!o&&X9n.some(i=>o.startsWith(i)));return n.length!==0&&(!n.every(({filename:o})=>!!o&&o.startsWith(oxe))||t.some(({type:o,value:i})=>o==="NoResponse"||nA(i)&&j9n.some(({value:r,exact:s})=>s?i===r:i.includes(r)))&&!e.some(({in_app:o,filename:i})=>o&&!i?.startsWith(oxe)))}xf(t){return t.some(({value:e})=>nA(e)&&q9n.some(n=>e.includes(n)))}$f(t){if(t.length>0){var e,n,o,i;const r=(e=(n=t[0].stacktrace)===null||n===void 0?void 0:n.frames)!==null&&e!==void 0?e:[],s=r[r.length-1];return(o=s==null||(i=s.filename)===null||i===void 0?void 0:i.includes("posthog.com/static"))!==null&&o!==void 0&&o}return!1}_f(t){return!Fs(t)&&As(t)}}},A7n=sn({productTours:class{get Il(){return this._instance.persistence}constructor(t){this.Tf=null,this.If=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!t.ok)return;const e=t.config;if("productTours"in e){var n,o;if(this.Il&&this.Il.register({[s2e]:!!e.productTours}),!txe(this._instance))return!this.Tf&&Fs((n=this.Il)===null||n===void 0?void 0:n.props.ph_product_tours)||mne.info("product tours disabled; stopping and clearing cached tours"),(o=this.Tf)===null||o===void 0||o.stop(),this.Tf=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.Tf&&txe(this._instance)&&this.Ho(()=>this.Mf())}Ho(t){var e,n,o;!((e=Ur.__PosthogExtensions__)===null||e===void 0)&&e.generateProductTours?t():(n=Ur.__PosthogExtensions__)===null||n===void 0||(o=n.loadExternalDependency)===null||o===void 0||o.call(n,this._instance,"product-tours",i=>{i?mne.error("Could not load product tours script",i):t()})}Mf(){var t;!this.Tf&&(!((t=Ur.__PosthogExtensions__)===null||t===void 0)&&t.generateProductTours)&&(this.Tf=Ur.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e=!1){if(As(this.If)&&!e)return void t(this.If,{isLoaded:!0});const n=this.Il;if(n){const o=n.props[A2e];if(As(o)&&!e)return this.If=o,void t(o,{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:o=>{if(!txe(this._instance))return void t([],{isLoaded:!0});const i=o.statusCode;if(i!==200||!o.json){const s=`Product Tours API could not be loaded, status: ${i}`;return i===0?o.error||mne.warn(s):mne.error(s),void t([],{isLoaded:!1,error:s})}const r=As(o.json.product_tours)?o.json.product_tours:[];this.If=r,n&&n.register({[A2e]:r}),t(r,{isLoaded:!0})}})}getActiveProductTours(t){Fs(this.Tf)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Tf.getActiveProductTours(t)}showProductTour(t){var e;(e=this.Tf)===null||e===void 0||e.showTourById(t)}previewTour(t){this.Tf?this.Tf.previewTour(t):this.Ho(()=>{var e;this.Mf(),(e=this.Tf)===null||e===void 0||e.previewTour(t)})}dismissProductTour(){var t;(t=this.Tf)===null||t===void 0||t.dismissTour("user_clicked_skip")}nextStep(){var t;(t=this.Tf)===null||t===void 0||t.nextStep()}previousStep(){var t;(t=this.Tf)===null||t===void 0||t.previousStep()}clearCache(){var t;this.If=null,(t=this.Il)===null||t===void 0||t.unregister("ph_product_tours")}resetTour(t){var e;(e=this.Tf)===null||e===void 0||e.resetTour(t)}resetAllTours(){var t;(t=this.Tf)===null||t===void 0||t.resetAllTours()}cancelPendingTour(t){var e;(e=this.Tf)===null||e===void 0||e.cancelPendingTour(t)}}},fne),c7n={siteApps:class{constructor(t){this._instance=t,this.Ef=0,this.Pf=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Rf(t,e){if(!e)return;const n=this.globalsForEvent(e);this.Pf.push(n),this.Pf.length>1e3&&(this.Pf=this.Pf.slice(10))}get siteAppLoaders(){var t;return(t=Ur._POSTHOG_REMOTE_CONFIG)===null||t===void 0||(t=t[this._instance.config.token])===null||t===void 0?void 0:t.siteApps}initialize(){if(this.isEnabled){const t=this._instance._addCaptureHook(this.Rf.bind(this));this.Af=()=>{t(),this.Pf=[],this.Af=void 0}}}globalsForEvent(t){var e,n,o,i,r,s,a;if(!t)throw new Error("Event payload is required");const A={},c=this._instance.get_property("$groups")||[],l=this._instance.get_property("$stored_group_properties")||{};for(const[h,d]of Object.entries(l))A[h]={id:c[h],type:h,properties:d};const{$set_once:g,$set:u}=t;return{event:sn(sn({},Rrt(t,H9n)),{},{properties:sn(sn(sn({},t.properties),u?{$set:sn(sn({},(e=(n=t.properties)===null||n===void 0?void 0:n.$set)!==null&&e!==void 0?e:{}),u)}:{}),g?{$set_once:sn(sn({},(o=(i=t.properties)===null||i===void 0?void 0:i.$set_once)!==null&&o!==void 0?o:{}),g)}:{}),elements_chain:(r=(s=t.properties)===null||s===void 0?void 0:s.$elements_chain)!==null&&r!==void 0?r:"",distinct_id:(a=t.properties)===null||a===void 0?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:A}}Of(t){var e;const n=(e=t.tagName)===null||e===void 0?void 0:e.toLowerCase();return n==="style"&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(S9.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)||(S9.error("prepare_external_dependency_script returned null"),null):t}Ff(){var t,e,n,o,i,r,s,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};const A=No?.defaultView,c=A==null||(t=A.Node)===null||t===void 0?void 0:t.prototype;if(!A||!c)return()=>{};if(this.Ef++,this.Df)return this.Lf();const l=[],g=this,u=new WeakSet,h=(m,_,f)=>{if(!m?.[_])return;const I=m[_];m[_]=f(I),l.push(()=>{m[_]=I})},d=m=>{if(u.has(m))return m;const _=g.Of(m);return _&&u.add(_),_},p=m=>m.map(_=>typeof _=="string"?_:d(_)).filter(_=>!ad(_));return h(c,"appendChild",m=>function(_){const f=d(_);return f?m.call(this,f):_}),h(c,"insertBefore",m=>function(_,f){const I=d(_);return I?m.call(this,I,f):_}),h(c,"replaceChild",m=>function(_,f){const I=d(_);return I?m.call(this,I,f):f}),[(e=A.Element)===null||e===void 0?void 0:e.prototype,(n=A.Document)===null||n===void 0?void 0:n.prototype,(o=A.DocumentFragment)===null||o===void 0?void 0:o.prototype].forEach(m=>{h(m,"append",_=>function(...f){return _.apply(this,p(f))}),h(m,"prepend",_=>function(...f){return _.apply(this,p(f))})}),[(i=A.Element)===null||i===void 0?void 0:i.prototype,(r=A.CharacterData)===null||r===void 0?void 0:r.prototype,(s=A.DocumentType)===null||s===void 0?void 0:s.prototype].forEach(m=>{h(m,"before",_=>function(...f){return _.apply(this,p(f))}),h(m,"after",_=>function(...f){return _.apply(this,p(f))}),h(m,"replaceWith",_=>function(...f){const I=p(f);return f.length&&!I.length?void 0:_.apply(this,I)})}),h((a=A.Element)===null||a===void 0?void 0:a.prototype,"insertAdjacentElement",m=>function(_,f){const I=d(f);return I?m.call(this,_,I):null}),this.Df=()=>{l.forEach(m=>m()),this.Df=void 0},this.Lf()}Lf(){let t=!1;return()=>{var e;t||(t=!0,this.Ef--,this.Ef===0&&((e=this.Df)===null||e===void 0||e.call(this)))}}Nf(t,e=!0){const n=this.Ff();try{const o=t(n);return e&&n(),o}catch(o){throw n(),o}}setupSiteApp(t){const e=this.apps[t.id],n=()=>{var r;!e.errored&&this.Pf.length&&(S9.info(`Processing ${this.Pf.length} events for site app with id ${t.id}`),this.Pf.forEach(s=>this.Nf(()=>{var a;return(a=e.processEvent)===null||a===void 0?void 0:a.call(e,s)})),e.processedBuffer=!0),Object.values(this.apps).every(s=>s.processedBuffer||s.errored)&&((r=this.Af)===null||r===void 0||r.call(this))};let o=!1;const i=r=>{e.errored=!r,e.loaded=!0,S9.info(`Site app with id ${t.id} ${r?"loaded":"errored"}`),o&&n()};try{const{processEvent:r}=this.Nf(s=>t.init({posthog:this._instance,callback(a){s(),i(a)}}),!1);r&&(e.processEvent=r),o=!0}catch(r){S9.error(iAt+t.id,r),i(!1)}if(o&&e.loaded)try{n()}catch(r){S9.error(`Error while processing buffered events PostHog app with config id ${t.id}`,r),e.errored=!0}}qf(){const t=this.siteAppLoaders||[];for(const e of t)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(const e of t)this.setupSiteApp(e)}jf(t){if(Object.keys(this.apps).length===0)return;const e=this.globalsForEvent(t);for(const n of Object.values(this.apps))try{this.Nf(()=>{var o;return(o=n.processEvent)===null||o===void 0?void 0:o.call(n,e)})}catch(o){S9.error(`Error while processing event ${t.event} for site app ${n.id}`,o)}}onRemoteConfig(t){var e,n,o;if(!((e=this.siteAppLoaders)===null||e===void 0)&&e.length)return this.isEnabled?(this.qf(),void this._instance.on("eventCaptured",a=>this.jf(a))):void S9.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((n=this.Af)===null||n===void 0||n.call(this),!t.ok)return;const i=t.config;if(!((o=i.siteApps)===null||o===void 0)&&o.length)if(this.isEnabled)for(const{id:a,url:A}of i.siteApps){var r,s;Ur[`__$$ph_site_app_${a}`]=this._instance,(r=Ur.__PosthogExtensions__)===null||r===void 0||(s=r.loadSiteApp)===null||s===void 0||s.call(r,this._instance,A,c=>{if(c)return S9.error(iAt+a,c)})}else S9.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},l7n={tracingHeaders:class{constructor(t){this._instance=t,this.Bf=void 0,this.Hf=void 0,this.zf=void 0,this.nf=()=>{const e=this.Uf();var n,o;e?(Eo(this.Bf)&&(this.Bf=(n=Ur.__PosthogExtensions__)===null||n===void 0||(n=n.tracingHeadersPatchFns)===null||n===void 0?void 0:n._patchXHR(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),Eo(this.Hf)&&(this.Hf=(o=Ur.__PosthogExtensions__)===null||o===void 0||(o=o.tracingHeadersPatchFns)===null||o===void 0?void 0:o._patchFetch(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.hf()}}initialize(){this.startIfEnabledOrStop()}Ho(t){var e,n,o;!((e=Ur.__PosthogExtensions__)===null||e===void 0)&&e.tracingHeadersPatchFns?t():(n=Ur.__PosthogExtensions__)===null||n===void 0||(o=n.loadExternalDependency)===null||o===void 0||o.call(n,this._instance,"tracing-headers",i=>{if(i)return R9n.error("failed to load script",i);t()})}Wf(){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}Uf(){const t=this.Wf();return As(t)?(As(this.zf)?this.zf.splice(0,this.zf.length,...t):this.zf=[...t],t.length>0?this.zf:void 0):(As(this.zf)&&this.zf.splice(0),this.zf=t||void 0,this.zf)}hf(){var t,e;(t=this.Bf)===null||t===void 0||t.call(this),(e=this.Hf)===null||e===void 0||e.call(this),this.Bf=void 0,this.Hf=void 0}startIfEnabledOrStop(){this.Uf()?this.Ho(this.nf):this.hf()}}},g7n=sn({surveys:class extends O9n{constructor(t){var e;super(new V9n(t),(e=t,{get projectToken(){return e.config.token},kv:new K9n(e)})),this._instance=t}Qh(t,e){const n=e.query?IV(t,e.query):t;return new Promise(o=>{var i;this._instance._send_request({method:e.method,url:this._instance.requestRouter.endpointFor((i=e.target)!==null&&i!==void 0?i:"api",n),data:e.body,headers:e.headers,timeout:e.timeoutMs,fireCallbackOnDrop:!0,transport:e.transport,compression:e.compression,timestampMode:e.sentAt,callback:o})})}}},fne),u7n={toolbar:class{constructor(t){this.instance=t}Vf(t){Ur.ph_toolbar_state=t}Gf(){var t;return(t=Ur.ph_toolbar_state)!==null&&t!==void 0?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t=void 0,e=void 0,n=void 0){var o,i;if(_2e(this.instance.config)||!Fn||!No)return!1;t=(o=t)!==null&&o!==void 0?o:Fn.location,n=(i=n)!==null&&i!==void 0?i:Fn.history;try{if(!e){try{Fn.localStorage.setItem("test","test"),Fn.localStorage.removeItem("test")}catch{return!1}e=Fn?.localStorage}const r=z9n||sne(t.hash,"__posthog")||sne(t.hash,"state");let s;const a=r?mrt(()=>JSON.parse(atob(decodeURIComponent(r))))||mrt(()=>JSON.parse(decodeURIComponent(r))):null;return a&&a.action==="ph_authorize"?(s=a,s.source="url",s&&Object.keys(s).length>0&&(a.desiredHash?t.hash=a.desiredHash:n?n.replaceState(n.state,"",t.pathname+t.search):t.hash="")):(s=JSON.parse(e.getItem(aAt)||"{}"),s.source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token||(this.loadToolbar(s),0))}catch{return!1}}Qf(t){const e=Ur.ph_load_toolbar||Ur.ph_load_editor;!Fs(e)&&L_(e)?e(t,this.instance):AAt.warn("No toolbar load function found")}loadToolbar(t){const e=!!No?.getElementById("__POSTHOG_TOOLBAR__");if(!Fn||e)return!1;const n=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,o=sn(sn({token:this.instance.config.token},t),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},n?{instrument:!1}:{});if(Fn.localStorage.setItem(aAt,JSON.stringify(sn(sn({},o),{},{source:void 0}))),this.Gf()===2)this.Qf(o);else if(this.Gf()===0){var i,r;this.Vf(1),(i=Ur.__PosthogExtensions__)===null||i===void 0||(r=i.loadExternalDependency)===null||r===void 0||r.call(i,this.instance,"toolbar",s=>{if(s)return AAt.error("[Toolbar] Failed to load",s),void this.Vf(0);this.Vf(2),this.Qf(o)}),jc(Fn,"turbolinks:load",()=>{this.Vf(0),this.loadToolbar(o)})}return!0}Jf(t){return this.loadToolbar(t)}maybeLoadEditor(t=void 0,e=void 0,n=void 0){return this.maybeLoadToolbar(t,e,n)}}},d7n=sn({experiments:class tx{get Mr(){return this._instance.config}constructor(e){this._instance=e,this.getWebExperimentsAndEvaluateDisplayLogic=(n=!1)=>{this.getWebExperiments(o=>{tx.Zf("retrieved web experiments from the server"),this.Kf=new Map,o.forEach(i=>{if(i.feature_flag_key){var r;this.Kf&&(tx.Zf("setting flag key ",i.feature_flag_key," to web experiment ",i),(r=this.Kf)===null||r===void 0||r.set(i.feature_flag_key,i));const s=this._instance.getFeatureFlag(i.feature_flag_key);nA(s)&&i.variants[s]&&this.Xf(i.name,s,i.variants[s].transforms)}else if(i.variants)for(const s in i.variants){const a=i.variants[s];tx.Yf(a,this._instance)&&this.Xf(i.name,s,a.transforms)}})},n)},this._instance.onFeatureFlags(n=>{this.onFeatureFlags(n)})}initialize(){}onFeatureFlags(e){if(this._is_bot())tx.Zf(mAt);else if(!this.Mr.disable_web_experiments){if(Fs(this.Kf))return this.Kf=new Map,this.loadIfEnabled(),void this.previewWebExperiment();tx.Zf("applying feature flags",e),e.forEach(n=>{var o;if(this.Kf&&(!((o=this.Kf)===null||o===void 0)&&o.has(n))){var i;const r=this._instance.getFeatureFlag(n),s=(i=this.Kf)===null||i===void 0?void 0:i.get(n);r&&s?.variants[r]&&this.Xf(s.name,r,s.variants[r].transforms)}})}}previewWebExperiment(){const e=tx.getWindowLocation();if(e?.search){const n=Hk(e?.search,"__experiment_id"),o=Hk(e?.search,"__experiment_variant");n&&o&&(tx.Zf(`previewing web experiments ${n} && ${o}`),this.getWebExperiments(i=>{this.tp(parseInt(n),o,i)},!1,!0))}}loadIfEnabled(){this.Mr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,n,o){if(this.Mr.disable_web_experiments&&!o)return e([]);const i=this._instance.get_property("$web_experiments");if(i&&!n)return e(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/web_experiments/?token=${this.Mr.token}`),method:"GET",timestampMode:"query",callback:r=>e(r.statusCode===200&&r.json&&r.json.experiments||[])})}tp(e,n,o){const i=o.filter(r=>r.id===e);i&&i.length>0&&(tx.Zf(`Previewing web experiment [${i[0].name}] with variant [${n}]`),this.Xf(i[0].name,n,i[0].variants[n].transforms))}static Yf(e,n){return!Fs(e.conditions)&&tx.ep(e,n)&&tx.np(e)}static ep(e,n){var o;if(Fs(e.conditions)||Fs((o=e.conditions)===null||o===void 0?void 0:o.url))return!0;const i=tx.getWindowLocation();if(i){var r,s,a;const A=vst(n,i.href);return!(!((r=e.conditions)===null||r===void 0)&&r.url)||$9n[(s=(a=e.conditions)===null||a===void 0?void 0:a.urlMatchType)!==null&&s!==void 0?s:"icontains"](e.conditions.url,A)}return!1}static getWindowLocation(){return Fn?.location}static np(e){var n;if(Fs(e.conditions)||Fs((n=e.conditions)===null||n===void 0?void 0:n.utm))return!0;const o=Zst();if(o.utm_source){var i,r,s,a,A,c,l,g;const u=!(!((i=e.conditions)===null||i===void 0||(i=i.utm)===null||i===void 0)&&i.utm_campaign)||((r=e.conditions)===null||r===void 0||(r=r.utm)===null||r===void 0?void 0:r.utm_campaign)==o.utm_campaign,h=!(!((s=e.conditions)===null||s===void 0||(s=s.utm)===null||s===void 0)&&s.utm_source)||((a=e.conditions)===null||a===void 0||(a=a.utm)===null||a===void 0?void 0:a.utm_source)==o.utm_source,d=!(!((A=e.conditions)===null||A===void 0||(A=A.utm)===null||A===void 0)&&A.utm_medium)||((c=e.conditions)===null||c===void 0||(c=c.utm)===null||c===void 0?void 0:c.utm_medium)==o.utm_medium,p=!(!((l=e.conditions)===null||l===void 0||(l=l.utm)===null||l===void 0)&&l.utm_term)||((g=e.conditions)===null||g===void 0||(g=g.utm)===null||g===void 0?void 0:g.utm_term)==o.utm_term;return u&&d&&p&&h}return!1}static Zf(e,...n){gi.info(`[WebExperiments] ${e}`,n)}Xf(e,n,o){this._is_bot()?tx.Zf(mAt):n!=="control"?o.forEach(i=>{if(i.selector){var r;tx.Zf(`applying transform of variant ${n} for experiment ${e} `,i);const s=(r=document)===null||r===void 0?void 0:r.querySelectorAll(i.selector);s?.forEach(a=>{const A=a;i.html&&(A.innerHTML=i.html),i.css&&A.setAttribute("style",i.css)})}}):tx.Zf("Control variants leave the page unmodified.")}_is_bot(){return F_&&this._instance?Fat(F_,this.Mr.custom_blocked_useragents):void 0}}},fne),h7n={conversations:class{constructor(t){this._instance=t,this.sp=void 0,this._conversationsManager=null,this.rp=!1,this.ne=null,this.op=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(this._instance.config.disable_conversations||(this.ap=t.ok,!t.ok))return;const e=t.config.conversations;Fs(e)||(py(e)?this.sp=e:(this.sp=e.enabled,this.ne=e),this.loadIfEnabled())}reset(){var t;(t=this._conversationsManager)===null||t===void 0||t.reset(),this._conversationsManager=null,this.sp=void 0,this.ne=null,this.ap=void 0,this.op=!1}loadIfEnabled(){if(this._conversationsManager||this.rp||this._instance.config.disable_conversations||_2e(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;const t=Ur?.__PosthogExtensions__;if(t&&!Eo(this.sp)&&this.sp)if(this.ne&&this.ne.token){this.rp=!0;try{const e=t.initConversations;if(e)return this.lp(e),void(this.rp=!1);const n=t.loadExternalDependency;if(!n)return void this.up(h2e);n(this._instance,"conversations",o=>{o||!t.initConversations?this.up("Could not load conversations script",o):this.lp(t.initConversations),this.rp=!1})}catch(e){this.up("Error initializing conversations",e),this.rp=!1}}else _5.error("Conversations enabled but missing token in remote config.")}lp(t){if(this.ne)try{this._conversationsManager=t(this.ne,this._instance),this.op=!1,_5.info("Conversations loaded successfully")}catch(e){this.up("Error completing conversations initialization",e)}else _5.error("Cannot complete initialization: remote config is null")}up(t,e){_5.error(t,e),this._conversationsManager=null,this.rp=!1,this.op=!0}show(){this._conversationsManager?this._conversationsManager.show():_5.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.sp===!0&&!ad(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":_2e(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":this.ap===!1?"remote_config_failed":Eo(this.sp)?this.ap?"disabled_in_project":"remote_config_pending":this.sp?Fs(this.ne)||!this.ne.token?"missing_token":Ur?.__PosthogExtensions__?this.rp?"initializing":this.op?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,e;return(t=(e=this._conversationsManager)===null||e===void 0?void 0:e.isVisible())!==null&&t!==void 0&&t}sendMessage(t,e,n){var o=this;return Wg(function*(){return o._conversationsManager?o._conversationsManager.sendMessage(t,e,n):(_5.warn(GM),null)})()}getMessages(t,e){var n=this;return Wg(function*(){return n._conversationsManager?n._conversationsManager.getMessages(t,e):(_5.warn(GM),null)})()}markAsRead(t){var e=this;return Wg(function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(_5.warn(GM),null)})()}getTickets(t){var e=this;return Wg(function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(_5.warn(GM),null)})()}requestRestoreLink(t){var e=this;return Wg(function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(_5.warn(GM),null)})()}restoreFromToken(t){var e=this;return Wg(function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(_5.warn(GM),null)})()}restoreFromUrlToken(){var t=this;return Wg(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(_5.warn(GM),null)})()}getCurrentTicketId(){var t,e;return(t=(e=this._conversationsManager)===null||e===void 0?void 0:e.getCurrentTicketId())!==null&&t!==void 0?t:null}getWidgetSessionId(){var t,e;return(t=(e=this._conversationsManager)===null||e===void 0?void 0:e.getWidgetSessionId())!==null&&t!==void 0?t:null}$h(){var t;(t=this._conversationsManager)===null||t===void 0||t.setIdentity()}Ch(){var t;(t=this._conversationsManager)===null||t===void 0||t.clearIdentity()}}},p7n={logs:class{constructor(t){var e;this._instance=t,this.name="logs",this.hp=!1,this.cp=!1,this.dp=!1,this.A=Ad("[logs]"),this.vp=sn(sn({},this.A),{},{error:(...n)=>{n.some(CAt)||this.A.error(...n)}}),this.ol=[],this.fp=[],this.kd=0,this.To=!1,this.pp=[],this.gp=[],this.mp=!1,this.yp=!1,this.bp=()=>{var n,o;this.To||(this.kd=0,(n=this._p)===null||n===void 0||n.onReconnect(),(o=this.wp)===null||o===void 0||o.onReconnect())},this._instance&&(!((e=this._instance.config.logs)===null||e===void 0)&&e.captureConsoleLogs)&&(this.hp=!0),Fn&&jc(Fn,"online",this.bp)}kp(t,e,n,o){var i;const r=_At((i=this._instance)===null||i===void 0||(i=i.config)===null||i===void 0?void 0:i.logs,n);return[new $4n(this.Sp(t,e),r,this.vp,()=>this.xp(),s=>s(),void 0,o),r]}$p(){var t;const e=(t=this._instance)===null||t===void 0||(t=t.config)===null||t===void 0?void 0:t.logs;var n;return this._p&&this.Cp===e||((n=this._p)===null||n===void 0||n.reset(),this.Cp=e,[this._p,this.Tp]=this.kp(()=>this.ol,o=>{this.ol=o})),this._p}Ip(){var t;const e=(t=this._instance)===null||t===void 0||(t=t.config)===null||t===void 0?void 0:t.logs;var n;return this.wp&&this.Mp===e||((n=this.wp)===null||n===void 0||n.reset(),this.Mp=e,[this.wp,this.Ep]=this.kp(()=>this.fp,o=>{this.fp=o},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},fAt)),this.wp}setup(t){var e;if(this.To)return;this.bo=t,!((e=this._instance)===null||e===void 0||(e=e.config)===null||e===void 0||(e=e.logs)===null||e===void 0)&&e.captureConsoleLogs&&(this.hp=!0),(this.hp||this.Pp()&&this.Rp())&&this.Ap();let n=!1;const o=t.onRemoteConfig(i=>{var r;n=i.ok&&((r=i.config.logs)===null||r===void 0?void 0:r.captureConsoleLogs)===!0,this.onRemoteConfig(i)});this.To?o.dispose():(this.Eo=o,n||this.loadIfEnabled())}dispose(){var t,e,n,o;this.To||(this.To=!0,this.Op(),(t=this.Eo)===null||t===void 0||t.dispose(),this.Eo=void 0,this.bo=void 0,this.dp=!1,Fn?.removeEventListener("online",this.bp),(e=this.Fp)===null||e===void 0||e.call(this),this.Fp=void 0,(n=this._p)===null||n===void 0||n.reset(),(o=this.wp)===null||o===void 0||o.reset())}onRemoteConfig(t){var e,n;if(this.To)return;const o=t.ok?(e=t.config.logs)===null||e===void 0?void 0:e.captureConsoleLogs:void 0;Fs(o)?this.Dp():((n=this._instance)===null||n===void 0||(n=n.persistence)===null||n===void 0||n.register({$logs_capture_enabled_server_side:!!o}),o?(this.hp=!0,this.cp||this.Ap(),this.loadIfEnabled()):this.Dp())}reset(){var t,e,n,o;this.Op(),(t=this._p)===null||t===void 0||t.clearQueue(),this.ol=[],(e=this._p)===null||e===void 0||e.reset(),(n=this.wp)===null||n===void 0||n.clearQueue(),this.fp=[],(o=this.wp)===null||o===void 0||o.reset(),this.kd=0}captureLog(t){this.To||this.$p().captureLog(t)}captureConsoleLog(t){this.To||this.Ip().captureLog(t)}captureBufferedConsoleLog(t,e,n){this.To||this.Ip().captureLog(t,{context:e,occurredAtMs:n})}Rp(){var t;return!!(!((t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||(t=t.props)===null||t===void 0)&&t[Zrt])}Pp(){var t,e,n;return!(!((t=this._instance)===null||t===void 0||(e=t.il)===null||e===void 0)&&e.call(t))||!!(!((n=Ur._POSTHOG_REMOTE_CONFIG)===null||n===void 0||(n=n[this._instance.config.token])===null||n===void 0)&&n.config)}Ih(){var t;this.Op(),(t=this.wp)===null||t===void 0||t.clearQueue(),this.fp=[]}Dp(){this.hp||this.Op()}Ap(){var t;if(this.mp||!Ur?.console)return;const e=_At((t=this._instance)===null||t===void 0||(t=t.config)===null||t===void 0?void 0:t.logs).maxBufferSize;let n=!0;this.gp.push(()=>{n=!1});for(const o of Z9n){let i;try{i=e7n(Ur.console[o])}catch{continue}i&&this.gp.push(bV(Ur.console,o,r=>{const s=(...a)=>{try{n&&this.Lp(o,a,e)}catch{}return r.apply(Ur.console,a)};return s.__rrweb_original__=i,s}))}this.mp=!0,this.Np=setTimeout(()=>{this.Op()},3e4)}Lp(t,e,n){var o;if(this.mp&&!this.yp&&e.length!==0)if(!((o=this._instance)===null||o===void 0)&&o.is_capturing()){if(n>this.pp.length){this.yp=!0;try{this.pp.push({level:t,args:e,occurredAtMs:Date.now(),context:this.xp()})}finally{this.yp=!1}}}else this.Op()}Op(){if(this.pp=[],this.mp){this.mp=!1,this.Np&&(clearTimeout(this.Np),this.Np=void 0);for(const t of this.gp)t();this.gp=[]}}qp(){const t=this.pp;return this.Op(),t}get logger(){return this.jp||(this.jp={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.jp}flushLogs(t){t?this.Bp(t):(this._p&&this._p.flush().catch(e=>this.Hp(e)),this.wp&&this.wp.flush().catch(e=>this.Hp(e)))}Hp(t){CAt(t)||this.A.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(this.To||!this.hp||this.cp||this.dp)return;const t=Ur?.__PosthogExtensions__;if(!t)return this.A.error("PostHog Extensions not found."),void this.Op();const e=t.loadExternalDependency;if(!e)return this.A.error(h2e),void this.Op();this.dp=!0;try{e(this._instance,"logs",n=>{if(this.dp=!1,this.To||!this.hp)return;const o=t.logs;if(n||!o?.initializeLogs)this.A.error("Could not load logs script",n),this.Op();else{var i;const a=this.qp();var r,s;this.Fp=o.initializeLogs((i=this.bo)!==null&&i!==void 0?i:this._instance),this.cp=!0,a.length>0&&((r=o.replayConsoleBuffer)===null||r===void 0||r.call(o,(s=this.bo)!==null&&s!==void 0?s:this._instance,a))}})}catch(n){throw this.dp=!1,n}}Sp(t,e){const n=this._instance;return{get isDisabled(){return!1},get optedOut(){return!n.is_capturing()},getPersistedProperty:o=>o===x9.LogsQueue?t():void 0,setPersistedProperty(o,i){var r;o===x9.LogsQueue&&e((r=i)!==null&&r!==void 0?r:[])},js:o=>this.js(o),getLibraryId:()=>Ym.LIB_NAME,getLibraryVersion:()=>Ym.LIB_VERSION}}js(t){return new Promise(e=>{if(qst(this.kd,3))return void e({kind:"fatal",error:ixe(void 0,"logs endpoint is unreachable, dropping batch")});let n=!1;const o=r=>{n||(n=!0,clearTimeout(i),e(r))},i=setTimeout(()=>{this.A.warn("Logs request timed out before receiving a response"),o({kind:"retry-later",error:ixe(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.zp(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:r=>{const s=r.statusCode;if(this.Up(s),s>=200&&300>s)o({kind:"ok"});else if(s===413)o({kind:"too-large"});else if(s!==0&&s!==408&&s!==429&&500>s)o({kind:"fatal",error:new Error(`logs request failed with status ${s}`)});else{var a;s===0?(r.error||this.A.warn("Logs request failed before receiving an HTTP response"),o({kind:"retry-later",error:ixe(r.error,"logs request failed before receiving an HTTP response")})):o({kind:"retry-later",error:(a=r.error)!==null&&a!==void 0?a:new Error(`logs request failed with status ${s}`)})}}})})}Up(t){(t!==0||this._instance.__loaded)&&(this.kd=$st(t,this.kd,3,()=>this.A.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.")))}Bp(t){this.ol.length>0&&this.Wp(t,this.ol,this.Tp,Ym.LIB_NAME,e=>{this.ol=e}),this.fp.length>0&&this.Wp(t,this.fp,this.Ep,fAt,e=>{this.fp=e})}Wp(t,e,n,o,i){if(e.length===0)return;const r=e.map(a=>a.record);i([]);const s=Grt(r,Ort(n,Ym.LIB_NAME,Ym.LIB_VERSION),o,Ym.LIB_VERSION);this._instance._send_request({method:"POST",url:this.zp(),data:s,compression:"best-available",batchKey:"logs",transport:t})}zp(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}xp(){var t;const e={};if(e.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){const{sessionId:n,windowId:o,sessionStartTimestamp:i,lastActivityTimestamp:r}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);e.sessionId=n,e.windowId=o,Fs(i)||(e.sessionStartTimestamp=i),Fs(r)||(e.lastActivityTimestamp=r)}if(!(Ur==null||(t=Ur.location)===null||t===void 0)&&t.href&&(e.currentUrl=this._instance.config.disable_capture_url_hashes?AQ(Ur.location.href):Ur.location.href),this._instance.featureFlags){const n=this._instance.featureFlags.getFlags();n&&n.length>0&&(e.activeFeatureFlags=n)}return e}}},m7n={metrics:class{constructor(t){this._instance=t,this.A=Ad("[metrics]"),this.To=!1}initialize(){this.onConfigChange()}onConfigChange(){var t;if(this.To)return;const e=!!(!((t=this._instance.config.metrics)===null||t===void 0)&&t.network);e&&!this.Vp?this.Vp=(n=>{let o=!0;const i=()=>o?(a=>{var A;const c=(A=a.config.metrics)===null||A===void 0?void 0:A.network;return c===!0?{}:c||void 0})(n):void 0,r=o7n(n,i),s=i7n(n,i);return()=>{o=!1,r(),s()}})(this._instance):!e&&this.Vp&&(this.Vp(),this.Vp=void 0)}$p(){var t;const e=(t=this._instance)===null||t===void 0||(t=t.config)===null||t===void 0?void 0:t.metrics;var n;return this._p&&this.Cp===e||((n=this._p)===null||n===void 0||n.reset(),this.Cp=e,this._p=new Z4n(this.Sp(),(function(o){var i,r,s,a,A;const c=o?.resourceAttributes;return{serviceName:(i=c?.["service.name"])!==null&&i!==void 0?i:o?.serviceName,serviceVersion:(r=c?.["service.version"])!==null&&r!==void 0?r:o?.serviceVersion,environment:(s=c?.["deployment.environment"])!==null&&s!==void 0?s:o?.environment,resourceAttributes:c,beforeSend:o?.beforeSend,flushIntervalMs:(a=o?.flushIntervalMs)!==null&&a!==void 0?a:1e4,maxSeriesPerFlush:(A=o?.maxSeriesPerFlush)!==null&&A!==void 0?A:1e3}})(e),this.A)),this._p}count(t,e=1,n){this.$p().count(t,e,n)}gauge(t,e,n){this.$p().gauge(t,e,n)}histogram(t,e,n){this.$p().histogram(t,e,n)}flush(t){if(!this._p)return Promise.resolve();if(t){const e=this._p.drainWindow();return e&&this.Ys(e,t),Promise.resolve()}return this._p.flush().catch(e=>this.A.error("PostHog metrics flush failed:",e))}reset(){var t;(t=this._p)===null||t===void 0||t.reset()}dispose(){var t,e;this.To=!0,(t=this.Vp)===null||t===void 0||t.call(this),this.Vp=void 0,(e=this._p)===null||e===void 0||e.reset()}Sp(){const t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Ys:n=>e.Ys(n),getLibraryId:()=>Ym.LIB_NAME,getLibraryVersion:()=>Ym.LIB_VERSION}}Ys(t,e){return new Promise(n=>{let o=!1;const i=s=>{o||(o=!0,clearTimeout(r),n(s))},r=setTimeout(()=>i({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(sn(sn({method:"POST",url:this.Gp(),data:t,compression:"best-available",batchKey:"metrics"},e&&{transport:e}),{},{fireCallbackOnDrop:!0,callback(s){const a=s.statusCode;if(a>=200&&300>a)i({kind:"ok"});else if(a===413)i({kind:"too-large"});else if(a!==0&&a!==408&&a!==429&&500>a)i({kind:"fatal",error:new Error(`metrics request failed with status ${a}`)});else{var A;i({kind:"retry-later",error:(A=s.error)!==null&&A!==void 0?A:new Error(`metrics request failed with status ${a}`)})}}}))})}Gp(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}};EV.__defaultExtensionClasses=sn({},sn(sn(sn(sn(sn(sn(sn(sn(sn(sn(sn(sn(sn({},fne),r7n),s7n),a7n),A7n),c7n),g7n),l7n),u7n),d7n),h7n),p7n),m7n));var Wk=(function(){Ym.SDK_DIST_CHANNEL="npm";const t=CV[xV]=new EV;return(function(){function e(){e.done||(e.done=!0,Dat=!1,vl(CV,function(n){n._dom_loaded()}))}No?.addEventListener?No.readyState==="complete"?e():jc(No,"DOMContentLoaded",e,{capture:!1}):Fn&&gi.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),t})();class YM extends Error{response;request;options;constructor(e,n,o){const i=e.status||e.status===0?e.status:"",r=e.statusText??"",s=`${i} ${r}`.trim(),a=s?`status code ${s}`:"an unknown error";super(`Request failed with ${a}: ${n.method} ${n.url}`),this.name="HTTPError",this.response=e,this.request=n,this.options=o}}class EAt extends Error{name="NonError";value;constructor(e){let n="Non-error value was thrown";try{typeof e=="string"?n=e:e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"&&(n=e.message)}catch{}super(n),this.value=e}}class axe extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const n=e?.cause?e.cause instanceof Error?e.cause:new EAt(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:"Forced retry",n?{cause:n}:void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}}const BAt=(()=>{let t=!1,e=!1;const n=typeof globalThis.ReadableStream=="function",o=typeof globalThis.Request=="function";if(n&&o)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return t&&!e})(),_7n=typeof globalThis.AbortController=="function",bAt=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",f7n=typeof globalThis.ReadableStream=="function",I7n=typeof globalThis.FormData=="function",SAt=["get","post","put","patch","head","delete"],C7n={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},Axe=2147483647,y7n=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,QAt=Symbol("stop");class vAt{options;constructor(e){this.options=e}}const x7n=t=>new vAt(t),E7n={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},B7n={next:!0},b7n={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},S7n=t=>{if(!t)return 0;if(t instanceof FormData){let e=0;for(const[n,o]of t)e+=y7n,e+=new TextEncoder().encode(`Content-Disposition: form-data; name="${n}"`).length,e+=typeof o=="string"?new TextEncoder().encode(o).length:o.size;return e}if(t instanceof Blob)return t.size;if(t instanceof ArrayBuffer)return t.byteLength;if(typeof t=="string")return new TextEncoder().encode(t).length;if(t instanceof URLSearchParams)return new TextEncoder().encode(t.toString()).length;if("byteLength"in t)return t.byteLength;if(typeof t=="object"&&t!==null)try{const e=JSON.stringify(t);return new TextEncoder().encode(e).length}catch{return 0}return 0},wAt=(t,e,n)=>{let o,i=0;return t.pipeThrough(new TransformStream({transform(r,s){if(s.enqueue(r),o){i+=o.byteLength;let a=e===0?0:i/e;a>=1&&(a=1-Number.EPSILON),n?.({percent:a,totalBytes:Math.max(e,i),transferredBytes:i},o)}o=r},flush(){o&&(i+=o.byteLength,n?.({percent:1,totalBytes:Math.max(e,i),transferredBytes:i},o))}}))},Q7n=(t,e)=>{if(!t.body)return t;if(t.status===204)return new Response(null,{status:t.status,statusText:t.statusText,headers:t.headers});const n=Math.max(0,Number(t.headers.get("content-length"))||0);return new Response(wAt(t.body,n,e),{status:t.status,statusText:t.statusText,headers:t.headers})},v7n=(t,e,n)=>{if(!t.body)return t;const o=S7n(n??t.body);return new Request(t,{duplex:"half",body:wAt(t.body,o,e)})},UM=t=>t!==null&&typeof t=="object",Ine=(...t)=>{for(const e of t)if((!UM(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return cxe({},...t)},PAt=(t={},e={})=>{const n=new globalThis.Headers(t),o=e instanceof globalThis.Headers,i=new globalThis.Headers(e);for(const[r,s]of i.entries())o&&s==="undefined"||s===void 0?n.delete(r):n.set(r,s);return n};function Cne(t,e,n){return Object.hasOwn(e,n)&&e[n]===void 0?[]:cxe(t[n]??[],e[n]??[])}const MAt=(t={},e={})=>({beforeRequest:Cne(t,e,"beforeRequest"),beforeRetry:Cne(t,e,"beforeRetry"),afterResponse:Cne(t,e,"afterResponse"),beforeError:Cne(t,e,"beforeError")}),w7n=(t,e)=>{const n=new URLSearchParams;for(const o of[t,e])if(o!==void 0)if(o instanceof URLSearchParams)for(const[i,r]of o.entries())n.append(i,r);else if(Array.isArray(o))for(const i of o){if(!Array.isArray(i)||i.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");n.append(String(i[0]),String(i[1]))}else if(UM(o))for(const[i,r]of Object.entries(o))r!==void 0&&n.append(i,String(r));else{const i=new URLSearchParams(o);for(const[r,s]of i.entries())n.append(r,s)}return n},cxe=(...t)=>{let e={},n={},o={},i;const r=[];for(const s of t)if(Array.isArray(s))Array.isArray(e)||(e=[]),e=[...e,...s];else if(UM(s)){for(let[a,A]of Object.entries(s)){if(a==="signal"&&A instanceof globalThis.AbortSignal){r.push(A);continue}if(a==="context"){if(A!=null&&(!UM(A)||Array.isArray(A)))throw new TypeError("The `context` option must be an object");e={...e,context:A==null?{}:{...e.context,...A}};continue}if(a==="searchParams"){A==null?i=void 0:i=i===void 0?A:w7n(i,A);continue}UM(A)&&a in e&&(A=cxe(e[a],A)),e={...e,[a]:A}}UM(s.hooks)&&(o=MAt(o,s.hooks),e.hooks=o),UM(s.headers)&&(n=PAt(n,s.headers),e.headers=n)}return i!==void 0&&(e.searchParams=i),r.length>0&&(r.length===1?e.signal=r[0]:bAt?e.signal=AbortSignal.any(r):e.signal=r.at(-1)),e},P7n=t=>SAt.includes(t)?t.toUpperCase():t,DAt={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:t=>.3*2**(t-1)*1e3,jitter:void 0,retryOnTimeout:!1},M7n=(t={})=>{if(typeof t=="number")return{...DAt,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.methods&&=t.methods.map(n=>n.toLowerCase()),t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");const e=Object.fromEntries(Object.entries(t).filter(([,n])=>n!==void 0));return{...DAt,...e}};class lxe extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}}async function D7n(t,e,n,o){return new Promise((i,r)=>{const s=setTimeout(()=>{n&&n.abort(),r(new lxe(t))},o.timeout);o.fetch(t,e).then(i).catch(r).then(()=>{clearTimeout(s)})})}async function N7n(t,{signal:e}){return new Promise((n,o)=>{e&&(e.throwIfAborted(),e.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(r),o(e.reason)}const r=setTimeout(()=>{e?.removeEventListener("abort",i),n()},t)})}const R7n=(t,e)=>{const n={};for(const o in e)Object.hasOwn(e,o)&&!(o in b7n)&&!(o in E7n)&&(!(o in t)||o in B7n)&&(n[o]=e[o]);return n},T7n=t=>t===void 0?!1:Array.isArray(t)?t.length>0:t instanceof URLSearchParams?t.size>0:typeof t=="object"?Object.keys(t).length>0:typeof t=="string"?t.trim().length>0:!!t;function k7n(t){return t instanceof YM||t?.name===YM.name}function F7n(t){return t instanceof lxe||t?.name===lxe.name}let NAt=class Znt{static create(e,n){const o=new Znt(e,n),i=async()=>{if(typeof o.#e.timeout=="number"&&o.#e.timeout>Axe)throw new RangeError(`The \`timeout\` option cannot be greater than ${Axe}`);await Promise.resolve();let s=await o.#_();for(const a of o.#e.hooks.afterResponse){const A=o.#d(s.clone());let c;try{c=await a(o.request,o.#c(),A,{retryCount:o.#n})}catch(g){throw o.#r(A),o.#r(s),g}if(c instanceof vAt)throw o.#r(A),o.#r(s),new axe(c.options);const l=c instanceof globalThis.Response?c:s;A!==l&&o.#r(A),s!==l&&o.#r(s),s=l}if(o.#d(s),!s.ok&&(typeof o.#e.throwHttpErrors=="function"?o.#e.throwHttpErrors(s.status):o.#e.throwHttpErrors)){let a=new YM(s,o.request,o.#c());for(const A of o.#e.hooks.beforeError)a=await A(a,{retryCount:o.#n});throw a}if(o.#e.onDownloadProgress){if(typeof o.#e.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!f7n)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");const a=s.clone();return o.#r(s),Q7n(a,o.#e.onDownloadProgress)}return s},r=o.#h(i).finally(()=>{const s=o.#s;o.#g(s?.body??void 0),o.#g(o.request.body??void 0)});for(const[s,a]of Object.entries(C7n))s==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(r[s]=async()=>{o.request.headers.set("accept",o.request.headers.get("accept")||a);const A=await r;if(s==="json"){if(A.status===204)return"";const c=await A.text();return c===""?"":n.parseJson?n.parseJson(c):JSON.parse(c)}return A[s]()});return r}static#a(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof URLSearchParams)?Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0)):e}request;#o;#n=0;#t;#e;#s;#i;#A;constructor(e,n={}){if(this.#t=e,this.#e={...n,headers:PAt(this.#t.headers,n.headers),hooks:MAt({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},n.hooks),method:P7n(n.method??this.#t.method??"GET"),prefixUrl:String(n.prefixUrl||""),retry:M7n(n.retry),throwHttpErrors:n.throwHttpErrors??!0,timeout:n.timeout??1e4,fetch:n.fetch??globalThis.fetch.bind(globalThis),context:n.context??{}},typeof this.#t!="string"&&!(this.#t instanceof URL||this.#t instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#e.prefixUrl&&typeof this.#t=="string"){if(this.#t.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#e.prefixUrl.endsWith("/")||(this.#e.prefixUrl+="/"),this.#t=this.#e.prefixUrl+this.#t}_7n&&bAt&&(this.#i=this.#e.signal??this.#t.signal,this.#o=new globalThis.AbortController,this.#e.signal=this.#i?AbortSignal.any([this.#i,this.#o.signal]):this.#o.signal),BAt&&(this.#e.duplex="half"),this.#e.json!==void 0&&(this.#e.body=this.#e.stringifyJson?.(this.#e.json)??JSON.stringify(this.#e.json),this.#e.headers.set("content-type",this.#e.headers.get("content-type")??"application/json"));const o=n.headers&&new globalThis.Headers(n.headers).has("content-type");if(this.#t instanceof globalThis.Request&&(I7n&&this.#e.body instanceof globalThis.FormData||this.#e.body instanceof URLSearchParams)&&!o&&this.#e.headers.delete("content-type"),this.request=new globalThis.Request(this.#t,this.#e),T7n(this.#e.searchParams)){const r="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(Znt.#a(this.#e.searchParams)).toString()),s=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,r);this.request=new globalThis.Request(s,this.#e)}if(this.#e.onUploadProgress){if(typeof this.#e.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!BAt)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#p(this.request,this.#e.body??void 0)}}#l(){const e=this.#e.retry.delay(this.#n);let n=e;this.#e.retry.jitter===!0?n=Math.random()*e:typeof this.#e.retry.jitter=="function"&&(n=this.#e.retry.jitter(e),(!Number.isFinite(n)||n<0)&&(n=e));const o=this.#e.retry.backoffLimit??Number.POSITIVE_INFINITY;return Math.min(o,n)}async#m(e){if(this.#n++,this.#n>this.#e.retry.limit)throw e;const n=e instanceof Error?e:new EAt(e);if(n instanceof axe)return n.customDelay??this.#l();if(!this.#e.retry.methods.includes(this.request.method.toLowerCase()))throw e;if(this.#e.retry.shouldRetry!==void 0){const o=await this.#e.retry.shouldRetry({error:n,retryCount:this.#n});if(o===!1)throw e;if(o===!0)return this.#l()}if(F7n(e)&&!this.#e.retry.retryOnTimeout)throw e;if(k7n(e)){if(!this.#e.retry.statusCodes.includes(e.response.status))throw e;const o=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Retry-After")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(o&&this.#e.retry.afterStatusCodes.includes(e.response.status)){let i=Number(o)*1e3;Number.isNaN(i)?i=Date.parse(o)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());const r=this.#e.retry.maxRetryAfter??i;return i<r?i:r}if(e.response.status===413)throw e}return this.#l()}#d(e){return this.#e.parseJson&&(e.json=async()=>this.#e.parseJson(await e.text())),e}#g(e){e&&e.cancel().catch(()=>{})}#r(e){this.#g(e.body??void 0)}async#h(e){try{return await e()}catch(n){const o=Math.min(await this.#m(n),Axe);if(this.#n<1)throw n;if(await N7n(o,this.#i?{signal:this.#i}:{}),n instanceof axe&&n.customRequest){const i=this.#e.signal?new globalThis.Request(n.customRequest,{signal:this.#e.signal}):new globalThis.Request(n.customRequest);this.#u(i)}for(const i of this.#e.hooks.beforeRetry){const r=await i({request:this.request,options:this.#c(),error:n,retryCount:this.#n});if(r instanceof globalThis.Request){this.#u(r);break}if(r instanceof globalThis.Response)return r;if(r===QAt)return}return this.#h(e)}}async#_(){this.#o?.signal.aborted&&(this.#o=new globalThis.AbortController,this.#e.signal=this.#i?AbortSignal.any([this.#i,this.#o.signal]):this.#o.signal,this.request=new globalThis.Request(this.request,{signal:this.#e.signal}));for(const n of this.#e.hooks.beforeRequest){const o=await n(this.request,this.#c(),{retryCount:this.#n});if(o instanceof Response)return o;if(o instanceof globalThis.Request){this.#u(o);break}}const e=R7n(this.request,this.#e);return this.#s=this.request,this.request=this.#s.clone(),this.#e.timeout===!1?this.#e.fetch(this.#s,e):D7n(this.#s,e,this.#o,this.#e)}#c(){if(!this.#A){const{hooks:e,...n}=this.#e;this.#A=Object.freeze(n)}return this.#A}#u(e){this.#A=void 0,this.request=this.#p(e)}#p(e,n){return!this.#e.onUploadProgress||!e.body?e:v7n(e,this.#e.onUploadProgress,n??this.#e.body??void 0)}};const gxe=t=>{const e=(n,o)=>NAt.create(n,Ine(t,o));for(const n of SAt)e[n]=(o,i)=>NAt.create(o,Ine(t,i,{method:n}));return e.create=n=>gxe(Ine(n)),e.extend=n=>(typeof n=="function"&&(n=n(t??{})),gxe(Ine(t,n))),e.stop=QAt,e.retry=x7n,e},L7n=gxe();class H7n extends YM{constructor(e,n,o,i){super(e,n,o),this.name="RegistryHTTPError",this.message=i}}function SV(t){return typeof window<"u"?window[t]:null}function KM(){const t=SV("TSCIRCUIT_REGISTRY_API_BASE_URL")||void 0||"https://registry-api.tscircuit.com",e=SV("TSCIRCUIT_REGISTRY_TOKEN");return L7n.create({prefixUrl:t,headers:{Authorization:`Bearer ${e}`},timeout:3e4,hooks:{afterResponse:[async(n,o,i)=>{if(i.ok)return i;let r=null;try{r=await i.clone().json()}catch(g){console.error("Failed to parse registry error response",g)}const s=r?.error?.message??r?.error?.error_message??r?.message,a=r?.error?.error_code??r?.error_code,A=new URL(i.url),l=[`Registry request failed for ${`${A.pathname}${A.search}`} (${i.status})`];throw s&&l.push(`Server message: ${s}`),a&&l.push(`Error code: ${a}`),new H7n(i,n,o,l.join(" | "))}]}})}function yne(){return!!SV("TSCIRCUIT_REGISTRY_TOKEN")}const xne={get:(t,e)=>KM().get(t,e),post:(t,e)=>KM().post(t,e),put:(t,e)=>KM().put(t,e),delete:(t,e)=>KM().delete(t,e),patch:(t,e)=>KM().patch(t,e)},O7n="phc_htd8AQjSfVEsFCLQMAiUooG4Q0DKBCjqYuQglc9V3Wo",G7n="https://postpig.tscircuit.com",RAt="runframe:anonymous-id",uxe=()=>typeof window<"u",TAt=t=>t.includes("localhost")||t.includes("127.0.0.1"),Y7n=t=>{try{return new URL(t).hostname}catch{return null}},U7n=()=>{if(!uxe())return null;let t=null;return document.referrer&&(t=Y7n(document.referrer)),t??window.location.hostname},K7n=()=>typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,V7n=()=>{if(!uxe())return null;try{const t=window.localStorage.getItem(RAt);if(t)return t;const e=K7n();return window.localStorage.setItem(RAt,e),e}catch{return null}},z7n=()=>SV("TSCIRCUIT_USE_RUNFRAME_FOR_CLI")===!0,kAt=()=>!uxe()||TAt(window.location.hostname)&&!z7n()?!1:(Wk.__loaded||Wk.init(O7n,{api_host:G7n,person_profiles:"always"}),!0),J7n=()=>{if(!kAt())return null;const t=U7n(),e=t!=null&&!TAt(t);let n=null;e||(n=V7n());let o,i;return e?(o=`domain:${t}`,i="domain"):(o=void 0,n&&(o=`anonymous:${n}`),i="anonymous_id"),{embedDomain:t,anonymousId:n,distinctId:o,identityType:i}},W7n=(t,{source:e,...n})=>{const o=J7n();if(!o)return;const{embedDomain:i,anonymousId:r,distinctId:s,identityType:a}=o;if(s){const A={};a==="domain"&&i&&(A.embed_domain=i),a==="anonymous_id"&&r&&(A.runframe_anonymous_id=r),Wk.identify(s,A)}Wk.capture(t,{...n,source:e,embed_domain:i,runframe_anonymous_id:r,identity_type:a})},j7n=t=>{W7n("runframe_activity",t)};kAt();function X7n(t){const e=String.fromCodePoint(...t);return btoa(e)}var tm=Uint8Array,T3=Uint16Array,dxe=Int32Array,Ene=new tm([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]),Bne=new tm([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]),hxe=new tm([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),FAt=function(t,e){for(var n=new T3(31),o=0;o<31;++o)n[o]=e+=1<<t[o-1];for(var i=new dxe(n[30]),o=1;o<30;++o)for(var r=n[o];r<n[o+1];++r)i[r]=r-n[o]<<5|o;return{b:n,r:i}},LAt=FAt(Ene,2),HAt=LAt.b,pxe=LAt.r;HAt[28]=258,pxe[258]=28;for(var OAt=FAt(Bne,0),q7n=OAt.b,GAt=OAt.r,mxe=new T3(32768),gd=0;gd<32768;++gd){var mQ=(gd&43690)>>1|(gd&21845)<<1;mQ=(mQ&52428)>>2|(mQ&13107)<<2,mQ=(mQ&61680)>>4|(mQ&3855)<<4,mxe[gd]=((mQ&65280)>>8|(mQ&255)<<8)>>1}for(var Q9=(function(t,e,n){for(var o=t.length,i=0,r=new T3(e);i<o;++i)t[i]&&++r[t[i]-1];var s=new T3(e);for(i=1;i<e;++i)s[i]=s[i-1]+r[i-1]<<1;var a;if(n){a=new T3(1<<e);var A=15-e;for(i=0;i<o;++i)if(t[i])for(var c=i<<4|t[i],l=e-t[i],g=s[t[i]-1]++<<l,u=g|(1<<l)-1;g<=u;++g)a[mxe[g]>>A]=c}else for(a=new T3(o),i=0;i<o;++i)t[i]&&(a[i]=mxe[s[t[i]-1]++]>>15-t[i]);return a}),_Q=new tm(288),gd=0;gd<144;++gd)_Q[gd]=8;for(var gd=144;gd<256;++gd)_Q[gd]=9;for(var gd=256;gd<280;++gd)_Q[gd]=7;for(var gd=280;gd<288;++gd)_Q[gd]=8;for(var QV=new tm(32),gd=0;gd<32;++gd)QV[gd]=5;var $7n=Q9(_Q,9,0),Z7n=Q9(_Q,9,1),e6n=Q9(QV,5,0),t6n=Q9(QV,5,1),_xe=function(t){for(var e=t[0],n=1;n<t.length;++n)t[n]>e&&(e=t[n]);return e},H4=function(t,e,n){var o=e/8|0;return(t[o]|t[o+1]<<8)>>(e&7)&n},fxe=function(t,e){var n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(e&7)},Ixe=function(t){return(t+7)/8|0},jk=function(t,e,n){return(e==null||e<0)&&(e=0),(n==null||n>t.length)&&(n=t.length),new tm(t.subarray(e,n))},n6n=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],rx=function(t,e,n){var o=new Error(e||n6n[t]);if(o.code=t,Error.captureStackTrace&&Error.captureStackTrace(o,rx),!n)throw o;return o},YAt=function(t,e,n,o){var i=t.length,r=0;if(!i||e.f&&!e.l)return n||new tm(0);var s=!n,a=s||e.i!=2,A=e.i;s&&(n=new tm(i*3));var c=function(me){var ye=n.length;if(me>ye){var Me=new tm(Math.max(ye*2,me));Me.set(n),n=Me}},l=e.f||0,g=e.p||0,u=e.b||0,h=e.l,d=e.d,p=e.m,m=e.n,_=i*8;do{if(!h){l=H4(t,g,1);var f=H4(t,g+1,3);if(g+=3,f)if(f==1)h=Z7n,d=t6n,p=9,m=5;else if(f==2){var x=H4(t,g,31)+257,E=H4(t,g+10,15)+4,B=x+H4(t,g+5,31)+1;g+=14;for(var S=new tm(B),Q=new tm(19),w=0;w<E;++w)Q[hxe[w]]=H4(t,g+w*3,7);g+=E*3;for(var M=_xe(Q),k=(1<<M)-1,R=Q9(Q,M,1),w=0;w<B;){var F=R[H4(t,g,k)];g+=F&15;var I=F>>4;if(I<16)S[w++]=I;else{var O=0,U=0;for(I==16?(U=3+H4(t,g,3),g+=2,O=S[w-1]):I==17?(U=3+H4(t,g,7),g+=3):I==18&&(U=11+H4(t,g,127),g+=7);U--;)S[w++]=O}}var Y=S.subarray(0,x),J=S.subarray(x);p=_xe(Y),m=_xe(J),h=Q9(Y,p,1),d=Q9(J,m,1)}else rx(1);else{var I=Ixe(g)+4,C=t[I-4]|t[I-3]<<8,y=I+C;if(y>i){A&&rx(0);break}a&&c(u+C),n.set(t.subarray(I,y),u),e.b=u+=C,e.p=g=y*8,e.f=l;continue}if(g>_){A&&rx(0);break}}a&&c(u+131072);for(var ee=(1<<p)-1,W=(1<<m)-1,X=g;;X=g){var O=h[fxe(t,g)&ee],oe=O>>4;if(g+=O&15,g>_){A&&rx(0);break}if(O||rx(2),oe<256)n[u++]=oe;else if(oe==256){X=g,h=null;break}else{var se=oe-254;if(oe>264){var w=oe-257,ie=Ene[w];se=H4(t,g,(1<<ie)-1)+HAt[w],g+=ie}var ge=d[fxe(t,g)&W],ue=ge>>4;ge||rx(3),g+=ge&15;var J=q7n[ue];if(ue>3){var ie=Bne[ue];J+=fxe(t,g)&(1<<ie)-1,g+=ie}if(g>_){A&&rx(0);break}a&&c(u+131072);var Ie=u+se;if(u<J){var le=r-J,_e=Math.min(J,Ie);for(le+u<0&&rx(3);u<_e;++u)n[u]=o[le+u]}for(;u<Ie;++u)n[u]=n[u-J]}}e.l=h,e.p=X,e.b=u,e.f=l,h&&(l=1,e.m=p,e.d=d,e.n=m)}while(!l);return u!=n.length&&s?jk(n,0,u):n.subarray(0,u)},S8=function(t,e,n){n<<=e&7;var o=e/8|0;t[o]|=n,t[o+1]|=n>>8},vV=function(t,e,n){n<<=e&7;var o=e/8|0;t[o]|=n,t[o+1]|=n>>8,t[o+2]|=n>>16},Cxe=function(t,e){for(var n=[],o=0;o<t.length;++o)t[o]&&n.push({s:o,f:t[o]});var i=n.length,r=n.slice();if(!i)return{t:zAt,l:0};if(i==1){var s=new tm(n[0].s+1);return s[n[0].s]=1,{t:s,l:1}}n.sort(function(y,x){return y.f-x.f}),n.push({s:-1,f:25001});var a=n[0],A=n[1],c=0,l=1,g=2;for(n[0]={s:-1,f:a.f+A.f,l:a,r:A};l!=i-1;)a=n[n[c].f<n[g].f?c++:g++],A=n[c!=l&&n[c].f<n[g].f?c++:g++],n[l++]={s:-1,f:a.f+A.f,l:a,r:A};for(var u=r[0].s,o=1;o<i;++o)r[o].s>u&&(u=r[o].s);var h=new T3(u+1),d=yxe(n[l-1],h,0);if(d>e){var o=0,p=0,m=d-e,_=1<<m;for(r.sort(function(x,E){return h[E.s]-h[x.s]||x.f-E.f});o<i;++o){var f=r[o].s;if(h[f]>e)p+=_-(1<<d-h[f]),h[f]=e;else break}for(p>>=m;p>0;){var I=r[o].s;h[I]<e?p-=1<<e-h[I]++-1:++o}for(;o>=0&&p;--o){var C=r[o].s;h[C]==e&&(--h[C],++p)}d=e}return{t:new tm(h),l:d}},yxe=function(t,e,n){return t.s==-1?Math.max(yxe(t.l,e,n+1),yxe(t.r,e,n+1)):e[t.s]=n},UAt=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new T3(++e),o=0,i=t[0],r=1,s=function(A){n[o++]=A},a=1;a<=e;++a)if(t[a]==i&&a!=e)++r;else{if(!i&&r>2){for(;r>138;r-=138)s(32754);r>2&&(s(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(s(i),--r;r>6;r-=6)s(8304);r>2&&(s(r-3<<5|8208),r=0)}for(;r--;)s(i);r=1,i=t[a]}return{c:n.subarray(0,o),n:e}},wV=function(t,e){for(var n=0,o=0;o<e.length;++o)n+=t[o]*e[o];return n},KAt=function(t,e,n){var o=n.length,i=Ixe(e+2);t[i]=o&255,t[i+1]=o>>8,t[i+2]=t[i]^255,t[i+3]=t[i+1]^255;for(var r=0;r<o;++r)t[i+r+4]=n[r];return(i+4+o)*8},VAt=function(t,e,n,o,i,r,s,a,A,c,l){S8(e,l++,n),++i[256];for(var g=Cxe(i,15),u=g.t,h=g.l,d=Cxe(r,15),p=d.t,m=d.l,_=UAt(u),f=_.c,I=_.n,C=UAt(p),y=C.c,x=C.n,E=new T3(19),B=0;B<f.length;++B)++E[f[B]&31];for(var B=0;B<y.length;++B)++E[y[B]&31];for(var S=Cxe(E,7),Q=S.t,w=S.l,M=19;M>4&&!Q[hxe[M-1]];--M);var k=c+5<<3,R=wV(i,_Q)+wV(r,QV)+s,F=wV(i,u)+wV(r,p)+s+14+3*M+wV(E,Q)+2*E[16]+3*E[17]+7*E[18];if(A>=0&&k<=R&&k<=F)return KAt(e,l,t.subarray(A,A+c));var O,U,Y,J;if(S8(e,l,1+(F<R)),l+=2,F<R){O=Q9(u,h,0),U=u,Y=Q9(p,m,0),J=p;var ee=Q9(Q,w,0);S8(e,l,I-257),S8(e,l+5,x-1),S8(e,l+10,M-4),l+=14;for(var B=0;B<M;++B)S8(e,l+3*B,Q[hxe[B]]);l+=3*M;for(var W=[f,y],X=0;X<2;++X)for(var oe=W[X],B=0;B<oe.length;++B){var se=oe[B]&31;S8(e,l,ee[se]),l+=Q[se],se>15&&(S8(e,l,oe[B]>>5&127),l+=oe[B]>>12)}}else O=$7n,U=_Q,Y=e6n,J=QV;for(var B=0;B<a;++B){var ie=o[B];if(ie>255){var se=ie>>18&31;vV(e,l,O[se+257]),l+=U[se+257],se>7&&(S8(e,l,ie>>23&31),l+=Ene[se]);var ge=ie&31;vV(e,l,Y[ge]),l+=J[ge],ge>3&&(vV(e,l,ie>>5&8191),l+=Bne[ge])}else vV(e,l,O[ie]),l+=U[ie]}return vV(e,l,O[256]),l+U[256]},o6n=new dxe([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),zAt=new tm(0),i6n=function(t,e,n,o,i,r){var s=r.z||t.length,a=new tm(o+s+5*(1+Math.ceil(s/7e3))+i),A=a.subarray(o,a.length-i),c=r.l,l=(r.r||0)&7;if(e){l&&(A[0]=r.r>>3);for(var g=o6n[e-1],u=g>>13,h=g&8191,d=(1<<n)-1,p=r.p||new T3(32768),m=r.h||new T3(d+1),_=Math.ceil(n/3),f=2*_,I=function(we){return(t[we]^t[we+1]<<_^t[we+2]<<f)&d},C=new dxe(25e3),y=new T3(288),x=new T3(32),E=0,B=0,S=r.i||0,Q=0,w=r.w||0,M=0;S+2<s;++S){var k=I(S),R=S&32767,F=m[k];if(p[R]=F,m[k]=R,w<=S){var O=s-S;if((E>7e3||Q>24576)&&(O>423||!c)){l=VAt(t,A,0,C,y,x,B,Q,M,S-M,l),Q=E=B=0,M=S;for(var U=0;U<286;++U)y[U]=0;for(var U=0;U<30;++U)x[U]=0}var Y=2,J=0,ee=h,W=R-F&32767;if(O>2&&k==I(S-W))for(var X=Math.min(u,O)-1,oe=Math.min(32767,S),se=Math.min(258,O);W<=oe&&--ee&&R!=F;){if(t[S+Y]==t[S+Y-W]){for(var ie=0;ie<se&&t[S+ie]==t[S+ie-W];++ie);if(ie>Y){if(Y=ie,J=W,ie>X)break;for(var ge=Math.min(W,ie-2),ue=0,U=0;U<ge;++U){var Ie=S-W+U&32767,le=p[Ie],_e=Ie-le&32767;_e>ue&&(ue=_e,F=Ie)}}}R=F,F=p[R],W+=R-F&32767}if(J){C[Q++]=268435456|pxe[Y]<<18|GAt[J];var me=pxe[Y]&31,ye=GAt[J]&31;B+=Ene[me]+Bne[ye],++y[257+me],++x[ye],w=S+Y,++E}else C[Q++]=t[S],++y[t[S]]}}for(S=Math.max(S,w);S<s;++S)C[Q++]=t[S],++y[t[S]];l=VAt(t,A,c,C,y,x,B,Q,M,S-M,l),c||(r.r=l&7|A[l/8|0]<<3,l-=7,r.h=m,r.p=p,r.i=S,r.w=w)}else{for(var S=r.w||0;S<s+c;S+=65535){var Me=S+65535;Me>=s&&(A[l/8|0]=c,Me=s),l=KAt(A,l+1,t.subarray(S,Me))}r.i=s}return jk(a,0,o+Ixe(l)+i)},r6n=(function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var n=e,o=9;--o;)n=(n&1&&-306674912)^n>>>1;t[e]=n}return t})(),s6n=function(){var t=-1;return{p:function(e){for(var n=t,o=0;o<e.length;++o)n=r6n[n&255^e[o]]^n>>>8;t=n},d:function(){return~t}}},JAt=function(){var t=1,e=0;return{p:function(n){for(var o=t,i=e,r=n.length|0,s=0;s!=r;){for(var a=Math.min(s+2655,r);s<a;++s)i+=o+=n[s];o=(o&65535)+15*(o>>16),i=(i&65535)+15*(i>>16)}t=o,e=i},d:function(){return t%=65521,e%=65521,(t&255)<<24|(t&65280)<<8|(e&255)<<8|e>>8}}},WAt=function(t,e,n,o,i){if(!i&&(i={l:1},e.dictionary)){var r=e.dictionary.subarray(-32768),s=new tm(r.length+t.length);s.set(r),s.set(t,r.length),t=s,i.w=r.length}return i6n(t,e.level==null?6:e.level,e.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(t.length)))*1.5):20:12+e.mem,n,o,i)},PV=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8},a6n=function(t,e){var n=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=e.level<2?4:e.level==9?2:0,t[9]=3,e.mtime!=0&&PV(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),n){t[3]=8;for(var o=0;o<=n.length;++o)t[o+10]=n.charCodeAt(o)}},A6n=function(t){return 10+(t.filename?t.filename.length+1:0)},c6n=function(t,e){var n=e.level,o=n==0?0:n<6?1:n==9?3:2;if(t[0]=120,t[1]=o<<6|(e.dictionary&&32),t[1]|=31-(t[0]<<8|t[1])%31,e.dictionary){var i=JAt();i.p(e.dictionary),PV(t,2,i.d())}},jAt=function(t,e){return((t[0]&15)!=8||t[0]>>4>7||(t[0]<<8|t[1])%31)&&rx(6,"invalid zlib data"),(t[1]>>5&1)==+!e&&rx(6,"invalid zlib data: "+(t[1]&32?"need":"unexpected")+" dictionary"),(t[1]>>3&4)+2},xxe=(function(){function t(e,n){typeof e=="function"&&(n=e,e={}),this.ondata=n;var o=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:o?o.length:0},this.o=new tm(32768),this.p=new tm(0),o&&this.o.set(o)}return t.prototype.e=function(e){if(this.ondata||rx(5),this.d&&rx(4),!this.p.length)this.p=e;else if(e.length){var n=new tm(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length),this.p=n}},t.prototype.c=function(e){this.s.i=+(this.d=e||!1);var n=this.s.b,o=YAt(this.p,this.s,this.o);this.ondata(jk(o,n,this.s.b),this.d),this.o=jk(o,this.s.b-32768),this.s.b=this.o.length,this.p=jk(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(e,n){this.e(e),this.c(n)},t})();function Exe(t,e){e||(e={});var n=s6n(),o=t.length;n.p(t);var i=WAt(t,e,A6n(e),8),r=i.length;return a6n(i,e),PV(i,r-8,n.d()),PV(i,r-4,o),i}function XAt(t,e){e||(e={});var n=JAt();n.p(t);var o=WAt(t,e,e.dictionary?6:2,4);return c6n(o,e),PV(o,o.length-4,n.d()),o}var bne=(function(){function t(e,n){xxe.call(this,e,n),this.v=e&&e.dictionary?2:1}return t.prototype.push=function(e,n){if(xxe.prototype.e.call(this,e),this.v){if(this.p.length<6&&!n)return;this.p=this.p.subarray(jAt(this.p,this.v-1)),this.v=0}n&&(this.p.length<4&&rx(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),xxe.prototype.c.call(this,n)},t})();function l6n(t,e){return YAt(t.subarray(jAt(t,e),-4),{i:2},e,e)}var qAt=typeof TextEncoder<"u"&&new TextEncoder,g6n=typeof TextDecoder<"u"&&new TextDecoder,u6n=0;try{g6n.decode(zAt,{stream:!0}),u6n=1}catch{}function Bxe(t,e){var n;if(qAt)return qAt.encode(t);for(var o=t.length,i=new tm(t.length+(t.length>>1)),r=0,s=function(c){i[r++]=c},n=0;n<o;++n){if(r+5>i.length){var a=new tm(r+8+(o-n<<1));a.set(i),i=a}var A=t.charCodeAt(n);A<128||e?s(A):A<2048?(s(192|A>>6),s(128|A&63)):A>55295&&A<57344?(A=65536+(A&1047552)|t.charCodeAt(++n)&1023,s(240|A>>18),s(128|A>>12&63),s(128|A>>6&63),s(128|A&63)):(s(224|A>>12),s(128|A>>6&63),s(128|A&63))}return jk(i,0,r)}function d6n(t,e){const n=JSON.stringify(t),o=Exe(Bxe(n));return`https://tscircuit.com/editor?#data:application/gzip;base64,${X7n(o)}`}function zr(...t){return W5n(R4(t))}const $At=t=>t.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()),bxe=_5n,Sne=te.forwardRef(({className:t,...e},n)=>V.jsx(mit,{ref:n,className:zr("rf-inline-flex rf-h-9 rf-items-center rf-justify-center rf-rounded-lg rf-bg-zinc-100 rf-p-1 rf-text-zinc-500 dark:rf-bg-zinc-800 dark:rf-text-zinc-400",t),...e}));Sne.displayName=mit.displayName;const v9=te.forwardRef(({className:t,...e},n)=>V.jsx(_it,{ref:n,className:zr("rf-inline-flex rf-items-center rf-justify-center rf-whitespace-nowrap rf-rounded-md rf-px-3 rf-py-1 rf-text-sm rf-font-medium rf-ring-offset-white rf-transition-all focus-visible:rf-outline-none focus-visible:rf-ring-2 focus-visible:rf-ring-zinc-950 focus-visible:rf-ring-offset-2 disabled:rf-pointer-events-none disabled:rf-opacity-50 data-[state=active]:rf-bg-white data-[state=active]:rf-text-zinc-950 data-[state=active]:rf-shadow dark:rf-ring-offset-zinc-950 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=active]:rf-bg-zinc-950 dark:data-[state=active]:rf-text-zinc-50",t),...e}));v9.displayName=_it.displayName;const X1=te.forwardRef(({className:t,...e},n)=>V.jsx(fit,{ref:n,className:zr("rf-h-full rf-mt-2 rf-ring-offset-white focus-visible:rf-outline-none focus-visible:rf-ring-2 focus-visible:rf-ring-zinc-950 focus-visible:rf-ring-offset-2 dark:rf-ring-offset-zinc-950 dark:focus-visible:rf-ring-zinc-300",t),...e}));X1.displayName=fit.displayName;const ZAt="T1RUTwAJAIAAAwAQQ0ZGIFhQSpcAAAcwAABJ3U9TLzJqmmVhAAABAAAAAGBjbWFwFN0WswAABEwAAALEaGVhZC1P1HwAAACcAAAANmhoZWEDrgI1AAAA1AAAACRobXR44xAAAAAAURAAAAFQbWF4cABUUAAAAAD4AAAABm5hbWUZQ94BAAABYAAAAutwb3N0AAMAAAAABxAAAAAgAAEAAAABAADb+Z65Xw889QADA+gAAAAA5e9IsgAAAADl70iy/9P/PwKHAvkAAAADAAIAAAAAAAAAAQAAA6z/LAAAArQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAFQAAFAAAFQAAAADArQB9AAFAAACigK7AAAAjAKKArsAAAHfADEBAgAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAABYWFhYAEAAIQB6A6z/LAAAAvkAwQAAAAEAAAAAAiwC1wAAAAAAAAAAACIBngABAAAAAAAAAAEAWQABAAAAAAABABEAAAABAAAAAAACAAcAMwABAAAAAAADABsA/AABAAAAAAAEABkASAABAAAAAAAFAAsA2wABAAAAAAAGABgAkwABAAAAAAAHAAEAWQABAAAAAAAIAAEAWQABAAAAAAAJAAEAWQABAAAAAAAKAAEAWQABAAAAAAALAAEAWQABAAAAAAAMAAEAWQABAAAAAAANAAEAWQABAAAAAAAOAAEAWQABAAAAAAAQABEAAAABAAAAAAARAAcAMwADAAEECQAAAAIAgwADAAEECQABACIAEQADAAEECQACAA4AOgADAAEECQADADYBFwADAAEECQAEADIAYQADAAEECQAFABYA5gADAAEECQAGADAAqwADAAEECQAHAAIAgwADAAEECQAIAAIAgwADAAEECQAJAAIAgwADAAEECQAKAAIAgwADAAEECQALAAIAgwADAAEECQAMAAIAgwADAAEECQANAAIAgwADAAEECQAOAAIAgwADAAEECQAQACIAEQADAAEECQARAA4AOlRzY2lyY3VpdEFscGhhYmV0AFQAcwBjAGkAcgBjAHUAaQB0AEEAbABwAGgAYQBiAGUAdFJlZ3VsYXIAUgBlAGcAdQBsAGEAclRzY2lyY3VpdEFscGhhYmV0IFJlZ3VsYXIAVABzAGMAaQByAGMAdQBpAHQAQQBsAHAAaABhAGIAZQB0ACAAUgBlAGcAdQBsAGEAclRzY2lyY3VpdEFscGhhYmV0UmVndWxhcgBUAHMAYwBpAHIAYwB1AGkAdABBAGwAcABoAGEAYgBlAHQAUgBlAGcAdQBsAGEAclZlcnNpb24gMC4xAFYAZQByAHMAaQBvAG4AIAAwAC4AMSA6VHNjaXJjdWl0QWxwaGFiZXQgUmVndWxhcgAgADoAVABzAGMAaQByAGMAdQBpAHQAQQBsAHAAaABhAGIAZQB0ACAAUgBlAGcAdQBsAGEAcgAAAAABAAMAAQAAAAwABAK4AAAAqgCAAAYAKgAAACEAIgAjACQAJwAoACkAKgArACwALQAuAC8AMAAxADIAMwA0ADUANgA3ADgAOQA8AD0APgBBAEIAQwBEAEUARgBHAEgASQBKAEsATABNAE4ATwBQAFEAUgBTAFQAVQBWAFcAWABZAFoAWwBcAF0AXgBfAGEAYgBjAGQAZQBmAGcAaABpAGoAawBsAG0AbgBvAHAAcQByAHMAdAB1AHYAdwB4AHkAev//AAAAAAAhACIAIwAkACcAKAApACoAKwAsAC0ALgAvADAAMQAyADMANAA1ADYANwA4ADkAPAA9AD4AQQBCAEMARABFAEYARwBIAEkASgBLAEwATQBOAE8AUABRAFIAUwBUAFUAVgBXAFgAWQBaAFsAXABdAF4AXwBhAGIAYwBkAGUAZgBnAGgAaQBqAGsAbABtAG4AbwBwAHEAcgBzAHQAdQB2AHcAeAB5AHr//wAA/+D/4P/g/+D/3v/e/97/3v/e/97/3v/e/97/3v/e/97/3v/e/97/3v/e/97/3v/c/9z/3P/a/9r/2v/a/9r/2v/a/9r/2v/a/9r/2v/a/9r/2v/a/9r/2v/a/9r/2v/a/9r/2v/a/9r/2v/a/9r/2v/a/9n/2f/Z/9n/2f/Z/9n/2f/Z/9n/2f/Z/9n/2f/Z/9n/2f/Z/9n/2f/Z/9n/2f/Z/9n/2QABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEABAEAAQEBGVRzY2lyY3VpdEFscGhhYmV0UmVndWxhcgABAQEo+BsA+BwC+B0D+B4Ei/tV+kD5SAUdAAABOQ8dAAAB4BGLHQAASd0SAFcBAQwlNj0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkFZlcnNpb24gMC4xVHNjaXJjdWl0QWxwaGFiZXQgUmVndWxhclRzY2lyY3VpdEFscGhhYmV0UmVndWxhciEiIyQnKCkqKywtLi8wMTIzNDU2Nzg5PD0+QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVpbXF1eX2FiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6AAAAAYsBjAGNAY4BjwGQAZEBkgGTAZQBlQGWAZcBmAGZAZoBmwGcAZ0BngGfAaABoQGiAaMBpAGlAaYBpwGoAakBqgGrAawBrQGuAa8BsAGxAbIBswG0AbUBtgG3AbgBuQG6AbsBvAG9Ab4BvwHAAcEBwgHDAcQBxQHGAccByAHJAcoBywHMAc0BzgHPAdAB0QHSAdMB1AHVAdYB1wHYAdkB2gHbAdwB3QBUAgABAAQAeADuAgwFUgWPBmUHOwffCGMIzwkMCUgJhQq1CzwMhg5ADwwQUBHfEt8U3hYZFqIXFxeiGEIZtBsIHCccsh0sHpIfGh9XIC8gtiEFIjwjJSRTJWUmviftKXQp2CqzK0gsfS0ILW8uPy6iLuAvQy+2L/IxEDItM0A0XjWWNlQ39zjFOTk59zp9Oro76Dy1Pd8+/EAaQJVCDELOQ49EGEVZReRGgUdR+UgO+Uj37vlBFYv8VgWIewWBfQV8ggV6iAV6jgV8lAWBmQWImwWL+FYFjpsFlZkFmpQFnI8FnIcFmoIFlX0FL/z3Fe+LBZyIBZmCBZV9BY97BYd7BYF9BX2CBXqIBSeLBXqOBX2UBYGZBYebBY+bBZWZBZmUBQ75SPdm+UEVi/uBBYh7BYF9BXyCBXqIBXqOBXyUBYGZBYibBYv3gQWOmwWVmQWalAWcjwWchwWaggWVfQX3p3sVi/uBBYh7BYF9BXyCBXqIBXqOBXyUBYGZBYibBYv3gQWOmwWVmQWalAWcjwWchwWaggWVfQUO+Uj3XvcoFYAiBYZ7BYB/BXyDBXmJBXqQBX6VBYOaBYmbBZPgBSR/BXqMBXuSBX+YBYaaBYycBZOaBZiVBZyRBfcPmgWe91QFKH8FeYwFfJIFf5gFhZoFjZwFkpkFmZYFm5EF9wyZBZ33RgWQmgWWmAWakwWdjQWchgWYgQWUfAWMewV7+zIF9zifBZr3JgWQmgWWmAWbkwWcjQWchgWZgQWTfAWNewV++xMF8JcFnIoFm4QFl34FkHwFinoFg30FfoAFeoUF+w19BXj7VQXslwWdigWahAWXfwWRewWKegWDfQV+gAV6hgX7CnwFfvscBYZ7BX9/BXyDBXqJBXqQBX2VBYOaBYmbBZf3CQX7MM0V9zifBZ/3VAX7OHcFDvlI9/T5XhWL/awFiHoFgX4FfIEFeogFeo4FfJUFgpgFh5wFi/msBY+bBZSZBZqUBZyOBZyIBZqCBZV9BfcB+2YVNd0FgpkFiJsFjpsFlZkFmpQFnI4FnIcFmoIF4DkFlX0FjnoFh3sFgX4FfYIFeYgFeo4FQ9sV+z+bBXuQBX2VBYOaBYmbBZCbBZeYBZqTBZ2MBfc+ewWchgWZgAWTfQWMegWGfAWAfgV8gwX7LqUVKjgFe4MFeogFeo8FfZUFgpkFiJwFkJsFlZgF7d4FmpMFnI0FnIcFmYEFlH0FjnsFh3sFLD4VZvsHBYN8BX2BBXqGBXqMBXuTBYCYBYabBY2bBa/3CAWTmQWZlgWckAWciQWbgwWWfwWQewVkIRWkSQWNegWHewWAfgV8gwV6iQV6jwV9lQWCmQVyzQWJmwWPmwWWmQWakwWcjQWchwWZgQWdTxXUWgWXfwWRewWKewWEfAV+fwV7hgV5iwV7kgVCvQV/lwWFmgWLnAWTmgWYlgWbkQWdigXTWhX3fFkFm4QFl38FkXwFi3oFhHwFfoAFe4UFeYwF+3y8BXuSBX+XBYWaBYycBZKaBZeWBZyRBfedUhXVWgWWfwWSewWKewWEfAV+fwV6hgV6iwV7kgVCvAV/mAWFmgWLnAWTmgWXlgWckQWcigX2PBWjOAWMewWGewV/fgV8hAV5igV6kAV+lgWDmQVz3gWKmwWQmwWXmAWakgWdjAWbhgWZgAWp+xAVW/sHBYF9BX2BBXqIBXmOBX2UBYGYBYebBY6cBbz3BwWUmQWalQWcjgWciAWaggWVfQWPewU/+y8V+w5aBXqHBXmOBX2UBYGZBYebBY6bBZWZBZmUBfcOvQWcjgWciAWaggWVfgWPewWIewWBfQX7M00V+zObBXuQBX2WBYOZBYqcBZCaBZaYBZuTBZyMBfczewWchgWYgAWTfAWNewWFewWAfwV7gwX7VqAVNb0Ff5YFg5oFi5sFkZsFl5cFm5IFnIsFnIYF4FkFmIAFknwFjHoFhXwFf38Fe4QFeYoF+wzZFWbuBYmbBY+bBZaYBZqUBZyNBZyHBZmBBZR9BbAnBY17BYd7BYB+BXyDBXmIBXqQBX2VBQ75SPfu+UEVi/uBBYh7BYF9BXyCBXqIBXqOBXyUBYGZBYibBYv3gQWOmwWVmQWalAWcjwWchwWaggWVfQUO+Uj4Ko0VsmUFlX0FjnsFh3sFgX0FfYIFeYgFeo8FfZQFYrMFio0FiYwFY7sFiowFiowFYsMFiowFiowFY8oFio4FiY0FbcoFio4FiY4Fd8oFi44Fio0FgcMFi5IFi5IFlcMFjI0Fi44Fn8oFjY4FjI4FqcoFjY0FjI4Fs8oFjIwFjIwFtMMFjIwFjIwFs7sFjYwFjI0FtLMFmZQFnI8FnYgFmYIFlX0Fj3sFiHsFgX0FZGUFZV4FZFUFZE8Fb1AFeFEFg10Fk10FnlEFp1AFsk8FslUFDvlI95tWFYqJBWJjBX2CBXqHBXmOBX2UBYGZBYebBY6bBZWZBbKxBbG4BbLBBbLHBafGBZ7FBZO5BYO5BXjFBW/GBWTHBWTBBWW4BWSxBYGZBYibBY+bBZWZBZqUBZyOBZyHBZmCBbRjBYyJBY2KBbRbBYuKBY2KBbNTBYyKBYyKBbRMBYuIBY2JBapMBYuIBY2IBZ9MBYuIBYyJBZVTBYuEBYuEBYFTBYqJBYuIBXdMBYmIBYuIBWxMBYmJBYuIBWJMBYqKBYqKBWNTBYmKBYuKBWJbBQ75SPeU+FUV+zRWBXqIBXqPBX2VBYKZBYicBY+bBZaYBZqTBfc5wgUh9yQFhJoFi5sFkZsFmJYFm5IFnIsFm4UFmIAF8fsfBfH3HwWYlgWbkQWciwWchAWXgAWRewWLewWEfAUh+yQF9zlUBZqDBZZ+BY97BYh6BYJ9BX2BBXqHBXqOBfs0wAWL+yoFiHsFgX0FfIIFeogFeo4FfJQFgZkFiJsFDvlI95T39hWL90sFjpwFlZgFmpUFnI4FnIgFmoEFlX4FjnoFi/tLBfdpiwWciAWaggWVfQWOewWIegWBfgV8ggV6hwX7aYsFi/tLBYh7BYF9BXyCBXqIBXqOBXyUBYGZBYibBYv3SwX7aYsFeo8FfJQFgZgFiJwFjpsFlZkFmpQFnI4FDvlI96puFcJVBZV9BY56BYd7BYF+BXyCBXqIBXqOBX2VBTXfBYeRBYaRBYuMBYqMBYqSBYmSBYyMBYqMBY2SBYyTBYyLBYuMBZCRBY+RBfc/9zwFmpUFnI4FnIgFmoMFlX0Fj3sFiHsFgX0FDvlI90L35RX3kosFnIgFmoIFlX0FjnsFiHsFgX0FfIIFeogF+5KLBXqOBXyUBYGZBYibBY6bBZWZBZqUBQ75SPf/7RX7D4sFeY4FfZQFgZkFiJsFjpsFlZkFmZQFnY4F9w+LBZyIBZmCBZV9BY97BYd7BYF9BX2CBQ75SKOAFfhx+WMFl5cFm5EFnYwFm4UFmIAFknwFjHoFhXwF/HH9YwV/fwV7hQV5igV7kQV+lgWEmgWKnAUO+Uj4CfkPFUOeBUN4BUZQBWMvBYH7JQWj+wwFxi0F2F0FyYsF2LkFxukFo/cMBYH3JQVj5wVq9x4VjYoFkYgFkYgFjIoFjYoF4EEFi4sFjIoFj4UFkIUFi4oFjIoFuSEFjIQFjYUFlvsyBYqGBYuGBXH7GQWIhQWJhAVH+wIFiYoFiokFhocFh4YFiYoFiooFKVEFh4kFiIkFhooFh4oFh4sFh4oFM4sFh4wFh4sFh4wFhowFiI0Fh40FKcUFiowFiYwFh5AFho8Fio0FiowFRvcCBYmSBYiRBXH3GQWLkAWKkAWW9zIFjZEFjJIFufUFjIwFi4wFkJEFj5EFjIwFjIsF39UFjYwFjIwFkY4FkY4FjYwFjYsF6aMFjowFjowFkYoFkYwFjooFjooF6XMFDvlI9/v5ZRWQjgWNjAWNjAWSiwWSjQWMigWNiwWSigWSiQWMigWNiwWRhwWQhwWMigWNigWOhQWPhQWMigWLiQWMhQWNhAWL/REFh3sFgX0FfYIFeogFeY4FfZQFgZkFiJsFi/i2BTRFBXuDBXqJBXqPBX2WBYOZBYmbBY+bBZaYBfc19xUFDvlI90rmFffoiwWdiAWZggWVfQWOewWIewWBfQV9ggV5iAX8TosFg4wFg4wFiowFiosFhY8FhI8Fi4sFiowFhpEFh5EFi4wFiowFipIFiZIFi4wFi4wFjJIFjJIFjIwFi4wFj5EFj5EF9zn3PgX3L/dKBcTlBZezBYueBYOqBXeiBV6dBUaQBWaGBVBzBWttBX9mBYN9BX6ABXqGBXmNBXyTBYCYBYaaBYycBZu6BYuMBYyNBY+QBY6RBYyMBYyNBbi2BYuLBYuLBZOQBZKQBYuLBYuLBdWoBZCNBZGMBbqSBZCKBZCMBd2FBZKJBZKKBclxBYyKBY2LBZCHBZGHBYyKBY2JBaxlBYyKBYuKBY+FBY6EBYuKBYyKBZdeBYuFBYyGBYptBYqGBYuGBX1ZBYiFBYmGBUwpBYmJBYqJBfsy+04FiooFiooFDvlI9wqUFYeMBVObBXySBX+YBYabBY2bBZOaBZmVBZuQBZ2KBcB8BdeABeiJBb2WBdGxBbW2BZy5BYOvBWWzBUStBTSiBT2UBYiMBYiLBYWOBYaMBYmNBYiNBYePBYeOBYmOBYmNBYmQBYmQBYuOBYqOBYuQBYuRBYyNBYuOBY2QBY2QBY2NBY2OBY+PBY+PBY6MBY2NBZCNBZGNBY6LBY6MBduVBeKdBdGpBauoBZGqBXWtBV2uBUagBTyPBUp2BVZxBWhxBXyEBXmKBXuQBX2WBYOZBYqcBZCaBZeYBbCnBY+MBY6OBceoBY6MBY6NBdikBZOMBZSMBemGBZCKBZGKBd1yBZKIBZOHBcVeBZCGBZCGBa9UBY2EBY6FBYuKBYyKBYqEBYuDBYBQBYmHBYqHBYmIBYmHBYiIBYiHBVxfBYWGBYSHBUduBdFqBZGGBZKHBcBUBYyIBY6JBY2GBY6HBYuIBY2HBZZQBYuJBYyIBYqFBYuGBYqIBYuJBXNKBYuLBYuLBYeEBYaEBYuLBYuLBVZUBYWHBYaHBTlfBYWJBYWIBU19BYWLBYWKBSeNBYiMBYiLBTmWBQ75SPgF98IVi+oFj5sFlJgFmpUFnI4FnIgFmoEFlX4FjnsFiywF6YsFnIcFmoIFlX0FjnsFiHsFgX0FfIIFeogFLYsFi/s9BYh7BYF9BXyCBXqIBXqOBXyUBYKZBYebBYv3PQX71IsFhIwFhYwFiYwFiYsFhY8FhY0Fio0FiYwFh5AFh5AFi40FiY0FipEFiZEFi40Fi40FjJEFjJEFjI0Fi40Fj5EFjpAF+Ab4PgWYlgWcjwWcigWbgwWWfgWQfAWKegWCfQX7yfv5BQ75SKn5QRWOmwWVmQWalAWcjwX4WIsFnIcFmoIFlX0FjnsFiHsFgX0FfIIFeogF/CuLBYv7dwX3HakFk4sFk4wF9x57BZOIBZOJBcJuBZGGBZGHBbFiBYyJBYyKBY6FBY+FBYuKBYyJBaj7BAWLigWLigWLhAWMhAWKigWLiQV9UQWLiwWLigWHhAWIhAWLiwWKigVnXgWFhQWFhgVFYQWFiQWFiAU5dQWGigWGigU+hwWFjAWGiwVKlwWGjQWGjAVWogWGjgWFjwVUugWAmAWHmwWOmwWUmQWZlQWcjwWciQWaggW9YQW0eQXCgQXNjgXSngXFrgWlqwWUswVz5wVxpwVjoAX7DZkF+01iBYaLBYaKBYeMBYiKBYaNBYaMBYiNBYeMBYePBYeNBYmOBYiNBYmQBYiPBYuOBYmPBYuPBYqQBQ75SPch96QVi4sFi4sFbW4FioMFnlkFm24FtWEFtHIFzoEF2o8FxaMFsqoFnrMFjaoFf7MFeKwFcqQFZ5sFUJcFU44FU4MFU28F+yxcFYqPBYyRBYy5BYuLBYuLBY7cBY2RBYyRBafaBYyNBYuNBbTfBZCSBZCRBcC7BY6NBY2NBdC4BZGOBZCOBdykBYyLBYuLBeKlBZ2NBZuGBZmBBZN8BY17BYZ7BYB+BXyDBTRyBUFzBU9kBV5jBWdABXJEBYp7BZGOBZCPBdGtBZKNBZKOBc6UBZCLBY+LBcuJBY+KBY+LBc58BZCKBZCJBbt2BZKGBZKHBa5oBY6GBY+GBaNhBYyHBY2HBZpZBYyEBYyFBYlbBYuLBYuLBYmDBYmDBYuLBYuLBW9UBYuKBYqKBYaGBYeFBYqKBYqLBVhiBYaIBYaIBUNtBYOJBYOJBS+GBYeMBYaLBTmXBYqLBYqLBYSOBYOOBYuLBYqLBVasBYiPBYaNBVq8BYeQBYeQBXaxBYqOBYqOBXXHBYqSBYmTBQ75SPfP90gVg/saBYd7BYF+BXyCBXmJBXqPBX2VBYKZBYmbBZL3HAWMjQWLjQWc9wcFi4wFjI0Fms0FjI0Fi4wFnsYFjIwFi40FoL4FjIwFi40ForcFjIwFi40Fo7EFjIwFjI0FoqoFjI0FjIwFoqYFjYwF+96LBXmOBX2UBYGZBYibBY6bBZWZBZmUBZ2PBfhfiwWQigWQigWOigWPigWPiAWQiQWOiQWNiQWOhwWPhwWMiAWNiAWMhgWNhgWLiAWMiAWJhgWLhgWKiAWKiAWIhwWJhgWIiQWJiAWHiAWHiAVqeQV9gQVkaAV3dAV2bgV1aAV2YgV4WwV5UwV8TAUO+Uj3pvf2FUR0BUpaBXBZBYleBaZdBcVnBdlzBciJBeCmBb6wBaLEBYLEBWK1BTi2BVKfBdH3sxU4kQVLgAVXcwVrXQWVaQW4ZQW/bAXDeAWwlgXetQWdpgWMwwV1rwVr9wEVi4sFk4gFk4kFi4sFjIsF0GgFjokFj4kFjocFj4gFjYgFjYgFrVIFjIkFjYgFjIYFjYYFiogFjIgFiTwFi4gFi4kFiYUFioYFiYkFiogFbVwFiYkFiYgFh4gFh4cFiIoFiYkFUm4F0mYFkIcFkYcFw1IFjYcFj4gFjIcFjYgFjIYFjIcFmDoFi4kFi4kFioUFi4UFiokFiokFbDwFiYcFiogFh4cFiYgFiIgFiIkFR1sFhYgFhYcFJ2sFg4oFg4oFP40FhY0FhIsFMqcFho4FhY0FQ7gFio0FiYwFho8Fh5AFio0FiYwFZc0Fio4Fio4FipAFiZAFjI4Fio4Fjs0Fi4wFi4sFjZMFjZIFi4wFi4sFr80Fi4wFjIwFkJAFkJEFi4wFjIsF2sYFkY4Fko8FmI8FaZ8FiI4Fh40FUrwFiY0FiI4FiY8FiI8Fio4FiY4FeMsFi40Fi4wFipIFi5IFi4wFi4wFjpIFjZIFjIsFjI0Fu9IFjo4FjY4Fj44Fj44Fjo0Fjo0F0KsFkYwFkY0F15gFkIsFkYwF7YQFDvlI+Fr4mBWVnQV8xwVwqwVfoAVIkwVHgwVTdAVnagV+XwWYYAWvaQXDdAXMhAXMmgW8qgVf/BoVi4oFZ0IFgX4FfIIFeYgFeo8FfZUFgpkFiJsFj5sFr9QFtuoFwPcXBYuLBYuMBZKcBT55BYOKBYKLBTuUBYWNBYWMBUWoBYSPBYSQBVm6BYqNBYmMBYiQBYeQBYuOBYqNBXfNBYqOBYqOBYyQBYqQBYyOBYyPBZ/NBYyNBYuNBY+QBY6QBY2NBYyNBb26BZKPBZKQBdGnBZGMBZGNBduVBZGKBZGMBduBBZKJBZKJBcdvBYyKBYyLBZGGBZGHBYuKBYyKBbNcBYyKBYyKBY6FBY6FBYuJBYyKBZ83BYuFBYyEBYqJBYuJBYmFBYmGBYqHBUH7SAVW+xgFi4oFiooFXysFDvlI9y/3yxX4OvtDBZqBBZR9BY57BYd7BYF9BXyCBXqJBXqOBfyY92oFhI8FhY8FiowFiowFh5EFh5EFi4wFiosFipMFiZIFi4wFi4wFjZIFjJIFjIwFi4wFj5EFj5EFjIwFjIsFkY8Fko8F+Jj3agWcjwWciAWaggWVfgWPewWIegWCfQV8ggUO+Ui2+GkV+JiLBZyIBZqCBZV9BY57BYh7BYF9BXyCBXqIBfyYiwV6jgV8lAWBmQWImwWOmwWVmQWalAWc+4gV+JiLBZyIBZqCBZV9BY57BYh7BYF9BXyCBXqIBfyYiwV6jgV8lAWBmQWImwWOmwWVmQWalAUO+Uj44/fpFYyKBY+FBY+FBYuKBYyKBYyEBY2EBYuKBYuKBYmEBYqDBYqLBYuKBYeFBYeFBYqKBYqKBYWHBYSHBfyY+2oFeogFeo0FfJQFgZkFh5sFjpsFlJkFmpUF+Dv3QwX8O/dDBXyUBYKZBYicBY+bBZWYBZqUBZyOBZyHBfiY+2oFkocFkYcFDvlI+Ev3kxWGigX7q4sFi4sFLPtyBYF9BX2CBXqIBXmOBX2UBYGYBYecBY6bBfek+REFkJIFkJIFi4sFi4sFko8FkpAFi4sFjIsFk40Fk40FjIsFi4sFk4kFlIoFi4sFi4sFkoYFkocFjIsFi4sFkIQFj4QF97r9EQWPewWIegWBfgV9gQV6iAV5jgV9lAWBmAX7IvfIFfsB94AFJvuABQ75SPe++GUV2bYFlMsFTL8F+weeBSmGBYv7VgX32vxEFYSJBYmLBYmLBfv7hwWKiwWLiwWDjAWCjQWLiwWLiwWEjwWEkAWKiwWLiwWGkgWHkQWLjAWKiwWKkwWJkgWLjAWLiwWL+QoFjJIFjZIFi4wFi4wFkJEFjpEFjIwFjIwFkY8FkY8FjYsFjIwFkowFk40F9yWTBZCKBZCLBfcZdQWOigWPigWQiQWQiQWNiQWOiQXlQQWNiAWPiQWNhwWOhwWMhwWNiAWLhgWMhwWLhwWLhwV9+wAFiokFi4gFiIYFiYYFiYkFiogFh4cFh4cFiIoFiYkFSGYF9wJmBY6JBY+KBY+IBY+JBY2IBY6IBdE3BY6GBY6FBYyJBYuKBYyEBYyEBYX7AAWLiQWLiQWJhQWJhQWKiQWKiQVsWwWIiQWKiAWHiAWHhwWIigWIiQU+ZAWJigWJigVu3BXEqAWeqAWP3QVYyQX7JLsF+1CWBYv7nAUO+Uj4ZPclFaDbBZOZBZiXBZuQBZ2KBZuEBZd/BZF7BYp7BXIwBYqIBYqHBYiHBYmHBYiIBYmIBUNLBYiJBYmJBYaJBYaIBYiLBYiJBSl1BYuLBYuLBYOLBYKLBYuLBYuLBfsEnAWJiwWKjAWEjQWEjgWKjAWKiwVRsQWFkQWFkQVU3QWLiwWLiwWIkwWIkgWLiwWLiwVm918Fi5MFi5MFuvdeBYyMBYuNBY+RBY2RBY2MBYyNBc7XBYyMBYuLBZGQBZKQBYuLBYuLBdGsBZKNBZKOBdqVBYyLBYyLBZOKBZKLBYyKBY2LBfVqBYyLBYyLBZKHBZGHBYyLBYyKBcNZBYyLBYuKBZCFBY+FBYyKBYuLBapEBY57BYh7BYF9BXyCBXqIBXqOBXyVBYGYBXDJBWKwBTSlBU6EBVVxBVRNBWD7TAWt+04FuUgFtG8F6H0F2JwFDvlI93uVFYaKBfs1iAWLiwWKiwWDjAWDjQWKiwWLiwWEjwWEjwWLjAWKiwWHkgWGkQWLjAWLiwWJkwWJkgWMjAWKiwWT+QQFjJAFi5EFjY0Fi48Fj48FjY8FjY4FjY0FkI4Fj44Fjo0FjowFkIwFkY0F7pgFj4sFjowF14kFkYoFkIsF9xBrBYuLBYuLBZOHBZKIBYyLBYuKBeZIBYyKBYuLBZCFBZGFBYuLBYuKBb8wBY2FBY6GBaAsBYuHBYyHBY1EBYqHBYuIBYJOBYmHBYqHBXhXBYeFBYmGBUw8BYWGBYWGBTdZBYWJBYWIBfsdaAV53hX3EasF0rUFwM4Fm7UFlMAFicsFeOAFXtoFPsQF+wGnBUiMBVGDBYX8tAUO+Uj3EeUV+CGLBZyIBZqCBZV9BY57BYh7BYF9BXyCBXqIBfxOiwV6jgV8lAWCmQWHmwWL99MFi/fSBY+bBZSZBZqUBZyPBfhOiwWchwWaggWVfQWOewWIewWBfQV8ggV6iAX8IYsFi/t+BfeciwWdiAWZggWVfQWOewWIegWBfgV9ggV5hwX7nIsFDvlI9xf32hWL+6oFiHsFgX0FfYIFeYgFeo4FfZQFgZkFh5sFi/kRBY+bBZWZBZmUBZyPBZ2HBYyKBfgviwWciAWZggWVfQWPewWHewWBfQV9ggV6iAX8FYsFi/t4BffQiwWdiAWZggWVfQWOewWIewWBfQV9ggV5hwUO+Uj4fve0Ffs1iwV6jwV9lAWBmQWImwWOmwWVmQWZlAWdjgX3bIsFj4oFkIsFj4kFj4oFj4kFj4kFjogFj4kFjYgFjocFjYgFjYcFjIcFjYcFi4cFjIcFiocFi4cFXvtaBYqJBYuIBYiGBYiGBYmJBYqJBUtGBYmKBYqJBYWIBYaHBYmKBYmKBTpwBYqLBYuKBYOKBYOKBYqLBYqLBTWSBYSNBYSNBTmuBYWOBYaOBUfCBYaQBYaQBV/QBYuMBYqMBYmRBYiSBYuMBYuMBXf3UgWLkQWLkgWx90IFjIwFi40FjpEFjpEFjIwFjI0FzdsFjIwFi4wFkZAFkY8FjIwFjIsF37QFi4sFi4sFk40Fk44Fi4sFi4sF9xeVBZKKBZGLBfcQcQWbhQWXfwWRfAWLegWEfAV+gAV7hQV5iwX7CKMF+weCBUhrBVZJBWj7MwWe+0IFrlUFxFwF0W4Fz4UFx6AFvL8FDvlI+H74OhWL95sFj5sFlJkFmpQFnI8FnIcFmoIFlX0FjnsFi/0RBYh7BYF9BXyCBXqIBXqOBXyUBYKZBYebBYv3tgX8DosFi/u2BYd7BYJ9BXyCBXqIBXqOBXyUBYGZBYibBYv34AWL98UFjpsFlZkFmpQFnI8FnIcFmoIFlH0Fj3sFi/ubBQ75SPfu+UEVi/0RBYh7BYF9BXyCBXqIBXqOBXyUBYGZBYibBYv5EQWOmwWVmQWalAWcjwWchwWaggWVfQUO+Ui/9z4Vio4Fia8FjpsFlJkFmZUFnY4FnIkFmoIFlX4Fj3sFjGsFkXIFlXYFmXkFnX0FunoFzoQFu5EFwp8FoJkFnJ0Fl6EFk70FivhxBY6bBZWZBZqUBZyPBZyHBZqCBZR+BY96BYz8dAWKiAWLiAWCTgWJhQWJhAV5awWHhgWIhwVycQWHiAWIiAVtdwWGiQWGiAVKcwWGigWFigVRhAWGiwWGiwU8kwWFjAWFjAVRoQWFjwWFjQVvoQWHjwWHjgV2pQWJkAWIjwV+qAWKkAWJjwWEqwUO+Uj3Uff3FfsBOQWL+3UFiHsFgX0FfYIFeYgFeo4FfZQFgZkFh5sFi/kRBY+bBZWZBZmUBZyPBZ2HBZmCBZV9BY57BYv7xAX4Hve7BZuSBZyNBZyGBZiABZR8BYx7BYZ7BX9/Bfui+14F9+b70AWVfQWPewWHewWCfQV8ggV6iAV6jgV8lAUO+Uj3DOUV+CuLBZyIBZmCBZV9BY97BYd7BYF9BX2CBXqIBfxYiwV6jgV9lAWBmQWHmwWL+REFj5sFlZkFmZQFnI8FnYcFmYIFlX0FjnsFDvlI+KH5WxWOjwWNjQWNjQWRjQWPjgWOjAWOjAWRjAWRjAWOigWOiwWQiQWRigWNigWOigWQhwWPiAWNiQWNiQWOhgWOhgWMiQWMiAWLhgWNhQWL/REFh3sFgX0FfYIFeogFeY4FfZQFgZkFiJsFi/h1BftD+6wFiYkFiokFhocFh4cFiYkFiYoFhYkFhYgFiYsFiIoFhYwFhYoFiIwFiYsFhY4FhY0FiYwFiY0Fh48Fho8Fio0FiY0F+0P3rAWL/HUFiHsFgX0FfYIFeYgFeo4FfZQFgZkFh5sFi/kRBY2RBYuQBYyOBYyNBY6QBY6QBY2NBY2NBY+OBZCPBY6MBY2MBZGMBZCNBY6LBY6MBZGKBZGKBY6KBY6KBY+IBZGJBY2JBY2JBY6HBY+HBfdw+/UF93D39QUO+Uj4e/dPFYT4hgWOmwWVmQWZlAWcjwWdiAWZggWVfQWPewWU/REFioYFi4cFiocFiocFiYgFiYcFiIgFiIcFiIkFiIgFh4kFh4kFh4oFh4oFhosFh4oFhosFh4sFh40Fh4wFh40Fh4wFiI4Fh44FiI4FiI4F/BT4oQWL/IkFh3sFgn0FfIIFeogFeo4FfJQFgZkFiJsFi/kRBYyPBYuPBYyPBYyPBY6PBYyOBY6OBY6PBY6NBY6OBZCNBY+NBY+MBY6NBZCLBZCMBY+KBY+LBY+JBZCKBY+JBY6KBY+IBY+IBY2IBY6IBQ75SPgblBWFiAWJiwWJiwUzgAWKiwWKigWEjAWDjAWKiwWKiwUypQWJjAWIjAWGjgWGjgWJjQWJjAU62gWJjgWIjgWJjwWIjwWLjwWJjgVP96AFi40Fi4wFi5IFi5IFjIwFi40FxPddBY2PBYyPBY6OBY2PBY6NBY6PBdHEBYyMBYyMBZKOBZGOBY2LBYyMBfcOqQWPiwWPjAWQigWPjAWPiQWPiwX3B2cFjIoFjYsFkYcFkYgFjIoFjYkFzkoFjYgFjYkFjocFjYYFjIgFjIgFxfuJBYuDBYuDBW/7LgWIhAWJhQVYMgWKiQWLigWGhgWGhgWKigWKigUwTgWJigWKigUg0BXOkwXUvAW11gWl9x8FVvd1BVm8BTCoBShzBVdgBVj7RgXD+4sFy00FDvlI93j3xxWJigX7AooFi/uVBYd7BYF9BX2CBXqIBXmOBX2UBYGZBYibBYv5BQWMkQWMkgWMjAWLjQWPkQWOkAWNjAWMjQWQjwWRjwWNiwWMjAWSjQWRjAX3HZcFjosFj4sF9w6EBY+KBZCLBdp2BY+KBY+KBa96BZCIBZCIBcRbBYuKBYuLBZCFBZCEBYuLBYyLBaRXBY2EBY2EBZA/BYuJBYuJBYqFBYqFBYqJBYuJBXRcBYqJBYqJBYeHBYeFBYmKBYqKBWhxBYWIBYWIBVN2BYeKBYeJBTp8BYiLBYmLBfsCggWF4BX1kwXWmQW5nAWgmwWZpwWGxAV6sAVesQVxlwVEnQX7BpIFL4MFi/uJBQ75SPiTtRXQOQWTfAWNewWFewWAfwV7gwV6igV6kAV+lQVRzwVUYAWIigWJiQWGiQWGiAWHiwWIigU1fgWJjAWJigWEjAWFiwWJjAWIiwU0qQWJjAWIjAWGjgWGjgWJjgWJjAU75AWKjgWJjQWJkAWIkAWLjgWKjQVQ98MFi4sFi4sFi5MFi5MFi4sFi4wFw/d2BY2OBYyPBY2PBY6PBY2OBY2OBdDLBY2MBYyNBZGOBZGOBY2MBY2MBfcLrAWRjAWRjAWNigWOjAWRiQWRigX3BGMFjYoFjooFj4cFkYgFjIkFjYoFzUEFjIkFjYkFjYYFjoYFjIgFjIkFw/uoBYuEBYuEBW/7QgWJhQWJhQX7K0AVMfUFg5oFipsFkJsFlpcFm5MFnIwFnIYFmIEF0zcFmqkFpfc1BVb3lgVZxAU0qgUucQVXWgVY+2IFwvuvBctDBcx2BcmUBQ75SPfz+EoV3JcFrpgFoJsFlqIFjLMFfbkFgZYFd5gFcZUFQZsF+xSQBfsofgWL+10F90g8FftIhQWL+7cFh3oFgn4FfIEFeogFeo4FfJUFgZgFiJwFi/j8BYyRBYyRBYyNBYuNBY+QBY6RBY2MBYyNBZGOBZCPBY2MBY2MBZGMBZKNBfdUmwWOiwWOjAX3G4UFj4oFj4sF3HoFj4kFj4sFrX0Fj4kFj4kFp3kFj4cFkIgFoHQFi4oFjIsFjoQFj4UFi4oFjIoFnU0FjIUFjIUFiVQFi4sFiYMFiYMFi4sFeWQFiooFi4oFhoUFhoUFiosFi4oFaXAFhIgFhYcFXXoFhooFhokFNX8F94H7rQWTfQWNegWGewV/fwV8gwV5igV6kAV+lgX7nPfLBYOaBQ75SOXBFYaOBYqNBYiNBYmQBYeQBVr3AQWHnAWOmwWVmQWZlAWcjgWdiAWZggWVfgW3KgXNaQX3IIcF7bgFq/AFdsUFS68F+4ezBYiNBYiLBYaNBYaNBYmOBYiMBUu+BYiPBYiOBYmOBYiOBYqQBYmOBXrHBYuPBYqOBYuQBYuPBYyPBYyPBbT3DAWOkAWNkAWNjQWMjQWQjwWPjwXvzAWRjgWQjgWOiwWNjAWRiwWRjAX3R4IFjYoFjIwFkogFkooFjIoFjYoFkIcFkYcFjIoFjIoF1zAFknwFjXoFhXwFgH4Fe4QFeYoFe5AFfpYFTNYF+yOTBUBaBWssBZVoBbZoBfeDYwWTiQWTiAXfWgWQhwWQhwWNiQWMigWOhQWOhgWrNgWLhgWNhwWLhwWLiAWKhgWKhgVi+xgFi4oFiooFh4UFiIQFiosFiooFhYYFhYcFiosFiooF+xJRBYmLBYqKBYSKBYSJBYmLBYmLBfs2jwWJjAWJiwWFjQWEjAWJjAWJjAUzuQUO+Uj3yflsFfeiiwWchwWaggWVfQWOewWIewWBfQV8ggV6iAX7dYsFi/znBYh7BYF9BX2CBXmIBXqOBXyUBYKZBYebBYv45wX7hYsFeo4FfJQFgZkFiJsFjpsFlZkFmpQFnI8FDvlI+HT3hxWQ+E4Fj5sFlZkFmZQFnY4FnIcFmYIFlX0FjnsFhvxQBYqIBYyJBYFHBYqHBYqGBXdYBYmIBYmHBX53BYiHBYiIBW1sBYWHBYaHBVhxBYSJBYSJBU2BBYWLBYSLBTOUBYaNBYWMBUWlBYWPBYWOBVyvBYeQBYWQBWjCBYiRBYiRBXnSBYqPBYqOBYTsBYuNBYuMBYr39wWOmwWVmQWalAWcjwWchwWaggWVfgWOegWM+/UFki8Fm00Fp2EFr28FxXYF14IFu5MFsJ4FoqIFk5cFnLYFDvlI99H3NRX3a/ivBZSZBZqVBZyPBZyIBZqCBZV+BY97BYh6BfuS/REFi4sFi4oFhoUFh4QFi4sFiooFhIcFhYYFiosFi4sFg4kFg4oFiosFi4sFg4wFgowFi4wFiosFhI8FhI8Fi4sFi4wFhpEFhpEFi4wFi4sF+7j5EgWHmwWOmwWVmQWZlAWcjwWciAWaggWVfQUO+Uj4dvdYFdf4gwWQmwWXlwWbkgWcjAWchgWYgAWTfAWMegUq/REFiYcFioYFiYgFiocFiIgFiIcFiIkFiIgFh4kFh4kFh4oFh4kFh4sFhooFh4sFh4sFho0Fh4sFh40Fh40FiI4Fh40FiI4FiI4FiY8FiI4F+0b3/wX7Ofv2BYiHBYiGBYmJBYmJBYaIBYeHBYiKBYiKBYaKBYWJBYiLBYiLBYWMBYaLBYiNBYiLBYaOBYaOBYmNBYiNBYiPBYiPBYqOBYmOBYqQBYmQBTv5CQWNnAWTmQWYlgWckAWcigWbhAWWfgWRewXH/G8F9x/3vgWPkAWPkQWMjAWMjAWRjwWRjwWNiwWMjAWSjAWSjQWNiwWMiwWSiQWTigWMiwWMigWRhwWSiAWMigWMigWPhQWPhQUO+Uj3/Pf/FfeZ+7QFlH0FjXsFhnsFgH4FfIMFeYkFeo8FfpYF+5D3qQX7kPupBX6ABXqHBXmNBXyTBYCYBYabBY2bBZSZBfeZ97QF+5/3uwWCmQWJnAWQmwWWlwWalAWdjAWchwWYgQX3lvuxBfeW97EFmZUFm48FnYoFmoIFln8FkHsFiXoFgn0FDvlI9+j4EhWV++EFiHsFgn0FfYEFeogFeY0FfJQFgZkFh5sFgffjBfud96cFgpkFiJsFj5sFlpkFmpMFnI4FnIcFmYEF94n7kQX3k/eQBZqVBZyPBZyIBZqCBZV+BY96BYh7BYJ9BQ75SPci5RX4KosFnYgFmYIFlX0FjnsFiHsFgX0FfYIFeYgF/IKLBYWMBYaLBYiMBYeMBYeOBYaNBYmNBYiNBYiPBYePBYqOBYmOBYqQBYmPBYuPBYuOBYyQBYuQBYyOBYyOBY6PBY2QBfhP+M4F/CqLBXmOBX2UBYGZBYibBY6bBZWZBZmUBZ2PBfiCiwWRigWQigWOigWPigWPiQWQiAWNiQWOiQWOhwWPhwWMiAWNiAWMhwWNhgWLiAWLhwWKhgWLhgWKiAWKiAWIhwWJhgUO+Uj3h3QV9zaLBZyIBZmCBZV9BY97BYd7BYF9BX2CBXqHBftjiwV5jwV9lAWBmQWImwWL+Z8FjpsFlZkFmZQFnY4F92OLBZyIBZmCBZV9BY97BYd7BYF9BX2CBXqIBfs2iwUO+Ujw+VgV+HH9YwWRfAWKegWEfAV+gAV7hQV5jAV7kQV/lwX8cfljBYWaBYycBZKaBZiWBZuRBZ2KBZuFBQ75SPhWShWHewWBfQV9ggV6hwX7Y4sFeY8FfZQFgZkFiJsFjpsFlZkFmZQFnY4F9zaLBYv5SwX7NosFeY4FfZQFgZkFiJsFjpsFlZkFmZQFnY4F92OLBZyIBZmCBZV9BY97BQ75SPeo+WQVko8FjIsFjIwFkowFk40FjIoFjIwFk4kFkooFjIoFjIsFkocFkYcF9577ggWVfgWPewWIegWBfQV9ggV6hwV6jgV8lAX7f/dmBft/+2YFfIIFeogFeo8FfZQFgZkFiJwFj5sFlZgF9573ggUO+UiL+wEV+O6LBZyIBZqCBZV9BY57BYh7BYF9BXyCBXqIBfzuiwV6jgV8lAWBmQWImwWOmwWVmQWalAUO+Uj4POoVxcIFi/eQBVLBBVCnBS+LBVBvBUxQBWsvBYtQBaswBcpPBcdvBeaLBfcIZhWHiAWFhwVAZwWKigWJigWEigWFiQWJjAWJigX7BYsFiYwFiYoFhI0FhYwFiYwFiYwFQK8FhY8FhY8FP9MFiowFiowFiJEFh5EFiowFiowFZvYFipIFipIFi9IFjJIFjJEFsPcABYyNBYyMBY+RBY6RBYyMBYyMBdfTBZGPBZGPBdeuBYyMBY2MBZKMBZKNBYyKBY2MBfcFiwWMigWNjAWSiQWSigWMigWNigXWaAWQhwWQiAWLjwWPnAWUmAWalQWcjgWciAWagQWVfgWOegWL/IoFiHsFgX4FfIEFeogFeo4FfJUFgpgFh5sFDvlI9xOvFYaOBYuKBYd6BYF+BX2CBXqHBXmPBX2UBYGYBYicBYv5OAWOmwWVmQWZlAWdjgWciAWZggWVfQWPewWL+3YFkI4FkY8F1asFjIsFjIsFko0Fk40FjIoFjIwF9wSLBYyLBYuLBZOJBZOJBYyLBYuLBddrBZCHBZKIBdZKBYyKBY2KBY6FBY+GBYyJBYyKBbApBYyEBYyEBYtLBYqEBYqDBWYrBYqKBYqJBYeGBYiFBYmKBYqJBUBLBYWIBYWHBUBqBYqLBYqLBYSJBYOJBYqLBYqLBfsEiwWKjAWKigWDjQWEjQWKiwWKiwVBrAWA9w0VwlwFxnEF54sFx6UFycAFqdoFi70FbdsFTcAFT6QFL4sFUHIFVFwFDvlI+DLqFczNBZqVBZyPBZyIBZqDBZV9BY97BYl7BYF9BUVDBYWHBYWHBUZmBYiLBYmJBYWKBYWJBYiMBYmKBSGLBYmMBYiKBYWNBYWMBYmNBYmLBUSwBYWPBYWPBUXTBYqMBYqMBYeRBYeRBYuMBYqMBWn2BYqRBYqSBYvSBYyRBYySBa33AAWMjAWLjAWPkQWPkQWMjAWMjAXR0wWRjwWRjwXSrwWNiwWNjQWRjAWSjQWNigWNjAX1iwWNigWNjAWSiQWRigWNiQWNiwXRZwWRhwWRhwXRQwWVfQWNewWHewWBfQV8gwV6iAV6jwV8lQVKzQVWpgU3iwVVcAVRUAVtLgWLUAWoLwXGUAXCbwXdiwUO+Uj4PfUVwroFi/dxBVS6BVCkBS+LBU9yBU1WBW07BYtZBak8BclWBcdxBeeLBfcGYhWGiAWFhwVBagWKiwWKiwWEiQWDiQWKjAWKigX7BIsFiosFiosFhI0Fg40FiosFiosFQKwFhY8Fho4FP8sFio0FiYwFiJEFh5AFio0FiowFZusFipMFipIFi8sFjJIFjJIFsO0FjIwFjI0Fj5AFjpEFjYwFjIwF18wFkY4FkI8F16sFi4sFjIsFk40Fk40Fi4sFjIsF9wSLBYyKBYyMBZOJBZKJBYyLBYyLBdVrBZGHBZCIBYv3dgWPmwWVmQWZlAWcjgWdiAWZggWVfQWOewWL/TgFiHoFgX4FfYIFeYcFeo8FfZQFgZgFh5wFDvlI9x74IBV8YQX4GIsFg5QFZs0FbaYFS6cFJosFSm8F93r7/BXXzgWZlAWdjgWchwWZggWVfQWNegWIewWAfgU6QwWGiAWFhwU8ZgWJiwWKigWEigWEiQWJiwWKiwX7DYsFiosFiosFg40FhIwFiowFiosFOrAFhY8FhY4FO9MFiYwFiowFh5EFh5AFi40Fio0FY/YFipIFipIFi9IFjJIFjJIFs/cABYyNBYuNBY+QBY+QBYyNBY2MBdvTBZKOBZCPBdyvBYyLBYyMBZOMBZKNBYyLBYyLBfcNiwWMiwWMiwWTiQWSigWMigWMiwXbZwWQhwWRiAW1ZwWPhQWQhQWyRAWQewWJegWDfQV/ggWUhQWVfgWOegWIewWBfQV9ggV5iAX8SYsFi3UFrDAFz08FzG4F8IsFDvlI97n4VhWL/CQFiHsFgX0FfIIFeogFeo4FfJQFgZkFiJsFi/gkBfsGiwV6jgV8lQWCmAWHmwWPnAWUmAWalQWcjgX3BosFi8AFi40Fi40FjZEFjJEFjY0Fi4wFwOoFkZEFkJEFi4sFi4wFk44Fko8F9asFkowFkowF9YsFnIgFmoIFlX0FjnsFiHsFgX0FfIIFeogFKIsFOXIFZEUFi2EF9zuLBZyIBZqBBZV+BY56BYh7BYF+BXyBBXqIBQ75SPg99yMVwroFi/dxBVS7BVCkBS+LBU9yBU1WBW06BYtaBak7BclWBcdxBeeLBfcGYhWGiAWFhwVBagWKiwWKigWEigWDiQWKiwWKiwX7BIsFiosFiosFg40FhIwFiowFiosFQKwFhY8FhY4FQMwFiowFiYwFiJEFh5AFio0FiowFZuwFipIFipIFi8wFjJIFjJIFsOwFjI0FjI0Fj5AFjpAFjY0FjIwF1swFko4FkI8F16sFi4sFjIwFk4wFk40Fi4sFjIsF9wSLBYyLBYyLBZOJBZKKBYyKBYyLBdVrBZGHBZCIBYuLBY+cBZWYBZmVBZyOBZ2IBZmBBZV+BY56BYv8mAWKhAWKhAVmKgWKigWKiQWHhgWIhQWJigWKiQVlawWFhwWFhwVBbAWKigWKiwWEiQWDigWKiwWKiwX7BIsFiosFi4sFg4wFg40FiosFi4sFP6sFho8FhI8FQMsFio0FiYwFiJAFh5AFio0Fio0FZuwFiZwFj5sFlZgFm5QFnI0FnIcFmYEFlH0FrDQFyVYFx3EF54sFxqUFpKAFqdoFDvlI+L34CRWNhAWL+9AFiHsFgX0FfIIFeogFeo4FfJQFgZkFiJsFi/fIBW7TBVqfBSyLBU1yBS49BYv7vQWIewWBfQV8ggV6iAV6jgV8lAWBmQWImwWL+SwFjpsFlZkFmpQFnI4FnIgFmoIFlX0FjnsFi/uSBbKsBZGOBZGPBdeqBYyLBYuMBZOMBZONBYyLBYuLBfcGiwWMiwWLiwWTiQWTigWMigWLiwXXbAWLiwWLiwWShgWShwWLigWMiwWPhAWQhQWLigWLiwWxLAUO+Uj3mfmIFduLBZyIBZqCBZV9BY57BYh7BYF9BXyCBXqIBTuLBXqOBXyUBYGZBYibBY6bBZWZBZqUBfH7mRWL/E4FiHsFgX0FfIIFeogFeo4FfJQFgZkFiJsFi/hOBY6cBZWYBZqVBZyOBZyIBZqBBZV+BQ75SPgV+YgVyYsFnIgFmoIFlX0FjnsFiHsFgX0FfIIFeogFTYsFeo4FfJQFgpkFh5sFj5sFlJkFmpQF+wn+MhWGigWIjQWHiwUpqQV8kwWAmAWGmwWNmwWUmQWZlgWbjwWdiQXhcQXpoQWhyQWL+I4Fj5sFlJkFmpQFnI8FnIcFmoIFlX0FjnsFi/yVBYqEBYqFBWswBYiGBYmHBYmIBYmIBYeIBYeIBYiJBYiJBYaKBYaJBfsXbQWIiwWHigUO+Uj3f/eMFfsRLwWLIQWIewWBfQV8ggV6iAV6jgV8lAWCmQWHmwWL+SwFj5sFlJkFmpQFnI4FnIgFmoIFlX0FjnsFi/xXBff495sFm5IFnIwFnIYFmIEFk3wFjHoFhnwFgH4F+2v7MgX3mPtwBZV+BZB7BYh7BYJ9BX2BBXqHBXqNBXyTBQ75SPfu+WMVi/0xBYh7BYF9BXyCBXqIBXqOBXyUBYGZBYibBYv5MQWOmwWVmQWalAWcjwWchwWaggWVfQUO+Uj43/iYFZCGBYuKBYyJBYyFBY2EBYuKBYyJBYv8WwWHewWBfQV9ggV6iAV5jgV9lAWBmQWImwWL+EgFfJYFXIsFdHgFVDEFi/vmBYh7BYF9BX2CBXmIBXqOBX2UBYGZBYebBYv36gVo4wV1nAVdiwVzeAVVMQWL++YFh3sFgX0FfYIFeogFeY4FfZQFgZkFiJsFi/h9BY6cBZWYBZmVBZ2OBZyIBZmBBZV+BY2ABa2mBZGOBZGPBY2LBYyMBZKLBZKNBduLBZKJBZKLBYyKBY2LBZGHBZGIBbZoBYyJBY2KBY+GBY+GBYuJBY2JBZN1BZynBZCQBZCRBbWtBZGPBZGPBY2LBYyMBZKLBZKNBdyLBZKJBZKLBYyKBY2LBZGHBZGIBbZoBYyKBYyKBQ75SPi++B0VjIUFi/vyBYh7BYF9BXyCBXqIBXqOBXyUBYGZBYibBYv36wVt3QVaoQUtiwVPcAUsMwWL++AFiHsFgX0FfIIFeogFeo4FfJQFgZkFiJsFi/h9BY6cBZWYBZqVBZyOBZyIBZqBBZV+BY56BYtlBbCtBZKPBZCPBdiuBYyLBYyMBZKMBZONBYyLBYyLBfcGiwWMiwWNiwWSiQWSigWMigWNiwXWaAWMiwWLiwWShgWRhgWMiwWLiwWPhAWPhAWLiwWLiwWyIQUO+Uj37Ph4FTWLBVRwBU9PBWwvBYtQBaowBcdPBcNvBeCLBcKnBcfHBarmBYvGBWznBU/HBWH3AxWNjAWRiQWSigWNiQWNiwXTaAWRhgWRhwXTQwWLigWMiwWPhAWPhQWLigWMigWv+wAFjIUFjIQFi0QFioQFioUFZyAFiooFi4oFh4QFh4UFiosFi4oFQ0MFhYcFhYcFQ2YFiYsFiYkFhYoFhIkFiYwFiYoF+wCLBYmMBYmKBYSNBYWMBYmNBYmLBUOwBYWPBYWPBUPTBYuMBYqLBYeRBYeSBYuMBYqMBWf2BYqRBYqSBYvSBYySBYyRBa/3AAWMjAWLjAWPkQWPkgWMiwWLjAXT0wWSjwWQkAXTrgWNiwWNjQWSjAWRjQWNigWNjAX3AIsFDvlI9xTXFYWPBYv7dQWHewWCfQV8ggV6iAV6jgV8lAWBmQWImwWL+TMFjpwFlZgFmpUFnI4FnIgFmoEFlH4Fj3oFi4sFkY8FkI4F1asFjIsFjIwFk4wFko0FjIsFjIsF9wSLBYyLBYuLBZOJBZOKBYyKBYuLBdZsBZGHBZGHBdZLBY2KBYyJBY+GBY+GBYuJBY2JBa8rBY2EBYyDBYtLBYqEBYmEBWYsBYqJBYuJBYeGBYeFBYqKBYmKBUBLBYWHBYaIBUBqBYqLBYqKBYOKBYSJBYqLBYqLBfsEiwWKiwWKiwWDjQWEjAWKjAWKiwVBrAWA9w0VwlwFxnEF54sFx6UFyb8FqdoFi7wFbdsFTb8FT6QFL4sFUHIFVFwFDvlI+D33JRXCugWL924FVLoFUKQFL4sFT3IFTVcFbTsFi1oFqTwFyVcFx3EF54sF9wZiFYaIBYWHBUFqBYqLBYqLBYSJBYOJBYqMBYqKBfsEiwWKjAWKigWEjQWDjQWKiwWKiwVArAWGjgWFjwVAywWJjAWKjQWHkAWHkAWLjQWKjQVm6gWJkgWKkwWLywWMkgWNkgWw6wWMjQWLjQWPkAWPkQWMjAWNjAXWywWRjwWRjwXWqgWLiwWMjAWTjAWTjQWLiwWMiwX3BIsFjIsFjIsFkokFk4oFjIoFjIsF1WwFkIcFkYgFi4sFj5sFlJkFmpQFnI4FnIgFmoIFlX0FjnsFi/00BYh7BYF9BXyCBXqIBXqOBXyUBYKZBYebBQ75SPfp+MsVk40F9yaLBZyIBZmBBZV+BY96BYd7BYF+BX2BBXqIBfsdiwU4bgU5TwViNAWL+6MFiHsFgX0FfYIFeYgFeo4FfZQFgZkFh5sFi/h9BY+cBZWYBZmVBZyOBZ2IBZmBBZV+BY56BYtWBdTABZGNBZGPBeutBQ75SO6nFYSQBYuLBYuMBYeSBYeSBXLSBYmcBY+bBZaYBZuTBZyNBZyGBZmBBZN9BZ9TBbt0BfWLBeSsBbuhBYuoBVHCBfsBygX7BIsFiYsFiosFhI0FhIwFiowFiYwFQK8FhY8Fho8FiowFiYwFiJEFh5EFi4wFio0FipEFipIFi9IFjJMFjZMFi4sFi4wFkJEFj5IF1tMFjIsFjIwFkY8Fko8FjIsFi4wF764Fk4wFk40F9xGLBYyKBY2MBZKJBZKKBYyKBY2KBdZoBZmBBZN8BY17BYd7BYB+BXyDBXmJBXqPBUqqBSGLBTluBVRWBYtuBbN4BfcGiwWOigWPiwWQiQWQigWOigWPiQX3EEQFj4cFkIgF1kQFj4QFkIQFi4sFi4sFjYMFjIMFi0MFioUFioQFiooFi4kFh4UFiIYFiYoFiokFhYgFhoYFQGgFiYsFiYkFJ2cFg4oFg4kF+xGLBYmMBYmKBYWNBYSMBYmMBYqMBUCvBQ75SPdd+DEV+wyLBXqOBXyUBYGZBYibBY6bBZWZBZqUBZyOBfcMiwWL9zcFjpsFlZkFmpQFnI4FnIgFmoIFlX0FjnsFi/s3BfdDiwWciAWaggWVfQWOewWIewWBfQV8ggV6iAX7Q4sFi/uCBbNMBeF0BfOLBZyHBZqCBZV9BY57BYh7BYF9BXyCBXqIBfsCiwWFjAWFjAX7AqgFg48FhI4Fi4sFiowFhpEFhZAFVOIFio4FiY4FipAFiZAFjI4Fio4FDvlI+GX3SRWL9+AFjpsFlZkFmpQFnI4FnIgFmoIFlX0FjnsFi/x9BYh6BYF+BXyBBXqIBXqOBXyVBYGYBYicBYuyBWZpBYWHBYWHBT9oBYmKBYqKBYSKBYSJBYmMBYqKBfsGiwWJjAWKigWEjQWEjAWJjAWKjAU/rgWEkAWEkAWLiwWLiwWHkgWHkgVk9AWKkgWKkQWL9/IFjpsFlZkFmpQFnI4FnIgFmoIFlX0FjnsFi/vrBak6Bb10BeeLBcinBQ75SPfB9xcV92j4JgWWmAWakwWcjQWchwWZgQWUfQWNegWHewX7kfxyBYiHBYiGBYiJBYqJBYaIBYaIBYiKBYiKBYaKBYWKBYiLBYiLBYWMBYaMBYiMBYiMBYaOBYaOBYqNBYiNBYiQBYiPBfuQ+HIFhpsFjZwFlJkFmZUFnI8FnIkFmoMFln4FDvlI+Fj3TRX29+kFk5oFmZUFm5AFnYoFmoMFl34FkHsFiXsF+yr8cgWIhwWKhwWIiAWKhwWHiQWIhwWHiQWIiQWGiQWHiQWHiwWHigWHiwWGiwWHjAWHiwWHjQWGjQWIjQWHjQWIjwWIjQWJjwWIjgWKjwWIjwUg9+kFIPvpBYiHBYqHBYiIBYmHBYiJBYiHBYeJBYiJBYaJBYeJBYeLBYeKBYeLBYaLBYeMBYeLBYeNBYaNBYiNBYeNBYiPBYiNBYmPBYiOBYqPBYiPBfsq+HIFiZsFkJsFl5gFmpMFnYwFm4YFmYEFk3wF9wD76QX29+kFjY8FjI8Fjo4FjY8Fj44Fjo4Fjo0Fj40Fj40Fj40Fj4sFj4wFkIsFkIsFj4oFj4sFj4kFkIkFjokFjokFjogFj4gFjYcFjogFjIcFjYcFDvlI+AL3pxX3evtlBZV+BY97BYh7BYF9BX2BBXqIBXmOBX2UBft992YF+337ZgV9ggV5iAV6jgV9lQWBmQWImwWPmwWVmAX3evdlBft692UFgZgFh5sFjpwFlZgFmZUFnI4FnYgFmYMF9337ZwX3ffdnBZmTBZ2OBZyIBZmBBZV+BY56BYd7BYF+BQ75SOj7TxWDigWLiwWLiwVjiwV6jgV8lAWBmQWImwWOmwWVmQWalAWcjgWqiwXLpQXOwQXJ7gX7dfg4BYebBY2bBZSaBZiVBZyPBZ2JBZqDBZZ+BfdX/AEF91n4AQWWmAWakwWdjQWbhwWZgQWUfAWNewWGewX7gfxMBYuKBYqJBT37EQWGhQWGhgU9TAWEiAWGhwU8bAWLiwWLiwUO+Uj3UtkV98+LBZ2IBZmCBZV9BY57BYh7BYF9BX2CBXmIBfwsiwWEjAWFiwWJjQWIiwWGjgWGjgWJjQWJjAWHkAWHkAWKjQWKjQWKkQWJkAWLjgWLjQWMkQWLkQWNjQWLjQWPkAWOkQX38vguBfvPiwV5jgV9lAWBmQWImwWOmwWVmQWZlAWdjgX4LIsFkooFkYsFjYoFjooFkIgFkYgFjIkFjYoFj4YFj4YFjIkFjIkFjIUFjYYFi4gFi4kFioUFi4UFiYkFi4kFh4YFiIYFDgAAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAAK0AAACtAAAArQAAA==";var Sxe,ect;function h6n(){if(ect)return Sxe;ect=1,Sxe=function(n){return n!=null&&(t(n)||e(n)||!!n._isBuffer)};function t(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function e(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&t(n.slice(0,0))}return Sxe}var Qxe,tct;function p6n(){if(tct)return Qxe;tct=1;var t=h6n(),e=Object.prototype.toString;return Qxe=function(o){if(typeof o>"u")return"undefined";if(o===null)return"null";if(o===!0||o===!1||o instanceof Boolean)return"boolean";if(typeof o=="string"||o instanceof String)return"string";if(typeof o=="number"||o instanceof Number)return"number";if(typeof o=="function"||o instanceof Function)return"function";if(typeof Array.isArray<"u"&&Array.isArray(o))return"array";if(o instanceof RegExp)return"regexp";if(o instanceof Date)return"date";var i=e.call(o);return i==="[object RegExp]"?"regexp":i==="[object Date]"?"date":i==="[object Arguments]"?"arguments":i==="[object Error]"?"error":t(o)?"buffer":i==="[object Set]"?"set":i==="[object WeakSet]"?"weakset":i==="[object Map]"?"map":i==="[object WeakMap]"?"weakmap":i==="[object Symbol]"?"symbol":i==="[object Int8Array]"?"int8array":i==="[object Uint8Array]"?"uint8array":i==="[object Uint8ClampedArray]"?"uint8clampedarray":i==="[object Int16Array]"?"int16array":i==="[object Uint16Array]"?"uint16array":i==="[object Int32Array]"?"int32array":i==="[object Uint32Array]"?"uint32array":i==="[object Float32Array]"?"float32array":i==="[object Float64Array]"?"float64array":"object"},Qxe}var vxe={exports:{}},nct;function m6n(){return nct||(nct=1,(function(t){(function(){function e(n,o){if(typeof o!="function")return n;var i={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[o(r,n[r])||r]=n[r]);return i}t.exports?t.exports=e:window.rename=e})()})(vxe)),vxe.exports}var wxe,oct;function _6n(){if(oct)return wxe;oct=1;var t=p6n(),e=m6n();return wxe=function n(o,i){var r=t(o);if(r!=="object"&&r!=="array")throw new Error("expected an object");var s=[];r==="object"&&(o=e(o,i),s={});for(var a in o)if(o.hasOwnProperty(a)){var A=o[a];t(A)==="object"||t(A)==="array"?s[a]=n(A,i):s[a]=A}return s},wxe}var f6n=_6n();const I6n=dy(f6n);var Pxe={exports:{}},ict;function rct(){return ict||(ict=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function o(){}Object.create&&(o.prototype=Object.create(null),new o().__proto__||(n=!1));function i(s,a,A){this.fn=s,this.context=a,this.once=A||!1}function r(){this._events=new o,this._eventsCount=0}r.prototype.eventNames=function(){var a=[],A,c;if(this._eventsCount===0)return a;for(c in A=this._events)e.call(A,c)&&a.push(n?c.slice(1):c);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(A)):a},r.prototype.listeners=function(a,A){var c=n?n+a:a,l=this._events[c];if(A)return!!l;if(!l)return[];if(l.fn)return[l.fn];for(var g=0,u=l.length,h=new Array(u);g<u;g++)h[g]=l[g].fn;return h},r.prototype.emit=function(a,A,c,l,g,u){var h=n?n+a:a;if(!this._events[h])return!1;var d=this._events[h],p=arguments.length,m,_;if(d.fn){switch(d.once&&this.removeListener(a,d.fn,void 0,!0),p){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,A),!0;case 3:return d.fn.call(d.context,A,c),!0;case 4:return d.fn.call(d.context,A,c,l),!0;case 5:return d.fn.call(d.context,A,c,l,g),!0;case 6:return d.fn.call(d.context,A,c,l,g,u),!0}for(_=1,m=new Array(p-1);_<p;_++)m[_-1]=arguments[_];d.fn.apply(d.context,m)}else{var f=d.length,I;for(_=0;_<f;_++)switch(d[_].once&&this.removeListener(a,d[_].fn,void 0,!0),p){case 1:d[_].fn.call(d[_].context);break;case 2:d[_].fn.call(d[_].context,A);break;case 3:d[_].fn.call(d[_].context,A,c);break;case 4:d[_].fn.call(d[_].context,A,c,l);break;default:if(!m)for(I=1,m=new Array(p-1);I<p;I++)m[I-1]=arguments[I];d[_].fn.apply(d[_].context,m)}}return!0},r.prototype.on=function(a,A,c){var l=new i(A,c||this),g=n?n+a:a;return this._events[g]?this._events[g].fn?this._events[g]=[this._events[g],l]:this._events[g].push(l):(this._events[g]=l,this._eventsCount++),this},r.prototype.once=function(a,A,c){var l=new i(A,c||this,!0),g=n?n+a:a;return this._events[g]?this._events[g].fn?this._events[g]=[this._events[g],l]:this._events[g].push(l):(this._events[g]=l,this._eventsCount++),this},r.prototype.removeListener=function(a,A,c,l){var g=n?n+a:a;if(!this._events[g])return this;if(!A)return--this._eventsCount===0?this._events=new o:delete this._events[g],this;var u=this._events[g];if(u.fn)u.fn===A&&(!l||u.once)&&(!c||u.context===c)&&(--this._eventsCount===0?this._events=new o:delete this._events[g]);else{for(var h=0,d=[],p=u.length;h<p;h++)(u[h].fn!==A||l&&!u[h].once||c&&u[h].context!==c)&&d.push(u[h]);d.length?this._events[g]=d.length===1?d[0]:d:--this._eventsCount===0?this._events=new o:delete this._events[g]}return this},r.prototype.removeAllListeners=function(a){var A;return a?(A=n?n+a:a,this._events[A]&&(--this._eventsCount===0?this._events=new o:delete this._events[A])):(this._events=new o,this._eventsCount=0),this},r.prototype.off=r.prototype.removeListener,r.prototype.addListener=r.prototype.on,r.prototype.setMaxListeners=function(){return this},r.prefixed=n,r.EventEmitter=r,t.exports=r})(Pxe)),Pxe.exports}var Mxe,sct;function C6n(){if(sct)return Mxe;sct=1;function t(c,l,g){return l in c?Object.defineProperty(c,l,{value:g,enumerable:!0,configurable:!0,writable:!0}):c[l]=g,c}var e=rct(),n=function(){},o={data:"state-data",cdata:"state-cdata",tagBegin:"state-tag-begin",tagName:"state-tag-name",tagEnd:"state-tag-end",attributeNameStart:"state-attribute-name-start",attributeName:"state-attribute-name",attributeNameEnd:"state-attribute-name-end",attributeValueBegin:"state-attribute-value-begin",attributeValue:"state-attribute-value"},i={lt:"action-lt",gt:"action-gt",space:"action-space",equal:"action-equal",quote:"action-quote",slash:"action-slash",char:"action-char",error:"action-error"},r={text:"text",openTag:"open-tag",closeTag:"close-tag",attributeName:"attribute-name",attributeValue:"attribute-value"},s={" ":i.space," ":i.space,"\n":i.space,"\r":i.space,"<":i.lt,">":i.gt,'"':i.quote,"'":i.quote,"=":i.equal,"/":i.slash},a=function(l){return s[l]||i.char},A=function(l){var g,u,h,d,p,m,_,f,I,C;l=Object.assign({debug:!1},l);var y=new e,x=o.data,E="",B="",S="",Q="",w="",M="",k=function(O,U){if(!(B[0]==="?"||B[0]==="!")){var Y={type:O,value:U};l.debug&&console.log("emit:",Y),y.emit("data",Y)}};y.stateMachine=(C={},t(C,o.data,(g={},t(g,i.lt,function(){E.trim()&&k(r.text,E),B="",w=!1,x=o.tagBegin}),t(g,i.char,function(F){E+=F}),g)),t(C,o.cdata,t({},i.char,function(F){E+=F,E.substr(-3)==="]]>"&&(k(r.text,E.slice(0,-3)),E="",x=o.data)})),t(C,o.tagBegin,(u={},t(u,i.space,n),t(u,i.char,function(F){B=F,x=o.tagName}),t(u,i.slash,function(){B="",w=!0}),u)),t(C,o.tagName,(h={},t(h,i.space,function(){w?x=o.tagEnd:(x=o.attributeNameStart,k(r.openTag,B))}),t(h,i.gt,function(){k(w?r.closeTag:r.openTag,B),E="",x=o.data}),t(h,i.slash,function(){x=o.tagEnd,k(r.openTag,B)}),t(h,i.char,function(F){B+=F,B==="![CDATA["&&(x=o.cdata,E="",B="")}),h)),t(C,o.tagEnd,(d={},t(d,i.gt,function(){k(r.closeTag,B),E="",x=o.data}),t(d,i.char,n),d)),t(C,o.attributeNameStart,(p={},t(p,i.char,function(F){S=F,x=o.attributeName}),t(p,i.gt,function(){E="",x=o.data}),t(p,i.space,n),t(p,i.slash,function(){w=!0,x=o.tagEnd}),p)),t(C,o.attributeName,(m={},t(m,i.space,function(){x=o.attributeNameEnd}),t(m,i.equal,function(){k(r.attributeName,S),x=o.attributeValueBegin}),t(m,i.gt,function(){Q="",k(r.attributeName,S),k(r.attributeValue,Q),E="",x=o.data}),t(m,i.slash,function(){w=!0,Q="",k(r.attributeName,S),k(r.attributeValue,Q),x=o.tagEnd}),t(m,i.char,function(F){S+=F}),m)),t(C,o.attributeNameEnd,(_={},t(_,i.space,n),t(_,i.equal,function(){k(r.attributeName,S),x=o.attributeValueBegin}),t(_,i.gt,function(){Q="",k(r.attributeName,S),k(r.attributeValue,Q),E="",x=o.data}),t(_,i.char,function(F){Q="",k(r.attributeName,S),k(r.attributeValue,Q),S=F,x=o.attributeName}),_)),t(C,o.attributeValueBegin,(f={},t(f,i.space,n),t(f,i.quote,function(F){M=F,Q="",x=o.attributeValue}),t(f,i.gt,function(){Q="",k(r.attributeValue,Q),E="",x=o.data}),t(f,i.char,function(F){M="",Q=F,x=o.attributeValue}),f)),t(C,o.attributeValue,(I={},t(I,i.space,function(F){M?Q+=F:(k(r.attributeValue,Q),x=o.attributeNameStart)}),t(I,i.quote,function(F){M===F?(k(r.attributeValue,Q),x=o.attributeNameStart):Q+=F}),t(I,i.gt,function(F){M?Q+=F:(k(r.attributeValue,Q),E="",x=o.data)}),t(I,i.slash,function(F){M?Q+=F:(k(r.attributeValue,Q),w=!0,x=o.tagEnd)}),t(I,i.char,function(F){Q+=F}),I)),C);var R=function(O){l.debug&&console.log(x,O);var U=y.stateMachine[x],Y=U[a(O)]||U[i.error]||U[i.char];Y(O)};return y.write=function(F){for(var O=F.length,U=0;U<O;U++)R(F[U])},y};return Mxe={State:o,Action:i,Type:r,create:A},Mxe}var Dxe,act;function y6n(){if(act)return Dxe;act=1;var t=rct(),e=C6n(),n=e.Type,o={element:"element",text:"text"},i=function(A){return Object.assign({name:"",type:o.element,value:"",parent:null,attributes:{},children:[]},A)},r=function(A){A=Object.assign({stream:!1,parentNodes:!0,doneEvent:"done",tagPrefix:"tag:",emitTopLevelOnly:!1,debug:!1},A);var c=void 0,l=void 0,g=void 0,u=void 0,h=new t,d=function(m){switch(m.type){case n.openTag:if(g===null)g=l,g.name=m.value;else{var _=i({name:m.value,parent:g});g.children.push(_),g=_}break;case n.closeTag:var f=g.parent;if(A.parentNodes||(g.parent=null),g.name!==m.value)break;A.stream&&f===l&&(l.children=[],g.parent=null),(!A.emitTopLevelOnly||f===l)&&(h.emit(A.tagPrefix+g.name,g),h.emit("tag",g.name,g)),g===l&&(c.removeAllListeners("data"),h.emit(A.doneEvent,g),l=null),g=f;break;case n.text:g&&g.children.push(i({type:o.text,value:m.value,parent:A.parentNodes?g:null}));break;case n.attributeName:u=m.value,g.attributes[u]="";break;case n.attributeValue:g.attributes[u]=m.value;break}};return h.reset=function(){c=e.create({debug:A.debug}),c.on("data",d),l=i(),g=null,u="",h.parse=c.write},h.reset(),h},s=function(A,c){c=Object.assign({},c,{stream:!1,tagPrefix:":"});var l=r(c),g=void 0;return l.on("done",function(u){g=u}),l.parse(A),g};return Dxe={parseSync:s,create:r,NodeType:o},Dxe}var x6n=y6n(),E6n=function(e){var n=x6n.parseSync("<root>".concat(e,"</root>"),{parentNodes:!1}),o=n.children&&n.children.length>0&&n.children.every(function(i){return i.name==="svg"});if(o)return n.children.length===1?n.children[0]:n.children;throw Error("nothing to parse")},B6n=function(e){return I6n(e,function(n){return S6n(n)?n:b6n(n)})},b6n=function(e){return e.replace(/[-|:]([a-z])/gi,function(n,o){return o.toUpperCase()})},S6n=function(e){return/^(data|aria)(-\w+)/.test(e)},Q6n=function(e){if(e){var n=String(e);return/[&<>]/.test(n)?"<![CDATA[".concat(n.replace(/]]>/,"]]]]><![CDATA[>"),"]]>"):n}return""},v6n=function(e){return String(e).replace(/&/g,"&").replace(/'/g,"'").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")},MV=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=n.transformNode,i=o===void 0?function(A){return A}:o,r=n.camelcase,s=r===void 0?!1:r,a=function(c){var l;return l=i(c),s&&(l=B6n(l)),l};return a(E6n(e))},Act=function t(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=n.transformAttr,i=o===void 0?function(h,d,p){return"".concat(h,'="').concat(p(d),'"')}:o,r=n.transformNode,s=r===void 0?function(h){return h}:r,a=n.selfClose,A=a===void 0?!0:a;if(Array.isArray(e))return e.map(function(h){return t(h,{transformAttr:i,selfClose:A,transformNode:s})}).join("");var c=s(e);if(c.type==="text")return Q6n(c.value);var l="";for(var g in c.attributes){var u=i(g,c.attributes[g],v6n,c.name);l+=u?" ".concat(u):""}return c.children&&c.children.length>0||!A?"<".concat(c.name).concat(l,">").concat(t(c.children,{transformAttr:i,transformNode:s,selfClose:A}),"</").concat(c.name,">"):"<".concat(c.name).concat(l,"/>")},fQ=t=>{const e=Math.round(t*1e3)/1e3;return`${Number(e.toFixed(3))}mm`},cct=new Map([["T",1e12],["G",1e9],["M",1e6],["K",1e3],["k",1e3],["",1],["m",.001],["µ",1e-6],["μ",1e-6],["u",1e-6],["n",1e-9],["p",1e-12],["f",1e-15]]),w6n=[...cct.keys()];function lct(t){return cct.get(t)}var gct={Hz:{baseUnit:"Hz",variants:{MHz:1e6,kHz:1e3,Hz:1}},g:{baseUnit:"g",variants:{kg:1e3,g:1}},Ω:{baseUnit:"Ω",variants:{mΩ:.001,mohm:.001,mOhm:.001,milliohm:.001,Ω:1,ohm:1,Ohm:1,kΩ:1e3,KΩ:1e3,kohm:1e3,kOhm:1e3,KOhm:1e3,Kohm:1e3,MΩ:1e6,Mohm:1e6,MOhm:1e6,megohm:1e6,Megohm:1e6,GΩ:1e9,Gohm:1e9,GOhm:1e9,TΩ:1e12,Tohm:1e12,TOhm:1e12}},V:{baseUnit:"V",variants:{mV:.001,V:1,kV:1e3,KV:1e3,MV:1e6,GV:1e9,TV:1e12}},A:{baseUnit:"A",variants:{µA:1e-6,μA:1e-6,mA:.001,ma:.001,A:1,kA:1e3,MA:1e6}},F:{baseUnit:"F",variants:{pF:1e-12,nF:1e-9,µF:1e-6,μF:1e-6,uF:1e-6,mF:.001,F:1,kF:1e3,KF:1e3,MF:1e6}},H:{baseUnit:"H",variants:{pH:1e-12,nH:1e-9,µH:1e-6,μH:1e-6,uH:1e-6,mH:.001,H:1,kH:1e3,KH:1e3,MH:1e6}},ml:{baseUnit:"ml",variants:{ml:1,mL:1,l:1e3,L:1e3}},deg:{baseUnit:"deg",variants:{rad:180/Math.PI}},ms:{baseUnit:"ms",variants:{fs:1e-12,ps:1e-9,ns:1e-6,us:.001,µs:.001,μs:.001,ms:1,s:1e3}},mm:{baseUnit:"mm",variants:{nm:1e-6,µm:.001,μm:.001,um:.001,mm:1,cm:10,dm:100,m:1e3,km:1e6,in:25.4,ft:304.8,IN:25.4,FT:304.8,yd:914.4,mi:1609344,mil:.0254}}},Nxe=new Set;for(const[t,e]of Object.entries(gct)){Nxe.add(t);for(const n of Object.keys(e.variants))Nxe.add(n)}function P6n(t){for(const e of Object.values(gct)){if(t in e.variants)return{baseUnit:e.baseUnit,conversionFactor:e.variants[t]};for(const[n,o]of Object.entries(e.variants)){if(!t.endsWith(n))continue;const i=t.slice(0,-n.length),r=lct(i);if(r!=null)return{baseUnit:e.baseUnit,conversionFactor:r*o}}}return{baseUnit:t,conversionFactor:1}}function q1(t,e){if(t==null)return{parsedUnit:null,unitOfValue:null,value:null};if(typeof t=="string"&&t.match(/^-?[\d.]+$/))return{value:Number.parseFloat(t),parsedUnit:null,unitOfValue:null};if(typeof t=="number")return{value:t,parsedUnit:null,unitOfValue:null};if(typeof t=="object"&&"x"in t&&"y"in t){const c=q1(t.x,e),l=q1(t.x,e),g=q1(t.y,e);return l.value===null||g.value===null?{parsedUnit:null,unitOfValue:null,value:null}:{parsedUnit:c.parsedUnit,unitOfValue:c.unitOfValue,value:{x:l.value,y:g.value}}}const o=t.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!o)throw new Error(`Could not determine unit: "${t}"`);const i=o.split("").reverse().join(""),r=t.slice(0,-i.length),s=lct(i);if(e&&s!=null)return{parsedUnit:null,unitOfValue:e,value:Number.parseFloat(r)*s};if(s!=null&&!Nxe.has(i))return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(r)*s};const{baseUnit:a,conversionFactor:A}=P6n(i);return{parsedUnit:i,unitOfValue:a,value:A*Number.parseFloat(r)}}w6n.filter(t=>t!=="").sort((t,e)=>e.length-t.length).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|");var Xk=[{value:1e12,symbol:"T"},{value:1e9,symbol:"G"},{value:1e6,symbol:"M"},{value:1e3,symbol:"k"},{value:1,symbol:""},{value:.001,symbol:"m"},{value:1e-6,symbol:"µ"},{value:1e-9,symbol:"n"},{value:1e-12,symbol:"p"}],M6n=Xk[Xk.length-1];function H_(t){if(t==null)return"";if(t===0)return"0";const e=Math.abs(t);let n=Xk.findIndex(s=>{const a=e/s.value;return a>=1&&a<1e3});n===-1&&(n=Xk.indexOf(M6n));let o=Xk[n],i=t/o.value;for(;n>0&&Math.abs(Number(i.toPrecision(3)))>=1e3;)n-=1,o=Xk[n],i=t/o.value;let r=i.toPrecision(3);return r.includes(".")&&!/\.0+$/.test(r)&&(r=r.replace(/0+$/,"")),r=r.replace(/\.0+$/,""),`${r}${o.symbol}`}var wl;(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function n(i){throw new Error}t.assertNever=n,t.arrayToEnum=i=>{const r={};for(const s of i)r[s]=s;return r},t.getValidEnumValues=i=>{const r=t.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),s={};for(const a of r)s[a]=i[a];return t.objectValues(s)},t.objectValues=i=>t.objectKeys(i).map(function(r){return i[r]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const r=[];for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&r.push(s);return r},t.find=(i,r)=>{for(const s of i)if(r(s))return s},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function o(i,r=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(r)}t.joinValues=o,t.jsonStringifyReplacer=(i,r)=>typeof r=="bigint"?r.toString():r})(wl||(wl={}));var uct;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(uct||(uct={}));const br=wl.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),IQ=t=>{switch(typeof t){case"undefined":return br.undefined;case"string":return br.string;case"number":return Number.isNaN(t)?br.nan:br.number;case"boolean":return br.boolean;case"function":return br.function;case"bigint":return br.bigint;case"symbol":return br.symbol;case"object":return Array.isArray(t)?br.array:t===null?br.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?br.promise:typeof Map<"u"&&t instanceof Map?br.map:typeof Set<"u"&&t instanceof Set?br.set:typeof Date<"u"&&t instanceof Date?br.date:br.object;default:return br.unknown}},lo=wl.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class f5 extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=o=>{this.issues=[...this.issues,o]},this.addIssues=(o=[])=>{this.issues=[...this.issues,...o]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(r){return r.message},o={_errors:[]},i=r=>{for(const s of r.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)o._errors.push(n(s));else{let a=o,A=0;for(;A<s.path.length;){const c=s.path[A];A===s.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(s))):a[c]=a[c]||{_errors:[]},a=a[c],A++}}};return i(this),o}static assert(e){if(!(e instanceof f5))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,wl.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},o=[];for(const i of this.issues)if(i.path.length>0){const r=i.path[0];n[r]=n[r]||[],n[r].push(e(i))}else o.push(e(i));return{formErrors:o,fieldErrors:n}}get formErrors(){return this.flatten()}}f5.create=t=>new f5(t);const DV=(t,e)=>{let n;switch(t.code){case lo.invalid_type:t.received===br.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case lo.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,wl.jsonStringifyReplacer)}`;break;case lo.unrecognized_keys:n=`Unrecognized key(s) in object: ${wl.joinValues(t.keys,", ")}`;break;case lo.invalid_union:n="Invalid input";break;case lo.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${wl.joinValues(t.options)}`;break;case lo.invalid_enum_value:n=`Invalid enum value. Expected ${wl.joinValues(t.options)}, received '${t.received}'`;break;case lo.invalid_arguments:n="Invalid function arguments";break;case lo.invalid_return_type:n="Invalid function return type";break;case lo.invalid_date:n="Invalid date";break;case lo.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:wl.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case lo.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case lo.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case lo.custom:n="Invalid input";break;case lo.invalid_intersection_types:n="Intersection results could not be merged";break;case lo.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case lo.not_finite:n="Number must be finite";break;default:n=e.defaultError,wl.assertNever(t)}return{message:n}};let D6n=DV;function Rxe(){return D6n}const Txe=t=>{const{data:e,path:n,errorMaps:o,issueData:i}=t,r=[...n,...i.path||[]],s={...i,path:r};if(i.message!==void 0)return{...i,path:r,message:i.message};let a="";const A=o.filter(c=>!!c).slice().reverse();for(const c of A)a=c(s,{data:e,defaultError:a}).message;return{...i,path:r,message:a}};function rr(t,e){const n=Rxe(),o=Txe({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===DV?void 0:DV].filter(i=>!!i)});t.common.issues.push(o)}class _y{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const o=[];for(const i of n){if(i.status==="aborted")return Zs;i.status==="dirty"&&e.dirty(),o.push(i.value)}return{status:e.value,value:o}}static async mergeObjectAsync(e,n){const o=[];for(const i of n){const r=await i.key,s=await i.value;o.push({key:r,value:s})}return _y.mergeObjectSync(e,o)}static mergeObjectSync(e,n){const o={};for(const i of n){const{key:r,value:s}=i;if(r.status==="aborted"||s.status==="aborted")return Zs;r.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),r.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(o[r.value]=s.value)}return{status:e.value,value:o}}}const Zs=Object.freeze({status:"aborted"}),NV=t=>({status:"dirty",value:t}),sx=t=>({status:"valid",value:t}),dct=t=>t.status==="aborted",hct=t=>t.status==="dirty",qk=t=>t.status==="valid",Qne=t=>typeof Promise<"u"&&t instanceof Promise;var is;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(is||(is={}));class w9{constructor(e,n,o,i){this._cachedPath=[],this.parent=e,this.data=n,this._path=o,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const pct=(t,e)=>{if(qk(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new f5(t.common.issues);return this._error=n,this._error}}};function EA(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:o,description:i}=t;if(e&&(n||o))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(s,a)=>{const{message:A}=t;return s.code==="invalid_enum_value"?{message:A??a.defaultError}:typeof a.data>"u"?{message:A??o??a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:A??n??a.defaultError}},description:i}}class Bc{get description(){return this._def.description}_getType(e){return IQ(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:IQ(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new _y,ctx:{common:e.parent.common,data:e.data,parsedType:IQ(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(Qne(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const o=this.safeParse(e,n);if(o.success)return o.data;throw o.error}safeParse(e,n){const o={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:IQ(e)},i=this._parseSync({data:e,path:o.path,parent:o});return pct(o,i)}"~validate"(e){const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:IQ(e)};if(!this["~standard"].async)try{const o=this._parseSync({data:e,path:[],parent:n});return qk(o)?{value:o.value}:{issues:n.common.issues}}catch(o){o?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(o=>qk(o)?{value:o.value}:{issues:n.common.issues})}async parseAsync(e,n){const o=await this.safeParseAsync(e,n);if(o.success)return o.data;throw o.error}async safeParseAsync(e,n){const o={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:IQ(e)},i=this._parse({data:e,path:o.path,parent:o}),r=await(Qne(i)?i:Promise.resolve(i));return pct(o,r)}refine(e,n){const o=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,r)=>{const s=e(i),a=()=>r.addIssue({code:lo.custom,...o(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(A=>A?!0:(a(),!1)):s?!0:(a(),!1)})}refinement(e,n){return this._refinement((o,i)=>e(o)?!0:(i.addIssue(typeof n=="function"?n(o,i):n),!1))}_refinement(e){return new yQ({schema:this,typeName:Ea.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return w8.create(this,this._def)}nullable(){return WM.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return M9.create(this)}promise(){return FV.create(this,this._def)}or(e){return Pne.create([this,e],this._def)}and(e){return Mne.create(this,e,this._def)}transform(e){return new yQ({...EA(this._def),schema:this,typeName:Ea.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new Rne({...EA(this._def),innerType:this,defaultValue:n,typeName:Ea.ZodDefault})}brand(){return new Ect({typeName:Ea.ZodBranded,type:this,...EA(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new Tne({...EA(this._def),innerType:this,catchValue:n,typeName:Ea.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Yxe.create(this,e)}readonly(){return kne.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const N6n=/^c[^\s-]{8,}$/i,R6n=/^[0-9a-z]+$/,T6n=/^[0-9A-HJKMNP-TV-Z]{26}$/i,k6n=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,F6n=/^[a-z0-9_-]{21}$/i,L6n=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,H6n=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,O6n=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,G6n="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let kxe;const Y6n=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,U6n=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,K6n=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,V6n=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,z6n=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,J6n=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,mct="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",W6n=new RegExp(`^${mct}$`);function _ct(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function j6n(t){return new RegExp(`^${_ct(t)}$`)}function X6n(t){let e=`${mct}T${_ct(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function q6n(t,e){return!!((e==="v4"||!e)&&Y6n.test(t)||(e==="v6"||!e)&&K6n.test(t))}function $6n(t,e){if(!L6n.test(t))return!1;try{const[n]=t.split(".");if(!n)return!1;const o=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(o));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function Z6n(t,e){return!!((e==="v4"||!e)&&U6n.test(t)||(e==="v6"||!e)&&V6n.test(t))}class P9 extends Bc{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==br.string){const r=this._getOrReturnCtx(e);return rr(r,{code:lo.invalid_type,expected:br.string,received:r.parsedType}),Zs}const o=new _y;let i;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(i=this._getOrReturnCtx(e,i),rr(i,{code:lo.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),o.dirty());else if(r.kind==="max")e.data.length>r.value&&(i=this._getOrReturnCtx(e,i),rr(i,{code:lo.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),o.dirty());else if(r.kind==="length"){const s=e.data.length>r.value,a=e.data.length<r.value;(s||a)&&(i=this._getOrReturnCtx(e,i),s?rr(i,{code:lo.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):a&&rr(i,{code:lo.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),o.dirty())}else if(r.kind==="email")O6n.test(e.data)||(i=this._getOrReturnCtx(e,i),rr(i,{validation:"email",code:lo.invalid_string,message:r.message}),o.dirty());else if(r.kind==="emoji")kxe||(kxe=new RegExp(G6n,"u")),kxe.test(e.data)||(i=this._getOrReturnCtx(e,i),rr(i,{validation:"emoji",code:lo.invalid_string,message:r.message}),o.dirty());else if(r.kind==="uuid")k6n.test(e.data)||(i=this._getOrReturnCtx(e,i),rr(i,{validation:"uuid",code:lo.invalid_string,message:r.message}),o.dirty());else if(r.kind==="nanoid")F6n.test(e.data)||(i=this._getOrReturnCtx(e,i),rr(i,{validation:"nanoid",code:lo.invalid_string,message:r.message}),o.dirty());else if(r.kind==="cuid")N6n.test(e.data)||(i=this._getOrReturnCtx(e,i),rr(i,{validation:"cuid",code:lo.invalid_string,message:r.message}),o.dirty());else if(r.kind==="cuid2")R6n.test(e.data)||(i=this._getOrReturnCtx(e,i),rr(i,{validation:"cuid2",code:lo.invalid_string,message:r.message}),o.dirty());else if(r.kind==="ulid")T6n.test(e.data)||(i=this._getOrReturnCtx(e,i),rr(i,{validation:"ulid",code:lo.invalid_string,message:r.message}),o.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),rr(i,{validation:"url",code:lo.invalid_string,message:r.message}),o.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),rr(i,{validation:"regex",code:lo.invalid_string,message:r.message}),o.dirty())):r.kind==="trim"?e.data=e.data.trim():r.kind==="includes"?e.data.includes(r.value,r.position)||(i=this._getOrReturnCtx(e,i),rr(i,{code:lo.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),o.dirty()):r.kind==="toLowerCase"?e.data=e.data.toLowerCase():r.kind==="toUpperCase"?e.data=e.data.toUpperCase():r.kind==="startsWith"?e.data.startsWith(r.value)||(i=this._getOrReturnCtx(e,i),rr(i,{code:lo.invalid_string,validation:{startsWith:r.value},message:r.message}),o.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(i=this._getOrReturnCtx(e,i),rr(i,{code:lo.invalid_string,validation:{endsWith:r.value},message:r.message}),o.dirty()):r.kind==="datetime"?X6n(r).test(e.data)||(i=this._getOrReturnCtx(e,i),rr(i,{code:lo.invalid_string,validation:"datetime",message:r.message}),o.dirty()):r.kind==="date"?W6n.test(e.data)||(i=this._getOrReturnCtx(e,i),rr(i,{code:lo.invalid_string,validation:"date",message:r.message}),o.dirty()):r.kind==="time"?j6n(r).test(e.data)||(i=this._getOrReturnCtx(e,i),rr(i,{code:lo.invalid_string,validation:"time",message:r.message}),o.dirty()):r.kind==="duration"?H6n.test(e.data)||(i=this._getOrReturnCtx(e,i),rr(i,{validation:"duration",code:lo.invalid_string,message:r.message}),o.dirty()):r.kind==="ip"?q6n(e.data,r.version)||(i=this._getOrReturnCtx(e,i),rr(i,{validation:"ip",code:lo.invalid_string,message:r.message}),o.dirty()):r.kind==="jwt"?$6n(e.data,r.alg)||(i=this._getOrReturnCtx(e,i),rr(i,{validation:"jwt",code:lo.invalid_string,message:r.message}),o.dirty()):r.kind==="cidr"?Z6n(e.data,r.version)||(i=this._getOrReturnCtx(e,i),rr(i,{validation:"cidr",code:lo.invalid_string,message:r.message}),o.dirty()):r.kind==="base64"?z6n.test(e.data)||(i=this._getOrReturnCtx(e,i),rr(i,{validation:"base64",code:lo.invalid_string,message:r.message}),o.dirty()):r.kind==="base64url"?J6n.test(e.data)||(i=this._getOrReturnCtx(e,i),rr(i,{validation:"base64url",code:lo.invalid_string,message:r.message}),o.dirty()):wl.assertNever(r);return{status:o.value,value:e.data}}_regex(e,n,o){return this.refinement(i=>e.test(i),{validation:n,code:lo.invalid_string,...is.errToObj(o)})}_addCheck(e){return new P9({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...is.errToObj(e)})}url(e){return this._addCheck({kind:"url",...is.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...is.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...is.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...is.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...is.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...is.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...is.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...is.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...is.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...is.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...is.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...is.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...is.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...is.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...is.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...is.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...is.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...is.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...is.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...is.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...is.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...is.errToObj(n)})}nonempty(e){return this.min(1,is.errToObj(e))}trim(){return new P9({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new P9({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new P9({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}P9.create=t=>new P9({checks:[],typeName:Ea.ZodString,coerce:t?.coerce??!1,...EA(t)});function e8n(t,e){const n=(t.toString().split(".")[1]||"").length,o=(e.toString().split(".")[1]||"").length,i=n>o?n:o,r=Number.parseInt(t.toFixed(i).replace(".","")),s=Number.parseInt(e.toFixed(i).replace(".",""));return r%s/10**i}class VM extends Bc{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==br.number){const r=this._getOrReturnCtx(e);return rr(r,{code:lo.invalid_type,expected:br.number,received:r.parsedType}),Zs}let o;const i=new _y;for(const r of this._def.checks)r.kind==="int"?wl.isInteger(e.data)||(o=this._getOrReturnCtx(e,o),rr(o,{code:lo.invalid_type,expected:"integer",received:"float",message:r.message}),i.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(o=this._getOrReturnCtx(e,o),rr(o,{code:lo.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),i.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(o=this._getOrReturnCtx(e,o),rr(o,{code:lo.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),i.dirty()):r.kind==="multipleOf"?e8n(e.data,r.value)!==0&&(o=this._getOrReturnCtx(e,o),rr(o,{code:lo.not_multiple_of,multipleOf:r.value,message:r.message}),i.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(o=this._getOrReturnCtx(e,o),rr(o,{code:lo.not_finite,message:r.message}),i.dirty()):wl.assertNever(r);return{status:i.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,is.toString(n))}gt(e,n){return this.setLimit("min",e,!1,is.toString(n))}lte(e,n){return this.setLimit("max",e,!0,is.toString(n))}lt(e,n){return this.setLimit("max",e,!1,is.toString(n))}setLimit(e,n,o,i){return new VM({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:o,message:is.toString(i)}]})}_addCheck(e){return new VM({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:is.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:is.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:is.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:is.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:is.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:is.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:is.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:is.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:is.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&wl.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const o of this._def.checks){if(o.kind==="finite"||o.kind==="int"||o.kind==="multipleOf")return!0;o.kind==="min"?(n===null||o.value>n)&&(n=o.value):o.kind==="max"&&(e===null||o.value<e)&&(e=o.value)}return Number.isFinite(n)&&Number.isFinite(e)}}VM.create=t=>new VM({checks:[],typeName:Ea.ZodNumber,coerce:t?.coerce||!1,...EA(t)});class zM extends Bc{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==br.bigint)return this._getInvalidInput(e);let o;const i=new _y;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(o=this._getOrReturnCtx(e,o),rr(o,{code:lo.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),i.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(o=this._getOrReturnCtx(e,o),rr(o,{code:lo.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),i.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(o=this._getOrReturnCtx(e,o),rr(o,{code:lo.not_multiple_of,multipleOf:r.value,message:r.message}),i.dirty()):wl.assertNever(r);return{status:i.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return rr(n,{code:lo.invalid_type,expected:br.bigint,received:n.parsedType}),Zs}gte(e,n){return this.setLimit("min",e,!0,is.toString(n))}gt(e,n){return this.setLimit("min",e,!1,is.toString(n))}lte(e,n){return this.setLimit("max",e,!0,is.toString(n))}lt(e,n){return this.setLimit("max",e,!1,is.toString(n))}setLimit(e,n,o,i){return new zM({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:o,message:is.toString(i)}]})}_addCheck(e){return new zM({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:is.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:is.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:is.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:is.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:is.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}zM.create=t=>new zM({checks:[],typeName:Ea.ZodBigInt,coerce:t?.coerce??!1,...EA(t)});class vne extends Bc{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==br.boolean){const o=this._getOrReturnCtx(e);return rr(o,{code:lo.invalid_type,expected:br.boolean,received:o.parsedType}),Zs}return sx(e.data)}}vne.create=t=>new vne({typeName:Ea.ZodBoolean,coerce:t?.coerce||!1,...EA(t)});class $k extends Bc{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==br.date){const r=this._getOrReturnCtx(e);return rr(r,{code:lo.invalid_type,expected:br.date,received:r.parsedType}),Zs}if(Number.isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return rr(r,{code:lo.invalid_date}),Zs}const o=new _y;let i;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(i=this._getOrReturnCtx(e,i),rr(i,{code:lo.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),o.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(i=this._getOrReturnCtx(e,i),rr(i,{code:lo.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),o.dirty()):wl.assertNever(r);return{status:o.value,value:new Date(e.data.getTime())}}_addCheck(e){return new $k({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:is.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:is.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}$k.create=t=>new $k({checks:[],coerce:t?.coerce||!1,typeName:Ea.ZodDate,...EA(t)});class fct extends Bc{_parse(e){if(this._getType(e)!==br.symbol){const o=this._getOrReturnCtx(e);return rr(o,{code:lo.invalid_type,expected:br.symbol,received:o.parsedType}),Zs}return sx(e.data)}}fct.create=t=>new fct({typeName:Ea.ZodSymbol,...EA(t)});class Fxe extends Bc{_parse(e){if(this._getType(e)!==br.undefined){const o=this._getOrReturnCtx(e);return rr(o,{code:lo.invalid_type,expected:br.undefined,received:o.parsedType}),Zs}return sx(e.data)}}Fxe.create=t=>new Fxe({typeName:Ea.ZodUndefined,...EA(t)});class wne extends Bc{_parse(e){if(this._getType(e)!==br.null){const o=this._getOrReturnCtx(e);return rr(o,{code:lo.invalid_type,expected:br.null,received:o.parsedType}),Zs}return sx(e.data)}}wne.create=t=>new wne({typeName:Ea.ZodNull,...EA(t)});class RV extends Bc{constructor(){super(...arguments),this._any=!0}_parse(e){return sx(e.data)}}RV.create=t=>new RV({typeName:Ea.ZodAny,...EA(t)});class Zk extends Bc{constructor(){super(...arguments),this._unknown=!0}_parse(e){return sx(e.data)}}Zk.create=t=>new Zk({typeName:Ea.ZodUnknown,...EA(t)});class CQ extends Bc{_parse(e){const n=this._getOrReturnCtx(e);return rr(n,{code:lo.invalid_type,expected:br.never,received:n.parsedType}),Zs}}CQ.create=t=>new CQ({typeName:Ea.ZodNever,...EA(t)});class Ict extends Bc{_parse(e){if(this._getType(e)!==br.undefined){const o=this._getOrReturnCtx(e);return rr(o,{code:lo.invalid_type,expected:br.void,received:o.parsedType}),Zs}return sx(e.data)}}Ict.create=t=>new Ict({typeName:Ea.ZodVoid,...EA(t)});class M9 extends Bc{_parse(e){const{ctx:n,status:o}=this._processInputParams(e),i=this._def;if(n.parsedType!==br.array)return rr(n,{code:lo.invalid_type,expected:br.array,received:n.parsedType}),Zs;if(i.exactLength!==null){const s=n.data.length>i.exactLength.value,a=n.data.length<i.exactLength.value;(s||a)&&(rr(n,{code:s?lo.too_big:lo.too_small,minimum:a?i.exactLength.value:void 0,maximum:s?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),o.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(rr(n,{code:lo.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),o.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(rr(n,{code:lo.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),o.dirty()),n.common.async)return Promise.all([...n.data].map((s,a)=>i.type._parseAsync(new w9(n,s,n.path,a)))).then(s=>_y.mergeArray(o,s));const r=[...n.data].map((s,a)=>i.type._parseSync(new w9(n,s,n.path,a)));return _y.mergeArray(o,r)}get element(){return this._def.type}min(e,n){return new M9({...this._def,minLength:{value:e,message:is.toString(n)}})}max(e,n){return new M9({...this._def,maxLength:{value:e,message:is.toString(n)}})}length(e,n){return new M9({...this._def,exactLength:{value:e,message:is.toString(n)}})}nonempty(e){return this.min(1,e)}}M9.create=(t,e)=>new M9({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Ea.ZodArray,...EA(e)});function eF(t){if(t instanceof Km){const e={};for(const n in t.shape){const o=t.shape[n];e[n]=w8.create(eF(o))}return new Km({...t._def,shape:()=>e})}else return t instanceof M9?new M9({...t._def,type:eF(t.element)}):t instanceof w8?w8.create(eF(t.unwrap())):t instanceof WM?WM.create(eF(t.unwrap())):t instanceof v8?v8.create(t.items.map(e=>eF(e))):t}class Km extends Bc{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=wl.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==br.object){const c=this._getOrReturnCtx(e);return rr(c,{code:lo.invalid_type,expected:br.object,received:c.parsedType}),Zs}const{status:o,ctx:i}=this._processInputParams(e),{shape:r,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof CQ&&this._def.unknownKeys==="strip"))for(const c in i.data)s.includes(c)||a.push(c);const A=[];for(const c of s){const l=r[c],g=i.data[c];A.push({key:{status:"valid",value:c},value:l._parse(new w9(i,g,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof CQ){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of a)A.push({key:{status:"valid",value:l},value:{status:"valid",value:i.data[l]}});else if(c==="strict")a.length>0&&(rr(i,{code:lo.unrecognized_keys,keys:a}),o.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of a){const g=i.data[l];A.push({key:{status:"valid",value:l},value:c._parse(new w9(i,g,i.path,l)),alwaysSet:l in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of A){const g=await l.key,u=await l.value;c.push({key:g,value:u,alwaysSet:l.alwaysSet})}return c}).then(c=>_y.mergeObjectSync(o,c)):_y.mergeObjectSync(o,A)}get shape(){return this._def.shape()}strict(e){return is.errToObj,new Km({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,o)=>{const i=this._def.errorMap?.(n,o).message??o.defaultError;return n.code==="unrecognized_keys"?{message:is.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new Km({...this._def,unknownKeys:"strip"})}passthrough(){return new Km({...this._def,unknownKeys:"passthrough"})}extend(e){return new Km({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Km({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ea.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new Km({...this._def,catchall:e})}pick(e){const n={};for(const o of wl.objectKeys(e))e[o]&&this.shape[o]&&(n[o]=this.shape[o]);return new Km({...this._def,shape:()=>n})}omit(e){const n={};for(const o of wl.objectKeys(this.shape))e[o]||(n[o]=this.shape[o]);return new Km({...this._def,shape:()=>n})}deepPartial(){return eF(this)}partial(e){const n={};for(const o of wl.objectKeys(this.shape)){const i=this.shape[o];e&&!e[o]?n[o]=i:n[o]=i.optional()}return new Km({...this._def,shape:()=>n})}required(e){const n={};for(const o of wl.objectKeys(this.shape))if(e&&!e[o])n[o]=this.shape[o];else{let r=this.shape[o];for(;r instanceof w8;)r=r._def.innerType;n[o]=r}return new Km({...this._def,shape:()=>n})}keyof(){return yct(wl.objectKeys(this.shape))}}Km.create=(t,e)=>new Km({shape:()=>t,unknownKeys:"strip",catchall:CQ.create(),typeName:Ea.ZodObject,...EA(e)}),Km.strictCreate=(t,e)=>new Km({shape:()=>t,unknownKeys:"strict",catchall:CQ.create(),typeName:Ea.ZodObject,...EA(e)}),Km.lazycreate=(t,e)=>new Km({shape:t,unknownKeys:"strip",catchall:CQ.create(),typeName:Ea.ZodObject,...EA(e)});class Pne extends Bc{_parse(e){const{ctx:n}=this._processInputParams(e),o=this._def.options;function i(r){for(const a of r)if(a.result.status==="valid")return a.result;for(const a of r)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const s=r.map(a=>new f5(a.ctx.common.issues));return rr(n,{code:lo.invalid_union,unionErrors:s}),Zs}if(n.common.async)return Promise.all(o.map(async r=>{const s={...n,common:{...n.common,issues:[]},parent:null};return{result:await r._parseAsync({data:n.data,path:n.path,parent:s}),ctx:s}})).then(i);{let r;const s=[];for(const A of o){const c={...n,common:{...n.common,issues:[]},parent:null},l=A._parseSync({data:n.data,path:n.path,parent:c});if(l.status==="valid")return l;l.status==="dirty"&&!r&&(r={result:l,ctx:c}),c.common.issues.length&&s.push(c.common.issues)}if(r)return n.common.issues.push(...r.ctx.common.issues),r.result;const a=s.map(A=>new f5(A));return rr(n,{code:lo.invalid_union,unionErrors:a}),Zs}}get options(){return this._def.options}}Pne.create=(t,e)=>new Pne({options:t,typeName:Ea.ZodUnion,...EA(e)});const Q8=t=>t instanceof Oxe?Q8(t.schema):t instanceof yQ?Q8(t.innerType()):t instanceof Nne?[t.value]:t instanceof JM?t.options:t instanceof Gxe?wl.objectValues(t.enum):t instanceof Rne?Q8(t._def.innerType):t instanceof Fxe?[void 0]:t instanceof wne?[null]:t instanceof w8?[void 0,...Q8(t.unwrap())]:t instanceof WM?[null,...Q8(t.unwrap())]:t instanceof Ect||t instanceof kne?Q8(t.unwrap()):t instanceof Tne?Q8(t._def.innerType):[];class Lxe extends Bc{_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==br.object)return rr(n,{code:lo.invalid_type,expected:br.object,received:n.parsedType}),Zs;const o=this.discriminator,i=n.data[o],r=this.optionsMap.get(i);return r?n.common.async?r._parseAsync({data:n.data,path:n.path,parent:n}):r._parseSync({data:n.data,path:n.path,parent:n}):(rr(n,{code:lo.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[o]}),Zs)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,o){const i=new Map;for(const r of n){const s=Q8(r.shape[e]);if(!s.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of s){if(i.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);i.set(a,r)}}return new Lxe({typeName:Ea.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:i,...EA(o)})}}function Hxe(t,e){const n=IQ(t),o=IQ(e);if(t===e)return{valid:!0,data:t};if(n===br.object&&o===br.object){const i=wl.objectKeys(e),r=wl.objectKeys(t).filter(a=>i.indexOf(a)!==-1),s={...t,...e};for(const a of r){const A=Hxe(t[a],e[a]);if(!A.valid)return{valid:!1};s[a]=A.data}return{valid:!0,data:s}}else if(n===br.array&&o===br.array){if(t.length!==e.length)return{valid:!1};const i=[];for(let r=0;r<t.length;r++){const s=t[r],a=e[r],A=Hxe(s,a);if(!A.valid)return{valid:!1};i.push(A.data)}return{valid:!0,data:i}}else return n===br.date&&o===br.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Mne extends Bc{_parse(e){const{status:n,ctx:o}=this._processInputParams(e),i=(r,s)=>{if(dct(r)||dct(s))return Zs;const a=Hxe(r.value,s.value);return a.valid?((hct(r)||hct(s))&&n.dirty(),{status:n.value,value:a.data}):(rr(o,{code:lo.invalid_intersection_types}),Zs)};return o.common.async?Promise.all([this._def.left._parseAsync({data:o.data,path:o.path,parent:o}),this._def.right._parseAsync({data:o.data,path:o.path,parent:o})]).then(([r,s])=>i(r,s)):i(this._def.left._parseSync({data:o.data,path:o.path,parent:o}),this._def.right._parseSync({data:o.data,path:o.path,parent:o}))}}Mne.create=(t,e,n)=>new Mne({left:t,right:e,typeName:Ea.ZodIntersection,...EA(n)});class v8 extends Bc{_parse(e){const{status:n,ctx:o}=this._processInputParams(e);if(o.parsedType!==br.array)return rr(o,{code:lo.invalid_type,expected:br.array,received:o.parsedType}),Zs;if(o.data.length<this._def.items.length)return rr(o,{code:lo.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Zs;!this._def.rest&&o.data.length>this._def.items.length&&(rr(o,{code:lo.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const r=[...o.data].map((s,a)=>{const A=this._def.items[a]||this._def.rest;return A?A._parse(new w9(o,s,o.path,a)):null}).filter(s=>!!s);return o.common.async?Promise.all(r).then(s=>_y.mergeArray(n,s)):_y.mergeArray(n,r)}get items(){return this._def.items}rest(e){return new v8({...this._def,rest:e})}}v8.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new v8({items:t,typeName:Ea.ZodTuple,rest:null,...EA(e)})};class Dne extends Bc{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:o}=this._processInputParams(e);if(o.parsedType!==br.object)return rr(o,{code:lo.invalid_type,expected:br.object,received:o.parsedType}),Zs;const i=[],r=this._def.keyType,s=this._def.valueType;for(const a in o.data)i.push({key:r._parse(new w9(o,a,o.path,a)),value:s._parse(new w9(o,o.data[a],o.path,a)),alwaysSet:a in o.data});return o.common.async?_y.mergeObjectAsync(n,i):_y.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(e,n,o){return n instanceof Bc?new Dne({keyType:e,valueType:n,typeName:Ea.ZodRecord,...EA(o)}):new Dne({keyType:P9.create(),valueType:e,typeName:Ea.ZodRecord,...EA(n)})}}class Cct extends Bc{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:o}=this._processInputParams(e);if(o.parsedType!==br.map)return rr(o,{code:lo.invalid_type,expected:br.map,received:o.parsedType}),Zs;const i=this._def.keyType,r=this._def.valueType,s=[...o.data.entries()].map(([a,A],c)=>({key:i._parse(new w9(o,a,o.path,[c,"key"])),value:r._parse(new w9(o,A,o.path,[c,"value"]))}));if(o.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const A of s){const c=await A.key,l=await A.value;if(c.status==="aborted"||l.status==="aborted")return Zs;(c.status==="dirty"||l.status==="dirty")&&n.dirty(),a.set(c.value,l.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const A of s){const c=A.key,l=A.value;if(c.status==="aborted"||l.status==="aborted")return Zs;(c.status==="dirty"||l.status==="dirty")&&n.dirty(),a.set(c.value,l.value)}return{status:n.value,value:a}}}}Cct.create=(t,e,n)=>new Cct({valueType:e,keyType:t,typeName:Ea.ZodMap,...EA(n)});class TV extends Bc{_parse(e){const{status:n,ctx:o}=this._processInputParams(e);if(o.parsedType!==br.set)return rr(o,{code:lo.invalid_type,expected:br.set,received:o.parsedType}),Zs;const i=this._def;i.minSize!==null&&o.data.size<i.minSize.value&&(rr(o,{code:lo.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&o.data.size>i.maxSize.value&&(rr(o,{code:lo.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const r=this._def.valueType;function s(A){const c=new Set;for(const l of A){if(l.status==="aborted")return Zs;l.status==="dirty"&&n.dirty(),c.add(l.value)}return{status:n.value,value:c}}const a=[...o.data.values()].map((A,c)=>r._parse(new w9(o,A,o.path,c)));return o.common.async?Promise.all(a).then(A=>s(A)):s(a)}min(e,n){return new TV({...this._def,minSize:{value:e,message:is.toString(n)}})}max(e,n){return new TV({...this._def,maxSize:{value:e,message:is.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}TV.create=(t,e)=>new TV({valueType:t,minSize:null,maxSize:null,typeName:Ea.ZodSet,...EA(e)});class kV extends Bc{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==br.function)return rr(n,{code:lo.invalid_type,expected:br.function,received:n.parsedType}),Zs;function o(a,A){return Txe({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Rxe(),DV].filter(c=>!!c),issueData:{code:lo.invalid_arguments,argumentsError:A}})}function i(a,A){return Txe({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Rxe(),DV].filter(c=>!!c),issueData:{code:lo.invalid_return_type,returnTypeError:A}})}const r={errorMap:n.common.contextualErrorMap},s=n.data;if(this._def.returns instanceof FV){const a=this;return sx(async function(...A){const c=new f5([]),l=await a._def.args.parseAsync(A,r).catch(h=>{throw c.addIssue(o(A,h)),c}),g=await Reflect.apply(s,this,l);return await a._def.returns._def.type.parseAsync(g,r).catch(h=>{throw c.addIssue(i(g,h)),c})})}else{const a=this;return sx(function(...A){const c=a._def.args.safeParse(A,r);if(!c.success)throw new f5([o(A,c.error)]);const l=Reflect.apply(s,this,c.data),g=a._def.returns.safeParse(l,r);if(!g.success)throw new f5([i(l,g.error)]);return g.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new kV({...this._def,args:v8.create(e).rest(Zk.create())})}returns(e){return new kV({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,o){return new kV({args:e||v8.create([]).rest(Zk.create()),returns:n||Zk.create(),typeName:Ea.ZodFunction,...EA(o)})}}class Oxe extends Bc{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Oxe.create=(t,e)=>new Oxe({getter:t,typeName:Ea.ZodLazy,...EA(e)});class Nne extends Bc{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return rr(n,{received:n.data,code:lo.invalid_literal,expected:this._def.value}),Zs}return{status:"valid",value:e.data}}get value(){return this._def.value}}Nne.create=(t,e)=>new Nne({value:t,typeName:Ea.ZodLiteral,...EA(e)});function yct(t,e){return new JM({values:t,typeName:Ea.ZodEnum,...EA(e)})}class JM extends Bc{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),o=this._def.values;return rr(n,{expected:wl.joinValues(o),received:n.parsedType,code:lo.invalid_type}),Zs}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),o=this._def.values;return rr(n,{received:n.data,code:lo.invalid_enum_value,options:o}),Zs}return sx(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return JM.create(e,{...this._def,...n})}exclude(e,n=this._def){return JM.create(this.options.filter(o=>!e.includes(o)),{...this._def,...n})}}JM.create=yct;class Gxe extends Bc{_parse(e){const n=wl.getValidEnumValues(this._def.values),o=this._getOrReturnCtx(e);if(o.parsedType!==br.string&&o.parsedType!==br.number){const i=wl.objectValues(n);return rr(o,{expected:wl.joinValues(i),received:o.parsedType,code:lo.invalid_type}),Zs}if(this._cache||(this._cache=new Set(wl.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const i=wl.objectValues(n);return rr(o,{received:o.data,code:lo.invalid_enum_value,options:i}),Zs}return sx(e.data)}get enum(){return this._def.values}}Gxe.create=(t,e)=>new Gxe({values:t,typeName:Ea.ZodNativeEnum,...EA(e)});class FV extends Bc{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==br.promise&&n.common.async===!1)return rr(n,{code:lo.invalid_type,expected:br.promise,received:n.parsedType}),Zs;const o=n.parsedType===br.promise?n.data:Promise.resolve(n.data);return sx(o.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}FV.create=(t,e)=>new FV({type:t,typeName:Ea.ZodPromise,...EA(e)});class yQ extends Bc{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ea.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:o}=this._processInputParams(e),i=this._def.effect||null,r={addIssue:s=>{rr(o,s),s.fatal?n.abort():n.dirty()},get path(){return o.path}};if(r.addIssue=r.addIssue.bind(r),i.type==="preprocess"){const s=i.transform(o.data,r);if(o.common.async)return Promise.resolve(s).then(async a=>{if(n.value==="aborted")return Zs;const A=await this._def.schema._parseAsync({data:a,path:o.path,parent:o});return A.status==="aborted"?Zs:A.status==="dirty"||n.value==="dirty"?NV(A.value):A});{if(n.value==="aborted")return Zs;const a=this._def.schema._parseSync({data:s,path:o.path,parent:o});return a.status==="aborted"?Zs:a.status==="dirty"||n.value==="dirty"?NV(a.value):a}}if(i.type==="refinement"){const s=a=>{const A=i.refinement(a,r);if(o.common.async)return Promise.resolve(A);if(A instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(o.common.async===!1){const a=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});return a.status==="aborted"?Zs:(a.status==="dirty"&&n.dirty(),s(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(a=>a.status==="aborted"?Zs:(a.status==="dirty"&&n.dirty(),s(a.value).then(()=>({status:n.value,value:a.value}))))}if(i.type==="transform")if(o.common.async===!1){const s=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});if(!qk(s))return Zs;const a=i.transform(s.value,r);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(s=>qk(s)?Promise.resolve(i.transform(s.value,r)).then(a=>({status:n.value,value:a})):Zs);wl.assertNever(i)}}yQ.create=(t,e,n)=>new yQ({schema:t,typeName:Ea.ZodEffects,effect:e,...EA(n)}),yQ.createWithPreprocess=(t,e,n)=>new yQ({schema:e,effect:{type:"preprocess",transform:t},typeName:Ea.ZodEffects,...EA(n)});class w8 extends Bc{_parse(e){return this._getType(e)===br.undefined?sx(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}w8.create=(t,e)=>new w8({innerType:t,typeName:Ea.ZodOptional,...EA(e)});class WM extends Bc{_parse(e){return this._getType(e)===br.null?sx(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}WM.create=(t,e)=>new WM({innerType:t,typeName:Ea.ZodNullable,...EA(e)});class Rne extends Bc{_parse(e){const{ctx:n}=this._processInputParams(e);let o=n.data;return n.parsedType===br.undefined&&(o=this._def.defaultValue()),this._def.innerType._parse({data:o,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Rne.create=(t,e)=>new Rne({innerType:t,typeName:Ea.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...EA(e)});class Tne extends Bc{_parse(e){const{ctx:n}=this._processInputParams(e),o={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:o.data,path:o.path,parent:{...o}});return Qne(i)?i.then(r=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new f5(o.common.issues)},input:o.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new f5(o.common.issues)},input:o.data})}}removeCatch(){return this._def.innerType}}Tne.create=(t,e)=>new Tne({innerType:t,typeName:Ea.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...EA(e)});class xct extends Bc{_parse(e){if(this._getType(e)!==br.nan){const o=this._getOrReturnCtx(e);return rr(o,{code:lo.invalid_type,expected:br.nan,received:o.parsedType}),Zs}return{status:"valid",value:e.data}}}xct.create=t=>new xct({typeName:Ea.ZodNaN,...EA(t)});class Ect extends Bc{_parse(e){const{ctx:n}=this._processInputParams(e),o=n.data;return this._def.type._parse({data:o,path:n.path,parent:n})}unwrap(){return this._def.type}}class Yxe extends Bc{_parse(e){const{status:n,ctx:o}=this._processInputParams(e);if(o.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:o.data,path:o.path,parent:o});return r.status==="aborted"?Zs:r.status==="dirty"?(n.dirty(),NV(r.value)):this._def.out._parseAsync({data:r.value,path:o.path,parent:o})})();{const i=this._def.in._parseSync({data:o.data,path:o.path,parent:o});return i.status==="aborted"?Zs:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:o.path,parent:o})}}static create(e,n){return new Yxe({in:e,out:n,typeName:Ea.ZodPipeline})}}class kne extends Bc{_parse(e){const n=this._def.innerType._parse(e),o=i=>(qk(i)&&(i.value=Object.freeze(i.value)),i);return Qne(n)?n.then(i=>o(i)):o(n)}unwrap(){return this._def.innerType}}kne.create=(t,e)=>new kne({innerType:t,typeName:Ea.ZodReadonly,...EA(e)});function Bct(t,e){const n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function w0(t,e={},n){return t?RV.create().superRefine((o,i)=>{const r=t(o);if(r instanceof Promise)return r.then(s=>{if(!s){const a=Bct(e,o),A=a.fatal??n??!0;i.addIssue({code:"custom",...a,fatal:A})}});if(!r){const s=Bct(e,o),a=s.fatal??n??!0;i.addIssue({code:"custom",...s,fatal:a})}}):RV.create()}var Ea;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(Ea||(Ea={}));const Z=P9.create,_t=VM.create;zM.create;const je=vne.create;$k.create;const bct=wne.create,ud=RV.create,Uxe=Zk.create;CQ.create;const dn=M9.create,Pt=Km.create,xo=Pne.create,fy=Lxe.create;Mne.create;const xQ=v8.create,bc=Dne.create,EQ=kV.create,Xe=Nne.create,Kn=JM.create,BQ=FV.create;w8.create,WM.create;const Sct=yQ.createWithPreprocess,I5={string:(t=>P9.create({...t,coerce:!0})),number:(t=>VM.create({...t,coerce:!0})),boolean:(t=>vne.create({...t,coerce:!0})),bigint:(t=>zM.create({...t,coerce:!0})),date:(t=>$k.create({...t,coerce:!0}))},t8n=Zs;var P8=Z().or(_t()).transform(t=>q1(t,"Ω").value),jM=Z().or(_t()).transform(t=>q1(t,"F").value).transform(t=>Number.parseFloat(t.toPrecision(12))),Fne=Z().or(_t()).transform(t=>q1(t,"H").value),O_=Z().or(_t()).transform(t=>q1(t,"V").value),ce=Z().or(_t()).transform(t=>q1(t).value),Iy=Z().or(_t()).transform(t=>q1(t,"Hz").value),ct=ce,k3=Z().or(_t()).transform(t=>q1(t,"A").value),tF=Z().or(_t()).transform(t=>q1(t).value),n8n=tF,Pl=tF,Qct=Z().datetime(),oA=Z().or(_t()).transform(t=>typeof t=="number"?t:t.endsWith("deg")?Number.parseFloat(t.split("deg")[0]):t.endsWith("rad")?Number.parseFloat(t.split("rad")[0])*180/Math.PI:Number.parseFloat(t)),vct=_t().or(Z().endsWith("mAh")).transform(t=>{if(typeof t=="string"){const e=t.replace("mAh",""),n=Number.parseFloat(e);if(Number.isNaN(n))throw new Error("Invalid capacity");return n}return t}).describe("Battery capacity in mAh"),ki=Pt({x:ct,y:ct}),o8n=ki,D9=Pt({x:ct,y:ct,z:ct}),i8n=D9,Lne=Pt({width:_t(),height:_t()}),r8n=t=>{const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:t},()=>e[Math.floor(Math.random()*e.length)]).join("")},so=t=>Z().optional().default(()=>`${t}_${r8n(10)}`),M8=Kn(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),s8n=Kn(["top_silkscreen","bottom_silkscreen","top_copper","bottom_copper","top_soldermask","bottom_soldermask","top_fabrication_note","bottom_fabrication_note","top_user_note","bottom_user_note","top_courtyard","bottom_courtyard","inner1_copper","inner2_copper","inner3_copper","inner4_copper","inner5_copper","inner6_copper","inner7_copper","inner8_copper","edge_cuts","drill"]),Hne=Pt({project_relative_path:Z(),url:Z(),mimetype:Z()}),One=ki.extend({rotation:oA.optional()}),Kxe=Pt({size:ki.optional(),thickness:ct.optional()}),wct=Pt({font:Kxe.optional()}),LV=Pt({value:Z(),at:One.optional(),layer:Z().optional(),uuid:Z().optional(),hide:je().optional(),effects:wct.optional()}),Pct=Pt({Reference:LV.optional(),Value:LV.optional(),Datasheet:LV.optional(),Description:LV.optional()}),Mct=Pt({through_hole:je().optional(),smd:je().optional(),exclude_from_pos_files:je().optional(),exclude_from_bom:je().optional()}),Dct=Pt({name:Z(),type:Z(),shape:Z().optional(),at:One.optional(),size:ki.optional(),drill:ct.optional(),layers:dn(Z()).optional(),removeUnusedLayers:je().optional(),uuid:Z().optional()}),Nct=Pt({path:Z(),offset:D9.optional(),scale:D9.optional(),rotate:D9.optional()}),Rct=Pt({footprintName:Z().optional(),version:xo([_t(),Z()]).optional(),generator:Z().optional(),generatorVersion:xo([_t(),Z()]).optional(),layer:Z().optional(),properties:Pct.optional(),attributes:Mct.optional(),pads:dn(Dct).optional(),embeddedFonts:je().optional(),model:Nct.optional()}),Tct=Pt({hide:je().optional()}),kct=Pt({offset:ct.optional(),hide:je().optional()}),Fct=Pt({font:Kxe.optional(),justify:xo([Z(),dn(Z())]).optional(),hide:je().optional()}),bQ=Pt({value:Z(),id:xo([_t(),Z()]).optional(),at:One.optional(),effects:Fct.optional()}),Lct=Pt({Reference:bQ.optional(),Value:bQ.optional(),Footprint:bQ.optional(),Datasheet:bQ.optional(),Description:bQ.optional(),ki_keywords:bQ.optional(),ki_fp_filters:bQ.optional()}),Hct=Pt({symbolName:Z().optional(),extends:Z().optional(),pinNumbers:Tct.optional(),pinNames:kct.optional(),excludeFromSim:je().optional(),inBom:je().optional(),onBoard:je().optional(),properties:Lct.optional(),embeddedFonts:je().optional()}),Ml=Pt({error_type:Z(),message:Z(),is_fatal:je().optional()}),XM=Kn(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),Bg=Pt({type:Xe("source_component"),ftype:Z().optional(),source_component_id:Z(),name:Z(),manufacturer_part_number:Z().optional(),supplier_part_numbers:bc(XM,dn(Z())).optional(),display_value:Z().optional(),display_name:Z().optional(),are_pins_interchangeable:je().optional(),internally_connected_source_port_ids:dn(dn(Z())).optional(),source_group_id:Z().optional(),subcircuit_id:Z().optional()}),Vxe=Bg.extend({ftype:Xe("simple_capacitor"),capacitance:jM,max_voltage_rating:O_.optional(),display_capacitance:Z().optional(),max_decoupling_trace_length:ct.optional()}),zxe=Bg.extend({ftype:Xe("simple_resistor"),resistance:P8,display_resistance:Z().optional()}),Gne=Bg.extend({ftype:Xe("simple_diode")}),Oct=Bg.extend({ftype:Xe("simple_fiducial")}),Jxe=Gne.extend({ftype:Xe("simple_led"),color:Z().optional(),wavelength:Z().optional()}),Gct=Bg.extend({ftype:Xe("simple_ground")}),Wxe=Bg.extend({ftype:Xe("simple_chip")}),jxe=Bg.extend({ftype:Xe("simple_power_source"),voltage:O_}),Yct=Bg.extend({ftype:Xe("simple_current_source"),current:k3,frequency:Iy.optional(),peak_to_peak_current:k3.optional(),wave_shape:Kn(["sine","square","triangle","sawtooth","dc"]).optional().default("dc"),phase:_t().optional(),duty_cycle:_t().min(0).max(1).optional()}),Uct=Bg.extend({ftype:Xe("simple_fuse"),current_rating_amps:_t().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:_t().describe("Voltage rating in volts, e.g. ±5V would be 5")}),Kct=Bg.extend({ftype:Xe("simple_ammeter")}),Vct=Pt({must_be_connected:je().optional(),provides_power:je().optional(),requires_power:je().optional(),provides_ground:je().optional(),requires_ground:je().optional(),provides_voltage:xo([Z(),_t()]).optional(),requires_voltage:xo([Z(),_t()]).optional(),do_not_connect:je().optional(),include_in_board_pinout:je().optional(),can_use_internal_pullup:je().optional(),is_using_internal_pullup:je().optional(),needs_external_pullup:je().optional(),can_use_internal_pulldown:je().optional(),is_using_internal_pulldown:je().optional(),needs_external_pulldown:je().optional(),can_use_open_drain:je().optional(),is_using_open_drain:je().optional(),can_use_push_pull:je().optional(),is_using_push_pull:je().optional(),should_have_decoupling_capacitor:je().optional(),recommended_decoupling_capacitor_capacitance:xo([Z(),_t()]).optional(),is_configured_for_i2c_sda:je().optional(),is_configured_for_i2c_scl:je().optional(),is_configured_for_spi_mosi:je().optional(),is_configured_for_spi_miso:je().optional(),is_configured_for_spi_sck:je().optional(),is_configured_for_spi_cs:je().optional(),is_configured_for_uart_tx:je().optional(),is_configured_for_uart_rx:je().optional(),supports_i2c_sda:je().optional(),supports_i2c_scl:je().optional(),supports_spi_mosi:je().optional(),supports_spi_miso:je().optional(),supports_spi_sck:je().optional(),supports_spi_cs:je().optional(),supports_uart_tx:je().optional(),supports_uart_rx:je().optional()}),Xxe=Bg.extend({ftype:Xe("simple_battery"),capacity:vct}),qxe=Bg.extend({ftype:Xe("simple_inductor"),inductance:Fne,display_inductance:Z().optional(),max_current_rating:_t().optional()}),$xe=Bg.extend({ftype:Xe("simple_push_button")}),Zxe=Bg.extend({ftype:Xe("simple_potentiometer"),max_resistance:P8,display_max_resistance:Z().optional()}),zct=Bg.extend({ftype:Xe("simple_crystal"),frequency:_t().describe("Frequency in Hz"),load_capacitance:_t().optional().describe("Load capacitance in pF"),pin_variant:Kn(["two_pin","four_pin"]).optional()}),e3e=Bg.extend({ftype:Xe("simple_pin_header"),pin_count:_t(),gender:Kn(["male","female"]).optional().default("male")}),Jct=["usb_c","m2","jst_sh","jst_gh","jst_zh","jst_ph","jst_xh","jst_vh"],Wct=Bg.extend({ftype:Xe("simple_connector"),standard:Kn(Jct).optional(),pin_count:_t().int().positive().optional()}),t3e=Bg.extend({ftype:Xe("simple_pinout")}),n3e=Bg.extend({ftype:Xe("simple_resonator"),load_capacitance:jM,equivalent_series_resistance:P8.optional(),frequency:Iy}),o3e=Bg.extend({ftype:Xe("simple_transistor"),transistor_type:Kn(["npn","pnp"])}),i3e=Bg.extend({ftype:Xe("simple_test_point"),footprint_variant:Kn(["pad","through_hole"]).optional(),pad_shape:Kn(["rect","circle"]).optional(),pad_diameter:xo([_t(),Z()]).optional(),hole_diameter:xo([_t(),Z()]).optional(),width:xo([_t(),Z()]).optional(),height:xo([_t(),Z()]).optional()}),r3e=Bg.extend({ftype:Xe("simple_mosfet"),channel_type:Kn(["n","p"]),mosfet_mode:Kn(["enhancement","depletion"])}),s3e=Bg.extend({ftype:Xe("simple_op_amp")}),a3e=Bg.extend({ftype:Xe("simple_switch")}),A3e=Pt({type:Xe("source_project_metadata"),name:Z().optional(),software_used_string:Z().optional(),project_url:Z().optional(),source_filesystem_md5_hash:Z().optional(),created_at:Qct.optional()}),jct=Ml.extend({type:Xe("source_missing_property_error"),source_missing_property_error_id:so("source_missing_property_error"),source_component_id:Z(),property_name:Z(),subcircuit_id:Z().optional(),error_type:Xe("source_missing_property_error").default("source_missing_property_error")}).describe("The source code is missing a property"),Xct=Ml.extend({type:Xe("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:so("source_failed_to_create_component_error"),error_type:Xe("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:Z().optional(),subcircuit_id:Z().optional(),parent_source_component_id:Z().optional(),pcb_center:Pt({x:_t().optional(),y:_t().optional()}).optional(),schematic_center:Pt({x:_t().optional(),y:_t().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),c3e=Ml.extend({type:Xe("source_invalid_component_property_error"),source_invalid_component_property_error_id:so("source_invalid_component_property_error"),source_component_id:Z(),property_name:Z(),property_value:Uxe().optional(),expected_format:Z().optional(),subcircuit_id:Z().optional(),error_type:Xe("source_invalid_component_property_error").default("source_invalid_component_property_error")}).describe("The source component property is invalid"),l3e=Ml.extend({type:Xe("source_trace_not_connected_error"),source_trace_not_connected_error_id:so("source_trace_not_connected_error"),error_type:Xe("source_trace_not_connected_error").default("source_trace_not_connected_error"),subcircuit_id:Z().optional(),source_group_id:Z().optional(),source_trace_id:Z().optional(),connected_source_port_ids:dn(Z()).optional(),selectors_not_found:dn(Z()).optional()}).describe("Occurs when a source trace selector does not match any ports"),qct=Pt({type:Xe("source_property_ignored_warning"),source_property_ignored_warning_id:so("source_property_ignored_warning"),source_component_id:Z(),property_name:Z(),subcircuit_id:Z().optional(),error_type:Xe("source_property_ignored_warning").default("source_property_ignored_warning"),message:Z()}).describe("The source property was ignored"),g3e=Pt({type:Xe("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:so("source_pin_missing_trace_warning"),warning_type:Xe("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:Z(),source_component_id:Z(),source_port_id:Z(),subcircuit_id:Z().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),u3e=Pt({type:Xe("source_missing_manufacturer_part_number_warning"),source_missing_manufacturer_part_number_warning_id:so("source_missing_manufacturer_part_number_warning"),warning_type:Xe("source_missing_manufacturer_part_number_warning").default("source_missing_manufacturer_part_number_warning"),message:Z(),source_component_id:Z(),standard:Z(),subcircuit_id:Z().optional()}).describe("Warning emitted when a standard connector is missing manufacturer part number"),d3e=Pt({type:Xe("source_refdes_convention_warning"),source_refdes_convention_warning_id:so("source_refdes_convention_warning"),warning_type:Xe("source_refdes_convention_warning").default("source_refdes_convention_warning"),message:Z(),source_component_id:Z(),refdes:Z(),source_component_ftype:Z(),expected_prefixes:dn(Z()),actual_prefix:Z().optional(),subcircuit_id:Z().optional()}).describe("Warning emitted when a source component reference designator does not match the component type convention"),$ct=Bg.extend({ftype:Xe("simple_voltage_probe")}),Zct=Bg.extend({ftype:Xe("interconnect")}),h3e=Ml.extend({type:Xe("source_i2c_misconfigured_error"),source_i2c_misconfigured_error_id:so("source_i2c_misconfigured_error"),error_type:Xe("source_i2c_misconfigured_error").default("source_i2c_misconfigured_error"),source_port_ids:dn(Z())}).describe("Error emitted when incompatible I2C pins (e.g. SDA and SCL) are connected to the same net"),HV=Ml.extend({type:Xe("source_component_misconfigured_error"),source_component_misconfigured_error_id:so("source_component_misconfigured_error"),error_type:Xe("source_component_misconfigured_error").default("source_component_misconfigured_error"),source_component_ids:dn(Z()),source_port_ids:dn(Z()).optional()}).describe("Error emitted when one or more source components have an invalid or conflicting configuration"),elt=Bg.extend({ftype:Xe("simple_voltage_source"),voltage:O_,frequency:Iy.optional(),peak_to_peak_voltage:O_.optional(),wave_shape:Kn(["sinewave","square","triangle","sawtooth"]).optional(),phase:oA.optional(),duty_cycle:_t().optional().describe("Duty cycle as a fraction (0 to 1)"),pulse_delay:Pl.optional(),rise_time:Pl.optional(),fall_time:Pl.optional(),pulse_width:Pl.optional(),period:Pl.optional()}),tlt=xo([zxe,Vxe,Gne,Oct,Jxe,Gct,Wxe,jxe,Yct,Kct,Xxe,qxe,$xe,Zxe,zct,e3e,Wct,t3e,n3e,a3e,o3e,i3e,r3e,s3e,Uct,$ct,Zct,elt,A3e,jct,c3e,Xct,l3e,qct,g3e,u3e,d3e,h3e,HV]),nlt=Pt({type:Xe("source_port"),pin_number:_t().optional(),port_hints:dn(Z()).optional(),name:Z(),source_port_id:Z(),source_component_id:Z().optional(),source_group_id:Z().optional(),most_frequently_referenced_by_name:Z().optional(),subcircuit_id:Z().optional(),subcircuit_connectivity_map_key:Z().optional()}).merge(Vct),olt=Pt({type:Xe("source_component_internal_connection"),source_component_internal_connection_id:Z(),source_component_id:Z(),source_port_ids:dn(Z()),subcircuit_id:Z().optional()}),ilt=Pt({type:Xe("source_trace"),source_trace_id:Z(),connected_source_port_ids:dn(Z()),connected_source_net_ids:dn(Z()),subcircuit_id:Z().optional(),subcircuit_connectivity_map_key:Z().optional(),max_length:_t().optional(),max_via_count:_t().int().nonnegative().optional(),name:Z().optional(),min_trace_thickness:_t().optional(),display_name:Z().optional()}),rlt=Pt({type:Xe("source_group"),source_group_id:Z(),subcircuit_id:Z().optional(),parent_subcircuit_id:Z().optional(),parent_source_group_id:Z().optional(),is_subcircuit:je().optional(),show_as_schematic_box:je().optional(),name:Z().optional(),was_automatically_named:je().optional()}),slt=Pt({type:Xe("source_net"),source_net_id:Z(),name:Z(),member_source_group_ids:dn(Z()),is_power:je().optional(),is_ground:je().optional(),is_digital_signal:je().optional(),is_analog_signal:je().optional(),is_positive_voltage_source:je().optional(),trace_width:_t().optional(),subcircuit_id:Z().optional(),subcircuit_connectivity_map_key:Z().optional()}),alt=Pt({type:Xe("source_board"),source_board_id:Z(),source_group_id:Z(),title:Z().optional()}).describe("Defines a board in the source domain"),Alt=Ml.extend({type:Xe("source_ambiguous_port_reference"),source_ambiguous_port_reference_id:so("source_ambiguous_port_reference"),error_type:Xe("source_ambiguous_port_reference").default("source_ambiguous_port_reference"),source_port_id:Z().optional(),source_component_id:Z().optional()}).describe("Error emitted when a port hint matches multiple non-overlapping pads, making the port reference ambiguous"),clt=Pt({type:Xe("source_pcb_ground_plane"),source_pcb_ground_plane_id:Z(),source_group_id:Z(),source_net_id:Z(),subcircuit_id:Z().optional()}).describe("Defines a ground plane in the source domain"),nF=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6","inner7","inner8"],p3e=Kn(nF),wr=p3e.or(Pt({name:p3e})).transform(t=>typeof t=="string"?t:t.name),Vm=Kn(["top","bottom"]),llt=Pt({type:Xe("source_manually_placed_via"),source_manually_placed_via_id:Z(),source_group_id:Z(),source_net_id:Z().min(1).optional(),subcircuit_id:Z().optional(),source_trace_id:Z().optional()}).describe("Defines a via that is manually placed in the source domain"),glt=Pt({type:Xe("source_unnamed_trace_warning"),source_unnamed_trace_warning_id:so("source_unnamed_trace_warning"),warning_type:Xe("source_unnamed_trace_warning").default("source_unnamed_trace_warning"),message:Z(),source_trace_id:Z(),subcircuit_id:Z().optional()}).describe("Warning emitted when a source trace is missing a name"),ult=Pt({type:Xe("source_no_power_pin_defined_warning"),source_no_power_pin_defined_warning_id:so("source_no_power_pin_defined_warning"),warning_type:Xe("source_no_power_pin_defined_warning").default("source_no_power_pin_defined_warning"),message:Z(),source_component_id:Z(),source_port_ids:dn(Z()),subcircuit_id:Z().optional()}).describe("Warning emitted when a chip has no source ports with requires_power=true"),dlt=Pt({type:Xe("source_no_ground_pin_defined_warning"),source_no_ground_pin_defined_warning_id:so("source_no_ground_pin_defined_warning"),warning_type:Xe("source_no_ground_pin_defined_warning").default("source_no_ground_pin_defined_warning"),message:Z(),source_component_id:Z(),source_port_ids:dn(Z()),subcircuit_id:Z().optional()}).describe("Warning emitted when a chip has no source ports marked as ground pins"),hlt=Pt({type:Xe("source_component_pins_underspecified_warning"),source_component_pins_underspecified_warning_id:so("source_component_pins_underspecified_warning"),warning_type:Xe("source_component_pins_underspecified_warning").default("source_component_pins_underspecified_warning"),message:Z(),source_component_id:Z(),source_port_ids:dn(Z()),subcircuit_id:Z().optional()}).describe("Warning emitted when all ports on a source component are underspecified"),plt=Ml.extend({type:Xe("source_pin_must_be_connected_error"),source_pin_must_be_connected_error_id:so("source_pin_must_be_connected_error"),error_type:Xe("source_pin_must_be_connected_error").default("source_pin_must_be_connected_error"),source_component_id:Z(),source_port_id:Z(),subcircuit_id:Z().optional()}).describe("Error emitted when a pin with mustBeConnected attribute is not connected to any trace"),mlt=Ml.extend({type:Xe("unknown_error_finding_part"),unknown_error_finding_part_id:so("unknown_error_finding_part"),error_type:Xe("unknown_error_finding_part").default("unknown_error_finding_part"),source_component_id:Z().optional(),subcircuit_id:Z().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),OV=Pt({type:Xe("source_part_not_found_warning"),source_part_not_found_warning_id:so("source_part_not_found_warning"),warning_type:Xe("source_part_not_found_warning").default("source_part_not_found_warning"),message:Z(),source_component_id:Z().optional(),subcircuit_id:Z().optional(),supplier_name:XM.optional(),manufacturer_part_number:Z().optional(),supplier_part_number:Z().optional(),part_name:Z().optional()}).describe("Warning emitted when a requested part can not be found"),_lt=Pt({type:Xe("source_confusing_net_name_warning"),source_confusing_net_name_warning_id:so("source_confusing_net_name_warning"),warning_type:Xe("source_confusing_net_name_warning").default("source_confusing_net_name_warning"),message:Z(),source_net_ids:dn(Z()).min(2),net_name:Z(),subcircuit_id:Z().optional()}).describe("Warning emitted when electrically disconnected source nets share a name"),flt=Pt({type:Xe("schematic_box"),schematic_sheet_id:Z().optional(),schematic_component_id:Z().optional(),schematic_symbol_id:Z().optional(),width:ct,height:ct,is_dashed:je().default(!1),x:ct,y:ct,subcircuit_id:Z().optional()}).describe("Draws a box on the schematic"),Ilt=Pt({type:Xe("schematic_path"),schematic_path_id:so("schematic_path"),schematic_sheet_id:Z().optional(),schematic_component_id:Z().optional(),schematic_symbol_id:Z().optional(),fill_color:Z().optional(),is_filled:je().optional(),is_dashed:je().default(!1),stroke_width:ct.nullable().optional(),stroke_color:Z().optional(),dash_length:ct.optional(),dash_gap:ct.optional(),points:dn(ki),subcircuit_id:Z().optional()}),Clt=bc(Pt({left_margin:ce.optional(),right_margin:ce.optional(),top_margin:ce.optional(),bottom_margin:ce.optional()})),ylt=Pt({left_size:_t(),right_size:_t(),top_size:_t().optional(),bottom_size:_t().optional()}),xlt=Pt({left_side:Pt({pins:dn(_t()),direction:Kn(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:Pt({pins:dn(_t()),direction:Kn(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:Pt({pins:dn(_t()),direction:Kn(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:Pt({pins:dn(_t()),direction:Kn(["left-to-right","right-to-left"]).optional()}).optional()}),Elt=xo([ylt,xlt]),Blt=Pt({type:Xe("schematic_component"),size:Lne,center:ki,source_component_id:Z().optional(),schematic_component_id:Z(),schematic_sheet_id:Z().optional(),schematic_symbol_id:Z().optional(),pin_spacing:ce.optional(),pin_styles:Clt.optional(),box_width:ce.optional(),symbol_name:Z().optional(),port_arrangement:Elt.optional(),port_labels:bc(Z()).optional(),symbol_display_value:Z().optional(),subcircuit_id:Z().optional(),schematic_group_id:Z().optional(),is_schematic_group:je().optional(),source_group_id:Z().optional(),is_box_with_pins:je().optional().default(!0)}),a8n=Pt({kicad_symbol:Hct.optional()}).catchall(Uxe()),blt=Pt({type:Xe("schematic_symbol"),schematic_symbol_id:Z(),name:Z().optional(),metadata:a8n.optional()}).describe("Defines a named schematic symbol that can be referenced by components."),Slt=Pt({type:Xe("schematic_line"),schematic_line_id:so("schematic_line"),schematic_sheet_id:Z().optional(),schematic_component_id:Z().optional(),schematic_symbol_id:Z().optional(),x1:ct,y1:ct,x2:ct,y2:ct,stroke_width:ct.nullable().optional(),color:Z().default("#000000"),is_dashed:je().default(!1),dash_length:ct.optional(),dash_gap:ct.optional(),subcircuit_id:Z().optional()}).describe("Draws a styled line on the schematic"),Qlt=Pt({type:Xe("schematic_rect"),schematic_rect_id:so("schematic_rect"),schematic_sheet_id:Z().optional(),schematic_component_id:Z().optional(),schematic_symbol_id:Z().optional(),center:ki,width:ct,height:ct,rotation:oA.default(0),stroke_width:ct.nullable().optional(),color:Z().default("#000000"),is_filled:je().default(!1),fill_color:Z().optional(),is_dashed:je().default(!1),subcircuit_id:Z().optional()}).describe("Draws a styled rectangle on the schematic"),vlt=Pt({type:Xe("schematic_circle"),schematic_circle_id:so("schematic_circle"),schematic_sheet_id:Z().optional(),schematic_component_id:Z().optional(),schematic_symbol_id:Z().optional(),center:ki,radius:ct,stroke_width:ct.nullable().optional(),color:Z().default("#000000"),is_filled:je().default(!1),fill_color:Z().optional(),is_dashed:je().default(!1),subcircuit_id:Z().optional()}).describe("Draws a styled circle on the schematic"),wlt=Pt({type:Xe("schematic_arc"),schematic_arc_id:so("schematic_arc"),schematic_sheet_id:Z().optional(),schematic_component_id:Z().optional(),schematic_symbol_id:Z().optional(),center:ki,radius:ct,start_angle_degrees:oA,end_angle_degrees:oA,direction:Kn(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:ct.nullable().optional(),color:Z().default("#000000"),is_dashed:je().default(!1),subcircuit_id:Z().optional()}).describe("Draws a styled arc on the schematic"),Plt=Pt({type:Xe("schematic_trace"),schematic_trace_id:Z(),schematic_sheet_id:Z().optional(),source_trace_id:Z().optional(),junctions:dn(Pt({x:_t(),y:_t()})),edges:dn(Pt({from:Pt({x:_t(),y:_t()}),to:Pt({x:_t(),y:_t()}),is_crossing:je().optional(),from_schematic_port_id:Z().optional(),to_schematic_port_id:Z().optional()})),subcircuit_id:Z().optional(),subcircuit_connectivity_map_key:Z().optional()}),A8n=Kn(["center","left","right","top","bottom"]),m3e=Pt({text:Z(),is_overlined:je().optional()}),Mlt=Pt({type:Xe("schematic_text"),schematic_sheet_id:Z().optional(),schematic_component_id:Z().optional(),schematic_symbol_id:Z().optional(),schematic_text_id:Z(),source_trace_id:Z().optional(),text:Z(),text_parts:dn(m3e).min(1).optional(),display_superscript:Z().optional(),font_size:_t().default(.18),position:Pt({x:ct,y:ct}),rotation:_t().default(0),anchor:xo([A8n.describe("legacy"),M8]).default("center"),color:Z().default("#000000"),subcircuit_id:Z().optional()}),Dlt=Pt({type:Xe("schematic_port"),schematic_port_id:Z(),source_port_id:Z(),schematic_sheet_id:Z().optional(),schematic_component_id:Z().optional(),center:ki,facing_direction:Kn(["up","down","left","right"]).optional(),distance_from_component_edge:_t().optional(),side_of_component:Kn(["top","bottom","left","right"]).optional(),true_ccw_index:_t().optional(),pin_number:_t().optional(),display_pin_label:Z().optional(),display_pin_label_text_parts:dn(m3e).min(1).optional(),display_pin_label_font_size:_t().positive().finite().optional(),subcircuit_id:Z().optional(),is_connected:je().optional(),is_internal_circuit_port:je().optional(),is_overlapping_internal_circuit_port:je().optional(),has_input_arrow:je().optional(),has_output_arrow:je().optional(),is_drawn_with_inversion_circle:je().optional()}).describe("Defines a port on a schematic component"),Nlt=Pt({type:Xe("schematic_net_label"),schematic_net_label_id:so("schematic_net_label"),schematic_sheet_id:Z().optional(),schematic_trace_id:Z().optional(),source_trace_id:Z().optional(),source_net_id:Z(),center:ki,anchor_position:ki.optional(),anchor_side:Kn(["top","bottom","left","right"]),text:Z(),display_superscript:Z().optional(),symbol_name:Z().optional(),is_movable:je().optional(),subcircuit_id:Z().optional()}),Rlt=Ml.extend({type:Xe("schematic_error"),schematic_error_id:Z(),error_type:Xe("schematic_port_not_found").default("schematic_port_not_found"),subcircuit_id:Z().optional()}).describe("Defines a schematic error on the schematic"),Tlt=Ml.extend({type:Xe("schematic_layout_error"),schematic_layout_error_id:so("schematic_layout_error"),error_type:Xe("schematic_layout_error").default("schematic_layout_error"),source_group_id:Z(),schematic_group_id:Z(),subcircuit_id:Z().optional()}).describe("Error emitted when schematic layout fails for a group"),Yne=Pt({type:Xe("schematic_debug_object"),label:Z().optional(),subcircuit_id:Z().optional()}),klt=Yne.extend({shape:Xe("rect"),center:ki,size:Lne}),Flt=Yne.extend({shape:Xe("line"),start:ki,end:ki}),Llt=Yne.extend({shape:Xe("point"),center:ki}),Hlt=fy("shape",[klt,Flt,Llt]),Olt=Pt({type:Xe("schematic_voltage_probe"),schematic_voltage_probe_id:Z(),schematic_sheet_id:Z().optional(),source_component_id:Z().optional(),name:Z().optional(),position:ki,schematic_trace_id:Z(),voltage:O_.optional(),subcircuit_id:Z().optional(),color:Z().optional(),label_alignment:M8.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),_3e=Pt({type:Xe("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:so("schematic_manual_edit_conflict_warning"),warning_type:Xe("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:Z(),schematic_component_id:Z(),schematic_group_id:Z().optional(),subcircuit_id:Z().optional(),source_component_id:Z()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),Glt=Pt({type:Xe("schematic_component_overlap_warning"),schematic_component_overlap_warning_id:so("schematic_component_overlap_warning"),warning_type:Xe("schematic_component_overlap_warning").default("schematic_component_overlap_warning"),message:Z(),schematic_component_ids:xQ([Z(),Z()]),schematic_sheet_id:Z().optional()}).describe("Warning emitted when the rendered bounds of two schematic components overlap"),Ylt=Pt({type:Xe("schematic_component_styling_warning"),schematic_component_styling_warning_id:so("schematic_component_styling_warning"),warning_type:Xe("schematic_component_styling_warning").default("schematic_component_styling_warning"),message:Z(),schematic_component_id:Z(),styling_issue_type:Z(),schematic_port_ids:dn(Z()).optional(),source_component_id:Z().optional(),schematic_sheet_id:Z().optional(),subcircuit_id:Z().optional()}).describe("Warning emitted when a schematic component has a visual styling issue"),Ult=Pt({type:Xe("schematic_element_outside_sheet_warning"),schematic_element_outside_sheet_warning_id:so("schematic_element_outside_sheet_warning"),warning_type:Xe("schematic_element_outside_sheet_warning").default("schematic_element_outside_sheet_warning"),message:Z(),schematic_sheet_id:Z(),schematic_element_type:Kn(["schematic_component","schematic_net_label","schematic_trace"]),schematic_element_id:Z()}).describe("Warning emitted when a schematic component, net label, or trace extends outside its schematic sheet"),Klt=ct.pipe(_t().positive().finite()),Vlt=Pt({type:Xe("schematic_graphic"),schematic_graphic_id:so("schematic_graphic"),schematic_sheet_id:Z().optional(),asset:Hne.optional(),svg_content:Z().optional(),width:Klt.optional(),height:Klt.optional()}).describe("References a graphic asset or inline SVG content with optional centered layout bounds on a schematic sheet").superRefine(({asset:t,svg_content:e},n)=>{t===void 0&&e===void 0&&n.addIssue({code:lo.custom,message:"At least one of asset or svg_content is required"})}),zlt=Pt({type:Xe("schematic_group"),schematic_group_id:so("schematic_group"),schematic_sheet_id:Z().optional(),source_group_id:Z(),is_subcircuit:je().optional(),subcircuit_id:Z().optional(),width:ce,height:ce,center:ki,schematic_component_ids:dn(Z()),show_as_schematic_box:je().optional(),name:Z().optional(),description:Z().optional()}).describe("Defines a group of components on the schematic"),Jlt=Pt({type:Xe("schematic_table"),schematic_table_id:so("schematic_table"),schematic_sheet_id:Z().optional(),anchor_position:ki,column_widths:dn(ct),row_heights:dn(ct),cell_padding:ct.optional(),border_width:ct.optional(),subcircuit_id:Z().optional(),schematic_component_id:Z().optional(),anchor:M8.optional()}).describe("Defines a table on the schematic"),Wlt=Pt({type:Xe("schematic_table_cell"),schematic_table_cell_id:so("schematic_table_cell"),schematic_sheet_id:Z().optional(),schematic_table_id:Z(),start_row_index:_t(),end_row_index:_t(),start_column_index:_t(),end_column_index:_t(),text:Z().optional(),center:ki,width:ct,height:ct,horizontal_align:Kn(["left","center","right"]).optional(),vertical_align:Kn(["top","middle","bottom"]).optional(),font_size:ct.optional(),subcircuit_id:Z().optional()}).describe("Defines a cell within a schematic_table"),f3e=Kn(["a4","ansi_b"]),jlt=Pt({type:Xe("schematic_sheet"),schematic_sheet_id:so("schematic_sheet"),name:Z().optional(),sheet_index:_t().optional(),sheet_size:f3e.optional(),sheet_width:_t().positive().optional(),sheet_height:_t().positive().optional(),subcircuit_id:Z().optional(),outline_color:Z().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),Xlt=Pt({type:Xe("schematic_missing_sheet_warning"),schematic_missing_sheet_warning_id:so("schematic_missing_sheet_warning"),warning_type:Xe("schematic_missing_sheet_warning").default("schematic_missing_sheet_warning"),message:Z()}).describe("Circuit-wide warning emitted when a schematic has no schematic sheet. Display as a banner without attaching it to a component or drawing a target outline or leader line."),qlt=Pt({x:ct,y:ct,bulge:_t().optional()}),I3e=Pt({vertices:dn(qlt)}),C3e=Pt({outer_ring:I3e,inner_rings:dn(I3e).default([])}),y3e={from_left:"from_left",from_right:"from_right",from_top:"from_top",from_bottom:"from_bottom",from_above:"from_above",from_below:"from_below",from_x_neg:"from_left",from_x_pos:"from_right",from_y_pos:"from_top",from_y_neg:"from_bottom",from_z_pos:"from_above",from_z_neg:"from_below",from_front:"from_top",from_back:"from_bottom"},c8n={from_left:{x:-1,y:0,z:0},from_right:{x:1,y:0,z:0},from_top:{x:0,y:1,z:0},from_bottom:{x:0,y:-1,z:0},from_above:{x:0,y:0,z:1},from_below:{x:0,y:0,z:-1}},$lt=Kn(["from_left","from_right","from_top","from_bottom","from_above","from_below","from_x_neg","from_x_pos","from_y_pos","from_y_neg","from_z_pos","from_z_neg","from_front","from_back"]).transform(t=>y3e[t]).describe('The side exposing the receptacle where the cable or mating part is attached, following the 2D PCB diagram convention, not a 3D viewport frame. In project coordinate space, "from_top" is +Y, "from_bottom" -Y, "from_left" -X, "from_right" +X, "from_above" +Z and "from_below" -Z. A receptacle on the +Y edge is "from_top" even though the plug moves in -Y as it seats. Cartesian spellings such as "from_y_pos" are accepted and normalized to the named values, as are the deprecated "from_front" (now "from_top") and "from_back" (now "from_bottom").'),GV=Kn(["leftside_top","leftside_bottom","rightside_top","rightside_bottom","topside_left","topside_right","bottomside_left","bottomside_right"]),l8n=[["leftside_top","bottomside_left","rightside_bottom","topside_right"],["leftside_bottom","bottomside_right","rightside_top","topside_left"]],g8n=(t,e)=>{for(const n of l8n){const o=n.indexOf(t),i=n.indexOf(e);if(o!==-1&&i!==-1)return(i-o+n.length)%n.length*90}return null},Zlt=Pt({x:ct,y:ct,via:je().optional(),via_to_layer:wr.optional()}),u8n=dn(Zlt),N9=Pt({x:ct,y:ct,via:je().optional(),to_layer:wr.optional(),trace_width:ct.optional()}),e0t=Pt({min_trace_width:ce.optional(),min_board_edge_clearance:ce.optional(),min_via_hole_edge_to_via_hole_edge_clearance:ce.optional(),min_plated_hole_drill_edge_to_drill_edge_clearance:ce.optional(),min_trace_to_pad_edge_clearance:ce.optional(),min_pad_edge_to_pad_edge_clearance:ce.optional(),min_same_net_trace_edge_to_trace_edge_clearance:ce.optional(),min_different_net_trace_edge_to_trace_edge_clearance:ce.optional(),min_via_edge_to_pad_edge_clearance:ce.optional(),min_via_hole_diameter:ce.optional(),min_via_pad_diameter:ce.optional()}),t0t=Pt({type:Xe("pcb_component"),pcb_component_id:so("pcb_component"),source_component_id:Z(),center:ki,layer:wr,rotation:oA,display_offset_x:Z().optional().describe("How to display the x offset for this part, usually corresponding with how the user specified it"),display_offset_y:Z().optional().describe("How to display the y offset for this part, usually corresponding with how the user specified it"),width:ce,height:ce,do_not_place:je().optional(),is_allowed_to_be_off_board:je().optional(),subcircuit_id:Z().optional(),pcb_group_id:Z().optional(),position_mode:Kn(["packed","relative_to_group_anchor","relative_to_another_component","none"]).optional(),anchor_position:ki.optional(),anchor_alignment:M8.optional(),positioned_relative_to_pcb_group_id:Z().optional(),positioned_relative_to_pcb_board_id:Z().optional(),cable_insertion_center:ki.optional(),insertion_direction:$lt.optional(),pin1_location:GV.optional().describe("Location of pin 1 on the unrotated, top-view component footprint"),supplier_pin1_location_map:bc(XM,GV).optional().describe("Pin 1 location for each supplier's unrotated, top-view footprint"),metadata:Pt({kicad_footprint:Rct.optional()}).optional(),obstructs_within_bounds:je().default(!0).describe("Does this component take up all the space within its bounds on a layer. This is generally true except for when separated pin headers are being represented by a single component (in which case, chips can be placed between the pin headers) or for tall modules where chips fit underneath")}).describe("Defines a component on the PCB"),Une=Pt({type:Xe("pcb_debug_object"),pcb_debug_object_id:so("pcb_debug_object"),label:Z().optional(),subcircuit_id:Z().optional()}),n0t=Une.extend({shape:Xe("rect"),center:ki,size:Lne}),o0t=Une.extend({shape:Xe("line"),start:ki,end:ki}),i0t=Une.extend({shape:Xe("point"),center:ki}),r0t=fy("shape",[n0t,o0t,i0t]),s0t=Pt({type:Xe("pcb_hole"),pcb_hole_id:so("pcb_hole"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),pcb_component_id:Z().optional(),hole_shape:Xe("circle"),hole_diameter:_t(),x:ct,y:ct,is_covered_with_solder_mask:je().optional(),soldermask_margin:_t().optional()}),d8n=s0t.describe("Defines a circular hole on the PCB"),a0t=Pt({type:Xe("pcb_hole"),pcb_hole_id:so("pcb_hole"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),pcb_component_id:Z().optional(),hole_shape:Xe("rect"),hole_width:_t(),hole_height:_t(),x:ct,y:ct,is_covered_with_solder_mask:je().optional(),soldermask_margin:_t().optional()}),h8n=a0t.describe("Defines a rectangular (square-capable) hole on the PCB. Use equal width/height for square."),A0t=Pt({type:Xe("pcb_hole"),pcb_hole_id:so("pcb_hole"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),pcb_component_id:Z().optional(),hole_shape:Kn(["circle","square"]),hole_diameter:_t(),x:ct,y:ct,is_covered_with_solder_mask:je().optional(),soldermask_margin:_t().optional()}),p8n=A0t.describe("Defines a circular or square hole on the PCB"),c0t=Pt({type:Xe("pcb_hole"),pcb_hole_id:so("pcb_hole"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),pcb_component_id:Z().optional(),hole_shape:Xe("oval"),hole_width:_t(),hole_height:_t(),x:ct,y:ct,is_covered_with_solder_mask:je().optional(),soldermask_margin:_t().optional()}),m8n=c0t.describe("Defines an oval hole on the PCB"),l0t=Pt({type:Xe("pcb_hole"),pcb_hole_id:so("pcb_hole"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),pcb_component_id:Z().optional(),hole_shape:Xe("pill"),hole_width:_t(),hole_height:_t(),x:ct,y:ct,is_covered_with_solder_mask:je().optional(),soldermask_margin:_t().optional()}),_8n=l0t.describe("Defines a pill-shaped hole on the PCB"),g0t=Pt({type:Xe("pcb_hole"),pcb_hole_id:so("pcb_hole"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),pcb_component_id:Z().optional(),hole_shape:Xe("rotated_pill"),hole_width:_t(),hole_height:_t(),x:ct,y:ct,ccw_rotation:oA,is_covered_with_solder_mask:je().optional(),soldermask_margin:_t().optional()}),f8n=g0t.describe("Defines a rotated pill-shaped hole on the PCB"),u0t=A0t.or(c0t).or(l0t).or(g0t).or(s0t).or(a0t),I8n=Pt({type:Xe("pcb_plated_hole"),shape:Xe("circle"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),outer_diameter:_t(),hole_diameter:_t(),is_covered_with_solder_mask:je().optional(),x:ct,y:ct,layers:dn(wr),port_hints:dn(Z()).optional(),pcb_component_id:Z().optional(),pcb_port_id:Z().optional(),pcb_plated_hole_id:so("pcb_plated_hole"),soldermask_margin:_t().optional()}),C8n=Pt({type:Xe("pcb_plated_hole"),shape:Kn(["oval","pill"]),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),outer_width:_t(),outer_height:_t(),hole_width:_t(),hole_height:_t(),is_covered_with_solder_mask:je().optional(),x:ct,y:ct,ccw_rotation:oA,layers:dn(wr),port_hints:dn(Z()).optional(),pcb_component_id:Z().optional(),pcb_port_id:Z().optional(),pcb_plated_hole_id:so("pcb_plated_hole"),soldermask_margin:_t().optional()}),y8n=Pt({type:Xe("pcb_plated_hole"),shape:Xe("circular_hole_with_rect_pad"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),hole_shape:Xe("circle"),pad_shape:Xe("rect"),hole_diameter:_t(),rect_pad_width:_t(),rect_pad_height:_t(),rect_border_radius:_t().optional(),hole_offset_x:ct.default(0),hole_offset_y:ct.default(0),is_covered_with_solder_mask:je().optional(),x:ct,y:ct,layers:dn(wr),port_hints:dn(Z()).optional(),pcb_component_id:Z().optional(),pcb_port_id:Z().optional(),pcb_plated_hole_id:so("pcb_plated_hole"),soldermask_margin:_t().optional(),rect_ccw_rotation:oA.optional()}),x8n=Pt({type:Xe("pcb_plated_hole"),shape:Xe("pill_hole_with_rect_pad"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),hole_shape:Xe("pill"),pad_shape:Xe("rect"),hole_width:_t(),hole_height:_t(),rect_pad_width:_t(),rect_pad_height:_t(),rect_border_radius:_t().optional(),hole_offset_x:ct.default(0),hole_offset_y:ct.default(0),is_covered_with_solder_mask:je().optional(),x:ct,y:ct,layers:dn(wr),port_hints:dn(Z()).optional(),pcb_component_id:Z().optional(),pcb_port_id:Z().optional(),pcb_plated_hole_id:so("pcb_plated_hole"),soldermask_margin:_t().optional()}),E8n=Pt({type:Xe("pcb_plated_hole"),shape:Xe("rotated_pill_hole_with_rect_pad"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),hole_shape:Xe("rotated_pill"),pad_shape:Xe("rect"),hole_width:_t(),hole_height:_t(),hole_ccw_rotation:oA,rect_pad_width:_t(),rect_pad_height:_t(),rect_border_radius:_t().optional(),rect_ccw_rotation:oA,hole_offset_x:ct.default(0),hole_offset_y:ct.default(0),is_covered_with_solder_mask:je().optional(),x:ct,y:ct,layers:dn(wr),port_hints:dn(Z()).optional(),pcb_component_id:Z().optional(),pcb_port_id:Z().optional(),pcb_plated_hole_id:so("pcb_plated_hole"),soldermask_margin:_t().optional()}),B8n=Pt({type:Xe("pcb_plated_hole"),shape:Xe("hole_with_polygon_pad"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),hole_shape:Kn(["circle","oval","pill","rotated_pill"]),hole_diameter:_t().optional(),hole_width:_t().optional(),hole_height:_t().optional(),pad_outline:dn(Pt({x:ct,y:ct})).min(3),hole_offset_x:ct.default(0),hole_offset_y:ct.default(0),is_covered_with_solder_mask:je().optional(),x:ct,y:ct,layers:dn(wr),port_hints:dn(Z()).optional(),pcb_component_id:Z().optional(),pcb_port_id:Z().optional(),pcb_plated_hole_id:so("pcb_plated_hole"),soldermask_margin:_t().optional(),ccw_rotation:oA.optional()}),d0t=xo([I8n,C8n,y8n,x8n,E8n,B8n]),h0t=Pt({type:Xe("pcb_port"),pcb_port_id:so("pcb_port"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),source_port_id:Z(),pcb_component_id:Z().optional(),x:ct,y:ct,layers:dn(wr),is_board_pinout:je().optional()}).describe("Defines a port on the PCB"),b8n=Pt({type:Xe("pcb_smtpad"),shape:Xe("circle"),pcb_smtpad_id:so("pcb_smtpad"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),x:ct,y:ct,radius:_t(),layer:wr,port_hints:dn(Z()).optional(),pcb_component_id:Z().optional(),pcb_port_id:Z().optional(),is_covered_with_solder_mask:je().optional(),soldermask_margin:_t().optional(),solderpaste_margin:_t().optional()}),S8n=Pt({type:Xe("pcb_smtpad"),shape:Xe("rect"),pcb_smtpad_id:so("pcb_smtpad"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),x:ct,y:ct,width:_t(),height:_t(),rect_border_radius:_t().optional(),corner_radius:_t().optional(),layer:wr,port_hints:dn(Z()).optional(),pcb_component_id:Z().optional(),pcb_port_id:Z().optional(),is_covered_with_solder_mask:je().optional(),soldermask_margin:_t().optional(),soldermask_margin_left:_t().optional(),soldermask_margin_top:_t().optional(),soldermask_margin_right:_t().optional(),soldermask_margin_bottom:_t().optional(),solderpaste_margin:_t().optional()}),Q8n=Pt({type:Xe("pcb_smtpad"),shape:Xe("rotated_rect"),pcb_smtpad_id:so("pcb_smtpad"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),x:ct,y:ct,width:_t(),height:_t(),rect_border_radius:_t().optional(),corner_radius:_t().optional(),ccw_rotation:oA,layer:wr,port_hints:dn(Z()).optional(),pcb_component_id:Z().optional(),pcb_port_id:Z().optional(),is_covered_with_solder_mask:je().optional(),soldermask_margin:_t().optional(),soldermask_margin_left:_t().optional(),soldermask_margin_top:_t().optional(),soldermask_margin_right:_t().optional(),soldermask_margin_bottom:_t().optional(),solderpaste_margin:_t().optional()}),p0t=Pt({type:Xe("pcb_smtpad"),shape:Xe("pill"),pcb_smtpad_id:so("pcb_smtpad"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),x:ct,y:ct,width:_t(),height:_t(),radius:_t(),layer:wr,port_hints:dn(Z()).optional(),pcb_component_id:Z().optional(),pcb_port_id:Z().optional(),is_covered_with_solder_mask:je().optional(),soldermask_margin:_t().optional(),solderpaste_margin:_t().optional()}),v8n=Pt({type:Xe("pcb_smtpad"),shape:Xe("rotated_pill"),pcb_smtpad_id:so("pcb_smtpad"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),x:ct,y:ct,width:_t(),height:_t(),radius:_t(),ccw_rotation:oA,layer:wr,port_hints:dn(Z()).optional(),pcb_component_id:Z().optional(),pcb_port_id:Z().optional(),is_covered_with_solder_mask:je().optional(),soldermask_margin:_t().optional(),solderpaste_margin:_t().optional()}),w8n=Pt({type:Xe("pcb_smtpad"),shape:Xe("polygon"),pcb_smtpad_id:so("pcb_smtpad"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),points:dn(ki),layer:wr,port_hints:dn(Z()).optional(),pcb_component_id:Z().optional(),pcb_port_id:Z().optional(),is_covered_with_solder_mask:je().optional(),soldermask_margin:_t().optional(),solderpaste_margin:_t().optional()}),m0t=fy("shape",[b8n,S8n,Q8n,v8n,p0t,w8n]).describe("Defines an SMT pad on the PCB"),P8n=Pt({type:Xe("pcb_solder_paste"),shape:Xe("circle"),pcb_solder_paste_id:so("pcb_solder_paste"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),x:ct,y:ct,radius:_t(),layer:wr,pcb_component_id:Z().optional(),pcb_smtpad_id:Z().optional()}),M8n=Pt({type:Xe("pcb_solder_paste"),shape:Xe("rect"),pcb_solder_paste_id:so("pcb_solder_paste"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),x:ct,y:ct,width:_t(),height:_t(),layer:wr,pcb_component_id:Z().optional(),pcb_smtpad_id:Z().optional()}),D8n=Pt({type:Xe("pcb_solder_paste"),shape:Xe("pill"),pcb_solder_paste_id:so("pcb_solder_paste"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),x:ct,y:ct,width:_t(),height:_t(),radius:_t(),layer:wr,pcb_component_id:Z().optional(),pcb_smtpad_id:Z().optional()}),N8n=Pt({type:Xe("pcb_solder_paste"),shape:Xe("rotated_rect"),pcb_solder_paste_id:so("pcb_solder_paste"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),x:ct,y:ct,width:_t(),height:_t(),ccw_rotation:ct,layer:wr,pcb_component_id:Z().optional(),pcb_smtpad_id:Z().optional()}),R8n=Pt({type:Xe("pcb_solder_paste"),shape:Xe("rotated_pill"),pcb_solder_paste_id:so("pcb_solder_paste"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),x:ct,y:ct,width:_t(),height:_t(),radius:_t(),ccw_rotation:oA,layer:wr,pcb_component_id:Z().optional(),pcb_smtpad_id:Z().optional()}),T8n=Pt({type:Xe("pcb_solder_paste"),shape:Xe("oval"),pcb_solder_paste_id:so("pcb_solder_paste"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),x:ct,y:ct,width:_t(),height:_t(),layer:wr,pcb_component_id:Z().optional(),pcb_smtpad_id:Z().optional()}),_0t=xo([P8n,M8n,D8n,N8n,R8n,T8n]).describe("Defines solderpaste on the PCB"),f0t=Pt({type:Xe("pcb_text"),pcb_text_id:so("pcb_text"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),text:Z(),center:ki,layer:wr,width:ce,height:ce,lines:_t(),align:Kn(["bottom-left"])}).describe("Defines text on the PCB"),I0t=Pt({route_type:Xe("wire"),x:ct,y:ct,width:ct,copper_pour_id:Z().optional(),is_inside_copper_pour:je().optional(),start_pcb_port_id:Z().optional(),end_pcb_port_id:Z().optional(),layer:wr}),C0t=Pt({route_type:Xe("via"),x:ct,y:ct,copper_pour_id:Z().optional(),is_inside_copper_pour:je().optional(),hole_diameter:ct.optional(),outer_diameter:ct.optional(),from_layer:wr,to_layer:wr}),y0t=Pt({route_type:Xe("through_pad"),start:ki,end:ki,width:ct,start_layer:wr,end_layer:wr,pcb_smtpad_id:Z().optional(),pcb_plated_hole_id:Z().optional()}),x3e=xo([I0t,C0t,y0t]),x0t=Pt({type:Xe("pcb_trace"),source_trace_id:Z().optional(),pcb_component_id:Z().optional(),pcb_trace_id:so("pcb_trace"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),route_thickness_mode:Kn(["constant","interpolated"]).default("constant").optional(),route_order_index:_t().optional(),should_round_corners:je().optional(),trace_length:_t().optional(),highlight_color:Z().optional(),route:dn(x3e)}).describe("Defines a trace on the PCB"),E0t=Pt({type:Xe("pcb_trace_warning"),pcb_trace_warning_id:so("pcb_trace_warning"),warning_type:Xe("pcb_trace_warning").default("pcb_trace_warning"),message:Z(),center:ki.optional(),pcb_trace_id:Z(),source_trace_id:Z(),pcb_component_ids:dn(Z()),pcb_port_ids:dn(Z()),subcircuit_id:Z().optional()}).describe("Defines a trace warning on the PCB"),B0t=Pt({type:Xe("pcb_trace_too_long_warning"),pcb_trace_too_long_warning_id:so("pcb_trace_too_long_warning"),warning_type:Xe("pcb_trace_too_long_warning").default("pcb_trace_too_long_warning"),message:Z(),pcb_trace_id:Z(),source_net_id:Z().optional(),source_trace_id:Z().optional(),actual_trace_length:ct,maximum_trace_length:ct,subcircuit_id:Z().optional()}).describe("Warning emitted when a PCB trace is longer than its maximum allowed length"),b0t=Pt({type:Xe("pcb_trace_too_many_vias_warning"),pcb_trace_too_many_vias_warning_id:so("pcb_trace_too_many_vias_warning"),warning_type:Xe("pcb_trace_too_many_vias_warning").default("pcb_trace_too_many_vias_warning"),message:Z(),pcb_trace_id:Z(),source_net_id:Z().optional(),source_trace_id:Z().optional(),actual_via_count:_t().int().nonnegative(),maximum_via_count:_t().int().nonnegative(),subcircuit_id:Z().optional()}).describe("Warning emitted when a PCB trace has more vias than its maximum allowed count"),S0t=Ml.extend({type:Xe("pcb_trace_error"),pcb_trace_error_id:so("pcb_trace_error"),error_type:Xe("pcb_trace_error").default("pcb_trace_error"),center:ki.optional(),pcb_trace_id:Z(),source_trace_id:Z(),pcb_component_ids:dn(Z()),pcb_port_ids:dn(Z()),subcircuit_id:Z().optional()}).describe("Defines a trace error on the PCB"),Q0t=Ml.extend({type:Xe("pcb_trace_missing_error"),pcb_trace_missing_error_id:so("pcb_trace_missing_error"),error_type:Xe("pcb_trace_missing_error").default("pcb_trace_missing_error"),center:ki.optional(),source_trace_id:Z(),pcb_component_ids:dn(Z()),pcb_port_ids:dn(Z()),subcircuit_id:Z().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),v0t=Ml.extend({type:Xe("pcb_port_not_matched_error"),pcb_error_id:so("pcb_error"),error_type:Xe("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),pcb_component_ids:dn(Z()),subcircuit_id:Z().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),w0t=Ml.extend({type:Xe("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:so("pcb_port_not_connected_error"),error_type:Xe("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),pcb_port_ids:dn(Z()),pcb_component_ids:dn(Z()),subcircuit_id:Z().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),P0t=Pt({type:Xe("pcb_net"),pcb_net_id:so("pcb_net"),source_net_id:Z().optional(),highlight_color:Z().optional()}).describe("Defines a net on the PCB"),Kne=Pt({type:Xe("pcb_via"),pcb_via_id:so("pcb_via"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),subcircuit_connectivity_map_key:Z().optional(),x:ct,y:ct,outer_diameter:ct.default("0.6mm"),hole_diameter:ct.default("0.25mm"),from_layer:wr.optional(),to_layer:wr.optional(),layers:dn(wr),pcb_trace_id:Z().optional(),source_trace_id:Z().optional(),source_net_id:Z().min(1).optional(),net_is_assignable:je().optional(),net_assigned:je().optional(),is_tented:je().optional(),tented_on_top:je().optional(),tented_on_bottom:je().optional()}).transform(({is_tented:t,...e})=>(t!==void 0&&(e.tented_on_top??=t,e.tented_on_bottom??=t),e)).describe("Defines a via on the PCB"),M0t=Pt({type:Xe("pcb_board"),pcb_board_id:so("pcb_board"),pcb_panel_id:Z().optional(),carrier_pcb_board_id:Z().optional(),is_subcircuit:je().optional(),subcircuit_id:Z().optional(),is_mounted_to_carrier_board:je().optional(),is_via_in_pad_allowed:je().optional(),width:ce.optional(),height:ce.optional(),center:ki,display_offset_x:Z().optional().describe("How to display the x offset for this board, usually corresponding with how the user specified it"),display_offset_y:Z().optional().describe("How to display the y offset for this board, usually corresponding with how the user specified it"),thickness:ce.optional().default(1.4),num_layers:_t().optional().default(4),allow_blind_and_buried_vias:je().optional().describe("Whether autorouters may generate blind and buried vias. False restricts newly generated vias to the full board stack."),outline:dn(ki).optional(),shape:Kn(["rect","polygon"]).optional(),material:Kn(["fr4","fr1"]).default("fr4"),solder_mask_color:Z().optional(),silkscreen_color:Z().optional(),anchor_position:ki.optional(),anchor_alignment:M8.optional(),position_mode:Kn(["relative_to_panel_anchor","none"]).optional()}).merge(e0t).describe("Defines the board outline of the PCB"),D0t=Pt({type:Xe("pcb_panel"),pcb_panel_id:so("pcb_panel"),width:ce,height:ce,center:ki,thickness:ce.optional().default(1.4),covered_with_solder_mask:je().optional().default(!0)}).describe("Defines a PCB panel that can contain multiple boards"),N0t=Ml.extend({type:Xe("pcb_placement_error"),pcb_placement_error_id:so("pcb_placement_error"),error_type:Xe("pcb_placement_error").default("pcb_placement_error"),subcircuit_id:Z().optional()}).describe("Defines a placement error on the PCB"),R0t=Ml.extend({type:Xe("pcb_packing_error"),pcb_packing_error_id:so("pcb_packing_error"),error_type:Xe("pcb_packing_error").default("pcb_packing_error"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional()}).describe("Defines a failure to pack PCB components within layout bounds"),T0t=Ml.extend({type:Xe("pcb_panelization_placement_error"),pcb_panelization_placement_error_id:so("pcb_panelization_placement_error"),error_type:Xe("pcb_panelization_placement_error").default("pcb_panelization_placement_error"),pcb_panel_id:Z().optional(),pcb_board_id:Z().optional(),subcircuit_id:Z().optional()}).describe("Defines a panelization placement error on the PCB"),k0t=Pt({type:Xe("pcb_trace_hint"),pcb_trace_hint_id:so("pcb_trace_hint"),pcb_port_id:Z(),pcb_component_id:Z(),route:dn(N9),subcircuit_id:Z().optional()}).describe("A hint that can be used during generation of a PCB trace"),F0t=Pt({type:Xe("pcb_silkscreen_line"),pcb_silkscreen_line_id:so("pcb_silkscreen_line"),pcb_component_id:Z(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),stroke_width:ct.default("0.1mm"),x1:ct,y1:ct,x2:ct,y2:ct,layer:Vm}).describe("Defines a silkscreen line on the PCB"),L0t=Pt({type:Xe("pcb_silkscreen_path"),pcb_silkscreen_path_id:so("pcb_silkscreen_path"),pcb_component_id:Z(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),layer:Vm,route:dn(ki),stroke_width:ce}).describe("Defines a silkscreen path on the PCB"),H0t=Pt({type:Xe("pcb_silkscreen_text"),pcb_silkscreen_text_id:so("pcb_silkscreen_text"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),font:Xe("tscircuit2024").default("tscircuit2024"),font_size:ct.default("0.2mm"),pcb_component_id:Z(),text:Z(),is_knockout:je().default(!1).optional(),knockout_padding:Pt({left:ce,top:ce,bottom:ce,right:ce}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:_t().optional(),layer:wr,is_mirrored:je().default(!1).optional(),anchor_position:ki.default({x:0,y:0}),anchor_alignment:M8.default("center")}).describe("Defines silkscreen text on the PCB"),O0t=Pt({type:Xe("pcb_copper_text"),pcb_copper_text_id:so("pcb_copper_text"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),font:Xe("tscircuit2024").default("tscircuit2024"),font_size:ct.default("0.2mm"),pcb_component_id:Z(),text:Z(),is_knockout:je().default(!1).optional(),knockout_padding:Pt({left:ce,top:ce,bottom:ce,right:ce}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:_t().optional(),layer:wr,is_mirrored:je().default(!1).optional(),anchor_position:ki.default({x:0,y:0}),anchor_alignment:M8.default("center")}).describe("Defines copper text on the PCB"),G0t=Pt({type:Xe("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:so("pcb_silkscreen_rect"),pcb_component_id:Z(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),center:ki,width:ce,height:ce,layer:wr,stroke_width:ce.default("1mm"),corner_radius:ce.optional(),is_filled:je().default(!0).optional(),has_stroke:je().optional(),is_stroke_dashed:je().optional(),ccw_rotation:_t().optional()}).describe("Defines a silkscreen rect on the PCB"),Y0t=Pt({type:Xe("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:so("pcb_silkscreen_circle"),pcb_component_id:Z(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),center:ki,radius:ce,layer:Vm,stroke_width:ce.default("1mm"),is_filled:je().optional()}).describe("Defines a silkscreen circle on the PCB"),U0t=Pt({type:Xe("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:so("pcb_silkscreen_oval"),pcb_component_id:Z(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),center:ki,radius_x:ct,radius_y:ct,layer:Vm,ccw_rotation:oA.optional()}).describe("Defines a silkscreen oval on the PCB"),k8n=Pt({type:Xe("pcb_silkscreen_graphic"),pcb_silkscreen_graphic_id:so("pcb_silkscreen_graphic"),pcb_component_id:Z(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),layer:Vm,image_asset:Hne.optional()}),K0t=k8n.extend({shape:Xe("brep"),brep_shape:C3e}).describe("Defines a BRep silkscreen graphic on the PCB"),V0t=fy("shape",[K0t]).describe("Defines a silkscreen graphic on the PCB"),z0t=Pt({type:Xe("pcb_silkscreen_pill"),pcb_silkscreen_pill_id:so("pcb_silkscreen_pill"),pcb_component_id:Z(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),center:ki,width:ce,height:ce,layer:wr,ccw_rotation:_t().optional()}).describe("Defines a silkscreen pill on the PCB"),E3e=Pt({type:Xe("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:so("pcb_fabrication_note_text"),subcircuit_id:Z().optional(),pcb_group_id:Z().optional(),font:Xe("tscircuit2024").default("tscircuit2024"),font_size:ct.default("1mm"),pcb_component_id:Z(),text:Z(),ccw_rotation:_t().optional(),layer:Vm,anchor_position:ki.default({x:0,y:0}),anchor_alignment:Kn(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:Z().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),B3e=Pt({type:Xe("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:so("pcb_fabrication_note_path"),pcb_component_id:Z(),subcircuit_id:Z().optional(),layer:wr,route:dn(ki),stroke_width:ce,color:Z().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),b3e=Pt({type:Xe("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:so("pcb_fabrication_note_rect"),pcb_component_id:Z(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),center:ki,width:ce,height:ce,layer:Vm,stroke_width:ce.default("0.1mm"),corner_radius:ce.optional(),is_filled:je().optional(),has_stroke:je().optional(),is_stroke_dashed:je().optional(),color:Z().optional()}).describe("Defines a fabrication note rectangle on the PCB"),S3e=Pt({type:Xe("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:so("pcb_fabrication_note_dimension"),pcb_component_id:Z(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),layer:Vm,from:ki,to:ki,text:Z().optional(),text_ccw_rotation:_t().optional(),offset:ce.optional(),offset_distance:ce.optional(),offset_direction:Pt({x:_t(),y:_t()}).optional(),font:Xe("tscircuit2024").default("tscircuit2024"),font_size:ce.default("1mm"),color:Z().optional(),arrow_size:ce.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),Q3e=Pt({type:Xe("pcb_note_text"),pcb_note_text_id:so("pcb_note_text"),pcb_component_id:Z().optional(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),name:Z().optional(),font:Xe("tscircuit2024").default("tscircuit2024"),font_size:ct.default("1mm"),text:Z().optional(),anchor_position:ki.default({x:0,y:0}),anchor_alignment:Kn(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),layer:Vm.default("top"),is_mirrored_from_top_view:je().optional(),color:Z().optional()}).describe("Defines a documentation note in text on the PCB"),v3e=Pt({type:Xe("pcb_note_rect"),pcb_note_rect_id:so("pcb_note_rect"),pcb_component_id:Z().optional(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),name:Z().optional(),text:Z().optional(),center:ki,width:ce,height:ce,layer:Vm.default("top"),stroke_width:ce.default("0.1mm"),corner_radius:ce.optional(),is_filled:je().optional(),has_stroke:je().optional(),is_stroke_dashed:je().optional(),color:Z().optional()}).describe("Defines a rectangular documentation note on the PCB"),w3e=Pt({type:Xe("pcb_note_path"),pcb_note_path_id:so("pcb_note_path"),pcb_component_id:Z().optional(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),name:Z().optional(),text:Z().optional(),route:dn(ki),layer:Vm.default("top"),stroke_width:ce.default("0.1mm"),color:Z().optional()}).describe("Defines a polyline documentation note on the PCB"),P3e=Pt({type:Xe("pcb_note_line"),pcb_note_line_id:so("pcb_note_line"),pcb_component_id:Z().optional(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),name:Z().optional(),text:Z().optional(),x1:ct,y1:ct,x2:ct,y2:ct,layer:Vm.default("top"),stroke_width:ct.default("0.1mm"),color:Z().optional(),is_dashed:je().optional()}).describe("Defines a straight documentation note line on the PCB"),M3e=Pt({type:Xe("pcb_note_dimension"),pcb_note_dimension_id:so("pcb_note_dimension"),pcb_component_id:Z().optional(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),name:Z().optional(),from:ki,to:ki,text:Z().optional(),text_ccw_rotation:_t().optional(),offset_distance:ce.optional(),offset_direction:Pt({x:_t(),y:_t()}).optional(),font:Xe("tscircuit2024").default("tscircuit2024"),font_size:ce.default("1mm"),layer:Vm.default("top"),color:Z().optional(),arrow_size:ce.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),J0t=Ml.extend({type:Xe("pcb_footprint_overlap_error"),pcb_error_id:so("pcb_error"),error_type:Xe("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),pcb_smtpad_ids:dn(Z()).optional(),pcb_plated_hole_ids:dn(Z()).optional(),pcb_hole_ids:dn(Z()).optional(),pcb_keepout_ids:dn(Z()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),W0t=Ml.extend({type:Xe("pcb_courtyard_overlap_error"),pcb_error_id:so("pcb_error"),error_type:Xe("pcb_courtyard_overlap_error").default("pcb_courtyard_overlap_error"),pcb_component_ids:xQ([Z(),Z()])}).describe("Error emitted when the courtyard (CrtYd) of one PCB component overlaps with the courtyard of another"),j0t=Pt({type:Xe("pcb_keepout"),shape:Xe("outline"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),outline:dn(ki).min(2),stroke_width:ce,pcb_keepout_id:Z(),layers:dn(Z()),description:Z().optional(),excluded_pcb_component_ids:dn(Z()).optional()}),D3e=Pt({type:Xe("pcb_keepout"),shape:Xe("rect"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),center:ki,width:ct,height:ct,pcb_keepout_id:Z(),layers:dn(Z()),description:Z().optional(),excluded_pcb_component_ids:dn(Z()).optional()}).or(Pt({type:Xe("pcb_keepout"),shape:Xe("circle"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),center:ki,radius:ct,pcb_keepout_id:Z(),layers:dn(Z()),description:Z().optional(),excluded_pcb_component_ids:dn(Z()).optional()})).or(j0t),Vne=Pt({type:Xe("pcb_cutout"),pcb_cutout_id:so("pcb_cutout"),pcb_component_id:Z().optional(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),pcb_board_id:Z().optional(),pcb_panel_id:Z().optional()}),X0t=Vne.extend({shape:Xe("rect"),center:ki,width:ce,height:ce,rotation:oA.optional(),corner_radius:ce.optional()}),q0t=Vne.extend({shape:Xe("circle"),center:ki,radius:ce}),$0t=Vne.extend({shape:Xe("polygon"),points:dn(ki)}),Z0t=Vne.extend({shape:Xe("path"),route:dn(ki),slot_width:ce,slot_length:ce.optional(),space_between_slots:ce.optional(),slot_corner_radius:ce.optional()}),N3e=fy("shape",[X0t,q0t,$0t,Z0t]).describe("Defines a cutout on the PCB, removing board material."),egt=Ml.extend({type:Xe("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:so("pcb_missing_footprint_error"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),error_type:Xe("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:Z()}).describe("Defines a missing footprint error on the PCB"),YV=Ml.extend({type:Xe("external_footprint_load_error"),external_footprint_load_error_id:so("external_footprint_load_error"),pcb_component_id:Z(),source_component_id:Z(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),footprinter_string:Z().optional(),error_type:Xe("external_footprint_load_error").default("external_footprint_load_error")}).describe("Defines an error when an external footprint fails to load"),R3e=Ml.extend({type:Xe("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:so("circuit_json_footprint_load_error"),pcb_component_id:Z(),source_component_id:Z(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),error_type:Xe("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),circuit_json:dn(ud()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),tgt=Pt({type:Xe("pcb_group"),pcb_group_id:so("pcb_group"),source_group_id:Z(),is_subcircuit:je().optional(),subcircuit_id:Z().optional(),width:ce.optional(),height:ce.optional(),center:ki,display_offset_x:Z().optional().describe("How to display the x offset for this group, usually corresponding with how the user specified it"),display_offset_y:Z().optional().describe("How to display the y offset for this group, usually corresponding with how the user specified it"),outline:dn(ki).optional(),anchor_position:ki.optional(),anchor_alignment:M8.default("center"),position_mode:Kn(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:Z().optional(),positioned_relative_to_pcb_board_id:Z().optional(),pcb_component_ids:dn(Z()),child_layout_mode:Kn(["packed","none"]).optional(),name:Z().optional(),description:Z().optional(),layout_mode:Z().optional(),autorouter_configuration:Pt({trace_clearance:ce}).optional(),autorouter_used_string:Z().optional()}).describe("Defines a group of components on the PCB"),ngt=Ml.extend({type:Xe("pcb_autorouting_error"),pcb_error_id:so("pcb_autorouting_error"),error_type:Xe("pcb_autorouting_error").default("pcb_autorouting_error"),subcircuit_id:Z().optional()}).describe("The autorouting has failed to route a portion of the board"),T3e=Pt({type:Xe("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:so("pcb_manual_edit_conflict_warning"),warning_type:Xe("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:Z(),pcb_component_id:Z(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),source_component_id:Z()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),ogt=Kn(["x-","x+","y+","y-"]),igt=Pt({type:Xe("pcb_connector_not_in_accessible_orientation_warning"),pcb_connector_not_in_accessible_orientation_warning_id:so("pcb_connector_not_in_accessible_orientation_warning"),warning_type:Xe("pcb_connector_not_in_accessible_orientation_warning").default("pcb_connector_not_in_accessible_orientation_warning"),message:Z(),pcb_component_id:Z(),source_component_id:Z().optional(),pcb_board_id:Z().optional(),facing_direction:ogt,recommended_facing_direction:ogt,subcircuit_id:Z().optional()}).describe("Warning emitted when a connector PCB component is facing inward toward the board and should be reoriented to an outward-facing direction"),rgt=Pt({type:Xe("pcb_component_missing_courtyard_warning"),pcb_component_missing_courtyard_warning_id:so("pcb_component_missing_courtyard_warning"),warning_type:Xe("pcb_component_missing_courtyard_warning").default("pcb_component_missing_courtyard_warning"),message:Z(),pcb_component_id:Z(),source_component_id:Z().optional(),subcircuit_id:Z().optional()}).describe("Warning emitted when a PCB component has no courtyard geometry"),k3e=Pt({type:Xe("supplier_footprint_mismatch_warning"),supplier_footprint_mismatch_warning_id:so("supplier_footprint_mismatch_warning"),warning_type:Xe("supplier_footprint_mismatch_warning").default("supplier_footprint_mismatch_warning"),message:Z(),source_component_id:Z(),pcb_component_id:Z().optional(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),supplier_name:XM.optional(),supplier_part_number:Z().optional(),supplier_footprint_url:Z().optional(),footprint_copper_intersection_over_union:_t()}).describe("Warning emitted when a supplier part footprint does not match the expected footprint"),sgt=Pt({type:Xe("pcb_fabricator_extra_charge_warning"),pcb_fabricator_extra_charge_warning_id:so("pcb_fabricator_extra_charge_warning"),warning_type:Xe("pcb_fabricator_extra_charge_warning").default("pcb_fabricator_extra_charge_warning"),message:Z(),fabricator_preset:Z(),pcb_board_id:Z().optional(),pcb_via_ids:dn(Z()).optional(),subcircuit_id:Z().optional()}).describe("Warning that a design feature incurs an extra charge for the selected fabricator preset, such as via hole diameters below 0.3 mm with JLCPCB economy or standard presets."),agt=Pt({type:Xe("pcb_breakout_point"),pcb_breakout_point_id:so("pcb_breakout_point"),pcb_group_id:Z(),subcircuit_id:Z().optional(),source_trace_id:Z().optional(),source_port_id:Z().optional(),source_net_id:Z().optional(),layer:wr.optional(),x:ct,y:ct}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),Agt=Pt({type:Xe("pcb_ground_plane"),pcb_ground_plane_id:so("pcb_ground_plane"),source_pcb_ground_plane_id:Z(),source_net_id:Z(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional()}).describe("Defines a ground plane on the PCB"),cgt=Pt({type:Xe("pcb_ground_plane_region"),pcb_ground_plane_region_id:so("pcb_ground_plane_region"),pcb_ground_plane_id:Z(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),layer:wr,points:dn(ki)}).describe("Defines a polygon region of a ground plane"),lgt=Pt({type:Xe("pcb_thermal_spoke"),pcb_thermal_spoke_id:so("pcb_thermal_spoke"),pcb_ground_plane_id:Z(),shape:Z(),spoke_count:_t(),spoke_thickness:ct,spoke_inner_diameter:ct,spoke_outer_diameter:ct,pcb_plated_hole_id:Z().optional(),subcircuit_id:Z().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),F3e=Pt({type:Xe("pcb_copper_pour"),pcb_copper_pour_id:so("pcb_copper_pour"),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),layer:wr,source_net_id:Z().optional(),covered_with_solder_mask:je().optional().default(!0)}),ggt=F3e.extend({shape:Xe("rect"),center:ki,width:ce,height:ce,rotation:oA.optional()}),ugt=F3e.extend({shape:Xe("brep"),brep_shape:C3e}),dgt=F3e.extend({shape:Xe("polygon"),points:dn(ki)}),L3e=fy("shape",[ggt,ugt,dgt]).describe("Defines a copper pour on the PCB."),hgt=Ml.extend({type:Xe("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:so("pcb_component_outside_board_error"),error_type:Xe("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),pcb_component_id:Z(),pcb_board_id:Z(),component_center:ki,component_bounds:Pt({min_x:_t(),max_x:_t(),min_y:_t(),max_y:_t()}),subcircuit_id:Z().optional(),source_component_id:Z().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),pgt=Ml.extend({type:Xe("pcb_component_not_on_board_edge_error"),pcb_component_not_on_board_edge_error_id:so("pcb_component_not_on_board_edge_error"),error_type:Xe("pcb_component_not_on_board_edge_error").default("pcb_component_not_on_board_edge_error"),pcb_component_id:Z(),pcb_board_id:Z(),component_center:ki,pad_to_nearest_board_edge_distance:_t(),source_component_id:Z().optional(),subcircuit_id:Z().optional()}).describe("Error emitted when a component that must be placed on the board edge is centered away from the edge"),zne=Ml.extend({type:Xe("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:so("pcb_component_invalid_layer_error"),error_type:Xe("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),pcb_component_id:Z().optional(),source_component_id:Z(),layer:wr,subcircuit_id:Z().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),mgt=Ml.extend({type:Xe("pcb_via_clearance_error"),pcb_error_id:so("pcb_error"),error_type:Xe("pcb_via_clearance_error").default("pcb_via_clearance_error"),pcb_via_ids:dn(Z()).min(2),minimum_clearance:ct.optional(),actual_clearance:ct.optional(),pcb_center:Pt({x:_t().optional(),y:_t().optional()}).optional(),subcircuit_id:Z().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),_gt=Ml.extend({type:Xe("pcb_via_trace_clearance_error"),pcb_via_trace_clearance_error_id:so("pcb_via_trace_clearance_error"),error_type:Xe("pcb_via_trace_clearance_error").default("pcb_via_trace_clearance_error"),pcb_via_id:Z(),pcb_trace_id:Z(),minimum_clearance:ct.optional(),actual_clearance:ct.optional(),center:Pt({x:_t().optional(),y:_t().optional()}).optional(),subcircuit_id:Z().optional()}).describe("Error emitted when a via and trace are closer than the allowed clearance"),fgt=Ml.extend({type:Xe("pcb_pad_pad_clearance_error"),pcb_pad_pad_clearance_error_id:so("pcb_pad_pad_clearance_error"),error_type:Xe("pcb_pad_pad_clearance_error").default("pcb_pad_pad_clearance_error"),pcb_pad_ids:dn(Z()).min(2),minimum_clearance:ct.optional(),actual_clearance:ct.optional(),center:Pt({x:_t().optional(),y:_t().optional()}).optional(),subcircuit_id:Z().optional()}).describe("Error emitted when pads are closer than the allowed clearance"),Igt=Ml.extend({type:Xe("pcb_pad_trace_clearance_error"),pcb_pad_trace_clearance_error_id:so("pcb_pad_trace_clearance_error"),error_type:Xe("pcb_pad_trace_clearance_error").default("pcb_pad_trace_clearance_error"),pcb_pad_id:Z(),pcb_trace_id:Z(),minimum_clearance:ct.optional(),actual_clearance:ct.optional(),center:Pt({x:_t().optional(),y:_t().optional()}).optional(),subcircuit_id:Z().optional()}).describe("Error emitted when a pad and trace are closer than allowed clearance"),H3e=Pt({type:Xe("pcb_courtyard_rect"),pcb_courtyard_rect_id:so("pcb_courtyard_rect"),pcb_component_id:Z(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),center:ki,width:ce,height:ce,layer:Vm,ccw_rotation:oA.optional(),color:Z().optional()}).describe("Defines a courtyard rectangle on the PCB"),O3e=Pt({type:Xe("pcb_courtyard_outline"),pcb_courtyard_outline_id:so("pcb_courtyard_outline"),pcb_component_id:Z(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),layer:Vm,outline:dn(ki).min(2)}).describe("Defines a courtyard outline on the PCB"),G3e=Pt({type:Xe("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:so("pcb_courtyard_polygon"),pcb_component_id:Z(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),layer:Vm,points:dn(ki).min(3),color:Z().optional()}).describe("Defines a courtyard polygon on the PCB"),Y3e=Pt({type:Xe("pcb_courtyard_circle"),pcb_courtyard_circle_id:so("pcb_courtyard_circle"),pcb_component_id:Z(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),center:ki,radius:ce,layer:Vm,color:Z().optional()}).describe("Defines a courtyard circle on the PCB"),U3e=Pt({type:Xe("pcb_courtyard_pill"),pcb_courtyard_pill_id:so("pcb_courtyard_pill"),pcb_component_id:Z(),pcb_group_id:Z().optional(),subcircuit_id:Z().optional(),center:ki,width:ce,height:ce,radius:ce,layer:Vm,color:Z().optional()}).describe("Defines a courtyard pill on the PCB"),F8n=["obj","stl","3mf","gltf","glb","step","wrl"],Cgt=["x+","x-","y+","y-","z+","z-"],L8n={obj:"z+",stl:"z+","3mf":"z+",gltf:"y+",glb:"y+",step:"z+",wrl:"y+"},ygt=Pt({type:Xe("cad_component"),cad_component_id:Z(),pcb_component_id:Z(),source_component_id:Z(),position:D9,rotation:D9.optional(),size:D9.optional(),layer:wr.optional(),subcircuit_id:Z().optional(),footprinter_string:Z().optional(),model_obj_url:Z().optional(),model_stl_url:Z().optional(),model_3mf_url:Z().optional(),model_gltf_url:Z().optional(),model_glb_url:Z().optional(),model_step_url:Z().optional(),model_wrl_url:Z().optional(),model_asset:Hne.optional(),model_unit_to_mm_scale_factor:_t().optional(),model_board_normal_direction:Kn(Cgt).optional().describe(`The direction in the model's coordinate space that is considered "up" or "coming out of the board surface"`),model_origin_position:D9.optional(),model_origin_alignment:Kn(["unknown","center","center_of_component_on_board_surface","bottom_center_of_component"]).optional(),model_object_fit:Kn(["contain_within_bounds","fill_bounds"]).optional().default("contain_within_bounds"),model_jscad:ud().optional(),show_as_translucent_model:je().optional(),show_as_bounding_box:je().optional(),show_hidden_edges:je().optional(),anchor_alignment:Kn(["center","center_of_component_on_board_surface"]).optional().default("center")}).describe("Defines a component on the PCB"),K3e=Kn(["sinewave","square","triangle","sawtooth"]),H8n=xo([Z(),_t()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(_t().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),xgt=Pt({type:Xe("simulation_voltage_source"),simulation_voltage_source_id:so("simulation_voltage_source"),is_dc_source:Xe(!0).optional().default(!0),positive_source_port_id:Z().optional(),negative_source_port_id:Z().optional(),positive_source_net_id:Z().optional(),negative_source_net_id:Z().optional(),voltage:O_,ac_magnitude:O_.optional(),ac_phase:oA.optional()}).describe("Defines a DC voltage source for simulation"),Egt=Pt({type:Xe("simulation_voltage_source"),simulation_voltage_source_id:so("simulation_voltage_source"),is_dc_source:Xe(!1),terminal1_source_port_id:Z().optional(),terminal2_source_port_id:Z().optional(),terminal1_source_net_id:Z().optional(),terminal2_source_net_id:Z().optional(),voltage:O_.optional(),frequency:Iy.optional(),peak_to_peak_voltage:O_.optional(),wave_shape:K3e.optional(),phase:oA.optional(),duty_cycle:H8n.optional(),pulse_delay:Pl.optional(),rise_time:Pl.optional(),fall_time:Pl.optional(),pulse_width:Pl.optional(),period:Pl.optional(),ac_magnitude:O_.optional(),ac_phase:oA.optional()}).describe("Defines an AC voltage source for simulation"),Bgt=xo([xgt,Egt]).describe("Defines a voltage source for simulation"),O8n=xo([Z(),_t()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(_t().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),bgt=Pt({type:Xe("simulation_current_source"),simulation_current_source_id:so("simulation_current_source"),is_dc_source:Xe(!0).optional().default(!0),positive_source_port_id:Z().optional(),negative_source_port_id:Z().optional(),positive_source_net_id:Z().optional(),negative_source_net_id:Z().optional(),current:k3,ac_magnitude:k3.optional(),ac_phase:oA.optional()}).describe("Defines a DC current source for simulation"),Sgt=Pt({type:Xe("simulation_current_source"),simulation_current_source_id:so("simulation_current_source"),is_dc_source:Xe(!1),terminal1_source_port_id:Z().optional(),terminal2_source_port_id:Z().optional(),terminal1_source_net_id:Z().optional(),terminal2_source_net_id:Z().optional(),current:k3.optional(),frequency:Iy.optional(),peak_to_peak_current:k3.optional(),wave_shape:K3e.optional(),phase:oA.optional(),duty_cycle:O8n.optional(),ac_magnitude:k3.optional(),ac_phase:oA.optional()}).describe("Defines an AC current source for simulation"),Qgt=xo([bgt,Sgt]).describe("Defines a current source for simulation"),Jne=w0(t=>t==="V"||t==="A"),V3e=w0(t=>t==="Ω"||t==="F"||t==="H"||t==="V"||t==="A"),vgt=xo([Xe("spice_dc_sweep"),Xe("spice_dc_operating_point"),Xe("spice_transient_analysis"),Xe("spice_ac_analysis")]),wgt=Pt({method:Kn(["trap","gear"]).optional(),reltol:xo([_t(),Z()]).optional(),abstol:xo([_t(),Z()]).optional(),vntol:xo([_t(),Z()]).optional()}).describe("SPICE solver options for a simulation experiment"),Pgt=Pt({type:Xe("simulation_experiment"),simulation_experiment_id:so("simulation_experiment"),name:Z(),experiment_type:vgt,time_per_step:tF.optional(),start_time_ms:Pl.optional(),end_time_ms:Pl.optional(),spice_options:wgt.optional(),dc_sweep_voltage_source_id:Z().optional(),dc_sweep_current_source_id:Z().optional(),dc_sweep_start:_t().optional(),dc_sweep_stop:_t().optional(),dc_sweep_step:_t().refine(t=>t!==0).optional(),dc_sweep_unit:Jne.optional(),ac_sweep_type:Kn(["linear","decade","octave"]).optional(),ac_samples_per_interval:_t().int().positive().optional(),ac_sample_count:_t().int().positive().optional(),ac_start_frequency_hz:_t().positive().optional(),ac_stop_frequency_hz:_t().positive().optional()}).superRefine((t,e)=>{if(t.experiment_type==="spice_dc_sweep"){const n=["dc_sweep_start","dc_sweep_stop","dc_sweep_step","dc_sweep_unit"];for(const r of n)t[r]===void 0&&e.addIssue({code:lo.custom,path:[r],message:`${r} is required for a DC sweep`});const o=t.dc_sweep_voltage_source_id!==void 0,i=t.dc_sweep_current_source_id!==void 0;o===i&&e.addIssue({code:lo.custom,path:["dc_sweep_voltage_source_id"],message:"Exactly one DC sweep voltage or current source ID is required"})}t.experiment_type==="spice_ac_analysis"&&(t.ac_sweep_type===void 0&&e.addIssue({code:lo.custom,path:["ac_sweep_type"],message:"ac_sweep_type is required for an AC analysis"}),t.ac_start_frequency_hz===void 0&&e.addIssue({code:lo.custom,path:["ac_start_frequency_hz"],message:"ac_start_frequency_hz is required for an AC analysis"}),t.ac_stop_frequency_hz===void 0&&e.addIssue({code:lo.custom,path:["ac_stop_frequency_hz"],message:"ac_stop_frequency_hz is required for an AC analysis"}),t.ac_sweep_type==="linear"&&t.ac_sample_count===void 0&&e.addIssue({code:lo.custom,path:["ac_sample_count"],message:"ac_sample_count is required for a linear AC analysis"}),(t.ac_sweep_type==="decade"||t.ac_sweep_type==="octave")&&t.ac_samples_per_interval===void 0&&e.addIssue({code:lo.custom,path:["ac_samples_per_interval"],message:"ac_samples_per_interval is required for decade and octave AC analyses"}))}).describe("Defines a simulation experiment configuration"),D8=Pt({simulation_parameter_sweep_id:Z(),sweep_index:_t().int().nonnegative(),parameter_value:_t(),parameter_unit:V3e}),Mgt=Pt({type:Xe("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:so("simulation_transient_voltage_graph"),simulation_experiment_id:Z(),simulation_parameter_sweep_coordinate:D8.optional(),timestamps_ms:dn(_t()).optional(),voltage_levels:dn(_t()),source_component_id:Z().optional(),subcircuit_connectivity_map_key:Z().optional(),time_per_step:tF,start_time_ms:Pl,end_time_ms:Pl,name:Z().optional(),color:Z().optional()}).describe("Stores voltage measurements over time for a simulation"),Dgt=Pt({type:Xe("simulation_transient_current_graph"),simulation_transient_current_graph_id:so("simulation_transient_current_graph"),simulation_experiment_id:Z(),simulation_parameter_sweep_coordinate:D8.optional(),timestamps_ms:dn(_t()).optional(),current_levels:dn(_t()),source_component_id:Z().optional(),subcircuit_connectivity_map_key:Z().optional(),time_per_step:tF,start_time_ms:Pl,end_time_ms:Pl,name:Z().optional(),color:Z().optional()}).describe("Stores current measurements over time for a simulation"),Ngt=Pt({type:Xe("simulation_switch"),simulation_switch_id:so("simulation_switch"),source_component_id:Z().optional(),closes_at:Pl.optional(),opens_at:Pl.optional(),starts_closed:je().optional(),switching_frequency:Iy.optional()}).describe("Defines a switch for simulation timing control"),Rgt=Pt({type:Xe("simulation_voltage_probe"),simulation_voltage_probe_id:so("simulation_voltage_probe"),source_component_id:Z().optional(),name:Z().optional(),signal_input_source_port_id:Z().optional(),signal_input_source_net_id:Z().optional(),reference_input_source_port_id:Z().optional(),reference_input_source_net_id:Z().optional(),subcircuit_id:Z().optional(),color:Z().optional()}).describe("Defines a voltage probe for simulation. If a reference input is not provided, it measures against ground. If a reference input is provided, it measures the differential voltage between two points.").superRefine((t,e)=>{if(t.reference_input_source_port_id||t.reference_input_source_net_id){const o=!!t.signal_input_source_port_id||!!t.reference_input_source_port_id,i=!!t.signal_input_source_net_id||!!t.reference_input_source_net_id;o&&i?e.addIssue({code:lo.custom,message:"Cannot mix port and net connections in a differential probe."}):o?(!t.signal_input_source_port_id||!t.reference_input_source_port_id)&&e.addIssue({code:lo.custom,message:"Differential port probe requires both signal_input_source_port_id and reference_input_source_port_id."}):i&&(!t.signal_input_source_net_id||!t.reference_input_source_net_id)&&e.addIssue({code:lo.custom,message:"Differential net probe requires both signal_input_source_net_id and reference_input_source_net_id."})}else!!t.signal_input_source_port_id==!!t.signal_input_source_net_id&&e.addIssue({code:lo.custom,message:"A voltage probe must have exactly one of signal_input_source_port_id or signal_input_source_net_id."})}),Tgt=Pt({type:Xe("simulation_current_probe"),simulation_current_probe_id:so("simulation_current_probe"),source_component_id:Z().optional(),name:Z().optional(),positive_source_port_id:Z().optional(),negative_source_port_id:Z().optional(),positive_source_net_id:Z().optional(),negative_source_net_id:Z().optional(),subcircuit_id:Z().optional(),color:Z().optional()}).describe("Defines a current probe for simulation. It measures current flowing from the positive endpoint to the negative endpoint.").superRefine((t,e)=>{const n=!!t.positive_source_port_id,o=!!t.negative_source_port_id,i=!!t.positive_source_net_id,r=!!t.negative_source_net_id,s=n||o,a=i||r;if(s&&a){e.addIssue({code:lo.custom,message:"Cannot mix port and net connections in a current probe."});return}if(s){(!n||!o)&&e.addIssue({code:lo.custom,message:"Current probe using source ports requires both positive_source_port_id and negative_source_port_id."});return}if(a){(!i||!r)&&e.addIssue({code:lo.custom,message:"Current probe using source nets requires both positive_source_net_id and negative_source_net_id."});return}e.addIssue({code:lo.custom,message:"A current probe must have either positive/negative source port ids or positive/negative source net ids."})}),kgt=Ml.extend({type:Xe("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:so("simulation_unknown_experiment_error"),error_type:Xe("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),simulation_experiment_id:Z().optional(),subcircuit_id:Z().optional()}).describe("An unknown error occurred during the simulation experiment."),G8n=Kn(["resistance","capacitance","inductance","voltage","current"]),UV=Pt({type:Xe("simulation_parameter_sweep"),simulation_parameter_sweep_id:so("simulation_parameter_sweep"),simulation_experiment_id:Z(),name:Z().optional(),parameter_values:dn(_t()).min(1),parameter_unit:V3e}),Fgt=fy("parameter_type",[UV.extend({parameter_type:Xe("resistance"),resistor_source_component_id:Z()}),UV.extend({parameter_type:Xe("capacitance"),capacitor_source_component_id:Z()}),UV.extend({parameter_type:Xe("inductance"),inductor_source_component_id:Z()}),UV.extend({parameter_type:Xe("voltage"),source_net_id:Z()}),UV.extend({parameter_type:Xe("current"),current_source_component_id:Z()})]).describe("Repeats a simulation experiment over component parameter values"),Lgt=Pt({type:Xe("simulation_dc_operating_point_voltage"),simulation_dc_operating_point_voltage_id:so("simulation_dc_operating_point_voltage"),simulation_experiment_id:Z(),simulation_parameter_sweep_coordinate:D8.optional(),simulation_voltage_probe_id:Z(),voltage:_t(),name:Z().optional(),color:Z().optional()}),Hgt=Pt({type:Xe("simulation_dc_operating_point_current"),simulation_dc_operating_point_current_id:so("simulation_dc_operating_point_current"),simulation_experiment_id:Z(),simulation_parameter_sweep_coordinate:D8.optional(),simulation_current_probe_id:Z(),current:_t(),name:Z().optional(),color:Z().optional()}),Ogt=Pt({type:Xe("simulation_dc_sweep_voltage_graph"),simulation_dc_sweep_voltage_graph_id:so("simulation_dc_sweep_voltage_graph"),simulation_experiment_id:Z(),simulation_parameter_sweep_coordinate:D8.optional(),simulation_voltage_probe_id:Z(),sweep_values:dn(_t()),sweep_unit:Jne,voltage_levels:dn(_t()),name:Z().optional(),color:Z().optional()}).refine(t=>t.sweep_values.length===t.voltage_levels.length,{message:"sweep_values and voltage_levels must have the same length"}),Ggt=Pt({type:Xe("simulation_dc_sweep_current_graph"),simulation_dc_sweep_current_graph_id:so("simulation_dc_sweep_current_graph"),simulation_experiment_id:Z(),simulation_parameter_sweep_coordinate:D8.optional(),simulation_current_probe_id:Z(),sweep_values:dn(_t()),sweep_unit:Jne,current_levels:dn(_t()),name:Z().optional(),color:Z().optional()}).refine(t=>t.sweep_values.length===t.current_levels.length,{message:"sweep_values and current_levels must have the same length"}),z3e=Pt({re:_t(),im:_t()}),Ygt=Pt({type:Xe("simulation_ac_sweep_voltage_graph"),simulation_ac_sweep_voltage_graph_id:so("simulation_ac_sweep_voltage_graph"),simulation_experiment_id:Z(),simulation_parameter_sweep_coordinate:D8.optional(),simulation_voltage_probe_id:Z(),frequencies_hz:dn(_t()),complex_voltages:dn(z3e),name:Z().optional(),color:Z().optional()}).refine(t=>t.frequencies_hz.length===t.complex_voltages.length,{message:"frequencies_hz and complex_voltages must have the same length"}),Ugt=Pt({type:Xe("simulation_ac_sweep_current_graph"),simulation_ac_sweep_current_graph_id:so("simulation_ac_sweep_current_graph"),simulation_experiment_id:Z(),simulation_parameter_sweep_coordinate:D8.optional(),simulation_current_probe_id:Z(),frequencies_hz:dn(_t()),complex_currents:dn(z3e),name:Z().optional(),color:Z().optional()}).refine(t=>t.frequencies_hz.length===t.complex_currents.length,{message:"frequencies_hz and complex_currents must have the same length"}),Kgt=Pt({type:Xe("simulation_op_amp"),simulation_op_amp_id:so("simulation_op_amp"),source_component_id:Z().optional(),inverting_input_source_port_id:Z(),non_inverting_input_source_port_id:Z(),output_source_port_id:Z(),positive_supply_source_port_id:Z(),negative_supply_source_port_id:Z()}).describe("Defines a simple ideal operational amplifier for simulation"),Vgt=Pt({type:Xe("simulation_spice_subcircuit"),simulation_spice_subcircuit_id:so("simulation_spice_subcircuit"),source_component_id:Z(),spice_pin_to_source_port_map:bc(Z(),Z()),subcircuit_source:Z()}).describe("Defines a custom SPICE subcircuit model for simulation"),zgt=t=>t!==void 0,Jgt=Pt({type:Xe("simulation_oscilloscope_trace"),simulation_oscilloscope_trace_id:so("simulation_oscilloscope_trace"),simulation_transient_voltage_graph_id:Z().optional(),simulation_transient_current_graph_id:Z().optional(),simulation_voltage_probe_id:Z().optional(),simulation_current_probe_id:Z().optional(),display_name:Z().optional(),color:Z().optional(),display_center_value:_t().optional(),display_center_offset_divs:_t().optional(),volts_per_div:_t().positive().optional(),amps_per_div:_t().positive().optional()}).describe("Defines how a simulation measurement is rendered as an oscilloscope-style trace.").superRefine((t,e)=>{const n=[t.simulation_transient_voltage_graph_id,t.simulation_voltage_probe_id].filter(zgt).length,o=[t.simulation_transient_current_graph_id,t.simulation_current_probe_id].filter(zgt).length;n+o!==1&&e.addIssue({code:lo.custom,message:"An oscilloscope trace must reference exactly one voltage graph, current graph, voltage probe, or current probe."}),n>0&&t.amps_per_div!==void 0&&e.addIssue({code:lo.custom,message:"Voltage oscilloscope traces must use volts_per_div, not amps_per_div."}),o>0&&t.volts_per_div!==void 0&&e.addIssue({code:lo.custom,message:"Current oscilloscope traces must use amps_per_div, not volts_per_div."})}),J3e=xo([ilt,nlt,olt,tlt,slt,rlt,Wxe,Vxe,Gne,Jxe,zxe,jxe,Xxe,qxe,e3e,t3e,n3e,a3e,o3e,i3e,r3e,s3e,Zxe,$xe,clt,llt,alt,A3e,c3e,l3e,g3e,glt,_lt,u3e,d3e,ult,dlt,hlt,plt,mlt,OV,h3e,HV,Alt,t0t,r0t,u0t,egt,YV,R3e,T3e,igt,rgt,k3e,sgt,d0t,D3e,h0t,P0t,f0t,x0t,E0t,B0t,b0t,Kne,m0t,_0t,M0t,D0t,tgt,k0t,F0t,L0t,H0t,z0t,O0t,G0t,Y0t,U0t,V0t,S0t,Q0t,N0t,R0t,T0t,v0t,w0t,mgt,_gt,fgt,Igt,B3e,E3e,b3e,S3e,Q3e,v3e,w3e,P3e,M3e,ngt,J0t,W0t,agt,N3e,Agt,cgt,lgt,L3e,hgt,pgt,zne,H3e,O3e,G3e,Y3e,U3e,flt,Mlt,Slt,Qlt,vlt,wlt,Blt,blt,Dlt,Plt,Ilt,Rlt,Tlt,Nlt,Hlt,Olt,_3e,Glt,Ylt,Xlt,Ult,Vlt,zlt,jlt,Jlt,Wlt,ygt,Bgt,Qgt,Pgt,Mgt,Dgt,Lgt,Hgt,Ogt,Ggt,Ygt,Ugt,Fgt,Ngt,Rgt,Tgt,Jgt,kgt,Kgt,Vgt]),O4=J3e;const R9=Object.freeze(Object.defineProperty({__proto__:null,all_layers:nF,any_circuit_element:J3e,any_soup_element:O4,any_source_component:tlt,asset:Hne,base_circuit_json_error:Ml,battery_capacity:vct,brep_shape:C3e,cadModelDefaultDirectionMap:L8n,cad_component:ygt,cad_model_axis_directions:Cgt,cad_model_formats:F8n,capacitance:jM,circuit_json_footprint_load_error:R3e,current:k3,distance:ct,duration_ms:tF,experiment_type:vgt,external_footprint_load_error:YV,frequency:Iy,getRotationBetweenPcbPin1Locations:g8n,getZodPrefixedIdWithDefault:so,inductance:Fne,insertionDirectionToCanonical:y3e,insertionDirectionToVector:c8n,insertion_direction:$lt,kicadAt:One,kicadEffects:wct,kicadFont:Kxe,kicadFootprintAttributes:Mct,kicadFootprintMetadata:Rct,kicadFootprintModel:Nct,kicadFootprintPad:Dct,kicadFootprintProperties:Pct,kicadProperty:LV,kicadSymbolEffects:Fct,kicadSymbolMetadata:Hct,kicadSymbolPinNames:kct,kicadSymbolPinNumbers:Tct,kicadSymbolProperties:Lct,kicadSymbolProperty:bQ,layer_ref:wr,layer_string:p3e,length:ce,manufacturing_drc_properties:e0t,ms:Pl,ninePointAnchor:M8,parseAndConvertSiUnit:q1,pcbRenderLayer:s8n,pcb_autorouting_error:ngt,pcb_board:M0t,pcb_breakout_point:agt,pcb_component:t0t,pcb_component_invalid_layer_error:zne,pcb_component_missing_courtyard_warning:rgt,pcb_component_not_on_board_edge_error:pgt,pcb_component_outside_board_error:hgt,pcb_connector_not_in_accessible_orientation_warning:igt,pcb_copper_pour:L3e,pcb_copper_pour_brep:ugt,pcb_copper_pour_polygon:dgt,pcb_copper_pour_rect:ggt,pcb_copper_text:O0t,pcb_courtyard_circle:Y3e,pcb_courtyard_outline:O3e,pcb_courtyard_overlap_error:W0t,pcb_courtyard_pill:U3e,pcb_courtyard_polygon:G3e,pcb_courtyard_rect:H3e,pcb_cutout:N3e,pcb_cutout_circle:q0t,pcb_cutout_path:Z0t,pcb_cutout_polygon:$0t,pcb_cutout_rect:X0t,pcb_debug_line:o0t,pcb_debug_object:r0t,pcb_debug_object_base:Une,pcb_debug_point:i0t,pcb_debug_rect:n0t,pcb_fabrication_note_dimension:S3e,pcb_fabrication_note_path:B3e,pcb_fabrication_note_rect:b3e,pcb_fabrication_note_text:E3e,pcb_fabricator_extra_charge_warning:sgt,pcb_footprint_overlap_error:J0t,pcb_ground_plane:Agt,pcb_ground_plane_region:cgt,pcb_group:tgt,pcb_hole:u0t,pcb_hole_circle_or_square_shape:p8n,pcb_hole_circle_shape:d8n,pcb_hole_oval_shape:m8n,pcb_hole_pill_shape:_8n,pcb_hole_rect_shape:h8n,pcb_hole_rotated_pill_shape:f8n,pcb_keepout:D3e,pcb_keepout_outline:j0t,pcb_manual_edit_conflict_warning:T3e,pcb_missing_footprint_error:egt,pcb_net:P0t,pcb_note_dimension:M3e,pcb_note_line:P3e,pcb_note_path:w3e,pcb_note_rect:v3e,pcb_note_text:Q3e,pcb_packing_error:R0t,pcb_pad_pad_clearance_error:fgt,pcb_pad_trace_clearance_error:Igt,pcb_panel:D0t,pcb_panelization_placement_error:T0t,pcb_pin1_location:GV,pcb_placement_error:N0t,pcb_plated_hole:d0t,pcb_port:h0t,pcb_port_not_connected_error:w0t,pcb_port_not_matched_error:v0t,pcb_route_hint:Zlt,pcb_route_hints:u8n,pcb_silkscreen_circle:Y0t,pcb_silkscreen_graphic:V0t,pcb_silkscreen_graphic_brep:K0t,pcb_silkscreen_line:F0t,pcb_silkscreen_oval:U0t,pcb_silkscreen_path:L0t,pcb_silkscreen_pill:z0t,pcb_silkscreen_rect:G0t,pcb_silkscreen_text:H0t,pcb_smtpad:m0t,pcb_smtpad_pill:p0t,pcb_solder_paste:_0t,pcb_text:f0t,pcb_thermal_spoke:lgt,pcb_trace:x0t,pcb_trace_error:S0t,pcb_trace_hint:k0t,pcb_trace_missing_error:Q0t,pcb_trace_route_point:x3e,pcb_trace_route_point_through_pad:y0t,pcb_trace_route_point_via:C0t,pcb_trace_route_point_wire:I0t,pcb_trace_too_long_warning:B0t,pcb_trace_too_many_vias_warning:b0t,pcb_trace_warning:E0t,pcb_via:Kne,pcb_via_clearance_error:mgt,pcb_via_trace_clearance_error:_gt,point:ki,point3:D9,point_with_bulge:qlt,port_arrangement:Elt,position:o8n,position3:i8n,resistance:P8,ring:I3e,rotation:oA,route_hint_point:N9,schematic_arc:wlt,schematic_box:flt,schematic_circle:vlt,schematic_component:Blt,schematic_component_overlap_warning:Glt,schematic_component_port_arrangement_by_sides:xlt,schematic_component_port_arrangement_by_size:ylt,schematic_component_styling_warning:Ylt,schematic_debug_line:Flt,schematic_debug_object:Hlt,schematic_debug_object_base:Yne,schematic_debug_point:Llt,schematic_debug_rect:klt,schematic_element_outside_sheet_warning:Ult,schematic_error:Rlt,schematic_graphic:Vlt,schematic_group:zlt,schematic_layout_error:Tlt,schematic_line:Slt,schematic_manual_edit_conflict_warning:_3e,schematic_missing_sheet_warning:Xlt,schematic_net_label:Nlt,schematic_path:Ilt,schematic_pin_styles:Clt,schematic_port:Dlt,schematic_rect:Qlt,schematic_sheet:jlt,schematic_sheet_size:f3e,schematic_symbol:blt,schematic_table:Jlt,schematic_table_cell:Wlt,schematic_text:Mlt,schematic_text_part:m3e,schematic_trace:Plt,schematic_voltage_probe:Olt,simulation_ac_current_source:Sgt,simulation_ac_sweep_current_graph:Ugt,simulation_ac_sweep_voltage_graph:Ygt,simulation_ac_voltage_source:Egt,simulation_complex_sample:z3e,simulation_current_probe:Tgt,simulation_current_source:Qgt,simulation_dc_current_source:bgt,simulation_dc_operating_point_current:Hgt,simulation_dc_operating_point_voltage:Lgt,simulation_dc_sweep_current_graph:Ggt,simulation_dc_sweep_unit:Jne,simulation_dc_sweep_voltage_graph:Ogt,simulation_dc_voltage_source:xgt,simulation_experiment:Pgt,simulation_op_amp:Kgt,simulation_oscilloscope_trace:Jgt,simulation_parameter_sweep:Fgt,simulation_parameter_sweep_coordinate:D8,simulation_parameter_type:G8n,simulation_parameter_unit:V3e,simulation_spice_subcircuit:Vgt,simulation_switch:Ngt,simulation_transient_current_graph:Dgt,simulation_transient_voltage_graph:Mgt,simulation_unknown_experiment_error:kgt,simulation_voltage_probe:Rgt,simulation_voltage_source:Bgt,size:Lne,source_ambiguous_port_reference:Alt,source_board:alt,source_component_base:Bg,source_component_internal_connection:olt,source_component_misconfigured_error:HV,source_component_pins_underspecified_warning:hlt,source_confusing_net_name_warning:_lt,source_failed_to_create_component_error:Xct,source_group:rlt,source_i2c_misconfigured_error:h3e,source_interconnect:Zct,source_invalid_component_property_error:c3e,source_manually_placed_via:llt,source_missing_manufacturer_part_number_warning:u3e,source_missing_property_error:jct,source_net:slt,source_no_ground_pin_defined_warning:dlt,source_no_power_pin_defined_warning:ult,source_part_not_found_warning:OV,source_pcb_ground_plane:clt,source_pin_attributes:Vct,source_pin_missing_trace_warning:g3e,source_pin_must_be_connected_error:plt,source_port:nlt,source_project_metadata:A3e,source_property_ignored_warning:qct,source_refdes_convention_warning:d3e,source_simple_ammeter:Kct,source_simple_battery:Xxe,source_simple_capacitor:Vxe,source_simple_chip:Wxe,source_simple_connector:Wct,source_simple_connector_standards:Jct,source_simple_crystal:zct,source_simple_current_source:Yct,source_simple_diode:Gne,source_simple_fiducial:Oct,source_simple_fuse:Uct,source_simple_ground:Gct,source_simple_inductor:qxe,source_simple_led:Jxe,source_simple_mosfet:r3e,source_simple_op_amp:s3e,source_simple_pin_header:e3e,source_simple_pinout:t3e,source_simple_potentiometer:Zxe,source_simple_power_source:jxe,source_simple_push_button:$xe,source_simple_resistor:zxe,source_simple_resonator:n3e,source_simple_switch:a3e,source_simple_test_point:i3e,source_simple_transistor:o3e,source_simple_voltage_probe:$ct,source_simple_voltage_source:elt,source_trace:ilt,source_trace_not_connected_error:l3e,source_unnamed_trace_warning:glt,spice_simulation_options:wgt,supplier_footprint_mismatch_warning:k3e,supplier_name:XM,time:n8n,timestamp:Qct,unknown_error_finding_part:mlt,visible_layer:Vm,voltage:O_,wave_shape:K3e},Symbol.toStringTag,{value:"Module"}));function hn(t,e){return Array.isArray(e)?[t.a*e[0]+t.c*e[1]+t.e,t.b*e[0]+t.d*e[1]+t.f]:{x:t.a*e.x+t.c*e.y+t.e,y:t.b*e.x+t.d*e.y+t.f}}const Y8n=/^matrix\(\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*\)$/i;function U8n(t){const e=t.match(Y8n);if(e===null||e.length<7)throw new Error(`'${t}' is not a matrix`);return{a:parseFloat(e[1]),b:parseFloat(e[2]),c:parseFloat(e[3]),d:parseFloat(e[4]),e:parseFloat(e[5]),f:parseFloat(e[6])}}function K8n(t){const{a:e,b:n,c:o,d:i,e:r,f:s}=t,a=e*i-n*o;return{a:i/a,b:n/-a,c:o/-a,d:e/a,e:(i*r-o*s)/-a,f:(n*r-e*s)/a}}function KV(t){return typeof t>"u"}function G_(t,e=0){return{a:1,c:0,e:t,b:0,d:1,f:e}}function VV(...t){t=Array.isArray(t[0])?t[0]:t;const e=(n,o)=>({a:n.a*o.a+n.c*o.b,c:n.a*o.c+n.c*o.d,e:n.a*o.e+n.c*o.f+n.e,b:n.b*o.a+n.d*o.b,d:n.b*o.c+n.d*o.d,f:n.b*o.e+n.d*o.f+n.f});switch(t.length){case 0:throw new Error("no matrices provided");case 1:return t[0];case 2:return e(t[0],t[1]);default:{const[n,o,...i]=t,r=e(n,o);return VV(r,...i)}}}function l0(...t){return VV(...t)}const{cos:V8n,sin:z8n}=Math;function N8(t,e,n){const o=V8n(t),i=z8n(t),r={a:o,c:-i,e:0,b:i,d:o,f:0};return KV(e)||KV(n)?r:VV([G_(e,n),r,G_(-e,-n)])}function ax(t,e=void 0,n=void 0,o=void 0){KV(e)&&(e=t);const i={a:t,c:0,e:0,b:0,d:e,f:0};return KV(n)||KV(o)?i:VV([G_(n,o),i,G_(-n,-o)])}function J8n(t){return R8(t)}function R8(t){return`matrix(${t.a},${t.b},${t.c},${t.d},${t.e},${t.f})`}function W8n(t,e=1e10){return{a:Math.round(t.a*e)/e,b:Math.round(t.b*e)/e,c:Math.round(t.c*e)/e,d:Math.round(t.d*e)/e,e:Math.round(t.e*e)/e,f:Math.round(t.f*e)/e}}function j8n(t,e){const n=t[0].x!=null?t[0].x:t[0][0],o=t[0].y!=null?t[0].y:t[0][1],i=e[0].x!=null?e[0].x:e[0][0],r=e[0].y!=null?e[0].y:e[0][1],s=t[1].x!=null?t[1].x:t[1][0],a=t[1].y!=null?t[1].y:t[1][1],A=e[1].x!=null?e[1].x:e[1][0],c=e[1].y!=null?e[1].y:e[1][1],l=t[2].x!=null?t[2].x:t[2][0],g=t[2].y!=null?t[2].y:t[2][1],u=e[2].x!=null?e[2].x:e[2][0],h=e[2].y!=null?e[2].y:e[2][1],d={a:n-l,b:o-g,c:s-l,d:a-g,e:l,f:g},p={a:i-u,b:r-h,c:A-u,d:c-h,e:u,f:h},m=K8n(d),_=VV([p,m]);return W8n(_)}function X8n(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n}function Wne(t,e,n,o){var i=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(i,Wne.prototype),i.expected=e,i.found=n,i.location=o,i.name="SyntaxError",i}X8n(Wne,Error);function W3e(t,e,n){return n=n||" ",t.length>e?t:(e-=t.length,n+=n.repeat(e),t+n.slice(0,e))}Wne.prototype.format=function(t){var e="Error: "+this.message;if(this.location){var n=null,o;for(o=0;o<t.length;o++)if(t[o].source===this.location.source){n=t[o].text.split(/\r\n|\n|\r/g);break}var i=this.location.start,r=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(i):i,s=this.location.source+":"+r.line+":"+r.column;if(n){var a=this.location.end,A=W3e("",r.line.toString().length," "),c=n[i.line-1],l=i.line===a.line?a.column:c.length+1,g=l-i.column||1;e+=`
|
|
242
242
|
--> `+s+`
|
|
243
243
|
`+A+` |
|
|
@@ -5504,15 +5504,15 @@ svg { font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif; }
|
|
|
5504
5504
|
.simulation-line { fill: none; stroke-width: 2.5; }
|
|
5505
5505
|
.simulation-point { stroke-width: 0; }
|
|
5506
5506
|
.chart-title { fill: rgba(0, 0, 0, 0.85); font-size: 18px; font-weight: 600; }
|
|
5507
|
-
`;return rc("style",{},[JB(t)])}function u0n(t,e){const n=t[e];if(typeof n=="string")return n}function svi(t,e,n,o){const r=[4,8],s=r.map(u=>ji(u)).join(" "),A=r.reduce((u,h)=>u+h,0)/3,c=[];t.forEach((u,h)=>{if(u.points.length===0)return;const d=[];u.points.forEach((I,C)=>{const y=ji(n(I.timeMs)),x=ji(o(I.displayValue));d.push(`${C===0?"M":"L"} ${y} ${x}`)});const p={class:"simulation-line",d:d.join(" "),stroke:u.color,"clip-path":`url(#${e})`,[s0n(u.graph)]:lWe(u.graph)};u.graph.source_component_id&&(p["data-source-component-id"]=u.graph.source_component_id);const m=u0n(u.graph,"source_probe_id");m&&(p["data-source-probe-id"]=m);const _=u0n(u.graph,"source_probe_name");_&&(p["data-source-probe-name"]=_),u.graph.subcircuit_connectivity_map_key&&(p["data-subcircuit-connectivity-map-key"]=u.graph.subcircuit_connectivity_map_key);const f=u.points.map(I=>{const C=ji(n(I.timeMs)),y=ji(o(I.displayValue));return rc("circle",{class:"simulation-point",cx:C,cy:y,r:"2.5",fill:u.color,"clip-path":`url(#${e})`})});c.push({entry:u,graphIndex:h,pathAttributes:p,pointElements:f})});const l=[];for(let u=0;u<3;u++)for(const h of c){const d=(h.graphIndex+u)%3,p=ji(d*A);l.push(rc("path",{...h.pathAttributes,"stroke-dasharray":s,"stroke-dashoffset":p}))}const g=c.flatMap(u=>u.pointElements);return rc("g",{class:"data-series"},[...l,...g])}function avi(t,e){return t?.name?rc("text",{class:"chart-title",x:ji(e/2),y:ji(dm.top-40),"text-anchor":"middle"},[JB(t.name)]):null}var d0n=16;function Avi(t,e,n,o){const i=o.map((r,s)=>rc("tspan",{x:"20",dy:s===0?"0":String(d0n)},[JB(r)]));return rc("g",{class:"legend-item",transform:`translate(${ji(e)} ${ji(n)})`},[rc("line",{class:"legend-line",x1:"0",y1:"0",x2:"16",y2:"0",stroke:t.color}),rc("text",{class:"legend-label",x:"20",y:"0","dominant-baseline":"middle"},i)])}var cvi=15;function lvi(t){const e=t.split("_");if(e.length<=1)return[t];const n=[];let o=e[0]??"";for(let i=1;i<e.length;i++){const r=e[i]??"",s=`${o}_${r}`;s.length>cvi?(n.push(o),o=r):o=s}return o&&n.push(o),n}var gvi=24;function uvi(t,e){let n=dm.top;const o=t.map(i=>{const r=e-dm.right+10,s=lvi(i.label),a=Avi(i,r,n,s),A=s.length*d0n;return n+=Math.max(A,gvi),a});return rc("g",{class:"legend"},o)}var fT=118,Yme=94,pU=18;function h0n(t,e){const n=Math.floor((e+pU)/(fT+pU)),o=Math.max(1,Math.min(n,t)),i=Math.max(1,Math.ceil(t/o)),r=o*fT+(o-1)*pU,s=i*Yme+(i-1)*pU;return{columns:o,rows:i,x:Math.max(0,(e-r)/2),height:s}}var Ume=20,uWe=8,dvi=14;function hvi(t,e,n){const o=h0n(t.length,e),i=[];for(const[r,s]of t.entries()){const a=r%o.columns,A=Math.floor(r/o.columns);i.push(pvi(s,r,o.x+a*(fT+pU),n+AWe+A*(Yme+pU)))}return rc("g",{class:"scope-legend"},i)}function pvi(t,e,n,o){const i=t.scopeTraceDisplay,r=Vx(t.graph)?"A":"V",s=i&&mZ(i)?gWe(i.valuePerDiv,r):`1 ${r}`,a=gWe(i?.center??0,r),A=WQi(i?.offsetDivs??0),c=`Ch${e+1}`,g=[t.label===c?void 0:t.label,`${s}/div`,A,a].filter(h=>!!h),u=g.length>1?(Yme-Ume-uWe*2-dvi)/(g.length-1):0;return rc("g",{class:"scope-channel",transform:`translate(${ji(n)} ${ji(o)})`,[s0n(t.graph)]:lWe(t.graph)},[rc("rect",{class:"scope-channel-card",x:"0",y:"0",width:ji(fT),height:ji(Yme),rx:"6",ry:"6"}),rc("rect",{x:"0",y:"0",width:ji(fT),height:ji(Ume),rx:"6",ry:"6",fill:t.color}),rc("rect",{x:"0",y:ji(Ume-6),width:ji(fT),height:"6",fill:t.color}),rc("text",{class:"scope-channel-header-text",x:ji(fT/2),y:"14","text-anchor":"middle"},[JB(c)]),...g.map((h,d)=>rc("text",{class:"scope-channel-detail",x:ji(uWe),y:ji(Ume+uWe+d*u),"dominant-baseline":"hanging"},[JB(h)]))])}function mvi(t){const e=Math.ceil(t/2),n=Math.floor(t/2);return{left:p0n(e),right:p0n(n)}}function p0n(t){if(t<=1)return 0;const e=10+(t-1)*cWe+6+KQi+VQi;return Math.max(0,e-dm.left)}function m0n(t){return t.type==="simulation_transient_voltage_graph"||t.type==="simulation_transient_current_graph"||t.type==="simulation_dc_operating_point_voltage"||t.type==="simulation_dc_operating_point_current"||t.type==="simulation_dc_sweep_voltage_graph"||t.type==="simulation_dc_sweep_current_graph"||t.type==="simulation_ac_sweep_voltage_graph"||t.type==="simulation_ac_sweep_current_graph"}function _0n(t){return t?.type==="simulation_experiment"}function _vi(t){return t?.type==="simulation_voltage_probe"}function fvi(t){return t?.type==="simulation_current_probe"}function Ivi(t){return t?.type==="simulation_oscilloscope_trace"}function Cvi(t,e){const n=xvi(t),o=a0n(t),i=Math.min(n.length,o.length),r=[],s=yvi(e);for(let a=0;a<i;a++){const A=Number(n[a]??Number.NaN),c=Number(o[a]??Number.NaN);!Number.isFinite(A)||!Number.isFinite(c)||r.push({timeMs:A,rawValue:c,displayValue:s(c)})}return r}function yvi(t){if(!mZ(t))return i=>i;const e=t.center??0,n=t.offsetDivs??0,o=t.valuePerDiv;return i=>n+(i-e)/o}function xvi(t){const e=a0n(t);if(Array.isArray(t.timestamps_ms)&&t.timestamps_ms.length===e.length)return t.timestamps_ms.map(r=>Number(r));const n=e.length;if(n===0)return[];const o=[];for(let r=0;r<n;r++)o.push(t.start_time_ms+t.time_per_step*r);const i=o.length>0?o[o.length-1]:void 0;return i!==void 0&&Number.isFinite(t.end_time_ms)&&Number.isFinite(i)&&Math.abs(i-t.end_time_ms)>t.time_per_step/2&&o.push(t.end_time_ms),o}function Kme(t,e){const n=t[e];if(typeof n=="string")return n}function Evi(t,e,n,o){const i=Vx(t)?"I":"V";if(n?.displayName)return n.displayName;if(t.simulation_parameter_sweep_coordinate&&t.name)return t.name;if(e?.name)return`${i}(${e.name})`;const r=Kme(t,"source_probe_name");if(r)return`${i}(${r})`;if(t.source_component_id){const s=o.get(t.source_component_id);if(s)return`${i}(${s})`}return t.name?t.name:t.source_component_id?`Probe ${t.source_component_id}`:lWe(t)}function Bvi(t,e,n,o,i,r){if(Vx(t)){const A=o.get(t.simulation_transient_current_graph_id);if(A)return A;const c=Kme(t,"source_probe_id")??(e?.type==="simulation_current_probe"?e.simulation_current_probe_id:void 0);return c?r.get(c):void 0}const s=n.get(t.simulation_transient_voltage_graph_id);if(s)return s;const a=Kme(t,"source_probe_id")??(e?.type==="simulation_voltage_probe"?e.simulation_voltage_probe_id:void 0);return a?i.get(a):void 0}function bvi(t,e,n,o,i){const r=Kme(t,"source_probe_id");if(r){const s=Vx(t)?n.get(r):e.get(r);if(s)return s}if(t.source_component_id)return Vx(t)?i.get(t.source_component_id):o.get(t.source_component_id)}function Svi(t,e){if(e)return{displayName:e.display_name,color:e.color,center:e.display_center_value,offsetDivs:e.display_center_offset_divs,valuePerDiv:Vx(t)?e.amps_per_div:e.volts_per_div}}function Qvi(t,e){const n=Array.isArray(jh.simulation_palette)?jh.simulation_palette:Array.isArray(jh.palette)?jh.palette:[],o=e.filter(_vi),i=e.filter(fvi),r=e.filter(Ivi),s=new Map,a=new Map,A=new Map,c=new Map,l=new Map,g=new Map,u=new Map,h=new Map,d=new Map,p=new Map,m=new Map,_=new Map;for(const f of r)f.simulation_transient_voltage_graph_id&&d.set(f.simulation_transient_voltage_graph_id,f),f.simulation_transient_current_graph_id&&p.set(f.simulation_transient_current_graph_id,f),f.simulation_voltage_probe_id&&m.set(f.simulation_voltage_probe_id,f),f.simulation_current_probe_id&&_.set(f.simulation_current_probe_id,f);for(const f of o)l.set(f.simulation_voltage_probe_id,f),f.name&&f.source_component_id&&s.set(f.source_component_id,f.name),f.color&&f.source_component_id&&a.set(f.source_component_id,f.color),f.source_component_id&&u.set(f.source_component_id,f);for(const f of i)g.set(f.simulation_current_probe_id,f),f.name&&f.source_component_id&&A.set(f.source_component_id,f.name),f.color&&f.source_component_id&&c.set(f.source_component_id,f.color),f.source_component_id&&h.set(f.source_component_id,f);return t.map((f,I)=>{const C=bvi(f,l,g,u,h),y=Bvi(f,C,d,p,m,_),x=Svi(f,y),E=Cvi(f,x),B=vvi(n,I),S=wvi(f,C,Vx(f)?c:a),Q=f.color??x?.color??S??B,w=Evi(f,C,x,Vx(f)?A:s);return{graph:f,points:E,color:Q,label:w,scopeTraceDisplay:x,usesScopeTraceDisplay:mZ(x)}}).filter(f=>f.points.length>0)}function vvi(t,e){return t.length===0?r0n:t[e%t.length]??r0n}function wvi(t,e,n){if(e?.color)return e.color;if(t.source_component_id)return n.get(t.source_component_id)}function f0n({circuitJson:t,simulation_experiment_id:e,simulation_transient_current_graph_ids:n,simulation_transient_voltage_graph_ids:o,simulation_result_ids:i,ac_sweep_view:r="magnitude",width:s=YQi,height:a=UQi,includeVersion:A}){const c=o?new Set(o):null,l=n?new Set(n):null,g=!!(c||l),u=i?new Set(i):null,h=t.find(X=>_0n(X)&&X.simulation_experiment_id===e),d=t.filter(X=>m0n(X)&&X.simulation_experiment_id===e&&(!u||u.has(i0n(X)))&&(!g||X.type==="simulation_transient_voltage_graph"&&(c?.has(X.simulation_transient_voltage_graph_id)??!1)||X.type==="simulation_transient_current_graph"&&(l?.has(X.simulation_transient_current_graph_id)??!1))),p=GQi({results:d,acSweepView:r,experiment:h}),m=p.graphs;if(m.length===0)throw new Error(`No simulation analysis results found for simulation_experiment_id "${e}"`);const _=Qvi(m,t),f=_.flatMap(X=>X.points);if(f.length===0)throw new Error(`Simulation results for simulation_experiment_id "${e}" do not contain any datapoints`);const I=f.map(X=>X.timeMs);let C;p.usesLogarithmicXValues?C=Pvi(I):p.xAxisTitle==="Time (ms)"?C=$Qi({values:I,graphs:m,experiment:h}):C=Ome(I);const y=Ome(f.map(X=>X.displayValue),!0),x=_.some(X=>X.usesScopeTraceDisplay),E=x?mvi(_.length):{left:0,right:0},B=s+E.left+E.right,S=x?h0n(_.length,B):null,Q=S?a+AWe+S.height+AWe:a,w=Math.max(1,s-dm.left-dm.right),M=Math.max(1,a-dm.top-dm.bottom),k=dm.left+E.left,R=g0n(C.domainMin,C.domainMax,k,k+w),F=g0n(y.domainMin,y.domainMax,dm.top+M,dm.top),O=JQi(e),U=tWe(t),Y=nWe,J=avi(h,B),ee=[rvi(),tvi(B,Q),nvi(O,k,w,M),ivi(k,w,M),ovi({timeAxis:C,valueAxis:y,scaleX:R,scaleY:F,plotLeft:k,plotWidth:w,plotHeight:M}),svi(_,O,R,F),qQi({timeAxis:C,valueAxis:y,graphs:_,scaleX:R,scaleY:F,plotLeft:k,plotWidth:w,plotHeight:M,yAxisTitle:p.yAxisTitle??zQi(_),xAxisTitle:p.xAxisTitle,usesScopeTraceDisplay:x}),x?hvi(_,B,a):uvi(_,B),...J?[J]:[]],W=rc("svg",{xmlns:"http://www.w3.org/2000/svg",width:B.toString(),height:Q.toString(),style:`background-color: ${jh.schematic.background}`,viewBox:`0 0 ${ji(B)} ${ji(Q)}`,"data-simulation-experiment-id":e,...h?.name&&{"data-simulation-experiment-name":h.name},...U&&{"data-software-used-string":U},...A&&{"data-circuit-to-svg-version":Y}},ee);return eWe(W)}var Pvi=t=>{const e=Ome(t);return{...e,tickLabelOverrides:new Map(e.ticks.map(n=>[n,ji(10**n)]))}},Mvi=1200,Dvi=1200,I0n=.55;function Nvi({circuitJson:t,simulation_experiment_id:e,simulation_transient_current_graph_ids:n,simulation_transient_voltage_graph_ids:o,simulation_result_ids:i,ac_sweep_view:r,width:s=Mvi,height:a=Dvi,schematicHeightRatio:A=I0n,schematicOptions:c,includeVersion:l,graphAboveSchematic:g=!1,showErrorsInTextOverlay:u}){const h=t.filter(F=>!_0n(F)&&!m0n(F)),d=Tvi(A),p=Math.max(1,a*d),m=Math.max(1,a-p),_=p+m,f=_===0?1:a/_,I=p*f,C=m*f,y=t0n(h,{...c,width:s,height:I,includeVersion:!1,showErrorsInTextOverlay:u}),x=f0n({circuitJson:t,simulation_experiment_id:e,simulation_transient_current_graph_ids:n,simulation_transient_voltage_graph_ids:o,simulation_result_ids:i,ac_sweep_view:r,width:s,height:C,includeVersion:!1}),E=Rln(MV(y)),B=Rln(MV(x)),S=Rvi(B)??{width:s,height:C},Q=S.width>0?s*(S.height/S.width):C,w=I+Q,M=[];g?(M.push(Nme(B,0,0,s,Q)),M.push(Nme(E,0,Q,s,I))):(M.push(Nme(E,0,0,s,I)),M.push(Nme(B,0,I,s,Q)));const k=tWe(h),R={name:"svg",type:"element",value:"",attributes:{xmlns:"http://www.w3.org/2000/svg",width:A4(s),height:A4(w),viewBox:`0 0 ${A4(s)} ${A4(w)}`,"data-simulation-experiment-id":e,...k&&{"data-software-used-string":k},...l&&{"data-circuit-to-svg-version":nWe}},children:M};return eWe(R)}function Rvi(t){const e=t.attributes?.viewBox;if(typeof e!="string")return null;const n=e.trim().split(/[\s,]+/).map(r=>Number.parseFloat(r));if(n.length!==4)return null;const o=n.at(2),i=n.at(3);return!Number.isFinite(o)||!Number.isFinite(i)||o===void 0||i===void 0||o<=0||i<=0?null:{width:o,height:i}}function Tvi(t){return Number.isFinite(t)?t<=0?0:t>=1?1:t:I0n}var C0n=({initialTransform:t,initialTouch1:e,initialTouch2:n,finalTouch1:o,finalTouch2:i})=>{if(!o||!i)return t;const r={x:(e.x+n.x)/2,y:(e.y+n.y)/2},s={x:(o.x+i.x)/2,y:(o.y+i.y)/2},a=Math.hypot(n.x-e.x,n.y-e.y),A=Math.hypot(i.x-o.x,i.y-o.y),c=a===0?1:A/a,l=s.x-r.x,g=s.y-r.y;return dd(hA(l,g),hA(r.x,r.y),uC(c,c),hA(-r.x,-r.y),t)},_Z=(t={})=>{const e=te.useRef(null),[n,o]=te.useState(0),i=t.canvasElm??e.current,[r,s]=te.useState(t.initialTransform??wQ()),[a,A]=te.useState(0),[c,l]=te.useReducer(I=>I+1,0),g=te.useCallback(I=>{t.onSetTransform&&t.onSetTransform(I),t.transform||s(I)},[t.onSetTransform,s]),u=te.useCallback(I=>{g(I),l()},[g]),h=t.transform??r,d=te.useCallback(()=>{o(Date.now())},[]),p=te.useRef("none"),m=te.useRef(null),_=te.useRef(null);te.useEffect(()=>{const I=t.canvasElm??e.current;if(I&&!i){A(a+1);return}if(!I){const U=setTimeout(()=>{A(a+1)},100);return()=>clearTimeout(U)}let C=t.transform??r,y={x:0,y:0},x={x:0,y:0},E=!1;const B=U=>({x:U.pageX-I.getBoundingClientRect().left-window.scrollX,y:U.pageY-I.getBoundingClientRect().top-window.scrollY});function S(U){t.enabled!==!1&&(t.shouldDrag&&!t.shouldDrag(U)||(y=B(U),!(Date.now()-n<100)&&(E=!0,U.preventDefault())))}function Q(U){if(!E||t.enabled===!1||t.shouldDrag&&!t.shouldDrag(U))return;x=B(U);const Y=dd(hA(x.x-y.x,x.y-y.y),C);g(Y),C=Y,E=!1}function w(U){if(B(U),!E||t.enabled===!1||t.shouldDrag&&!t.shouldDrag(U))return;x=B(U);const Y=dd(hA(x.x-y.x,x.y-y.y),C);g(Y)}function M(U){if(t.enabled===!1||t.shouldDrag&&!t.shouldDrag(U))return;const Y=B(U),J=dd(hA(Y.x,Y.y),uC(1-U.deltaY/1e3,1-U.deltaY/1e3),hA(-Y.x,-Y.y),C);g(J),C=J,U.preventDefault()}function k(U){if(!E||t.shouldDrag&&!t.shouldDrag(U))return;if(I){const J=I.getBoundingClientRect();if(U.clientX>=J.left+10&&U.clientX<=J.right-10&&U.clientY>=J.top+10&&U.clientY<=J.bottom-10)return}E=!1,x=B(U);const Y=dd(hA(x.x-y.x,x.y-y.y),C);g(Y),C=Y}function R(U){if(U.preventDefault(),t.enabled!==!1){if(U.touches.length===1){p.current="drag";const Y=U.touches[0];m.current={initialTransform:C,initialTouch:{x:Y.clientX,y:Y.clientY}}}else if(U.touches.length===2){p.current="pinch";const Y=U.touches[0],J=U.touches[1];_.current={initialTransform:C,initialTouch1:{x:Y.clientX,y:Y.clientY},initialTouch2:{x:J.clientX,y:J.clientY},finalTouch1:null,finalTouch2:null}}}}function F(U){if(U.preventDefault(),t.enabled!==!1){if(p.current==="drag"&&U.touches.length===1&&m.current){const Y=U.touches[0],J={x:Y.clientX,y:Y.clientY},ee=J.x-m.current.initialTouch.x,W=J.y-m.current.initialTouch.y,X=dd(hA(ee,W),m.current.initialTransform);g(X)}else if(p.current==="pinch"&&U.touches.length===2&&_.current){const Y=U.touches[0],J=U.touches[1];_.current.finalTouch1={x:Y.clientX,y:Y.clientY},_.current.finalTouch2={x:J.clientX,y:J.clientY};const ee=C0n(_.current);g(ee)}}}function O(U){U.preventDefault();const Y=U.changedTouches[0];if(p.current==="drag"&&m.current&&Y){const J={x:Y.clientX,y:Y.clientY},ee=J.x-m.current.initialTouch.x,W=J.y-m.current.initialTouch.y,X=dd(hA(ee,W),m.current.initialTransform);g(X),C=X}else if(p.current==="pinch"&&_.current){const J=C0n(_.current);g(J),C=J}p.current="none",m.current=null,_.current=null}return I.addEventListener("mousedown",S),I.addEventListener("mouseup",Q),window.addEventListener("mousemove",w),I.addEventListener("mouseout",k),I.addEventListener("wheel",M),I.addEventListener("touchstart",R,{passive:!1}),I.addEventListener("touchmove",F,{passive:!1}),I.addEventListener("touchend",O,{passive:!1}),I.addEventListener("touchcancel",O,{passive:!1}),()=>{I.removeEventListener("mousedown",S),I.removeEventListener("mouseup",Q),window.removeEventListener("mousemove",w),I.removeEventListener("mouseout",k),I.removeEventListener("wheel",M),I.removeEventListener("touchstart",R),I.removeEventListener("touchmove",F),I.removeEventListener("touchend",O),I.removeEventListener("touchcancel",O)}},[i,a,c,n,t.enabled,t.shouldDrag]);const f=te.useCallback(I=>Bn(h,I),[h]);return{ref:e,transform:h,applyTransformToPoint:f,setTransform:u,cancelDrag:d}},y0n=_Z;function dWe(t){const e=V3(t),n=new Map;for(const s of e.schematic_component.list())s.source_component_id&&n.set(s.source_component_id,s.schematic_component_id);const o=new Map;for(const s of e.source_trace.list()){const a=s.subcircuit_connectivity_map_key;if(a)for(const A of s.connected_source_port_ids??[]){const c=n.get(e.source_port.get(A)?.source_component_id??"");c&&(o.has(c)||o.set(c,new Set),o.get(c).add(a))}}const i=new Map;for(const s of e.schematic_net_label.list()){if(!s.source_net_id)continue;const a=e.source_net.get(s.source_net_id)?.subcircuit_connectivity_map_key??s.source_net_id;i.set(s.schematic_net_label_id,a)}const r=new Map;for(const s of e.schematic_text.list()){if(!s.source_trace_id)continue;const a=e.source_trace.get(s.source_trace_id)?.subcircuit_connectivity_map_key;a&&r.set(s.schematic_text_id,a)}return{componentIdToKeys:o,netLabelIdToKey:i,textIdToKey:r}}var Vme=(t,e)=>Math.hypot(t.x-e.x,t.y-e.y),x0n=(t,e,n)=>{const o=n.x-e.x,i=n.y-e.y,r=o*o+i*i,s=r?Math.max(0,Math.min(1,((t.x-e.x)*o+(t.y-e.y)*i)/r)):0;return Vme(t,{x:e.x+s*o,y:e.y+s*i})},IT=(t,e,n)=>Math.abs(Vme(e,t)+Vme(t,n)-Vme(e,n))<1e-5;function kvi(t,e){const n=dWe(e),o=t?.closest("[data-subcircuit-connectivity-map-key], [data-schematic-net-label-id], [data-schematic-text-id], [data-schematic-trace-id]");if(!o)return;const i=e.find(r=>r.type==="schematic_trace"&&r.schematic_trace_id===o.getAttribute("data-schematic-trace-id"));return o.getAttribute("data-subcircuit-connectivity-map-key")||n.netLabelIdToKey.get(o.getAttribute("data-schematic-net-label-id"))||n.textIdToKey.get(o.getAttribute("data-schematic-text-id"))||(i?.type==="schematic_trace"?i.subcircuit_connectivity_map_key||e.filter(r=>r.type==="source_trace").find(r=>r.source_trace_id===i.source_trace_id)?.subcircuit_connectivity_map_key:void 0)}function Fvi(t,e){const n=dWe(t),o=t.filter(g=>g.type==="source_trace"),i=t.filter(g=>g.type==="schematic_trace"),r=t.filter(g=>g.type==="schematic_sheet"),s=r[0]?.schematic_sheet_id,a=[];for(const g of i)if((g.subcircuit_connectivity_map_key??o.find(h=>h.source_trace_id===g.source_trace_id)?.subcircuit_connectivity_map_key)===e)for(const h of g.edges)a.push({a:h.from,b:h.to,sheet:g.schematic_sheet_id??s,target:{type:"schematic_trace",id:g.schematic_trace_id},sourceTraceId:g.source_trace_id,portIds:[h.from_schematic_port_id,h.to_schematic_port_id].filter(d=>!!d),junctions:g.junctions});for(const g of t)if(g.type==="schematic_net_label"&&n.netLabelIdToKey.get(g.schematic_net_label_id)===e){const u=g.anchor_position??g.center;a.push({a:u,b:u,sheet:g.schematic_sheet_id??s,target:{type:"schematic_net_label",id:g.schematic_net_label_id},name:g.text})}for(const g of t){if(g.type!=="schematic_text"||n.textIdToKey.get(g.schematic_text_id)!==e)continue;const u=g.schematic_sheet_id??s,d=a.filter(p=>p.sheet===u&&p.sourceTraceId===g.source_trace_id).sort((p,m)=>x0n(g.position,p.a,p.b)-x0n(g.position,m.a,m.b))[0]?.a??g.position;a.push({a:d,b:d,sheet:u,target:{type:"schematic_text",id:g.schematic_text_id},name:g.text})}const A=a.map((g,u)=>u),c=g=>A[g]===g?g:A[g]=c(A[g]);for(let g=0;g<a.length;g++)for(let u=0;u<g;u++){const h=a[g],d=a[u];h.sheet===d.sheet&&(IT(h.a,d.a,d.b)||IT(h.b,d.a,d.b)||IT(d.a,h.a,h.b)||IT(d.b,h.a,h.b)||[...h.junctions??[],...d.junctions??[]].some(p=>IT(p,h.a,h.b)&&IT(p,d.a,d.b)))&&(A[c(g)]=c(u))}const l=new Map;return a.forEach((g,u)=>l.set(c(u),[...l.get(c(u))??[],g])),[...l.values()].map((g,u)=>{const h=g.find(f=>f.target.type!=="schematic_trace")??g[0],p=t.filter(f=>f.type==="schematic_port").filter(f=>(f.schematic_sheet_id??s)===h.sheet&&g.some(I=>I.portIds?.includes(f.schematic_port_id)||IT(f.center,I.a,I.b))).map(f=>{const I=t.find(y=>y.type==="source_port"&&y.source_port_id===f.source_port_id);if(I?.type!=="source_port")return;const C=t.find(y=>y.type==="source_component"&&y.source_component_id===I.source_component_id);return C?.type==="source_component"?`${C.name}.${I.name??`pin${I.pin_number}`}`:void 0}).filter(f=>!!f).sort(),m=r.findIndex(f=>f.schematic_sheet_id===h.sheet);return{kind:"net",label:`${r[m]?.name??`Sheet ${Math.max(0,m)+1}`}: ${p[0]??h.name??`Location ${u+1}`}`,schematicSheetId:h.sheet,target:h.target,focusPoint:{x:(h.a.x+h.b.x)/2,y:(h.a.y+h.b.y)/2}}})}var Lvi="https://jscdn.tscircuit.com/@tscircuit/circuit-json-schematic-placement-analysis/latest/dist/browser.js",Hvi={async load(){const t=await import(Lvi);if(typeof t.createSchematicPlacementIssueArtifacts!="function")throw new Error("The style analyzer module does not export its analysis function.");return t}},CE={contextMenu:110,styleAnalysis:120,viewMenu:55,viewMenuIcon:48,clickToInteractOverlay:100,schematicComponentDetailsTooltip:105,schematicComponentHoverOutline:47,schematicPortHoverOutline:48,schematicSearch:101},Ovi=({circuitJson:t,onClose:e})=>{const[n,o]=te.useState({status:"loading"});return te.useEffect(()=>{let i=!1;const r=window.setTimeout(async()=>{try{const{createSchematicPlacementIssueArtifacts:s}=await Hvi.load();if(i)return;const a=s(t);i||o({status:"complete",artifacts:a})}catch(s){i||o({status:"error",message:s instanceof Error?s.message:String(s)})}},0);return()=>{i=!0,window.clearTimeout(r)}},[t]),V.jsx(zJe,{open:!0,onOpenChange:i=>!i&&e(),children:V.jsxs(JJe,{children:[V.jsx(xme,{style:{position:"fixed",inset:0,background:"#0008",zIndex:CE.styleAnalysis}}),V.jsxs(Eme,{style:{position:"fixed",top:"5vh",left:"50%",transform:"translateX(-50%)",width:"min(1000px, 94vw)",maxHeight:"90vh",overflowY:"auto",boxSizing:"border-box",padding:24,borderRadius:12,background:"#fafafa",color:"#171717",fontFamily:"system-ui, sans-serif",boxShadow:"0 20px 60px #0005",zIndex:CE.styleAnalysis},children:[V.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16},children:[V.jsx(Bme,{style:{margin:0,fontSize:22},children:"Style Analysis"}),V.jsx(jJe,{style:{cursor:"pointer",padding:"6px 12px"},children:"Close"})]}),V.jsx(bme,{style:{color:"#525252"},children:"Placement and style issues across all schematic sheets. Each image highlights one issue with its description below."}),n.status==="loading"&&V.jsx("p",{role:"status",children:"Running style analysis…"}),n.status==="error"&&V.jsxs("p",{role:"alert",children:["Style analysis failed: ",n.message]}),n.status==="complete"&&V.jsxs(V.Fragment,{children:[V.jsx("p",{role:"status",children:n.artifacts.length===0?"No style issues found.":`${n.artifacts.length} style ${n.artifacts.length===1?"issue":"issues"} found.`}),n.artifacts.map(i=>V.jsxs("section",{style:{marginTop:24,border:"1px solid #ddd",borderRadius:8,overflow:"hidden",background:"white"},children:[V.jsxs("h3",{style:{margin:16,fontSize:16},children:[i.issueIndex+1,"."," ",i.issue.lineItemType.replace(/([a-z])([A-Z])/g,"$1 $2"),i.schematicSheetId&&V.jsxs("small",{style:{display:"block",marginTop:4,color:"#525252"},children:["Sheet: ",i.schematicSheetId]})]}),V.jsx("img",{src:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i.content)}`,alt:i.descriptionXml,loading:"lazy",style:{display:"block",width:"100%",height:"auto"}})]},i.issueIndex))]})]})]})})},mU={IS_SHOWING_SCHEMATIC_GROUPS:"schematic_viewer_show_groups",IS_SHOWING_SCHEMATIC_PORTS:"schematic_viewer_show_ports",SELECTED_SCHEMATIC_SHEET:"schematic_viewer_selected_sheet"},E0n=(t,e)=>{if(typeof window>"u")return e;try{const n=localStorage.getItem(t);return n!==null?JSON.parse(n):e}catch{return e}},B0n=(t,e)=>{if(!(typeof window>"u"))try{localStorage.setItem(t,JSON.stringify(e))}catch{}},Gvi=t=>{if(typeof window>"u")return null;try{return localStorage.getItem(t)}catch{return null}},Yvi=(t,e)=>{if(!(typeof window>"u"))try{localStorage.setItem(t,e)}catch{}},b0n=["#8B0000","#2F4F4F","#191970","#006400","#FF4500","#800080","#2E8B57","#B8860B","#C71585","#008B8B"],Uvi=t=>{const{svgDivRef:e,circuitJson:n,circuitJsonKey:o,showGroups:i}=t;te.useEffect(()=>{if(e.current&&e.current.querySelectorAll(".schematic-group-overlay").forEach(a=>a.remove()),!e.current||!i||!n||n.length===0)return;const r=setTimeout(()=>{if(!e.current)return;const s=e.current.querySelector("svg");if(!s)return;s.querySelectorAll(".schematic-group-overlay").forEach(A=>A.remove());try{const A=V3(n).source_group?.list().filter(f=>!f.is_subcircuit)||[],c=V3(n).schematic_component?.list()||[],l=new Map;A.forEach(f=>{const I=f;if(I.parent_source_group_id){const C=l.get(I.parent_source_group_id)||[];C.push(f.source_group_id),l.set(I.parent_source_group_id,C)}});const g=f=>{const I=[],C=l.get(f)||[];for(const y of C)I.push(y),I.push(...g(y));return I},u=f=>{const I=A.find(C=>C.source_group_id===f);return I?.parent_source_group_id?1+u(I.parent_source_group_id):0},h=A.length>0&&A.some(f=>f.name&&f.name.trim()!=="");let d=[];if(h){const f=new Map;for(const I of c){const C=V3(n).source_component.get(I.source_component_id);C?.source_group_id&&(f.has(C.source_group_id)||f.set(C.source_group_id,[]),f.get(C.source_group_id).push(I))}A.forEach((I,C)=>{let y=f.get(I.source_group_id)||[];const x=g(I.source_group_id);for(const E of x){const B=f.get(E)||[];y=[...y,...B]}if(y.length>0){const E=u(I.source_group_id),B=g(I.source_group_id).length>0;if(I.name?.startsWith("unnamed_board"))return;d.push({id:I.source_group_id,name:I.name||`Group ${C+1}`,components:y,color:b0n[C%b0n.length],depthLevel:E,hasChildren:B,sourceGroupId:I.source_group_id})}})}const p=s.viewBox.baseVal,m=s.getBoundingClientRect(),_=Math.min(m.width/p.width,m.height/p.height)||1;d.sort((f,I)=>f.depthLevel-I.depthLevel),d.forEach(f=>{if(f.components.length===0)return;const I=Kvi(f.components,s);if(!I)return;const C=Math.max(8,Math.min(25,15/Math.max(_,.3))),y=f.hasChildren?C*.6:0,x=C+y,E=Math.max(1,2/Math.max(_,.5)),B=f.depthLevel===0?E:E*.7,S=Math.max(4,8/Math.max(_,.5)),Q=f.hasChildren?1.3:1,w=S*Q,M=w*.5,k=document.createElementNS("http://www.w3.org/2000/svg","rect");k.setAttribute("class","schematic-group-overlay"),k.setAttribute("x",(I.minX-x).toString()),k.setAttribute("y",(I.minY-x).toString()),k.setAttribute("width",(I.maxX-I.minX+x*2).toString()),k.setAttribute("height",(I.maxY-I.minY+x*2).toString()),k.setAttribute("fill","none"),k.setAttribute("stroke",f.color),k.setAttribute("stroke-width",B.toString()),k.setAttribute("stroke-dasharray",`${w},${M}`),k.setAttribute("opacity","0.8"),k.setAttribute("rx","0"),k.setAttribute("ry","0");const R=Math.max(6,Math.min(20,14/Math.max(_,.2))),F=f.depthLevel===0||f.depthLevel===1?0:f.depthLevel*.2,O=R*(1-F),U=Math.max(1,O*.2),Y=f.name,J=document.createElementNS("http://www.w3.org/2000/svg","text");J.setAttribute("font-size",O.toString()),J.setAttribute("font-family","Arial, sans-serif"),J.textContent=Y,s.appendChild(J);const ee=J.getBBox();s.removeChild(J);const W=ee.width+U*2,X=O+U*2,oe=I.minX-x,se=I.minY-x-X,ie=document.createElementNS("http://www.w3.org/2000/svg","rect");ie.setAttribute("class","schematic-group-overlay"),ie.setAttribute("x",oe.toString()),ie.setAttribute("y",(se-X).toString()),ie.setAttribute("width",W.toString()),ie.setAttribute("height",X.toString()),ie.setAttribute("fill","transparent"),ie.setAttribute("rx","0"),ie.setAttribute("ry","0");const ge=document.createElementNS("http://www.w3.org/2000/svg","text");ge.setAttribute("class","schematic-group-overlay"),ge.setAttribute("x",(oe+U).toString()),ge.setAttribute("y",(se+X-U).toString()),ge.setAttribute("fill",f.color),ge.setAttribute("font-size",O.toString()),ge.setAttribute("font-family","Arial, sans-serif"),ge.setAttribute("font-weight",f.depthLevel===0?"600":"500"),ge.setAttribute("stroke",f.color),ge.setAttribute("stroke-width",Math.max(.2,O*.02).toString()),ge.textContent=Y,s.appendChild(k),s.appendChild(ie),s.appendChild(ge)})}catch(A){console.error("Error creating group overlays:",A)}},10);return()=>clearTimeout(r)},[e,o,i])};function Kvi(t,e){let n=1/0,o=1/0,i=-1/0,r=-1/0;for(const a of t){let A=e.querySelector(`g[data-schematic-component-id="${a.schematic_component_id}"]`);if(A||(A=e.querySelector(`[data-schematic-component-id="${a.schematic_component_id}"]`)),A){const c=A.getBBox();n=Math.min(n,c.x),o=Math.min(o,c.y),i=Math.max(i,c.x+c.width),r=Math.max(r,c.y+c.height)}}return n===1/0?null:{minX:n,minY:o,maxX:i,maxY:r}}var hWe="sch-net-faded",S0n="g.trace[data-subcircuit-connectivity-map-key], g.trace-overlays[data-subcircuit-connectivity-map-key]",pWe="[data-schematic-net-label-id], [data-schematic-text-id]",Vvi=({svgDivRef:t,circuitJson:e,circuitJsonKey:n,enabled:o})=>{te.useEffect(()=>{const i=t.current;if(!o||!i)return;const{componentIdToKeys:r,netLabelIdToKey:s,textIdToKey:a}=dWe(e);let A=[];const c=new Map;let l=null;const g=()=>{for(const{el:_}of A)_.classList.remove(hWe);A=[],c.clear(),l=null;const m=i.querySelector("svg");if(m){for(const _ of Array.from(m.querySelectorAll(S0n))){const f=_.getAttribute("data-subcircuit-connectivity-map-key"),I=new Set;f&&(I.add(f),c.set(_,f)),A.push({el:_,keys:I})}for(const _ of Array.from(m.querySelectorAll("g[data-schematic-component-id]"))){const f=_.getAttribute("data-schematic-component-id");A.push({el:_,keys:r.get(f)??new Set})}for(const _ of Array.from(m.querySelectorAll(pWe))){const f=s.get(_.getAttribute("data-schematic-net-label-id"))??a.get(_.getAttribute("data-schematic-text-id")),I=new Set;f&&(I.add(f),c.set(_,f)),A.push({el:_,keys:I})}}},u=m=>{if(m!==l){l=m;for(const{el:_,keys:f}of A)_.classList.toggle(hWe,m!==null&&!f.has(m))}},h=m=>{const _=m.target;if(!(_ instanceof Element)){u(null);return}const f=_.closest(`${S0n}, ${pWe}`);if(f&&c.has(f)){u(c.get(f));return}for(const[I,C]of c){if(!I.matches(pWe))continue;const y=I.getBoundingClientRect();if(m.clientX>=y.left-6&&m.clientX<=y.right+6&&m.clientY>=y.top-6&&m.clientY<=y.bottom+6){u(C);return}}u(null)},d=()=>u(null);g(),i.addEventListener("mousemove",h),i.addEventListener("mouseleave",d);const p=new MutationObserver(g);return p.observe(i,{childList:!0}),()=>{p.disconnect(),i.removeEventListener("mousemove",h),i.removeEventListener("mouseleave",d);for(const{el:m}of A)m.classList.remove(hWe)}},[t,n,o])},mWe="http://www.w3.org/2000/svg",zvi=({svgDivRef:t,svgContent:e,circuitJsonKey:n})=>{const o=te.useRef(new Set);te.useLayoutEffect(()=>{o.current.clear()},[n]),te.useLayoutEffect(()=>{const i=[];for(const r of t.current?.querySelectorAll(".schematic-warning")??[]){const s=r.getAttribute("data-warning-id"),a=r.querySelector('[data-warning-reference="callout"]');if(!s||!a)continue;const A=Array.from(r.children),c=A.map(I=>I.style.display),l=r.getAttribute("role"),g=r.getAttribute("aria-label")??"Warning",u=document.createElementNS(mWe,"g");u.setAttribute("data-warning-icon",""),u.setAttribute("aria-hidden","true"),u.setAttribute("transform",`translate(${a.getAttribute("x")} ${a.getAttribute("y")})`);const h=document.createElementNS(mWe,"rect");h.setAttribute("width","24"),h.setAttribute("height","24"),h.setAttribute("fill",a.getAttribute("fill")??"#fffaeb"),h.setAttribute("stroke",a.getAttribute("stroke")??"#d99a00"),h.setAttribute("stroke-width","1");const d=document.createElementNS(mWe,"text");d.setAttribute("x","12"),d.setAttribute("y","12"),d.setAttribute("dominant-baseline","central"),d.setAttribute("text-anchor","middle"),d.setAttribute("font-size","16"),d.setAttribute("font-family","sans-serif"),d.setAttribute("font-weight","bold"),d.setAttribute("fill","#5c4300"),d.textContent="!",u.append(h,d),r.append(u),r.setAttribute("role","button"),r.setAttribute("tabindex","0"),r.style.cursor="pointer",r.style.outline="none";const p=()=>{const I=o.current.has(s);A.forEach((C,y)=>{C.style.display=I?"none":c[y]}),u.style.display=I?"":"none",r.setAttribute("aria-expanded",String(!I)),r.setAttribute("aria-label",`${I?"Expand":"Minimize"} warning: ${g}`)},m=I=>{I.preventDefault(),I.stopPropagation(),o.current.has(s)?o.current.delete(s):o.current.add(s),p()},_=I=>{(I.key==="Enter"||I.key===" ")&&(I.repeat?I.preventDefault():m(I))},f=I=>I.stopPropagation();r.addEventListener("click",m),r.addEventListener("keydown",_),r.addEventListener("mousedown",f),r.addEventListener("touchstart",f),p(),i.push(()=>{r.removeEventListener("click",m),r.removeEventListener("keydown",_),r.removeEventListener("mousedown",f),r.removeEventListener("touchstart",f),u.remove(),A.forEach((I,C)=>{I.style.display=c[C]}),l?r.setAttribute("role",l):r.removeAttribute("role"),r.setAttribute("aria-label",g),r.removeAttribute("aria-expanded"),r.removeAttribute("tabindex"),r.style.removeProperty("cursor"),r.style.removeProperty("outline")})}return()=>i.forEach(r=>r())},[t,e,n])},_We=t=>String(t??"").toLocaleLowerCase(),fZ=(t,e)=>{const n=_We(t);return n===e?0:n.startsWith(e)?1:n.includes(e)?2:Number.POSITIVE_INFINITY},Jvi=t=>{if(t)return String(t).replace(/^simple_/,"").replaceAll("_"," ").replace(/\b\w/g,e=>e.toLocaleUpperCase())},Wvi=(t,e,n)=>{let i=Jvi(t?.ftype);t?.ftype==="simple_chip"&&t.manufacturer_part_number&&(i=t.manufacturer_part_number);const r=[];t?.display_name===n&&t.name!==n&&r.push(t.name);let s=t?.display_value;if(!s&&t){for(const a of["display_resistance","display_capacitance","display_inductance","display_frequency","symbol_display_value"])if(a in t){const A=t[a];if(typeof A=="string"){s=A;break}}}if(s??(s=e.symbol_display_value),i&&r.push(i),s&&r.push(s),!i&&!s&&t?.manufacturer_part_number&&r.push(t.manufacturer_part_number),r.length!==0)return r.join(" · ")},jvi=t=>t.type==="source_component"&&"source_component_id"in t,Xvi=t=>t.type==="source_port",qvi=t=>t.type==="source_trace",$vi=t=>t.type==="schematic_component",Zvi=t=>t.type==="schematic_port",ewi=t=>t.type==="schematic_net_label",twi=t=>t.type==="schematic_sheet",fWe=({schematicSheets:t,schematicSheetId:e})=>{if(!(t.length<=1||!e))return t.find(n=>n.schematic_sheet_id===e)?.name},nwi=(t,e)=>{const n=_We(e).trim();if(!n)return[];const o=new Map(t.filter(jvi).map(l=>[l.source_component_id,l])),i=new Map(t.filter(Xvi).map(l=>[l.source_port_id,l])),r=t.filter(Zvi),s=t.filter(qvi),a=t.filter(twi),A=[],c=new Map;for(const l of t.filter($vi)){const g=l.source_component_id?o.get(l.source_component_id):void 0,u=g?.display_name??g?.name??"Component",h=Math.min(fZ(g?.name,n),fZ(g?.display_name,n),fZ(g?.manufacturer_part_number,n));if(Number.isFinite(h)){const d={label:u,detail:Wvi(g,l,u),kind:"component",schematicSheetId:l.schematic_sheet_id,schematicSheetName:fWe({schematicSheets:a,schematicSheetId:l.schematic_sheet_id}),target:{type:"schematic_component",id:l.schematic_component_id}};A.push(d),c.set(d,h)}}for(const l of t.filter(ewi)){if(!_We(l.text).includes(n))continue;const g=new Set;for(const I of s.filter(C=>C.connected_source_net_ids.includes(l.source_net_id)))for(const C of I.connected_source_port_ids)g.add(C);const u=l.anchor_position??l.center,h=r.filter(I=>g.has(I.source_port_id)&&(!l.schematic_sheet_id||!I.schematic_sheet_id||I.schematic_sheet_id===l.schematic_sheet_id)).map(I=>({port:I,distance:Math.hypot(I.center.x-u.x,I.center.y-u.y)})).filter(({distance:I})=>I<=1).sort((I,C)=>I.distance-C.distance)[0]?.port,d=h?i.get(h.source_port_id):void 0,p=d?.source_component_id?o.get(d.source_component_id):void 0,m=d?.name??(d?.pin_number!==void 0?`pin${d.pin_number}`:h?.display_pin_label),_=p?.name&&m?`Connected to ${p.name}.${m}`:void 0,f={label:l.text,detail:_,kind:"net",schematicSheetId:l.schematic_sheet_id,schematicSheetName:fWe({schematicSheets:a,schematicSheetId:l.schematic_sheet_id}),target:{type:"schematic_net_label",id:l.schematic_net_label_id}};A.push(f),c.set(f,fZ(l.text,n))}for(const l of t){if(l.type!=="schematic_text"||!l.source_trace_id)continue;const g=fZ(l.text,n);if(!Number.isFinite(g))continue;const u={label:l.text,kind:"net",schematicSheetId:l.schematic_sheet_id,schematicSheetName:fWe({schematicSheets:a,schematicSheetId:l.schematic_sheet_id}),target:{type:"schematic_text",id:l.schematic_text_id}};A.push(u),c.set(u,g)}return A.sort((l,g)=>(c.get(l)??Number.POSITIVE_INFINITY)-(c.get(g)??Number.POSITIVE_INFINITY)||l.label.localeCompare(g.label))},owi=({containerRect:t,targetRect:e,visibleProjection:n,minimumScale:o})=>{const i=n.a||1,r={x:e.left+e.width/2-t.left,y:e.top+e.height/2-t.top},s={x:(r.x-n.e)/i,y:(r.y-n.f)/i},a=Math.max(i,o);return{a,b:0,c:0,d:a,e:t.width/2-s.x*a,f:t.height/2-s.y*a}},iwi=1.8,Q0n=350,rwi=({controller:t,circuitJson:e,circuitJsonKey:n,svgDivRef:o,containerRef:i,activeSheetId:r,hasMultipleSheets:s,handleSelectSheet:a,svgString:A,svgToScreenProjection:c,setSvgToScreenProjection:l,setIsInteractionEnabled:g})=>{const[u,h]=te.useState(""),[d,p]=te.useState(null),m=te.useRef(null),_=te.useMemo(()=>nwi(e,u),[e,n,u]),f=te.useCallback(E=>{const B=o.current,S=i.current;if(!B||!S)return!1;const Q=`data-${E.target.type.replaceAll("_","-")}-id`,w=Array.from(B.querySelectorAll(`[${Q}]`)).find(O=>O.getAttribute(Q)===E.target.id);if(!w)return!1;let M=w.getBoundingClientRect();if(E.focusPoint){const O=w.closest("svg"),U=O?.getAttribute("data-real-to-screen-transform"),Y=O?.getScreenCTM?.();if(U&&Y){const J=Bn(Y,Bn(zV(U),E.focusPoint));M={left:J.x-1,top:J.y-1,width:2,height:2}}}const k=S.getBoundingClientRect();if(!k.width||!k.height||!M.width&&!M.height)return!1;m.current&&clearTimeout(m.current);let R=c;const F=getComputedStyle(B).transform;if(F&&F!=="none")try{R=zV(F),B.style.transition="none",B.style.transform=F,B.offsetWidth}catch{}return B.style.transition=`transform ${Q0n}ms ease-in-out`,B.offsetWidth,l(owi({containerRect:k,targetRect:M,visibleProjection:R,minimumScale:iwi})),m.current=setTimeout(()=>{B.style.transition=""},Q0n),B.querySelectorAll(".schematic-search-match").forEach(O=>O.classList.remove("schematic-search-match")),B.querySelectorAll(`[${Q}]`).forEach(O=>{O.getAttribute(Q)===E.target.id&&O.classList.add("schematic-search-match")}),!0},[i,l,o,c]),I=te.useCallback(E=>{if(g(!0),E.schematicSheetId&&E.schematicSheetId!==r&&s){a(E.schematicSheetId),p(E);return}f(E)},[r,f,a,s,g]),C=te.useCallback(()=>{h(""),p(null),m.current&&(clearTimeout(m.current),m.current=null),o.current&&(o.current.style.transition="",o.current.querySelectorAll(".schematic-search-match").forEach(E=>E.classList.remove("schematic-search-match")))},[o]),y=t?.focusRequest,x=t?.onFocusRequestHandled;return te.useEffect(()=>{if(!y)return;const E=e.find(B=>B.type==="schematic_component"&&B.schematic_component_id===y.schematicComponentId);if(E?.type!=="schematic_component"){p(null),x?.(y);return}g(!0),E.schematic_sheet_id&&s&&a(E.schematic_sheet_id),p({kind:"component",label:E.schematic_component_id,schematicSheetId:E.schematic_sheet_id,target:{type:"schematic_component",id:E.schematic_component_id}})},[y,x,e,n,s,a,g]),te.useEffect(()=>{if(!d||!A||s&&d.schematicSheetId&&d.schematicSheetId!==r)return;const E=requestAnimationFrame(()=>{f(d)&&(p(null),y?.schematicComponentId===d.target.id&&x?.(y))});return()=>cancelAnimationFrame(E)},[f,y,x,d,A,s,r]),te.useEffect(()=>{u||o.current?.querySelectorAll(".schematic-search-match").forEach(E=>E.classList.remove("schematic-search-match"))},[u,o]),te.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),{searchQuery:u,setSearchQuery:h,searchResults:_,handleSearchResultSelect:I,handleCancelSearch:C}};g0("schematic-viewer");var swi=()=>{g0.enable("schematic-viewer*")},v0n=t=>{const[e,n]=te.useState(0),[o,i]=te.useState(0);return te.useEffect(()=>{if(!t.current)return;const r=()=>{const a=t.current?.getBoundingClientRect();n(a?.width||0),i(a?.height||0)};r();const s=new ResizeObserver(r);return s.observe(t.current),window.addEventListener("resize",r),()=>{s.disconnect(),window.removeEventListener("resize",r)}},[]),{containerWidth:e,containerHeight:o}},awi=600,zme=10,Awi=({containerRef:t})=>{const[e,n]=te.useState(null),[o,i]=te.useState(!1),[r,s]=te.useState({x:0,y:0}),a=te.useRef(null),A=te.useRef(null),c=te.useRef(null),l=te.useRef(0),g=te.useCallback(()=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null)},[]),u=te.useCallback(_=>{if(_.preventDefault(),Date.now()<l.current)return;const f=A.current;if(!f)return;const I=Math.abs(_.clientX-f.x)>zme||Math.abs(_.clientY-f.y)>zme;A.current=null,!I&&(n(_.target instanceof Element?_.target:null),s({x:_.clientX,y:_.clientY}),i(!0))},[]),h=te.useCallback(_=>{if(g(),_.touches.length!==1){A.current=null;return}const f=_.touches[0];if(!f)return;const I=_.target instanceof Element?_.target:null;A.current={x:f.clientX,y:f.clientY},c.current=window.setTimeout(()=>{const C=t.current;if(!C||!A.current)return;n(I);const y=C.getBoundingClientRect();s({x:y.left+y.width/2,y:y.top+y.height/2}),i(!0),l.current=Date.now()+1e3,A.current=null},awi)},[g,t]),d=te.useCallback(_=>{const f=A.current;if(!f||_.touches.length!==1)return;const I=_.touches[0];(!I||Math.abs(I.clientX-f.x)>zme||Math.abs(I.clientY-f.y)>zme)&&(A.current=null,g())},[g]),p=te.useCallback(()=>{g(),A.current=null},[g]),m=te.useCallback(_=>{const f=_.target;a.current?.contains(f)||f.closest?.("[data-radix-popper-content-wrapper], [data-radix-dropdown-menu-content]")||i(!1)},[]);return te.useEffect(()=>{if(o)return document.addEventListener("mousedown",m),document.addEventListener("touchstart",m),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("touchstart",m)}},[m,o]),te.useEffect(()=>g,[g]),{menuVisible:o,menuTarget:e,menuPos:r,menuRef:a,setMenuVisible:i,contextMenuEventHandlers:{onMouseDown:_=>{A.current=_.button===2||_.button===0&&_.ctrlKey?{x:_.clientX,y:_.clientY}:null},onContextMenu:u,onTouchStart:h,onTouchMove:d,onTouchEnd:p,onTouchCancel:p}}},cwi=(t,e,n)=>t.filter(o=>{if(!o.type.endsWith("_warning"))return!1;const i=o;return[["source_component",e.source_component_id],["schematic_component",e.schematic_component_id],["pcb_component",n?.pcb_component_id]].some(([s,a])=>{if(!a)return!1;const A=i[`${s}_ids`];return i[`${s}_id`]===a||Array.isArray(A)&&A.includes(a)||i.schematic_element_type===s&&i.schematic_element_id===a})}),lwi=new Set(["type","source_component_id","source_group_id","subcircuit_id","display_name","ftype","are_pins_interchangeable","supplier_part_numbers"]),w0n=["name","resistance","capacitance","inductance","frequency","voltage","current","max_voltage_rating","max_current_rating","power_rating","manufacturer_part_number"],gwi={jlcpcb:t=>`https://jlcpcb.com/partdetail/${encodeURIComponent(t)}`,lcsc:t=>`https://www.lcsc.com/product-detail/${encodeURIComponent(t)}.html`},uwi=t=>{const e=t.trim(),n=/^c?(\d+)$/i.exec(e);return n?`C${n[1]}`:e},P0n=t=>{const e=w0n.indexOf(t);return e===-1?w0n.length:e},dwi=(t,e,n)=>{if(e==="name")return String(n);const o=t[`display_${e}`];if(typeof o=="string"&&o.trim()){const i=e==="resistance"?o.replace(/Ω$/,""):o;return JSON.stringify(i)}return JSON.stringify(n)??String(n)},hwi=t=>Object.entries(t).filter(([e,n])=>lwi.has(e)||e.startsWith("display_")&&e.slice(8)in t?!1:n!=null&&n!=="").sort(([e],[n])=>P0n(e)-P0n(n)||e.localeCompare(n)).map(([e,n])=>({key:e,label:e,value:dwi(t,e,n)})),pwi=t=>{const e=t.supplier_part_numbers;return e?["jlcpcb","lcsc"].flatMap(n=>{const o=e[n];if(!Array.isArray(o))return[];const i=[...new Set(o.filter(r=>!!(typeof r=="string"&&r.trim())).map(uwi))];return i.length?[{key:`supplier_part_numbers.${n}`,label:n,links:i.map(r=>({partNumber:r,href:gwi[n](r)}))}]:[]}):[]},mwi=(t,e)=>{const n=t.find(A=>A.type==="schematic_component"&&A.schematic_component_id===e);if(!n)return null;const o=t.find(A=>A.type==="source_component"&&A.source_component_id===n.source_component_id);if(!o)return null;const i=t.find(A=>A.type==="pcb_component"&&A.source_component_id===o.source_component_id),r=t.find(A=>A.type==="cad_component"&&A.source_component_id===o.source_component_id&&(!i||A.pcb_component_id===i.pcb_component_id)),s=i?.footprinter_string??r?.footprinter_string,a=i?_wi(t,i.pcb_component_id):null;return{schematicComponent:n,sourceComponent:o,pcbComponent:i,footprinterString:s,footprintPreviewCircuitJson:a?.circuitJson,footprintPreviewViewBox:a?.viewBox,warnings:cwi(t,n,i)}},Jme=2,_wi=(t,e)=>{const n=t.find(r=>r.type==="pcb_component"&&r.pcb_component_id===e);if(!n)return null;const o=Cln(n);if(!o)return null;const i={minX:o.minX-Jme,minY:o.minY-Jme,maxX:o.maxX+Jme,maxY:o.maxY+Jme};return{circuitJson:bSi(t,i),viewBox:i}},fwi=t=>{let e="";for(let o=0;o<t.length;o+=8192)e+=String.fromCharCode(...t.subarray(o,o+8192));return btoa(e)},Iwi=(t,e)=>{const n=fwi(Exe(Bxe(JSON.stringify(t)))),o=new URL("https://svg.tscircuit.com/");return o.searchParams.set("svg_type","pcb"),o.searchParams.set("circuit_json",n),o.searchParams.set("viewbox",[e.minX,e.minY,e.maxX,e.maxY].join(",")),o.searchParams.set("background_color","#f8fafc"),o.toString()},IWe=te.createContext(null),Cwi=5,ywi=(t,e)=>!t&&!e?!0:!t||!e?!1:t.minX===e.minX&&t.maxX===e.maxX&&t.minY===e.minY&&t.maxY===e.maxY,xwi=({children:t})=>te.useContext(IWe)?V.jsx(V.Fragment,{children:t}):V.jsx(Ewi,{children:t}),Ewi=({children:t})=>{const e=te.useRef({pointer:null,boundingBoxes:new Map,hoveringIds:new Set,subscribers:new Set,mouseDownPosition:null}),n=te.useCallback(()=>{for(const l of e.current.subscribers)l()},[]),o=te.useCallback(()=>{const l=e.current.pointer,g=new Set;if(l)for(const[h,d]of e.current.boundingBoxes){const p=d.bounds;p&&l.x>=p.minX&&l.x<=p.maxX&&l.y>=p.minY&&l.y<=p.maxY&&g.add(h)}const u=e.current.hoveringIds;g.size===u.size&&[...g].every(h=>u.has(h))||(e.current.hoveringIds=g,n())},[n]),i=te.useCallback((l,g)=>{e.current.boundingBoxes.set(l,g),o()},[o]),r=te.useCallback((l,g)=>{const u=e.current.boundingBoxes.get(l);u&&ywi(u.bounds,g.bounds)&&u.onClick===g.onClick||(e.current.boundingBoxes.set(l,g),o())},[o]),s=te.useCallback(l=>{e.current.boundingBoxes.delete(l)&&o()},[o]),a=te.useCallback(l=>(e.current.subscribers.add(l),()=>{e.current.subscribers.delete(l)}),[]),A=te.useCallback(l=>e.current.hoveringIds.has(l),[]);te.useEffect(()=>{const l=d=>{const{clientX:p,clientY:m}=d,_=e.current.pointer;_&&_.x===p&&_.y===m||(e.current.pointer={x:p,y:m},o())},g=()=>{e.current.pointer!==null&&(e.current.pointer=null,e.current.mouseDownPosition=null,o())},u=d=>{e.current.mouseDownPosition={x:d.clientX,y:d.clientY}},h=d=>{const{clientX:p,clientY:m}=d,_=e.current.mouseDownPosition;if(_&&Math.sqrt(Math.pow(p-_.x,2)+Math.pow(m-_.y,2))>Cwi){e.current.mouseDownPosition=null;return}e.current.mouseDownPosition=null;for(const f of e.current.boundingBoxes.values()){const I=f.bounds;I&&p>=I.minX&&p<=I.maxX&&m>=I.minY&&m<=I.maxY&&f.onClick?.(d)}};return window.addEventListener("pointermove",l,{passive:!0}),window.addEventListener("pointerdown",l,{passive:!0}),window.addEventListener("pointerup",l,{passive:!0}),window.addEventListener("pointerleave",g),window.addEventListener("pointercancel",g),window.addEventListener("blur",g),window.addEventListener("mousedown",u,{passive:!0}),window.addEventListener("click",h,{passive:!0}),()=>{window.removeEventListener("pointermove",l),window.removeEventListener("pointerdown",l),window.removeEventListener("pointerup",l),window.removeEventListener("pointerleave",g),window.removeEventListener("pointercancel",g),window.removeEventListener("blur",g),window.removeEventListener("mousedown",u),window.removeEventListener("click",h)}},[o]);const c=te.useMemo(()=>({registerBoundingBox:i,updateBoundingBox:r,unregisterBoundingBox:s,subscribe:a,isHovering:A}),[i,r,s,a,A]);return V.jsx(IWe.Provider,{value:c,children:t})},CWe={color:"#64748b",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace',fontSize:"12px",lineHeight:1.45},Bwi=({sourceComponent:t,warnings:e=[],footprinterString:n,footprintPreviewCircuitJson:o,footprintPreviewViewBox:i,left:r,top:s,width:a,maxHeight:A})=>{const c=te.useMemo(()=>hwi(t),[t]),l=te.useMemo(()=>pwi(t),[t]),g=te.useMemo(()=>o?.length&&i?Iwi(o,i):void 0,[o,i]);return V.jsxs("dialog",{open:!0,"aria-label":`${t.name} component details`,"data-schematic-component-details-tooltip":!0,style:{position:"absolute",left:r,right:"auto",top:s,bottom:"auto",width:a,maxHeight:A,margin:0,padding:0,overflowY:"auto",boxSizing:"border-box",border:"1px solid #cbd5e1",borderRadius:"4px",backgroundColor:"rgba(255, 255, 255, 0.98)",boxShadow:"0 20px 25px -5px rgba(15, 23, 42, 0.18), 0 8px 10px -6px rgba(15, 23, 42, 0.12)",color:"#0f172a",fontFamily:'Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',pointerEvents:"auto",userSelect:"text",WebkitUserSelect:"text",zIndex:CE.schematicComponentDetailsTooltip},onMouseDown:u=>u.stopPropagation(),onClick:u=>u.stopPropagation(),children:[V.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"minmax(110px, 0.8fr) minmax(0, 1.2fr)",gap:"6px 12px",margin:0,padding:"8px"},children:[c.map(u=>V.jsxs("div",{style:{display:"contents"},children:[V.jsx("dt",{style:CWe,children:u.label}),V.jsx("dd",{style:{minWidth:0,margin:0,color:"#1e293b",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace',fontSize:"12px",lineHeight:1.45,overflowWrap:"anywhere"},children:u.value})]},u.key)),l.map(u=>V.jsxs("div",{style:{display:"contents"},children:[V.jsx("dt",{style:CWe,children:u.label}),V.jsx("dd",{style:{minWidth:0,margin:0,fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace',fontSize:"12px",lineHeight:1.45,overflowWrap:"anywhere"},children:u.links.map((h,d)=>V.jsxs("span",{children:[d>0&&", ",V.jsx("a",{href:h.href,target:"_blank",rel:"noreferrer noopener",style:{color:"#2563eb",textDecoration:"underline"},children:h.partNumber})]},h.href))})]},u.key)),n&&V.jsxs("div",{style:{display:"contents"},children:[V.jsx("dt",{style:CWe,children:"footprint"}),V.jsx("dd",{style:{minWidth:0,margin:0,color:"#1e293b",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace',fontSize:"12px",lineHeight:1.45,overflowWrap:"anywhere"},children:JSON.stringify(n)})]})]}),e.length>0&&V.jsxs("section",{"aria-label":"Component warnings",style:{margin:"0 8px 8px",padding:"8px",border:"1px solid #fcd34d",borderRadius:"4px",backgroundColor:"#fffbeb",color:"#92400e",fontSize:"12px",lineHeight:1.45,overflowWrap:"anywhere"},children:[V.jsxs("strong",{children:["Warnings (",e.length,")"]}),V.jsx("ul",{style:{margin:"4px 0 0",paddingLeft:"18px"},children:e.map((u,h)=>V.jsx("li",{children:u.message},`${u.type}-${h}`))})]}),g&&V.jsx("div",{style:{padding:"0 4px 4px"},children:V.jsx("div",{style:{height:"210px",overflow:"hidden",border:"1px solid #e2e8f0",borderRadius:"2px",background:"#f8fafc"},children:V.jsx("img",{src:g,alt:`${t.name}${n?` ${n}`:""} PCB footprint`,loading:"lazy",referrerPolicy:"no-referrer",style:{display:"block",width:"100%",height:"100%",objectFit:"contain"}})})})]})},M0n=t=>{const e=te.useContext(IWe);if(!e)throw new Error("useMouseEventsOverBoundingBox must be used within a MouseTracker");const n=te.useId(),o=te.useRef(t);o.current=t;const i=te.useMemo(()=>s=>{o.current.onClick?.(s)},[]);return te.useEffect(()=>(e.registerBoundingBox(n,{bounds:o.current.bounds,onClick:o.current.onClick?i:void 0}),()=>{e.unregisterBoundingBox(n)}),[e,i,n]),te.useEffect(()=>{e.updateBoundingBox(n,{bounds:o.current.bounds,onClick:o.current.onClick?i:void 0})},[e,i,n,t.bounds?.minX,t.bounds?.maxX,t.bounds?.minY,t.bounds?.maxY,t.onClick]),{hovering:te.useSyncExternalStore(e.subscribe,()=>e.isHovering(n),()=>!1)}},bwi=(t,e)=>!t&&!e?!0:!t||!e?!1:Math.abs(t.bounds.minX-e.bounds.minX)<.5&&Math.abs(t.bounds.maxX-e.bounds.maxX)<.5&&Math.abs(t.bounds.minY-e.bounds.minY)<.5&&Math.abs(t.bounds.maxY-e.bounds.maxY)<.5&&Math.abs(t.rect.left-e.rect.left)<.5&&Math.abs(t.rect.top-e.rect.top)<.5&&Math.abs(t.rect.width-e.rect.width)<.5&&Math.abs(t.rect.height-e.rect.height)<.5,Swi=({componentId:t,svgDivRef:e,containerRef:n,onComponentClick:o,onHoverChange:i,showOutline:r,circuitJsonKey:s})=>{const[a,A]=te.useState(null),c=te.useRef(null),l=te.useCallback(()=>{c.current=null;const m=e.current,_=n.current;if(!m||!_){A(x=>x&&null);return}const f=m.querySelector(`[data-schematic-component-id="${t}"]`);if(!f){A(x=>x&&null);return}const I=f.getBoundingClientRect(),C=_.getBoundingClientRect(),y={bounds:{minX:I.left,maxX:I.right,minY:I.top,maxY:I.bottom},rect:{left:I.left-C.left,top:I.top-C.top,width:I.width,height:I.height}};A(x=>bwi(x,y)?x:y)},[t,n,e]),g=te.useCallback(()=>{c.current===null&&(c.current=window.requestAnimationFrame(l))},[l]);te.useEffect(()=>{g()},[g,s]),te.useEffect(()=>{g();const m=e.current,_=n.current;if(!m||!_)return;const f=typeof ResizeObserver<"u"?new ResizeObserver(()=>{g()}):null;f?.observe(_),f?.observe(m);const I=typeof MutationObserver<"u"?new MutationObserver(()=>{g()}):null;return I?.observe(m,{attributes:!0,attributeFilter:["style","transform"],subtree:!0,childList:!0}),window.addEventListener("scroll",g,!0),window.addEventListener("resize",g),()=>{f?.disconnect(),I?.disconnect(),window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",g),c.current!==null&&(cancelAnimationFrame(c.current),c.current=null)}},[g,e,n]);const u=te.useCallback(m=>{o&&o(t,m)},[t,o]),h=a?.bounds??null,{hovering:d}=M0n({bounds:h,onClick:o?u:void 0});if(te.useEffect(()=>{i&&i(t,d)},[d,t,i]),!a||!d||!r)return null;const p=a.rect;return V.jsx("div",{style:{position:"absolute",left:p.left,top:p.top,width:p.width,height:p.height,border:"1.5px solid rgba(51, 153, 255, 0.9)",pointerEvents:"none",zIndex:CE.schematicComponentHoverOutline}})},Qwi=(t,e)=>!t&&!e?!0:!t||!e?!1:Math.abs(t.bounds.minX-e.bounds.minX)<.5&&Math.abs(t.bounds.maxX-e.bounds.maxX)<.5&&Math.abs(t.bounds.minY-e.bounds.minY)<.5&&Math.abs(t.bounds.maxY-e.bounds.maxY)<.5&&Math.abs(t.rect.left-e.rect.left)<.5&&Math.abs(t.rect.top-e.rect.top)<.5&&Math.abs(t.rect.width-e.rect.width)<.5&&Math.abs(t.rect.height-e.rect.height)<.5,vwi=({portId:t,portLabel:e,svgDivRef:n,containerRef:o,onPortClick:i,onHoverChange:r,showOutline:s,circuitJsonKey:a})=>{const[A,c]=te.useState(null),l=te.useRef(null),g=te.useCallback(()=>{l.current=null;const _=n.current,f=o.current;if(!_||!f){c(B=>B&&null);return}const I=_.querySelector(`[data-schematic-port-id="${t}"]`);if(!I){c(B=>B&&null);return}const C=I.getBoundingClientRect(),y=f.getBoundingClientRect(),x=4,E={bounds:{minX:C.left-x,maxX:C.right+x,minY:C.top-x,maxY:C.bottom+x},rect:{left:C.left-y.left-x,top:C.top-y.top-x,width:C.width+x*2,height:C.height+x*2}};c(B=>Qwi(B,E)?B:E)},[t,o,n]),u=te.useCallback(()=>{l.current===null&&(l.current=window.requestAnimationFrame(g))},[g]);te.useEffect(()=>{u()},[u,a]),te.useEffect(()=>{u();const _=n.current,f=o.current;if(!_||!f)return;const I=typeof ResizeObserver<"u"?new ResizeObserver(()=>{u()}):null;I?.observe(f),I?.observe(_);const C=typeof MutationObserver<"u"?new MutationObserver(()=>{u()}):null;return C?.observe(_,{attributes:!0,attributeFilter:["style","transform"],subtree:!0,childList:!0}),window.addEventListener("scroll",u,!0),window.addEventListener("resize",u),()=>{I?.disconnect(),C?.disconnect(),window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u),l.current!==null&&(cancelAnimationFrame(l.current),l.current=null)}},[u,n,o]);const h=te.useCallback(_=>{i&&i(t,_)},[t,i]),d=A?.bounds??null,{hovering:p}=M0n({bounds:d,onClick:i?h:void 0});if(te.useEffect(()=>{r&&r(t,p)},[p,t,r]),!A||!s)return null;const m=A.rect;return V.jsxs(V.Fragment,{children:[V.jsx("div",{style:{position:"absolute",left:m.left,top:m.top,width:m.width,height:m.height,border:p?"1.5px solid rgba(255, 153, 51, 0.9)":"1.5px solid rgba(255, 153, 51, 0.3)",backgroundColor:p?"rgba(255, 153, 51, 0.15)":"rgba(255, 153, 51, 0.05)",borderRadius:"50%",pointerEvents:"none",zIndex:CE.schematicPortHoverOutline,transition:"border-color 0.15s, background-color 0.15s"}}),p&&e&&V.jsx("div",{style:{position:"absolute",left:m.left+m.width/2,top:m.top-24,transform:"translateX(-50%)",backgroundColor:"rgba(0, 0, 0, 0.85)",color:"white",padding:"4px 8px",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",whiteSpace:"nowrap",pointerEvents:"none",zIndex:CE.schematicPortHoverOutline+1},children:e})]})},IZ=({children:t,size:e,strokeWidth:n})=>V.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t}),D0n=t=>V.jsxs(IZ,{...t,children:[V.jsx("circle",{cx:"11",cy:"11",r:"8"}),V.jsx("path",{d:"m21 21-4.34-4.34"})]}),wwi=t=>V.jsxs(IZ,{...t,children:[V.jsx("path",{d:"M18 6 6 18"}),V.jsx("path",{d:"m6 6 12 12"})]}),Pwi=t=>V.jsxs(IZ,{...t,children:[V.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),V.jsx("rect",{x:"8",y:"8",width:"8",height:"8",rx:"1"}),V.jsx("path",{d:"M7 2v2M12 2v2M17 2v2M7 20v2M12 20v2M17 20v2M2 7h2M2 12h2M2 17h2M20 7h2M20 12h2M20 17h2"})]}),Mwi=t=>V.jsxs(IZ,{...t,children:[V.jsx("path",{d:"M15 6a9 9 0 0 0-9 9V3"}),V.jsx("circle",{cx:"18",cy:"6",r:"3"}),V.jsx("circle",{cx:"6",cy:"18",r:"3"})]}),Dwi=t=>V.jsxs(IZ,{...t,children:[V.jsx("path",{d:"M20 4v7a4 4 0 0 1-4 4H4"}),V.jsx("path",{d:"m9 10-5 5 5 5"})]}),Nwi=({text:t,query:e})=>{const n=e.trim().toLocaleLowerCase();if(!n)return t;const o=t.toLocaleLowerCase(),i=[];let r=0,s=o.indexOf(n);for(;s!==-1;)s>r&&i.push(t.slice(r,s)),i.push(V.jsx("strong",{style:{fontWeight:700},children:t.slice(s,s+n.length)},`${s}-${r}`)),r=s+n.length,s=o.indexOf(n,r);return r<t.length&&i.push(t.slice(r)),i.length>0?i:t},Rwi=()=>typeof navigator>"u"?"Ctrl F":/mac/i.test(navigator.platform)?"⌘ F":"Ctrl F",Twi=({query:t,onQueryChange:e,onCancel:n,results:o,onSelect:i,viewerContainerRef:r})=>{const[s,a]=te.useState(!1),[A,c]=te.useState(null),[l,g]=te.useState(null),u=te.useRef(null),h=te.useRef(null),d=Rwi();te.useEffect(()=>{c(S=>o.some(Q=>Q.target.id===S)?S:o.find(Q=>Q.kind==="component")?.target.id??o[0]?.target.id??null)},[o]),te.useEffect(()=>{A&&h.current?.querySelector(`[data-search-result-id="${A}"]`)?.scrollIntoView({behavior:"smooth",block:"nearest"})},[A]),te.useEffect(()=>{const S=w=>{if(w.key==="Escape"&&s){w.preventDefault(),w.stopPropagation(),w.stopImmediatePropagation(),n(),a(!1),u.current?.blur();return}w.code!=="KeyF"&&w.key.toLocaleLowerCase()!=="f"||!w.metaKey&&!w.ctrlKey||r.current?.matches(":hover")&&(w.preventDefault(),w.stopPropagation(),w.stopImmediatePropagation(),a(!0),requestAnimationFrame(()=>{u.current?.focus(),u.current?.select()}))},Q=[window];try{window.parent!==window&&window.parent.document&&Q.push(window.parent)}catch{}return Q.forEach(w=>w.addEventListener("keydown",S,{capture:!0})),()=>{Q.forEach(w=>w.removeEventListener("keydown",S,{capture:!0}))}},[s,n,r]);const p=()=>{n(),a(!1),u.current?.blur()},m=S=>{a(!0),S&&requestAnimationFrame(()=>u.current?.focus())},_=o.filter(S=>S.kind==="component"),f=o.filter(S=>S.kind==="net"),I=[..._,...f],C=I.find(S=>S.target.id===A)??I[0],y=o.length===1?"1 result":`${o.length} results`;let x="none";t&&(x="1px solid #e8e8e8");const E=S=>{if(!(S.key==="Enter"&&S.target instanceof Element&&S.target.closest('[aria-label="Clear search"]'))){if(S.key==="Escape"){S.preventDefault(),p();return}if(I.length>0&&(S.key==="ArrowDown"||S.key==="ArrowUp")){S.preventDefault();let Q=-1;S.key==="ArrowDown"&&(Q=1),c(w=>{const M=I.findIndex(F=>F.target.id===w);let k=M;M===-1&&(k=0,Q===1&&(k=-1));const R=(k+Q+I.length)%I.length;return I[R]?.target.id??null});return}S.key==="Enter"&&C&&(S.preventDefault(),i(C))}},B=(S,Q)=>Q.length===0?null:V.jsxs("section",{children:[V.jsx("div",{style:{padding:"6px 12px 3px",backgroundColor:"#f7f7f8",color:"#777777",fontSize:"11px",fontWeight:600,letterSpacing:"0.02em",textTransform:"lowercase"},children:S}),Q.map(w=>{const M=w.target.id===C?.target.id,k=w.target.id===l;let R="#ffffff";(k||M)&&(R="#f1f3f5");let F=V.jsx(Mwi,{size:15,strokeWidth:1.8});w.kind==="component"&&(F=V.jsx(Pwi,{size:15,strokeWidth:1.8}));const O=()=>{u.current?.blur(),c(w.target.id),i(w)};return V.jsxs("button",{type:"button","data-search-result-id":w.target.id,onPointerUp:U=>{U.button===0&&O()},onClick:U=>{U.detail===0&&O()},onMouseEnter:()=>g(w.target.id),onMouseLeave:()=>g(null),style:{width:"100%",display:"flex",alignItems:"center",gap:"9px",padding:"7px 12px",border:"none",background:R,color:"#222222",cursor:"pointer",textAlign:"left"},children:[V.jsx("span",{style:{width:"26px",height:"26px",flexShrink:0,display:"grid",placeItems:"center",border:"1px solid #e5e5e5",borderRadius:"6px",backgroundColor:"#f7f7f7",color:"#666666"},children:F}),V.jsxs("span",{style:{minWidth:0,flex:1},children:[V.jsx("span",{style:{display:"block",overflow:"hidden",fontSize:"13px",fontWeight:400,lineHeight:1.25,textOverflow:"ellipsis",whiteSpace:"nowrap"},children:V.jsx(Nwi,{text:w.label,query:t})}),w.detail&&V.jsx("span",{style:{display:"block",overflow:"hidden",marginTop:"2px",color:"#777777",fontSize:"11px",lineHeight:1.2,textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.detail}),w.schematicSheetName&&V.jsxs("span",{style:{display:"block",overflow:"hidden",marginTop:"2px",color:"#777777",fontSize:"11px",lineHeight:1.2,textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["Sheet: ",w.schematicSheetName]})]}),M&&V.jsx("span",{title:"Press Enter to open",style:{flexShrink:0,color:"#666666",fontSize:"17px",lineHeight:1},children:V.jsx(Dwi,{size:14,strokeWidth:1.8})})]},w.target.id)})]});return V.jsx("div",{"data-schematic-search":!0,onPointerDown:S=>S.stopPropagation(),onMouseDown:S=>S.stopPropagation(),onTouchStart:S=>S.stopPropagation(),onTouchEnd:S=>S.stopPropagation(),style:{position:"relative",zIndex:CE.schematicSearch,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'},children:s?V.jsxs("div",{onKeyDown:E,style:{width:"min(280px, calc(100vw - 32px))",overflow:"hidden",border:"none",borderRadius:"4px",backgroundColor:"#ffffff",boxShadow:"0 2px 4px rgba(0,0,0,0.1)"},children:[V.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",height:"32px",boxSizing:"border-box",padding:"0 12px",borderBottom:x},children:[V.jsx(D0n,{size:15,strokeWidth:2}),V.jsx("input",{ref:u,value:t,"aria-label":"Search components and nets",placeholder:"Search...",onPointerUp:S=>S.currentTarget.focus(),onChange:S=>e(S.target.value),style:{minWidth:0,flex:1,border:"none",outline:"none",fontSize:"13px",color:"#222222",background:"transparent"}}),t&&o.length>0?V.jsx("span",{style:{flexShrink:0,color:"#888888",fontSize:"12px",whiteSpace:"nowrap"},children:y}):V.jsx("kbd",{style:{flexShrink:0,padding:"2px 5px",border:"1px solid #dddddd",borderRadius:"4px",backgroundColor:"#f7f7f7",color:"#777777",fontFamily:"inherit",fontSize:"10px",lineHeight:1.2},children:d}),s&&V.jsx("button",{type:"button","aria-label":"Clear search",onPointerUp:S=>{S.button===0&&p()},onClick:S=>{S.detail===0&&p()},style:{border:"none",background:"transparent",color:"#777777",cursor:"pointer",width:"20px",height:"20px",display:"grid",placeItems:"center",padding:0,lineHeight:1},children:V.jsx(wwi,{size:16,strokeWidth:2})})]}),t&&V.jsx("div",{ref:h,style:{maxHeight:"240px",overflowX:"hidden",overflowY:"auto",overscrollBehavior:"contain",scrollBehavior:"smooth",touchAction:"pan-y",WebkitOverflowScrolling:"touch"},onWheel:S=>S.stopPropagation(),onTouchMove:S=>S.stopPropagation(),children:o.length===0?V.jsx("div",{style:{padding:"12px",color:"#777777",fontSize:"13px"},children:"No matching components or nets"}):V.jsxs(V.Fragment,{children:[B("components",_),B("nets",f)]})})]}):V.jsx("button",{type:"button",title:"Search schematic","aria-label":"Search schematic",onPointerDown:S=>{S.stopPropagation(),S.pointerType!=="mouse"&&m(!1)},onPointerUp:S=>{S.pointerType==="mouse"&&S.button===0&&m(!0)},onClick:S=>{S.detail===0&&m(!0)},style:{width:"32px",height:"32px",display:"grid",placeItems:"center",padding:0,border:"none",borderRadius:"4px",backgroundColor:"#ffffff",color:"#000000",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)"},children:V.jsx(D0n,{size:16,strokeWidth:2})})})},yWe='system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',kwi={backgroundColor:"#ffffff",color:"#111111",borderRadius:8,boxShadow:"0 6px 24px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.08)",border:"1px solid #e5e7eb",padding:4,minWidth:200,maxWidth:320,maxHeight:320,overflowY:"auto",fontSize:13,fontFamily:yWe,outline:"none",zIndex:CE.viewMenu},Fwi={display:"flex",alignItems:"center",gap:8,padding:"7px 10px 7px 8px",borderRadius:6,cursor:"pointer",outline:"none",userSelect:"none",color:"#111111",fontSize:13,fontFamily:yWe},Lwi={width:16,height:16,flexShrink:0,display:"inline-flex",alignItems:"center",justifyContent:"center",color:"#111111"},N0n={overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Hwi=`
|
|
5507
|
+
`;return rc("style",{},[JB(t)])}function u0n(t,e){const n=t[e];if(typeof n=="string")return n}function svi(t,e,n,o){const r=[4,8],s=r.map(u=>ji(u)).join(" "),A=r.reduce((u,h)=>u+h,0)/3,c=[];t.forEach((u,h)=>{if(u.points.length===0)return;const d=[];u.points.forEach((I,C)=>{const y=ji(n(I.timeMs)),x=ji(o(I.displayValue));d.push(`${C===0?"M":"L"} ${y} ${x}`)});const p={class:"simulation-line",d:d.join(" "),stroke:u.color,"clip-path":`url(#${e})`,[s0n(u.graph)]:lWe(u.graph)};u.graph.source_component_id&&(p["data-source-component-id"]=u.graph.source_component_id);const m=u0n(u.graph,"source_probe_id");m&&(p["data-source-probe-id"]=m);const _=u0n(u.graph,"source_probe_name");_&&(p["data-source-probe-name"]=_),u.graph.subcircuit_connectivity_map_key&&(p["data-subcircuit-connectivity-map-key"]=u.graph.subcircuit_connectivity_map_key);const f=u.points.map(I=>{const C=ji(n(I.timeMs)),y=ji(o(I.displayValue));return rc("circle",{class:"simulation-point",cx:C,cy:y,r:"2.5",fill:u.color,"clip-path":`url(#${e})`})});c.push({entry:u,graphIndex:h,pathAttributes:p,pointElements:f})});const l=[];for(let u=0;u<3;u++)for(const h of c){const d=(h.graphIndex+u)%3,p=ji(d*A);l.push(rc("path",{...h.pathAttributes,"stroke-dasharray":s,"stroke-dashoffset":p}))}const g=c.flatMap(u=>u.pointElements);return rc("g",{class:"data-series"},[...l,...g])}function avi(t,e){return t?.name?rc("text",{class:"chart-title",x:ji(e/2),y:ji(dm.top-40),"text-anchor":"middle"},[JB(t.name)]):null}var d0n=16;function Avi(t,e,n,o){const i=o.map((r,s)=>rc("tspan",{x:"20",dy:s===0?"0":String(d0n)},[JB(r)]));return rc("g",{class:"legend-item",transform:`translate(${ji(e)} ${ji(n)})`},[rc("line",{class:"legend-line",x1:"0",y1:"0",x2:"16",y2:"0",stroke:t.color}),rc("text",{class:"legend-label",x:"20",y:"0","dominant-baseline":"middle"},i)])}var cvi=15;function lvi(t){const e=t.split("_");if(e.length<=1)return[t];const n=[];let o=e[0]??"";for(let i=1;i<e.length;i++){const r=e[i]??"",s=`${o}_${r}`;s.length>cvi?(n.push(o),o=r):o=s}return o&&n.push(o),n}var gvi=24;function uvi(t,e){let n=dm.top;const o=t.map(i=>{const r=e-dm.right+10,s=lvi(i.label),a=Avi(i,r,n,s),A=s.length*d0n;return n+=Math.max(A,gvi),a});return rc("g",{class:"legend"},o)}var fT=118,Yme=94,pU=18;function h0n(t,e){const n=Math.floor((e+pU)/(fT+pU)),o=Math.max(1,Math.min(n,t)),i=Math.max(1,Math.ceil(t/o)),r=o*fT+(o-1)*pU,s=i*Yme+(i-1)*pU;return{columns:o,rows:i,x:Math.max(0,(e-r)/2),height:s}}var Ume=20,uWe=8,dvi=14;function hvi(t,e,n){const o=h0n(t.length,e),i=[];for(const[r,s]of t.entries()){const a=r%o.columns,A=Math.floor(r/o.columns);i.push(pvi(s,r,o.x+a*(fT+pU),n+AWe+A*(Yme+pU)))}return rc("g",{class:"scope-legend"},i)}function pvi(t,e,n,o){const i=t.scopeTraceDisplay,r=Vx(t.graph)?"A":"V",s=i&&mZ(i)?gWe(i.valuePerDiv,r):`1 ${r}`,a=gWe(i?.center??0,r),A=WQi(i?.offsetDivs??0),c=`Ch${e+1}`,g=[t.label===c?void 0:t.label,`${s}/div`,A,a].filter(h=>!!h),u=g.length>1?(Yme-Ume-uWe*2-dvi)/(g.length-1):0;return rc("g",{class:"scope-channel",transform:`translate(${ji(n)} ${ji(o)})`,[s0n(t.graph)]:lWe(t.graph)},[rc("rect",{class:"scope-channel-card",x:"0",y:"0",width:ji(fT),height:ji(Yme),rx:"6",ry:"6"}),rc("rect",{x:"0",y:"0",width:ji(fT),height:ji(Ume),rx:"6",ry:"6",fill:t.color}),rc("rect",{x:"0",y:ji(Ume-6),width:ji(fT),height:"6",fill:t.color}),rc("text",{class:"scope-channel-header-text",x:ji(fT/2),y:"14","text-anchor":"middle"},[JB(c)]),...g.map((h,d)=>rc("text",{class:"scope-channel-detail",x:ji(uWe),y:ji(Ume+uWe+d*u),"dominant-baseline":"hanging"},[JB(h)]))])}function mvi(t){const e=Math.ceil(t/2),n=Math.floor(t/2);return{left:p0n(e),right:p0n(n)}}function p0n(t){if(t<=1)return 0;const e=10+(t-1)*cWe+6+KQi+VQi;return Math.max(0,e-dm.left)}function m0n(t){return t.type==="simulation_transient_voltage_graph"||t.type==="simulation_transient_current_graph"||t.type==="simulation_dc_operating_point_voltage"||t.type==="simulation_dc_operating_point_current"||t.type==="simulation_dc_sweep_voltage_graph"||t.type==="simulation_dc_sweep_current_graph"||t.type==="simulation_ac_sweep_voltage_graph"||t.type==="simulation_ac_sweep_current_graph"}function _0n(t){return t?.type==="simulation_experiment"}function _vi(t){return t?.type==="simulation_voltage_probe"}function fvi(t){return t?.type==="simulation_current_probe"}function Ivi(t){return t?.type==="simulation_oscilloscope_trace"}function Cvi(t,e){const n=xvi(t),o=a0n(t),i=Math.min(n.length,o.length),r=[],s=yvi(e);for(let a=0;a<i;a++){const A=Number(n[a]??Number.NaN),c=Number(o[a]??Number.NaN);!Number.isFinite(A)||!Number.isFinite(c)||r.push({timeMs:A,rawValue:c,displayValue:s(c)})}return r}function yvi(t){if(!mZ(t))return i=>i;const e=t.center??0,n=t.offsetDivs??0,o=t.valuePerDiv;return i=>n+(i-e)/o}function xvi(t){const e=a0n(t);if(Array.isArray(t.timestamps_ms)&&t.timestamps_ms.length===e.length)return t.timestamps_ms.map(r=>Number(r));const n=e.length;if(n===0)return[];const o=[];for(let r=0;r<n;r++)o.push(t.start_time_ms+t.time_per_step*r);const i=o.length>0?o[o.length-1]:void 0;return i!==void 0&&Number.isFinite(t.end_time_ms)&&Number.isFinite(i)&&Math.abs(i-t.end_time_ms)>t.time_per_step/2&&o.push(t.end_time_ms),o}function Kme(t,e){const n=t[e];if(typeof n=="string")return n}function Evi(t,e,n,o){const i=Vx(t)?"I":"V";if(n?.displayName)return n.displayName;if(t.simulation_parameter_sweep_coordinate&&t.name)return t.name;if(e?.name)return`${i}(${e.name})`;const r=Kme(t,"source_probe_name");if(r)return`${i}(${r})`;if(t.source_component_id){const s=o.get(t.source_component_id);if(s)return`${i}(${s})`}return t.name?t.name:t.source_component_id?`Probe ${t.source_component_id}`:lWe(t)}function Bvi(t,e,n,o,i,r){if(Vx(t)){const A=o.get(t.simulation_transient_current_graph_id);if(A)return A;const c=Kme(t,"source_probe_id")??(e?.type==="simulation_current_probe"?e.simulation_current_probe_id:void 0);return c?r.get(c):void 0}const s=n.get(t.simulation_transient_voltage_graph_id);if(s)return s;const a=Kme(t,"source_probe_id")??(e?.type==="simulation_voltage_probe"?e.simulation_voltage_probe_id:void 0);return a?i.get(a):void 0}function bvi(t,e,n,o,i){const r=Kme(t,"source_probe_id");if(r){const s=Vx(t)?n.get(r):e.get(r);if(s)return s}if(t.source_component_id)return Vx(t)?i.get(t.source_component_id):o.get(t.source_component_id)}function Svi(t,e){if(e)return{displayName:e.display_name,color:e.color,center:e.display_center_value,offsetDivs:e.display_center_offset_divs,valuePerDiv:Vx(t)?e.amps_per_div:e.volts_per_div}}function Qvi(t,e){const n=Array.isArray(jh.simulation_palette)?jh.simulation_palette:Array.isArray(jh.palette)?jh.palette:[],o=e.filter(_vi),i=e.filter(fvi),r=e.filter(Ivi),s=new Map,a=new Map,A=new Map,c=new Map,l=new Map,g=new Map,u=new Map,h=new Map,d=new Map,p=new Map,m=new Map,_=new Map;for(const f of r)f.simulation_transient_voltage_graph_id&&d.set(f.simulation_transient_voltage_graph_id,f),f.simulation_transient_current_graph_id&&p.set(f.simulation_transient_current_graph_id,f),f.simulation_voltage_probe_id&&m.set(f.simulation_voltage_probe_id,f),f.simulation_current_probe_id&&_.set(f.simulation_current_probe_id,f);for(const f of o)l.set(f.simulation_voltage_probe_id,f),f.name&&f.source_component_id&&s.set(f.source_component_id,f.name),f.color&&f.source_component_id&&a.set(f.source_component_id,f.color),f.source_component_id&&u.set(f.source_component_id,f);for(const f of i)g.set(f.simulation_current_probe_id,f),f.name&&f.source_component_id&&A.set(f.source_component_id,f.name),f.color&&f.source_component_id&&c.set(f.source_component_id,f.color),f.source_component_id&&h.set(f.source_component_id,f);return t.map((f,I)=>{const C=bvi(f,l,g,u,h),y=Bvi(f,C,d,p,m,_),x=Svi(f,y),E=Cvi(f,x),B=vvi(n,I),S=wvi(f,C,Vx(f)?c:a),Q=f.color??x?.color??S??B,w=Evi(f,C,x,Vx(f)?A:s);return{graph:f,points:E,color:Q,label:w,scopeTraceDisplay:x,usesScopeTraceDisplay:mZ(x)}}).filter(f=>f.points.length>0)}function vvi(t,e){return t.length===0?r0n:t[e%t.length]??r0n}function wvi(t,e,n){if(e?.color)return e.color;if(t.source_component_id)return n.get(t.source_component_id)}function f0n({circuitJson:t,simulation_experiment_id:e,simulation_transient_current_graph_ids:n,simulation_transient_voltage_graph_ids:o,simulation_result_ids:i,ac_sweep_view:r="magnitude",width:s=YQi,height:a=UQi,includeVersion:A}){const c=o?new Set(o):null,l=n?new Set(n):null,g=!!(c||l),u=i?new Set(i):null,h=t.find(X=>_0n(X)&&X.simulation_experiment_id===e),d=t.filter(X=>m0n(X)&&X.simulation_experiment_id===e&&(!u||u.has(i0n(X)))&&(!g||X.type==="simulation_transient_voltage_graph"&&(c?.has(X.simulation_transient_voltage_graph_id)??!1)||X.type==="simulation_transient_current_graph"&&(l?.has(X.simulation_transient_current_graph_id)??!1))),p=GQi({results:d,acSweepView:r,experiment:h}),m=p.graphs;if(m.length===0)throw new Error(`No simulation analysis results found for simulation_experiment_id "${e}"`);const _=Qvi(m,t),f=_.flatMap(X=>X.points);if(f.length===0)throw new Error(`Simulation results for simulation_experiment_id "${e}" do not contain any datapoints`);const I=f.map(X=>X.timeMs);let C;p.usesLogarithmicXValues?C=Pvi(I):p.xAxisTitle==="Time (ms)"?C=$Qi({values:I,graphs:m,experiment:h}):C=Ome(I);const y=Ome(f.map(X=>X.displayValue),!0),x=_.some(X=>X.usesScopeTraceDisplay),E=x?mvi(_.length):{left:0,right:0},B=s+E.left+E.right,S=x?h0n(_.length,B):null,Q=S?a+AWe+S.height+AWe:a,w=Math.max(1,s-dm.left-dm.right),M=Math.max(1,a-dm.top-dm.bottom),k=dm.left+E.left,R=g0n(C.domainMin,C.domainMax,k,k+w),F=g0n(y.domainMin,y.domainMax,dm.top+M,dm.top),O=JQi(e),U=tWe(t),Y=nWe,J=avi(h,B),ee=[rvi(),tvi(B,Q),nvi(O,k,w,M),ivi(k,w,M),ovi({timeAxis:C,valueAxis:y,scaleX:R,scaleY:F,plotLeft:k,plotWidth:w,plotHeight:M}),svi(_,O,R,F),qQi({timeAxis:C,valueAxis:y,graphs:_,scaleX:R,scaleY:F,plotLeft:k,plotWidth:w,plotHeight:M,yAxisTitle:p.yAxisTitle??zQi(_),xAxisTitle:p.xAxisTitle,usesScopeTraceDisplay:x}),x?hvi(_,B,a):uvi(_,B),...J?[J]:[]],W=rc("svg",{xmlns:"http://www.w3.org/2000/svg",width:B.toString(),height:Q.toString(),style:`background-color: ${jh.schematic.background}`,viewBox:`0 0 ${ji(B)} ${ji(Q)}`,"data-simulation-experiment-id":e,...h?.name&&{"data-simulation-experiment-name":h.name},...U&&{"data-software-used-string":U},...A&&{"data-circuit-to-svg-version":Y}},ee);return eWe(W)}var Pvi=t=>{const e=Ome(t);return{...e,tickLabelOverrides:new Map(e.ticks.map(n=>[n,ji(10**n)]))}},Mvi=1200,Dvi=1200,I0n=.55;function Nvi({circuitJson:t,simulation_experiment_id:e,simulation_transient_current_graph_ids:n,simulation_transient_voltage_graph_ids:o,simulation_result_ids:i,ac_sweep_view:r,width:s=Mvi,height:a=Dvi,schematicHeightRatio:A=I0n,schematicOptions:c,includeVersion:l,graphAboveSchematic:g=!1,showErrorsInTextOverlay:u}){const h=t.filter(F=>!_0n(F)&&!m0n(F)),d=Tvi(A),p=Math.max(1,a*d),m=Math.max(1,a-p),_=p+m,f=_===0?1:a/_,I=p*f,C=m*f,y=t0n(h,{...c,width:s,height:I,includeVersion:!1,showErrorsInTextOverlay:u}),x=f0n({circuitJson:t,simulation_experiment_id:e,simulation_transient_current_graph_ids:n,simulation_transient_voltage_graph_ids:o,simulation_result_ids:i,ac_sweep_view:r,width:s,height:C,includeVersion:!1}),E=Rln(MV(y)),B=Rln(MV(x)),S=Rvi(B)??{width:s,height:C},Q=S.width>0?s*(S.height/S.width):C,w=I+Q,M=[];g?(M.push(Nme(B,0,0,s,Q)),M.push(Nme(E,0,Q,s,I))):(M.push(Nme(E,0,0,s,I)),M.push(Nme(B,0,I,s,Q)));const k=tWe(h),R={name:"svg",type:"element",value:"",attributes:{xmlns:"http://www.w3.org/2000/svg",width:A4(s),height:A4(w),viewBox:`0 0 ${A4(s)} ${A4(w)}`,"data-simulation-experiment-id":e,...k&&{"data-software-used-string":k},...l&&{"data-circuit-to-svg-version":nWe}},children:M};return eWe(R)}function Rvi(t){const e=t.attributes?.viewBox;if(typeof e!="string")return null;const n=e.trim().split(/[\s,]+/).map(r=>Number.parseFloat(r));if(n.length!==4)return null;const o=n.at(2),i=n.at(3);return!Number.isFinite(o)||!Number.isFinite(i)||o===void 0||i===void 0||o<=0||i<=0?null:{width:o,height:i}}function Tvi(t){return Number.isFinite(t)?t<=0?0:t>=1?1:t:I0n}var C0n=({initialTransform:t,initialTouch1:e,initialTouch2:n,finalTouch1:o,finalTouch2:i})=>{if(!o||!i)return t;const r={x:(e.x+n.x)/2,y:(e.y+n.y)/2},s={x:(o.x+i.x)/2,y:(o.y+i.y)/2},a=Math.hypot(n.x-e.x,n.y-e.y),A=Math.hypot(i.x-o.x,i.y-o.y),c=a===0?1:A/a,l=s.x-r.x,g=s.y-r.y;return dd(hA(l,g),hA(r.x,r.y),uC(c,c),hA(-r.x,-r.y),t)},_Z=(t={})=>{const e=te.useRef(null),[n,o]=te.useState(0),i=t.canvasElm??e.current,[r,s]=te.useState(t.initialTransform??wQ()),[a,A]=te.useState(0),[c,l]=te.useReducer(I=>I+1,0),g=te.useCallback(I=>{t.onSetTransform&&t.onSetTransform(I),t.transform||s(I)},[t.onSetTransform,s]),u=te.useCallback(I=>{g(I),l()},[g]),h=t.transform??r,d=te.useCallback(()=>{o(Date.now())},[]),p=te.useRef("none"),m=te.useRef(null),_=te.useRef(null);te.useEffect(()=>{const I=t.canvasElm??e.current;if(I&&!i){A(a+1);return}if(!I){const U=setTimeout(()=>{A(a+1)},100);return()=>clearTimeout(U)}let C=t.transform??r,y={x:0,y:0},x={x:0,y:0},E=!1;const B=U=>({x:U.pageX-I.getBoundingClientRect().left-window.scrollX,y:U.pageY-I.getBoundingClientRect().top-window.scrollY});function S(U){t.enabled!==!1&&(t.shouldDrag&&!t.shouldDrag(U)||(y=B(U),!(Date.now()-n<100)&&(E=!0,U.preventDefault())))}function Q(U){if(!E||t.enabled===!1||t.shouldDrag&&!t.shouldDrag(U))return;x=B(U);const Y=dd(hA(x.x-y.x,x.y-y.y),C);g(Y),C=Y,E=!1}function w(U){if(B(U),!E||t.enabled===!1||t.shouldDrag&&!t.shouldDrag(U))return;x=B(U);const Y=dd(hA(x.x-y.x,x.y-y.y),C);g(Y)}function M(U){if(t.enabled===!1||t.shouldDrag&&!t.shouldDrag(U))return;const Y=B(U),J=dd(hA(Y.x,Y.y),uC(1-U.deltaY/1e3,1-U.deltaY/1e3),hA(-Y.x,-Y.y),C);g(J),C=J,U.preventDefault()}function k(U){if(!E||t.shouldDrag&&!t.shouldDrag(U))return;if(I){const J=I.getBoundingClientRect();if(U.clientX>=J.left+10&&U.clientX<=J.right-10&&U.clientY>=J.top+10&&U.clientY<=J.bottom-10)return}E=!1,x=B(U);const Y=dd(hA(x.x-y.x,x.y-y.y),C);g(Y),C=Y}function R(U){if(U.preventDefault(),t.enabled!==!1){if(U.touches.length===1){p.current="drag";const Y=U.touches[0];m.current={initialTransform:C,initialTouch:{x:Y.clientX,y:Y.clientY}}}else if(U.touches.length===2){p.current="pinch";const Y=U.touches[0],J=U.touches[1];_.current={initialTransform:C,initialTouch1:{x:Y.clientX,y:Y.clientY},initialTouch2:{x:J.clientX,y:J.clientY},finalTouch1:null,finalTouch2:null}}}}function F(U){if(U.preventDefault(),t.enabled!==!1){if(p.current==="drag"&&U.touches.length===1&&m.current){const Y=U.touches[0],J={x:Y.clientX,y:Y.clientY},ee=J.x-m.current.initialTouch.x,W=J.y-m.current.initialTouch.y,X=dd(hA(ee,W),m.current.initialTransform);g(X)}else if(p.current==="pinch"&&U.touches.length===2&&_.current){const Y=U.touches[0],J=U.touches[1];_.current.finalTouch1={x:Y.clientX,y:Y.clientY},_.current.finalTouch2={x:J.clientX,y:J.clientY};const ee=C0n(_.current);g(ee)}}}function O(U){U.preventDefault();const Y=U.changedTouches[0];if(p.current==="drag"&&m.current&&Y){const J={x:Y.clientX,y:Y.clientY},ee=J.x-m.current.initialTouch.x,W=J.y-m.current.initialTouch.y,X=dd(hA(ee,W),m.current.initialTransform);g(X),C=X}else if(p.current==="pinch"&&_.current){const J=C0n(_.current);g(J),C=J}p.current="none",m.current=null,_.current=null}return I.addEventListener("mousedown",S),I.addEventListener("mouseup",Q),window.addEventListener("mousemove",w),I.addEventListener("mouseout",k),I.addEventListener("wheel",M),I.addEventListener("touchstart",R,{passive:!1}),I.addEventListener("touchmove",F,{passive:!1}),I.addEventListener("touchend",O,{passive:!1}),I.addEventListener("touchcancel",O,{passive:!1}),()=>{I.removeEventListener("mousedown",S),I.removeEventListener("mouseup",Q),window.removeEventListener("mousemove",w),I.removeEventListener("mouseout",k),I.removeEventListener("wheel",M),I.removeEventListener("touchstart",R),I.removeEventListener("touchmove",F),I.removeEventListener("touchend",O),I.removeEventListener("touchcancel",O)}},[i,a,c,n,t.enabled,t.shouldDrag]);const f=te.useCallback(I=>Bn(h,I),[h]);return{ref:e,transform:h,applyTransformToPoint:f,setTransform:u,cancelDrag:d}},y0n=_Z;function dWe(t){const e=V3(t),n=new Map;for(const s of e.schematic_component.list())s.source_component_id&&n.set(s.source_component_id,s.schematic_component_id);const o=new Map;for(const s of e.source_trace.list()){const a=s.subcircuit_connectivity_map_key;if(a)for(const A of s.connected_source_port_ids??[]){const c=n.get(e.source_port.get(A)?.source_component_id??"");c&&(o.has(c)||o.set(c,new Set),o.get(c).add(a))}}const i=new Map;for(const s of e.schematic_net_label.list()){if(!s.source_net_id)continue;const a=e.source_net.get(s.source_net_id)?.subcircuit_connectivity_map_key??s.source_net_id;i.set(s.schematic_net_label_id,a)}const r=new Map;for(const s of e.schematic_text.list()){if(!s.source_trace_id)continue;const a=e.source_trace.get(s.source_trace_id)?.subcircuit_connectivity_map_key;a&&r.set(s.schematic_text_id,a)}return{componentIdToKeys:o,netLabelIdToKey:i,textIdToKey:r}}var Vme=(t,e)=>Math.hypot(t.x-e.x,t.y-e.y),x0n=(t,e,n)=>{const o=n.x-e.x,i=n.y-e.y,r=o*o+i*i,s=r?Math.max(0,Math.min(1,((t.x-e.x)*o+(t.y-e.y)*i)/r)):0;return Vme(t,{x:e.x+s*o,y:e.y+s*i})},IT=(t,e,n)=>Math.abs(Vme(e,t)+Vme(t,n)-Vme(e,n))<1e-5;function kvi(t,e){const n=dWe(e),o=t?.closest("[data-subcircuit-connectivity-map-key], [data-schematic-net-label-id], [data-schematic-text-id], [data-schematic-trace-id]");if(!o)return;const i=e.find(r=>r.type==="schematic_trace"&&r.schematic_trace_id===o.getAttribute("data-schematic-trace-id"));return o.getAttribute("data-subcircuit-connectivity-map-key")||n.netLabelIdToKey.get(o.getAttribute("data-schematic-net-label-id"))||n.textIdToKey.get(o.getAttribute("data-schematic-text-id"))||(i?.type==="schematic_trace"?i.subcircuit_connectivity_map_key||e.filter(r=>r.type==="source_trace").find(r=>r.source_trace_id===i.source_trace_id)?.subcircuit_connectivity_map_key:void 0)}function Fvi(t,e){const n=dWe(t),o=t.filter(g=>g.type==="source_trace"),i=t.filter(g=>g.type==="schematic_trace"),r=t.filter(g=>g.type==="schematic_sheet"),s=r[0]?.schematic_sheet_id,a=[];for(const g of i)if((g.subcircuit_connectivity_map_key??o.find(h=>h.source_trace_id===g.source_trace_id)?.subcircuit_connectivity_map_key)===e)for(const h of g.edges)a.push({a:h.from,b:h.to,sheet:g.schematic_sheet_id??s,target:{type:"schematic_trace",id:g.schematic_trace_id},sourceTraceId:g.source_trace_id,portIds:[h.from_schematic_port_id,h.to_schematic_port_id].filter(d=>!!d),junctions:g.junctions});for(const g of t)if(g.type==="schematic_net_label"&&n.netLabelIdToKey.get(g.schematic_net_label_id)===e){const u=g.anchor_position??g.center;a.push({a:u,b:u,sheet:g.schematic_sheet_id??s,target:{type:"schematic_net_label",id:g.schematic_net_label_id},name:g.text})}for(const g of t){if(g.type!=="schematic_text"||n.textIdToKey.get(g.schematic_text_id)!==e)continue;const u=g.schematic_sheet_id??s,d=a.filter(p=>p.sheet===u&&p.sourceTraceId===g.source_trace_id).sort((p,m)=>x0n(g.position,p.a,p.b)-x0n(g.position,m.a,m.b))[0]?.a??g.position;a.push({a:d,b:d,sheet:u,target:{type:"schematic_text",id:g.schematic_text_id},name:g.text})}const A=a.map((g,u)=>u),c=g=>A[g]===g?g:A[g]=c(A[g]);for(let g=0;g<a.length;g++)for(let u=0;u<g;u++){const h=a[g],d=a[u];h.sheet===d.sheet&&(IT(h.a,d.a,d.b)||IT(h.b,d.a,d.b)||IT(d.a,h.a,h.b)||IT(d.b,h.a,h.b)||[...h.junctions??[],...d.junctions??[]].some(p=>IT(p,h.a,h.b)&&IT(p,d.a,d.b)))&&(A[c(g)]=c(u))}const l=new Map;return a.forEach((g,u)=>l.set(c(u),[...l.get(c(u))??[],g])),[...l.values()].map((g,u)=>{const h=g.find(f=>f.target.type!=="schematic_trace")??g[0],p=t.filter(f=>f.type==="schematic_port").filter(f=>(f.schematic_sheet_id??s)===h.sheet&&g.some(I=>I.portIds?.includes(f.schematic_port_id)||IT(f.center,I.a,I.b))).map(f=>{const I=t.find(y=>y.type==="source_port"&&y.source_port_id===f.source_port_id);if(I?.type!=="source_port")return;const C=t.find(y=>y.type==="source_component"&&y.source_component_id===I.source_component_id);return C?.type==="source_component"?`${C.name}.${I.name??`pin${I.pin_number}`}`:void 0}).filter(f=>!!f).sort(),m=r.findIndex(f=>f.schematic_sheet_id===h.sheet);return{kind:"net",label:`${r[m]?.name??`Sheet ${Math.max(0,m)+1}`}: ${p[0]??h.name??`Location ${u+1}`}`,schematicSheetId:h.sheet,target:h.target,focusPoint:{x:(h.a.x+h.b.x)/2,y:(h.a.y+h.b.y)/2}}})}var Lvi="https://jscdn.tscircuit.com/@tscircuit/circuit-json-schematic-placement-analysis/latest/dist/browser.js",Hvi={async load(){const t=await import(Lvi);if(typeof t.createSchematicPlacementIssueArtifacts!="function")throw new Error("The style analyzer module does not export its analysis function.");return t}},CE={contextMenu:110,styleAnalysis:120,viewMenu:55,viewMenuIcon:48,clickToInteractOverlay:100,schematicComponentDetailsTooltip:105,schematicComponentHoverOutline:47,schematicPortHoverOutline:48,schematicSearch:101},Ovi=({circuitJson:t,onClose:e})=>{const[n,o]=te.useState({status:"loading"});return te.useEffect(()=>{let i=!1;const r=window.setTimeout(async()=>{try{const{createSchematicPlacementIssueArtifacts:s}=await Hvi.load();if(i)return;const a=s(t);i||o({status:"complete",artifacts:a})}catch(s){i||o({status:"error",message:s instanceof Error?s.message:String(s)})}},0);return()=>{i=!0,window.clearTimeout(r)}},[t]),V.jsx(zJe,{open:!0,onOpenChange:i=>!i&&e(),children:V.jsxs(JJe,{children:[V.jsx(xme,{style:{position:"fixed",inset:0,background:"#0008",zIndex:CE.styleAnalysis}}),V.jsxs(Eme,{style:{position:"fixed",top:"5vh",left:"50%",transform:"translateX(-50%)",width:"min(1000px, 94vw)",maxHeight:"90vh",overflowY:"auto",boxSizing:"border-box",padding:24,borderRadius:12,background:"#fafafa",color:"#171717",fontFamily:"system-ui, sans-serif",boxShadow:"0 20px 60px #0005",zIndex:CE.styleAnalysis},children:[V.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16},children:[V.jsx(Bme,{style:{margin:0,fontSize:22},children:"Style Analysis"}),V.jsx(jJe,{style:{cursor:"pointer",padding:"6px 12px"},children:"Close"})]}),V.jsx(bme,{style:{color:"#525252"},children:"Placement and style issues across all schematic sheets. Each image highlights one issue with its description below."}),n.status==="loading"&&V.jsx("p",{role:"status",children:"Running style analysis…"}),n.status==="error"&&V.jsxs("p",{role:"alert",children:["Style analysis failed: ",n.message]}),n.status==="complete"&&V.jsxs(V.Fragment,{children:[V.jsx("p",{role:"status",children:n.artifacts.length===0?"No style issues found.":`${n.artifacts.length} style ${n.artifacts.length===1?"issue":"issues"} found.`}),n.artifacts.map(i=>V.jsxs("section",{style:{marginTop:24,border:"1px solid #ddd",borderRadius:8,overflow:"hidden",background:"white"},children:[V.jsxs("h3",{style:{margin:16,fontSize:16},children:[i.issueIndex+1,"."," ",i.issue.lineItemType.replace(/([a-z])([A-Z])/g,"$1 $2"),i.schematicSheetId&&V.jsxs("small",{style:{display:"block",marginTop:4,color:"#525252"},children:["Sheet: ",i.schematicSheetId]})]}),V.jsx("img",{src:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i.content)}`,alt:i.descriptionXml,loading:"lazy",style:{display:"block",width:"100%",height:"auto"}})]},i.issueIndex))]})]})]})})},mU={IS_SHOWING_SCHEMATIC_GROUPS:"schematic_viewer_show_groups",IS_SHOWING_SCHEMATIC_PORTS:"schematic_viewer_show_ports",SELECTED_SCHEMATIC_SHEET:"schematic_viewer_selected_sheet"},E0n=(t,e)=>{if(typeof window>"u")return e;try{const n=localStorage.getItem(t);return n!==null?JSON.parse(n):e}catch{return e}},B0n=(t,e)=>{if(!(typeof window>"u"))try{localStorage.setItem(t,JSON.stringify(e))}catch{}},Gvi=t=>{if(typeof window>"u")return null;try{return localStorage.getItem(t)}catch{return null}},Yvi=(t,e)=>{if(!(typeof window>"u"))try{localStorage.setItem(t,e)}catch{}},b0n=["#8B0000","#2F4F4F","#191970","#006400","#FF4500","#800080","#2E8B57","#B8860B","#C71585","#008B8B"],Uvi=t=>{const{svgDivRef:e,circuitJson:n,circuitJsonKey:o,showGroups:i}=t;te.useEffect(()=>{if(e.current&&e.current.querySelectorAll(".schematic-group-overlay").forEach(a=>a.remove()),!e.current||!i||!n||n.length===0)return;const r=setTimeout(()=>{if(!e.current)return;const s=e.current.querySelector("svg");if(!s)return;s.querySelectorAll(".schematic-group-overlay").forEach(A=>A.remove());try{const A=V3(n).source_group?.list().filter(f=>!f.is_subcircuit)||[],c=V3(n).schematic_component?.list()||[],l=new Map;A.forEach(f=>{const I=f;if(I.parent_source_group_id){const C=l.get(I.parent_source_group_id)||[];C.push(f.source_group_id),l.set(I.parent_source_group_id,C)}});const g=f=>{const I=[],C=l.get(f)||[];for(const y of C)I.push(y),I.push(...g(y));return I},u=f=>{const I=A.find(C=>C.source_group_id===f);return I?.parent_source_group_id?1+u(I.parent_source_group_id):0},h=A.length>0&&A.some(f=>f.name&&f.name.trim()!=="");let d=[];if(h){const f=new Map;for(const I of c){const C=V3(n).source_component.get(I.source_component_id);C?.source_group_id&&(f.has(C.source_group_id)||f.set(C.source_group_id,[]),f.get(C.source_group_id).push(I))}A.forEach((I,C)=>{let y=f.get(I.source_group_id)||[];const x=g(I.source_group_id);for(const E of x){const B=f.get(E)||[];y=[...y,...B]}if(y.length>0){const E=u(I.source_group_id),B=g(I.source_group_id).length>0;if(I.name?.startsWith("unnamed_board"))return;d.push({id:I.source_group_id,name:I.name||`Group ${C+1}`,components:y,color:b0n[C%b0n.length],depthLevel:E,hasChildren:B,sourceGroupId:I.source_group_id})}})}const p=s.viewBox.baseVal,m=s.getBoundingClientRect(),_=Math.min(m.width/p.width,m.height/p.height)||1;d.sort((f,I)=>f.depthLevel-I.depthLevel),d.forEach(f=>{if(f.components.length===0)return;const I=Kvi(f.components,s);if(!I)return;const C=Math.max(8,Math.min(25,15/Math.max(_,.3))),y=f.hasChildren?C*.6:0,x=C+y,E=Math.max(1,2/Math.max(_,.5)),B=f.depthLevel===0?E:E*.7,S=Math.max(4,8/Math.max(_,.5)),Q=f.hasChildren?1.3:1,w=S*Q,M=w*.5,k=document.createElementNS("http://www.w3.org/2000/svg","rect");k.setAttribute("class","schematic-group-overlay"),k.setAttribute("x",(I.minX-x).toString()),k.setAttribute("y",(I.minY-x).toString()),k.setAttribute("width",(I.maxX-I.minX+x*2).toString()),k.setAttribute("height",(I.maxY-I.minY+x*2).toString()),k.setAttribute("fill","none"),k.setAttribute("stroke",f.color),k.setAttribute("stroke-width",B.toString()),k.setAttribute("stroke-dasharray",`${w},${M}`),k.setAttribute("opacity","0.8"),k.setAttribute("rx","0"),k.setAttribute("ry","0");const R=Math.max(6,Math.min(20,14/Math.max(_,.2))),F=f.depthLevel===0||f.depthLevel===1?0:f.depthLevel*.2,O=R*(1-F),U=Math.max(1,O*.2),Y=f.name,J=document.createElementNS("http://www.w3.org/2000/svg","text");J.setAttribute("font-size",O.toString()),J.setAttribute("font-family","Arial, sans-serif"),J.textContent=Y,s.appendChild(J);const ee=J.getBBox();s.removeChild(J);const W=ee.width+U*2,X=O+U*2,oe=I.minX-x,se=I.minY-x-X,ie=document.createElementNS("http://www.w3.org/2000/svg","rect");ie.setAttribute("class","schematic-group-overlay"),ie.setAttribute("x",oe.toString()),ie.setAttribute("y",(se-X).toString()),ie.setAttribute("width",W.toString()),ie.setAttribute("height",X.toString()),ie.setAttribute("fill","transparent"),ie.setAttribute("rx","0"),ie.setAttribute("ry","0");const ge=document.createElementNS("http://www.w3.org/2000/svg","text");ge.setAttribute("class","schematic-group-overlay"),ge.setAttribute("x",(oe+U).toString()),ge.setAttribute("y",(se+X-U).toString()),ge.setAttribute("fill",f.color),ge.setAttribute("font-size",O.toString()),ge.setAttribute("font-family","Arial, sans-serif"),ge.setAttribute("font-weight",f.depthLevel===0?"600":"500"),ge.setAttribute("stroke",f.color),ge.setAttribute("stroke-width",Math.max(.2,O*.02).toString()),ge.textContent=Y,s.appendChild(k),s.appendChild(ie),s.appendChild(ge)})}catch(A){console.error("Error creating group overlays:",A)}},10);return()=>clearTimeout(r)},[e,o,i])};function Kvi(t,e){let n=1/0,o=1/0,i=-1/0,r=-1/0;for(const a of t){let A=e.querySelector(`g[data-schematic-component-id="${a.schematic_component_id}"]`);if(A||(A=e.querySelector(`[data-schematic-component-id="${a.schematic_component_id}"]`)),A){const c=A.getBBox();n=Math.min(n,c.x),o=Math.min(o,c.y),i=Math.max(i,c.x+c.width),r=Math.max(r,c.y+c.height)}}return n===1/0?null:{minX:n,minY:o,maxX:i,maxY:r}}var hWe="sch-net-faded",S0n="g.trace[data-subcircuit-connectivity-map-key], g.trace-overlays[data-subcircuit-connectivity-map-key]",pWe="[data-schematic-net-label-id], [data-schematic-text-id]",Vvi=({svgDivRef:t,circuitJson:e,circuitJsonKey:n,enabled:o})=>{te.useEffect(()=>{const i=t.current;if(!o||!i)return;const{componentIdToKeys:r,netLabelIdToKey:s,textIdToKey:a}=dWe(e);let A=[];const c=new Map;let l=null;const g=()=>{for(const{el:_}of A)_.classList.remove(hWe);A=[],c.clear(),l=null;const m=i.querySelector("svg");if(m){for(const _ of Array.from(m.querySelectorAll(S0n))){const f=_.getAttribute("data-subcircuit-connectivity-map-key"),I=new Set;f&&(I.add(f),c.set(_,f)),A.push({el:_,keys:I})}for(const _ of Array.from(m.querySelectorAll("g[data-schematic-component-id]"))){const f=_.getAttribute("data-schematic-component-id");A.push({el:_,keys:r.get(f)??new Set})}for(const _ of Array.from(m.querySelectorAll(pWe))){const f=s.get(_.getAttribute("data-schematic-net-label-id"))??a.get(_.getAttribute("data-schematic-text-id")),I=new Set;f&&(I.add(f),c.set(_,f)),A.push({el:_,keys:I})}}},u=m=>{if(m!==l){l=m;for(const{el:_,keys:f}of A)_.classList.toggle(hWe,m!==null&&!f.has(m))}},h=m=>{const _=m.target;if(!(_ instanceof Element)){u(null);return}const f=_.closest(`${S0n}, ${pWe}`);if(f&&c.has(f)){u(c.get(f));return}for(const[I,C]of c){if(!I.matches(pWe))continue;const y=I.getBoundingClientRect();if(m.clientX>=y.left-6&&m.clientX<=y.right+6&&m.clientY>=y.top-6&&m.clientY<=y.bottom+6){u(C);return}}u(null)},d=()=>u(null);g(),i.addEventListener("mousemove",h),i.addEventListener("mouseleave",d);const p=new MutationObserver(g);return p.observe(i,{childList:!0}),()=>{p.disconnect(),i.removeEventListener("mousemove",h),i.removeEventListener("mouseleave",d);for(const{el:m}of A)m.classList.remove(hWe)}},[t,n,o])},mWe="http://www.w3.org/2000/svg",zvi=({svgDivRef:t,svgContent:e,circuitJsonKey:n})=>{const o=te.useRef(new Set);te.useLayoutEffect(()=>{o.current.clear()},[n]),te.useLayoutEffect(()=>{const i=[];for(const r of t.current?.querySelectorAll(".schematic-warning")??[]){const s=r.getAttribute("data-warning-id"),a=r.querySelector('[data-warning-reference="callout"]');if(!s||!a)continue;const A=Array.from(r.children),c=A.map(I=>I.style.display),l=r.getAttribute("role"),g=r.getAttribute("aria-label")??"Warning",u=document.createElementNS(mWe,"g");u.setAttribute("data-warning-icon",""),u.setAttribute("aria-hidden","true"),u.setAttribute("transform",`translate(${a.getAttribute("x")} ${a.getAttribute("y")})`);const h=document.createElementNS(mWe,"rect");h.setAttribute("width","24"),h.setAttribute("height","24"),h.setAttribute("fill",a.getAttribute("fill")??"#fffaeb"),h.setAttribute("stroke",a.getAttribute("stroke")??"#d99a00"),h.setAttribute("stroke-width","1");const d=document.createElementNS(mWe,"text");d.setAttribute("x","12"),d.setAttribute("y","12"),d.setAttribute("dominant-baseline","central"),d.setAttribute("text-anchor","middle"),d.setAttribute("font-size","16"),d.setAttribute("font-family","sans-serif"),d.setAttribute("font-weight","bold"),d.setAttribute("fill","#5c4300"),d.textContent="!",u.append(h,d),r.append(u),r.setAttribute("role","button"),r.setAttribute("tabindex","0"),r.style.cursor="pointer",r.style.outline="none";const p=()=>{const I=o.current.has(s);A.forEach((C,y)=>{C.style.display=I?"none":c[y]}),u.style.display=I?"":"none",r.setAttribute("aria-expanded",String(!I)),r.setAttribute("aria-label",`${I?"Expand":"Minimize"} warning: ${g}`)},m=I=>{I.preventDefault(),I.stopPropagation(),o.current.has(s)?o.current.delete(s):o.current.add(s),p()},_=I=>{(I.key==="Enter"||I.key===" ")&&(I.repeat?I.preventDefault():m(I))},f=I=>I.stopPropagation();r.addEventListener("click",m),r.addEventListener("keydown",_),r.addEventListener("mousedown",f),r.addEventListener("touchstart",f),p(),i.push(()=>{r.removeEventListener("click",m),r.removeEventListener("keydown",_),r.removeEventListener("mousedown",f),r.removeEventListener("touchstart",f),u.remove(),A.forEach((I,C)=>{I.style.display=c[C]}),l?r.setAttribute("role",l):r.removeAttribute("role"),r.setAttribute("aria-label",g),r.removeAttribute("aria-expanded"),r.removeAttribute("tabindex"),r.style.removeProperty("cursor"),r.style.removeProperty("outline")})}return()=>i.forEach(r=>r())},[t,e,n])},_We=t=>String(t??"").toLocaleLowerCase(),fZ=(t,e)=>{const n=_We(t);return n===e?0:n.startsWith(e)?1:n.includes(e)?2:Number.POSITIVE_INFINITY},Jvi=t=>{if(t)return String(t).replace(/^simple_/,"").replaceAll("_"," ").replace(/\b\w/g,e=>e.toLocaleUpperCase())},Wvi=(t,e,n)=>{let i=Jvi(t?.ftype);t?.ftype==="simple_chip"&&t.manufacturer_part_number&&(i=t.manufacturer_part_number);const r=[];t?.display_name===n&&t.name!==n&&r.push(t.name);let s=t?.display_value;if(!s&&t){for(const a of["display_resistance","display_capacitance","display_inductance","display_frequency","symbol_display_value"])if(a in t){const A=t[a];if(typeof A=="string"){s=A;break}}}if(s??(s=e.symbol_display_value),i&&r.push(i),s&&r.push(s),!i&&!s&&t?.manufacturer_part_number&&r.push(t.manufacturer_part_number),r.length!==0)return r.join(" · ")},jvi=t=>t.type==="source_component"&&"source_component_id"in t,Xvi=t=>t.type==="source_port",qvi=t=>t.type==="source_trace",$vi=t=>t.type==="schematic_component",Zvi=t=>t.type==="schematic_port",ewi=t=>t.type==="schematic_net_label",twi=t=>t.type==="schematic_sheet",fWe=({schematicSheets:t,schematicSheetId:e})=>{if(!(t.length<=1||!e))return t.find(n=>n.schematic_sheet_id===e)?.name},nwi=(t,e)=>{const n=_We(e).trim();if(!n)return[];const o=new Map(t.filter(jvi).map(l=>[l.source_component_id,l])),i=new Map(t.filter(Xvi).map(l=>[l.source_port_id,l])),r=t.filter(Zvi),s=t.filter(qvi),a=t.filter(twi),A=[],c=new Map;for(const l of t.filter($vi)){const g=l.source_component_id?o.get(l.source_component_id):void 0,u=g?.display_name??g?.name??"Component",h=Math.min(fZ(g?.name,n),fZ(g?.display_name,n),fZ(g?.manufacturer_part_number,n));if(Number.isFinite(h)){const d={label:u,detail:Wvi(g,l,u),kind:"component",schematicSheetId:l.schematic_sheet_id,schematicSheetName:fWe({schematicSheets:a,schematicSheetId:l.schematic_sheet_id}),target:{type:"schematic_component",id:l.schematic_component_id}};A.push(d),c.set(d,h)}}for(const l of t.filter(ewi)){if(!_We(l.text).includes(n))continue;const g=new Set;for(const I of s.filter(C=>C.connected_source_net_ids.includes(l.source_net_id)))for(const C of I.connected_source_port_ids)g.add(C);const u=l.anchor_position??l.center,h=r.filter(I=>g.has(I.source_port_id)&&(!l.schematic_sheet_id||!I.schematic_sheet_id||I.schematic_sheet_id===l.schematic_sheet_id)).map(I=>({port:I,distance:Math.hypot(I.center.x-u.x,I.center.y-u.y)})).filter(({distance:I})=>I<=1).sort((I,C)=>I.distance-C.distance)[0]?.port,d=h?i.get(h.source_port_id):void 0,p=d?.source_component_id?o.get(d.source_component_id):void 0,m=d?.name??(d?.pin_number!==void 0?`pin${d.pin_number}`:h?.display_pin_label),_=p?.name&&m?`Connected to ${p.name}.${m}`:void 0,f={label:l.text,detail:_,kind:"net",schematicSheetId:l.schematic_sheet_id,schematicSheetName:fWe({schematicSheets:a,schematicSheetId:l.schematic_sheet_id}),target:{type:"schematic_net_label",id:l.schematic_net_label_id}};A.push(f),c.set(f,fZ(l.text,n))}for(const l of t){if(l.type!=="schematic_text"||!l.source_trace_id)continue;const g=fZ(l.text,n);if(!Number.isFinite(g))continue;const u={label:l.text,kind:"net",schematicSheetId:l.schematic_sheet_id,schematicSheetName:fWe({schematicSheets:a,schematicSheetId:l.schematic_sheet_id}),target:{type:"schematic_text",id:l.schematic_text_id}};A.push(u),c.set(u,g)}return A.sort((l,g)=>(c.get(l)??Number.POSITIVE_INFINITY)-(c.get(g)??Number.POSITIVE_INFINITY)||l.label.localeCompare(g.label))},owi=({containerRect:t,targetRect:e,visibleProjection:n,minimumScale:o})=>{const i=n.a||1,r={x:e.left+e.width/2-t.left,y:e.top+e.height/2-t.top},s={x:(r.x-n.e)/i,y:(r.y-n.f)/i},a=Math.max(i,o);return{a,b:0,c:0,d:a,e:t.width/2-s.x*a,f:t.height/2-s.y*a}},iwi=1.8,Q0n=350,rwi=({controller:t,circuitJson:e,circuitJsonKey:n,svgDivRef:o,containerRef:i,activeSheetId:r,hasMultipleSheets:s,handleSelectSheet:a,svgString:A,svgToScreenProjection:c,setSvgToScreenProjection:l,setIsInteractionEnabled:g})=>{const[u,h]=te.useState(""),[d,p]=te.useState(null),m=te.useRef(null),_=te.useMemo(()=>nwi(e,u),[e,n,u]),f=te.useCallback(E=>{const B=o.current,S=i.current;if(!B||!S)return!1;const Q=`data-${E.target.type.replaceAll("_","-")}-id`,w=Array.from(B.querySelectorAll(`[${Q}]`)).find(O=>O.getAttribute(Q)===E.target.id);if(!w)return!1;let M=w.getBoundingClientRect();if(E.focusPoint){const O=w.closest("svg"),U=O?.getAttribute("data-real-to-screen-transform"),Y=O?.getScreenCTM?.();if(U&&Y){const J=Bn(Y,Bn(zV(U),E.focusPoint));M={left:J.x-1,top:J.y-1,width:2,height:2}}}const k=S.getBoundingClientRect();if(!k.width||!k.height||!M.width&&!M.height)return!1;m.current&&clearTimeout(m.current);let R=c;const F=getComputedStyle(B).transform;if(F&&F!=="none")try{R=zV(F),B.style.transition="none",B.style.transform=F,B.offsetWidth}catch{}return B.style.transition=`transform ${Q0n}ms ease-in-out`,B.offsetWidth,l(owi({containerRect:k,targetRect:M,visibleProjection:R,minimumScale:iwi})),m.current=setTimeout(()=>{B.style.transition=""},Q0n),B.querySelectorAll(".schematic-search-match").forEach(O=>O.classList.remove("schematic-search-match")),B.querySelectorAll(`[${Q}]`).forEach(O=>{O.getAttribute(Q)===E.target.id&&O.classList.add("schematic-search-match")}),!0},[i,l,o,c]),I=te.useCallback(E=>{if(g(!0),E.schematicSheetId&&E.schematicSheetId!==r&&s){a(E.schematicSheetId),p(E);return}f(E)},[r,f,a,s,g]),C=te.useCallback(()=>{h(""),p(null),m.current&&(clearTimeout(m.current),m.current=null),o.current&&(o.current.style.transition="",o.current.querySelectorAll(".schematic-search-match").forEach(E=>E.classList.remove("schematic-search-match")))},[o]),y=t?.focusRequest,x=t?.onFocusRequestHandled;return te.useEffect(()=>{if(!y)return;const E=e.find(B=>B.type==="schematic_component"&&B.schematic_component_id===y.schematicComponentId);if(E?.type!=="schematic_component"){p(null),x?.(y);return}g(!0),E.schematic_sheet_id&&s&&a(E.schematic_sheet_id),p({kind:"component",label:E.schematic_component_id,schematicSheetId:E.schematic_sheet_id,target:{type:"schematic_component",id:E.schematic_component_id}})},[y,x,e,n,s,a,g]),te.useEffect(()=>{if(!d||!A||s&&d.schematicSheetId&&d.schematicSheetId!==r)return;const E=requestAnimationFrame(()=>{f(d)&&(p(null),y?.schematicComponentId===d.target.id&&x?.(y))});return()=>cancelAnimationFrame(E)},[f,y,x,d,A,s,r]),te.useEffect(()=>{u||o.current?.querySelectorAll(".schematic-search-match").forEach(E=>E.classList.remove("schematic-search-match"))},[u,o]),te.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),{searchQuery:u,setSearchQuery:h,searchResults:_,handleSearchResultSelect:I,handleCancelSearch:C}};g0("schematic-viewer");var swi=()=>{g0.enable("schematic-viewer*")},v0n=t=>{const[e,n]=te.useState(0),[o,i]=te.useState(0);return te.useEffect(()=>{if(!t.current)return;const r=()=>{const a=t.current?.getBoundingClientRect();n(a?.width||0),i(a?.height||0)};r();const s=new ResizeObserver(r);return s.observe(t.current),window.addEventListener("resize",r),()=>{s.disconnect(),window.removeEventListener("resize",r)}},[]),{containerWidth:e,containerHeight:o}},awi=600,zme=10,Awi=({containerRef:t})=>{const[e,n]=te.useState(null),[o,i]=te.useState(!1),[r,s]=te.useState({x:0,y:0}),a=te.useRef(null),A=te.useRef(null),c=te.useRef(null),l=te.useRef(0),g=te.useCallback(()=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null)},[]),u=te.useCallback(_=>{if(_.preventDefault(),Date.now()<l.current)return;const f=A.current;if(!f)return;const I=Math.abs(_.clientX-f.x)>zme||Math.abs(_.clientY-f.y)>zme;A.current=null,!I&&(n(_.target instanceof Element?_.target:null),s({x:_.clientX,y:_.clientY}),i(!0))},[]),h=te.useCallback(_=>{if(g(),_.touches.length!==1){A.current=null;return}const f=_.touches[0];if(!f)return;const I=_.target instanceof Element?_.target:null;A.current={x:f.clientX,y:f.clientY},c.current=window.setTimeout(()=>{const C=t.current;if(!C||!A.current)return;n(I);const y=C.getBoundingClientRect();s({x:y.left+y.width/2,y:y.top+y.height/2}),i(!0),l.current=Date.now()+1e3,A.current=null},awi)},[g,t]),d=te.useCallback(_=>{const f=A.current;if(!f||_.touches.length!==1)return;const I=_.touches[0];(!I||Math.abs(I.clientX-f.x)>zme||Math.abs(I.clientY-f.y)>zme)&&(A.current=null,g())},[g]),p=te.useCallback(()=>{g(),A.current=null},[g]),m=te.useCallback(_=>{const f=_.target;a.current?.contains(f)||f.closest?.("[data-radix-popper-content-wrapper], [data-radix-dropdown-menu-content]")||i(!1)},[]);return te.useEffect(()=>{if(o)return document.addEventListener("mousedown",m),document.addEventListener("touchstart",m),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("touchstart",m)}},[m,o]),te.useEffect(()=>g,[g]),{menuVisible:o,menuTarget:e,menuPos:r,menuRef:a,setMenuVisible:i,contextMenuEventHandlers:{onMouseDown:_=>{A.current=_.button===2||_.button===0&&_.ctrlKey?{x:_.clientX,y:_.clientY}:null},onContextMenu:u,onTouchStart:h,onTouchMove:d,onTouchEnd:p,onTouchCancel:p}}},cwi=(t,e,n)=>t.filter(o=>{if(!o.type.endsWith("_warning"))return!1;const i=o;return[["source_component",e.source_component_id],["schematic_component",e.schematic_component_id],["pcb_component",n?.pcb_component_id]].some(([s,a])=>{if(!a)return!1;const A=i[`${s}_ids`];return i[`${s}_id`]===a||Array.isArray(A)&&A.includes(a)||i.schematic_element_type===s&&i.schematic_element_id===a})}),lwi=new Set(["type","source_component_id","source_group_id","subcircuit_id","display_name","ftype","are_pins_interchangeable","supplier_part_numbers"]),w0n=["name","resistance","capacitance","inductance","frequency","voltage","current","max_voltage_rating","max_current_rating","power_rating","manufacturer_part_number"],gwi={jlcpcb:t=>`https://jlcpcb.com/partdetail/${encodeURIComponent(t)}`,lcsc:t=>`https://www.lcsc.com/product-detail/${encodeURIComponent(t)}.html`},uwi=t=>{const e=t.trim(),n=/^c?(\d+)$/i.exec(e);return n?`C${n[1]}`:e},P0n=t=>{const e=w0n.indexOf(t);return e===-1?w0n.length:e},dwi=(t,e,n)=>{if(e==="name")return String(n);const o=t[`display_${e}`];if(typeof o=="string"&&o.trim()){const i=e==="resistance"?o.replace(/Ω$/,""):o;return JSON.stringify(i)}return JSON.stringify(n)??String(n)},hwi=t=>Object.entries(t).filter(([e,n])=>lwi.has(e)||e.startsWith("display_")&&e.slice(8)in t?!1:n!=null&&n!=="").sort(([e],[n])=>P0n(e)-P0n(n)||e.localeCompare(n)).map(([e,n])=>({key:e,label:e,value:dwi(t,e,n)})),pwi=t=>{const e=t.supplier_part_numbers;return e?["jlcpcb","lcsc"].flatMap(n=>{const o=e[n];if(!Array.isArray(o))return[];const i=[...new Set(o.filter(r=>!!(typeof r=="string"&&r.trim())).map(uwi))];return i.length?[{key:`supplier_part_numbers.${n}`,label:n,links:i.map(r=>({partNumber:r,href:gwi[n](r)}))}]:[]}):[]},mwi=(t,e)=>{const n=t.find(A=>A.type==="schematic_component"&&A.schematic_component_id===e);if(!n)return null;const o=t.find(A=>A.type==="source_component"&&A.source_component_id===n.source_component_id);if(!o)return null;const i=t.find(A=>A.type==="pcb_component"&&A.source_component_id===o.source_component_id),r=t.find(A=>A.type==="cad_component"&&A.source_component_id===o.source_component_id&&(!i||A.pcb_component_id===i.pcb_component_id)),s=i?.footprinter_string??r?.footprinter_string,a=i?_wi(t,i.pcb_component_id):null;return{schematicComponent:n,sourceComponent:o,pcbComponent:i,footprinterString:s,footprintPreviewCircuitJson:a?.circuitJson,footprintPreviewViewBox:a?.viewBox,warnings:cwi(t,n,i)}},Jme=2,_wi=(t,e)=>{const n=t.find(r=>r.type==="pcb_component"&&r.pcb_component_id===e);if(!n)return null;const o=Cln(n);if(!o)return null;const i={minX:o.minX-Jme,minY:o.minY-Jme,maxX:o.maxX+Jme,maxY:o.maxY+Jme};return{circuitJson:bSi(t,i),viewBox:i}},fwi=t=>{let e="";for(let o=0;o<t.length;o+=8192)e+=String.fromCharCode(...t.subarray(o,o+8192));return btoa(e)},Iwi=(t,e)=>{const n=fwi(Exe(Bxe(JSON.stringify(t)))),o=new URL("https://svg.tscircuit.com/");return o.searchParams.set("svg_type","pcb"),o.searchParams.set("circuit_json",n),o.searchParams.set("viewbox",[e.minX,e.minY,e.maxX,e.maxY].join(",")),o.searchParams.set("background_color","#f8fafc"),o.toString()},IWe=te.createContext(null),Cwi=5,ywi=(t,e)=>!t&&!e?!0:!t||!e?!1:t.minX===e.minX&&t.maxX===e.maxX&&t.minY===e.minY&&t.maxY===e.maxY,xwi=({children:t})=>te.useContext(IWe)?V.jsx(V.Fragment,{children:t}):V.jsx(Ewi,{children:t}),Ewi=({children:t})=>{const e=te.useRef({pointer:null,boundingBoxes:new Map,hoveringIds:new Set,subscribers:new Set,mouseDownPosition:null}),n=te.useCallback(()=>{for(const l of e.current.subscribers)l()},[]),o=te.useCallback(()=>{const l=e.current.pointer,g=new Set;if(l)for(const[h,d]of e.current.boundingBoxes){const p=d.bounds;p&&l.x>=p.minX&&l.x<=p.maxX&&l.y>=p.minY&&l.y<=p.maxY&&g.add(h)}const u=e.current.hoveringIds;g.size===u.size&&[...g].every(h=>u.has(h))||(e.current.hoveringIds=g,n())},[n]),i=te.useCallback((l,g)=>{e.current.boundingBoxes.set(l,g),o()},[o]),r=te.useCallback((l,g)=>{const u=e.current.boundingBoxes.get(l);u&&ywi(u.bounds,g.bounds)&&u.onClick===g.onClick||(e.current.boundingBoxes.set(l,g),o())},[o]),s=te.useCallback(l=>{e.current.boundingBoxes.delete(l)&&o()},[o]),a=te.useCallback(l=>(e.current.subscribers.add(l),()=>{e.current.subscribers.delete(l)}),[]),A=te.useCallback(l=>e.current.hoveringIds.has(l),[]);te.useEffect(()=>{const l=d=>{const{clientX:p,clientY:m}=d,_=e.current.pointer;_&&_.x===p&&_.y===m||(e.current.pointer={x:p,y:m},o())},g=()=>{e.current.pointer!==null&&(e.current.pointer=null,e.current.mouseDownPosition=null,o())},u=d=>{e.current.mouseDownPosition={x:d.clientX,y:d.clientY}},h=d=>{const{clientX:p,clientY:m}=d,_=e.current.mouseDownPosition;if(_&&Math.sqrt(Math.pow(p-_.x,2)+Math.pow(m-_.y,2))>Cwi){e.current.mouseDownPosition=null;return}e.current.mouseDownPosition=null;for(const f of e.current.boundingBoxes.values()){const I=f.bounds;I&&p>=I.minX&&p<=I.maxX&&m>=I.minY&&m<=I.maxY&&f.onClick?.(d)}};return window.addEventListener("pointermove",l,{passive:!0}),window.addEventListener("pointerdown",l,{passive:!0}),window.addEventListener("pointerup",l,{passive:!0}),window.addEventListener("pointerleave",g),window.addEventListener("pointercancel",g),window.addEventListener("blur",g),window.addEventListener("mousedown",u,{passive:!0}),window.addEventListener("click",h,{passive:!0}),()=>{window.removeEventListener("pointermove",l),window.removeEventListener("pointerdown",l),window.removeEventListener("pointerup",l),window.removeEventListener("pointerleave",g),window.removeEventListener("pointercancel",g),window.removeEventListener("blur",g),window.removeEventListener("mousedown",u),window.removeEventListener("click",h)}},[o]);const c=te.useMemo(()=>({registerBoundingBox:i,updateBoundingBox:r,unregisterBoundingBox:s,subscribe:a,isHovering:A}),[i,r,s,a,A]);return V.jsx(IWe.Provider,{value:c,children:t})},CWe={color:"#64748b",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace',fontSize:"12px",lineHeight:1.45},Bwi=({sourceComponent:t,warnings:e=[],footprinterString:n,footprintPreviewCircuitJson:o,footprintPreviewViewBox:i,left:r,top:s,width:a,maxHeight:A})=>{const c=te.useMemo(()=>hwi(t),[t]),l=te.useMemo(()=>pwi(t),[t]),g=te.useMemo(()=>o?.length&&i?Iwi(o,i):void 0,[o,i]);return V.jsxs("dialog",{open:!0,"aria-label":`${t.name} component details`,"data-schematic-component-details-tooltip":!0,style:{position:"absolute",left:r,right:"auto",top:s,bottom:"auto",width:a,maxHeight:A,margin:0,padding:0,overflowY:"auto",overscrollBehavior:"contain",cursor:"auto",boxSizing:"border-box",border:"1px solid #cbd5e1",borderRadius:"4px",backgroundColor:"rgba(255, 255, 255, 0.98)",boxShadow:"0 20px 25px -5px rgba(15, 23, 42, 0.18), 0 8px 10px -6px rgba(15, 23, 42, 0.12)",color:"#0f172a",fontFamily:'Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',pointerEvents:"auto",userSelect:"text",WebkitUserSelect:"text",zIndex:CE.schematicComponentDetailsTooltip},onMouseDown:u=>u.stopPropagation(),onClick:u=>u.stopPropagation(),onWheel:u=>u.stopPropagation(),children:[V.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"minmax(110px, 0.8fr) minmax(0, 1.2fr)",gap:"6px 12px",margin:0,padding:"8px"},children:[c.map(u=>V.jsxs("div",{style:{display:"contents"},children:[V.jsx("dt",{style:CWe,children:u.label}),V.jsx("dd",{style:{minWidth:0,margin:0,color:"#1e293b",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace',fontSize:"12px",lineHeight:1.45,overflowWrap:"anywhere"},children:u.value})]},u.key)),l.map(u=>V.jsxs("div",{style:{display:"contents"},children:[V.jsx("dt",{style:CWe,children:u.label}),V.jsx("dd",{style:{minWidth:0,margin:0,fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace',fontSize:"12px",lineHeight:1.45,overflowWrap:"anywhere"},children:u.links.map((h,d)=>V.jsxs("span",{children:[d>0&&", ",V.jsx("a",{href:h.href,target:"_blank",rel:"noreferrer noopener",style:{color:"#2563eb",textDecoration:"underline"},children:h.partNumber})]},h.href))})]},u.key)),n&&V.jsxs("div",{style:{display:"contents"},children:[V.jsx("dt",{style:CWe,children:"footprint"}),V.jsx("dd",{style:{minWidth:0,margin:0,color:"#1e293b",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace',fontSize:"12px",lineHeight:1.45,overflowWrap:"anywhere"},children:JSON.stringify(n)})]})]}),e.length>0&&V.jsxs("section",{"aria-label":"Component warnings",style:{margin:"0 8px 8px",padding:"8px",border:"1px solid #fcd34d",borderRadius:"4px",backgroundColor:"#fffbeb",color:"#92400e",fontSize:"12px",lineHeight:1.45,overflowWrap:"anywhere"},children:[V.jsxs("strong",{children:["Warnings (",e.length,")"]}),V.jsx("ul",{style:{margin:"4px 0 0",paddingLeft:"18px"},children:e.map((u,h)=>V.jsx("li",{children:u.message},`${u.type}-${h}`))})]}),g&&V.jsx("div",{style:{padding:"0 4px 4px"},children:V.jsx("div",{style:{height:"210px",overflow:"hidden",border:"1px solid #e2e8f0",borderRadius:"2px",background:"#f8fafc"},children:V.jsx("img",{src:g,alt:`${t.name}${n?` ${n}`:""} PCB footprint`,loading:"lazy",referrerPolicy:"no-referrer",style:{display:"block",width:"100%",height:"100%",objectFit:"contain"}})})})]})},M0n=t=>{const e=te.useContext(IWe);if(!e)throw new Error("useMouseEventsOverBoundingBox must be used within a MouseTracker");const n=te.useId(),o=te.useRef(t);o.current=t;const i=te.useMemo(()=>s=>{o.current.onClick?.(s)},[]);return te.useEffect(()=>(e.registerBoundingBox(n,{bounds:o.current.bounds,onClick:o.current.onClick?i:void 0}),()=>{e.unregisterBoundingBox(n)}),[e,i,n]),te.useEffect(()=>{e.updateBoundingBox(n,{bounds:o.current.bounds,onClick:o.current.onClick?i:void 0})},[e,i,n,t.bounds?.minX,t.bounds?.maxX,t.bounds?.minY,t.bounds?.maxY,t.onClick]),{hovering:te.useSyncExternalStore(e.subscribe,()=>e.isHovering(n),()=>!1)}},bwi=(t,e)=>!t&&!e?!0:!t||!e?!1:Math.abs(t.bounds.minX-e.bounds.minX)<.5&&Math.abs(t.bounds.maxX-e.bounds.maxX)<.5&&Math.abs(t.bounds.minY-e.bounds.minY)<.5&&Math.abs(t.bounds.maxY-e.bounds.maxY)<.5&&Math.abs(t.rect.left-e.rect.left)<.5&&Math.abs(t.rect.top-e.rect.top)<.5&&Math.abs(t.rect.width-e.rect.width)<.5&&Math.abs(t.rect.height-e.rect.height)<.5,Swi=({componentId:t,svgDivRef:e,containerRef:n,onComponentClick:o,onHoverChange:i,showOutline:r,circuitJsonKey:s})=>{const[a,A]=te.useState(null),c=te.useRef(null),l=te.useCallback(()=>{c.current=null;const m=e.current,_=n.current;if(!m||!_){A(x=>x&&null);return}const f=m.querySelector(`[data-schematic-component-id="${t}"]`);if(!f){A(x=>x&&null);return}const I=f.getBoundingClientRect(),C=_.getBoundingClientRect(),y={bounds:{minX:I.left,maxX:I.right,minY:I.top,maxY:I.bottom},rect:{left:I.left-C.left,top:I.top-C.top,width:I.width,height:I.height}};A(x=>bwi(x,y)?x:y)},[t,n,e]),g=te.useCallback(()=>{c.current===null&&(c.current=window.requestAnimationFrame(l))},[l]);te.useEffect(()=>{g()},[g,s]),te.useEffect(()=>{g();const m=e.current,_=n.current;if(!m||!_)return;const f=typeof ResizeObserver<"u"?new ResizeObserver(()=>{g()}):null;f?.observe(_),f?.observe(m);const I=typeof MutationObserver<"u"?new MutationObserver(()=>{g()}):null;return I?.observe(m,{attributes:!0,attributeFilter:["style","transform"],subtree:!0,childList:!0}),window.addEventListener("scroll",g,!0),window.addEventListener("resize",g),()=>{f?.disconnect(),I?.disconnect(),window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",g),c.current!==null&&(cancelAnimationFrame(c.current),c.current=null)}},[g,e,n]);const u=te.useCallback(m=>{o&&o(t,m)},[t,o]),h=a?.bounds??null,{hovering:d}=M0n({bounds:h,onClick:o?u:void 0});if(te.useEffect(()=>{i&&i(t,d)},[d,t,i]),!a||!d||!r)return null;const p=a.rect;return V.jsx("div",{style:{position:"absolute",left:p.left,top:p.top,width:p.width,height:p.height,border:"1.5px solid rgba(51, 153, 255, 0.9)",pointerEvents:"none",zIndex:CE.schematicComponentHoverOutline}})},Qwi=(t,e)=>!t&&!e?!0:!t||!e?!1:Math.abs(t.bounds.minX-e.bounds.minX)<.5&&Math.abs(t.bounds.maxX-e.bounds.maxX)<.5&&Math.abs(t.bounds.minY-e.bounds.minY)<.5&&Math.abs(t.bounds.maxY-e.bounds.maxY)<.5&&Math.abs(t.rect.left-e.rect.left)<.5&&Math.abs(t.rect.top-e.rect.top)<.5&&Math.abs(t.rect.width-e.rect.width)<.5&&Math.abs(t.rect.height-e.rect.height)<.5,vwi=({portId:t,portLabel:e,svgDivRef:n,containerRef:o,onPortClick:i,onHoverChange:r,showOutline:s,circuitJsonKey:a})=>{const[A,c]=te.useState(null),l=te.useRef(null),g=te.useCallback(()=>{l.current=null;const _=n.current,f=o.current;if(!_||!f){c(B=>B&&null);return}const I=_.querySelector(`[data-schematic-port-id="${t}"]`);if(!I){c(B=>B&&null);return}const C=I.getBoundingClientRect(),y=f.getBoundingClientRect(),x=4,E={bounds:{minX:C.left-x,maxX:C.right+x,minY:C.top-x,maxY:C.bottom+x},rect:{left:C.left-y.left-x,top:C.top-y.top-x,width:C.width+x*2,height:C.height+x*2}};c(B=>Qwi(B,E)?B:E)},[t,o,n]),u=te.useCallback(()=>{l.current===null&&(l.current=window.requestAnimationFrame(g))},[g]);te.useEffect(()=>{u()},[u,a]),te.useEffect(()=>{u();const _=n.current,f=o.current;if(!_||!f)return;const I=typeof ResizeObserver<"u"?new ResizeObserver(()=>{u()}):null;I?.observe(f),I?.observe(_);const C=typeof MutationObserver<"u"?new MutationObserver(()=>{u()}):null;return C?.observe(_,{attributes:!0,attributeFilter:["style","transform"],subtree:!0,childList:!0}),window.addEventListener("scroll",u,!0),window.addEventListener("resize",u),()=>{I?.disconnect(),C?.disconnect(),window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u),l.current!==null&&(cancelAnimationFrame(l.current),l.current=null)}},[u,n,o]);const h=te.useCallback(_=>{i&&i(t,_)},[t,i]),d=A?.bounds??null,{hovering:p}=M0n({bounds:d,onClick:i?h:void 0});if(te.useEffect(()=>{r&&r(t,p)},[p,t,r]),!A||!s)return null;const m=A.rect;return V.jsxs(V.Fragment,{children:[V.jsx("div",{style:{position:"absolute",left:m.left,top:m.top,width:m.width,height:m.height,border:p?"1.5px solid rgba(255, 153, 51, 0.9)":"1.5px solid rgba(255, 153, 51, 0.3)",backgroundColor:p?"rgba(255, 153, 51, 0.15)":"rgba(255, 153, 51, 0.05)",borderRadius:"50%",pointerEvents:"none",zIndex:CE.schematicPortHoverOutline,transition:"border-color 0.15s, background-color 0.15s"}}),p&&e&&V.jsx("div",{style:{position:"absolute",left:m.left+m.width/2,top:m.top-24,transform:"translateX(-50%)",backgroundColor:"rgba(0, 0, 0, 0.85)",color:"white",padding:"4px 8px",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",whiteSpace:"nowrap",pointerEvents:"none",zIndex:CE.schematicPortHoverOutline+1},children:e})]})},IZ=({children:t,size:e,strokeWidth:n})=>V.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t}),D0n=t=>V.jsxs(IZ,{...t,children:[V.jsx("circle",{cx:"11",cy:"11",r:"8"}),V.jsx("path",{d:"m21 21-4.34-4.34"})]}),wwi=t=>V.jsxs(IZ,{...t,children:[V.jsx("path",{d:"M18 6 6 18"}),V.jsx("path",{d:"m6 6 12 12"})]}),Pwi=t=>V.jsxs(IZ,{...t,children:[V.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),V.jsx("rect",{x:"8",y:"8",width:"8",height:"8",rx:"1"}),V.jsx("path",{d:"M7 2v2M12 2v2M17 2v2M7 20v2M12 20v2M17 20v2M2 7h2M2 12h2M2 17h2M20 7h2M20 12h2M20 17h2"})]}),Mwi=t=>V.jsxs(IZ,{...t,children:[V.jsx("path",{d:"M15 6a9 9 0 0 0-9 9V3"}),V.jsx("circle",{cx:"18",cy:"6",r:"3"}),V.jsx("circle",{cx:"6",cy:"18",r:"3"})]}),Dwi=t=>V.jsxs(IZ,{...t,children:[V.jsx("path",{d:"M20 4v7a4 4 0 0 1-4 4H4"}),V.jsx("path",{d:"m9 10-5 5 5 5"})]}),Nwi=({text:t,query:e})=>{const n=e.trim().toLocaleLowerCase();if(!n)return t;const o=t.toLocaleLowerCase(),i=[];let r=0,s=o.indexOf(n);for(;s!==-1;)s>r&&i.push(t.slice(r,s)),i.push(V.jsx("strong",{style:{fontWeight:700},children:t.slice(s,s+n.length)},`${s}-${r}`)),r=s+n.length,s=o.indexOf(n,r);return r<t.length&&i.push(t.slice(r)),i.length>0?i:t},Rwi=()=>typeof navigator>"u"?"Ctrl F":/mac/i.test(navigator.platform)?"⌘ F":"Ctrl F",Twi=({query:t,onQueryChange:e,onCancel:n,results:o,onSelect:i,viewerContainerRef:r})=>{const[s,a]=te.useState(!1),[A,c]=te.useState(null),[l,g]=te.useState(null),u=te.useRef(null),h=te.useRef(null),d=Rwi();te.useEffect(()=>{c(S=>o.some(Q=>Q.target.id===S)?S:o.find(Q=>Q.kind==="component")?.target.id??o[0]?.target.id??null)},[o]),te.useEffect(()=>{A&&h.current?.querySelector(`[data-search-result-id="${A}"]`)?.scrollIntoView({behavior:"smooth",block:"nearest"})},[A]),te.useEffect(()=>{const S=w=>{if(w.key==="Escape"&&s){w.preventDefault(),w.stopPropagation(),w.stopImmediatePropagation(),n(),a(!1),u.current?.blur();return}w.code!=="KeyF"&&w.key.toLocaleLowerCase()!=="f"||!w.metaKey&&!w.ctrlKey||r.current?.matches(":hover")&&(w.preventDefault(),w.stopPropagation(),w.stopImmediatePropagation(),a(!0),requestAnimationFrame(()=>{u.current?.focus(),u.current?.select()}))},Q=[window];try{window.parent!==window&&window.parent.document&&Q.push(window.parent)}catch{}return Q.forEach(w=>w.addEventListener("keydown",S,{capture:!0})),()=>{Q.forEach(w=>w.removeEventListener("keydown",S,{capture:!0}))}},[s,n,r]);const p=()=>{n(),a(!1),u.current?.blur()},m=S=>{a(!0),S&&requestAnimationFrame(()=>u.current?.focus())},_=o.filter(S=>S.kind==="component"),f=o.filter(S=>S.kind==="net"),I=[..._,...f],C=I.find(S=>S.target.id===A)??I[0],y=o.length===1?"1 result":`${o.length} results`;let x="none";t&&(x="1px solid #e8e8e8");const E=S=>{if(!(S.key==="Enter"&&S.target instanceof Element&&S.target.closest('[aria-label="Clear search"]'))){if(S.key==="Escape"){S.preventDefault(),p();return}if(I.length>0&&(S.key==="ArrowDown"||S.key==="ArrowUp")){S.preventDefault();let Q=-1;S.key==="ArrowDown"&&(Q=1),c(w=>{const M=I.findIndex(F=>F.target.id===w);let k=M;M===-1&&(k=0,Q===1&&(k=-1));const R=(k+Q+I.length)%I.length;return I[R]?.target.id??null});return}S.key==="Enter"&&C&&(S.preventDefault(),i(C))}},B=(S,Q)=>Q.length===0?null:V.jsxs("section",{children:[V.jsx("div",{style:{padding:"6px 12px 3px",backgroundColor:"#f7f7f8",color:"#777777",fontSize:"11px",fontWeight:600,letterSpacing:"0.02em",textTransform:"lowercase"},children:S}),Q.map(w=>{const M=w.target.id===C?.target.id,k=w.target.id===l;let R="#ffffff";(k||M)&&(R="#f1f3f5");let F=V.jsx(Mwi,{size:15,strokeWidth:1.8});w.kind==="component"&&(F=V.jsx(Pwi,{size:15,strokeWidth:1.8}));const O=()=>{u.current?.blur(),c(w.target.id),i(w)};return V.jsxs("button",{type:"button","data-search-result-id":w.target.id,onPointerUp:U=>{U.button===0&&O()},onClick:U=>{U.detail===0&&O()},onMouseEnter:()=>g(w.target.id),onMouseLeave:()=>g(null),style:{width:"100%",display:"flex",alignItems:"center",gap:"9px",padding:"7px 12px",border:"none",background:R,color:"#222222",cursor:"pointer",textAlign:"left"},children:[V.jsx("span",{style:{width:"26px",height:"26px",flexShrink:0,display:"grid",placeItems:"center",border:"1px solid #e5e5e5",borderRadius:"6px",backgroundColor:"#f7f7f7",color:"#666666"},children:F}),V.jsxs("span",{style:{minWidth:0,flex:1},children:[V.jsx("span",{style:{display:"block",overflow:"hidden",fontSize:"13px",fontWeight:400,lineHeight:1.25,textOverflow:"ellipsis",whiteSpace:"nowrap"},children:V.jsx(Nwi,{text:w.label,query:t})}),w.detail&&V.jsx("span",{style:{display:"block",overflow:"hidden",marginTop:"2px",color:"#777777",fontSize:"11px",lineHeight:1.2,textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.detail}),w.schematicSheetName&&V.jsxs("span",{style:{display:"block",overflow:"hidden",marginTop:"2px",color:"#777777",fontSize:"11px",lineHeight:1.2,textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["Sheet: ",w.schematicSheetName]})]}),M&&V.jsx("span",{title:"Press Enter to open",style:{flexShrink:0,color:"#666666",fontSize:"17px",lineHeight:1},children:V.jsx(Dwi,{size:14,strokeWidth:1.8})})]},w.target.id)})]});return V.jsx("div",{"data-schematic-search":!0,onPointerDown:S=>S.stopPropagation(),onMouseDown:S=>S.stopPropagation(),onTouchStart:S=>S.stopPropagation(),onTouchEnd:S=>S.stopPropagation(),style:{position:"relative",zIndex:CE.schematicSearch,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'},children:s?V.jsxs("div",{onKeyDown:E,style:{width:"min(280px, calc(100vw - 32px))",overflow:"hidden",border:"none",borderRadius:"4px",backgroundColor:"#ffffff",boxShadow:"0 2px 4px rgba(0,0,0,0.1)"},children:[V.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",height:"32px",boxSizing:"border-box",padding:"0 12px",borderBottom:x},children:[V.jsx(D0n,{size:15,strokeWidth:2}),V.jsx("input",{ref:u,value:t,"aria-label":"Search components and nets",placeholder:"Search...",onPointerUp:S=>S.currentTarget.focus(),onChange:S=>e(S.target.value),style:{minWidth:0,flex:1,border:"none",outline:"none",fontSize:"13px",color:"#222222",background:"transparent"}}),t&&o.length>0?V.jsx("span",{style:{flexShrink:0,color:"#888888",fontSize:"12px",whiteSpace:"nowrap"},children:y}):V.jsx("kbd",{style:{flexShrink:0,padding:"2px 5px",border:"1px solid #dddddd",borderRadius:"4px",backgroundColor:"#f7f7f7",color:"#777777",fontFamily:"inherit",fontSize:"10px",lineHeight:1.2},children:d}),s&&V.jsx("button",{type:"button","aria-label":"Clear search",onPointerUp:S=>{S.button===0&&p()},onClick:S=>{S.detail===0&&p()},style:{border:"none",background:"transparent",color:"#777777",cursor:"pointer",width:"20px",height:"20px",display:"grid",placeItems:"center",padding:0,lineHeight:1},children:V.jsx(wwi,{size:16,strokeWidth:2})})]}),t&&V.jsx("div",{ref:h,style:{maxHeight:"240px",overflowX:"hidden",overflowY:"auto",overscrollBehavior:"contain",scrollBehavior:"smooth",touchAction:"pan-y",WebkitOverflowScrolling:"touch"},onWheel:S=>S.stopPropagation(),onTouchMove:S=>S.stopPropagation(),children:o.length===0?V.jsx("div",{style:{padding:"12px",color:"#777777",fontSize:"13px"},children:"No matching components or nets"}):V.jsxs(V.Fragment,{children:[B("components",_),B("nets",f)]})})]}):V.jsx("button",{type:"button",title:"Search schematic","aria-label":"Search schematic",onPointerDown:S=>{S.stopPropagation(),S.pointerType!=="mouse"&&m(!1)},onPointerUp:S=>{S.pointerType==="mouse"&&S.button===0&&m(!0)},onClick:S=>{S.detail===0&&m(!0)},style:{width:"32px",height:"32px",display:"grid",placeItems:"center",padding:0,border:"none",borderRadius:"4px",backgroundColor:"#ffffff",color:"#000000",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)"},children:V.jsx(D0n,{size:16,strokeWidth:2})})})},yWe='system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',kwi={backgroundColor:"#ffffff",color:"#111111",borderRadius:8,boxShadow:"0 6px 24px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.08)",border:"1px solid #e5e7eb",padding:4,minWidth:200,maxWidth:320,maxHeight:320,overflowY:"auto",fontSize:13,fontFamily:yWe,outline:"none",zIndex:CE.viewMenu},Fwi={display:"flex",alignItems:"center",gap:8,padding:"7px 10px 7px 8px",borderRadius:6,cursor:"pointer",outline:"none",userSelect:"none",color:"#111111",fontSize:13,fontFamily:yWe},Lwi={width:16,height:16,flexShrink:0,display:"inline-flex",alignItems:"center",justifyContent:"center",color:"#111111"},N0n={overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Hwi=`
|
|
5508
5508
|
.sv-sheet-item[data-highlighted], .sv-sheet-item:hover { background-color: #f1f3f5; }
|
|
5509
5509
|
.sv-sheet-chevron { transition: transform 0.2s ease; }
|
|
5510
5510
|
[data-state="open"] > .sv-sheet-chevron { transform: rotate(180deg); }
|
|
5511
|
-
`,Owi=()=>V.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:V.jsx("path",{d:"M20 6 9 17l-5-5"})}),Gwi=({className:t})=>V.jsx("svg",{className:t,width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.6,flexShrink:0},"aria-hidden":"true",children:V.jsx("path",{d:"m6 9 6 6 6-6"})}),Ywi=({sheets:t,selectedSheetId:e,onSelectSheet:n})=>{const[o,i]=te.useState(!1);if(t.length<=1)return null;const s=t.find(a=>a.schematic_sheet_id===e)?.name??"Select sheet";return V.jsxs(V.Fragment,{children:[V.jsx("style",{children:Hwi}),V.jsxs(_me,{open:o,onOpenChange:i,modal:!1,children:[V.jsx(fme,{asChild:!0,children:V.jsxs("button",{type:"button",title:s,onPointerDown:a=>a.stopPropagation(),style:{display:"flex",alignItems:"center",gap:"6px",maxWidth:"220px",height:"32px",boxSizing:"border-box",padding:"0 12px",backgroundColor:"#ffffff",color:"#000000",border:"none",outline:"none",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",fontSize:"13px",fontFamily:yWe},children:[V.jsx("span",{style:{color:"#888888",flexShrink:0},children:"Sheet:"}),V.jsx("span",{style:{...N0n,minWidth:0},children:s}),V.jsx(Gwi,{className:"sv-sheet-chevron"})]})}),V.jsx(aU,{children:V.jsx(nZ,{style:kwi,side:"bottom",align:"start",sideOffset:8,collisionPadding:10,children:t.map(a=>{const A=a.schematic_sheet_id===e;return V.jsxs(_S,{className:"sv-sheet-item",style:Fwi,title:a.name,onSelect:c=>c.preventDefault(),onPointerUp:()=>{n(a.schematic_sheet_id),i(!1)},children:[V.jsx("span",{style:Lwi,children:A&&V.jsx(Owi,{})}),V.jsx("span",{style:{...N0n,minWidth:0},children:a.name})]},a.schematic_sheet_id)})})})]})]})},Uwi=({count:t,showWarnings:e,onToggle:n})=>{const o=`${e?"Hide":"Show"} ${t} ${t===1?"warning":"warnings"}`;return V.jsxs("button",{type:"button","data-schematic-warnings":!0,title:o,"aria-label":o,"aria-pressed":e,onClick:n,onPointerDown:i=>i.stopPropagation(),onMouseDown:i=>i.stopPropagation(),onTouchStart:i=>i.stopPropagation(),onTouchEnd:i=>i.stopPropagation(),style:{height:"32px",display:"flex",alignItems:"center",gap:"4px",padding:"0 8px",border:"none",borderRadius:"4px",backgroundColor:e?"#fff3cd":"#ffffff",color:"#946200",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',fontSize:"12px",fontWeight:600},children:[V.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[V.jsx("path",{d:"M10.3 3.9 1.8 18.1A2 2 0 0 0 3.5 21h17a2 2 0 0 0 1.7-2.9L13.7 3.9a2 2 0 0 0-3.4 0Z"}),V.jsx("path",{d:"M12 9v4m0 4h.01"})]}),V.jsx("span",{children:t})]})},Kwi={version:"2.0.
|
|
5511
|
+
`,Owi=()=>V.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:V.jsx("path",{d:"M20 6 9 17l-5-5"})}),Gwi=({className:t})=>V.jsx("svg",{className:t,width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.6,flexShrink:0},"aria-hidden":"true",children:V.jsx("path",{d:"m6 9 6 6 6-6"})}),Ywi=({sheets:t,selectedSheetId:e,onSelectSheet:n})=>{const[o,i]=te.useState(!1);if(t.length<=1)return null;const s=t.find(a=>a.schematic_sheet_id===e)?.name??"Select sheet";return V.jsxs(V.Fragment,{children:[V.jsx("style",{children:Hwi}),V.jsxs(_me,{open:o,onOpenChange:i,modal:!1,children:[V.jsx(fme,{asChild:!0,children:V.jsxs("button",{type:"button",title:s,onPointerDown:a=>a.stopPropagation(),style:{display:"flex",alignItems:"center",gap:"6px",maxWidth:"220px",height:"32px",boxSizing:"border-box",padding:"0 12px",backgroundColor:"#ffffff",color:"#000000",border:"none",outline:"none",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",fontSize:"13px",fontFamily:yWe},children:[V.jsx("span",{style:{color:"#888888",flexShrink:0},children:"Sheet:"}),V.jsx("span",{style:{...N0n,minWidth:0},children:s}),V.jsx(Gwi,{className:"sv-sheet-chevron"})]})}),V.jsx(aU,{children:V.jsx(nZ,{style:kwi,side:"bottom",align:"start",sideOffset:8,collisionPadding:10,children:t.map(a=>{const A=a.schematic_sheet_id===e;return V.jsxs(_S,{className:"sv-sheet-item",style:Fwi,title:a.name,onSelect:c=>c.preventDefault(),onPointerUp:()=>{n(a.schematic_sheet_id),i(!1)},children:[V.jsx("span",{style:Lwi,children:A&&V.jsx(Owi,{})}),V.jsx("span",{style:{...N0n,minWidth:0},children:a.name})]},a.schematic_sheet_id)})})})]})]})},Uwi=({count:t,showWarnings:e,onToggle:n})=>{const o=`${e?"Hide":"Show"} ${t} ${t===1?"warning":"warnings"}`;return V.jsxs("button",{type:"button","data-schematic-warnings":!0,title:o,"aria-label":o,"aria-pressed":e,onClick:n,onPointerDown:i=>i.stopPropagation(),onMouseDown:i=>i.stopPropagation(),onTouchStart:i=>i.stopPropagation(),onTouchEnd:i=>i.stopPropagation(),style:{height:"32px",display:"flex",alignItems:"center",gap:"4px",padding:"0 8px",border:"none",borderRadius:"4px",backgroundColor:e?"#fff3cd":"#ffffff",color:"#946200",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',fontSize:"12px",fontWeight:600},children:[V.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[V.jsx("path",{d:"M10.3 3.9 1.8 18.1A2 2 0 0 0 3.5 21h17a2 2 0 0 0 1.7-2.9L13.7 3.9a2 2 0 0 0-3.4 0Z"}),V.jsx("path",{d:"M12 9v4m0 4h.01"})]}),V.jsx("span",{children:t})]})},Kwi={version:"2.0.99"},xWe='system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',R0n={backgroundColor:"#262626",color:"#fafafa",borderRadius:6,boxShadow:"0px 12px 48px -12px rgba(0, 0, 0, 0.5), 0px 8px 24px -8px rgba(0, 0, 0, 0.3)",border:"1px solid #333333",padding:4,minWidth:208,fontSize:14,fontWeight:400,fontFamily:xWe,outline:"none",zIndex:CE.contextMenu},CT={display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:6,cursor:"default",outline:"none",userSelect:"none",color:"#fafafa",fontSize:14,fontWeight:400,fontFamily:xWe},CZ={width:16,height:16,flexShrink:0,display:"inline-flex",alignItems:"center",justifyContent:"center",color:"#fafafa"},T0n={height:1,backgroundColor:"#ffffff1a",margin:"4px 0"},Vwi=`
|
|
5512
5512
|
.sv-vm-item[data-highlighted]:not([data-disabled]),
|
|
5513
5513
|
.sv-vm-item:hover:not([data-disabled]) { background-color: #404040; }
|
|
5514
5514
|
.sv-vm-item[data-disabled] { opacity: 0.45; cursor: not-allowed; }
|
|
5515
|
-
`,Wme=()=>V.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:V.jsx("path",{d:"M20 6 9 17l-5-5"})}),zwi=({netLocations:t=[],onSelectNetLocation:e,circuitJson:n,circuitJsonKey:o,menuRef:i,menuPos:r,onOpenChange:s,onRunStyleAnalysis:a,showGroups:A,onToggleGroups:c,showGrid:l,onToggleGrid:g,showPorts:u,onTogglePorts:h,showWarnings:d,onToggleWarnings:p})=>{const m=te.useMemo(()=>{if(!n||n.length===0)return!1;try{if((V3(n).source_group?.list()||[]).length>0)return!0;const I=V3(n).schematic_component?.list()||[];if(I.length>1){const C=new Set;for(const y of I){const x=V3(n).source_component.get(y.source_component_id);x?.ftype&&C.add(x.ftype)}return C.size>1}return!1}catch(f){return console.error("Error checking for groups:",f),!1}},[o]),_=te.useMemo(()=>{if(!n||n.length===0)return!1;try{return(V3(n).schematic_port?.list()||[]).length>0}catch(f){return console.error("Error checking for schematic ports:",f),!1}},[o]);return V.jsx("div",{ref:i,style:{position:"fixed",left:r.x,top:r.y,width:0,height:0},children:V.jsxs(_me,{open:!0,onOpenChange:s,modal:!1,children:[V.jsx(fme,{asChild:!0,children:V.jsx("div",{style:{position:"absolute",width:1,height:1}})}),V.jsx(aU,{children:V.jsxs(nZ,{style:R0n,align:"start",sideOffset:0,collisionPadding:10,avoidCollisions:!0,children:[V.jsx("style",{children:Vwi}),t.length>0&&V.jsxs(aln,{children:[V.jsxs(UJe,{className:"sv-vm-item",style:CT,children:["Net Locations ",V.jsx("span",{style:{marginLeft:"auto"},children:"›"})]}),V.jsx(aU,{children:V.jsx(KJe,{style:{...R0n,maxHeight:"min(400px, var(--radix-dropdown-menu-content-available-height))",overflowY:"auto"},collisionPadding:10,children:t.map((f,I)=>V.jsx(_S,{className:"sv-vm-item",style:CT,onSelect:()=>e?.(f),children:f.label},I))})})]}),V.jsxs(_S,{className:"sv-vm-item",style:CT,disabled:!_,title:_?void 0:"No ports found in this schematic",onSelect:f=>f.preventDefault(),onPointerDown:f=>{f.preventDefault(),_&&h(!u)},children:[V.jsx("span",{style:CZ,children:u&&V.jsx(Wme,{})}),V.jsx("span",{children:"Show Schematic Ports"})]}),V.jsxs(_S,{className:"sv-vm-item",style:CT,disabled:!m,title:m?void 0:"No groups found in this schematic",onSelect:f=>f.preventDefault(),onPointerDown:f=>{f.preventDefault(),m&&c(!A)},children:[V.jsx("span",{style:CZ,children:A&&V.jsx(Wme,{})}),V.jsx("span",{children:"View Schematic Groups"})]}),V.jsxs(_S,{className:"sv-vm-item",style:CT,onSelect:f=>f.preventDefault(),onPointerDown:f=>{f.preventDefault(),g(!l)},children:[V.jsx("span",{style:CZ,children:l&&V.jsx(Wme,{})}),V.jsx("span",{children:"Show Grid"})]}),V.jsxs(GJe,{className:"sv-vm-item",style:CT,checked:d,onCheckedChange:p,onSelect:f=>f.preventDefault(),children:[V.jsx("span",{style:CZ,children:V.jsx(YJe,{children:V.jsx(Wme,{})})}),V.jsx("span",{children:"Show Warnings"})]}),V.jsx(Ime,{style:T0n}),V.jsxs(_S,{className:"sv-vm-item",style:CT,onSelect:a,children:[V.jsx("span",{style:CZ}),V.jsx("span",{children:"Run Style Analysis"})]}),V.jsx(Ime,{style:T0n}),V.jsxs("div",{style:{padding:"4px 8px 4px 32px",fontSize:11,opacity:.35,color:"#a1a1aa",letterSpacing:"0.2px",fontFamily:xWe},children:["@tscircuit/schematic-viewer@",String(Kwi?.version)]})]})})]})})},Jwi=({circuitJson:t,containerStyle:e,debugGrid:n=!1,debug:o=!1,clickToInteractEnabled:i=!1,colorOverrides:r,disableGroups:s=!1,netHoverHighlightEnabled:a=!0,onSchematicComponentClicked:A,showSchematicPorts:c,onSchematicPortClicked:l,onSchematicSheetChange:g,searchEnabled:u=!0,controller:h,css:d,className:p})=>{o&&swi();const m=rt=>`${rt?.length||0}_${rt?.editCount||0}`,_=te.useMemo(()=>m(t),[t]),f=te.useMemo(()=>{try{return t.filter(rt=>rt?.type==="schematic_sheet").slice().sort((rt,xt)=>(rt.sheet_index??0)-(xt.sheet_index??0))}catch(rt){return console.error("Failed to derive schematic sheets",rt),[]}},[_]),I=f.length>1,C=f[0]?.schematic_sheet_id,[y,x]=te.useState(()=>{const rt=Gvi(mU.SELECTED_SCHEMATIC_SHEET);return rt&&f.some(xt=>xt.schematic_sheet_id===rt)?rt:C});te.useEffect(()=>{y!==void 0&&f.some(xt=>xt.schematic_sheet_id===y)||x(C)},[_]);const E=I?y??C:void 0,B=te.useCallback(rt=>{x(rt),Yvi(mU.SELECTED_SCHEMATIC_SHEET,rt),g?.(rt)},[g]),[S,Q]=te.useState(!1),[w,M]=te.useState(null),[k,R]=te.useState(!1),F=t.filter(rt=>rt.type.startsWith("schematic_")&&rt.type.endsWith("_warning")).length,O=n||S,[U,Y]=te.useState(!i),[J,ee]=te.useState(()=>s?!1:E0n(mU.IS_SHOWING_SCHEMATIC_GROUPS,!1)),[W,X]=te.useState(()=>c??E0n(mU.IS_SHOWING_SCHEMATIC_PORTS,!1));te.useEffect(()=>{c!==void 0&&X(c)},[c]);const[oe,se]=te.useState(!1),ie=te.useRef(new Set),[ge,ue]=te.useState(null),Ie=te.useCallback((rt,xt)=>{xt?ie.current.add(rt):ie.current.delete(rt),se(ie.current.size>0)},[]),[le,_e]=te.useState(!1),me=te.useRef(new Set),ye=te.useCallback((rt,xt)=>{xt?me.current.add(rt):me.current.delete(rt),_e(me.current.size>0)},[]),Me=te.useRef(null),we=te.useRef(null),he=te.useRef({x:1,y:1}),Qe=te.useMemo(()=>{try{return(V3(t).schematic_component?.list()??[]).filter(xt=>!E||xt.schematic_sheet_id===E).map(xt=>xt.schematic_component_id)}catch(rt){return console.error("Failed to derive schematic component ids",rt),[]}},[_,t,E]),ve=te.useMemo(()=>{if(!W)return[];try{return(V3(t).schematic_port?.list()??[]).filter(xt=>!E||xt.schematic_sheet_id===E).map(xt=>{const $e=V3(t).source_port.get(xt.source_port_id),ut=($e?.source_component_id?V3(t).source_component.get($e.source_component_id):null)?.name??"?",Ut=xt.display_pin_label??$e?.pin_number??$e?.name??"?";return{portId:xt.source_port_id,label:`${ut}.${Ut}`}})}catch(rt){return console.error("Failed to derive schematic port info",rt),[]}},[_,t,W,E]),Pe=rt=>{const xt=rt.touches[0];we.current={x:xt.clientX,y:xt.clientY}},Fe=rt=>{const xt=rt.changedTouches[0],$e=we.current;if(!$e)return;const Ze=Math.abs(xt.clientX-$e.x),ut=Math.abs(xt.clientY-$e.y);Ze<10&&ut<10&&(rt.preventDefault(),Y(!0)),we.current=null},Re=te.useCallback(rt=>rt.target instanceof Element&&rt.target.closest("[data-schematic-search], [data-schematic-warnings], .schematic-warning")?!1:rt.type!=="mousedown"||!("button"in rt)?!0:rt.button!==2&&!(rt.button===0&&rt.ctrlKey),[]),{ref:Be,transform:ke,setTransform:Ce}=_Z({onSetTransform(rt){const xt=rt.a!==he.current.x||rt.d!==he.current.y;he.current={x:rt.a,y:rt.d},xt&&ue(null),Me.current&&(Me.current.style.transform=qM(rt))},enabled:U,shouldDrag:Re}),{menuVisible:He,menuPos:Ye,menuRef:tt,setMenuVisible:st,contextMenuEventHandlers:At,menuTarget:lt}=Awi({containerRef:Be}),{containerWidth:pt,containerHeight:bt}=v0n(Be),Ct=te.useMemo(()=>ge?mwi(t,ge.schematicComponentId):null,[_,t,ge]),Tt=te.useMemo(()=>{if(!ge||!pt||!bt)return null;const rt=12,xt=14,$e=Math.min(420,pt-rt*2),Ze=Math.min(520,bt-rt*2),{anchorX:ut,anchorY:Ut}=ge,Wt=ut+xt,$t=ut-$e-xt,Jt=Wt+$e<=pt-rt?Wt:$t>=rt?$t:Math.max(rt,Math.min(ut-$e/2,pt-$e-rt)),yn=Math.max(rt,Math.min(Ut-24,bt-Ze-rt));return{left:Jt,top:yn,width:$e,maxHeight:Ze}},[ge,pt,bt]),kt=te.useCallback((rt,xt)=>{if(xt.target instanceof Element&&xt.target.closest("[data-schematic-component-details-tooltip]"))return;const $e=Be.current?.getBoundingClientRect();$e&&(ue({schematicComponentId:rt,anchorX:xt.clientX-$e.left,anchorY:xt.clientY-$e.top}),A?.({schematicComponentId:rt,event:xt}))},[Be,A]);te.useEffect(()=>{ue(null)},[_,E]),te.useEffect(()=>{if(!ge)return;const rt=$e=>{$e.key==="Escape"&&ue(null)},xt=$e=>{$e.target instanceof Element&&$e.target.closest("[data-schematic-component-details-tooltip]")||ue(null)};return window.addEventListener("keydown",rt),document.addEventListener("mousedown",xt),()=>{window.removeEventListener("keydown",rt),document.removeEventListener("mousedown",xt)}},[ge]);const ot=te.useMemo(()=>!pt||!bt?"":t0n(t,{width:pt,height:bt||720,drawPorts:W,shouldDrawWarnings:k,schematicSheetId:E,grid:O?{cellSize:1,labelCells:!0}:void 0,colorOverrides:r,css:d,className:p}),[_,pt,bt,O,k,W,E]),Yt=te.useMemo(()=>ot.match(/<svg[^>]*style="[^"]*background-color:\s*([^;\"]+)/i)?.[1]??"transparent",[ot]),{searchQuery:pn,setSearchQuery:be,searchResults:et,handleSearchResultSelect:It,handleCancelSearch:Bt}=rwi({controller:h,circuitJson:t,circuitJsonKey:_,svgDivRef:Me,containerRef:Be,activeSheetId:E,hasMultipleSheets:I,handleSelectSheet:B,svgString:ot,svgToScreenProjection:ke,setSvgToScreenProjection:Ce,setIsInteractionEnabled:Y});Uvi({svgDivRef:Me,circuitJson:t,circuitJsonKey:`${_}_${E??""}`,showGroups:J&&!s}),Vvi({svgDivRef:Me,circuitJson:t,circuitJsonKey:`${_}_${E??""}`,enabled:a});const mt=te.useMemo(()=>V.jsx("div",{ref:Me,style:{pointerEvents:i?U?"auto":"none":"auto",transformOrigin:"0 0"},className:"schematic-component-clickable",dangerouslySetInnerHTML:{__html:ot}}),[ot,U,i]);return zvi({svgDivRef:Me,svgContent:mt,circuitJsonKey:_}),V.jsxs(xwi,{children:[a&&V.jsx("style",{children:`.sch-net-faded { opacity: 0.35; }
|
|
5515
|
+
`,Wme=()=>V.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:V.jsx("path",{d:"M20 6 9 17l-5-5"})}),zwi=({netLocations:t=[],onSelectNetLocation:e,circuitJson:n,circuitJsonKey:o,menuRef:i,menuPos:r,onOpenChange:s,onRunStyleAnalysis:a,showGroups:A,onToggleGroups:c,showGrid:l,onToggleGrid:g,showPorts:u,onTogglePorts:h,showWarnings:d,onToggleWarnings:p})=>{const m=te.useMemo(()=>{if(!n||n.length===0)return!1;try{if((V3(n).source_group?.list()||[]).length>0)return!0;const I=V3(n).schematic_component?.list()||[];if(I.length>1){const C=new Set;for(const y of I){const x=V3(n).source_component.get(y.source_component_id);x?.ftype&&C.add(x.ftype)}return C.size>1}return!1}catch(f){return console.error("Error checking for groups:",f),!1}},[o]),_=te.useMemo(()=>{if(!n||n.length===0)return!1;try{return(V3(n).schematic_port?.list()||[]).length>0}catch(f){return console.error("Error checking for schematic ports:",f),!1}},[o]);return V.jsx("div",{ref:i,style:{position:"fixed",left:r.x,top:r.y,width:0,height:0},children:V.jsxs(_me,{open:!0,onOpenChange:s,modal:!1,children:[V.jsx(fme,{asChild:!0,children:V.jsx("div",{style:{position:"absolute",width:1,height:1}})}),V.jsx(aU,{children:V.jsxs(nZ,{style:R0n,align:"start",sideOffset:0,collisionPadding:10,avoidCollisions:!0,children:[V.jsx("style",{children:Vwi}),t.length>0&&V.jsxs(aln,{children:[V.jsxs(UJe,{className:"sv-vm-item",style:CT,children:["Net Locations ",V.jsx("span",{style:{marginLeft:"auto"},children:"›"})]}),V.jsx(aU,{children:V.jsx(KJe,{style:{...R0n,maxHeight:"min(400px, var(--radix-dropdown-menu-content-available-height))",overflowY:"auto"},collisionPadding:10,children:t.map((f,I)=>V.jsx(_S,{className:"sv-vm-item",style:CT,onSelect:()=>e?.(f),children:f.label},I))})})]}),V.jsxs(_S,{className:"sv-vm-item",style:CT,disabled:!_,title:_?void 0:"No ports found in this schematic",onSelect:f=>f.preventDefault(),onPointerDown:f=>{f.preventDefault(),_&&h(!u)},children:[V.jsx("span",{style:CZ,children:u&&V.jsx(Wme,{})}),V.jsx("span",{children:"Show Schematic Ports"})]}),V.jsxs(_S,{className:"sv-vm-item",style:CT,disabled:!m,title:m?void 0:"No groups found in this schematic",onSelect:f=>f.preventDefault(),onPointerDown:f=>{f.preventDefault(),m&&c(!A)},children:[V.jsx("span",{style:CZ,children:A&&V.jsx(Wme,{})}),V.jsx("span",{children:"View Schematic Groups"})]}),V.jsxs(_S,{className:"sv-vm-item",style:CT,onSelect:f=>f.preventDefault(),onPointerDown:f=>{f.preventDefault(),g(!l)},children:[V.jsx("span",{style:CZ,children:l&&V.jsx(Wme,{})}),V.jsx("span",{children:"Show Grid"})]}),V.jsxs(GJe,{className:"sv-vm-item",style:CT,checked:d,onCheckedChange:p,onSelect:f=>f.preventDefault(),children:[V.jsx("span",{style:CZ,children:V.jsx(YJe,{children:V.jsx(Wme,{})})}),V.jsx("span",{children:"Show Warnings"})]}),V.jsx(Ime,{style:T0n}),V.jsxs(_S,{className:"sv-vm-item",style:CT,onSelect:a,children:[V.jsx("span",{style:CZ}),V.jsx("span",{children:"Run Style Analysis"})]}),V.jsx(Ime,{style:T0n}),V.jsxs("div",{style:{padding:"4px 8px 4px 32px",fontSize:11,opacity:.35,color:"#a1a1aa",letterSpacing:"0.2px",fontFamily:xWe},children:["@tscircuit/schematic-viewer@",String(Kwi?.version)]})]})})]})})},Jwi=({circuitJson:t,containerStyle:e,debugGrid:n=!1,debug:o=!1,clickToInteractEnabled:i=!1,colorOverrides:r,disableGroups:s=!1,netHoverHighlightEnabled:a=!0,onSchematicComponentClicked:A,showSchematicPorts:c,onSchematicPortClicked:l,onSchematicSheetChange:g,searchEnabled:u=!0,controller:h,css:d,className:p})=>{o&&swi();const m=rt=>`${rt?.length||0}_${rt?.editCount||0}`,_=te.useMemo(()=>m(t),[t]),f=te.useMemo(()=>{try{return t.filter(rt=>rt?.type==="schematic_sheet").slice().sort((rt,xt)=>(rt.sheet_index??0)-(xt.sheet_index??0))}catch(rt){return console.error("Failed to derive schematic sheets",rt),[]}},[_]),I=f.length>1,C=f[0]?.schematic_sheet_id,[y,x]=te.useState(()=>{const rt=Gvi(mU.SELECTED_SCHEMATIC_SHEET);return rt&&f.some(xt=>xt.schematic_sheet_id===rt)?rt:C});te.useEffect(()=>{y!==void 0&&f.some(xt=>xt.schematic_sheet_id===y)||x(C)},[_]);const E=I?y??C:void 0,B=te.useCallback(rt=>{x(rt),Yvi(mU.SELECTED_SCHEMATIC_SHEET,rt),g?.(rt)},[g]),[S,Q]=te.useState(!1),[w,M]=te.useState(null),[k,R]=te.useState(!1),F=t.filter(rt=>rt.type.startsWith("schematic_")&&rt.type.endsWith("_warning")).length,O=n||S,[U,Y]=te.useState(!i),[J,ee]=te.useState(()=>s?!1:E0n(mU.IS_SHOWING_SCHEMATIC_GROUPS,!1)),[W,X]=te.useState(()=>c??E0n(mU.IS_SHOWING_SCHEMATIC_PORTS,!1));te.useEffect(()=>{c!==void 0&&X(c)},[c]);const[oe,se]=te.useState(!1),ie=te.useRef(new Set),[ge,ue]=te.useState(null),Ie=te.useCallback((rt,xt)=>{xt?ie.current.add(rt):ie.current.delete(rt),se(ie.current.size>0)},[]),[le,_e]=te.useState(!1),me=te.useRef(new Set),ye=te.useCallback((rt,xt)=>{xt?me.current.add(rt):me.current.delete(rt),_e(me.current.size>0)},[]),Me=te.useRef(null),we=te.useRef(null),he=te.useRef({x:1,y:1}),Qe=te.useMemo(()=>{try{return(V3(t).schematic_component?.list()??[]).filter(xt=>!E||xt.schematic_sheet_id===E).map(xt=>xt.schematic_component_id)}catch(rt){return console.error("Failed to derive schematic component ids",rt),[]}},[_,t,E]),ve=te.useMemo(()=>{if(!W)return[];try{return(V3(t).schematic_port?.list()??[]).filter(xt=>!E||xt.schematic_sheet_id===E).map(xt=>{const $e=V3(t).source_port.get(xt.source_port_id),ut=($e?.source_component_id?V3(t).source_component.get($e.source_component_id):null)?.name??"?",Ut=xt.display_pin_label??$e?.pin_number??$e?.name??"?";return{portId:xt.source_port_id,label:`${ut}.${Ut}`}})}catch(rt){return console.error("Failed to derive schematic port info",rt),[]}},[_,t,W,E]),Pe=rt=>{const xt=rt.touches[0];we.current={x:xt.clientX,y:xt.clientY}},Fe=rt=>{const xt=rt.changedTouches[0],$e=we.current;if(!$e)return;const Ze=Math.abs(xt.clientX-$e.x),ut=Math.abs(xt.clientY-$e.y);Ze<10&&ut<10&&(rt.preventDefault(),Y(!0)),we.current=null},Re=te.useCallback(rt=>rt.target instanceof Element&&rt.target.closest("[data-schematic-search], [data-schematic-warnings], .schematic-warning, [data-schematic-component-details-tooltip]")?!1:rt.type!=="mousedown"||!("button"in rt)?!0:rt.button!==2&&!(rt.button===0&&rt.ctrlKey),[]),{ref:Be,transform:ke,setTransform:Ce}=_Z({onSetTransform(rt){const xt=rt.a!==he.current.x||rt.d!==he.current.y;he.current={x:rt.a,y:rt.d},xt&&ue(null),Me.current&&(Me.current.style.transform=qM(rt))},enabled:U,shouldDrag:Re}),{menuVisible:He,menuPos:Ye,menuRef:tt,setMenuVisible:st,contextMenuEventHandlers:At,menuTarget:lt}=Awi({containerRef:Be}),{containerWidth:pt,containerHeight:bt}=v0n(Be),Ct=te.useMemo(()=>ge?mwi(t,ge.schematicComponentId):null,[_,t,ge]),Tt=te.useMemo(()=>{if(!ge||!pt||!bt)return null;const rt=12,xt=14,$e=Math.min(420,pt-rt*2),Ze=Math.min(520,bt-rt*2),{anchorX:ut,anchorY:Ut}=ge,Wt=ut+xt,$t=ut-$e-xt,Jt=Wt+$e<=pt-rt?Wt:$t>=rt?$t:Math.max(rt,Math.min(ut-$e/2,pt-$e-rt)),yn=Math.max(rt,Math.min(Ut-24,bt-Ze-rt));return{left:Jt,top:yn,width:$e,maxHeight:Ze}},[ge,pt,bt]),kt=te.useCallback((rt,xt)=>{if(xt.target instanceof Element&&xt.target.closest("[data-schematic-component-details-tooltip]"))return;const $e=Be.current?.getBoundingClientRect();$e&&(ue({schematicComponentId:rt,anchorX:xt.clientX-$e.left,anchorY:xt.clientY-$e.top}),A?.({schematicComponentId:rt,event:xt}))},[Be,A]);te.useEffect(()=>{ue(null)},[_,E]),te.useEffect(()=>{if(!ge)return;const rt=$e=>{$e.key==="Escape"&&ue(null)},xt=$e=>{$e.target instanceof Element&&$e.target.closest("[data-schematic-component-details-tooltip]")||ue(null)};return window.addEventListener("keydown",rt),document.addEventListener("mousedown",xt),()=>{window.removeEventListener("keydown",rt),document.removeEventListener("mousedown",xt)}},[ge]);const ot=te.useMemo(()=>!pt||!bt?"":t0n(t,{width:pt,height:bt||720,drawPorts:W,shouldDrawWarnings:k,schematicSheetId:E,grid:O?{cellSize:1,labelCells:!0}:void 0,colorOverrides:r,css:d,className:p}),[_,pt,bt,O,k,W,E]),Yt=te.useMemo(()=>ot.match(/<svg[^>]*style="[^"]*background-color:\s*([^;\"]+)/i)?.[1]??"transparent",[ot]),{searchQuery:pn,setSearchQuery:be,searchResults:et,handleSearchResultSelect:It,handleCancelSearch:Bt}=rwi({controller:h,circuitJson:t,circuitJsonKey:_,svgDivRef:Me,containerRef:Be,activeSheetId:E,hasMultipleSheets:I,handleSelectSheet:B,svgString:ot,svgToScreenProjection:ke,setSvgToScreenProjection:Ce,setIsInteractionEnabled:Y});Uvi({svgDivRef:Me,circuitJson:t,circuitJsonKey:`${_}_${E??""}`,showGroups:J&&!s}),Vvi({svgDivRef:Me,circuitJson:t,circuitJsonKey:`${_}_${E??""}`,enabled:a});const mt=te.useMemo(()=>V.jsx("div",{ref:Me,style:{pointerEvents:i?U?"auto":"none":"auto",transformOrigin:"0 0"},className:"schematic-component-clickable",dangerouslySetInnerHTML:{__html:ot}}),[ot,U,i]);return zvi({svgDivRef:Me,svgContent:mt,circuitJsonKey:_}),V.jsxs(xwi,{children:[a&&V.jsx("style",{children:`.sch-net-faded { opacity: 0.35; }
|
|
5516
5516
|
svg :is(g.trace, g.trace-overlays, g[data-schematic-component-id], [data-schematic-net-label-id]) { transition: opacity 0.12s ease-in-out; }`}),u&&V.jsx("style",{children:`.schematic-search-match text,
|
|
5517
5517
|
text.schematic-search-match {
|
|
5518
5518
|
fill: #ff00d4 !important;
|
|
@@ -5664,7 +5664,7 @@ test("${c} should solve problem correctly", () => {
|
|
|
5664
5664
|
// Add more specific assertions based on expected output
|
|
5665
5665
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5666
5666
|
})
|
|
5667
|
-
`,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),h=document.createElement("a");h.href=u,h.download=`${c}.test.ts`,h.click(),URL.revokeObjectURL(u)}catch(A){alert(`Error generating test.ts for ${t.getSolverName()}: ${A instanceof Error?A.message:String(A)}`)}o(!1)};return V.jsxs("div",{className:`relative ${e}`,ref:i,children:[V.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.getSolverName()}`,children:t.getSolverName()}),n&&V.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},Ldn=t=>t.activeSubSolver?[t,...Ldn(t.activeSubSolver)]:[t],gLi=({solver:t})=>{const e=Ldn(t);return V.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>V.jsxs("div",{className:"flex items-center",children:[o>0&&V.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),V.jsx(lLi,{solver:n})]},n.getSolverName()))})},uLi=({solver:t,triggerRender:e,animationSpeed:n=25,renderer:o,onRendererChange:i,onAnimationSpeedChange:r,onDownloadVisualization:s,onSolverStarted:a,onSolverCompleted:A})=>{const[c,l]=te.useReducer(B=>!B,!1),g=te.useRef(void 0),u=te.useRef(null),h="solver-debugger-last-iteration",[d,p]=te.useState(null),m=te.useRef(null),_=te.useMemo(()=>[{label:"Slow",value:250,description:"250ms"},{label:"Normal",value:100,description:"100ms"},{label:"Fast",value:10,description:"10ms"},{label:"Fast (2x)",value:5,description:"5ms"},{label:"Fast (10x)",value:1,description:"1ms"},{label:"Fast 20x",value:.5,description:"2 steps / 1ms"},{label:"Fast 100x",value:.1,description:"10 steps / 1ms"}],[]),f=()=>{const B=Math.max(1,n),S=n<1?Math.round(1/n):1;g.current=setInterval(()=>{if(t.solved||t.failed){g.current&&(clearInterval(g.current),g.current=void 0),l(),e(),A&&t.solved&&A(t);return}for(let Q=0;Q<S&&!(t.solved||t.failed);Q++)t.step();e()},B)},I=()=>{g.current&&(clearInterval(g.current),g.current=void 0)},C=()=>{!t.solved&&!t.failed&&(t.step(),e())},y=()=>{!t.solved&&!t.failed&&(a&&a(t),t.solve(),e(),A&&A(t))},x=()=>{c?(I(),l()):(l(),f())},E=()=>{if(t.solved||t.failed||c)return;u.current===null&&typeof window<"u"&&(u.current=window.localStorage.getItem(h));const B=window.prompt("Step until which iteration?",u.current??`${t.iterations}`);if(B===null)return;u.current=B,typeof window<"u"&&window.localStorage.setItem(h,B);const S=Number(B);if(!Number.isFinite(S)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<S&&!t.solved&&!t.failed;)t.step();e(),t.solved&&A&&A(t)};return te.useEffect(()=>()=>{I()},[]),te.useEffect(()=>{(t.solved||t.failed)&&c&&(I(),l())},[t.solved,t.failed,c]),te.useEffect(()=>{c&&(I(),f())},[n,c]),te.useEffect(()=>{if(typeof document>"u")return;const B=S=>{m.current&&!m.current.contains(S.target)&&p(null)};return document.addEventListener("mousedown",B),()=>{document.removeEventListener("mousedown",B)}},[]),V.jsxs("div",{className:"space-y-2 p-2 border-b",children:[V.jsx("div",{className:"flex items-center",children:V.jsxs("div",{className:"flex items-center gap-2",ref:m,children:[V.jsxs("div",{className:"flex h-9 items-center space-x-1 rounded-md border border-slate-200 bg-white p-1 shadow-sm",children:[V.jsxs("div",{className:"relative",children:[V.jsx("button",{type:"button",onClick:()=>p(d==="renderer"?null:"renderer"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":d==="renderer"?"open":"closed",children:"Renderer"}),d==="renderer"&&V.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[10rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:["vector","canvas"].map(B=>V.jsxs("button",{type:"button",onClick:()=>{i(B),p(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:[B==="vector"?"Vector":"Canvas",o===B&&V.jsx("span",{className:"ml-auto text-xs text-slate-500",children:"✓"})]},B))})]}),V.jsxs("div",{className:"relative",children:[V.jsx("button",{type:"button",onClick:()=>p(d==="debug"?null:"debug"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":d==="debug"?"open":"closed",children:"Debug"}),d==="debug"&&V.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[12rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:V.jsx("button",{type:"button",onClick:()=>{s(),p(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:"Download Visualization"})})]}),V.jsxs("div",{className:"relative",children:[V.jsx("button",{type:"button",onClick:()=>p(d==="animation"?null:"animation"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":d==="animation"?"open":"closed",children:"Animation"}),d==="animation"&&V.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[12rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:_.map(B=>V.jsxs("button",{type:"button",onClick:()=>{r(B.value),p(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:[B.label,V.jsx("span",{className:"ml-auto text-xs text-slate-500",children:B.description}),n===B.value&&V.jsx("span",{className:"ml-2 text-xs text-slate-500",children:"✓"})]},B.value))})]})]}),V.jsx(gLi,{solver:t})]})}),V.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[V.jsx("button",{onClick:C,disabled:t.solved||t.failed||c,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),V.jsx("button",{onClick:y,disabled:t.solved||t.failed||c,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),V.jsx("button",{onClick:x,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${c?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:c?"Stop":"Animate"}),V.jsx("button",{onClick:E,disabled:t.solved||t.failed||c,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),V.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),t.solved&&V.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&V.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&V.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},dLi=t=>t!==null&&"pipelineDef"in t&&Array.isArray(t.pipelineDef),hLi=(t,e,n)=>{const o=t.currentPipelineStageIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},pLi=(t,e)=>{const o=t.pipelineDef[e].solverName,i=hLi(t,e),r=t[o],s=t.firstIterationOfStage?.[o]??(e===t.currentPipelineStageIndex?t.iterations:null),a=t.iterations;let A=0;if(i==="Completed"){const u=t.pipelineDef[e+1],h=u?t.firstIterationOfStage?.[u.solverName]:void 0;h!==void 0&&s!==null?A=h-s:s!==null&&(A=a-s)}else i==="In Progress"&&s!==null&&(A=a-s);const c=t.timeSpentOnStage?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const g=r?.stats??null;return{index:e,name:o,status:i,firstIteration:s,iterations:A,progress:l,timeSpent:c,stats:g&&Object.keys(g).length>0?g:null,solverInstance:r??null}},mLi=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return V.jsx("span",{className:`font-medium ${e[t]}`,children:t})},_Li=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:V.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),V.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},Hdn=t=>{if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"||t==null)return String(t);if(typeof t=="object")try{return JSON.stringify(t)}catch{return String(t)}return String(t)},fLi=t=>Object.entries(t).map(([e,n])=>`${e}: ${Hdn(n)}`).join(", "),ILi=({stats:t})=>{if(!t||Object.keys(t).length===0)return V.jsx("span",{children:"-"});const e=Object.entries(t),n=fLi(t);return V.jsxs("details",{className:"cursor-pointer",children:[V.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),V.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>V.jsxs("div",{children:[o,": ",Hdn(i)]},o))})]})},Gje=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(Gje);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=Gje(o));return e},CLi=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=Gje(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${e}_input.json`,r.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},yLi=({expanded:t})=>V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:`w-4 h-4 transition-transform duration-200 ${t?"rotate-90":""}`,children:V.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})}),Odn=t=>{let e=t;for(;e.activeSubSolver;)e=e.activeSubSolver;return e},Gdn=({solver:t,onStepUntilPhase:e,onDownloadInput:n,isNested:o=!1,indentLevel:i=0,triggerRender:r})=>{const[s,a]=te.useState(new Set),A=t.pipelineDef.map((m,_)=>pLi(t,_)),c=m=>{a(_=>{const f=new Set(_);return f.has(m)?f.delete(m):f.add(m),f})},l=m=>{e?.(m)},g=m=>{m.solverInstance&&(n?n(m.solverInstance,m.name):CLi(m.solverInstance,m.name))},u=m=>`${(m/1e3).toFixed(2)}s`,h=()=>{if(!t.solved&&!t.failed){const m=t.activeSubSolver;for(;!t.solved&&!t.failed&&(t.step(),!(t.activeSubSolver&&t.activeSubSolver!==m)););r?.()}},d=()=>{if(!t.solved&&!t.failed){const m=Odn(t);for(;!t.solved&&!t.failed&&(t.step(),Odn(t)===m););r?.()}},p=i*24;return V.jsxs("div",{className:o?"":"border-t border-gray-200",children:[!o&&V.jsxs("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200 flex items-center justify-between",children:[V.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Stages"}),V.jsxs("div",{className:"flex gap-2",children:[V.jsx("button",{onClick:d,disabled:t.solved||t.failed,className:"bg-indigo-500 hover:bg-indigo-600 disabled:bg-gray-300 disabled:cursor-not-allowed cursor-pointer text-white px-3 py-1 rounded text-sm",children:"Next Solver"}),V.jsx("button",{onClick:h,disabled:t.solved||t.failed,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 disabled:cursor-not-allowed cursor-pointer text-white px-3 py-1 rounded text-sm",children:"Next Stage"})]})]}),V.jsx("div",{className:"overflow-x-auto",children:V.jsxs("table",{className:"w-full text-sm",children:[!o&&V.jsx("thead",{children:V.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stage"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),V.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",V.jsx("sub",{children:"0"})]}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),V.jsx("tbody",{children:A.map(m=>{const _=dLi(m.solverInstance),f=s.has(m.name);return V.jsxs(ks.Fragment,{children:[V.jsxs("tr",{className:`border-b border-gray-100 ${m.status==="In Progress"?"bg-yellow-50":""}`,children:[V.jsx("td",{className:"px-4 py-2",children:V.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:p},children:[_?V.jsx("button",{onClick:()=>c(m.name),className:"text-gray-500 hover:text-gray-700",title:f?"Collapse":"Expand",children:V.jsx(yLi,{expanded:f})}):V.jsx("span",{className:"w-4"}),V.jsx("span",{className:"text-gray-400 w-6",children:String(m.index+1).padStart(2,"0")}),V.jsx("button",{onClick:()=>l(m.name),disabled:m.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${m.name} completes`,children:V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),V.jsx("span",{className:"font-medium text-gray-900",children:m.name})]})}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(mLi,{status:m.status})}),V.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:m.firstIteration!==null?m.firstIteration:""}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:m.iterations}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(_Li,{progress:m.progress})}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:u(m.timeSpent)}),V.jsx("td",{className:"px-4 py-2 text-gray-500",children:V.jsx(ILi,{stats:m.stats})}),V.jsx("td",{className:"px-4 py-2",children:m.solverInstance?V.jsxs("button",{onClick:()=>g(m),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${m.name}`,children:[V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),V.jsx("span",{children:"Input"})]}):null})]}),_&&f&&V.jsx("tr",{children:V.jsx("td",{colSpan:8,className:"p-0",children:V.jsx(Gdn,{solver:m.solverInstance,onStepUntilPhase:e,onDownloadInput:n,isNested:!0,indentLevel:i+1,triggerRender:r})})})]},m.name)})})]})})]})};function xLi({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,A=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(m,_)=>{typeof m=="number"&&(m<s&&(s=m),m>A&&(A=m)),typeof _=="number"&&(_<a&&(a=_),_>c&&(c=_))};for(const m of e)l(m.x,m.y);for(const m of n){const _=m.points??[];for(const f of _)l(f.x,f.y)}for(const m of o){const _=m.x??0,f=m.y??0,I=m.width??0,C=m.height??0;l(_,f),l(_+I,f+C)}for(const m of i){const _=m.x??0,f=m.y??0,I=m.radius??1;l(_-I,f-I),l(_+I,f+I)}for(const m of r)l(m.x,m.y);(!isFinite(s)||!isFinite(a)||!isFinite(A)||!isFinite(c))&&(s=-20,a=-20,A=20,c=20);const g=10,u=s-g,h=a-g,d=Math.max(1,A-s+2*g),p=Math.max(1,c-a+2*g);return V.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${h} ${d} ${p}`,role:"img","aria-label":"Graphics fallback",children:[o.map((m,_)=>V.jsx("rect",{x:m.x??0,y:m.y??0,width:m.width??0,height:m.height??0,fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`rect-${_}`)),n.map((m,_)=>V.jsx("polyline",{fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1,points:(m.points??[]).map(f=>`${f.x??0},${f.y??0}`).join(" ")},`line-${_}`)),i.map((m,_)=>V.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.fillColor??"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`circle-${_}`)),e.map((m,_)=>V.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.color??"black"},`point-${_}`)),r.map((m,_)=>V.jsx("text",{x:m.x??0,y:m.y??0,fontSize:m.fontSize??10,fill:m.color??"black",children:m.text??""},`text-${_}`))]})}var ELi=class extends ks.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}},BLi=({solver:t,createSolver:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=te.useReducer(f=>f+1,0),[a]=te.useState(()=>{if(e)return e();if(!t)throw new Error("GenericSolverDebugger requires solver or createSolver");return t}),[A,c]=te.useState(()=>typeof window>"u"?"vector":window.localStorage.getItem("solver-utils-renderer")==="canvas"?"canvas":"vector"),[l,g]=te.useState(n),u=te.useMemo(()=>{try{return a.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(f){return console.error("Visualization error:",f),{points:[],lines:[],rects:[],circles:[]}}},[a,r]),h=te.useMemo(()=>(u.rects?.length||0)===0&&(u.lines?.length||0)===0&&(u.points?.length||0)===0&&(u.circles?.length||0)===0,[u]);te.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const f=document.createElement("script");f.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(f)}},[]),te.useEffect(()=>{g(n)},[n]);const d=a.pipelineDef!==void 0,p=f=>{const I=a;if(!a.solved&&!a.failed){for(;!a.solved&&!a.failed&&I.currentPipelineStageIndex<=I.pipelineDef.findIndex(C=>C.solverName===f);)a.step();s()}},m=()=>{const f=JSON.stringify(u,null,2),I=new Blob([f],{type:"application/json"}),C=URL.createObjectURL(I),y=document.createElement("a");y.download="visualization.json",y.href=C,document.body.appendChild(y),y.click(),document.body.removeChild(y),URL.revokeObjectURL(C)},_=f=>{c(f),typeof window<"u"&&window.localStorage.setItem("solver-utils-renderer",f)};return V.jsxs("div",{children:[V.jsx(uLi,{solver:a,triggerRender:s,animationSpeed:l,renderer:A,onRendererChange:_,onAnimationSpeedChange:g,onDownloadVisualization:m,onSolverStarted:o,onSolverCompleted:i}),h?V.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):V.jsx(ELi,{fallback:V.jsx(xLi,{graphics:u}),children:A==="canvas"?V.jsx(cLi,{graphics:u}):V.jsx(sLi,{graphics:u})}),d&&V.jsx(Gdn,{solver:a,onStepUntilPhase:p,triggerRender:s})]})};const bLi=()=>{te.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},SLi=1e3,bE=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),s=document.createElement("a");s.href=r,s.download=n,s.target="_blank",s.rel="noopener noreferrer",s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>{URL.revokeObjectURL(r)},SLi)},Yje=t=>{let e=t.trim().replace(/[\\/:*?"<>|]/g,"_").replace(/[\x00-\x1f]/g,"").replace(/^\.+/,"").replace(/\.+$/,"").replace(/\s+/g," ").replace(/_+/g,"_");return/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i.test(e)&&(e=`_${e}`),e=e.slice(0,200),e||"untitled"},QLi=t=>{const e=t.solverConstructorArgs??[t.solverParams];if(t.solverName!=="AutoroutingPipelineSolver7_MultiGraph"||e.length!==1)return e;const[{input:n,options:o}]=e;return[n,o]},J6="https://github.com/tscircuit/tscircuit-autorouter/issues/new",Ydn="https://github.com/tscircuit/copper-pour-solver/issues/new",Udn="https://github.com/tscircuit/calculate-packing/issues/new",vLi="https://github.com/tscircuit/matchpack/issues/new",Kdn="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",wLi={PackSolver2:Udn,LayoutPipelineSolver:vLi,AutoroutingPipelineSolver:J6,AssignableAutoroutingPipeline2:J6,AssignableAutoroutingPipeline3:J6,AutoroutingPipeline1_OriginalUnravel:J6,AutoroutingPipelineSolver3_HgPortPointPathing:J6,AutoroutingPipelineSolver4:J6,AutoroutingPipelineSolver5:J6,AutoroutingPipelineSolver7_MultiGraph:J6,AutoroutingPipelineSolver8:J6,CopperPourPipelineSolver:Ydn,SchematicTracePipelineSolver:Kdn},PLi=t=>t.toLowerCase().includes("pack")?x7i:t.toLowerCase().includes("rout")?OAn:h7i,Vdn=t=>{const e=wLi[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?J6:n.includes("schematic")&&n.includes("trace")?Kdn:n.includes("copperpour")?Ydn:n.includes("pack")?Udn:null},MLi=t=>`${Yje(`${t.componentName}-${t.solverName}`)}-solver-input.json`,zdn=t=>{bE(JSON.stringify(t.solverParams,null,2),{fileName:MLi(t),mimeType:"application/json"})},DLi=({solverEvent:t})=>{const e=Vdn(t.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[V.jsxs(Zc,{type:"button",variant:"outline",size:"sm",onClick:()=>zdn(t),children:[V.jsx(j$,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?V.jsx(Zc,{asChild:!0,variant:"outline",size:"sm",children:V.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[V.jsx(Ype,{className:"rf-w-4 rf-h-4"}),"Report"]})}):V.jsxs(Zc,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[V.jsx(Ype,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},NLi=({solverEvent:t})=>{const e=Vdn(t.solverName);return e?V.jsx(Zc,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:V.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:V.jsx(Ype,{className:"rf-w-4 rf-h-4"})})}):V.jsx(Zc,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:V.jsx(Ype,{className:"rf-w-4 rf-h-4"})})},RLi=({solverEvents:t=[]})=>{const[e,n]=te.useState(null);bLi();const o=te.useMemo(()=>{const a=new Map;for(const A of t){const c=`${A.componentName}-${A.solverName}`;a.set(c,A)}return a},[t]),i=te.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=te.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=PRe[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(PRe).join(", ")}`,classFound:!1};try{return{instance:new a(...QLi(r)),error:null,classFound:!0}}catch(A){const c=A instanceof Error?A.message:String(A);return console.error("Failed to reconstruct solver:",A),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?V.jsx("div",{className:"rf-p-4",children:V.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:V.jsxs("div",{className:"rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),V.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):V.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[V.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(a=>{const A=o.get(a),c=e===a;return V.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const l=PLi(A.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:A.componentName}),V.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:A.solverName})]})]})})()},a)})]}),V.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?V.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[V.jsx(DLi,{solverEvent:r}),V.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:V.jsx(KB,{fallback:V.jsx("div",{className:"rf-p-4",children:V.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),V.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:V.jsx(BLi,{solver:s.instance})})})]}):V.jsxs("div",{className:"rf-p-4",children:[V.jsxs("div",{className:"rf-mb-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),V.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&V.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:V.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),V.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[V.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[V.jsx(NLi,{solverEvent:r}),V.jsx(Zc,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>zdn(r),children:V.jsx(j$,{className:"rf-w-4 rf-h-4"})})]})]}),V.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:V.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):V.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},TLi=new Map([["custom","Custom"],["fanout","Fanout"],["single_layer_fanout","Single layer fanout"],["tscircuit_simplify","Simplify"]]),kLi=new Set(["tscircuit","default","auto","auto_local"]);function FLi(t){if(t==="FanoutSolver")return"Fanout";if(t==="AutoroutingPipelineSolver11_Simplification")return"Simplify";const e=t.match(/^AutoroutingPipeline(?:Solver)?(\d+)(?:_|$)/);if(e)return`Pipeline${e[1]}`;const n=t.match(/^AssignableAutoroutingPipeline(\d+)$/);return n?`Assignable${n[1]}`:t}function LLi(t){const e=t.autorouterName?.trim(),n=e?.replace(/-/g,"_"),o=n&&TLi.get(n);if(o)return o;if(n&&!kLi.has(n))return e;const i=t.solverName?.trim();if(i)return FLi(i);const r=t.autorouterVersion?.trim();if(r){const s=r.match(/^beta[_-]pipeline(\d+)$/);return s?`Pipeline${s[1]}`:r==="latest"?"default":r}return e?"default":"Unknown"}const Uje="#fbbf24";function HLi(t){const e=t.endSimpleRouteJson?.traces??[],n=new Set(e.flatMap(i=>[i.pcb_trace_id,i.__replaces_pcb_trace_id].filter(r=>r!==void 0)));return[...(t.startSimpleRouteJson?.traces??[]).filter(i=>!n.has(i.pcb_trace_id)),...e]}function Jdn(t){const e=new Map((t.startSimpleRouteJson?.traces??[]).map(n=>[n.pcb_trace_id,n]));return(t.endSimpleRouteJson?.traces??[]).filter(n=>{const o=e.get(n.pcb_trace_id);return!o||!!n.__replaces_pcb_trace_id&&n.__replaces_pcb_trace_id!==o.__replaces_pcb_trace_id||JSON.stringify(o.route)!==JSON.stringify(n.route)}).map(n=>n.pcb_trace_id)}function OLi(t,e){return{outer_diameter:t.via_diameter??e.minViaPadDiameter??e.min_via_pad_diameter??e.minViaDiameter??.6,hole_diameter:t.via_hole_diameter??e.minViaHoleDiameter??e.min_via_hole_diameter??.3}}function Wdn(t,e){const n=[];for(const a of t.route)a.route_type==="wire"?n.push({...a,layer:a.layer}):a.route_type==="via"?n.push({route_type:"via",x:a.x,y:a.y,from_layer:a.from_layer,to_layer:a.to_layer,...OLi(a,e)}):a.route_type==="through_obstacle"&&n.push({route_type:"through_pad",start:{...a.start},end:{...a.end},width:a.width,start_layer:a.from_layer,end_layer:a.to_layer,pcb_smtpad_id:a.circuitJsonMetadata?.pcb_smtpad_id,pcb_plated_hole_id:a.circuitJsonMetadata?.pcb_plated_hole_id});const o=a=>{let A=-1,c=Number.POSITIVE_INFINITY;return n.forEach((l,g)=>{if(l.route_type!=="wire")return;const u=Math.hypot(l.x-a.x,l.y-a.y);u<c&&(c=u,A=g)}),A},i=t.route.filter(a=>a.route_type==="jumper").map(a=>[o(a.start),o(a.end)].sort((A,c)=>A-c)).filter(([a,A])=>a>=0&&A>a).sort(([a],[A])=>a-A),r=[];let s=0;for(const[a,A]of i)a>=s&&r.push(n.slice(s,a+1)),s=Math.max(s,A);return s<n.length&&r.push(n.slice(s)),r}function GLi(t){const e=[],n=[],o=t.endSimpleRouteJson;if(!o)return{lines:e,circles:n};const i=new Set(Jdn(t));for(const r of o.traces??[])if(i.has(r.pcb_trace_id))for(const s of Wdn(r,o)){let a;for(const A of s){if(A.route_type==="through_pad"){a={...A.end,layer:A.end_layer,width:A.width};continue}const c=A.route_type==="wire"?A.layer:A.from_layer;a&&a.layer===c&&(a.x!==A.x||a.y!==A.y)&&e.push({points:[{x:a.x,y:a.y},{x:A.x,y:A.y}],strokeWidth:A.route_type==="wire"?A.width:a.width,strokeColor:Uje,layer:c}),A.route_type==="via"&&n.push({center:{x:A.x,y:A.y},radius:A.outer_diameter/2,stroke:Uje,fill:"transparent"}),a={x:A.x,y:A.y,layer:A.route_type==="wire"?A.layer:A.to_layer,width:A.route_type==="wire"?A.width:a?.width??o.minTraceWidth}}}return{coordinateSystem:"cartesian",lines:e,circles:n}}function YLi(t){const e=JSON.stringify(t);let n=2166136261;for(let o=0;o<e.length;o++)n=Math.imul(n^e.charCodeAt(o),16777619);return(n>>>0).toString(36)}const ULi=new Set(["pcb_trace","pcb_via","pcb_copper_pour","pcb_ground_plane","pcb_ground_plane_region","pcb_thermal_spoke","pcb_breakout_point"]);function KLi(t,e,n){const o=n==="input"?e.startSimpleRouteJson??e.errorSimpleRouteJson:e.endSimpleRouteJson,i=t.filter(c=>!ULi.has(c.type)&&!c.type.endsWith("_error")&&!c.type.endsWith("_warning"));if(!o)return i;const r=n==="input"?o.traces??[]:HLi(e),s=new Set(t.filter(c=>c.type==="source_trace").map(c=>c.source_trace_id)),a=["top",...Array.from({length:Math.max(0,o.layerCount-2)},(c,l)=>`inner${l+1}`),...o.layerCount>1?["bottom"]:[]],A=[];for(const c of r){const g=o.connections.find(h=>h.name===c.connection_name||h.source_trace_id===c.connection_name)?.source_trace_id??c.connection_name??"",u=Wdn(c,o);for(const[h,d]of u.entries()){const p={type:"pcb_trace",pcb_trace_id:`${e.id}_${n}_${c.pcb_trace_id}_${h}_${YLi(d)}`,subcircuit_id:e.subcircuit_id??void 0,source_trace_id:s.has(g)?g:void 0,route:d};A.push(p);for(const[m,_]of d.entries()){if(_.route_type!=="via")continue;const f=a.indexOf(_.from_layer),I=a.indexOf(_.to_layer),C={type:"pcb_via",pcb_via_id:`${p.pcb_trace_id}_via_${m}`,pcb_trace_id:p.pcb_trace_id,subcircuit_id:e.subcircuit_id??void 0,x:_.x,y:_.y,outer_diameter:_.outer_diameter,hole_diameter:_.hole_diameter,layers:f>=0&&I>=0?a.slice(Math.min(f,I),Math.max(f,I)+1):[_.from_layer,_.to_layer]};A.push(C)}}}return[...i,...A]}const Kje=(t,e)=>t.phaseName||`Phase ${t.phaseOrdinal??e+1}`,jdn=t=>t.componentDisplayName?.match(/name="([^"]+)"/)?.[1]?.replace(/^\./,"")||t.componentDisplayName||t.subcircuit_id||"Board",Xdn=t=>t.startSimpleRouteJson??t.endSimpleRouteJson??t.errorSimpleRouteJson,VLi={is_showing_autorouting:!0,is_showing_rats_nest:!1,is_showing_drc_errors:!1,is_showing_drc_warnings:!1,is_showing_pcb_groups:!1},zLi=({circuitJson:t,phases:e=[],isRunning:n=!1})=>{const[o,i]=te.useState(null),[r,s]=te.useState("output"),[a,A]=te.useState(!0),[c,l]=te.useState(!1),g=te.useRef(null),[u,h]=te.useState(480),d=o?e.findIndex(R=>R.id===o.id&&Xdn(R)===Xdn(o)):-1,p=d<0?e.length-1:d,m=e[p],_=d<0,f=!!m?.endSimpleRouteJson,I=m?.startSimpleRouteJson??m?.errorSimpleRouteJson,C=!!I,y=r==="output"&&!f?"input":r==="input"&&!C?"output":r,x=y==="input"?I:m?.endSimpleRouteJson,E=te.useMemo(()=>!m||!x?null:KLi(t??[],m,y),[t,m,x,y]),B=te.useMemo(()=>m&&y==="output"&&a?GLi(m):{lines:[],circles:[]},[m,y,a]);if(te.useLayoutEffect(()=>{const R=g.current;if(!R)return;const F=()=>h(Math.max(360,R.clientHeight));F();const O=new ResizeObserver(F);return O.observe(R),()=>O.disconnect()},[!!m]),!m)return V.jsxs("div",{className:"rf-flex rf-min-h-[400px] rf-flex-col rf-items-center rf-justify-center rf-gap-3 rf-p-8 rf-text-center",children:[V.jsx(OAn,{className:"rf-h-7 rf-w-7 rf-text-blue-500"}),V.jsx("h3",{className:"rf-text-base rf-font-medium",children:n?"Waiting for autorouting":"No autorouting captures"}),V.jsx("p",{className:"rf-max-w-md rf-text-sm rf-text-gray-500",children:n?"Phases appear as the circuit routes. Each capture includes its input and output on the PCB.":"Run a circuit with autorouting enabled to inspect its phases. A circuit JSON file alone does not include routing history."})]});const S=Kje(m,p),Q=m.status==="running"&&n,w=!f,M=I?.connections.length,k=E?.filter(R=>R.type==="pcb_trace").length??0;return V.jsxs("div",{className:"rf-flex rf-h-full rf-min-h-[620px] rf-flex-col rf-bg-white md:rf-flex-row","data-testid":"autorouting-explorer",children:[V.jsxs("aside",{className:"rf-flex rf-shrink-0 rf-flex-col rf-border-b rf-border-gray-200 md:rf-w-52 md:rf-border-b-0 md:rf-border-r","aria-label":"Routing phases",children:[V.jsxs("div",{className:"rf-flex rf-items-center rf-justify-between rf-px-3 rf-py-2 rf-text-xs rf-text-gray-500",children:[V.jsx("span",{children:"Routing phases"}),V.jsx("span",{children:e.length})]}),V.jsx("div",{className:"rf-flex rf-gap-1 rf-overflow-x-auto rf-px-1.5 rf-pb-1.5 md:rf-flex-col md:rf-overflow-x-hidden md:rf-overflow-y-auto",children:e.map((R,F)=>{const O=Jdn(R).length,U=R.endSimpleRouteJson?`${O} ${O===1?"trace":"traces"} routed`:R.status==="error"?"Failed":R.status==="running"&&n?"Routing…":"No output";return V.jsxs("button",{type:"button","aria-pressed":F===p,title:`${jdn(R)} · ${U}`,onClick:()=>i(R),className:zr("rf-flex rf-min-w-[192px] rf-items-start rf-gap-2 rf-rounded-md rf-border rf-px-2 rf-py-2 rf-text-left md:rf-min-w-0",F===p?"rf-border-blue-200 rf-bg-blue-50":"rf-border-transparent hover:rf-bg-gray-50"),children:[V.jsx("span",{className:zr("rf-flex rf-h-5 rf-w-5 rf-shrink-0 rf-items-center rf-justify-center rf-rounded-full rf-text-[11px]",F===p?"rf-bg-blue-600 rf-text-white":"rf-bg-gray-100 rf-text-gray-500"),children:F+1}),V.jsxs("span",{className:"rf-min-w-0 rf-flex-1",children:[V.jsxs("span",{className:"rf-flex rf-items-center rf-gap-1",children:[V.jsx("span",{className:"rf-min-w-0 rf-flex-1 rf-truncate rf-text-xs rf-font-medium rf-leading-5 rf-text-gray-800",title:Kje(R,F),children:Kje(R,F)}),R.status==="complete"?V.jsx(W$,{"aria-label":"Captured",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-green-600"}):R.status==="error"?V.jsx(tJe,{"aria-label":"Failed",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-red-500"}):n?V.jsx(a4,{"aria-label":"Routing",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-animate-spin rf-text-blue-500"}):null]}),V.jsxs("span",{className:"rf-block rf-text-[11px] rf-leading-4 rf-text-gray-500",children:[LLi(R)," · ",U]})]})]},R.id)})})]}),V.jsxs("div",{className:"rf-flex rf-min-w-0 rf-flex-1 rf-flex-col",children:[V.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-gap-3 rf-border-b rf-border-gray-200 rf-px-4 rf-py-3",children:[V.jsxs("h3",{className:"rf-mr-auto rf-flex rf-items-center rf-gap-2 rf-text-sm rf-font-medium",children:[S,V.jsxs("span",{className:"rf-text-xs rf-font-normal rf-text-gray-500",children:[p+1," of ",e.length]})]}),n&&V.jsx("button",{type:"button",onClick:()=>i(null),disabled:_,className:"rf-text-xs rf-text-blue-600 disabled:rf-text-gray-500",children:_?"Following latest":"Follow latest"}),V.jsx("div",{className:"rf-flex rf-rounded-md rf-bg-gray-100 rf-p-1","aria-label":"Phase snapshot",children:["input","output"].map(R=>V.jsx("button",{type:"button","aria-pressed":y===R,disabled:R==="input"?!C:!f,onClick:()=>s(R),className:zr("rf-rounded rf-px-3 rf-py-1 rf-text-xs disabled:rf-opacity-40",y===R?"rf-bg-white rf-text-gray-900 rf-shadow-sm":"rf-text-gray-500"),children:R==="input"?"Input":"Output"},R))})]}),V.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-justify-between rf-gap-2 rf-px-4 rf-py-2 rf-text-xs rf-text-gray-600",children:[V.jsxs("label",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx("input",{type:"checkbox",checked:a,disabled:y!=="output",onChange:R=>A(R.target.checked),className:"rf-accent-blue-600"}),V.jsx("span",{"aria-hidden":"true",className:"rf-inline-block rf-h-0.5 rf-w-3",style:{backgroundColor:Uje}}),"Highlight changes (all layers)"]}),V.jsxs("span",{children:[y==="input"?"Before this phase":"After this phase"," ","· ",k," traces"]})]}),w&&V.jsx("div",{className:zr("rf-border-y rf-px-4 rf-py-2 rf-text-xs",m.status==="error"?"rf-border-red-100 rf-bg-red-50 rf-text-red-700":"rf-border-blue-100 rf-bg-blue-50 rf-text-blue-700"),role:"status",children:m.status==="error"?`Routing failed: ${m.error?.message||"No output was captured."}`:Q?"Routing in progress. Showing captured input until output is available.":"No output was captured for this phase. Showing the available input."}),V.jsx("div",{ref:g,className:"rf-relative rf-min-h-[360px] rf-flex-1","data-testid":"autorouting-pcb",children:E?V.jsx(Rje,{circuitJson:E,height:u,allowEditing:!1,clickToInteractEnabled:!1,initialState:VLi,debugGraphics:B}):V.jsx("div",{className:"rf-p-6 rf-text-sm rf-text-gray-500",children:"No PCB snapshot available for this capture."})}),V.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-justify-between rf-gap-2 rf-border-t rf-border-gray-200 rf-px-4 rf-py-3 rf-text-xs rf-text-gray-500",children:[V.jsxs("span",{children:[M===void 0?"Input unavailable":`${M} input connections`,` · ${jdn(m)}`]}),V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-4",children:[V.jsxs("button",{type:"button",disabled:!x,onClick:()=>bE(JSON.stringify(x,null,2),{fileName:`${m.id}-${y}.srj.json`,mimeType:"application/json"}),className:"rf-flex rf-items-center rf-gap-1 disabled:rf-opacity-40",children:[V.jsx(j$,{className:"rf-h-3 rf-w-3"}),"Download SRJ"]}),V.jsxs("button",{type:"button","aria-expanded":c,onClick:()=>l(!c),className:"rf-flex rf-items-center rf-gap-1",children:[V.jsx(XY,{className:zr("rf-h-3 rf-w-3",c&&"rf-rotate-90")}),"Inspect SRJ"]})]})]}),c&&V.jsx("pre",{className:"rf-m-0 rf-max-h-64 rf-overflow-auto rf-border-t rf-border-gray-200 rf-bg-gray-50 rf-p-4 rf-text-xs","aria-label":`${S} ${y} SRJ`,children:x?JSON.stringify(x,null,2):"No snapshot captured."})]})]})},qdn=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{te.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{Wk.captureException(o)}catch{}}},[t,e]),te.useEffect(()=>{if(n&&n.length>0)for(const o of n){const i=new Error(o.message||"Circuit JSON Error");o.stack&&(i.stack=o.stack);try{Wk.captureException(i,{error_type:o.type})}catch{}}},[n])},JLi=t=>{te.useEffect(()=>{try{j7n(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},$dn="0.0.2906",WLi={version:$dn},Vje={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},zje=new Map,R_e=t=>{const e=zje.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},jLi=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=zje.get(n.name);if(o)return{type:"tracked",store:t,...o};const i={connection:e.connect(n),stores:{}};return zje.set(n.name,i),{type:"tracked",store:t,...i}},Zdn=(t,e={})=>(n,o,i)=>{const{enabled:r,anonymousActionType:s,store:a,...A}=e;let c;try{c=(r??(Vje?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return(Vje?"production":void 0)!=="production"&&r&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,i);const{connection:l,...g}=jLi(a,c,A);let u=!0;i.setState=(p,m,_)=>{const f=n(p,m);if(!u)return f;const I=_===void 0?{type:s||"anonymous"}:typeof _=="string"?{type:_}:_;return a===void 0?(l?.send(I,o()),f):(l?.send({...I,type:`${a}/${I.type}`},{...R_e(A.name),[a]:i.getState()}),f)};const h=(...p)=>{const m=u;u=!1,n(...p),u=m},d=t(i.setState,o,i);if(g.type==="untracked"?l?.init(d):(g.stores[g.store]=i,l?.init(Object.fromEntries(Object.entries(g.stores).map(([p,m])=>[p,p===g.store?d:m.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let p=!1;const m=i.dispatch;i.dispatch=(..._)=>{(Vje?"production":void 0)!=="production"&&_[0].type==="__setState"&&!p&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),p=!0),m(..._)}}return l.subscribe(p=>{var m;switch(p.type){case"ACTION":if(typeof p.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return Jje(p.payload,_=>{if(_.type==="__setState"){if(a===void 0){h(_.state);return}Object.keys(_.state).length!==1&&console.error(`
|
|
5667
|
+
`,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),h=document.createElement("a");h.href=u,h.download=`${c}.test.ts`,h.click(),URL.revokeObjectURL(u)}catch(A){alert(`Error generating test.ts for ${t.getSolverName()}: ${A instanceof Error?A.message:String(A)}`)}o(!1)};return V.jsxs("div",{className:`relative ${e}`,ref:i,children:[V.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.getSolverName()}`,children:t.getSolverName()}),n&&V.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},Ldn=t=>t.activeSubSolver?[t,...Ldn(t.activeSubSolver)]:[t],gLi=({solver:t})=>{const e=Ldn(t);return V.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>V.jsxs("div",{className:"flex items-center",children:[o>0&&V.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),V.jsx(lLi,{solver:n})]},n.getSolverName()))})},uLi=({solver:t,triggerRender:e,animationSpeed:n=25,renderer:o,onRendererChange:i,onAnimationSpeedChange:r,onDownloadVisualization:s,onSolverStarted:a,onSolverCompleted:A})=>{const[c,l]=te.useReducer(B=>!B,!1),g=te.useRef(void 0),u=te.useRef(null),h="solver-debugger-last-iteration",[d,p]=te.useState(null),m=te.useRef(null),_=te.useMemo(()=>[{label:"Slow",value:250,description:"250ms"},{label:"Normal",value:100,description:"100ms"},{label:"Fast",value:10,description:"10ms"},{label:"Fast (2x)",value:5,description:"5ms"},{label:"Fast (10x)",value:1,description:"1ms"},{label:"Fast 20x",value:.5,description:"2 steps / 1ms"},{label:"Fast 100x",value:.1,description:"10 steps / 1ms"}],[]),f=()=>{const B=Math.max(1,n),S=n<1?Math.round(1/n):1;g.current=setInterval(()=>{if(t.solved||t.failed){g.current&&(clearInterval(g.current),g.current=void 0),l(),e(),A&&t.solved&&A(t);return}for(let Q=0;Q<S&&!(t.solved||t.failed);Q++)t.step();e()},B)},I=()=>{g.current&&(clearInterval(g.current),g.current=void 0)},C=()=>{!t.solved&&!t.failed&&(t.step(),e())},y=()=>{!t.solved&&!t.failed&&(a&&a(t),t.solve(),e(),A&&A(t))},x=()=>{c?(I(),l()):(l(),f())},E=()=>{if(t.solved||t.failed||c)return;u.current===null&&typeof window<"u"&&(u.current=window.localStorage.getItem(h));const B=window.prompt("Step until which iteration?",u.current??`${t.iterations}`);if(B===null)return;u.current=B,typeof window<"u"&&window.localStorage.setItem(h,B);const S=Number(B);if(!Number.isFinite(S)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<S&&!t.solved&&!t.failed;)t.step();e(),t.solved&&A&&A(t)};return te.useEffect(()=>()=>{I()},[]),te.useEffect(()=>{(t.solved||t.failed)&&c&&(I(),l())},[t.solved,t.failed,c]),te.useEffect(()=>{c&&(I(),f())},[n,c]),te.useEffect(()=>{if(typeof document>"u")return;const B=S=>{m.current&&!m.current.contains(S.target)&&p(null)};return document.addEventListener("mousedown",B),()=>{document.removeEventListener("mousedown",B)}},[]),V.jsxs("div",{className:"space-y-2 p-2 border-b",children:[V.jsx("div",{className:"flex items-center",children:V.jsxs("div",{className:"flex items-center gap-2",ref:m,children:[V.jsxs("div",{className:"flex h-9 items-center space-x-1 rounded-md border border-slate-200 bg-white p-1 shadow-sm",children:[V.jsxs("div",{className:"relative",children:[V.jsx("button",{type:"button",onClick:()=>p(d==="renderer"?null:"renderer"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":d==="renderer"?"open":"closed",children:"Renderer"}),d==="renderer"&&V.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[10rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:["vector","canvas"].map(B=>V.jsxs("button",{type:"button",onClick:()=>{i(B),p(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:[B==="vector"?"Vector":"Canvas",o===B&&V.jsx("span",{className:"ml-auto text-xs text-slate-500",children:"✓"})]},B))})]}),V.jsxs("div",{className:"relative",children:[V.jsx("button",{type:"button",onClick:()=>p(d==="debug"?null:"debug"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":d==="debug"?"open":"closed",children:"Debug"}),d==="debug"&&V.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[12rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:V.jsx("button",{type:"button",onClick:()=>{s(),p(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:"Download Visualization"})})]}),V.jsxs("div",{className:"relative",children:[V.jsx("button",{type:"button",onClick:()=>p(d==="animation"?null:"animation"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":d==="animation"?"open":"closed",children:"Animation"}),d==="animation"&&V.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[12rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:_.map(B=>V.jsxs("button",{type:"button",onClick:()=>{r(B.value),p(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:[B.label,V.jsx("span",{className:"ml-auto text-xs text-slate-500",children:B.description}),n===B.value&&V.jsx("span",{className:"ml-2 text-xs text-slate-500",children:"✓"})]},B.value))})]})]}),V.jsx(gLi,{solver:t})]})}),V.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[V.jsx("button",{onClick:C,disabled:t.solved||t.failed||c,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),V.jsx("button",{onClick:y,disabled:t.solved||t.failed||c,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),V.jsx("button",{onClick:x,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${c?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:c?"Stop":"Animate"}),V.jsx("button",{onClick:E,disabled:t.solved||t.failed||c,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),V.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),t.solved&&V.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&V.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&V.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},dLi=t=>t!==null&&"pipelineDef"in t&&Array.isArray(t.pipelineDef),hLi=(t,e,n)=>{const o=t.currentPipelineStageIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},pLi=(t,e)=>{const o=t.pipelineDef[e].solverName,i=hLi(t,e),r=t[o],s=t.firstIterationOfStage?.[o]??(e===t.currentPipelineStageIndex?t.iterations:null),a=t.iterations;let A=0;if(i==="Completed"){const u=t.pipelineDef[e+1],h=u?t.firstIterationOfStage?.[u.solverName]:void 0;h!==void 0&&s!==null?A=h-s:s!==null&&(A=a-s)}else i==="In Progress"&&s!==null&&(A=a-s);const c=t.timeSpentOnStage?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const g=r?.stats??null;return{index:e,name:o,status:i,firstIteration:s,iterations:A,progress:l,timeSpent:c,stats:g&&Object.keys(g).length>0?g:null,solverInstance:r??null}},mLi=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return V.jsx("span",{className:`font-medium ${e[t]}`,children:t})},_Li=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:V.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),V.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},Hdn=t=>{if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"||t==null)return String(t);if(typeof t=="object")try{return JSON.stringify(t)}catch{return String(t)}return String(t)},fLi=t=>Object.entries(t).map(([e,n])=>`${e}: ${Hdn(n)}`).join(", "),ILi=({stats:t})=>{if(!t||Object.keys(t).length===0)return V.jsx("span",{children:"-"});const e=Object.entries(t),n=fLi(t);return V.jsxs("details",{className:"cursor-pointer",children:[V.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),V.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>V.jsxs("div",{children:[o,": ",Hdn(i)]},o))})]})},Gje=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(Gje);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=Gje(o));return e},CLi=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=Gje(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${e}_input.json`,r.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},yLi=({expanded:t})=>V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:`w-4 h-4 transition-transform duration-200 ${t?"rotate-90":""}`,children:V.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})}),Odn=t=>{let e=t;for(;e.activeSubSolver;)e=e.activeSubSolver;return e},Gdn=({solver:t,onStepUntilPhase:e,onDownloadInput:n,isNested:o=!1,indentLevel:i=0,triggerRender:r})=>{const[s,a]=te.useState(new Set),A=t.pipelineDef.map((m,_)=>pLi(t,_)),c=m=>{a(_=>{const f=new Set(_);return f.has(m)?f.delete(m):f.add(m),f})},l=m=>{e?.(m)},g=m=>{m.solverInstance&&(n?n(m.solverInstance,m.name):CLi(m.solverInstance,m.name))},u=m=>`${(m/1e3).toFixed(2)}s`,h=()=>{if(!t.solved&&!t.failed){const m=t.activeSubSolver;for(;!t.solved&&!t.failed&&(t.step(),!(t.activeSubSolver&&t.activeSubSolver!==m)););r?.()}},d=()=>{if(!t.solved&&!t.failed){const m=Odn(t);for(;!t.solved&&!t.failed&&(t.step(),Odn(t)===m););r?.()}},p=i*24;return V.jsxs("div",{className:o?"":"border-t border-gray-200",children:[!o&&V.jsxs("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200 flex items-center justify-between",children:[V.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Stages"}),V.jsxs("div",{className:"flex gap-2",children:[V.jsx("button",{onClick:d,disabled:t.solved||t.failed,className:"bg-indigo-500 hover:bg-indigo-600 disabled:bg-gray-300 disabled:cursor-not-allowed cursor-pointer text-white px-3 py-1 rounded text-sm",children:"Next Solver"}),V.jsx("button",{onClick:h,disabled:t.solved||t.failed,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 disabled:cursor-not-allowed cursor-pointer text-white px-3 py-1 rounded text-sm",children:"Next Stage"})]})]}),V.jsx("div",{className:"overflow-x-auto",children:V.jsxs("table",{className:"w-full text-sm",children:[!o&&V.jsx("thead",{children:V.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stage"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),V.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",V.jsx("sub",{children:"0"})]}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),V.jsx("tbody",{children:A.map(m=>{const _=dLi(m.solverInstance),f=s.has(m.name);return V.jsxs(ks.Fragment,{children:[V.jsxs("tr",{className:`border-b border-gray-100 ${m.status==="In Progress"?"bg-yellow-50":""}`,children:[V.jsx("td",{className:"px-4 py-2",children:V.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:p},children:[_?V.jsx("button",{onClick:()=>c(m.name),className:"text-gray-500 hover:text-gray-700",title:f?"Collapse":"Expand",children:V.jsx(yLi,{expanded:f})}):V.jsx("span",{className:"w-4"}),V.jsx("span",{className:"text-gray-400 w-6",children:String(m.index+1).padStart(2,"0")}),V.jsx("button",{onClick:()=>l(m.name),disabled:m.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${m.name} completes`,children:V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),V.jsx("span",{className:"font-medium text-gray-900",children:m.name})]})}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(mLi,{status:m.status})}),V.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:m.firstIteration!==null?m.firstIteration:""}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:m.iterations}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(_Li,{progress:m.progress})}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:u(m.timeSpent)}),V.jsx("td",{className:"px-4 py-2 text-gray-500",children:V.jsx(ILi,{stats:m.stats})}),V.jsx("td",{className:"px-4 py-2",children:m.solverInstance?V.jsxs("button",{onClick:()=>g(m),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${m.name}`,children:[V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),V.jsx("span",{children:"Input"})]}):null})]}),_&&f&&V.jsx("tr",{children:V.jsx("td",{colSpan:8,className:"p-0",children:V.jsx(Gdn,{solver:m.solverInstance,onStepUntilPhase:e,onDownloadInput:n,isNested:!0,indentLevel:i+1,triggerRender:r})})})]},m.name)})})]})})]})};function xLi({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,A=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(m,_)=>{typeof m=="number"&&(m<s&&(s=m),m>A&&(A=m)),typeof _=="number"&&(_<a&&(a=_),_>c&&(c=_))};for(const m of e)l(m.x,m.y);for(const m of n){const _=m.points??[];for(const f of _)l(f.x,f.y)}for(const m of o){const _=m.x??0,f=m.y??0,I=m.width??0,C=m.height??0;l(_,f),l(_+I,f+C)}for(const m of i){const _=m.x??0,f=m.y??0,I=m.radius??1;l(_-I,f-I),l(_+I,f+I)}for(const m of r)l(m.x,m.y);(!isFinite(s)||!isFinite(a)||!isFinite(A)||!isFinite(c))&&(s=-20,a=-20,A=20,c=20);const g=10,u=s-g,h=a-g,d=Math.max(1,A-s+2*g),p=Math.max(1,c-a+2*g);return V.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${h} ${d} ${p}`,role:"img","aria-label":"Graphics fallback",children:[o.map((m,_)=>V.jsx("rect",{x:m.x??0,y:m.y??0,width:m.width??0,height:m.height??0,fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`rect-${_}`)),n.map((m,_)=>V.jsx("polyline",{fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1,points:(m.points??[]).map(f=>`${f.x??0},${f.y??0}`).join(" ")},`line-${_}`)),i.map((m,_)=>V.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.fillColor??"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`circle-${_}`)),e.map((m,_)=>V.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.color??"black"},`point-${_}`)),r.map((m,_)=>V.jsx("text",{x:m.x??0,y:m.y??0,fontSize:m.fontSize??10,fill:m.color??"black",children:m.text??""},`text-${_}`))]})}var ELi=class extends ks.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}},BLi=({solver:t,createSolver:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=te.useReducer(f=>f+1,0),[a]=te.useState(()=>{if(e)return e();if(!t)throw new Error("GenericSolverDebugger requires solver or createSolver");return t}),[A,c]=te.useState(()=>typeof window>"u"?"vector":window.localStorage.getItem("solver-utils-renderer")==="canvas"?"canvas":"vector"),[l,g]=te.useState(n),u=te.useMemo(()=>{try{return a.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(f){return console.error("Visualization error:",f),{points:[],lines:[],rects:[],circles:[]}}},[a,r]),h=te.useMemo(()=>(u.rects?.length||0)===0&&(u.lines?.length||0)===0&&(u.points?.length||0)===0&&(u.circles?.length||0)===0,[u]);te.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const f=document.createElement("script");f.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(f)}},[]),te.useEffect(()=>{g(n)},[n]);const d=a.pipelineDef!==void 0,p=f=>{const I=a;if(!a.solved&&!a.failed){for(;!a.solved&&!a.failed&&I.currentPipelineStageIndex<=I.pipelineDef.findIndex(C=>C.solverName===f);)a.step();s()}},m=()=>{const f=JSON.stringify(u,null,2),I=new Blob([f],{type:"application/json"}),C=URL.createObjectURL(I),y=document.createElement("a");y.download="visualization.json",y.href=C,document.body.appendChild(y),y.click(),document.body.removeChild(y),URL.revokeObjectURL(C)},_=f=>{c(f),typeof window<"u"&&window.localStorage.setItem("solver-utils-renderer",f)};return V.jsxs("div",{children:[V.jsx(uLi,{solver:a,triggerRender:s,animationSpeed:l,renderer:A,onRendererChange:_,onAnimationSpeedChange:g,onDownloadVisualization:m,onSolverStarted:o,onSolverCompleted:i}),h?V.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):V.jsx(ELi,{fallback:V.jsx(xLi,{graphics:u}),children:A==="canvas"?V.jsx(cLi,{graphics:u}):V.jsx(sLi,{graphics:u})}),d&&V.jsx(Gdn,{solver:a,onStepUntilPhase:p,triggerRender:s})]})};const bLi=()=>{te.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},SLi=1e3,bE=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),s=document.createElement("a");s.href=r,s.download=n,s.target="_blank",s.rel="noopener noreferrer",s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>{URL.revokeObjectURL(r)},SLi)},Yje=t=>{let e=t.trim().replace(/[\\/:*?"<>|]/g,"_").replace(/[\x00-\x1f]/g,"").replace(/^\.+/,"").replace(/\.+$/,"").replace(/\s+/g," ").replace(/_+/g,"_");return/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i.test(e)&&(e=`_${e}`),e=e.slice(0,200),e||"untitled"},QLi=t=>{const e=t.solverConstructorArgs??[t.solverParams];if(t.solverName!=="AutoroutingPipelineSolver7_MultiGraph"||e.length!==1)return e;const[{input:n,options:o}]=e;return[n,o]},J6="https://github.com/tscircuit/tscircuit-autorouter/issues/new",Ydn="https://github.com/tscircuit/copper-pour-solver/issues/new",Udn="https://github.com/tscircuit/calculate-packing/issues/new",vLi="https://github.com/tscircuit/matchpack/issues/new",Kdn="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",wLi={PackSolver2:Udn,LayoutPipelineSolver:vLi,AutoroutingPipelineSolver:J6,AssignableAutoroutingPipeline2:J6,AssignableAutoroutingPipeline3:J6,AutoroutingPipeline1_OriginalUnravel:J6,AutoroutingPipelineSolver3_HgPortPointPathing:J6,AutoroutingPipelineSolver4:J6,AutoroutingPipelineSolver5:J6,AutoroutingPipelineSolver7_MultiGraph:J6,AutoroutingPipelineSolver8:J6,CopperPourPipelineSolver:Ydn,SchematicTracePipelineSolver:Kdn},PLi=t=>t.toLowerCase().includes("pack")?x7i:t.toLowerCase().includes("rout")?OAn:h7i,Vdn=t=>{const e=wLi[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?J6:n.includes("schematic")&&n.includes("trace")?Kdn:n.includes("copperpour")?Ydn:n.includes("pack")?Udn:null},MLi=t=>`${Yje(`${t.componentName}-${t.solverName}`)}-solver-input.json`,zdn=t=>{bE(JSON.stringify(t.solverParams,null,2),{fileName:MLi(t),mimeType:"application/json"})},DLi=({solverEvent:t})=>{const e=Vdn(t.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[V.jsxs(Zc,{type:"button",variant:"outline",size:"sm",onClick:()=>zdn(t),children:[V.jsx(j$,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?V.jsx(Zc,{asChild:!0,variant:"outline",size:"sm",children:V.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[V.jsx(Ype,{className:"rf-w-4 rf-h-4"}),"Report"]})}):V.jsxs(Zc,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[V.jsx(Ype,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},NLi=({solverEvent:t})=>{const e=Vdn(t.solverName);return e?V.jsx(Zc,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:V.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:V.jsx(Ype,{className:"rf-w-4 rf-h-4"})})}):V.jsx(Zc,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:V.jsx(Ype,{className:"rf-w-4 rf-h-4"})})},RLi=({solverEvents:t=[]})=>{const[e,n]=te.useState(null);bLi();const o=te.useMemo(()=>{const a=new Map;for(const A of t){const c=`${A.componentName}-${A.solverName}`;a.set(c,A)}return a},[t]),i=te.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=te.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=PRe[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(PRe).join(", ")}`,classFound:!1};try{return{instance:new a(...QLi(r)),error:null,classFound:!0}}catch(A){const c=A instanceof Error?A.message:String(A);return console.error("Failed to reconstruct solver:",A),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?V.jsx("div",{className:"rf-p-4",children:V.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:V.jsxs("div",{className:"rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),V.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):V.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[V.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(a=>{const A=o.get(a),c=e===a;return V.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const l=PLi(A.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:A.componentName}),V.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:A.solverName})]})]})})()},a)})]}),V.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?V.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[V.jsx(DLi,{solverEvent:r}),V.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:V.jsx(KB,{fallback:V.jsx("div",{className:"rf-p-4",children:V.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),V.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:V.jsx(BLi,{solver:s.instance})})})]}):V.jsxs("div",{className:"rf-p-4",children:[V.jsxs("div",{className:"rf-mb-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),V.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&V.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:V.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),V.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[V.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[V.jsx(NLi,{solverEvent:r}),V.jsx(Zc,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>zdn(r),children:V.jsx(j$,{className:"rf-w-4 rf-h-4"})})]})]}),V.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:V.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):V.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},TLi=new Map([["custom","Custom"],["fanout","Fanout"],["single_layer_fanout","Single layer fanout"],["tscircuit_simplify","Simplify"]]),kLi=new Set(["tscircuit","default","auto","auto_local"]);function FLi(t){if(t==="FanoutSolver")return"Fanout";if(t==="AutoroutingPipelineSolver11_Simplification")return"Simplify";const e=t.match(/^AutoroutingPipeline(?:Solver)?(\d+)(?:_|$)/);if(e)return`Pipeline${e[1]}`;const n=t.match(/^AssignableAutoroutingPipeline(\d+)$/);return n?`Assignable${n[1]}`:t}function LLi(t){const e=t.autorouterName?.trim(),n=e?.replace(/-/g,"_"),o=n&&TLi.get(n);if(o)return o;if(n&&!kLi.has(n))return e;const i=t.solverName?.trim();if(i)return FLi(i);const r=t.autorouterVersion?.trim();if(r){const s=r.match(/^beta[_-]pipeline(\d+)$/);return s?`Pipeline${s[1]}`:r==="latest"?"default":r}return e?"default":"Unknown"}const Uje="#fbbf24";function HLi(t){const e=t.endSimpleRouteJson?.traces??[],n=new Set(e.flatMap(i=>[i.pcb_trace_id,i.__replaces_pcb_trace_id].filter(r=>r!==void 0)));return[...(t.startSimpleRouteJson?.traces??[]).filter(i=>!n.has(i.pcb_trace_id)),...e]}function Jdn(t){const e=new Map((t.startSimpleRouteJson?.traces??[]).map(n=>[n.pcb_trace_id,n]));return(t.endSimpleRouteJson?.traces??[]).filter(n=>{const o=e.get(n.pcb_trace_id);return!o||!!n.__replaces_pcb_trace_id&&n.__replaces_pcb_trace_id!==o.__replaces_pcb_trace_id||JSON.stringify(o.route)!==JSON.stringify(n.route)}).map(n=>n.pcb_trace_id)}function OLi(t,e){return{outer_diameter:t.via_diameter??e.minViaPadDiameter??e.min_via_pad_diameter??e.minViaDiameter??.6,hole_diameter:t.via_hole_diameter??e.minViaHoleDiameter??e.min_via_hole_diameter??.3}}function Wdn(t,e){const n=[];for(const a of t.route)a.route_type==="wire"?n.push({...a,layer:a.layer}):a.route_type==="via"?n.push({route_type:"via",x:a.x,y:a.y,from_layer:a.from_layer,to_layer:a.to_layer,...OLi(a,e)}):a.route_type==="through_obstacle"&&n.push({route_type:"through_pad",start:{...a.start},end:{...a.end},width:a.width,start_layer:a.from_layer,end_layer:a.to_layer,pcb_smtpad_id:a.circuitJsonMetadata?.pcb_smtpad_id,pcb_plated_hole_id:a.circuitJsonMetadata?.pcb_plated_hole_id});const o=a=>{let A=-1,c=Number.POSITIVE_INFINITY;return n.forEach((l,g)=>{if(l.route_type!=="wire")return;const u=Math.hypot(l.x-a.x,l.y-a.y);u<c&&(c=u,A=g)}),A},i=t.route.filter(a=>a.route_type==="jumper").map(a=>[o(a.start),o(a.end)].sort((A,c)=>A-c)).filter(([a,A])=>a>=0&&A>a).sort(([a],[A])=>a-A),r=[];let s=0;for(const[a,A]of i)a>=s&&r.push(n.slice(s,a+1)),s=Math.max(s,A);return s<n.length&&r.push(n.slice(s)),r}function GLi(t){const e=[],n=[],o=t.endSimpleRouteJson;if(!o)return{lines:e,circles:n};const i=new Set(Jdn(t));for(const r of o.traces??[])if(i.has(r.pcb_trace_id))for(const s of Wdn(r,o)){let a;for(const A of s){if(A.route_type==="through_pad"){a={...A.end,layer:A.end_layer,width:A.width};continue}const c=A.route_type==="wire"?A.layer:A.from_layer;a&&a.layer===c&&(a.x!==A.x||a.y!==A.y)&&e.push({points:[{x:a.x,y:a.y},{x:A.x,y:A.y}],strokeWidth:A.route_type==="wire"?A.width:a.width,strokeColor:Uje,layer:c}),A.route_type==="via"&&n.push({center:{x:A.x,y:A.y},radius:A.outer_diameter/2,stroke:Uje,fill:"transparent"}),a={x:A.x,y:A.y,layer:A.route_type==="wire"?A.layer:A.to_layer,width:A.route_type==="wire"?A.width:a?.width??o.minTraceWidth}}}return{coordinateSystem:"cartesian",lines:e,circles:n}}function YLi(t){const e=JSON.stringify(t);let n=2166136261;for(let o=0;o<e.length;o++)n=Math.imul(n^e.charCodeAt(o),16777619);return(n>>>0).toString(36)}const ULi=new Set(["pcb_trace","pcb_via","pcb_copper_pour","pcb_ground_plane","pcb_ground_plane_region","pcb_thermal_spoke","pcb_breakout_point"]);function KLi(t,e,n){const o=n==="input"?e.startSimpleRouteJson??e.errorSimpleRouteJson:e.endSimpleRouteJson,i=t.filter(c=>!ULi.has(c.type)&&!c.type.endsWith("_error")&&!c.type.endsWith("_warning"));if(!o)return i;const r=n==="input"?o.traces??[]:HLi(e),s=new Set(t.filter(c=>c.type==="source_trace").map(c=>c.source_trace_id)),a=["top",...Array.from({length:Math.max(0,o.layerCount-2)},(c,l)=>`inner${l+1}`),...o.layerCount>1?["bottom"]:[]],A=[];for(const c of r){const g=o.connections.find(h=>h.name===c.connection_name||h.source_trace_id===c.connection_name)?.source_trace_id??c.connection_name??"",u=Wdn(c,o);for(const[h,d]of u.entries()){const p={type:"pcb_trace",pcb_trace_id:`${e.id}_${n}_${c.pcb_trace_id}_${h}_${YLi(d)}`,subcircuit_id:e.subcircuit_id??void 0,source_trace_id:s.has(g)?g:void 0,route:d};A.push(p);for(const[m,_]of d.entries()){if(_.route_type!=="via")continue;const f=a.indexOf(_.from_layer),I=a.indexOf(_.to_layer),C={type:"pcb_via",pcb_via_id:`${p.pcb_trace_id}_via_${m}`,pcb_trace_id:p.pcb_trace_id,subcircuit_id:e.subcircuit_id??void 0,x:_.x,y:_.y,outer_diameter:_.outer_diameter,hole_diameter:_.hole_diameter,layers:f>=0&&I>=0?a.slice(Math.min(f,I),Math.max(f,I)+1):[_.from_layer,_.to_layer]};A.push(C)}}}return[...i,...A]}const Kje=(t,e)=>t.phaseName||`Phase ${t.phaseOrdinal??e+1}`,jdn=t=>t.componentDisplayName?.match(/name="([^"]+)"/)?.[1]?.replace(/^\./,"")||t.componentDisplayName||t.subcircuit_id||"Board",Xdn=t=>t.startSimpleRouteJson??t.endSimpleRouteJson??t.errorSimpleRouteJson,VLi={is_showing_autorouting:!0,is_showing_rats_nest:!1,is_showing_drc_errors:!1,is_showing_drc_warnings:!1,is_showing_pcb_groups:!1},zLi=({circuitJson:t,phases:e=[],isRunning:n=!1})=>{const[o,i]=te.useState(null),[r,s]=te.useState("output"),[a,A]=te.useState(!0),[c,l]=te.useState(!1),g=te.useRef(null),[u,h]=te.useState(480),d=o?e.findIndex(R=>R.id===o.id&&Xdn(R)===Xdn(o)):-1,p=d<0?e.length-1:d,m=e[p],_=d<0,f=!!m?.endSimpleRouteJson,I=m?.startSimpleRouteJson??m?.errorSimpleRouteJson,C=!!I,y=r==="output"&&!f?"input":r==="input"&&!C?"output":r,x=y==="input"?I:m?.endSimpleRouteJson,E=te.useMemo(()=>!m||!x?null:KLi(t??[],m,y),[t,m,x,y]),B=te.useMemo(()=>m&&y==="output"&&a?GLi(m):{lines:[],circles:[]},[m,y,a]);if(te.useLayoutEffect(()=>{const R=g.current;if(!R)return;const F=()=>h(Math.max(360,R.clientHeight));F();const O=new ResizeObserver(F);return O.observe(R),()=>O.disconnect()},[!!m]),!m)return V.jsxs("div",{className:"rf-flex rf-min-h-[400px] rf-flex-col rf-items-center rf-justify-center rf-gap-3 rf-p-8 rf-text-center",children:[V.jsx(OAn,{className:"rf-h-7 rf-w-7 rf-text-blue-500"}),V.jsx("h3",{className:"rf-text-base rf-font-medium",children:n?"Waiting for autorouting":"No autorouting captures"}),V.jsx("p",{className:"rf-max-w-md rf-text-sm rf-text-gray-500",children:n?"Phases appear as the circuit routes. Each capture includes its input and output on the PCB.":"Run a circuit with autorouting enabled to inspect its phases. A circuit JSON file alone does not include routing history."})]});const S=Kje(m,p),Q=m.status==="running"&&n,w=!f,M=I?.connections.length,k=E?.filter(R=>R.type==="pcb_trace").length??0;return V.jsxs("div",{className:"rf-flex rf-h-full rf-min-h-[620px] rf-flex-col rf-bg-white md:rf-flex-row","data-testid":"autorouting-explorer",children:[V.jsxs("aside",{className:"rf-flex rf-shrink-0 rf-flex-col rf-border-b rf-border-gray-200 md:rf-w-52 md:rf-border-b-0 md:rf-border-r","aria-label":"Routing phases",children:[V.jsxs("div",{className:"rf-flex rf-items-center rf-justify-between rf-px-3 rf-py-2 rf-text-xs rf-text-gray-500",children:[V.jsx("span",{children:"Routing phases"}),V.jsx("span",{children:e.length})]}),V.jsx("div",{className:"rf-flex rf-gap-1 rf-overflow-x-auto rf-px-1.5 rf-pb-1.5 md:rf-flex-col md:rf-overflow-x-hidden md:rf-overflow-y-auto",children:e.map((R,F)=>{const O=Jdn(R).length,U=R.endSimpleRouteJson?`${O} ${O===1?"trace":"traces"} routed`:R.status==="error"?"Failed":R.status==="running"&&n?"Routing…":"No output";return V.jsxs("button",{type:"button","aria-pressed":F===p,title:`${jdn(R)} · ${U}`,onClick:()=>i(R),className:zr("rf-flex rf-min-w-[192px] rf-items-start rf-gap-2 rf-rounded-md rf-border rf-px-2 rf-py-2 rf-text-left md:rf-min-w-0",F===p?"rf-border-blue-200 rf-bg-blue-50":"rf-border-transparent hover:rf-bg-gray-50"),children:[V.jsx("span",{className:zr("rf-flex rf-h-5 rf-w-5 rf-shrink-0 rf-items-center rf-justify-center rf-rounded-full rf-text-[11px]",F===p?"rf-bg-blue-600 rf-text-white":"rf-bg-gray-100 rf-text-gray-500"),children:F+1}),V.jsxs("span",{className:"rf-min-w-0 rf-flex-1",children:[V.jsxs("span",{className:"rf-flex rf-items-center rf-gap-1",children:[V.jsx("span",{className:"rf-min-w-0 rf-flex-1 rf-truncate rf-text-xs rf-font-medium rf-leading-5 rf-text-gray-800",title:Kje(R,F),children:Kje(R,F)}),R.status==="complete"?V.jsx(W$,{"aria-label":"Captured",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-green-600"}):R.status==="error"?V.jsx(tJe,{"aria-label":"Failed",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-red-500"}):n?V.jsx(a4,{"aria-label":"Routing",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-animate-spin rf-text-blue-500"}):null]}),V.jsxs("span",{className:"rf-block rf-text-[11px] rf-leading-4 rf-text-gray-500",children:[LLi(R)," · ",U]})]})]},R.id)})})]}),V.jsxs("div",{className:"rf-flex rf-min-w-0 rf-flex-1 rf-flex-col",children:[V.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-gap-3 rf-border-b rf-border-gray-200 rf-px-4 rf-py-3",children:[V.jsxs("h3",{className:"rf-mr-auto rf-flex rf-items-center rf-gap-2 rf-text-sm rf-font-medium",children:[S,V.jsxs("span",{className:"rf-text-xs rf-font-normal rf-text-gray-500",children:[p+1," of ",e.length]})]}),n&&V.jsx("button",{type:"button",onClick:()=>i(null),disabled:_,className:"rf-text-xs rf-text-blue-600 disabled:rf-text-gray-500",children:_?"Following latest":"Follow latest"}),V.jsx("div",{className:"rf-flex rf-rounded-md rf-bg-gray-100 rf-p-1","aria-label":"Phase snapshot",children:["input","output"].map(R=>V.jsx("button",{type:"button","aria-pressed":y===R,disabled:R==="input"?!C:!f,onClick:()=>s(R),className:zr("rf-rounded rf-px-3 rf-py-1 rf-text-xs disabled:rf-opacity-40",y===R?"rf-bg-white rf-text-gray-900 rf-shadow-sm":"rf-text-gray-500"),children:R==="input"?"Input":"Output"},R))})]}),V.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-justify-between rf-gap-2 rf-px-4 rf-py-2 rf-text-xs rf-text-gray-600",children:[V.jsxs("label",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx("input",{type:"checkbox",checked:a,disabled:y!=="output",onChange:R=>A(R.target.checked),className:"rf-accent-blue-600"}),V.jsx("span",{"aria-hidden":"true",className:"rf-inline-block rf-h-0.5 rf-w-3",style:{backgroundColor:Uje}}),"Highlight changes (all layers)"]}),V.jsxs("span",{children:[y==="input"?"Before this phase":"After this phase"," ","· ",k," traces"]})]}),w&&V.jsx("div",{className:zr("rf-border-y rf-px-4 rf-py-2 rf-text-xs",m.status==="error"?"rf-border-red-100 rf-bg-red-50 rf-text-red-700":"rf-border-blue-100 rf-bg-blue-50 rf-text-blue-700"),role:"status",children:m.status==="error"?`Routing failed: ${m.error?.message||"No output was captured."}`:Q?"Routing in progress. Showing captured input until output is available.":"No output was captured for this phase. Showing the available input."}),V.jsx("div",{ref:g,className:"rf-relative rf-min-h-[360px] rf-flex-1","data-testid":"autorouting-pcb",children:E?V.jsx(Rje,{circuitJson:E,height:u,allowEditing:!1,clickToInteractEnabled:!1,initialState:VLi,debugGraphics:B}):V.jsx("div",{className:"rf-p-6 rf-text-sm rf-text-gray-500",children:"No PCB snapshot available for this capture."})}),V.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-justify-between rf-gap-2 rf-border-t rf-border-gray-200 rf-px-4 rf-py-3 rf-text-xs rf-text-gray-500",children:[V.jsxs("span",{children:[M===void 0?"Input unavailable":`${M} input connections`,` · ${jdn(m)}`]}),V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-4",children:[V.jsxs("button",{type:"button",disabled:!x,onClick:()=>bE(JSON.stringify(x,null,2),{fileName:`${m.id}-${y}.srj.json`,mimeType:"application/json"}),className:"rf-flex rf-items-center rf-gap-1 disabled:rf-opacity-40",children:[V.jsx(j$,{className:"rf-h-3 rf-w-3"}),"Download SRJ"]}),V.jsxs("button",{type:"button","aria-expanded":c,onClick:()=>l(!c),className:"rf-flex rf-items-center rf-gap-1",children:[V.jsx(XY,{className:zr("rf-h-3 rf-w-3",c&&"rf-rotate-90")}),"Inspect SRJ"]})]})]}),c&&V.jsx("pre",{className:"rf-m-0 rf-max-h-64 rf-overflow-auto rf-border-t rf-border-gray-200 rf-bg-gray-50 rf-p-4 rf-text-xs","aria-label":`${S} ${y} SRJ`,children:x?JSON.stringify(x,null,2):"No snapshot captured."})]})]})},qdn=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{te.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{Wk.captureException(o)}catch{}}},[t,e]),te.useEffect(()=>{if(n&&n.length>0)for(const o of n){const i=new Error(o.message||"Circuit JSON Error");o.stack&&(i.stack=o.stack);try{Wk.captureException(i,{error_type:o.type})}catch{}}},[n])},JLi=t=>{te.useEffect(()=>{try{j7n(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},$dn="0.0.2908",WLi={version:$dn},Vje={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},zje=new Map,R_e=t=>{const e=zje.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},jLi=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=zje.get(n.name);if(o)return{type:"tracked",store:t,...o};const i={connection:e.connect(n),stores:{}};return zje.set(n.name,i),{type:"tracked",store:t,...i}},Zdn=(t,e={})=>(n,o,i)=>{const{enabled:r,anonymousActionType:s,store:a,...A}=e;let c;try{c=(r??(Vje?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return(Vje?"production":void 0)!=="production"&&r&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,i);const{connection:l,...g}=jLi(a,c,A);let u=!0;i.setState=(p,m,_)=>{const f=n(p,m);if(!u)return f;const I=_===void 0?{type:s||"anonymous"}:typeof _=="string"?{type:_}:_;return a===void 0?(l?.send(I,o()),f):(l?.send({...I,type:`${a}/${I.type}`},{...R_e(A.name),[a]:i.getState()}),f)};const h=(...p)=>{const m=u;u=!1,n(...p),u=m},d=t(i.setState,o,i);if(g.type==="untracked"?l?.init(d):(g.stores[g.store]=i,l?.init(Object.fromEntries(Object.entries(g.stores).map(([p,m])=>[p,p===g.store?d:m.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let p=!1;const m=i.dispatch;i.dispatch=(..._)=>{(Vje?"production":void 0)!=="production"&&_[0].type==="__setState"&&!p&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),p=!0),m(..._)}}return l.subscribe(p=>{var m;switch(p.type){case"ACTION":if(typeof p.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return Jje(p.payload,_=>{if(_.type==="__setState"){if(a===void 0){h(_.state);return}Object.keys(_.state).length!==1&&console.error(`
|
|
5668
5668
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
5669
5669
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
5670
5670
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|