@tscircuit/runframe 0.0.2940 → 0.0.2942
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/standalone.min.js
CHANGED
|
@@ -1064,8 +1064,8 @@ ${u.map(B=>B.spiceString).join(`
|
|
|
1064
1064
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
1065
1065
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
1066
1066
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|
|
1067
|
-
`);const _=f.state[a];if(_==null)return;JSON.stringify(i.getState())!==JSON.stringify(_)&&h(_);return}i.dispatchFromDevtools&&typeof i.dispatch=="function"&&i.dispatch(f)});case"DISPATCH":switch(m.payload.type){case"RESET":return h(d),a===void 0?l?.init(i.getState()):l?.init(Wge(A.name));case"COMMIT":if(a===void 0){l?.init(i.getState());return}return l?.init(Wge(A.name));case"ROLLBACK":return mNe(m.state,f=>{if(a===void 0){h(f),l?.init(i.getState());return}h(f[a]),l?.init(Wge(A.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return mNe(m.state,f=>{if(a===void 0){h(f);return}JSON.stringify(i.getState())!==JSON.stringify(f[a])&&h(f[a])});case"IMPORT_STATE":{const{nextLiftedState:f}=m.payload,_=(p=f.computedStates.slice(-1)[0])==null?void 0:p.state;if(!_)return;h(a===void 0?_:_[a]),l?.send(null,f);return}case"PAUSE_RECORDING":return g=!g}return}}),d},mNe=(t,e)=>{let n;try{n=JSON.parse(t)}catch(o){console.error("[zustand devtools middleware] Could not parse the received json",o)}n!==void 0&&e(n)},UC=window.TSCIRCUIT_FILESERVER_API_BASE_URL??"/api",cVo=[".tsx",".ts",".jsx",".js",".mjs",".json",".kicad_pcb",".kicad_sym",".kicad_sch",".kicad_prl",".kicad_pro"],pNe=t=>cVo.some(e=>t.endsWith(e)),a$=VHt.extend("store");async function aOt(t,e){return(await(await fetch(`${UC}/files/upsert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:t,text_content:e})})).json()).file}async function fNe(t){return(await(await fetch(`${UC}/files/get?file_path=${encodeURIComponent(t)}`)).json()).file}async function lVo(t){const e=t?`${UC}/events/list?since=${encodeURIComponent(t)}`:`${UC}/events/list`;return(await(await fetch(e)).json()).event_list}async function uVo(){const t=await fetch(`${UC}/files/list`),{file_list:e}=await t.json(),n=new Map;for(const o of e){if(pNe(o.file_path)){const i=await fNe(o.file_path);n.set(o.file_path,i.text_content);continue}n.set(o.file_path,"__STATIC_ASSET__")}return n}const gVo=["manual-edits.json","manual_edits.json"],Id=rOt()(sOt((t,e)=>({fsMap:new Map,lastEventTime:new Date().toISOString(),isPolling:!1,error:null,circuitJson:null,lastManualEditsChangeSentAt:0,recentEvents:[],simulateScenarioOrder:void 0,currentMainComponentPath:null,recentlySavedFiles:[],loadInitialFiles:async()=>{const n=await uVo();a$("loaded initial files",{fsMap:n}),t({fsMap:n})},upsertFile:async(n,o)=>{try{const i=await aOt(n,o);t(r=>({fsMap:new Map(r.fsMap).set(i.file_path,i.text_content)}))}catch(i){t({error:i})}},getFile:async n=>{try{const o=await fNe(n);t(i=>({fsMap:new Map(i.fsMap).set(o.file_path,o.text_content)}))}catch(o){t({error:o})}},setCircuitJson:n=>{n!==e().circuitJson&&t({circuitJson:n})},addRecentlySavedFile:n=>{t(o=>{if(gVo.includes(n)||!pNe(n))return o;const i=o.recentlySavedFiles.filter(r=>r!==n);return{recentlySavedFiles:[n,...i].slice(0,10)}})},startPolling:()=>{const n=async()=>{const o=e();if(o.isPolling){try{const i=await lVo(o.lastEventTime);if(i.length>0){const r=i[i.length-1].created_at;a$("received events",i.map(A=>A.event_type)),t(A=>({recentEvents:[...A.recentEvents,...i].slice(0,100),lastEventTime:r}));let s=0;const a=new Map(o.fsMap);for(const A of i)if(A.event_type==="FILE_UPDATED"){s++;const c=await fNe(A.file_path);if(A.file_path==="manual_edits.json"&&Date.now()-o.lastManualEditsChangeSentAt<1e3)continue;pNe(c.file_path)?a.set(c.file_path,c.text_content??""):a.set(c.file_path,"__STATIC_ASSET__"),e().addRecentlySavedFile(A.file_path)}else A.event_type==="FILE_DELETED"&&(s++,a.delete(A.file_path));s>0&&(a$("updating fsMap, fsUpdateCount:",s),t({fsMap:a}))}}catch(i){t({error:i})}setTimeout(n,1e3)}};t({isPolling:!0}),n()},stopPolling:()=>{t({isPolling:!1})},pushEvent:async n=>{await fetch(`${UC}/events/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})},applyEditEventsAndUpdateManualEditsJson:async n=>{a$("applyEditEventsAndUpdateManualEditsJson",{editEvents:n});const o=e();if(!o.circuitJson)return;const i=o.fsMap.get("manual-edits.json"),r=i?JSON.parse(i):{},s=TFt({circuitJson:o.circuitJson,editEvents:n,manualEditsFile:r});a$("updatedManualEditsFileContent",s),t(a=>({lastManualEditsChangeSentAt:Date.now(),fsMap:new Map(a.fsMap).set("manual-edits.json",JSON.stringify(s))})),await aOt("manual-edits.json",JSON.stringify(s,null,2))},setSimulateScenarioOrder:n=>t({simulateScenarioOrder:n}),setCurrentMainComponentPath:n=>t({currentMainComponentPath:n})}),{name:"run-frame-store"})),dVo=VHt.extend("useEditEventController"),hVo=()=>{const t=Id(h=>h.applyEditEventsAndUpdateManualEditsJson),[e,n]=X.useState([]),[o,i]=X.useState(!1),r=e.filter(h=>!h._applied),s=e.filter(h=>h._applied),a=o?e:r,A=X.useCallback(h=>{n(d=>[...d,{...h,_applied:!1}])},[]),c=X.useCallback(h=>{n(d=>d.map(m=>m===h?{...m,_applied:!0}:m))},[]),l=X.useCallback(()=>{n(h=>h.map(d=>({...d,_applied:!0})))},[]),u=X.useCallback(()=>{i(!0),e.length!==0&&(dVo("removing edit events that are applied"),n(h=>h.filter(d=>!d._applied)))},[e]),g=X.useCallback(()=>{i(!1)},[]);return X.useEffect(()=>{if(e.filter(d=>!d._applied).length===0)return;const h=setTimeout(()=>{l(),t(e)},1e3);return()=>clearTimeout(h)},[e]),{unappliedEditEvents:r,appliedEditEvents:s,editEventsForRender:a,pushEditEvent:A,markEditEventApplied:c,markRenderStarted:u,markRenderComplete:g,markAllEditEventsApplied:l}},_Ne=vc("run-frame:useHasReceivedInitialFilesLoaded"),mVo=()=>{const[t,e]=X.useState(!1),n=Id(i=>i.recentEvents),o=Id(i=>i.loadInitialFiles);return X.useEffect(()=>{(async()=>{await o();try{const r=await fetch(`${UC}/events/list?event_type=INITIAL_FILES_UPLOADED`);if(r.ok){const{event_list:s}=await r.json();if(s.length>0){_Ne("INITIAL_FILES_UPLOADED found in history. Assuming ready."),e(!0);return}}}catch(r){console.error("Failed to check for event history",r)}_Ne("No INITIAL_FILES_UPLOADED in history, waiting for polling.")})()},[o]),X.useEffect(()=>{t||n.some(i=>i.event_type==="INITIAL_FILES_UPLOADED")&&(_Ne("INITIAL_FILES_UPLOADED received via polling. Assuming ready."),e(!0))},[n,t]),t};function uG(t,e,n){const[o,i]=X.useState(()=>{if(n!==void 0)return n;try{const r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return console.error("Error reading from localStorage:",r),e}});return X.useEffect(()=>{try{window.localStorage.setItem(t,JSON.stringify(o))}catch(r){console.error("Error writing to localStorage:",r)}},[t,o]),[o,i]}var pVo=Object.defineProperty,gG=(t,e)=>pVo(t,"name",{value:e,configurable:!0}),AOt=!!(typeof window<"u"&&window.document&&window.document.createElement);function rr(t,e,{checkForDefaultPrevented:n=!0}={}){return gG(function(i){if(t?.(i),n===!1||!i||!i.defaultPrevented)return e?.(i)},"handleEvent")}gG(rr,"composeEventHandlers");function fVo(t){if(!AOt)throw new Error("Cannot access window outside of the DOM");return t?.ownerDocument?.defaultView??window}gG(fVo,"getOwnerWindow");function INe(t){if(!AOt)throw new Error("Cannot access document outside of the DOM");return t?.ownerDocument??document}gG(INe,"getOwnerDocument");function cOt(t,e=!1){const{activeElement:n}=INe(t);if(!n?.nodeName)return null;if(lOt(n)&&n.contentDocument)return cOt(n.contentDocument.body,e);if(e){const o=n.getAttribute("aria-activedescendant");if(o){const i=INe(n).getElementById(o);if(i)return i}}return n}gG(cOt,"getActiveElement");function lOt(t){return t.tagName==="IFRAME"}gG(lOt,"isFrame");var _Vo=Object.defineProperty,y4=(t,e)=>_Vo(t,"name",{value:e,configurable:!0});function IVo(t,e){const n=X.createContext(e);n.displayName=t+"Context";const o=y4(r=>{const{children:s,...a}=r,A=X.useMemo(()=>a,Object.values(a));return K.jsx(n.Provider,{value:A,children:s})},"Provider");o.displayName=t+"Provider";function i(r,s={}){const{optional:a=!1}=s,A=X.useContext(n);if(A)return A;if(e!==void 0)return e;if(!a)throw new Error(`\`${r}\` must be used within \`${t}\``)}return y4(i,"useContext"),[o,i]}y4(IVo,"createContext");function Vx(t,e=[]){let n=[];function o(r,s){const a=X.createContext(s);a.displayName=r+"Context";const A=n.length;n=[...n,s];const c=y4(u=>{const{scope:g,children:h,...d}=u,m=g?.[t]?.[A]||a,p=X.useMemo(()=>d,Object.values(d));return K.jsx(m.Provider,{value:p,children:h})},"Provider");c.displayName=r+"Provider";function l(u,g,h={}){const{optional:d=!1}=h,m=g?.[t]?.[A]||a,p=X.useContext(m);if(p)return p;if(s!==void 0)return s;if(!d)throw new Error(`\`${u}\` must be used within \`${r}\``)}return y4(l,"useContext"),[c,l]}y4(o,"createContext");const i=y4(()=>{const r=n.map(s=>X.createContext(s));return y4(function(a){const A=a?.[t]||r;return X.useMemo(()=>({[`__scope${t}`]:{...a,[t]:A}}),[a,A])},"useScope")},"createScope");return i.scopeName=t,[o,uOt(i,...e)]}y4(Vx,"createContextScope");function uOt(...t){const e=t[0];if(t.length===1)return e;const n=y4(()=>{const o=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return y4(function(r){const s=o.reduce((a,{useScope:A,scopeName:c})=>{const u=A(r)[`__scope${c}`];return{...a,...u}},{});return X.useMemo(()=>({[`__scope${e.scopeName}`]:s}),[s])},"useComposedScopes")},"createScope");return n.scopeName=e.scopeName,n}y4(uOt,"composeContextScopes");var CVo=Object.defineProperty,CNe=(t,e)=>CVo(t,"name",{value:e,configurable:!0});function yNe(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}CNe(yNe,"setRef");function HR(...t){return e=>{let n=!1;const o=t.map(i=>{const r=yNe(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():yNe(t[i],null)}}}}CNe(HR,"composeRefs");function LA(...t){return X.useCallback(HR(...t),t)}CNe(LA,"useComposedRefs");var yVo=Object.defineProperty,x4=(t,e)=>yVo(t,"name",{value:e,configurable:!0});function jB(t){const e=X.forwardRef((n,o)=>{let{children:i,...r}=n,s=null,a=!1;const A=[];xNe(i)&&typeof jge=="function"&&(i=jge(i._payload)),X.Children.forEach(i,g=>{if(pOt(g)){a=!0;const h=g;let d="child"in h.props?h.props.child:h.props.children;xNe(d)&&typeof jge=="function"&&(d=jge(d._payload)),s=EVo(h,d),A.push(s?.props?.children)}else A.push(g)}),s?s=X.cloneElement(s,void 0,A):!a&&X.Children.count(i)===1&&X.isValidElement(i)&&(s=i);const c=s?mOt(s):void 0,l=LA(o,c);if(!s){if(i||i===0)throw new Error(a?SVo(t):bVo(t));return i}const u=hOt(r,s.props??{});return s.type!==X.Fragment&&(u.ref=o?l:c),X.cloneElement(s,u)});return e.displayName=`${t}.Slot`,e}x4(jB,"createSlot");var xVo=jB("Slot"),gOt=Symbol.for("radix.slottable");function dOt(t){const e=x4(n=>"child"in n?n.children(n.child):n.children,"Slottable");return e.displayName=`${t}.Slottable`,e.__radixId=gOt,e}x4(dOt,"createSlottable");var EVo=x4((t,e)=>{if("child"in t.props){const n=t.props.child;return X.isValidElement(n)?X.cloneElement(n,void 0,t.props.children(n.props.children)):null}return X.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(" "):o==="aria-describedby"&&(n[o]=_Ot(r,i))}return{...t,...n}}x4(hOt,"mergeProps");function mOt(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)}x4(mOt,"getElementRef");function pOt(t){return X.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===gOt}x4(pOt,"isSlottable");var BVo=Symbol.for("react.lazy");function xNe(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===BVo&&"_payload"in t&&fOt(t._payload)}x4(xNe,"isLazyComponent");function fOt(t){return typeof t=="object"&&t!==null&&"then"in t}x4(fOt,"isPromiseLike");function _Ot(...t){const e=new Set;for(const n of t)if(typeof n=="string")for(const o of String(n).trim().split(/\s+/))o&&e.add(o);return e.size>0?Array.from(e).join(" "):void 0}x4(_Ot,"concatAriaDescribedby");var bVo=x4(t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),SVo=x4(t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),jge=Y5[" use ".trim().toString()],QVo=Object.defineProperty,_1=(t,e)=>QVo(t,"name",{value:e,configurable:!0});function qge(t){const e=t+"CollectionProvider",[n,o]=Vx(e),[i,r]=n(e,{collectionRef:{current:null},itemMap:new Map}),s=_1(m=>{const{scope:p,children:f}=m,_=X.useRef(null),I=X.useRef(new Map).current;return K.jsx(i,{scope:p,itemMap:I,collectionRef:_,children:f})},"CollectionProvider");s.displayName=e;const a=t+"CollectionSlot",A=jB(a),c=X.forwardRef((m,p)=>{const{scope:f,children:_}=m,I=r(a,f),C=LA(p,I.collectionRef);return K.jsx(A,{ref:C,children:_})});c.displayName=a;const l=t+"CollectionItemSlot",u="data-radix-collection-item",g=jB(l),h=X.forwardRef((m,p)=>{const{scope:f,children:_,...I}=m,C=X.useRef(null),y=LA(p,C),x=r(l,f);return X.useEffect(()=>(x.itemMap.set(C,{ref:C,...I}),()=>{x.itemMap.delete(C)})),K.jsx(g,{[u]:"",ref:y,children:_})});h.displayName=l;function d(m){const p=r(t+"CollectionConsumer",m);return X.useCallback(()=>{const _=p.collectionRef.current;if(!_)return[];const I=Array.from(_.querySelectorAll(`[${u}]`));return Array.from(p.itemMap.values()).sort((x,E)=>I.indexOf(x.ref.current)-I.indexOf(E.ref.current))},[p.collectionRef,p.itemMap])}return _1(d,"useCollection"),[{Provider:s,Slot:c,ItemSlot:h},d,o]}_1(qge,"createCollection");var IOt=new WeakMap,ENe=(i5=class extends Map{constructor(n){super(n);tat(this,Pf);Fne(this,Pf,[...super.keys()]),IOt.set(this,!0)}set(n,o){return IOt.get(this)&&(this.has(n)?v0(this,Pf)[v0(this,Pf).indexOf(n)]=n:v0(this,Pf).push(n)),super.set(n,o),this}insert(n,o,i){const r=this.has(o),s=v0(this,Pf).length,a=BNe(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 u=[...v0(this,Pf)];let g,h=!1;for(let d=A;d<l;d++)if(A===d){let m=u[d];u[d]===o&&(m=u[d+1]),r&&this.delete(o),g=this.get(m),this.set(o,i)}else{!h&&u[d-1]===o&&(h=!0);const m=u[h?d:d-1],p=g;g=this.get(m),this.delete(m),this.set(m,p)}return this}with(n,o,i){const r=new i5(this);return r.insert(n,o,i),r}before(n){const o=v0(this,Pf).indexOf(n)-1;if(!(o<0))return this.entryAt(o)}setBefore(n,o,i){const r=v0(this,Pf).indexOf(n);return r===-1?this:this.insert(r,o,i)}after(n){let o=v0(this,Pf).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,Pf).indexOf(n);return r===-1?this:this.insert(r+1,o,i)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return Fne(this,Pf,[]),super.clear()}delete(n){const o=super.delete(n);return o&&v0(this,Pf).splice(v0(this,Pf).indexOf(n),1),o}deleteAt(n){const o=this.keyAt(n);return o!==void 0?this.delete(o):!1}at(n){const o=$ge(v0(this,Pf),n);if(o!==void 0)return this.get(o)}entryAt(n){const o=$ge(v0(this,Pf),n);if(o!==void 0)return[o,this.get(o)]}indexOf(n){return v0(this,Pf).indexOf(n)}keyAt(n){return $ge(v0(this,Pf),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 i5(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 i5(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 i5(o)}toReversed(){const n=new i5;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 i5(o)}slice(n,o){const i=new i5;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}},Pf=new WeakMap,_1(i5,"OrderedDict"),i5);function $ge(t,e){if("at"in Array.prototype)return Array.prototype.at.call(t,e);const n=COt(t,e);return n===-1?void 0:t[n]}_1($ge,"at");function COt(t,e){const n=t.length,o=BNe(e),i=o>=0?o:n+o;return i<0||i>=n?-1:i}_1(COt,"toSafeIndex");function BNe(t){return t!==t||t===0?0:Math.trunc(t)}_1(BNe,"toSafeInteger");function vVo(t){const e=t+"CollectionProvider",[n,o]=Vx(e),[i,r]=n(e,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new ENe,setItemMap:_1(()=>{},"setItemMap")}),s=_1(({state:I,...C})=>I?K.jsx(A,{...C,state:I}):K.jsx(a,{...C}),"CollectionProvider");s.displayName=e;const a=_1(I=>{const C=p();return K.jsx(A,{...I,state:C})},"CollectionInit");a.displayName=e+"Init";const A=_1(I=>{const{scope:C,children:y,state:x}=I,E=X.useRef(null),[B,S]=X.useState(null),Q=LA(E,S),[w,M]=x;return X.useEffect(()=>{if(!B)return;const T=EOt(()=>{});return T.observe(B,{childList:!0,subtree:!0}),()=>{T.disconnect()}},[B]),K.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=jB(c),u=X.forwardRef((I,C)=>{const{scope:y,children:x}=I,E=r(c,y),B=LA(C,E.collectionRef);return K.jsx(l,{ref:B,children:x})});u.displayName=c;const g=t+"CollectionItemSlot",h="data-radix-collection-item",d=jB(g),m=X.forwardRef((I,C)=>{const{scope:y,children:x,...E}=I,B=X.useRef(null),[S,Q]=X.useState(null),w=LA(C,B,Q),M=r(g,y),{setItemMap:T}=M,R=X.useRef(E);yOt(R.current,E)||(R.current=E);const F=R.current;return X.useEffect(()=>{const O=F;return T(U=>S?U.has(S)?U.set(S,{...O,element:S}).toSorted(bNe):(U.set(S,{...O,element:S}),U.toSorted(bNe)):U),()=>{T(U=>!S||!U.has(S)?U:(U.delete(S),new ENe(U)))}},[S,F,T]),K.jsx(d,{[h]:"",ref:w,children:x})});m.displayName=g;function p(){return X.useState(new ENe)}_1(p,"useInitCollection");function f(I){const{itemMap:C}=r(t+"CollectionConsumer",I);return C}return _1(f,"useCollection"),[{Provider:s,Slot:u,ItemSlot:m},{createCollectionScope:o,useCollection:f,useInitCollection:p}]}_1(vVo,"createCollection");function yOt(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}_1(yOt,"shallowEqual");function xOt(t,e){return!!(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_PRECEDING)}_1(xOt,"isElementPreceding");function bNe(t,e){return!t[1].element||!e[1].element?0:xOt(t[1].element,e[1].element)?-1:1}_1(bNe,"sortByDocumentPosition");function EOt(t){return new MutationObserver(n=>{for(const o of n)if(o.type==="childList"){t();return}})}_1(EOt,"getChildListObserver");var Sm=globalThis?.document?X.useLayoutEffect:()=>{},wVo=Object.defineProperty,PVo=(t,e)=>wVo(t,"name",{value:e,configurable:!0}),MVo=Y5[" useId ".trim().toString()]||(()=>{}),DVo=0;function Qm(t){const[e,n]=X.useState(MVo());return Sm(()=>{t||n(o=>o??String(DVo++))},[t]),t||(e?`radix-${e}`:"")}PVo(Qm,"useId");var M7=lxe();const BOt=SC(M7);var NVo=Object.defineProperty,RVo=(t,e)=>NVo(t,"name",{value:e,configurable:!0}),TVo=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ra=TVo.reduce((t,e)=>{const n=jB(`Primitive.${e}`),o=X.forwardRef((i,r)=>{const{asChild:s,...a}=i,A=s?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),K.jsx(A,{...a,ref:r})});return o.displayName=`Primitive.${e}`,{...t,[e]:o}},{});function SNe(t,e){t&&M7.flushSync(()=>t.dispatchEvent(e))}RVo(SNe,"dispatchDiscreteCustomEvent");var kVo=Object.defineProperty,FVo=(t,e)=>kVo(t,"name",{value:e,configurable:!0});function EE(t){const e=X.useRef(t);return X.useEffect(()=>{e.current=t}),X.useMemo(()=>((...n)=>e.current?.(...n)),[])}FVo(EE,"useCallbackRef");var LVo=Object.defineProperty,HVo=(t,e)=>LVo(t,"name",{value:e,configurable:!0}),bOt=Y5[" useEffectEvent ".trim().toString()],SOt=Y5[" useInsertionEffect ".trim().toString()];function QOt(t){if(typeof bOt=="function")return bOt(t);const e=X.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof SOt=="function"?SOt(()=>{e.current=t}):Sm(()=>{e.current=t}),X.useMemo(()=>((...n)=>e.current?.(...n)),[])}HVo(QOt,"useEffectEvent");var OVo=Object.defineProperty,A$=(t,e)=>OVo(t,"name",{value:e,configurable:!0}),GVo=Y5[" useInsertionEffect ".trim().toString()]||Sm;function qB({prop:t,defaultProp:e,onChange:n=A$(()=>{},"onChange"),caller:o}){const[i,r,s]=vOt({defaultProp:e,onChange:n}),a=t!==void 0,A=a?t:i,c=X.useCallback(l=>{if(a){const u=wOt(l)?l(t):l;u!==t&&s.current?.(u)}else r(l)},[a,t,r,s]);return[A,c]}A$(qB,"useControllableState");function vOt({defaultProp:t,onChange:e}){const[n,o]=X.useState(t),i=X.useRef(n),r=X.useRef(e);return GVo(()=>{r.current=e},[e]),X.useEffect(()=>{i.current!==n&&(r.current?.(n),i.current=n)},[n,i]),[n,o,r]}A$(vOt,"useUncontrolledState");function wOt(t){return typeof t=="function"}A$(wOt,"isFunction");var POt=Symbol("RADIX:SYNC_STATE");function YVo(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[u,g]=X.useReducer((p,f)=>{if(f.type===POt)return{...p,state:f.state};const _=t(p,f);return A&&!Object.is(_.state,p.state)&&c(_.state),_},...l),h=u.state,d=X.useRef(h);X.useEffect(()=>{d.current!==h&&(d.current=h,A||c(h))},[h,d,A]);const m=X.useMemo(()=>i!==void 0?{...u,state:i}:u,[u,i]);return X.useEffect(()=>{A&&!Object.is(i,u.state)&&g({type:POt,state:i})},[i,u.state,A]),[m,g]}A$(YVo,"useControllableStateReducer");var UVo=Object.defineProperty,KVo=(t,e)=>UVo(t,"name",{value:e,configurable:!0}),zVo={LTR:"ltr"},VVo=X.createContext(void 0);function c$(t){const e=X.useContext(VVo);return t||e||zVo.LTR}KVo(c$,"useDirection");var JVo=Object.defineProperty,QNe=(t,e)=>JVo(t,"name",{value:e,configurable:!0}),vNe=!1;function MOt(){const[t,e]=X.useState(vNe);return X.useEffect(()=>{vNe||(vNe=!0,e(!0))},[]),t}QNe(MOt,"useIsHydrated");var DOt=Y5[" useSyncExternalStore ".trim().toString()];function NOt(){return()=>{}}QNe(NOt,"subscribe");function ROt(){return DOt(NOt,()=>!0,()=>!1)}QNe(ROt,"useIsHydratedModern");var WVo=typeof DOt=="function"?ROt:MOt,jVo=Object.defineProperty,OR=(t,e)=>jVo(t,"name",{value:e,configurable:!0}),wNe="rovingFocusGroup.onEntryFocus",qVo={bubbles:!1,cancelable:!0},Xge="RovingFocusGroup",[PNe,TOt,$Vo]=qge(Xge),[XVo,Zge]=Vx(Xge,[$Vo]),kOt={Vertical:"vertical",Horizontal:"horizontal"},ZVo={RTL:"rtl"},[eJo,tJo]=XVo(Xge),FOt=X.forwardRef(OR(function(e,n){return K.jsx(PNe.Provider,{scope:e.__scopeRovingFocusGroup,children:K.jsx(PNe.Slot,{scope:e.__scopeRovingFocusGroup,children:K.jsx(nJo,{...e,ref:n})})})},"RovingFocusGroup")),nJo=X.forwardRef(OR(function(e,n){const{__scopeRovingFocusGroup:o,orientation:i,loop:r=!1,dir:s,currentTabStopId:a,defaultCurrentTabStopId:A,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...g}=e,h=X.useRef(null),d=LA(n,h),m=c$(s),[p,f]=qB({prop:a,defaultProp:A??null,onChange:c,caller:Xge}),[_,I]=X.useState(!1),C=EE(l),y=TOt(o),x=X.useRef(!1),[E,B]=X.useState(0);return X.useEffect(()=>{const S=h.current;if(S)return S.addEventListener(wNe,C),()=>S.removeEventListener(wNe,C)},[C]),K.jsx(eJo,{scope:o,orientation:i,dir:m,loop:r,currentTabStopId:p,onItemFocus:X.useCallback(S=>f(S),[f]),onItemShiftTab:X.useCallback(()=>I(!0),[]),onFocusableItemAdd:X.useCallback(()=>B(S=>S+1),[]),onFocusableItemRemove:X.useCallback(()=>B(S=>S-1),[]),children:K.jsx(Ra.div,{tabIndex:_||E===0?-1:0,"data-orientation":i,...g,ref:d,style:{outline:"none",...e.style},onMouseDown:rr(e.onMouseDown,()=>{x.current=!0}),onFocus:rr(e.onFocus,S=>{const Q=!x.current;if(S.target===S.currentTarget&&Q&&!_){const w=new CustomEvent(wNe,qVo);if(S.currentTarget.dispatchEvent(w),!w.defaultPrevented){const M=y().filter(U=>U.focusable),T=M.find(U=>U.active),R=M.find(U=>U.id===p),O=[T,R,...M].filter(Boolean).map(U=>U.ref.current);MNe(O,u)}}x.current=!1}),onBlur:rr(e.onBlur,()=>I(!1))})})},"RovingFocusGroupImpl")),oJo="RovingFocusGroupItem",LOt=X.forwardRef(OR(function(e,n){const{__scopeRovingFocusGroup:o,focusable:i=!0,active:r=!1,tabStopId:s,children:a,...A}=e,c=Qm(),l=s||c,u=tJo(oJo,o),g=u.currentTabStopId===l,h=TOt(o),{onFocusableItemAdd:d,onFocusableItemRemove:m,currentTabStopId:p}=u,f=WVo();return Sm(()=>{if(!(!f||!i))return d(),()=>m()},[f,i,d,m]),X.useEffect(()=>{if(!(f||!i))return d(),()=>m()},[f,i,d,m]),K.jsx(PNe.ItemSlot,{scope:o,id:l,focusable:i,active:r,children:K.jsx(Ra.span,{tabIndex:g?0:-1,"data-orientation":u.orientation,...A,ref:n,onMouseDown:rr(e.onMouseDown,_=>{i?u.onItemFocus(l):_.preventDefault()}),onFocus:rr(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:rr(e.onKeyDown,_=>{if(_.key==="Tab"&&_.shiftKey){u.onItemShiftTab();return}if(_.target!==_.currentTarget)return;const I=OOt(_,u.orientation,u.dir);if(I!==void 0){if(_.metaKey||_.ctrlKey||_.altKey||_.shiftKey)return;_.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(_.currentTarget);y=u.loop?GOt(y,x+1):y.slice(x+1)}setTimeout(()=>MNe(y))}}),children:typeof a=="function"?a({isCurrentTabStop:g,hasTabStop:p!=null}):a})})},"RovingFocusGroupItem")),iJo={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function HOt(t,e){return e!==ZVo.RTL?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}OR(HOt,"getDirectionAwareKey");function OOt(t,e,n){const o=HOt(t.key,n);if(!(e===kOt.Vertical&&["ArrowLeft","ArrowRight"].includes(o))&&!(e===kOt.Horizontal&&["ArrowUp","ArrowDown"].includes(o)))return iJo[o]}OR(OOt,"getFocusIntent");function MNe(t,e=!1){const n=document.activeElement;for(const o of t)if(o===n||(o.focus({preventScroll:e}),document.activeElement!==n))return}OR(MNe,"focusFirst");function GOt(t,e){return t.map((n,o)=>t[(e+o)%t.length])}OR(GOt,"wrapArray");var rJo=Object.defineProperty,cS=(t,e)=>rJo(t,"name",{value:e,configurable:!0});function YOt(t,e){return X.useReducer((n,o)=>e[n][o]??n,t)}cS(YOt,"useStateMachine");var BE=cS(t=>{const{present:e,children:n}=t,o=UOt(e),i=typeof n=="function"?n({present:o.isPresent}):X.Children.only(n),r=KOt(o.ref,zOt(i));return typeof n=="function"||o.isPresent?X.cloneElement(i,{ref:r}):null},"Presence");function UOt(t){const[e,n]=X.useState(),o=X.useRef(null),i=X.useRef(t),r=X.useRef("none"),s=X.useRef(void 0),a=t?"mounted":"unmounted",[A,c]=YOt(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return X.useEffect(()=>{A==="mounted"?(r.current=s.current??dG(o.current),s.current=void 0):r.current="none"},[A]),Sm(()=>{const l=o.current,u=i.current;if(u!==t){const h=r.current,d=dG(l);t?(s.current=d,c("MOUNT")):d==="none"||l?.display==="none"?c("UNMOUNT"):c(u&&h!==d?"ANIMATION_OUT":"UNMOUNT"),i.current=t}},[t,c]),Sm(()=>{if(e){let l;const u=e.ownerDocument.defaultView??window,g=cS(d=>{const p=dG(o.current).includes(CSS.escape(d.animationName));if(d.target===e&&p&&(c("ANIMATION_END"),!i.current)){const f=e.style.animationFillMode;e.style.animationFillMode="forwards",l=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=f)})}},"handleAnimationEnd"),h=cS(d=>{d.target===e&&(r.current=dG(o.current))},"handleAnimationStart");return e.addEventListener("animationstart",h),e.addEventListener("animationcancel",g),e.addEventListener("animationend",g),()=>{u.clearTimeout(l),e.removeEventListener("animationstart",h),e.removeEventListener("animationcancel",g),e.removeEventListener("animationend",g)}}else c("ANIMATION_END")},[e,c]),{isPresent:["mounted","unmountSuspended"].includes(A),ref:X.useCallback(l=>{if(l){const u=getComputedStyle(l);o.current=u,s.current=dG(u)}else o.current=null;n(l)},[])}}cS(UOt,"usePresence");function DNe(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}cS(DNe,"setRef");function KOt(...t){const e=X.useRef(t);return e.current=t,X.useCallback(n=>{const o=e.current;let i=!1;const r=o.map(s=>{const a=DNe(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():DNe(o[s],null)}}},[])}cS(KOt,"useStableComposedRefs");function dG(t){return t?.animationName||"none"}cS(dG,"getAnimationName");function zOt(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)}cS(zOt,"getElementRef");var sJo=Object.defineProperty,hG=(t,e)=>sJo(t,"name",{value:e,configurable:!0}),VOt={Automatic:"automatic",Manual:"manual"},NNe="Tabs",[aJo,_Er]=Vx(NNe,[Zge]),JOt=Zge(),[AJo,RNe]=aJo(NNe),cJo=X.forwardRef(hG(function(e,n){const{__scopeTabs:o,value:i,onValueChange:r,defaultValue:s,orientation:a="horizontal",dir:A,activationMode:c=VOt.Automatic,...l}=e,u=c$(A),[g,h]=qB({prop:i,onChange:r,defaultProp:s??"",caller:NNe});return K.jsx(AJo,{scope:o,baseId:Qm(),value:g,onValueChange:h,orientation:a,dir:u,activationMode:c,children:K.jsx(Ra.div,{dir:u,"data-orientation":a,...l,ref:n})})},"Tabs")),lJo="TabsList",WOt=X.forwardRef(hG(function(e,n){const{__scopeTabs:o,loop:i=!0,...r}=e,s=RNe(lJo,o),a=JOt(o);return K.jsx(FOt,{asChild:!0,...a,orientation:s.orientation,dir:s.dir,loop:i,children:K.jsx(Ra.div,{role:"tablist","aria-orientation":s.orientation,...r,ref:n})})},"TabsList")),uJo="TabsTrigger",jOt=X.forwardRef(hG(function(e,n){const{__scopeTabs:o,value:i,disabled:r=!1,...s}=e,a=RNe(uJo,o),A=JOt(o),c=TNe(a.baseId,i),l=kNe(a.baseId,i),u=i===a.value;return K.jsx(LOt,{asChild:!0,...A,focusable:!r,active:u,children:K.jsx(Ra.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":l,"data-state":u?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:c,...s,ref:n,onMouseDown:rr(e.onMouseDown,g=>{!r&&g.button===0&&g.ctrlKey===!1?(g.currentTarget.focus(),a.onValueChange(i)):g.preventDefault()}),onKeyDown:rr(e.onKeyDown,g=>{r||g.target!==g.currentTarget||[" ","Enter"].includes(g.key)&&a.onValueChange(i)}),onFocus:rr(e.onFocus,()=>{const g=a.activationMode!==VOt.Manual;!u&&!r&&g&&a.onValueChange(i)})})})},"TabsTrigger")),gJo="TabsContent",qOt=X.forwardRef(hG(function(e,n){const{__scopeTabs:o,value:i,forceMount:r,children:s,...a}=e,A=RNe(gJo,o),c=TNe(A.baseId,i),l=kNe(A.baseId,i),u=i===A.value,g=X.useRef(u);return X.useEffect(()=>{const h=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(h)},[]),K.jsx(BE,{present:r||u,children:({present:h})=>K.jsx(Ra.div,{"data-state":u?"active":"inactive","data-orientation":A.orientation,role:"tabpanel","aria-labelledby":c,hidden:!h,id:l,tabIndex:0,...a,ref:n,style:{...e.style,animationDuration:g.current?"0s":void 0},children:h&&s})})},"TabsContent"));function TNe(t,e){return`${t}-trigger-${e}`}hG(TNe,"makeTriggerId");function kNe(t,e){return`${t}-content-${e}`}hG(kNe,"makeContentId");function $Ot(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=$Ot(t[e]))&&(o&&(o+=" "),o+=n)}else for(n in t)t[n]&&(o&&(o+=" "),o+=n);return o}function $B(){for(var t,e,n=0,o="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=$Ot(t))&&(o&&(o+=" "),o+=e);return o}const FNe="-",dJo=t=>{const e=mJo(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=t;return{getClassGroupId:s=>{const a=s.split(FNe);return a[0]===""&&a.length!==1&&a.shift(),XOt(a,e)||hJo(s)},getConflictingClassGroupIds:(s,a)=>{const A=n[s]||[];return a&&o[s]?[...A,...o[s]]:A}}},XOt=(t,e)=>{if(t.length===0)return e.classGroupId;const n=t[0],o=e.nextPart.get(n),i=o?XOt(t.slice(1),o):void 0;if(i)return i;if(e.validators.length===0)return;const r=t.join(FNe);return e.validators.find(({validator:s})=>s(r))?.classGroupId},ZOt=/^\[(.+)\]$/,hJo=t=>{if(ZOt.test(t)){const e=ZOt.exec(t)[1],n=e?.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},mJo=t=>{const{theme:e,prefix:n}=t,o={nextPart:new Map,validators:[]};return fJo(Object.entries(t.classGroups),n).forEach(([r,s])=>{LNe(s,o,r,e)}),o},LNe=(t,e,n,o)=>{t.forEach(i=>{if(typeof i=="string"){const r=i===""?e:eGt(e,i);r.classGroupId=n;return}if(typeof i=="function"){if(pJo(i)){LNe(i(o),e,n,o);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([r,s])=>{LNe(s,eGt(e,r),n,o)})})},eGt=(t,e)=>{let n=t;return e.split(FNe).forEach(o=>{n.nextPart.has(o)||n.nextPart.set(o,{nextPart:new Map,validators:[]}),n=n.nextPart.get(o)}),n},pJo=t=>t.isThemeGetter,fJo=(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,_Jo=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)}}},tGt="!",IJo=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,u;for(let p=0;p<a.length;p++){let f=a[p];if(c===0){if(f===i&&(o||a.slice(p,p+r)===e)){A.push(a.slice(l,p)),l=p+r;continue}if(f==="/"){u=p;continue}}f==="["?c++:f==="]"&&c--}const g=A.length===0?a:a.substring(l),h=g.startsWith(tGt),d=h?g.substring(1):g,m=u&&u>l?u-l:void 0;return{modifiers:A,hasImportantModifier:h,baseClassName:d,maybePostfixModifierPosition:m}};return n?a=>n({className:a,parseClassName:s}):s},CJo=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},yJo=t=>({cache:_Jo(t.cacheSize),parseClassName:IJo(t),...dJo(t)}),xJo=/\s+/,EJo=(t,e)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:i}=e,r=[],s=t.trim().split(xJo);let a="";for(let A=s.length-1;A>=0;A-=1){const c=s[A],{modifiers:l,hasImportantModifier:u,baseClassName:g,maybePostfixModifierPosition:h}=n(c);let d=!!h,m=o(d?g.substring(0,h):g);if(!m){if(!d){a=c+(a.length>0?" "+a:a);continue}if(m=o(g),!m){a=c+(a.length>0?" "+a:a);continue}d=!1}const p=CJo(l).join(":"),f=u?p+tGt:p,_=f+m;if(r.includes(_))continue;r.push(_);const I=i(m,d);for(let C=0;C<I.length;++C){const y=I[C];r.push(f+y)}a=c+(a.length>0?" "+a:a)}return a};function BJo(){let t=0,e,n,o="";for(;t<arguments.length;)(e=arguments[t++])&&(n=nGt(e))&&(o&&(o+=" "),o+=n);return o}const nGt=t=>{if(typeof t=="string")return t;let e,n="";for(let o=0;o<t.length;o++)t[o]&&(e=nGt(t[o]))&&(n&&(n+=" "),n+=e);return n};function bJo(t,...e){let n,o,i,r=s;function s(A){const c=e.reduce((l,u)=>u(l),t());return n=yJo(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=EJo(A,n);return i(A,l),l}return function(){return r(BJo.apply(null,arguments))}}const Cd=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},oGt=/^\[(?:([a-z-]+):)?(.+)\]$/i,SJo=/^\d+\/\d+$/,QJo=new Set(["px","full","screen"]),vJo=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,wJo=/\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$/,PJo=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,MJo=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,DJo=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,lS=t=>mG(t)||QJo.has(t)||SJo.test(t),Xw=t=>pG(t,"length",OJo),mG=t=>!!t&&!Number.isNaN(Number(t)),HNe=t=>pG(t,"number",mG),l$=t=>!!t&&Number.isInteger(Number(t)),NJo=t=>t.endsWith("%")&&mG(t.slice(0,-1)),HA=t=>oGt.test(t),Zw=t=>vJo.test(t),RJo=new Set(["length","size","percentage"]),TJo=t=>pG(t,RJo,iGt),kJo=t=>pG(t,"position",iGt),FJo=new Set(["image","url"]),LJo=t=>pG(t,FJo,YJo),HJo=t=>pG(t,"",GJo),u$=()=>!0,pG=(t,e,n)=>{const o=oGt.exec(t);return o?o[1]?typeof e=="string"?o[1]===e:e.has(o[1]):n(o[2]):!1},OJo=t=>wJo.test(t)&&!PJo.test(t),iGt=()=>!1,GJo=t=>MJo.test(t),YJo=t=>DJo.test(t),UJo=bJo(()=>{const t=Cd("colors"),e=Cd("spacing"),n=Cd("blur"),o=Cd("brightness"),i=Cd("borderColor"),r=Cd("borderRadius"),s=Cd("borderSpacing"),a=Cd("borderWidth"),A=Cd("contrast"),c=Cd("grayscale"),l=Cd("hueRotate"),u=Cd("invert"),g=Cd("gap"),h=Cd("gradientColorStops"),d=Cd("gradientColorStopPositions"),m=Cd("inset"),p=Cd("margin"),f=Cd("opacity"),_=Cd("padding"),I=Cd("saturate"),C=Cd("scale"),y=Cd("sepia"),x=Cd("skew"),E=Cd("space"),B=Cd("translate"),S=()=>["auto","contain","none"],Q=()=>["auto","hidden","clip","visible","scroll"],w=()=>["auto",HA,e],M=()=>[HA,e],T=()=>["",lS,Xw],R=()=>["auto",mG,HA],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"],q=()=>["","0",HA],ee=()=>["auto","avoid","all","avoid-page","page","left","right","column"],W=()=>[mG,HA];return{cacheSize:500,separator:":",theme:{colors:[u$],spacing:[lS,Xw],blur:["none","",Zw,HA],brightness:W(),borderColor:[t],borderRadius:["none","","full",Zw,HA],borderSpacing:M(),borderWidth:T(),contrast:W(),grayscale:q(),hueRotate:W(),invert:q(),gap:M(),gradientColorStops:[t],gradientColorStopPositions:[NJo,Xw],inset:w(),margin:w(),opacity:W(),padding:M(),saturate:W(),scale:W(),sepia:q(),skew:W(),space:M(),translate:M()},classGroups:{aspect:[{aspect:["auto","square","video",HA]}],container:["container"],columns:[{columns:[Zw]}],"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(),HA]}],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:[m]}],"inset-x":[{"inset-x":[m]}],"inset-y":[{"inset-y":[m]}],start:[{start:[m]}],end:[{end:[m]}],top:[{top:[m]}],right:[{right:[m]}],bottom:[{bottom:[m]}],left:[{left:[m]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",l$,HA]}],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",HA]}],grow:[{grow:q()}],shrink:[{shrink:q()}],order:[{order:["first","last","none",l$,HA]}],"grid-cols":[{"grid-cols":[u$]}],"col-start-end":[{col:["auto",{span:["full",l$,HA]},HA]}],"col-start":[{"col-start":R()}],"col-end":[{"col-end":R()}],"grid-rows":[{"grid-rows":[u$]}],"row-start-end":[{row:["auto",{span:[l$,HA]},HA]}],"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",HA]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",HA]}],gap:[{gap:[g]}],"gap-x":[{"gap-x":[g]}],"gap-y":[{"gap-y":[g]}],"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:[_]}],px:[{px:[_]}],py:[{py:[_]}],ps:[{ps:[_]}],pe:[{pe:[_]}],pt:[{pt:[_]}],pr:[{pr:[_]}],pb:[{pb:[_]}],pl:[{pl:[_]}],m:[{m:[p]}],mx:[{mx:[p]}],my:[{my:[p]}],ms:[{ms:[p]}],me:[{me:[p]}],mt:[{mt:[p]}],mr:[{mr:[p]}],mb:[{mb:[p]}],ml:[{ml:[p]}],"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",HA,e]}],"min-w":[{"min-w":[HA,e,"min","max","fit"]}],"max-w":[{"max-w":[HA,e,"none","full","min","max","fit","prose",{screen:[Zw]},Zw]}],h:[{h:[HA,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[HA,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[HA,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[HA,e,"auto","min","max","fit"]}],"font-size":[{text:["base",Zw,Xw]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",HNe]}],"font-family":[{font:[u$]}],"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",HA]}],"line-clamp":[{"line-clamp":["none",mG,HNe]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",lS,HA]}],"list-image":[{"list-image":["none",HA]}],"list-style-type":[{list:["none","disc","decimal",HA]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[f]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[f]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...O(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",lS,Xw]}],"underline-offset":[{"underline-offset":["auto",lS,HA]}],"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",HA]}],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",HA]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[f]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...F(),kJo]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",TJo]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},LJo]}],"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":[f]}],"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":[f]}],"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":[lS,HA]}],"outline-w":[{outline:[lS,Xw]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:T()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[f]}],"ring-offset-w":[{"ring-offset":[lS,Xw]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Zw,HJo]}],"shadow-color":[{shadow:[u$]}],opacity:[{opacity:[f]}],"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",Zw,HA]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[l]}],invert:[{invert:[u]}],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":[u]}],"backdrop-opacity":[{"backdrop-opacity":[f]}],"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",HA]}],duration:[{duration:W()}],ease:[{ease:["linear","in","out","in-out",HA]}],delay:[{delay:W()}],animate:[{animate:["none","spin","ping","pulse","bounce",HA]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[C]}],"scale-x":[{"scale-x":[C]}],"scale-y":[{"scale-y":[C]}],rotate:[{rotate:[l$,HA]}],"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",HA]}],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",HA]}],"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",HA]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[lS,Xw,HNe]}],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"]}}}),jn="u">typeof window?window:void 0,KC="u">typeof globalThis?globalThis:jn,I_=KC?.navigator,qo=KC?.document,tg=KC?.location,g$=KC?.fetch,ONe=KC?.XMLHttpRequest&&"withCredentials"in new KC.XMLHttpRequest?KC.XMLHttpRequest:void 0,rGt=KC?.AbortController,KJo=KC?.CompressionStream,l2=I_?.userAgent,d$=typeof globalThis<"u"?globalThis:jn;d$&&typeof self>"u"&&(d$.self=d$),d$&&typeof File>"u"&&(d$.File=function(){});const Kr=jn??{},zJo="0.9.2",uS={DEBUG:!1,LIB_VERSION:zJo,LIB_NAME:"browser-common"};var D7=(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})({}),GNe=(function(t){return t.GZipJS="gzip-js",t.Base64="base64",t})({});const VJo=["$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"],JJo=["token"];function jr(t,e){return t.indexOf(e)!==-1}const fG=function(t){return t.trim()},YNe=function(t){return t.replace(/^\$/,"")};function sGt(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 aGt=Object.prototype,UNe=aGt.hasOwnProperty,ede=aGt.toString,qr=Array.isArray||function(t){return ede.call(t)==="[object Array]"},pp=t=>typeof t=="function",va=t=>t===Object(t)&&!qr(t),Jx=t=>{if(va(t)){for(const e in t)if(UNe.call(t,e))return!1;return!0}return!1},Eo=t=>t===void 0,Za=t=>ede.call(t)=="[object String]",h$=t=>Za(t)&&t.trim().length===0,yd=t=>t===null,Hs=t=>Eo(t)||yd(t),gh=t=>ede.call(t)=="[object Number]"&&t==t,gS=t=>gh(t)&&t>0,u2=t=>ede.call(t)==="[object Boolean]",WJo=t=>jr(VJo,t),jJo=t=>jr(JJo,t);function AGt(t){return t===null||typeof t!="object"}function tde(t,e){return{}.toString.call(t)===`[object ${e}]`}function _G(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 cGt(t,Error)}}function KNe(t){return"u">typeof Event&&cGt(t,Event)}function cGt(t,e){try{return t instanceof e}catch{return!1}}const qJo=[!0,"true",1,"1","yes"],zNe=t=>jr(qJo,t),$Jo=[!1,"false",0,"0","no"];function lGt(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 ng(t){return function(){var e=this,n=arguments;return new Promise(function(o,i){var r=t.apply(e,n);function s(A){lGt(r,o,i,s,a,"next",A)}function a(A){lGt(r,o,i,s,a,"throw",A)}s(void 0)})}}const XJo=["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"],nde=new Map,uGt=function(t,e=[]){if(!t)return!1;const n=(function(s,a){let A="";for(let c=0;a.length>c;c++){const l=a[c];A+=l.length+":"+l}return s.length+":"+s+"|"+a.length+":"+A})(t,e),o=nde.get(n);if(o!==void 0)return o;const i=t.toLowerCase(),r=XJo.concat(e).some(s=>i.indexOf(s.toLowerCase())!==-1);return 256>nde.size||nde.clear(),nde.set(n,r),r};function N7(t,e,n,o,i){return e>n&&(o.warn("min cannot be greater than max."),e=n),gh(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),N7(i??n,e,n,o))}var ZJo=class{constructor(e){this.C={},this.I=e.I,this.R=N7(e.bucketSize,0,100,e.A),this.$=N7(e.refillRate,0,this.R,e.A),this.O=N7(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 IG="Mobile",m$="Android",ode="Tablet",gGt="Android Tablet",dGt="iPad",hGt="Apple Watch",ide="Safari",rde="BlackBerry",mGt="Samsung Internet",sde="Chrome",pGt="Chrome iOS",fGt="Internet Explorer",_Gt="Internet Explorer Mobile",IGt="Opera",CGt="Microsoft Edge",ade="Firefox",yGt="Firefox iOS",Ade="Nintendo",cde="PlayStation",lde="Xbox",xGt="Android Mobile",EGt="Mobile Safari",VNe="Windows",BGt="Windows Phone",bGt="Nokia",JNe="Ouya",eWo="Generic "+IG.toLowerCase(),SGt="Generic "+ode.toLowerCase(),WNe="Konqueror",QGt="Oculus Browser",vGt="Vivaldi",wGt="Yandex",PGt="Whale",MGt="DuckDuckGo",DGt="Pale Moon",NGt="Waterfox",jNe="Brave",RGt="Claude",TGt="Codex",kGt="ChatGPT",FGt="Google Search App",qNe=new RegExp("Version/(\\d+(\\.\\d+)?)"),$Ne=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),tWo=new RegExp(lde,"i"),nWo=new RegExp("PlayStation \\w+","i"),oWo=new RegExp("Nintendo \\w+","i"),XNe=new RegExp("BlackBerry|PlayBook|BB10","i"),iWo={"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"},LGt=function(t,e,n,o){return e=e||"",(function(r){return r?.brave?jNe:null})(n)||(o?.detectGoogleSearchApp&&jr(t,"GSA/")?FGt:jr(t," OPR/")&&jr(t,"Mini")?"Opera Mini":jr(t," OPR/")?IGt:XNe.test(t)?rde:jr(t,"IEMobile")||jr(t,"WPDesktop")?_Gt:jr(t,"OculusBrowser")?QGt:jr(t,"SamsungBrowser")?mGt:jr(t,"Edge")||jr(t,"Edg/")?CGt:jr(t,"Vivaldi/")?vGt:jr(t,"YaBrowser/")?wGt:jr(t,"Whale/")?PGt:jr(t,"DuckDuckGo/")||jr(t,"Ddg/")?MGt:jr(t,"Claude/")?RGt:jr(t,"Codex/")?TGt:jr(t,"ChatGPT/")?kGt:jr(t,"FBIOS")?"Facebook Mobile":jr(t,"UCWEB")||jr(t,"UCBrowser")?"UC Browser":jr(t,"CriOS")?pGt:jr(t,"CrMo")||jr(t,sde)?sde:jr(t,m$)&&jr(t,ide)?xGt:jr(t,"FxiOS")?yGt:jr(t.toLowerCase(),WNe.toLowerCase())?WNe:jr(t,"Brave/")?jNe:((r,s)=>s&&jr(s,"Apple")||(function(a){return jr(a,ide)&&!jr(a,sde)&&!jr(a,m$)})(r))(t,e)?jr(t,IG)?EGt:ide:jr(t,"PaleMoon/")?DGt:jr(t,"Waterfox/")?NGt:jr(t,ade)?ade:jr(t,"MSIE")||jr(t,"Trident/")?fGt:jr(t,"Gecko")?ade:"")},rWo={[_Gt]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[CGt]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[sde]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[pGt]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[ide]:[qNe],[EGt]:[qNe],[IGt]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[ade]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[yGt]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[WNe]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[rde]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),qNe],[xGt]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[mGt]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[QGt]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[vGt]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[wGt]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[PGt]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[jNe]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[RGt]:[$Ne],[TGt]:[$Ne],[kGt]:[$Ne],[MGt]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[DGt]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[NGt]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[FGt]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[fGt]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},sWo=function(t,e,n,o){const i=LGt(t,e,n,o),r=rWo[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},HGt=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>[lde,t&&t[1]||""]],[new RegExp(Ade,"i"),[Ade,""]],[new RegExp(cde,"i"),[cde,""]],[XNe,[rde,""]],[new RegExp(VNe,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[BGt,""];if(new RegExp(IG).test(e)&&!/IEMobile\b/.test(e))return["Windows Mobile",""];const n=/Windows NT ([0-9.]+)/i.exec(e);if(n&&n[1]){let o=iWo[n[1]]||"";return/arm/i.test(e)&&(o="RT"),[VNe,o]}return[VNe,""]}],[/((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]?[m$,[t[2],t[3],t[4]||"0"].join(".")]:[m$,""]],[/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",""]]],OGt=function(t){for(let e=0;HGt.length>e;e++){const[n,o]=HGt[e],i=n.exec(t),r=i&&(pp(o)?o(i,t):o);if(r)return r}return["",""]},GGt=function(t){return oWo.test(t)?Ade:nWo.test(t)?cde:tWo.test(t)?lde:new RegExp(JNe,"i").test(t)?JNe:new RegExp("(Windows Phone|WPDesktop)","i").test(t)?BGt:/iPad/.test(t)?dGt:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?hGt:XNe.test(t)?rde:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(bGt,"i").test(t)?bGt:/(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(IG).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)?m$:gGt:new RegExp("(pda|Mobile)","i").test(t)?eWo:new RegExp(ode,"i").test(t)&&!new RegExp("Tablet pc","i").test(t)?SGt:""},aWo=function(t,e){var n;const o=GGt(t);return o===dGt||o===gGt||o==="Kobo"||o==="Kindle Fire"||o===SGt?ode:o===Ade||o===lde||o===cde||o===JNe?"Console":o===hGt?"Wearable":o?IG: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)?IG:ode:"Desktop";var i,r,s},ZNe=/\bFBAV\/(\d+(?:\.\d+)*)/i,YGt=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",ZNe],[/\bFBAN\/EMA\b/i,"Facebook Lite",ZNe],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",ZNe],[/\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"]],eRe="[Truncated]",p$="[Unserializable]";function CG(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 UGt(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=p$}Object.defineProperty(t,o,{value:i,enumerable:!0,writable:!0,configurable:!0})}return t}const ude=3e5;var KGt=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,ude);if(!n)return this.ts=o,void(this.es=o+i);this.es=Math.max(this.es,Math.min(o+i,this.ts+ude))}remainingMs(){const e=Date.now();if(this.ts-5e3>e)return this.reset(),0;const n=Math.min(ude,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 AWo=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function zGt(t,e){return typeof(n=t)=="string"&&AWo.test(n)?t:e();var n}function VGt(t,e){const n=new Error(e);try{Object.defineProperty(n,"name",{value:t,writable:!0,enumerable:!0,configurable:!0})}catch{}return n}function eP(t){return t&&t.split("#")[0]}function JGt(t){try{return t()}catch{return}}function WGt(t,e){const n=setTimeout(t,e);return n!=null&&n.unref&&n?.unref(),n}function jGt(t,e,n){return qGt.apply(this,arguments)}function qGt(){return(qGt=ng(function*(t,e,n){let o;try{return yield Promise.race([t,new Promise((i,r)=>{o=WGt(()=>{try{n?.(),i()}catch(s){r(s)}},e)})])}finally{clearTimeout(o)}})).apply(this,arguments)}let gde,$Gt,tRe;function cWo(t){const e=globalThis._posthogChunkIds;if(!e)return;const n=Object.keys(e);return tRe&&n.length===$Gt||($Gt=n.length,tRe=n.reduce((o,i)=>{gde||(gde={});const r=gde[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,gde[i]=[c,l];break}}}return o},{})),tRe}function f$(t){return f$=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},f$(t)}function lWo(t,e,n){return(e=(function(o){var i=(function(r){if(f$(r)!="object"||!r)return r;var s=r[Symbol.toPrimitive];if(s!==void 0){var a=s.call(r,"string");if(f$(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)})(o);return f$(i)=="symbol"?i:i+""})(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function XGt(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 Zt(t){for(var e=1;arguments.length>e;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?XGt(Object(n),!0).forEach(function(o){lWo(t,o,n[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):XGt(Object(n)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(n,o))})}return t}var uWo=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 ng(function*(){for(const o of e)o.stacktrace&&o.stacktrace.frames&&qr(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 Zt(Zt({},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 ng(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?Zt(Zt({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},u={type:r.type,value:r.value,mechanism:l};r.stack&&(u.stacktrace={type:"raw",frames:r.stack}),o.push(u),r.cause&&i(r.cause,c,"cause");for(const g of(A=r.errors)!==null&&A!==void 0?A:[])i(g,c,"member")};return i(e),o}buildParsingContext(e){var n;return{chunkIdMap:cWo(this.stackParser),skipFirstLines:(n=e.skipFirstLines)!==null&&n!==void 0?n:1}}getAggregateErrors(e){try{if(_G(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 qr(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,m=0)=>{const p=u(d,m),f=p.apply;if(p.apply=E=>{A.push(h);try{return f(E)}finally{A.pop()}},m>4||m>0&&A.indexOf(h)!==-1)return this.coerceFallback(p);const _=typeof h=="object"&&h!==null||typeof h=="function";if(m===0&&i>=50||_&&a.has(h))return;_&&a.add(h),m===0&&i++;const I=this.getAggregateErrors(h);let C,y;s||(s=!!I);try{if(C=this.applyCoercers(h,p),!C)throw c}catch(E){if(E===c)return void(m===0&&i--);if(!s)throw E;C=this.coerceFallback(p)}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=p.next(I[E])}catch{i++,B=this.coerceFallback(u(d+1))}B&&x.push(B)}return Zt(Zt({},C),{},{errors:x})},u=(h,d=0)=>Zt(Zt({},n),{},{syntheticException:h==0?n.syntheticException:void 0,mechanism:h==0?e:{},apply(m){const p=l(m,h,d+1);if(!p)throw c;return p},next:m=>l(m,h+1)}),g=u(o);return Zt(Zt({},g),{},{apply:h=>{var d;return(d=l(h,o))!==null&&d!==void 0?d:this.coerceFallback(g)}})}};const gWo=/^([a-z][a-z0-9.+-]+):/i,dWo=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function hWo(t){if(!t||t==="<anonymous>")return!1;const e=gWo.exec(t);return!e||dWo.includes(e[1].toLowerCase())}function nRe(t,e,n,o,i){const r={platform:t,filename:e,function:n==="<anonymous>"?"?":n,in_app:hWo(e)};return Eo(o)||(r.lineno=o),Eo(i)||(r.colno=i),r}const ZGt=(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]},mWo=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,pWo=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,fWo=/\((\S*)(?::(\d+))(?::(\d+))\)/,_Wo=(t,e)=>{const n=mWo.exec(t);if(n){const[,i,r,s]=n;return nRe(e,i,"?",+r,+s)}const o=pWo.exec(t);if(o){if(o[2]&&o[2].indexOf("eval")===0){const s=fWo.exec(o[2]);s&&(o[2]=s[1],o[3]=s[2],o[4]=s[3])}const[i,r]=ZGt(o[1]||"?",o[2]);return nRe(e,r,i,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},IWo=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,CWo=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,yWo=(t,e)=>{const n=IWo.exec(t);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){const r=CWo.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]=ZGt(i,o),nRe(e,o,i,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},eYt=/\(error: (.*)\)/;function oRe(t,e){return t.filename===e.filename&&t.function===e.function&&t.module===e.module&&t.lineno===e.lineno&&t.colno===e.colno}function xWo(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(!oRe(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 EWo(t,e){const n=e.start+e.length,o=nYt(t,e);o&&t.splice(n+o===t.length?n:e.start,o)}function tYt(t,e){let n=e.start;for(;n>0&&oRe(t[n-1],t[n-1+e.length]);)n--;return e.start-n}function nYt(t,e){const n=e.start+e.length;let o=n;for(;t.length>o&&oRe(t[o],t[o-e.length]);)o++;return o-n}function BWo(t,e){const n=e[0];let o=t.length-(n?tYt(t,n):0);for(const i of e)o-=nYt(t,i);return o}function bWo(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 SWo=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,n){const o=Za(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 tde(e,"DOMException")}isDOMError(e){return tde(e,"DOMError")}},QWo=class{match(e){return _G(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}}},vWo=class{match(e){return!!tde(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 Zt(Zt({},i),{},{stack:(o=this.lr(e))!==null&&o!==void 0?o:i.stack,synthetic:!0})}ar(e){return Za(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(Za(i.filename)&&i.filename.length!==0&&r!==0)return`Error
|
|
1068
|
-
at ${i.filename}:${r}:${s}`}};const wWo=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var PWo=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(wWo);return i&&(n=i[1],o=i[2]),[n,o]}};const MWo=["fatal","error","warning","log","info","debug"];function oYt(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 DWo=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(KNe(e))return e.constructor.name;const n="name"in e?e.name:void 0;return Za(n)&&!h$(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: ${oYt(e)}`}isSeverityLevel(e){return Za(e)&&!h$(e)&&MWo.indexOf(e)>=0}getStack(e){try{return Za(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:Za(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(_G(o))return o}}getObjectClassName(e){try{const n=Object.getPrototypeOf(e);return n?n.constructor.name:void 0}catch{return}}},NWo=class{match(e){return KNe(e)}coerce(e,n){var o;const i=e.constructor.name;return{type:i,value:`${i} captured as exception with keys: ${oYt(e)}`,stack:(o=n.syntheticException)===null||o===void 0?void 0:o.stack,synthetic:!0}}},RWo=class{match(e){return AGt(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}}},TWo=class{match(e){return tde(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!KNe(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 AGt(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 dde="$message",hde="$timestamp",kWo=new Set([dde,hde]),iRe={enabled:!0,max_bytes:32768};function mde(t){var e;return t?{enabled:(e=t.enabled)!==null&&e!==void 0?e:iRe.enabled,max_bytes:LWo(t.max_bytes,iRe.max_bytes)}:Zt({},iRe)}var FWo=class{constructor(e){this.ns=[],this.ss=0,this.Mr=mde(e)}setConfig(e){this.Mr=mde(e),this.rs()}add(e){const n=(function(i){let r;try{r=sGt(i)}catch{return}try{const s=JSON.parse(r);if(!va(s))return;const a=s,A=a[dde],c=a[hde];return!Za(A)||A.trim().length===0||!Za(c)&&!gh(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 LWo(t,e){if(!gh(t)||t===1/0||t===-1/0)return e;const n=Math.floor(t);return 0>n?e:n}const iYt=t=>{if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}};function rYt(t){return typeof t=="string"||t}function sYt(t){return typeof t=="string"?t:void 0}const HWo=["$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","$react_native_version"],aYt="NativeGzipValidationError",rRe=t=>t.length>=2&&t[0]===31&&t[1]===139,AYt=(t,e)=>t===GNe.GZipJS||e===GNe.GZipJS||e==="gzip",cYt=t=>!(!t||typeof t!="object")&&("name"in t?String(t.name):"")==="NotReadableError";let _$;const pde=t=>{throw VGt(aYt,`Native gzip produced invalid output: ${t}`)},OWo=(lYt=ng(function*(t,e){18>t.size&&pde("too-short");const n=new Uint8Array(yield t.slice(0,10).arrayBuffer());rRe(n)&&n[2]===8||pde("invalid-header");const o=new DataView(yield t.slice(t.size-8).arrayBuffer());o.getUint32(0,!0)!==(r=>{const s=(()=>{if(_$)return _$;_$=[];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;_$[A]=c>>>0}return _$})();let a=4294967295;for(let A=0;r.length>A;A++)a=s[255&(a^r[A])]^a>>>8;return(4294967295^a)>>>0})(e)&&pde("invalid-crc");const i=e.length>>>0;o.getUint32(4,!0)!==i&&pde("invalid-size")}),function(t,e){return lYt.apply(this,arguments)});var lYt;function sRe(){return sRe=ng(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=ng(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 OWo(c,i),c}catch(i){if(n?.rethrow)throw i;return e&&console.error("Failed to gzip compress data",i),null}var o}),sRe.apply(this,arguments)}function uYt(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 zC="[redacted]",GWo=/^[A-Za-z0-9+/\n\r]+=*$/,YWo=/^[A-Za-z0-9_-]+={0,2}$/,UWo=/[-_]/,KWo=/^data:[^,\s]*;base64,/i,zWo=/^[A-Za-z0-9+/_-]+={0,2}$/,VWo=/\bph[a-z]_[A-Za-z0-9_-]{20,}\b/g,JWo=/^(authorization|cookie|set-cookie|x-api-key|api[-_]?key|api[-_]?token|access[-_]?token|refresh[-_]?token|token|password|secret|client[-_]?secret|private[-_]?key)$/i,gYt=/[a-z][a-z0-9+.-]{0,63}:[^\s<>"]+/gi,WWo=/[\s<>"]/,dYt=new RegExp(gYt.source,"i"),hYt=/[a-z][a-z0-9+.-]{0,63}:\/\//i,jWo=new RegExp(`^${hYt.source}`,"i"),qWo=new RegExp(hYt.source,"gi"),$Wo=/(^|[-_./;])(auth|token|secret|password|passwd|pwd|credential|signature|sig|key|hmac|sas|bearer|jwt|session|sessionid)([-_./;]|$)/i,XWo=/^(code|AWSAccessKeyId|GoogleAccessId|Policy)$/i,ZWo=/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g,ejo=/[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,24}/g,tjo=/\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g,njo=/(^|[^\w:])((?:(?:[0-9A-Fa-f]{1,4}:){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}){0,5}|::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,6})))(?=$|[^\w:])/g,ojo=/\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g,ijo=/\b\d(?:[ ./-]?\d){12,}\b/g,mYt=/\d+/g,rjo=/(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g,sjo=/(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;function aRe(t){return(function(e){return JWo.test(e)})(t)||$Wo.test(t)||XWo.test(t)}function ARe(t){return t.split("&",129).length>128}function ajo(t,e,n){return aRe(t)||e.includes(";")&&(function(o){return o.split(";").some(i=>aRe(i.split("=",1)[0]))})(e)?zC:dYt.test(e)?n?lRe(e,{allowNestedUrls:!1,stripPunctuation:!0}):zC:e}function pYt(t,e){const n=new URLSearchParams;let o=!1,i=!1;for(const[r,s]of new URLSearchParams(t)){const a=fde(r),A=fde(s);o||(o=a!==r||A!==s);const c=ajo(a,A,e);o||(o=c!==A),i=aRe(a)||c!==A,n.append(a,c)}return{changed:o,lastFieldSensitive:i,serialized:n.toString()}}function fYt(t,e){if(!t.includes("="))return{value:Ajo(t,e),lastFieldSensitive:!1};const n=pYt(t,e);return{value:n.changed?n.serialized:t,lastFieldSensitive:n.lastFieldSensitive}}function Ajo(t,e){return e?lRe(t,{allowNestedUrls:!1,stripPunctuation:!0}):dYt.test(t)?zC:t}function cjo(t,e,n){return t==="#"?!e.fragment&&(e.fragment=!0):t==="?"&&(e.fragment?n!=="="&&!e.fragmentQuery&&(e.fragmentQuery=!0):!e.query&&(e.query=!0))}function cRe(t,e){var n;if(t.length>8192&&jWo.test(t))return zC;const{address:o,suffix:i}=e.stripPunctuation?(function(p){let f=p.length;for(;f>0&&".,;:!?)]}'".includes(p[f-1]);)f--;return{address:p.slice(0,f),suffix:p.slice(f)}})(t):{address:t,suffix:""};let r;try{r=new URL(o)}catch{return zC+i}const s=r.search.slice(1),a=r.hash!=="",A=(function(p){const f=p.slice(1),_=f.indexOf("?");return 0>_?{head:f,tail:null}:{head:f.slice(0,_),tail:f.slice(_+1)}})(r.hash);if(ARe(s)||ARe(A.head)||ARe((n=A.tail)!==null&&n!==void 0?n:""))return zC+i;let c=!1;(r.username||r.password)&&(r.username=zC,r.password="",c=!0);const l=pYt(s,e.allowNestedUrls);l.changed&&(r.search=l.serialized,c=!0);const u=fYt(A.head,e.allowNestedUrls),g=A.tail===null?null:(h=A.tail,u.lastFieldSensitive?{value:h===""?"":zC,lastFieldSensitive:!0}:fYt(h,e.allowNestedUrls));var h;const d=g===null?u.value:`${u.value}?${g.value}`;d!==r.hash.slice(1)&&(r.hash=d,c=!0);const m=a?g??u:l;return(c?fde(r.toString()):o)+(m.lastFieldSensitive?"":i)}function lRe(t,e){return t.replace(gYt,n=>(function(o,i){const r=(function(A){if(!A.includes("://"))return[];const c=[...A.matchAll(qWo)].map(m=>m.index),l=[],u={query:!1,fragment:!1,fragmentQuery:!1};let g=0,h=!1,d="";for(let m=0;A.length>m&&c.length>g;m++){c[g]===m&&(m>0&&d!=="="&&l.push(m),g++);const p=A[m];cjo(p,u,d)?(d=p,h=!0):h&&"=&".includes(p)&&(d=p)}return l})(o);if(r.length===0)return cRe(o,i);let s="",a=0;for(const A of r)s+=cRe(o.slice(a,A),Zt(Zt({},i),{},{stripPunctuation:!1})),a=A;return s+cRe(o.slice(a),i)})(n,Zt(Zt({},e),{},{stripPunctuation:e.stripPunctuation&&n.length!==t.length})))}function fde(t){return t.replace(VWo,zC)}function ljo(t,e){return(function(n){return n.length>=10240&&(GWo.test(n)||(function(o){const i=KWo.exec(o);if(!i)return!1;let r;try{r=decodeURIComponent(o.slice(i[0].length))}catch{return!1}return zWo.test(r.replace(/[\r\n]/g,""))})(n)||UWo.test(n)&&YWo.test(n))})(t)?"[binary data redacted - not supported by PostHog MCP analytics]":(function(n,o,i){const r=4*i.maxStringLength;if(n.length>r){const s=o(n.slice(0,(function(a,A){let c=A;for(;c>0&&!WWo.test(a[c-1]);)c--;return c})(n,r)));if(s.length>=2*i.maxStringLength)return s+i.truncationSuffix}return o(n)})(t,n=>(function(o){return lRe(o,{allowNestedUrls:!0,stripPunctuation:!0})})((function(o){let i=o.replace(ZWo," ");return i=i.replace(ejo,zC),i=i.replace(tjo,zC),i=i.replace(njo,`$1${zC}`),i=i.replace(ijo,gjo),i=i.replace(ojo,zC),i=i.replace(rjo,`$1${zC}`),i=i.replace(sjo,`$1${zC}`),i})(fde(n))),e)}function ujo(t){let e=0,n=!1;for(let o=t.length-1;o>=0;o--){let i=t.charCodeAt(o)-48;if(0>i||i>9)return!1;n&&(i*=2,i>9&&(i-=9)),e+=i,n=!n}return e%10==0}function gjo(t){const e=[];for(let r=mYt.exec(t);r!==null;r=mYt.exec(t))e.push({digits:r[0],start:r.index,end:r.index+r[0].length});let n="",o=0,i=0;for(;e.length>i;){let r="",s=-1;for(let a=i;e.length>a&&(r+=e[a].digits,19>=r.length);a++)r.length>=13&&ujo(r)&&(s=a);0>s?i++:(n+=t.slice(o,e[i].start)+zC,o=e[s].end,i=s+1)}return n+t.slice(o)}const djo={}.propertyIsEnumerable;function _de(t,e){try{return _Yt(t,e,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch{return[]}}function uRe(t,e,n,o){if(0>=n.remainingNodes)return{stringValue:eRe};if(n.remainingNodes--,u2(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:CG(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:eRe};if(t instanceof Date){const i=t.getTime(),r=Number.isFinite(i)?t.toISOString():String(t);return{stringValue:typeof r=="string"?CG(r):String(r)}}n.ancestors.add(t);try{try{const i=t.toJSON;if(typeof i=="function")return uRe(i.call(t),e,n,o+1)}catch{}return qr(t)?{arrayValue:{values:hjo(t,e,n,o+1)}}:{kvlistValue:{values:_Yt(t,e,n,o+1)}}}finally{n.ancestors.delete(t)}}return{stringValue:CG(String(t))}}function hjo(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(Hs(a))continue;i.push(uRe(a,e,n,o))}catch{i.push({stringValue:p$})}return t.length>s&&i.push({stringValue:eRe}),i}function _Yt(t,e,n,o){const i=[];for(const r in t)if(djo.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(yd(s)||Eo(s))continue;i.push({key:CG(r),value:uRe(s,e,n,o)})}catch{i.push({key:CG(r),value:{stringValue:p$}})}}return i}function IYt(t,e,n){return Zt(Zt(Zt(Zt({},UGt({},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 mjo=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function CYt(t,e){const n=UGt({},t),o={};for(const i of mjo)({}).hasOwnProperty.call(n,i)&&(o[i]=n[i],delete n[i]);return[..._de(n,e),..._de(o,e)]}const yYt={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"},xYt={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}},pjo=xYt.info;function fjo(t){try{return CG(String(t))}catch{return p$}}function _jo(t,e,n,o){const i=t.level||"info",{text:r,number:s}=xYt[i]||pjo,a=(function(g=Date.now()){return String(g)+"000000"})(gh(o)?o:void 0),A={};e.distinctId&&(A.posthogDistinctId=e.distinctId),e.sessionId&&(A.sessionId=e.sessionId),e.windowId&&(A["window.id"]=e.windowId),Hs(e.sessionStartTimestamp)||(A.sessionStartTimestamp=String(e.sessionStartTimestamp)),Hs(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=Zt({},A),l=t.attributes;if(l){let g=[];try{g=Object.keys(l)}catch{g=[]}for(const h of g){let d;try{d=l[h]}catch{d=p$}Object.defineProperty(c,h,{value:d,enumerable:!0,writable:!0,configurable:!0})}}const u={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:s,severityText:r,body:{stringValue:fjo(t.body)},attributes:_de(c,n)};return t.trace_id&&(u.traceId=t.trace_id),t.span_id&&(u.spanId=t.span_id),Eo(t.trace_flags)||(u.flags=t.trace_flags),u}function EYt(t,e,n){return IYt(t,e,n)}function BYt(t,e,n,o){return{resourceLogs:[{resource:{attributes:CYt(e)},scopeLogs:[{scope:{name:n,version:o},logRecords:t}]}]}}var bYt=class{constructor(e){this.ls=e,this.us=0}get pending(){return!!this.cs}arm(e){this.clear(),this.us=Date.now()+e,this.cs=WGt(()=>{this.cs=void 0,this.ls()},e)}armNoEarlierThan(e){this.cs&&Date.now()+e<=this.us||this.arm(e)}clear(){this.cs&&(clearTimeout(this.cs),this.cs=void 0)}};function SYt(){return .75+.5*Math.random()}function QYt(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 Ijo=class{constructor(e,n,o,i,r,s=()=>Promise.resolve(),a){var A;this._instance=e,this.Mr=n,this.A=o,this.hs=i,this.ds=r,this.vs=s,this.fs=a,this.ps=new bYt(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new KGt,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(D7.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.Fs():this.gs()}captureLog(e,n){var o;if(this._instance.isDisabled||this._instance.optedOut||!e?.body)return;const i=this.Os(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:_jo(i,(o=n?.context)!==null&&o!==void 0?o:this.hs(),this.A,n?.occurredAtMs)};this.ds(()=>this.Ls(r))}Os(e){const n=this.Mr.beforeSend;if(!n)return e;const o=qr(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 ng(function*(){if(!e._instance.isDisabled)return e.ys||(e.ys=e.Ns().finally(()=>{e.ys=null})),e.ys})()}Ns(){var e=this;return ng(function*(){var n;e.ps.clear();let o=(n=e._instance.getPersistedProperty(D7.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),u=BYt(l.map(h=>h.record),e.qs(),(s=e.fs)!==null&&s!==void 0?s:e._instance.getLibraryId(),e._instance.getLibraryVersion()),g=yield e._instance.js(u);if(e._s!==A)return;if(g.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(g),e.ps.pending&&e.ps.arm(Math.max(e.Ms,e.ws.remainingMs())),g.kind==="retry-later"||(g.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."):g.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(D7.LogsQueue))!==null&&a!==void 0?a:[],r+=l.length,g.kind==="fatal"))throw g.error}})()}Bs(e){var n=this;return ng(function*(){var o;const i=Math.max(0,e-n.bs),r=(o=n._instance.getPersistedProperty(D7.LogsQueue))!==null&&o!==void 0?o:[];n._instance.setPersistedProperty(D7.LogsQueue,r.slice(i)),yield n.vs()})()}qs(){return EYt(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(e){var n;if(this._instance.optedOut)return;const o=(n=this._instance.getPersistedProperty(D7.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(D7.LogsQueue,o),this.Ts>o.length||this.ws.isOpen()?this.Fs():this.gs()}Fs(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}zs(){return Math.max(QYt(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){const e=this._instance.getPersistedProperty(D7.LogsQueue);return!!e&&e.length>0}shutdown(e){var n=this;return ng(function*(){n.ps.clear();const o=n.flush().catch(()=>{});e!==void 0?yield jGt(o,e):yield o})()}flushWithTimeout(e){var n=this;return ng(function*(){const o=n.flush();yield jGt(o,e,()=>{o.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},e=>{this.ks++,this.Ss=SYt(),this.A.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.zs())})}};const gRe=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function vYt(t){return String(t)+"000000"}function wYt(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 Cjo=class{constructor(e,n,o){this._instance=e,this.Mr=n,this.A=o,this.Hs=new Map,this.ps=new bYt(()=>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 KGt,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=ng(function*(){n&&(yield n.catch(()=>{})),yield e.Zs()});return function(){return i.apply(this,arguments)}})()().finally(()=>{this.ys===o&&(this.ys=null)});return this.ys=o,o}drainWindow(){if(this.Hs.size===0)return null;const e=this.Hs;return this.Hs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Js(e)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.Hs=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.Os(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?Zt({},n.attributes):void 0,i=wYt(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.Hs.get(i);if(!r){if(!this.Ks())return;r={name:n.name,type:n.type,unit:n.unit,attributes:o,windowStartMs:Date.now()},this.Hs.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.Fs()}Ks(){return this.Mr.maxSeriesPerFlush>this.Hs.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(gRe.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,gRe)]+=1;break}}}Os(e){const n=this.Mr.beforeSend;if(!n)return e;const o=qr(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}Fs(){this.ps.pending||this.ps.arm(this.zs())}zs(){return Math.max(QYt(this.Mr.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Zs(){var e=this;return ng(function*(){if(e.ps.clear(),e.Hs.size===0)return;const n=e.Hs;e.Hs=new Map,e.Us=!1,e.Ws=new Map,e.Vs=new Set;const o=e.Gs,i=yield e._instance.Ys(e.Js(n));if(o===e.Gs)switch(e.ws.record(i),i.kind==="retry-later"?(e.ks++,e.Ss=SYt()):(e.ks=0,e.Ss=1),e.ps.pending&&e.ps.arm(e.zs()),i.kind){case"ok":return;case"retry-later":return e.co(n),void e.ps.armNoEarlierThan(e.zs());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)}})()}Js(e){return n=this.ho(e),o=(function(s,a,A){return IYt(s,a,A)})(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),i=this._instance.getLibraryId(),r=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:CYt(o)},scopeMetrics:[{scope:{name:i,version:r},metrics:n}]}]};var n,o,i,r}ho(e){const n=vYt(Date.now()),o=new Map;for(const a of e.values()){var i;const A=wYt(a.type,a.name,a.unit,void 0);let c=o.get(A);c||(c=Zt({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=_de((i=a.attributes)!==null&&i!==void 0?i:{},this.A),u=vYt(a.windowStartMs);if(a.type==="count"){var r;const g={attributes:l,startTimeUnixNano:u,timeUnixNano:n,asDouble:(r=a.total)!==null&&r!==void 0?r:0};c.sum.dataPoints.push(g)}else if(a.type==="gauge"){var s;const g={attributes:l,timeUnixNano:n,asDouble:(s=a.last)!==null&&s!==void 0?s:0};c.gauge.dataPoints.push(g)}else a.hist&&c.histogram.dataPoints.push({attributes:l,startTimeUnixNano:u,timeUnixNano:n,count:a.hist.count,sum:a.hist.sum,min:a.hist.min,max:a.hist.max,bucketCounts:a.hist.bucketCounts,explicitBounds:gRe})}return Array.from(o.values())}co(e){for(const[i,r]of e){const s=this.Hs.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.Hs.set(i,r)}}};const PYt=(t,{debugEnabled:e}={})=>{const n={N(o,...i){let r;try{r=typeof window>"u"?void 0:window}catch{return}r&&(uS.DEBUG||r.POSTHOG_DEBUG||e)&&!Eo(r.console)&&r.console&&("__rrweb_original__"in r.console[o]?r.console[o].__rrweb_original__:r.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)=>PYt(`${t} ${o}`,i)};return n},li=PYt("[PostHog.js]"),xd=li.createLogger,yjo=xd("[ExternalScriptsLoader]"),Ide=t=>{const e=qo?.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]}},GR=(t,e,n)=>{if(t.config.disable_external_dependency_loading)return yjo.warn(`${e} was requested but loading of external scripts is disabled.`),n("Loading of external scripts is disabled");const o=Ide(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(!qo)return n("document not found");if(Ide(e))return GR(t,e,n);let r=qo.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")qo.head.appendChild(r);else{const a=qo.querySelectorAll("body > script");var s;a.length>0?(s=a[0].parentNode)===null||s===void 0||s.insertBefore(r,a[0]):qo.body.appendChild(r)}};qo?.body?i():qo?.addEventListener("DOMContentLoaded",i)},dRe={},MYt=(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)};Kr.__PosthogExtensions__=Kr.__PosthogExtensions__||{},Kr.__PosthogExtensions__.loadExternalDependency=(t,e,n)=>{if(e==="remote-config"){const i=t.requestRouter.endpointFor("assets",`/array/${t.config.token}/config.js`);return void GR(t,i,n)}const o=t.config.strict_script_versioning;if(o){const i=t.requestRouter.endpointFor("assets",`/static/${t.version}/${e}.js`),r=dRe[i];if(o==="fallback"&&r){if(Ide(r))return void GR(t,r,n);delete dRe[i]}return void GR(t,i,o==="fallback"?(s,a)=>{if(s)if(typeof s=="string")n(s);else{var A;const c=MYt(t,e);dRe[i]=c;const l=Ide(i);l==null||(A=l.parentNode)===null||A===void 0||A.removeChild(l),GR(t,c,n)}else n(void 0,a)}:n)}GR(t,MYt(t,e),n)},Kr.__PosthogExtensions__.loadSiteApp=(t,e,n)=>{const o=t.requestRouter.endpointFor("api",e);GR(t,o,n)},uS.DEBUG=!1,uS.LIB_VERSION="1.438.3",uS.LIB_NAME="web";var df=uS;const hRe="$early_access_features",dS="$active_feature_flags",YR="$feature_flag_details",I$="$feature_flag_errors",tP="$feature_flag_evaluated_at",UR="$feature_flag_request_id",C$="$minimal_flag_called_events",XB="$enabled_feature_flags",nP="$stored_group_properties",oP="$stored_person_properties",iP="$flag_call_reported",y$="$flag_call_reported_session_id",rP="$feature_flag_payloads",R7="$override_feature_flags",KR="$override_feature_flag_payloads",x$="visibilitychange",xjo="$people_distinct_id",ZB="distinct_id",mRe="$device_id",pRe="$device_model",Cde="__alias",Ejo="__cmpns",DYt="$fbc",yG="$fbc_persistence",NYt="$fbp",E$="$fbp_persistence",fRe="__timers",RYt="$autocapture_disabled_server_side",_Re="$heatmaps_enabled_server_side",IRe="$exception_capture_enabled_server_side",TYt="$error_tracking_suppression_rules",CRe="$error_tracking_capture_extension_exceptions",yRe="$web_vitals_enabled_server_side",xRe="$dead_clicks_enabled_server_side",ERe="$product_tours_enabled_server_side",kYt="$logs_capture_enabled_server_side",FYt="$web_vitals_allowed_metrics",B$="$session_recording_remote_config",Bjo="$session_recording_enabled_server_side",bjo="$replay_sample_rate",Sjo="$replay_override_sampling",Qjo="$replay_override_linked_flag",vjo="$replay_override_url_trigger",wjo="$replay_override_event_trigger",xG="$sesid",LYt="$session_is_sampled",Pjo="$session_past_minimum_duration",Mjo="$session_recording_url_trigger_activated_session",Djo="$session_recording_event_trigger_activated_session",Njo="$debug_first_full_snapshot_timestamp",Rjo="$sess_rec_flush_size",HYt="$groups",b$="$surveys",yde="$surveys_loaded_at",OYt="$surveys_activated",GYt="$surveys_activated_session",YYt="$surveys_activated_timestamps",BRe="ph_product_tours",Tjo="$product_tours_activated",kjo="$product_tours_activated_session",Fjo="$conversations_widget_session_id",Ljo="$conversations_ticket_id",Hjo="$conversations_widget_state",Ojo="$conversations_user_traits",g2="$user_state",bRe="$client_session_props",Gjo="$capture_rate_limit",UYt="$initial_campaign_params",KYt="$initial_referrer_info",EG="$initial_person_info",SRe="$epp",QRe="$posthog_cookieless",zYt="$cookieless_mode",VYt="$sdk_debug_extensions_init_method",JYt="$sdk_debug_extensions_init_time_ms",vRe="$sdk_debug_recording_script_not_loaded",wRe="$sdk_debug_replay_stale_config",WYt="$sdk_debug_replay_event_trigger_status",jYt="$sdk_debug_replay_linked_flag_trigger_status",qYt="$sdk_debug_replay_matched_recording_trigger_groups",$Yt="$sdk_debug_replay_pending_trigger_conditions",XYt="$sdk_debug_replay_remote_trigger_matching_config",ZYt="$sdk_debug_replay_trigger_groups_count",eUt="$sdk_debug_replay_url_trigger_status",Yjo="$session_recording_start_reason",PRe="PostHog loadExternalDependency extension not found.",hS="anonymous",xde="identified",tUt="identified_only",Ede="beforeunload",MRe="$pageview",nUt="$pageleave",oUt="$identify",iUt="$groupidentify";function BG(t,e){qr(t)&&t.forEach(e)}function Cl(t,e){if(!Hs(t))if(qr(t))t.forEach(e);else if((n=>n instanceof FormData)(t))t.forEach((n,o)=>e(n,o));else for(const n in t)UNe.call(t,n)&&e(t[n],n)}const og=function(t,...e){for(const n of e)for(const o in n)n[o]!==void 0&&(t[o]=n[o]);return t};function Bde(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 Ujo=function(t){return function(...e){try{return t.apply(this,e)}catch(n){li.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),li.critical(n)}}},DRe=function(t){const e={};return Cl(t,function(n,o){(Za(n)&&n.length>0||gh(n))&&(e[o]=n)}),e};function rUt(t){const e=Zt({},t);for(const n of["name","message","stack","cause","errors"])try{n in t&&(e[n]=t[n])}catch{}return e}const Kjo=["herokuapp.com","vercel.app","netlify.app"];function zjo(t){const e=t?.hostname;if(!Za(e))return!1;const n=e.split(".").slice(-2).join(".");for(const o of Kjo)if(n===o)return!1;return!0}function Zc(t,e,n,o){const{capture:i=!1,passive:r=!0}=o??{};t?.addEventListener(e,n,{capture:i,passive:r})}function NRe(t){return t.name==="ph_toolbar_internal"}const S$=t=>{if(qo){try{const e=t+"=",n=qo.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 gh(t)&&isFinite(t)&&Math.floor(t)===t});var Vjo=class dat{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 dat(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 dat(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}},Jjo=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 gh(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 Vjo.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 Wjo}};let sUt=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};jn&&!Eo(jn.crypto)&&crypto.getRandomValues&&(sUt=t=>crypto.getRandomValues(t));var Wjo=class{nextUint32(){return this.Rt.length>this.Et||(sUt(this.Rt),this.Et=0),this.Rt[this.Et++]}constructor(){this.Rt=new Uint32Array(8),this.Et=1/0}};let aUt;const e9=()=>jjo().toString(),jjo=()=>(aUt||(aUt=new Jjo)).generate();let Q$="";const qjo=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let bG=null;const Ed={At(){if(!yd(bG))return bG;if(bG=!1,qo)try{const t=`__ph_cookie_support_${e9()}`;Ed.$t(t,"xyz"),bG=S$(t)==='"xyz"',Ed.Pt(t)}catch{bG=!1}return bG},Dt(t){li.error("cookieStore error: "+t)},Ot:S$,Ft(t){let e;try{e=JSON.parse(Ed.Ot(t))||{}}catch{}return e},$t(t,e,n,o,i){if(!qo)return!1;try{let r="",s="";const a=(function(c,l){if(l){let u=(function(g,h=qo){if(Q$)return Q$;if(!h||["localhost","127.0.0.1"].includes(g))return"";const d=g.split(".");let m=Math.min(d.length,8);const p="dmn_chk_"+e9();for(;!Q$&&m--;){const f=d.slice(m).join("."),_=p+"=1;domain=."+f+";path=/";h.cookie=_+";max-age=3",h.cookie.includes(p)&&(h.cookie=_+";max-age=0",Q$=f)}return Q$})(c);if(!u){const g=(h=>{const d=h.match(qjo);return d?d[0]:""})(c);g!==u&&li.info("Warning: cookie subdomain discovery mismatch",g,u),u=g}return u?"; domain=."+u:""}return""})(qo.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&&li.warn("cookieStore warning: large cookie, len="+A.length),qo.cookie=A,!0}catch{return!1}},Pt(t,e){if(qo?.cookie&&(!e||!yd(S$(t))))try{Ed.$t(t,"",-1,e)}catch{return}}};let RRe=null;const hc={At(){if(!yd(RRe))return RRe;let t=!0;if(Eo(jn))t=!1;else try{const e="__mplssupport__";hc.$t(e,"xyz"),hc.Ot(e)!=='"xyz"'&&(t=!1),hc.Pt(e)}catch{t=!1}return t||li.error("localStorage unsupported; falling back to cookie store"),RRe=t,t},Dt(t){li.error("localStorage error: "+t)},Ot(t){try{return jn?.localStorage.getItem(t)}catch(e){hc.Dt(e)}return null},Ft(t){try{return JSON.parse(hc.Ot(t))||{}}catch{}return null},$t(t,e){try{return jn?.localStorage.setItem(t,JSON.stringify(e)),!0}catch(n){hc.Dt(n)}return!1},Pt(t){try{jn?.localStorage.removeItem(t)}catch(e){hc.Dt(e)}}},TRe=[oP,dS,XB,YR,rP,UR,tP,I$,iP],zR=[mRe,ZB,xG,LYt,SRe,EG,yG,g2],bde=t=>t+"_cpm",$jo=["__proto__","constructor","prototype"],kRe=t=>{if(!va(t))return{};const e={};return Object.keys(t).forEach(n=>{$jo.indexOf(n)===-1&&(e[n]=t[n])}),e},FRe=(t,e=[])=>{const n={};return[...zR,...e].forEach(o=>{const i=t[o];Eo(i)||yd(i)||i===""||(n[o]=i)}),n},AUt=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)},cUt=(t,e)=>({p:e,f:AUt(JSON.stringify(t))}),lUt=(t,e)=>{if(!e)return{properties:[],isValid:!1};try{const n=Ed.Ft(bde(t)),o=n?.f===AUt(e)&&qr(n.p);return{properties:o?n.p:[],isValid:o}}catch{return{properties:[],isValid:!1}}},LRe=(t,e)=>e+"|"+(Ed.Ot(bde(t))||""),SG={},HRe={At:()=>!0,Dt(t){li.error("memoryStorage error: "+t)},Ot:t=>t in SG?SG[t]:null,Ft:t=>t in SG?SG[t]:null,$t:(t,e)=>(SG[t]=e,!0),Pt(t){delete SG[t]}};let VR=null;const ou={At(){if(!yd(VR))return VR;if(VR=!0,Eo(jn))VR=!1;else try{const t="__support__";ou.$t(t,"xyz"),ou.Ot(t)!=='"xyz"'&&(VR=!1),ou.Pt(t)}catch{VR=!1}return VR},Dt(t){li.error("sessionStorage error: ",t)},Ot(t){try{return jn?.sessionStorage.getItem(t)}catch(e){ou.Dt(e)}return null},Ft(t){try{return JSON.parse(ou.Ot(t))||null}catch{}return null},$t(t,e){try{return jn?.sessionStorage.setItem(t,JSON.stringify(e)),!0}catch(n){ou.Dt(n)}return!1},Pt(t){try{jn?.sessionStorage.removeItem(t)}catch(e){ou.Dt(e)}}};var Xjo=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 zNe(e)?1:jr($Jo,e)?0:-1}get No(){const e=this.Mr.opt_out_capturing_persistence_type,n=e==="localStorage"?hc:Ed,o=n.At()?n:HRe;if(!this.jo||this.jo!==o){this.jo=o;const i=e==="localStorage"?Ed:hc;i.Ot(this.qo)&&(this.jo.Ot(this.qo)||this.optInOut(zNe(i.Ot(this.qo))),i.Pt(this.qo,this.Mr.cross_subdomain_cookie))}return this.jo}Do(){return!!this.Mr.respect_dnt&&[I_?.doNotTrack,I_?.msDoNotTrack,Kr.doNotTrack,I_?.globalPrivacyControl].some(e=>zNe(e))}};function uUt(t,e){var n;const o=t==null||(n=t.config)===null||n===void 0?void 0:n.get_current_url;if(!pp(o))return e;try{const i=o(e);return Za(i)&&i?i:e}catch(i){return li.error("Error in get_current_url, falling back to window.location.href",i),e}}function gUt(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 t9(t){return!!t&&t.nodeType===1}function BI(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function dUt(t){return!!t&&t.nodeType===3}function ORe(t){return!!t&&t.nodeType===11&&t9(t.host)}function GRe(t){return t?fG(t).split(/\s+/):[]}function hUt(t,e){const n=(function(o){var i;const r=jn==null||(i=jn.location)===null||i===void 0?void 0:i.href;return Eo(r)?void 0:uUt(o,r)})(e);return!!(n&&t&&t.some(o=>n.match(o)))}function QG(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 GRe(e)}function mUt(t){return Hs(t)?null:fG(t).split(/(\s+)/).filter(e=>wG(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function v$(t){let e="";return JR(t)&&!vG(t)&&t.childNodes&&t.childNodes.length&&Cl(t.childNodes,function(n){var o;dUt(n)&&n.textContent&&(e+=(o=mUt(n.textContent))!==null&&o!==void 0?o:"")}),fG(e)}function w$(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 YRe=["a","button","form","input","select","textarea","label"];function URe(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 KRe(t,e){if(Eo(e))return!0;for(const n of t)if(e.some(o=>URe(n,o)))return!0;return!1}function pUt(t){const e=t.parentNode;return!(!e||!t9(e))&&e}const zRe=[".ph-no-autocapture","[data-ph-no-autocapture]"],fUt=["next","previous","prev",">","<","→","←","›","‹","»","«","▶","◀","❯","❮"],VRe=[...fUt,"+","-","−","–"],_Ut=VRe.length+10,Zjo=["button","a","input","select","textarea","label"],eqo=["button","link","tab","menuitem","option"],IUt=(t,e)=>/[a-z0-9]/i.test(e)?jr(VRe,e)?new RegExp(`\\b${e}\\b`).test(t):t.includes(e):t===e,tqo=t=>jr(Zjo,t.tagName.toLowerCase())||jr(eqo,(t.getAttribute("role")||"").toLowerCase());function JRe(t){let e="",n="";const o=s=>{t9(s)&&JR(s)&&!vG(s)&&(e+=` ${v$(s)}`,n=n||s.getAttribute("aria-label")||"",Cl(s.childNodes,o))};o(t),e=fG(e.replace(/\s+/g," "));const i=(wG(e)?e:"").toLowerCase(),r=t.getAttribute("aria-label")||(i?"":n);return{safeText:i,ariaLabel:fG(r).toLowerCase()}}const CUt=[".ph-no-rageclick",".ph-no-capture"],nqo=["","text","search","email","password","url","tel","number"];function yUt(t,e){if(!jn||WRe(t))return!1;let n,o,i;var r,s;if(u2(e)?(n=!!e&&CUt,o=void 0,i=!1):(n=(r=e?.css_selector_ignorelist)!==null&&r!==void 0?r:CUt,o=e?.content_ignorelist,i=(s=e?.ignore_text_selection)!==null&&s!==void 0&&s),n===!1||i&&(function(A){return!(!A||!t9(A))&&(!!BI(A,"textarea")||(BI(A,"input")?jr(nqo,(A.getAttribute("type")||"").toLowerCase()):(function(c){var l;if(c.isContentEditable)return!0;const u=(l=c.getAttribute)===null||l===void 0?void 0:l.call(c,"contenteditable");return u==="true"||u===""})(A)))})(t))return!1;const{targetElementList:a}=xUt(t,!1);return!(o&&(function(A,{safeText:c,ariaLabel:l}){let u;if(A===!0)u=fUt;else{if(!qr(A))return!1;if(A.length>_Ut)return li.error(`[PostHog] content_ignorelist array cannot exceed ${_Ut} items. Use css_selector_ignorelist for more complex matching.`),!1;u=A.map(g=>g.toLowerCase())}return u.some(g=>IUt(c,g)||IUt(l,g))})(o,(function(A,c){for(const l of c)if(tqo(l))return JRe(l);for(const l of c){try{if(jn?.getComputedStyle(l).getPropertyValue("cursor")!=="pointer")break}catch{break}const u=JRe(l);if(u.safeText||u.ariaLabel)return u}return JRe(A)})(t,a))||KRe(a,n))}const WRe=t=>!t||BI(t,"html")||!t9(t),xUt=(t,e)=>{if(!jn||WRe(t))return{parentIsUsefulElement:!1,targetElementList:[]};let n=!1;const o=[t];let i=t;for(;i.parentNode&&!BI(i,"body");){if(ORe(i.parentNode)){o.push(i.parentNode.host),i=i.parentNode.host;continue}const r=pUt(i);if(!r)break;if(e||YRe.indexOf(r.tagName.toLowerCase())>-1)n=!0;else try{const s=jn.getComputedStyle(r);s&&s.getPropertyValue("cursor")==="pointer"&&(n=!0)}catch{}o.push(r),i=r}return{parentIsUsefulElement:n,targetElementList:o}};function JR(t){const e=new Set;let n=0;for(let r=t;r.parentNode&&!BI(r,"body");r=r.parentNode){if(n++>=1e3||e.has(r))return!1;e.add(r);const s=QG(r);if(jr(s,"ph-sensitive")||jr(s,"ph-no-capture"))return!1}if(jr(QG(t),"ph-include"))return!0;const o=t.type||"";if(Za(o))switch(o.toLowerCase()){case"hidden":case"password":return!1}const i=t.name||t.id||"";return!Za(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 vG(t){return!!(BI(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||BI(t,"select")||BI(t,"textarea")||t.getAttribute("contenteditable")==="true")}const EUt=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}))$"),BUt=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,oqo=[16,15,14,13],iqo=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),bUt=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),SUt=/[0-9A-Za-z_]/;function rqo(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 wG(t,e=!0){return!(Hs(t)||Za(t)&&(t=fG(t),(e?EUt.test((t||"").replace(/[- ]/g,"")):(function(n){let o;for(BUt.lastIndex=0;o=BUt.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 oqo){const A=s+a;if(r.length>=A){const c=r.slice(s,A);if(EUt.test(c)&&rqo(c))return!0}}}return!1})(t))||(e?iqo.test(t):(function(n){let o;for(bUt.lastIndex=0;o=bUt.exec(n);){const i=o[1],r=o[3];if(!(i&&r&&SUt.test(i)&&SUt.test(r)))return!0}return!1})(t))))}function QUt(t){let e=v$(t);return e=`${e} ${vUt(t)}`.trim(),wG(e)?e:""}function vUt(t){let e="";return t&&t.childNodes&&t.childNodes.length&&Cl(t.childNodes,function(n){var o;if(n&&((o=n.tagName)===null||o===void 0?void 0:o.toLowerCase())==="span")try{const i=v$(n);e=`${e} ${i}`.trim(),n.childNodes&&n.childNodes.length&&(e=`${e} ${vUt(n)}`.trim())}catch(i){li.error("[AutoCapture]",i)}}),e}function wUt(t){return t.replace(/"|\\"/g,'\\"')}function sqo(t){const e=t.attr__class;if(e)return qr(e)?e:GRe(e)}const Sde=xd("[Dead Clicks]"),aqo=()=>!0,Aqo=t=>{var e;const n=!!(!((e=t.instance.persistence)===null||e===void 0)&&e.get_property(xRe)),o=t.instance.config.capture_dead_clicks;return u2(o)?o:!!va(o)||n};var PUt=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({[xRe]:n.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.zo(()=>{this.Ho()}):this.stop()}zo(e){var n,o,i;!((n=Kr.__PosthogExtensions__)===null||n===void 0)&&n.initDeadClicksAutocapture?e():(o=Kr.__PosthogExtensions__)===null||o===void 0||(i=o.loadExternalDependency)===null||i===void 0||i.call(o,this.instance,"dead-clicks-autocapture",r=>{r?Sde.error("failed to load script",r):e()})}Ho(){var e;if(qo){if(!this.Bo&&(!((e=Kr.__PosthogExtensions__)===null||e===void 0)&&e.initDeadClicksAutocapture)){const n=va(this.instance.config.capture_dead_clicks)?Zt({},this.instance.config.capture_dead_clicks):{};n.__onCapture=this.onCapture,this.onCapture&&(n.capture_dead_swipes=!1),this.Bo=Kr.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this.Bo.start(qo),Sde.info("starting...")}}else Sde.error("`document` not found. Cannot start.")}stop(){this.Bo&&(this.Bo.stop(),this.Bo=void 0,Sde.info("stopping..."))}};const P$=xd("[SegmentIntegration]");function MUt(t,e,n=!0){const o=t.config.segment;if(!o)return e();const{analytics:i,filterProperties:r}=(a=>pp(a.register))(s=o)?{analytics:s}:s;var s;(function(a,A,c,l){const u=h=>{const d=()=>h.anonymousId()||e9();a.config.get_device_id=d,l&&h.id()&&(a.register({distinct_id:h.id(),$device_id:d()}),a.persistence.set_property(g2,xde)),c(l?void 0:h.anonymousId()||void 0)},g=A.user();"then"in g&&pp(g.then)?g.then(u):u(g)})(t,i,a=>{i.register(((A,c,{filterProperties:l}={})=>{typeof Promise<"u"&&Promise.resolve||P$.warn("This browser does not have Promise support, and can not use the segment integration");const u=(g,h)=>{if(!h)return g;const d=!!c&&g.event.anonymousId===c&&!g.event.userId;d||g.event.userId||g.event.anonymousId===A.get_distinct_id()||(P$.info("No userId set, resetting PostHog"),A.reset()),d||(c=void 0),g.event.userId&&g.event.userId!==A.get_distinct_id()&&(P$.info("UserId set, identifying with PostHog"),A.identify(g.event.userId));let m=A.calculateEventProperties(h,g.event.properties);if(!Hs(l)){const p=g.event.properties||{},f={};for(const I of Object.keys(m))UNe.call(p,I)||(f[I]=m[I]);const _=((I,C)=>{const y=qr(I)?I:[I];let x=Zt({},C);for(const E of y)try{if(x=E(x),Hs(x))return null}catch(B){return P$.error("Error in Segment filterProperties:",B),null}return x})(l,f);if(Hs(_))return g;m=_}return g.event.properties=Object.assign({},m,g.event.properties),g};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(g){return u(g,g.event.event)},page(g){return u(g,MRe)},identify(g){return u(g,oUt)},screen(g){return u(g,"$screen")}}})(t,a,{filterProperties:r})).then(()=>{e()},A=>{P$.error("Failed to register the Segment integration",A),e()})},n)}const DUt="posthog-js";function NUt(t,{organization:e,projectId:n,prefix:o,severityAllowList:i=["error"],sendExceptionsToPostHog:r=!0}={}){return s=>{var a,A,c,l,u;if(i!=="*"&&!i.includes(s.level)||!t.__loaded)return s;s.tags||(s.tags={});const g=t.requestRouter.endpointFor("ui",`/project/${t.config.token}/person/${t.get_distinct_id()}`);s.tags["PostHog Person URL"]=g,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(f=>Zt(Zt({},f),{},{stacktrace:f.stacktrace?Zt(Zt({},f.stacktrace),{},{type:"raw",frames:(f.stacktrace.frames||[]).map(_=>Zt(Zt({},_),{},{platform:"web:javascript"}))}):void 0})),m={$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:(u=h[0])===null||u===void 0?void 0:u.type,$sentry_tags:s.tags};var p;return e&&n&&(m.$sentry_url=(o||"https://sentry.io/organizations/")+e+"/issues/?project="+n+"&query="+s.event_id),r&&((p=t.exceptions)===null||p===void 0||p.sendExceptionEvent(m)),s}}var cqo=class{constructor(e,n,o,i,r,s){this.name=DUt,this.setupOnce=function(a){a(NUt(e,{organization:n,projectId:o,prefix:i,severityAllowList:r,sendExceptionsToPostHog:s==null||s}))}}},RUt=class{constructor(e){this.Uo=(n,o,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(li.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=jn?.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:u}=r;if(!(Eo(s)||Eo(a)||Eo(A)||Eo(c)||Eo(l)||Eo(u))){s=Math.ceil(s),a=Math.ceil(a),A=Math.ceil(A),c=Math.ceil(c),l=Math.ceil(l),u=Math.ceil(u);const g=s>1?N7(a/s,0,1,li):1,h=s>1?N7(A/s,0,1,li):1,d=c>1?N7(l/c,0,1,li):1,m=c>1?N7(u/c,0,1,li):1;i=og(i,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:g,$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:u,$prev_pageview_max_content_percentage:m})}}return o.pathname&&(i.$prev_pageview_pathname=o.pathname),o.timestamp&&(i.$prev_pageview_duration=(e.getTime()-o.timestamp.getTime())/1e3),i}};const M$=["flags","surveys"],lqo={[xjo]:{exposure:"hidden"},[Cde]:{exposure:"hidden"},[Ejo]:{exposure:"hidden"},[fRe]:{exposure:"hidden"},[yG]:{exposure:"hidden"},[E$]:{exposure:"hidden"},[RYt]:{exposure:"event"},[_Re]:{exposure:"hidden"},[kYt]:{exposure:"hidden"},[IRe]:{exposure:"event"},[TYt]:{exposure:"hidden"},[CRe]:{exposure:"event"},[yRe]:{exposure:"event"},[xRe]:{exposure:"event"},[ERe]:{exposure:"hidden"},[FYt]:{exposure:"event"},[B$]:{exposure:"hidden"},[Bjo]:{exposure:"hidden"},[xG]:{exposure:"hidden"},[LYt]:{exposure:"event"},[bjo]:{exposure:"event",shouldSkipFromEventProperties:t=>yd(t)},[Pjo]:{exposure:"event"},[Mjo]:{exposure:"event"},[Djo]:{exposure:"event"},[Njo]:{exposure:"event"},[Rjo]:{exposure:"hidden"},[XB]:{exposure:"hidden",storageGroup:"flags"},[dS]:{exposure:"hidden",storageGroup:"flags"},[hRe]:{exposure:"hidden"},[YR]:{exposure:"hidden",storageGroup:"flags"},[rP]:{exposure:"hidden",storageGroup:"flags"},[UR]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[C$]:{exposure:"hidden",storageGroup:"flags"},[R7]:{exposure:"hidden"},[KR]:{exposure:"hidden"},[oP]:{exposure:"hidden"},[nP]:{exposure:"hidden"},[b$]:{exposure:"hidden",storageGroup:"surveys"},[yde]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[OYt]:{exposure:"event"},[GYt]:{exposure:"hidden"},[YYt]:{exposure:"hidden"},[BRe]:{exposure:"hidden"},[Tjo]:{exposure:"hidden"},[kjo]:{exposure:"hidden"},[Fjo]:{exposure:"event"},[Ljo]:{exposure:"event"},[Hjo]:{exposure:"event"},[Ojo]:{exposure:"event"},[iP]:{exposure:"hidden"},[y$]:{exposure:"hidden"},[HYt]:{exposure:"event"},[I$]:{exposure:"hidden"},[tP]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[g2]:{exposure:"hidden"},[bRe]:{exposure:"hidden"},[Gjo]:{exposure:"hidden"},[UYt]:{exposure:"hidden"},[KYt]:{exposure:"hidden"},[EG]:{exposure:"hidden"},[SRe]:{exposure:"hidden"},[Sjo]:{exposure:"event"},[Qjo]:{exposure:"event"},[vjo]:{exposure:"event"},[wjo]:{exposure:"event"},[VYt]:{exposure:"event"},[JYt]:{exposure:"event"},[vRe]:{exposure:"hidden"},[wRe]:{exposure:"hidden"},[WYt]:{exposure:"hidden"},[jYt]:{exposure:"hidden"},[qYt]:{exposure:"hidden"},[$Yt]:{exposure:"hidden"},[XYt]:{exposure:"hidden"},[ZYt]:{exposure:"hidden"},[eUt]:{exposure:"hidden"},[Yjo]:{exposure:"event"}},uqo=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],I1=t=>{const e=lqo[t];if(e)return e;for(const[n,o]of uqo)if(t.indexOf(n)===0)return o};function TUt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}const kUt=()=>{try{return"u">typeof window&&window.navigator.onLine!==!1}catch{return!1}},FUt=(t,e)=>t>=e&&kUt(),LUt=(t,e,n,o)=>{if(t===0){if(kUt()){const i=e+1;return i===n&&o(),i}return e}return 0},PG=(t,e)=>{try{let n;return JSON.stringify(t,(o,i)=>{var r;return _G(i)?((r=n)!==null&&r!==void 0||(n=new WeakMap),n.has(i)||n.set(i,rUt(i)),n.get(i)):typeof i=="bigint"?i.toString():i},e)}catch{return sGt(t)}},mS=t=>{const e=qo?.createElement("a");return Eo(e)?null:(e.href=t,e)},MG=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(!qr(o)||2>o.length)return"";{let i=o[1];try{i=decodeURIComponent(i)}catch{li.error("Skipping decoding for malformed query param: "+i)}return i.replace(/\+/g," ")}},D$=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 u=0;A.length>u;u++){const g=A[u].split("=");qr(g)&&(e.includes(g[0])?c.push(g[0]+"="+n):c.push(A[u]))}let l=a;return s!=null&&(l+="?"+c.join("&")),i!=null&&(l+="#"+i),l},Qde=function(t,e){const n=t.match(new RegExp(e+"=([^&]*)"));return n?n[1]:null},DG=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","irclid","_kx"],gqo=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...DG],N$="<masked>",dqo=["li_fat_id"];function HUt(t,e,n){if(!qo)return{};const o=e?[...DG,...n||[]]:[],i=OUt(D$(qo.URL,o,N$),t),r=(function(){const s={};return Cl(dqo,function(a){const A=S$(a);s[a]=A||null}),s})();return og(r,i)}function OUt(t,e){const n=gqo.concat(e||[]),o={};return Cl(n,function(i){const r=MG(t,i);o[i]=r||null}),o}function GUt(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(!yd(e)){o.$search_engine=e;const i=qo?MG(qo.referrer,n):"";i.length&&(o.ph_keyword=i)}return o}function YUt(){return navigator.language||navigator.userLanguage}function hqo(){const t=YUt();return typeof t=="string"?t.split("-")[0]:void 0}const vde="$direct";function UUt(){return qo?.referrer||vde}function KUt(t,e,n=!1){const o=t?[...DG,...e||[]]:[],i=n?eP(tg?.href):tg?.href,r=i?.substring(0,1e3);return{r:UUt().substring(0,1e3),u:r?D$(r,o,N$):void 0}}function zUt(t,e=!1){var n;const{r:o,u:i}=t,r=e?eP(i):i,s={$referrer:o,$referring_domain:o==null?void 0:o==vde?vde:(n=mS(o))===null||n===void 0?void 0:n.host};if(r){s.$current_url=r;const a=mS(r);s.$host=a?.host,s.$pathname=a?.pathname;const A=OUt(r);og(s,A)}if(o){const a=GUt(o);og(s,a)}return s}function mqo(){try{return new Date().getTimezoneOffset()}catch{return}}const pqo={flags:tP,surveys:yde},fqo=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],wde=t=>`${t}_cookie_identity_change_pending`,Pde=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},hf="main",pS=[XB,dS,YR,rP,UR,tP,C$,oP],jRe=t=>pS.indexOf(t)!==-1,VUt=[yG,E$],JUt=t=>VUt.indexOf(t)!==-1,sP=(t,e)=>{try{return JSON.stringify(t)===JSON.stringify(e)}catch{return t===e}},NG=t=>{if(!t)return{};const e=JSON.parse(t);return va(e)?e:{}},WUt=(t,e)=>{Cl(t,(n,o)=>{const i=I1(o);i&&i.exposure!=="event"||{}.hasOwnProperty.call(e,o)||delete t[o]})};var qRe=class{constructor(e,n,o=!0,i=!e.cookieless_mode){if(this.Zo={},this.Jo=!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.ca(e),this.Xo=this.ha(e),this.load(i),this.da(),e.debug&&li.info("Persistence loaded",e.persistence,Zt({},this.props)),this.update_config(e,e,n),this.save(),jn){const r=()=>this.flush();Zc(jn,"beforeunload",r,{capture:!1}),Zc(jn,"pagehide",r,{capture:!1}),this.va=s=>{if(this.Jo&&(!s.storageArea||s.storageArea===jn?.localStorage)&&s.key)if(s.key!==this.ua){if(this.Xo){const a=M$.find(A=>s.key===this.fa(A));a&&this.pa(s.key,a)}}else this.pa(s.key,hf)},Zc(jn,"storage",this.va)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([n,o])=>{const i=this.ea.get(n);if(!jRe(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&&jn&&(jn.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=hc.Ot(e),yd(r)){const A=this.ma(n);return A.storageValue=null,n!==hf&&(A.persisted=!1),!1}i=NG(r)}catch{return!1}const s=n===hf?i:hc.Ft(this.ua);if(s&&this.ya(s))return!1;const a=this.ba(i,n,o);return n===hf&&this.Xo&&!sP(this._a().main,i)||this.wa(i,n,!0,r),a}ya(e){const n=this.props[ZB],o=e[ZB];return!Eo(n)&&!Eo(o)&&n!==o}wa(e,n,o,i){const r=this.ma(n);r.storageValue=i,n!==hf&&(r.persisted=o);try{r.fingerprint=this.ka(e,n)}catch{r.fingerprint=void 0}}ba(e,n,o){let i=!1;return pS.forEach(r=>{var s;const a=(s=I1(r))===null||s===void 0?void 0:s.storageGroup;if(n===hf&&this.Xo&&a||n!==hf&&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&&sP(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.Jo)return!1;try{this.sa=!1;const e=hc.Ot(this.ua),n=this.ma(hf);let o,i=!1,r=!1;if(e!==n.storageValue)if(yd(e))n.storageValue=null;else{if(o=NG(e),this.sa=!this.na&&this.ya(o),this.sa)return!1;r=this.ba(o,hf,!1),!this.Xo||sP(this._a().main,o)?this.wa(o,hf,!0,e):n.storageValue=e,i=!0}return this.Xo&&M$.forEach(s=>{const a=hc.Ot(this.fa(s)),A=this.ma(s),c=o||{},l=i&&pS.some(g=>{var h;return((h=I1(g))===null||h===void 0?void 0:h.storageGroup)===s&&g in c});if(a===A.storageValue&&!l)return;if(yd(a))return A.storageValue=null,A.persisted=!1,void(l&&(r=this.ba(c,s,!1)||r));const u=NG(a);r=this.ba(u,s,!1)||r,this.wa(u,s,!0,a)}),r}catch{return!1}}ga(e,n){this.ea.set(e,n);const o=I1(e);o?.volatile||(this.ma((this.Xo?o?.storageGroup:void 0)||hf).fingerprint=void 0,this.Ta(e))}Ia(){pS.forEach(e=>this.ea.set(e,!0))}da(){if(this.Jo)try{const e=hc.Ot(this.ua),n=NG(e);this.ma(hf).storageValue=e,pS.forEach(o=>{var i;const r=this.Xo?(i=I1(o))===null||i===void 0?void 0:i.storageGroup:void 0,s=r?hc.Ot(this.fa(r)):null;if(r){const A=this.ma(r);A.storageValue=s,A.persisted=!yd(s)}const a=r&&!yd(s)?NG(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(qr(n)?n:[]),a=new Set(qr(this.props[e])?this.props[e]:[]);return o.forEach(A=>a.has(A)?s.add(A):s.delete(A)),Array.from(s)}const i=va(n)?Zt({},n):{},r=va(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(!jRe(e))return;const i=this.ea.get(e);if(i===!0)return;let r=n;if(this.Jo)try{var s;const A=this.Xo?(s=I1(e))===null||s===void 0?void 0:s.storageGroup:void 0,c=A?this.fa(A):this.ua;r=NG(hc.Ot(c))[e]}catch{}const a=new Set(i||[]);if(e==="$active_feature_flags"){if(!Eo(n)&&!qr(n)||!Eo(r)&&!qr(r)||!qr(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(u=>{A.has(u)!==l.has(u)&&a.add(u)}),a.forEach(u=>{c.has(u)===l.has(u)&&a.delete(u)})}else{if(!va(o))return void(sP(r,o)?this.ea.delete(e):this.ga(e,!0));{if(!Eo(n)&&!va(n)||Eo(n)&&Jx(o)&&Eo(r))return void this.ga(e,!0);const A=va(n)?n:{},c=va(r)?r:{};new Set([...Object.keys(A),...Object.keys(o)]).forEach(l=>{l in A==l in o&&sP(A[l],o[l])||a.add(l)}),a.forEach(l=>{l in c==l in o&&sP(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 gh(n)&&n>0?n:0}Pa(e){if(this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie")if(e)try{const n=FRe(e,this.Mr.cookie_persisted_properties||[]),o=cUt(n,this.Mr.cookie_persisted_properties||[]),i=JSON.stringify(n)+"|"+JSON.stringify(o),r=Ed.Ot(this.ua)||void 0;r&&LRe(this.ua,r)===i&&(this.Ra=i,this.Aa=r)}catch{}else try{const n=Ed.Ot(this.ua)||void 0;this.Ra=n?LRe(this.ua,n):void 0,this.Aa=n}catch{}}syncCookieProperties(){return this.Fa(this.Mr)}Fa(e,n=!1){if(this.hi&&!n||this.ta||!e.cookieWinsOnConflict||e.persistence.toLowerCase()!=="localstorage+cookie")return!1;let o;try{o=Ed.Ot(this.ua)||void 0}catch{}if(!o||o===this.Aa)return!1;const i=LRe(this.ua,o);let r;try{r=kRe(JSON.parse(o))}catch{return!1}if((Ed.Ot(this.ua)||void 0)!==o)return!1;this.Ra=i,this.Aa=o;const s=lUt(this.ua,o),a=[...zR,...s.properties],A={};if(Object.keys(r).forEach(p=>{const f=r[p];(Eo(f)||yd(f)||f===""||p==="$user_state"&&f!=="anonymous"&&f!=="identified")&&(A[p]=!0,delete r[p])}),Jx(r))return!1;const c="distinct_id"in r||r.$user_state==="anonymous"||r.$user_state==="identified",l=this.props,u=l[ZB],g=l[g2],h=og({},l);[...zR,...e.cookie_persisted_properties||[]].forEach(p=>{if(a.indexOf(p)!==-1&&!(p in r)&&!A[p]&&(c||p!=="distinct_id"&&p!=="$user_state")){const f=h[p];(s.isValid||zR.indexOf(p)===-1||f!==!1&&f!==0)&&delete h[p]}}),this.props=og(h,r),pS.forEach(p=>{const f=p in this.props;p in l===f&&sP(l[p],this.props[p])||(f?this.Ma(p,l[p],this.props[p]):this.ga(p,!0))}),!c||"$user_state"in r||"$user_state"in this.props||this.xa(g2,hS);const d=this.props[ZB],m=this.props[g2];return!c||d===u&&m===g||(this.na=!0,this.Yo=!0,ou.$t(wde(this.ua),!0),this.$a(oP),this.$a(dS),this.$a(XB),this.$a(YR),this.$a(rP),this.$a(UR),this.$a(tP),this.$a(I$),this.$a(iP),m!=="anonymous"||g!=="identified"&&r.$user_state!=="anonymous"&&(Eo(u)||d===u)||(WUt(this.props,r),this.$a(nP)),m==="identified"?this.props.$user_id=d:delete this.props.$user_id,this.$a(Cde)),!0}consumeCookieIdentityChange(){const e=wde(this.ua),n=this.Yo||!!ou.Ot(e);return this.Yo=!1,n&&ou.Pt(e),n}Oa(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.Zo[hf],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}ca(e){fqo.indexOf(e.persistence.toLowerCase())===-1&&(li.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");const n=((a=[],A=!1,c=()=>!1)=>{const l=[...zR,...a];return Zt(Zt({},hc),{},{Ft(u){try{let h,d={};try{h=Ed.Ot(u)||void 0,d=h?kRe(JSON.parse(h)):{}}catch{}const m=JSON.parse(hc.Ot(u)||"{}");let p;if(A){const f=lUt(u,h),_=[...zR,...f.properties],I={};Object.keys(d).forEach(y=>{const x=d[y];yd(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 g;const y=m[ZB],x=(g=m.$user_state)!==null&&g!==void 0?g:hS;l.forEach(E=>{if(_.indexOf(E)!==-1&&!(E in d)&&(C||E!=="distinct_id"&&E!=="$user_state")){const B=m[E];(f.isValid||zR.indexOf(E)===-1||B!==!1&&B!==0)&&delete m[E]}}),!C||"$user_state"in d||"$user_state"in m||(m[g2]=hS),!C||("distinct_id"in I?I[ZB]:m[ZB])===y&&("$user_state"in I?I[g2]:m[g2])===x||(TRe.forEach(E=>delete m[E]),I.$user_state==="identified"&&"distinct_id"in I?m.$user_id=I[ZB]:delete m.$user_id,I.$user_state!=="identified"&&(delete m[HYt],delete m[nP]),delete m.__alias)}p=og(m,I)}else p=og(d,m);return c()||hc.$t(u,p),p}catch{}return null},$t(u,g,h,d,m,p){const f=hc.$t(u,g,void 0,void 0,p);try{const _=FRe(g,a);if(Object.keys(_).length){if(A){const I=bde(u),C=cUt(_,a);if(Ed.$t(I,C,h,d,m,p),Ed.Ot(I)!==JSON.stringify(C)){Ed.Pt(I,d);const y=FRe(g);return Ed.$t(u,y,h,d,m,p),f}}Ed.$t(u,_,h,d,m,p)}}catch(_){hc.Dt(_)}return f},Pt(u,g){try{jn?.localStorage.removeItem(u),Ed.Pt(u,g),Ed.Pt(bde(u),g)}catch(h){hc.Dt(h)}}})})(e.cookie_persisted_properties||[],e.cookieWinsOnConflict,()=>!!this.hi);let o,i=!1,r=!1;const s=e.persistence.toLowerCase();return s==="localstorage"&&hc.At()?(o=hc,r=!0):s==="localstorage+cookie"&&n.At()?(o=n,r=!0,i=!0):s==="sessionstorage"&&ou.At()?o=ou:s==="memory"?o=HRe:s==="cookie"&&Ed.At()?(o=Ed,i=!0):n.At()?(o=n,r=!0,i=!0):Ed.At()?(o=Ed,i=!0):o=HRe,this.Jo=r,this.Ko=i,o}fa(e){return`${this.ua}__${e}`}ha(e){return this.Jo&&!!e.split_storage}properties(){const e={};return Cl(this.props,(n,o)=>{const i=I1(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?hc.Ft(this.ua):null;let i={};if(n)try{i=kRe(Ed.Ft(this.ua)),Cl(i,(A,c)=>{(Eo(A)||yd(A)||A==="")&&delete i[c]})}catch{}const r=this.No.Ft(this.ua);if(r&&(this.props=og({},r)),this.Xo&&this.ja(),n&&r){var s,a;const A=o?.[ZB],c=(s=o?.$user_state)!==null&&s!==void 0?s:hS,l=r[ZB],u=(a=r.$user_state)!==null&&a!==void 0?a:hS;if(l!==A||u!==c){this.Yo=!0,this.hi||ou.$t(wde(this.ua),!0);const g=og({},this.props);TRe.forEach(d=>delete g[d]),u!=="anonymous"||c!=="identified"&&i.$user_state!=="anonymous"&&(Eo(A)||l===A)||(WUt(g,i),delete g[nP]),this.props=g;const h=new Set;TRe.forEach(d=>{var m;const p=(m=I1(d))===null||m===void 0?void 0:m.storageGroup;p&&h.add(p)}),h.forEach(d=>{if(this.hi)return;const m={};Cl(this.props,(p,f)=>{var _;((_=I1(f))===null||_===void 0?void 0:_.storageGroup)===d&&(m[f]=p)}),Jx(m)?(hc.Pt(this.fa(d)),this.Zo[d]={}):hc.$t(this.fa(d),m)&&(this.Zo[d]={persisted:!0,fingerprint:this.ka(m,d)})})}}ou.Ot(wde(this.ua))&&(this.Yo=!0)}ja(){for(const e of M$){const n=hc.Ft(this.fa(e));if(n&&!Jx(n)){const o=this.ma(e);o.persisted=!0,this.Ba(e)||(o.fingerprint=this.ka(n,e)),this.za(e,n)||og(this.props,n)}}}Ba(e){return Object.keys(this.props).some(n=>{var o;return((o=I1(n))===null||o===void 0?void 0:o.storageGroup)===e})}za(e,n){const o=pqo[e];if(!o)return!1;const i=n[o],r=this.props[o];return gh(i)&&gh(r)&&r>i}refreshKey(e){var n;if(this.hi||this.ra.has(e))return;const o=this.Xo?(n=I1(e))===null||n===void 0?void 0:n.storageGroup:void 0,i=o?hc.Ft(this.fa(o)):this.No.Ft(this.ua);if(i&&e in i)this.xa(e,i[e],!1);else{if(o){const r=this.No.Ft(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"||VUt.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&&li.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this.Xo)return this.Ha(),void(o&&this.oa.forEach(r=>r()));const i=this.Ua(this.No,this.ua,this.props,hf);i==="written"&&this.Pa(this.props),i!=="failed"&&(this.ea.clear(),this.na=!1,this.ra.clear()),o&&this.oa.forEach(r=>r())}Ha(){const{main:e,groups:n}=this._a(),o=this.Ua(this.No,this.ua,e,hf);o==="written"&&this.Pa(e),o!=="failed"&&(this.na=!1,this.ra.clear(),pS.forEach(r=>{var s;!((s=I1(r))===null||s===void 0)&&s.storageGroup||this.ea.delete(r)}));for(const r of M$){var i;const s=n[r];if(Jx(s)&&!(!((i=this.Zo[r])===null||i===void 0)&&i.persisted)){pS.forEach(A=>{var c;((c=I1(A))===null||c===void 0?void 0:c.storageGroup)===r&&this.ea.delete(A)});continue}const a=this.Ua(hc,this.fa(r),s,r);a!=="failed"&&pS.forEach(A=>{const c=I1(A);c?.storageGroup!==r||a!=="written"&&c.volatile||this.ea.delete(A)})}}_a(){const e={},n={flags:{},surveys:{}};return Cl(this.props,(o,i)=>{var r;const s=(r=I1(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===hf)return JSON.stringify(e)+"|"+this.Wa+"|"+this.Va+"|"+this.Ga;const o={};return Cl(e,(i,r)=>{var s;o[r]=!((s=I1(r))===null||s===void 0)&&s.volatile?"__volatile__":i}),JSON.stringify(o)}Ua(e,n,o,i){const r=this.ma(i);if(i!==hf&&!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!==hf&&(r.persisted=!0),Eo(s)||(r.fingerprint=s),this.Jo&&(r.storageValue=hc.Ot(n)),"written"):(this.Mr.debug&&li.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 M$)hc.Pt(this.fa(n));e?delete this.Zo[hf]:this.Zo={},this.Ra=void 0,this.Aa=void 0}clear(){this.remove(),this.props={}}register_once(e,n,o){if(va(e)){this.syncCookieProperties(),Eo(n)&&(n="None"),this.Wa=Eo(o)?this.Qa:o;let i=!1;if(Cl(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(va(e)){this.syncCookieProperties(),this.Wa=Eo(n)?this.Qa:n;let o=!1;if(Cl(e,(i,r)=>{e.hasOwnProperty(r)&&(this.props[r]!==i||va(i)||qr(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=qo?.URL;if(e===this.la)return;const n=HUt(this.Mr.custom_campaign_params,this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties),o=!Jx(DRe(n));return o&&this.register(n),this.la=e,o?n:void 0}update_search_keyword(){this.register((function(){const e=qo?.referrer;return e?GUt(e):{}})())}update_referrer_info(){var e;this.register_once({$referrer:UUt(),$referring_domain:qo?.referrer&&((e=mS(qo.referrer))===null||e===void 0?void 0:e.host)||vde},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const e=KUt(this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties,this.Mr.disable_capture_url_hashes);this.register_once({[EG]:this.Ko?{r:Pde(e.r),u:e.u?Pde(e.u):void 0}:e},void 0)}get_initial_props(){const e={};Cl([KYt,UYt],o=>{const i=this.props[o];i&&Cl(i,function(r,s){e["$initial_"+YNe(s)]=r})});const n=this.props[EG];if(n){const o=(function(i,r=!1){const s=zUt(i,r),a={};return Cl(s,function(A,c){a[`$initial_${YNe(c)}`]=A}),a})(n,this.Mr.disable_capture_url_hashes);og(e,o)}return e}safe_merge(e){return Cl(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,m)=>{if(d.length!==m.length)return!1;const p=[...d].sort(),f=[...m].sort();return p.every((_,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.Fa(n,c),this.Mr=e,!A&&(i||r||a)&&(this.Ra=void 0,this.Aa=void 0,this.Fa(Zt(Zt({},e),{},{cookie_persisted_properties:n.cookie_persisted_properties}),c));const l=s||a?this.ca(e):this.No;this.Za();const u=this.ha(e),g=s||u!==this.Xo,h=!A&&(g||e.cross_subdomain_cookie!==this.Va||e.secure_cookie!==this.Ga)&&this.Oa(c);this.ia=g;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),g){const d=this.props;this.clear(),this.No=l,this.Xo=u,this.props=d,this.save()}else a&&(this.No=l,A||(delete this.Zo[hf],this.Na()))}finally{this.ia=!1,h&&this.qa()}}Za(){const e=this.props[EG];if(!this.Ko||!va(e)||typeof e.r!="string")return;const n=Pde(e.r),o=typeof e.u=="string"?Pde(e.u):e.u;n===e.r&&o===e.u||this.xa(EG,Zt(Zt({},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(fRe,o),this.save()}remove_event_timer(e){const n=this.props.__timers||{},o=n[e];return Eo(o)||(delete n[e],this.xa(fRe,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),JUt(e)&&!sP(r,n)&&this.ra.add(e),this.Ma(e,r,n),!((i=I1(e))===null||i===void 0)&&i.volatile||this.Ta(e))}$a(e,n=!0){delete this.props[e],n&&(jRe(e)&&this.ga(e,!0),JUt(e)&&this.ra.add(e),this.Ta(e))}Ta(e){var n;const o=(n=I1(e))===null||n===void 0?void 0:n.storageGroup;o&&(this.ma(o).dirty=!0)}ma(e){return this.Zo[e]||(this.Zo[e]={})}};const bE={GZipJS:"gzip-js",Base64:"base64"},R$={Activation:"events",Cancellation:"cancelEvents"},$Re={Popover:"popover",API:"api",Widget:"widget"},SE={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},XRe={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},ZRe={Popover:"popover",Inline:"inline"};function Mde(t){let e=!0;return{dispose(){if(e){e=!1;const n=t();n&&pp(n.then)&&n.then(void 0,()=>{})}}}}const _qo={SHOWN:"product tour shown"},jUt={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},qUt=xd("[RateLimiter]");var Iqo=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=>{qUt.info(`${i||"events"} is quota limited.`),this.serverLimits[i]=new Date().getTime()+6e4})}catch(i){return void qUt.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=(gh(A.dropped)?A.dropped:0)+1;A.dropped=l,!this.lastEventRateLimited&&this.Ja(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!qr(n)||!n.includes(e)}Xa(){var e;if(this.Ka("$current_url")&&this.Ka("$pathname")&&tg?.pathname)return`${(e=tg.origin)!==null&&e!==void 0?e:""}${tg.pathname}`}Ja(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 aP=xd("[RemoteConfig]");var $Ut=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=Kr._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=Kr.__PosthogExtensions__)===null||n===void 0)&&n.loadExternalDependency?(o=Kr.__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 aP.info("Using preloaded remote config",this.remoteConfig),void this.el(this.remoteConfig);if(this._instance.il())return void aP.warn("Remote config is disabled. Falling back to local config.");this.Ya(e=>{if(!e)return aP.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){aP.error("Error loading remote config",e),this.el()}}el(e,n){!e&&n&&(n.statusCode===0?n.error||aP.warn("Failed to fetch remote config from PostHog."):aP.error("Failed to fetch remote config from PostHog."));try{this._instance.el(e?{ok:!0,config:e}:{ok:!1})}catch(i){aP.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){aP.error("Error loading feature flags",i)}}},E4=Uint8Array,Wx=Uint16Array,RG=Uint32Array,eTe=new E4([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]),tTe=new E4([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]),XUt=new E4([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ZUt=function(t,e){for(var n=new Wx(31),o=0;31>o;++o)n[o]=e+=1<<t[o-1];var i=new RG(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]},eKt=ZUt(eTe,2),nTe=eKt[1];eKt[0][28]=258,nTe[258]=28;for(var tKt=ZUt(tTe,0)[1],nKt=new Wx(32768),Bd=0;32768>Bd;++Bd){var TG=(43690&Bd)>>>1|(21845&Bd)<<1;nKt[Bd]=((65280&(TG=(61680&(TG=(52428&TG)>>>2|(13107&TG)<<2))>>>4|(3855&TG)<<4))>>>8|(255&TG)<<8)>>>1}var T$=function(t,e,n){for(var o=t.length,i=0,r=new Wx(e);o>i;++i)++r[t[i]-1];var s,a=new Wx(e);for(i=0;e>i;++i)a[i]=a[i-1]+r[i-1]<<1;for(s=new Wx(o),i=0;o>i;++i)s[i]=nKt[a[t[i]-1]++]>>>15-t[i];return s},WR=new E4(288);for(Bd=0;144>Bd;++Bd)WR[Bd]=8;for(Bd=144;256>Bd;++Bd)WR[Bd]=9;for(Bd=256;280>Bd;++Bd)WR[Bd]=7;for(Bd=280;288>Bd;++Bd)WR[Bd]=8;var Dde=new E4(32);for(Bd=0;32>Bd;++Bd)Dde[Bd]=5;var Cqo=T$(WR,9),yqo=T$(Dde,5),oKt=function(t){return(t/8|0)+(7&t&&1)},iKt=function(t,e,n){(n==null||n>t.length)&&(n=t.length);var o=new(t instanceof Wx?Wx:t instanceof RG?RG:E4)(n-e);return o.set(t.subarray(e,n)),o},fS=function(t,e,n){var o=e/8|0;t[o]|=n<<=7&e,t[o+1]|=n>>>8},k$=function(t,e,n){var o=e/8|0;t[o]|=n<<=7&e,t[o+1]|=n>>>8,t[o+2]|=n>>>16},oTe=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 E4(0),0];if(i==1){var s=new E4(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,u=2;for(n[0]={s:-1,f:a.f+A.f,l:a,r:A};l!=i-1;)a=n[n[u].f>n[c].f?c++:u++],A=n[c!=l&&n[u].f>n[c].f?c++:u++],n[l++]={s:-1,f:a.f+A.f,l:a,r:A};var g=r[0].s;for(o=1;i>o;++o)r[o].s>g&&(g=r[o].s);var h=new Wx(g+1),d=iTe(n[l-1],h,0);if(d>e){o=0;var m=0,p=d-e,f=1<<p;for(r.sort(function(y,x){return h[x.s]-h[y.s]||y.f-x.f});i>o;++o){var _=r[o].s;if(e>=h[_])break;m+=f-(1<<d-h[_]),h[_]=e}for(m>>>=p;m>0;){var I=r[o].s;e>h[I]?m-=1<<e-h[I]++-1:++o}for(;o>=0&&m;--o){var C=r[o].s;h[C]==e&&(--h[C],++m)}d=e}return[new E4(h),d]},iTe=function(t,e,n){return t.s==-1?Math.max(iTe(t.l,e,n+1),iTe(t.r,e,n+1)):e[t.s]=n},rKt=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new Wx(++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]},F$=function(t,e){for(var n=0,o=0;e.length>o;++o)n+=t[o]*e[o];return n},rTe=function(t,e,n){var o=n.length,i=oKt(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)},sKt=function(t,e,n,o,i,r,s,a,A,c,l){fS(e,l++,n),++i[256];for(var u=oTe(i,15),g=u[0],h=u[1],d=oTe(r,15),m=d[0],p=d[1],f=rKt(g),_=f[0],I=f[1],C=rKt(m),y=C[0],x=C[1],E=new Wx(19),B=0;_.length>B;++B)E[31&_[B]]++;for(B=0;y.length>B;++B)E[31&y[B]]++;for(var S=oTe(E,7),Q=S[0],w=S[1],M=19;M>4&&!Q[XUt[M-1]];--M);var T,R,F,O,U=c+5<<3,Y=F$(i,WR)+F$(r,Dde)+s,q=F$(i,g)+F$(r,m)+s+14+3*M+F$(E,Q)+(2*E[16]+3*E[17]+7*E[18]);if(Y>=U&&q>=U)return rTe(e,l,t.subarray(A,A+c));if(fS(e,l,1+(Y>q)),l+=2,Y>q){T=T$(g,h),R=g,F=T$(m,p),O=m;var ee=T$(Q,w);for(fS(e,l,I-257),fS(e,l+5,x-1),fS(e,l+10,M-4),l+=14,B=0;M>B;++B)fS(e,l+3*B,Q[XUt[B]]);l+=3*M;for(var W=[_,y],J=0;2>J;++J){var te=W[J];for(B=0;te.length>B;++B)fS(e,l,ee[ie=31&te[B]]),l+=Q[ie],ie>15&&(fS(e,l,te[B]>>>5&127),l+=te[B]>>>12)}}else T=Cqo,R=WR,F=yqo,O=Dde;for(B=0;a>B;++B)if(o[B]>255){var ie;k$(e,l,T[257+(ie=o[B]>>>18&31)]),l+=R[ie+257],ie>7&&(fS(e,l,o[B]>>>23&31),l+=eTe[ie]);var ne=31&o[B];k$(e,l,F[ne]),l+=O[ne],ne>3&&(k$(e,l,o[B]>>>5&8191),l+=tTe[ne])}else k$(e,l,T[o[B]]),l+=R[o[B]];return k$(e,l,T[256]),l+R[256]},xqo=new RG([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Eqo=(function(){for(var t=new RG(256),e=0;256>e;++e){for(var n=e,o=9;--o;)n=(1&n&&3988292384)^n>>>1;t[e]=n}return t})(),sTe=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8};function Bqo(t,e){e===void 0&&(e={});var n=(function(){var u=4294967295;return{p(g){for(var h=u,d=0;g.length>d;++d)h=Eqo[255&h^g[d]]^h>>>8;u=h},d(){return 4294967295^u}}})(),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(u,g,h,d,m,p){var f=u.length,_=new E4(d+f+5*(1+Math.floor(f/7e3))+m),I=_.subarray(d,_.length-m),C=0;if(!g||8>f)for(var y=0;f>=y;y+=65535){var x=y+65535;f>x?C=rTe(I,C,u.subarray(y,x)):(I[y]=p,C=rTe(I,C,u.subarray(y,f)))}else{for(var E=xqo[g-1],B=E>>>13,S=8191&E,Q=(1<<h)-1,w=new Wx(32768),M=new Wx(Q+1),T=Math.ceil(h/3),R=2*T,F=function(Ce){return(u[Ce]^u[Ce+1]<<T^u[Ce+2]<<R)&Q},O=new RG(25e3),U=new Wx(288),Y=new Wx(32),q=0,ee=0,W=(y=0,0),J=0,te=0;f>y;++y){var ie=F(y),ne=32767&y,le=M[ie];if(w[ne]=le,M[ie]=ne,y>=J){var de=f-y;if((q>7e3||W>24576)&&de>423){C=sKt(u,I,0,O,U,Y,ee,W,te,y-te,C),W=q=ee=0,te=y;for(var Ie=0;286>Ie;++Ie)U[Ie]=0;for(Ie=0;30>Ie;++Ie)Y[Ie]=0}var ce=2,fe=0,ue=S,pe=ne-le&32767;if(de>2&&ie==F(y-pe))for(var Me=Math.min(B,de)-1,Se=Math.min(32767,y),he=Math.min(258,de);Se>=pe&&--ue&&ne!=le;){if(u[y+ce]==u[y+ce-pe]){for(var Pe=0;he>Pe&&u[y+Pe]==u[y+Pe-pe];++Pe);if(Pe>ce){if(ce=Pe,fe=pe,Pe>Me)break;var we=Math.min(pe,Pe-2),Qe=0;for(Ie=0;we>Ie;++Ie){var Re=y-pe+Ie+32768&32767,De=Re-w[Re]+32768&32767;De>Qe&&(Qe=De,le=Re)}}}pe+=(ne=le)-(le=w[ne])+32768&32767}if(fe){O[W++]=268435456|nTe[ce]<<18|tKt[fe];var xe=31&nTe[ce],Te=31&tKt[fe];ee+=eTe[xe]+tTe[Te],++U[257+xe],++Y[Te],J=y+ce,++q}else O[W++]=u[y],++U[u[y]]}}C=sKt(u,I,p,O,U,Y,ee,W,te,y-te,C)}return iKt(_,0,d+oKt(C)+m)})(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(u,g){var h=g.filename;if(u[0]=31,u[1]=139,u[2]=8,u[8]=2>g.level?4:g.level==9?2:0,u[9]=3,g.mtime!=0&&sTe(u,4,Math.floor(new Date(g.mtime||Date.now())/1e3)),h){u[3]=8;for(var d=0;h.length>=d;++d)u[d+10]=h.charCodeAt(d)}})(c,e),sTe(c,l-8,n.d()),sTe(c,l-4,o),c}const bqo=!!ONe||!!g$,aKt=new WeakMap,AKt="text/plain";let aTe=0,Nde=!1;const cKt=(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}`:""}`},L$=(t,e,n=!0)=>{var o;const[i,r]=t.split("?"),s=Zt({},e),a=(o=r?.split("&").map(c=>{var l;const[u,g]=c.split("="),h=n&&(l=s[u])!==null&&l!==void 0?l:g;return delete s[u],`${u}=${h}`}))!==null&&o!==void 0?o:[],A=(function(c,l="&"){let u,g;const h=[];return Cl(c,function(d,m){Eo(d)||Eo(m)||m==="undefined"||(u=encodeURIComponent((p=>p instanceof File)(d)?d.name:d.toString()),g=encodeURIComponent(m),h[h.length]=g+"="+u)}),h.join(l)})(s);return A&&a.push(A),a.length>0?`${i}?${a.join("&")}`:i},ATe=t=>{if(t.nl)return t.nl;const{data:e,compression:n}=t;if(!e)return;if(n===bE.GZipJS){const i=Bqo((function(r){var s=r.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(r);for(var a=new E4(r.length+(r.length>>>1)),A=0,c=function(h){a[A++]=h},l=0;s>l;++l){if(A+5>a.length){var u=new E4(A+8+(s-l<<1));u.set(a),a=u}var g=r.charCodeAt(l);128>g?c(g):2048>g?(c(192|g>>>6),c(128|63&g)):g>55295&&57344>g?(c(240|(g=65536+(1047552&g)|1023&r.charCodeAt(++l))>>>18),c(128|g>>>12&63),c(128|g>>>6&63),c(128|63&g)):(c(224|g>>>12),c(128|g>>>6&63),c(128|63&g))}return iKt(a,0,A)})(PG(e)),{mtime:0});return{contentType:AKt,body:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),estimatedSize:i.byteLength}}if(n===bE.Base64){const i=(function(s){return s&&btoa(encodeURIComponent(s).replace(/%([0-9A-F]{2})/g,(a,A)=>String.fromCharCode(parseInt(A,16))))})(PG(e)),r=(s=>"data="+encodeURIComponent(typeof s=="string"?s:PG(s)))(i);return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}const o=PG(e);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}},lKt=t=>{const e=()=>t.transport==="sendBeacon"?{url:L$(t.url,{compression:bE.Base64}),encodedBody:ATe(Zt(Zt({},t),{},{compression:bE.Base64,nl:void 0}))}:{url:cKt(t.url,"compression"),encodedBody:ATe(Zt(Zt({},t),{},{compression:void 0,nl:void 0}))};let n;try{n=ATe(t)}catch(i){if(AYt(t.compression,MG(t.url,"compression")))return li.error("Failed to gzip request body, sending uncompressed payload",i),e();throw i}return n&&AYt(t.compression,MG(t.url,"compression"))&&!((o=n.body)instanceof ArrayBuffer?rRe(new Uint8Array(o)):ArrayBuffer.isView(o)&&rRe(new Uint8Array(o.buffer,o.byteOffset,o.byteLength)))?(Nde=!0,e()):{url:t.url,encodedBody:n};var o},uKt=t=>{try{return lKt(t)}catch(n){var e;return li.error(n),void((e=t.callback)===null||e===void 0||e.call(t,{statusCode:0,error:n}))}},Sqo=(function(){var t=ng(function*(e){const n=yield(function(i){return sRe.apply(this,arguments)})(PG(e.data),df.DEBUG,{rethrow:!0});if(!n)return e;const o=yield n.arrayBuffer();return Zt(Zt({},e),{},{nl:{contentType:AKt,body:o,estimatedSize:o.byteLength}})});return function(e){return t.apply(this,arguments)}})(),Qqo=/Failed to fetch|NetworkError|Load failed/i,gKt=t=>t?.name==="TypeError"&&Qqo.test(t?.message||""),dKt=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,ude):void 0})(t());return Eo(e)?void 0:Math.min(e,3e4)}catch{return}},hKt=t=>{const e=uKt(t);if(!e)return;const n=new ONe;aKt.set(n,!0);const{url:o,encodedBody:i}=e;n.open(t.method||"GET",o,!0);const{contentType:r,body:s}=i??{};Cl(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,dKt(()=>n.getResponseHeader("Retry-After")))}},n.send(s)},mKt=t=>{const e=uKt(t);if(!e)return;const{url:n,encodedBody:o}=e,{contentType:i,body:r,estimatedSize:s}=o??{},a=new Headers;Cl(t.headers,function(d,m){a.append(m,d)}),i&&a.append("Content-Type",i);let A=null,c=!1;if(rGt){const d=new rGt;A={signal:d.signal,timeout:setTimeout(()=>{c=!0;try{d.abort(VGt("AbortError","PostHog request timed out"+((m=t.timeout)?` after ${m}ms`:"")))}catch(p){u(p)}var m},t.timeout)}}let l=!1;const u=d=>{var m;l||(l=!0,c&&d?.name==="AbortError"||gKt(d)?li.warn(d):li.error(d),(m=t.callback)===null||m===void 0||m.call(t,{statusCode:0,error:d}))};let g=0;const h=()=>{aTe-=g,g=0,A&&clearTimeout(A.timeout)};try{const d=Zt({method:t?.method||"GET",headers:a,referrerPolicy:"strict-origin",body:r,signal:A?.signal},t.fetchOptions),m=s??(Eo(r)?0:void 0);d.keepalive=d.method==="POST"&&!t.sl&&d.keepalive!==!1&&d.body===r&&!Eo(m)&&m>=0&&52428.8>aTe+m,d.keepalive&&(g=m,aTe+=g),g$(n,d).then(p=>p.text().then(f=>{var _;if(l)return;const I={statusCode:p.status,text:f};if(p.status===200)try{I.json=JSON.parse(f)}catch(C){li.error(C)}l=!0,h(),(_=t.callback)===null||_===void 0||_.call(t,I,dKt(()=>p.headers.get("Retry-After")))})).catch(p=>{h(),u(p)}).finally(h)}catch(d){h(),u(d)}},cTe=t=>{try{var e;const{url:n,encodedBody:o}=lKt(t),{contentType:i,body:r,estimatedSize:s}=o??{};if(!r)return;const a=r instanceof Blob?r:new Blob([r],{type:i});if(I_.sendBeacon(n,a))return;const A=qr(t.data)?t.data:(e=t.data)===null||e===void 0?void 0:e.batch;if(qr(A)&&A.length>1&&(s??0)>16384){const c=Math.ceil(A.length/2),l=u=>qr(t.data)?u:Zt(Zt({},t.data),{},{batch:u});return cTe(Zt(Zt({},t),{},{data:l(A.slice(0,c))})),void cTe(Zt(Zt({},t),{},{data:l(A.slice(c))}))}li.warn(`Beacon of ~${s??0} bytes was rejected by the browser, falling back to ${g$?"fetch":"XHR"}`),g$?mKt(Zt(Zt({},t),{},{sl:!0})):hKt(t)}catch(n){li.warn("Beacon send failed",n)}},pKt=(t,e,n,o)=>{const i=o==="query"?e==="POST"?"sent_at":"_":void 0;return L$(n===bE.GZipJS?cKt(t,"compression"):t,Zt(Zt({},i?{[i]:Date.now().toString()}:{}),n===bE.GZipJS?{}:{compression:n}))},vqo=(()=>{const t=[];return g$&&t.push({transport:"fetch",method:mKt}),ONe&&t.push({transport:"XHR",method:hKt}),I_?.sendBeacon&&t.push({transport:"sendBeacon",method:cTe}),t})();let fKt=!bqo&&l2?.indexOf("MSIE")===-1&&l2?.indexOf("Mozilla")===-1;function _Kt(t,e,n){var o,i,r;n&&(e=Zt(Zt({},e),{},{callback:s=>n(s)})),t.__loaded?fKt?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=Zt(Zt({},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 u=Zt(Zt({},s),{},{callback:a??(p=>{var f;return(f=s.callback)===null||f===void 0?void 0:f.call(s,p)})});u.timeout=u.timeout||6e4;const g=(A=u.transport)!==null&&A!==void 0?A:"fetch";g==="sendBeacon"&&Eo(u.compression)&&u.data&&(u.compression=bE.Base64),u.method==="POST"&&u.data&&(u.timestampMode==="capture-body"?u.data=(p=>{var f,_;const I=(qr(p)?p:[p]).map(y=>Zt(Zt({},y),y.timestamp instanceof Date&&!isNaN(y.timestamp.getTime())?{timestamp:y.timestamp.toISOString()}:{})),C=I[0];return{api_key:(f=C==null||(_=C.properties)===null||_===void 0?void 0:_.token)!==null&&f!==void 0?f:C?.token,batch:I,sent_at:new Date().toISOString()}})(u.data):u.timestampMode==="body"&&(u.data=((p,f=new Date().toISOString())=>qr(p)?p.map(_=>Zt(Zt({},_),{},{sent_at:f})):Zt(Zt({},p),{},{sent_at:f}))(u.data))),u.url=pKt(u.url,u.method,u.compression,u.timestampMode);const h=vqo.filter(p=>!u.disableTransport||!p.transport||!u.disableTransport.includes(p.transport)),d=(c=(l=(function(p,f){for(let _=0;p.length>_;_++)if(f(p[_]))return p[_]})(h,p=>p.transport===g))===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 m=p=>{try{d(p)}catch(_){var f;gKt(_)?li.warn(_):li.error(_),(f=u.callback)===null||f===void 0||f.call(u,{statusCode:0,error:_})}};g!=="sendBeacon"&&!u.preferSyncCompression&&u.data&&u.compression===bE.GZipJS&&KJo&&typeof Promise<"u"&&!Nde?Sqo(u).then(p=>{m(p)}).catch(p=>{if(cYt(p))return Nde=!0,void m(Zt(Zt({},u),{},{compression:void 0,url:pKt(s.url,s.method,void 0,s.timestampMode)}));(f=>{if(!f||typeof f!="object")return!1;const _="name"in f?String(f.name):"";return cYt(f)||_===aYt})(p)&&(Nde=!0),m(u)}):m(u)})(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 wqo=class{constructor(t,e){this.rl=!0,this.ol=[],this.al=N7(e?.flush_interval_ms||3e3,250,5e3,li.createLogger("flush interval"),3e3),this.ll=t}enqueue(t){this.ol.push(t),this.ul||this.cl()}unload(){this.hl();const t=this.ol.length>0?this.dl():{},e=Object.values(t);[...e.filter(n=>n.url.indexOf("/e")===0),...e.filter(n=>n.url.indexOf("/e")!==0)].map(n=>{this.vl(Zt(Zt({},n),{},{callback:void 0}),"sendBeacon")})}enable(){this.rl=!1,this.cl()}cl(){this.rl||(this.ul=setTimeout(()=>{this.hl(),this.fl()},this.al))}fl(){if(this.ol.length>0){const t=this.dl();for(const e in t)this.vl(t[e])}}vl(t,e){try{this.ll(t,e)}catch(n){li.error(n)}}hl(){clearTimeout(this.ul),this.ul=void 0}dl(){const t={},e={};Cl(this.ol,n=>{var o;const i=n,r=((i?i.batchKey:null)||i.url)+(i.batchGroup?`:${i.batchGroup}`:"");Eo(t[r])&&(t[r]=Zt(Zt({},i),{},{data:[],callback:void 0,fireCallbackOnDrop:void 0}),e[r]=[]),(o=t[r].data)===null||o===void 0||o.push(i.data),i.callback&&e[r].push(i.callback)});for(const n in e){const o=e[n];o.length&&(t[n].callback=i=>{for(const r of o)r(i)})}return this.ol=[],t}};const Pqo=["retriesPerformedSoFar"];var Mqo=class{constructor(t){this._instance=t,this.pl=!1,this.gl=3e3,this.ol=[],this.ol=[],this.ml=!0,this.resume()}resume(){if(!Eo(jn)&&"onLine"in jn.navigator){if(this.ml=jn.navigator.onLine,this.yl)return;this.yl=()=>{this.ml=!0,this.fl()},this.bl=()=>{this.ml=!1},Zc(jn,"online",this.yl),Zc(jn,"offline",this.bl)}}get length(){return this.ol.length}retriableRequest(t,e){let{retriesPerformedSoFar:n}=t,o=uYt(t,Pqo);gS(n)&&(o.url=L$(o.url,{retry_count:n})),_Kt(this._instance,e?Zt(Zt({},o),{},{transport:e}):o,(i,r)=>{var s;if(i.statusCode!==200&&(400>i.statusCode||i.statusCode>=500)){if((i.statusCode===0?3:10)>(n??0))return void this.Ls(Zt({retriesPerformedSoFar:n},o),r);i.statusCode===0&&li.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after ${n??0} retries.`)}(s=o.callback)===null||s===void 0||s.call(o,i)})}Ls(t,e){const n=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=n+1;const o=Math.max((function(s){const a=3e3*Math.pow(2,s),A=a/2,c=Math.min(18e5,a),l=(Math.random()-.5)*(c-A);return Math.ceil(c+l)})(n),e??0),i=Date.now()+o;this.ol.push({retryAt:i,requestOptions:t});let r=`Enqueued failed request for retry in ${o}`;navigator.onLine||(r+=" (Browser is offline)"),li.warn(r),this.pl||(this.pl=!0,this._l())}_l(){if(this.wl&&clearTimeout(this.wl),this.ol.length===0)return this.pl=!1,void(this.wl=void 0);this.wl=setTimeout(()=>{this.ml&&this.ol.length>0&&this.fl(),this._l()},this.gl)}fl(){const t=Date.now(),e=[],n=this.ol.filter(o=>t>o.retryAt||(e.push(o),!1));if(this.ol=e,n.length>0)for(const{requestOptions:o}of n)this.retriableRequest(o)}unload(){this.wl&&(clearTimeout(this.wl),this.wl=void 0),this.pl=!1,Eo(jn)||(this.yl&&(jn.removeEventListener("online",this.yl),this.yl=void 0),this.bl&&(jn.removeEventListener("offline",this.bl),this.bl=void 0));for(const{requestOptions:t}of this.ol)try{this._instance._send_request(Zt(Zt({},t),{},{callback:qr(t.data)?void 0:t.callback,transport:"sendBeacon"}))}catch(e){li.error(e)}this.ol=[]}},Dqo=class{constructor(t){this._instance=t,this.kl=()=>{var e,n,o,i;this.Sl||(this.Sl={});const r=this.scrollElement(),s=this.scrollY(),a=r?Math.max(0,r.scrollHeight-r.clientHeight):0,A=s+(r?.clientHeight||0),c=r?.scrollHeight||0;this.Sl.lastScrollY=Math.ceil(s),this.Sl.maxScrollY=Math.max(s,(e=this.Sl.maxScrollY)!==null&&e!==void 0?e:0),this.Sl.maxScrollHeight=Math.max(a,(n=this.Sl.maxScrollHeight)!==null&&n!==void 0?n:0),this.Sl.lastContentY=A,this.Sl.maxContentY=Math.max(A,(o=this.Sl.maxContentY)!==null&&o!==void 0?o:0),this.Sl.maxContentHeight=Math.max(c,(i=this.Sl.maxContentHeight)!==null&&i!==void 0?i:0)}}get xl(){return this._instance.config.scroll_root_selector}getContext(){return this.Sl}resetContext(){const t=this.Sl;return this.Sl=void 0,setTimeout(this.kl,0),t}startMeasuringScrollPosition(){Zc(jn,"scroll",this.kl,{capture:!0}),Zc(jn,"scrollend",this.kl,{capture:!0}),Zc(jn,"resize",this.kl)}scrollElement(){if(this.xl){const n=qr(this.xl)?this.xl:[this.xl];for(const o of n){var t;const i=jn==null||(t=jn.document)===null||t===void 0?void 0:t.querySelector(o);if(i)return i}return}var e;return jn==null||(e=jn.document)===null||e===void 0?void 0:e.documentElement}$l(t){var e,n;const o=t==="y"?"scrollTop":"scrollLeft";if(this.xl){const i=this.scrollElement();return i&&i[o]||0}return jn?t==="y"?jn.scrollY||jn.pageYOffset||((e=jn.document)===null||e===void 0||(e=e.documentElement)===null||e===void 0?void 0:e.scrollTop)||0:jn.scrollX||jn.pageXOffset||((n=jn.document)===null||n===void 0||(n=n.documentElement)===null||n===void 0?void 0:n.scrollLeft)||0:0}scrollY(){return this.$l("y")}scrollX(){return this.$l("x")}};const Nqo=t=>KUt(t?.config.mask_personal_data_properties,t?.config.custom_personal_data_properties,t?.config.disable_capture_url_hashes);var IKt=class{constructor(t,e,n,o){this.qe=i=>{const r=this.Cl();if(r&&r.sessionId===i)return;const s={sessionId:i,props:this.Tl(this._instance)};this.Il.register({[bRe]:s})},this._instance=t,this.Ml=e,this.Il=n,this.Tl=o||Nqo,this.Ml.onSessionId(this.qe)}Cl(){return this.Il.props[bRe]}getSetOnceProps(){var t;const e=(t=this.Cl())===null||t===void 0?void 0:t.props;return e?"r"in e?zUt(e,this._instance.config.disable_capture_url_hashes):{$referring_domain:e.referringDomain,$pathname:e.initialPathName,utm_source:e.utm_source,utm_campaign:e.utm_campaign,utm_medium:e.utm_medium,utm_content:e.utm_content,utm_term:e.utm_term}:{}}getSessionProps(){const t={};return Cl(DRe(this.getSetOnceProps()),(e,n)=>{n==="$current_url"&&(n="url"),t[`$session_entry_${YNe(n)}`]=e}),t}},Rde=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 kG=xd("[SessionId]"),CKt=864e5;var yKt=class{on(t,e){return this.Pl.on(t,e)}constructor(t,e,n){var o;if(this.Rl=null,this.Al=null,this.Fl=[],this.Ol=void 0,this.Dl=!1,this.Pl=new Rde,this.Ll=(r,s)=>!(!gS(r)||!gS(s))&&Math.abs(r-s)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(t.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Mr=t.config,this.Il=t.persistence,this.je=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.Nl=void 0,this._sessionActivityTimestamp=null,this.ql=e||e9,this.jl=n||e9;const i=this.Mr.persistence_name||this.Mr.token;if(this._sessionTimeoutMs=1e3*N7(this.Mr.session_idle_timeout_seconds||1800,60,36e3,kG.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Bl(),this.zl="ph_"+i+"_window_id",this.Hl="ph_"+i+"_primary_window_exists",this.Ul()){const r=ou.Ft(this.zl),s=ou.Ft(this.Hl);r&&!s?this.je=r:ou.Pt(this.zl),ou.$t(this.Hl,!0)}!((o=this.Mr.bootstrap)===null||o===void 0)&&o.sessionID&&this.setBootstrapSessionId(this.Mr.bootstrap.sessionID),this.Wl()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return Eo(this.Fl)&&(this.Fl=[]),this.Fl.push(t),this.Xt&&t(this.Xt,this.je),()=>{this.Fl=this.Fl.filter(e=>e!==t)}}Ul(){return this.Mr.persistence!=="memory"&&!this.Il.hi&&ou.At()}Vl(t){t!==this.je&&(this.je=t,this.Ul()&&ou.$t(this.zl,t))}Gl(){return this.je?this.je:this.Ul()?ou.Ft(this.zl):null}Ql(t){const e=this.Rl;return!yd(e)&&!yd(t)&&5e3>Math.abs(t-e)}Zl(t,e,n){const o=e!==this._sessionActivityTimestamp,i=!(t!==this.Xt||n!==this._sessionStartTimestamp);this._sessionStartTimestamp=n,this._sessionActivityTimestamp=e,this.Xt=t,i&&!o||i&&this.Ql(e)||(this.Rl=e,this.Il.register({[xG]:[e,t,n]}))}Jl(){var t;const e=(t=this.Mr)===null||t===void 0?void 0:t.persistence_save_debounce_ms;return gS(e)&&e>0}Kl(){this.Jl()?this.Il.refreshKey(xG):(this.Il.flush(),this.Il.load())}Xl(){var t;if(yd(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this.Rl)return;this.Kl();const[,e,n]=this.Yl();e===this.Xt&&n===this._sessionStartTimestamp&&(this.Rl=this._sessionActivityTimestamp,this.Il.register({[xG]:[this._sessionActivityTimestamp,(t=this.Xt)!==null&&t!==void 0?t:null,this._sessionStartTimestamp]}),this.Il.flush())}tu(){const[t]=this.Yl(),e=gS(t)?t:0,n=gS(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(e,n)}eu(t){return this.Kl(),this.Ll(t,this.tu())}Yl(){const t=this.Il.props[xG];return qr(t)&&t.length===2&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.Rl=null,this.Nl=void 0,clearTimeout(this.iu),this.iu=void 0,this.Zl(null,null,null)}setBootstrapSessionId(t,e=!1){const n=((o,i=new Date().getTime())=>{try{const r=(s=>{const a=s.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)})(o);return r>i+6e4?void kG.error("Bootstrap sessionID cannot be in the future"):r}catch(r){return void kG.error("Invalid sessionID in bootstrap",r)}})(t);return!Eo(n)&&(e?this.Nl={sessionId:t,sessionStartTimestamp:n}:this.Zl(t,new Date().getTime(),n),!0)}destroy(){this.Dl=!0,this.Xl(),clearTimeout(this.iu),this.iu=void 0,this.Ol&&jn&&(jn.removeEventListener(Ede,this.Ol,{capture:!1}),this.Ol=void 0),this.Fl=[]}Wl(){this.Ol=()=>{this.Xl(),this.Ul()&&ou.Pt(this.Hl)},Zc(jn,Ede,this.Ol,{capture:!1})}checkAndGetSessionAndWindowId(t=!1,e=null,n=!1){if(this.Mr.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');const o=e||new Date().getTime(),i=this.Xt;if(n)this.Al=o;else if(yd(this.Al)||this.Al>o||o-this.Al>=1e3){var r,s;(r=(s=this.Il).syncCookieProperties)===null||r===void 0||r.call(s),this.Al=o}let[,a,A]=this.Yl();const c=!Eo(i)&&a!==i,l=this.tu();let u=this.Gl();const g=this.Nl,h=!!g&&(g.sessionStartTimestamp>o+6e4||o-g.sessionStartTimestamp>CKt),d=g?h:gS(A)&&Math.abs(o-A)>CKt;let m=!1,p=c,f=!a||!!g;const _=a;let I=!f&&!t&&this.Ll(o,l);if(I&&(I=this.eu(o),I||kG.info("cross-tab refresh kept the session alive",{sessionId:a}),[,a,A]=this.Yl(),I||(f=!a||!!g)),f||I||d){p=!1;const E=g&&!h;a=E?g.sessionId:this.ql(),u=this.jl(),kG.info("new session ID assigned",{sessionId:a,windowId:u,bootstrapped:!!E,changeReason:{noSessionId:f,activityTimeout:I,sessionPastMaximumLength:d}}),A=E?g.sessionStartTimestamp:o,this.Nl=void 0,m=!0}else u||(u=this.jl(),m=!0),p=p||a!==_,p&&(kG.info("adopted cross-tab session id",{sessionId:a,windowId:u}),m=!0);const C=gS(l)&&t&&!d?l:o,y=gS(A)?A:new Date().getTime();this.Vl(u),this.Zl(a,C,y),t||this.Bl();const x={noSessionId:f,activityTimeout:I,sessionPastMaximumLength:d,crossTabAdoption:p};return m&&this.Fl.forEach(E=>E(a,u,x)),{sessionId:a,windowId:u,sessionStartTimestamp:y,changeReason:m?x:void 0,lastActivityTimestamp:l}}Bl(){this.Dl||(clearTimeout(this.iu),this.iu=setTimeout(()=>{if(!this.Dl)if(this.eu(new Date().getTime())){const t=this.Xt;this.resetSessionId(),this.Pl.emit("forcedIdleReset",{idleSessionId:t})}else this.Bl()},1.1*this.sessionTimeoutMs))}};const xKt=function(t,e){if(!t)return!1;const n=t.userAgent;if(n&&uGt(n,e))return!0;try{const o=t?.userAgentData;if(o?.brands&&o.brands.some(i=>uGt(i?.brand,e)))return!0}catch{}return!!t.webdriver};function EKt(){return(EKt=ng(function*(){const t=I_?.userAgentData;if(t?.getHighEntropyValues)try{const e=yield t.getHighEntropyValues(["model"]),n=e?.model;return Za(n)&&n.length>0?n:void 0}catch(e){return void li.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}})).apply(this,arguments)}function Rqo(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 BKt(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 Tde=(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}},kde=t=>t.toLowerCase(),bKt={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=>Tde(n,o))),not_regex:(t,e)=>e.every(n=>t.every(o=>!Tde(n,o))),icontains:(t,e)=>e.map(kde).some(n=>t.map(kde).some(o=>n.includes(o))),not_icontains:(t,e)=>e.map(kde).every(n=>t.map(kde).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 SKt(t,e){return!t||Object.entries(t).every(([n,o])=>{const i=e?.[n];if(i==null)return!1;const r=bKt[o.operator];return!!r&&r(o.values.map(String),[String(i)])})}function lTe(t,e,n){return PG({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:n})}const uTe="custom",QKt="i.posthog.com",Tqo=/^\/static\//,kqo=["/s/","/e/","/i/"];var Fqo=class{constructor(t){this.nu={},this.instance=t}get apiHost(){const t=this.instance.config.api_host.trim().replace(/\/$/,"");return t==="https://app.posthog.com"?"https://us.i.posthog.com":t}get flagsApiHost(){const t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t;let e=(t=this.instance.config.ui_host)===null||t===void 0?void 0:t.replace(/\/$/,"");return e||(e=this.apiHost.replace(`.${QKt}`,".posthog.com")),e==="https://app.posthog.com"?"https://us.posthog.com":e}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":uTe),this.nu[this.apiHost]}su(t){if(!Tqo.test(t))return;const e=this.instance.config.asset_host;return typeof e=="string"&&e.trim().replace(/\/$/,"")||void 0}ru(t){const e=mS(t);return e?e.protocol+"//"+e.host+e.pathname:void 0}ou(t,e,n){if(t==="ui")return n;let o=n;const i=this.instance.config.rewriteRequestPath;if(i){var r;const s=((r=mS(n))===null||r===void 0?void 0:r.href)||n;o=i(new URL(s)).toString()}if(i&&t==="api"&&kqo.some(s=>e.indexOf(s)===0)){const s=this.ru(o);if(s){const a=this.apiHost;let A=this.au;A?.apiHost===a&&A.rewriteRequestPath===i||(A={apiHost:a,rewriteRequestPath:i,urls:new Set},this.au=A),A.urls.add(s)}}return o}isIngestionEndpoint(t){const e=this.au,n=this.ru(t);return e?.apiHost===this.apiHost&&e.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!n&&e.urls.has(n)}endpointFor(t,e=""){if(e&&(e=e[0]==="/"?e:`/${e}`),t==="ui")return this.ou(t,e,this.uiHost+e);if(t==="flags")return this.ou(t,e,this.flagsApiHost+e);if(t==="assets"){const o=this.su(e);if(o)return this.ou(t,e,`${o}${e}`)}if(this.region===uTe)return this.ou(t,e,this.apiHost+e);const n=QKt+e;switch(t){case"assets":return this.ou(t,e,`https://${this.region}-assets.${n}`);case"api":return this.ou(t,e,`https://${this.region}.${n}`)}}};const yl=xd("[Surveys]"),vKt=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){yl.error("Failed to persist survey seen state",e)}},Lqo=[$Re.Popover,$Re.Widget,$Re.API],Hqo={ignoreConditions:!1,ignoreDelay:!1,displayType:ZRe.Popover},Oqo=xd("[PostHog ExternalIntegrations]"),Gqo={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var Yqo=class{constructor(t){this._instance=t}zo(t,e){var n,o;(n=Kr.__PosthogExtensions__)===null||n===void 0||(o=n.loadExternalDependency)===null||o===void 0||o.call(n,this._instance,t,i=>{if(i)return Oqo.error("failed to load script",i);e()})}startIfEnabledOrStop(){var t;for(const[i,r]of Object.entries((t=this._instance.config.integrations)!==null&&t!==void 0?t:{})){var e,n,o;r&&!(!((e=Kr.__PosthogExtensions__)===null||e===void 0||(e=e.integrations)===null||e===void 0)&&e[i])&&this.zo(Gqo[i],()=>{var s;(s=Kr.__PosthogExtensions__)===null||s===void 0||(s=s.integrations)===null||s===void 0||(s=s[i])===null||s===void 0||s.start(this._instance)}),!r&&(!((n=Kr.__PosthogExtensions__)===null||n===void 0||(n=n.integrations)===null||n===void 0)&&n[i])&&((o=Kr.__PosthogExtensions__)===null||o===void 0||(o=o.integrations)===null||o===void 0||(o=o[i])===null||o===void 0||o.stop())}}},Uqo=class{constructor(t,e){this.A=t,this.bo=e,this.lu=new Map,this.To=!1}add(t){var e=this;return ng(function*(){if(e.To)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(e.lu.has(t.name))throw new Error(`Browser extension "${t.name}" is already registered`);e.lu.set(t.name,t);try{const n=t.setup(e.bo);n&&(yield n)}catch(n){const o=e.lu.get(t.name)===t;o&&e.lu.delete(t.name),e.A.error(`Failed to set up browser extension "${t.name}"`,n),o&&e.uu(t)}})()}getExtension(t){return this.lu.get(t)}dispose(){if(this.To)return;this.To=!0;const t=Array.from(this.lu.values()).reverse();this.lu.clear();for(const e of t)this.uu(e)}uu(t){try{var e;const n=(e=t.dispose)===null||e===void 0?void 0:e.call(t);n&&pp(n.then)&&n.then(void 0,o=>{this.A.error(`Failed to dispose browser extension "${t.name}"`,o)})}catch(n){this.A.error(`Failed to dispose browser extension "${t.name}"`,n)}}},Kqo=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 wKt="extensionsRemoteConfig";var zqo=class{constructor(e){this.instance=e,this.To=!1,this.A=li,this.cu=e.hu,this.kv=new Kqo(e),this.onEvent=n=>Mde(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 Mde(()=>{});const o=r=>{try{n(r)}catch(s){this.A.error("Browser extension remote config listener failed",s)}},i=this.instance.du.on(wKt,o);return this.cu&&o(this.cu),Mde(i)},this.vu=new Uqo(li.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(mRe);return typeof e=="string"?e:void 0}get library(){return{name:df.LIB_NAME,version:df.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 Mde(this.instance.fu(e))}handleRemoteConfig(e){this.To||(this.cu=e,this.instance.du.emit(wKt,e))}sendRequest(e){var n=this;return ng(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?L$(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"?GNe.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 H$={};let gTe=0;const O$=()=>{},PKt='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',FG="Surveys module not available",MKt="sanitize_properties is deprecated. Use before_send instead",DKt="Invalid value for property_denylist config: ",Vqo=["$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"],Jqo=["$feature_flag_called","$$heatmap","$snapshot"],NKt=t=>t.charAt(0)==="$"&&!jr(Jqo,t),Wqo=/^[A-Za-z0-9_-]{1,400}$/,RKt=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,TKt=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,jqo=["token","distinct_id",zYt],G$="posthog",qqo=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},dTe=t=>{var e;return Zt({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:zjo(qo?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:O$,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_replay_sync_fetch:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:tg&&Za(tg?.search)&&tg.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:(jn==null||(e=jn.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){li.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:tUt,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:O$},(n=>({rageclick:n&&n>="2026-05-30"?{content_ignorelist:VRe,ignore_text_selection:!0}:!n||"2025-11-30">n||{content_ignorelist:!0},capture_pageview:!n||"2025-05-24">n||"history_change",session_recording:qqo(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))},$qo=[["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"]],kKt=t=>{const e={};for(const[i,r]of $qo)Eo(t[i])||(e[r]=t[i]);const n=og({},e,t),o=t.__preview_external_dependency_versioned_paths;return Eo(o)||(Eo(t.strict_script_versioning)&&(n.strict_script_versioning=!!o),Za(o)&&Eo(t.asset_host)&&(n.asset_host=o)),qr(t.property_blacklist)&&(Eo(t.property_denylist)?n.property_denylist=t.property_blacklist:qr(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:li.error(DKt+t.property_denylist)),n};var Xqo=class{constructor(){this.__forceAllowLocalhost=!1}get pu(){return this.__forceAllowLocalhost}set pu(e){li.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Y$=class gD{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(e9());this.register({distinct_id:o,$device_id:o}),e.set_property(g2,hS)}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 Xqo,this.Mu=!1,this.version=df.LIB_VERSION,this.Eu=new Set,this.Pu="",this.du=new Rde,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=dTe(),this.SentryIntegration=cqo,this.sentryIntegration=o=>(function(i,r){const s=NUt(i,r);return{name:DUt,processEvent:a=>s(a)}})(this,o),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Fu=!1,this.Ou=null,this.Du=null,this.Lu=null,this.scrollManager=new Dqo(this),this.pageViewManager=new RUt(this),this.rateLimiter=new Iqo(this),this.requestRouter=new Fqo(this),this.consent=new Xjo(this),this.externalIntegrations=new Yqo(this);const n=(e=gD.__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=Za(o)?{[o]:i}:o;this.setPersonProperties(s),r?.({})},set_once:(o,i,r)=>{const s=Za(o)?{[o]:i}:o;this.setPersonProperties(void 0,s),r?.({})}},this.on("eventCaptured",o=>li.info(`send "${o?.event}"`,o))}init(e,n,o){if(o&&o!==G$){var i;const r=(i=H$[o])!==null&&i!==void 0?i:new gD;return r._init(e,n,o),H$[o]=r,H$[G$][o]=r,r}return this._init(e,n,o)}_init(e,n={},o){var i,r,s;const a=Za(e)?e.trim():"";if(!a)return li.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=dTe(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=dTe(n.defaults),l=kKt(n),u=og({},c,l,{name:o,token:a});va(c.rageclick)&&va(l.rageclick)&&(u.rageclick=og({},c.rageclick,l.rageclick)),va(c.session_recording)&&va(l.session_recording)&&(u.session_recording=og({},c.session_recording,l.session_recording)),this.set_config(u),this.config.on_xhr_error&&li.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:bE.GZipJS;const g=this.Cu(),h=!this.yu();if(this.persistence=new qRe(this.config,g,!0,h),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new qRe(Zt(Zt({},this.config),{},{persistence:"sessionStorage"}),g,!1,h),this.Pu="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!g&&ou.At()){const _=ou.Ft(this.Pu);qr(_)&&_.forEach(I=>{Za(I)&&this.Eu.add(I)})}else ou.Pt(this.Pu);const d=Zt({},this.persistence.props),m=Zt({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Bu=new wqo((_,I)=>this.zu(_,I),this.config.request_queue_config),this.Hu=new Mqo(this),this.__request_queue=[];const p=this.yu();p||(this.sessionManager=new yKt(this),this.sessionPropsManager=new IKt(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((_,I,C)=>{(C?.activityTimeout||C?.sessionPastMaximumLength||C?.crossTabAdoption)&&this.Uu()})),this.Wu(),this.config.__preview_deferred_init_extensions?(li.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.Vu(p)},0)):(li.info("Initializing extensions synchronously"),this.Vu(p)),df.DEBUG=df.DEBUG||this.config.debug,df.DEBUG&&li.info("Starting in debug mode",{this:this,config:n,thisC:Zt({},this.config),p:d,s:m}),this.config.identity_distinct_id&&!(!((i=n.bootstrap)===null||i===void 0)&&i.distinctID)&&(n.bootstrap=Zt(Zt({},n.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const f=(r=n.bootstrap)===null||r===void 0?void 0:r.distinctID;if(this.wu=!!f&&!h$(f),(s=n.bootstrap)===null||s===void 0?void 0:s.distinctID){const _=n.bootstrap.distinctID,I=this.get_distinct_id(),C=this.persistence.get_property(g2);if(n.bootstrap.isIdentifiedID&&I!=null&&I!==_&&C==="anonymous")this.identify(_);else if(n.bootstrap.isIdentifiedID&&I!=null&&I!==_&&C==="identified")li.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(e9()),x=n.bootstrap.isIdentifiedID?y:_;this.persistence.set_property(g2,n.bootstrap.isIdentifiedID?xde:hS),this.register({distinct_id:_,$device_id:x})}}if(p)this.register_once({distinct_id:QRe,$device_id:null},"");else if(!this.get_distinct_id()){const _=this.config.get_device_id(e9());this.register_once({distinct_id:_,$device_id:_},""),this.persistence.set_property(g2,hS)}return Zc(jn,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),Zc(jn,"pageshow",()=>{var _;this.Tu=!1,this.Iu||(_=this.Hu)===null||_===void 0||_.resume()}),n.segment?MUt(this,()=>this.Gu()):this.Gu(),pp(this.config._onCapture)&&this.config._onCapture!==O$&&(li.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",_=>this.config._onCapture(_.event,_))),this.config.ip&&li.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 EKt.apply(this,arguments)})().then(_=>{_&&this.register({[pRe]:_})}).catch(O$),this}Qu(e){const n=e;return Za(n.name)&&pp(n.setup)}Zu(e,n){this.Qu(e)?n.push(()=>{this.Ju().add(e).catch(()=>{var o;return(o=e.dispose)===null||o===void 0?void 0:o.call(e)}).catch(o=>{li.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=gD.__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)),pp(this.featureFlags.onReloading)&&pp(this.featureFlags.setup)?this.Ku||(this.Ku=this.featureFlags.onReloading(()=>{this.du.emit("featureFlagsReloading",!0)}),this.Ju().add(this.featureFlags)):(s=(a=this.featureFlags).initialize)===null||s===void 0||s.call(a))}Vu(e){const n=performance.now(),o=Zt(Zt({},gD.__defaultExtensionClasses),this.config.__extensionClasses),i=[];var r,s,a,A,c,l,u,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.Zu(this.autocapture=new o.autocapture(this),i),o.surveys&&this.Zu(this.surveys=(s=this.surveys)!==null&&s!==void 0?s:new o.surveys(this),i),o.logs&&this.Zu(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,Aqo)),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=(u=this.experiments)!==null&&u!==void 0?u:new o.experiments(this)),o.webMCP&&this.lu.push(this.webMCP=(g=this.webMCP)!==null&&g!==void 0?g:new o.webMCP(this)),this.lu.forEach(h=>{h.initialize&&i.push(()=>{var d;(d=h.initialize)===null||d===void 0||d.call(h)})}),i.push(()=>{if(this.Xu){const h=this.Xu;this.Xu=void 0,this.lu.forEach(d=>{var m;return(m=d.onRemoteConfig)===null||m===void 0?void 0:m.call(d,h)})}}),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){li.error("Error initializing extension:",r)}}const o=Math.round(performance.now()-n);this.register_for_session({[VYt]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[JYt]:o}),this.config.__preview_deferred_init_extensions&&li.info(`PostHog extensions initialized (${o}ms)`)}el(e){var n;if(!qo||!qo.body)return li.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.hu=e,this.compression=void 0,e.ok){var o;const i=e.config;i.supportedCompression&&!this.config.disable_compression&&(this.compression=jr(i.supportedCompression,bE.GZipJS)?bE.GZipJS:jr(i.supportedCompression,bE.Base64)?bE.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:tUt}),(n=this.tc)===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){li.critical("`loaded` function failed",e)}if(this.ec(),this.config.internal_or_test_user_hostname&&tg?.hostname){const e=tg.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.nc()},1),this.sc=new $Ut(this),this.sc.load()}ec(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Bu)===null||e===void 0||e.enable())}_dom_loaded(){this.is_capturing()&&BG(this.__request_queue,e=>this.zu(e)),this.__request_queue=[],this.ec()}_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.rc()&&this.capture(nUt),(i=this.logs)===null||i===void 0||i.flushLogs("sendBeacon"),(r=this.Bu)===null||r===void 0||r.unload(),(s=this.Hu)===null||s===void 0||s.unload()):this.rc()&&this.capture(nUt,null,{transport:"sendBeacon"})}_send_request(e){_Kt(this,e)}zu(e,n){this.Hu?this.Hu.retriableRequest(e,n):this._send_request(n?Zt(Zt({},e),{},{transport:n}):e)}_execute_array(e){gTe++;try{let n;const o=[],i=[],r=[];BG(e,a=>{if(a)if(n=a[0],qr(n))r.push(a);else if(pp(a))try{a.call(this)}catch(A){li.error("Error executing queued PostHog call",a,A)}else qr(a)&&n==="alias"?o.push(a):qr(a)&&n.indexOf("capture")!==-1&&pp(this[n])?r.push(a):i.push(a)});const s=function(a,A){BG(a,function(c){try{if(qr(c[0])){let l=A;Cl(c,function(u){l=l[u[0]].apply(l,u.slice(1))})}else A[c[0]].apply(A,c.slice(1))}catch(l){li.error("Error executing queued PostHog call",c,l)}})};s(o,this),s(i,this),s(r,this)}finally{gTe--}}push(e){if(gTe>0&&qr(e)&&Za(e[0])){const n=gD.prototype[e[0]];return void(pp(n)&&n.apply(this,e.slice(1)))}this._execute_array([e])}get oc(){return{property:DYt,persistenceKey:yG,cookieName:"_fbc",pattern:RKt,register:(e,n)=>{var o;return(o=this.persistence)===null||o===void 0?void 0:o.register({[yG]:{value:e,delivered:n}})},unregister:()=>{var e;return(e=this.persistence)===null||e===void 0?void 0:e.unregister(yG)}}}get ac(){return{property:NYt,persistenceKey:E$,cookieName:"_fbp",pattern:TKt,register:(e,n)=>{var o;return(o=this.persistence)===null||o===void 0?void 0:o.register({[E$]:{value:e,delivered:n}})},unregister:()=>{var e;return(e=this.persistence)===null||e===void 0?void 0:e.unregister(E$)}}}lc(e){var n;const o=(n=this.persistence)===null||n===void 0?void 0:n.get_property(e.persistenceKey);return Za(o)&&e.pattern.test(o)?{value:o,delivered:!1}:va(o)&&Za(o.value)&&e.pattern.test(o.value)?{value:o.value,delivered:o.delivered===!0}:void 0}uc(e,n,o){return n===o?.value?{value:n,pending:!o.delivered}:(e.register(n,!1),{value:n,pending:!0})}cc(e){if(!this.config.save_campaign_params||this.yu())return;const n=S$(e.cookieName);return Za(n)&&e.pattern.test(n)?n:void 0}hc(e,n,o,i){if(!this.persistence)return;const r=this.oc;this.persistence.refreshKey(r.persistenceKey);const s=this.lc(r);if(i)return void r.unregister();if(o)return Za(n)&&RKt.test(n)?this.uc(r,n,s):void r.unregister();const a=Za(e)&&Wqo.test(e)?e:void 0,A=this.cc(r);return A&&((c,l,u)=>{const g=c.split(".");if(l)return g[3]===l;if(!u)return!0;const h=u.value.split(".");return g[3]===h[3]||Number(g[2])>Number(h[2])})(A,a,s)?this.uc(r,A,s):a?s?.value.split(".")[3]===a?{value:s.value,pending:!s.delivered}:this.uc(r,`fb.1.${Date.now()}.${a}`,s):s?{value:s.value,pending:!s.delivered}:void 0}dc(e,n,o){if(!this.persistence)return;const i=this.ac;this.persistence.refreshKey(i.persistenceKey);const r=this.lc(i);if(o)return void i.unregister();if(n)return Za(e)&&TKt.test(e)?this.uc(i,e,r):void i.unregister();const s=this.cc(i);return s?this.uc(i,s,r):r?{value:r.value,pending:!r.delivered}:void 0}vc(e,n){if(!this.persistence)return;this.persistence.refreshKey(e.persistenceKey);const o=this.lc(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 li.uninitializedWarning("posthog.capture");if(!this.is_capturing())return;if(Eo(e)||!Za(e))return void li.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 li.critical("This capture call is ignored due to client rate limiting.");let A;n?.$current_url&&!Za(n?.$current_url)&&(li.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?.fc||li.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,u=zGt(o?.uuid,e9);let g={uuid:u,event:e,properties:this.calculateEventProperties(e,n||{},l,u)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&s&&(g.event="$bot_pageview",g.properties.$browser_type="bot"),a&&(g.properties.$lib_rate_limit_remaining_tokens=a.remainingTokens);const h=e==="$feature_flag_called"&&g.properties.$feature_flag_has_experiment===!1&&this.get_property("$minimal_flag_called_events")===!0;o?.$set&&!h&&(g.$set=o?.$set);const d=va(n?.$set)?n.$set:void 0,m=qr(n?.$unset)?n.$unset:[],p=o?.$unset||[],f=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:m.indexOf(R)!==-1||p.indexOf(R)!==-1}},_=f(DYt),I=f(NYt),C=[{channel:this.oc,hasProvided:_.hasProvided,update:this.hc(A?.fbclid,_.provided,_.hasProvided,_.unset)},{channel:this.ac,hasProvided:I.hasProvided,update:this.dc(I.provided,I.hasProvided,I.unset)}];for(const{channel:R,hasProvided:F,update:O}of C)O&&g.properties.$process_person_profile===!0&&O.pending&&!F&&!h&&(g.$set=Zt({[R.property]:O.value},g.$set));const y=o?.$unset;y&&(g.$unset=y);const x=h?void 0:this.gc(o?.$set_once,e!==iUt,e===oUt);if(x&&(g.$set_once=x),o?._noTruncate||(E=this.config.properties_string_max_length,g=(function(R,F){const O=new Set;return(function U(Y,q){if(Y!==Object(Y))return F?F(Y):Y;if(O.has(Y))return;let ee;if(O.add(Y),qr(Y))ee=[],BG(Y,W=>{ee.push(U(W))});else{const W={};Cl(_G(Y)?rUt(Y):Y,(J,te)=>{O.has(J)||(W[te]=U(J))}),ee=W}return ee})(R)})(g,R=>Za(R)?R.slice(0,E):R)),g.timestamp=l,Eo(o?.timestamp)||(g.properties.$event_time_override_provided=!0,g.properties.$event_time_override_system_time=c),h&&(g.properties=((R,F=[])=>{const O={},U=Y=>{R[Y]!==void 0&&(O[Y]=R[Y])};return HWo.forEach(U),F.forEach(U),O})(g.properties,jqo)),e===SE.DISMISSED||e===SE.SENT){const R=n?.[XRe.SURVEY_ID],F=n?.[XRe.SURVEY_ITERATION];vKt({id:R,current_iteration:F}),g.$set=Zt(Zt({},g.$set),{},{[Rqo({id:R,current_iteration:F},e===SE.SENT?"responded":"dismissed")]:!0})}else e===SE.SHOWN&&(g.$set=Zt(Zt({},g.$set),{},{[XRe.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var E;if(e===_qo.SHOWN){const R=n?.[jUt.TOUR_TYPE];R&&(g.$set=Zt(Zt({},g.$set),{},{[`${jUt.TOUR_LAST_SEEN_DATE}/${R}`]:new Date().toISOString()}))}const B=Zt(Zt({},g.properties.$set),g.$set);if(Jx(B)||this.setPersonPropertiesForFlags(B),!Hs(this.config.before_send)){const R=this.Os(g);if(!R)return;g=R,g.uuid=zGt(g.uuid,e9)}this.sessionRecording&&!this.Au&&NKt(e)&&(this.Au=!0,setTimeout(()=>this.Au=!1,3e4));const S=C.filter(({channel:R,update:F})=>{var O,U,Y;const q=(O=(U=g.$set)===null||U===void 0?void 0:U[R.property])!==null&&O!==void 0?O:va((Y=g.properties)===null||Y===void 0?void 0:Y.$set)?g.properties.$set[R.property]:void 0;return F?.pending&&q===F.value});this.du.emit("eventCaptured",g);const Q=(i=o?._url)!==null&&i!==void 0?i:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),w=o?._batchKey==="recordings"||/\/s\/(?:\?|$)/.test(Q),M=Zt(Zt(Zt({method:"POST",url:Q,data:g,compression:"best-available",preferSyncCompression:o?.send_instantly,timestampMode:w?"body":"capture-body",batchKey:o?._batchKey},w&&(!((r=g.properties)===null||r===void 0)&&r.$session_id)?{batchGroup:g.properties.$session_id+(g.properties.$window_id?`-${g.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.vc(F,O.value)}}:{});if(!this.config.request_batching||o&&!o?._batchKey||o?.send_instantly){var T;let R;!M.transport&&!M.callback&&Jx((T=this.config.request_headers)!==null&&T!==void 0?T:{})&&this.Tu&&(R="sendBeacon"),this.zu(M,R)}else this.Bu.enqueue(M);return g}_addCaptureHook(e){return this.on("eventCaptured",n=>e(n.event,n))}getExtension(e){var n;return(n=this.tc)===null||n===void 0?void 0:n.getExtension(e)}Ju(){var e;return(e=this.tc)!==null&&e!==void 0?e:this.tc=new zqo(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)}}mc(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.yc()),(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.mc();const s=r?void 0:this.persistence.remove_event_timer(e);let a=Zt({},n);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,this.yu()&&(a[zYt]=!0),e==="$snapshot"){const _=Zt(Zt({},this.persistence.properties()),this.sessionPersistence.properties());return a.distinct_id=_.distinct_id,(!Za(a.distinct_id)&&!gh(a.distinct_id)||h$(a.distinct_id))&&li.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}const A=(function(_,I,C,y=!1){var x,E,B,S;if(!l2)return{};const Q=_?[...DG,...I||[]]:[],[w,M]=OGt(l2),[T,R]=(function(ie){for(let ne=0;YGt.length>ne;ne++){const[le,de,Ie]=YGt[ne],ce=ie.match(le);if(ce){const fe=Ie&&ie.match(Ie)||ce;return[de,fe?.[1]||""]}}return["",""]})(l2),F=(function(){const ie="u">typeof navigator?navigator:void 0;return ie?.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,q=(E=navigator)===null||E===void 0?void 0:E.maxTouchPoints,ee=jn==null||(B=jn.screen)===null||B===void 0?void 0:B.width,W=jn==null||(S=jn.screen)===null||S===void 0?void 0:S.height,J=jn?.devicePixelRatio;Eo(Y)||(U.userAgentDataPlatform=Y),Eo(q)||(U.maxTouchPoints=q),Eo(ee)||(U.screenWidth=ee),Eo(W)||(U.screenHeight=W),Eo(J)||(U.devicePixelRatio=J);const te=og(DRe({$os:w,$os_version:M,$browser:LGt(l2,navigator.vendor,F,O),$webview_app:T,$webview_app_version:R,$device:GGt(l2),$device_type:aWo(l2,U),$timezone:TUt(),$timezone_offset:mqo()}),{$current_url:D$(y?eP(tg?.href):tg?.href,Q,N$),$host:tg?.host,$pathname:tg?.pathname,$raw_user_agent:l2.length>1e3?l2.substring(0,997)+"...":l2,$browser_version:sWo(l2,navigator.vendor,F,O),$browser_language:YUt(),$browser_language_prefix:hqo(),$screen_height:jn?.screen.height,$screen_width:jn?.screen.width,$viewport_height:jn?.innerHeight,$viewport_width:jn?.innerWidth,$lib:uS.LIB_NAME,$lib_version:uS.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return uS.SDK_DIST_CHANNEL&&(te.$sdk_dist_channel=uS.SDK_DIST_CHANNEL),te})(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:_,windowId:I}=this.sessionManager.checkAndGetSessionAndWindowId(r,o.getTime(),!0);a.$session_id=_,a.$window_id=I}this.sessionPropsManager&&og(a,this.sessionPropsManager.getSessionProps());try{var c;if(this.sessionRecording){const _=this.sessionRecording.sdkDebugProperties,I=!this.Au&&NKt(e);for(const C in _)(I||jr(Vqo,C))&&(a[C]=_[C])}a.$sdk_debug_retry_queue_size=(c=this.Hu)===null||c===void 0?void 0:c.length}catch(_){a.$sdk_debug_error_capturing_properties=String(_)}let l;if(this.requestRouter.region===uTe&&(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=og(a,l),e==="$pageview"&&qo&&(a.title=qo.title),!Eo(s)){const _=o.getTime()-s;a.$duration=parseFloat((_/1e3).toFixed(3))}l2&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser");const u=this.persistence.properties(),g=this.sessionPersistence.properties(),h=a.$groups,d=u.$groups;va(h)&&!Jx(h)&&(a.$groups=Zt(Zt({},va(d)?d:{}),h)),Cl(["$referrer","$referring_domain"],_=>{_ in u&&delete g[_]});const m={};if(this.Ru.length>0)for(const _ of this.Ru.slice())try{og(m,_())}catch(I){li.error("Failed to produce browser extension event properties",I)}a=og({},A,u,g,Zt(Zt({},m),a)),a.$is_identified=this._isIdentified(),qr(this.config.property_denylist)?Cl(this.config.property_denylist,function(_){delete a[_]}):li.error(DKt+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const p=this.config.sanitize_properties;p&&(li.error(MKt),a=p(a,e));const f=this.bc();return a.$process_person_profile=f,f&&!r&&this._c("_calculate_event_properties"),a}gc(e,n=!0,o=!1){var i;if(!this.persistence||!this.bc()||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=og({},r,s||{},e||{});const A=this.config.sanitize_properties;return A&&(li.error(MKt),a=A(a,"$set_once")),n&&(this.Mu=!0),Jx(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.mc(),(o=this.sessionPersistence)===null||o===void 0||o.register(e),Object.keys(e).forEach(i=>this.Eu.add(i)),this.yc()}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.yc()}wc(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.yc()}yc(){var e;if(!this.Pu)return;if(this.config.persistence==="memory"||!((e=this.sessionPersistence)===null||e===void 0)&&e.hi||!ou.At())return void ou.Pt(this.Pu);const n=[];this.Eu.forEach(o=>n.push(o)),n.length>0?ou.$t(this.Pu,n):ou.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:FG}),()=>{})}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:FG})}getActiveMatchingSurveys(e,n=!1){this.surveys?this.surveys.getActiveMatchingSurveys(e,n):e([],{isLoaded:!1,error:FG})}onActiveMatchingSurveysChanged(e){return this.surveys?this.surveys.onActiveMatchingSurveysChanged(e):(e([],{isLoaded:!1,error:FG}),()=>{})}renderSurvey(e,n){var o;(o=this.surveys)===null||o===void 0||o.renderSurvey(e,n)}displaySurvey(e,n=Hqo){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:FG}}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:FG})}kc(e){return!e||h$(e)?(li.critical("Unique user id has not been set in posthog.identify"),!1):e==="$posthog_cookieless"?(li.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())||(li.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 li.uninitializedWarning("posthog.identify");if(gh(e)&&(e=e.toString(),li.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!this.kc(e)||!this._c("posthog.identify"))return;this.ku();const i=this.get_distinct_id(),r=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==i,s=this.mc(!1),a=this.persistence.Oa();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(Cde),this.register({distinct_id:e}));const u=(this.persistence.get_property("$user_state")||"anonymous")===hS,g=e!==l,h=!g&&u;if(g&&u){var c;const d=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:l};this.persistence.set_property(g2,xde),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=lTe(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(g2,xde);const d=n||{},m=o||{};this.setPersonPropertiesForFlags({$set:d,$set_once:m},!1),this.config.cookieWinsOnConflict&&this.persistence.Da(),this.capture("$set",{$set:d,$set_once:m})&&(this.Lu=lTe(e,n,o))}else(n||o)&&this.setPersonProperties(n,o);g||r||s?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(iP)):h&&(n||o)&&this.reloadFeatureFlags(),A=!0}finally{a&&this.persistence.qa(A)}}setPersonProperties(e,n){if(!e&&!n||!this._c("posthog.setPersonProperties"))return;const o=lTe(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)):li.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(e){var n;const o=(qr(e)?e:[e]).filter(i=>Za(i)&&i.length>0);o.length!==0&&this._c("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 li.error("posthog.group requires a group type and group key");(i=this.persistence)===null||i===void 0||i.syncCookieProperties(),this.mc();const r=this.getGroups(),s=r[e]!==n;if(s&&this.resetGroupPropertiesForFlags(e),this.register({$groups:Zt(Zt({},r),{},{[e]:n})}),(s||o)&&this.bc()){const a={$group_type:e,$group_key:n};o&&(a.$group_set=o),this.capture(iUt,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._c("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=u2(e)?e:e?.resetDeviceID,o=u2(e)||e==null?void 0:e.bootstrap;this.Sc(n,!1,o)}Sc(e,n=!1,o){var i,r,s,a,A,c;if(li.info("reset"),!this.__loaded)return li.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 u=this.get_property(mRe),g=this.get_property(pRe),h=this.get_property(B$);(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 m=(A=this.persistence)===null||A===void 0||(c=A.Oa)===null||c===void 0?void 0:c.call(A),p=this.Su;this.Su=p||n;let f=!1;try{var _,I,C,y,x,E,B,S,Q,w,M,T,R;if((_=this.persistence)===null||_===void 0||_.clear(),(I=this.sessionPersistence)===null||I===void 0||I.clear(),this.Eu.clear(),this.yc(),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:QRe,$device_id:null},"");else{const U=this.config.get_device_id(e9());this.register_once({distinct_id:U,$device_id:e?U:u},""),e||Eo(g)||this.register({[pRe]:g})}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(),!Hs(l)&&!(!((T=this.sessionManager)===null||T===void 0)&&T.setBootstrapSessionId(l,!0)))){const U=Zt({},o);delete U.sessionID,this.config.bootstrap=U}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,f=!0}finally{var F,O;this.Su=p,m&&((F=this.persistence)===null||F===void 0||(O=F.qa)===null||O===void 0||O.call(F,f))}this.reloadFeatureFlags()}shutdown(e){var n=this;return ng(function*(){var o,i,r,s,a,A,c,l;if(n.__loaded){n.Iu=!0,n.Ju().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.Hu)===null||A===void 0||A.unload();try{var u;(u=n.featureFlags)===null||u===void 0||u.destroy()}catch(g){li.error("Error while destroying feature flags",g)}(c=n.persistence)===null||c===void 0||c.destroy(),(l=n.sessionPersistence)===null||l===void 0||l.destroy()}else li.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.xc()}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.$c()}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")?(li.critical("Attempting to create alias for existing People user - aborting."),-2):this._c("posthog.alias")?(Eo(n)&&(n=this.get_distinct_id()),e!==n?(this.wc(Cde,e),this.capture("$create_alias",{alias:e,distinct_id:n})):(li.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){const n=Zt({},this.config);if(va(e)){var o,i,r,s,a,A,c,l,u,g,h,d,m,p;og(this.config,kKt(e));const y=this.Cu();if(this.persistence){const E=this.config.persistence==="sessionStorage"||this.config.persistence==="memory";var f,_;if(E&&this.sessionPersistence!==this.persistence&&((f=this.sessionPersistence)===null||f===void 0||f.remove(),(_=this.sessionPersistence)===null||_===void 0||_.destroy()),this.persistence.update_config(this.config,n,y),E)this.sessionPersistence=this.persistence;else if(this.sessionPersistence===this.persistence)this.sessionPersistence=new qRe(Zt(Zt({},this.config),{},{persistence:"sessionStorage"}),y,!1);else{var I;(I=this.sessionPersistence)===null||I===void 0||I.update_config(Zt(Zt({},this.config),{},{persistence:"sessionStorage"}),Zt(Zt({},n),{},{persistence:"sessionStorage"}),y)}}const x=this.Nu(this.config.debug);var C;u2(x)&&(this.config.debug=x),u2(this.config.debug)&&(this.config.debug?(df.DEBUG=!0,hc.At()&&hc.$t("ph_debug",!0),li.info("set_config",{config:e,oldConfig:n,newConfig:Zt({},this.config)})):(df.DEBUG=!1,hc.At()&&hc.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.webMCP)===null||A===void 0||A.startIfEnabled(),(c=this.sessionRecording)===null||c===void 0||c.startIfEnabledOrStop(),(l=this.tracingHeaders)===null||l===void 0||l.startIfEnabledOrStop(),(u=this.autocapture)===null||u===void 0||u.startIfEnabled(),(g=this.heatmaps)===null||g===void 0||g.startIfEnabled(),("capture_pageview"in e||"disable_capture_url_hashes"in e)&&((C=this.historyAutocapture)===null||C===void 0||C.startIfEnabledOrStop()),(h=this.exceptionObserver)===null||h===void 0||h.startIfEnabledOrStop(),(d=this.deadClicksAutocapture)===null||d===void 0||d.startIfEnabledOrStop(),(m=this.surveys)===null||m===void 0||m.loadIfEnabled(),this.xu(),(p=this.externalIntegrations)===null||p===void 0||p.startIfEnabledOrStop(),!n.segment&&this.config.segment&&this.persistence&&MUt(this,O$,!1)}}_overrideSDKInfo(e,n){df.LIB_NAME=e,df.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(Zt(Zt({},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:gD.Cc}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:G$;return n!==G$&&(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"}bc(){var e,n;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&Jx(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))}rc(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&!!this.config.capture_pageview}createPersonProfile(){this.bc()||this._c("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this._c("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}_c(e){return this.config.person_profiles==="never"?(li.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.bu(),this.wc(SRe,!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.Tc(),((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.yc(),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.Sc(!0,!0),(i=this.sessionManager)===null||i===void 0||i.destroy(),(r=this.pageViewManager)===null||r===void 0||r.destroy(),this.sessionManager=new yKt(this),this.pageViewManager=new RUt(this),this.persistence&&(this.sessionPropsManager=new IKt(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=gD.__defaultExtensionClasses)===null||A===void 0?void 0:A.sessionRecording;var c,l;h&&(this.sessionRecording=this.mu(this.sessionRecording,new h(this)),this.hu&&((c=this.sessionRecording)===null||c===void 0||(l=c.onRemoteConfig)===null||l===void 0||l.call(c,this.hu)))}var u,g;this.consent.optInOut(!0),this.xu(),this.ec(),(n=this.sessionRecording)===null||n===void 0||n.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&((u=this.surveys)===null||u===void 0||u.loadIfEnabled()),(Eo(e?.captureEventName)||e?.captureEventName)&&this.capture((g=e?.captureEventName)!==null&&g!==void 0?g:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.nc()}else li.warn(PKt)}opt_out_capturing(){this.config.cookieless_mode!=="always"?(this.consent.optInOut(!1),this.xu(),this.config.cookieless_mode==="on_reject"&&this.$u()):li.warn(PKt)}$u(){var e,n;const o=this.sessionRecording;o?.dispose({discardBufferedEvents:!0}),this.get_distinct_id()!=="$posthog_cookieless"&&this.Sc(!0,!0),this.register({distinct_id:QRe,$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.nc(),this.ec()}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 I_?xKt(I_,this.config.custom_blocked_useragents):void 0}nc(){qo&&(qo.visibilityState==="visible"?this.Fu||(this.Fu=!0,this.capture(MRe,{title:qo.title},{send_instantly:!0}),this.Ou&&(qo.removeEventListener(x$,this.Ou),this.Ou=null)):this.Ou||(this.Ou=this.nc.bind(this),Zc(qo,x$,this.Ou)))}debug(e){e===!1?(jn?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(jn?.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?(li.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&&!Hs(n[o]),A=i in n&&!Hs(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,li)}Os(e){var n;if(Hs(this.config.before_send))return e;const o=Object.keys((n=e.properties)!==null&&n!==void 0?n:{}).filter(jJo),i=qr(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),Hs(r)){const a=`Event '${e.event}' was rejected in beforeSend function`;return WJo(e.event)?li.warn(`${a}. This can cause unexpected behavior.`):li.info(a),null}r.properties&&!Jx(r.properties)||li.warn(`Event '${e.event}' has no properties after beforeSend function, this is likely an error.`)}catch(a){return li.error(`Error in beforeSend function for event '${e.event}':`,a),null}for(const s of o)if(r.properties&&Hs(r.properties[s]))return li.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=u2(e)&&!e,o=hc.At()&&hc.Ot("ph_debug")==="true";return!n&&(!!o||e)}};Y$.__defaultExtensionClasses={},Y$.Cc=(()=>{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]]=Ujo(t.prototype[e[n]])})(Y$,["identify"]);var FKt=class{constructor(e){this.disabled=e===!1;const n=va(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 hTe="$copy_autocapture",mTe=xd("[AutoCapture]");function pTe(t,e){return e.length>t?e.slice(0,t)+"...":e}function Zqo(t){if(t.previousElementSibling)return t.previousElementSibling;let e=t;do e=e.previousSibling;while(e&&!t9(e));return e}function e$o(t,{e,maskAllElementAttributes:n,maskAllText:o,elementAttributeIgnoreList:i,elementsChainAsString:r,disableCaptureUrlHashes:s}){var a,A;if(!t9(t))return{props:{}};const c=[t],l=new Set([t]);let u=t;for(;u.parentNode&&!BI(u,"body")&&1e3>c.length;){if(ORe(u.parentNode)){const x=u.parentNode.host;if(l.has(x))break;l.add(x),c.push(x),u=x;continue}if(!t9(u.parentNode)||l.has(u.parentNode))break;l.add(u.parentNode),c.push(u.parentNode),u=u.parentNode}const g=e.type==="click"&&t.namespaceURI==="http://www.w3.org/2000/svg"?c.findIndex(x=>BI(x,"button")||BI(x,"a")):-1;g>0&&(o=o||c.slice(0,g+1).some(x=>!JR(x)||vG(x)));const h=[],d={};let m,p=!1,f=!1;if(Cl(c,x=>{const E=JR(x);if(BI(x,"a")&&!n&&!i?.includes("href")){const B=x.getAttribute("href");p=!!(E&&B&&wG(B))&&(s?eP(B):B)}jr(QG(x),"ph-no-capture")&&(f=!0),h.push((function(B,S,Q,w,M=!1){const T=B.tagName.toLowerCase(),R={tag_name:T};YRe.indexOf(T)>-1&&!Q&&(R.$el_text=T.toLowerCase()==="a"||T.toLowerCase()==="button"?pTe(1024,QUt(B)):pTe(1024,v$(B)));const F=QG(B);S||w?.includes("class")||0>=F.length||(R.classes=F.filter(function(q){return q!==""})),Cl(B.attributes,function(q){var ee;if((!vG(B)||["name","id","class","aria-label"].indexOf(q.name)!==-1)&&!w?.includes(q.name)&&!S&&wG(q.value)&&(!Za(ee=q.name)||ee.substring(0,10)!=="_ngcontent"&&ee.substring(0,7)!=="_nghost")){let W=q.value;q.name==="class"&&(W=GRe(W).join(" ")),R["attr__"+q.name]=pTe(1024,q.name==="href"&&M?eP(W):W)}});let O=1,U=1,Y=B;for(;Y=Zqo(Y);)O++,Y.tagName===B.tagName&&U++;return R.nth_child=O,R.nth_of_type=U,R})(x,n,o,i,s)),Cl((function(B){if(!JR(B))return{};const S={};return Cl(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&&wG(M)&&(S[w]=M)}}),S})(x),(B,S)=>{({}).hasOwnProperty.call(d,S)||(d[S]=B)})}),f)return{props:{},explicitNoCapture:f};if(g>0&&(t=c[g],h.splice(0,g)),o||(h[0].$el_text=BI(t,"a")||BI(t,"button")?QUt(t):v$(t)),p){var _,I;h[0].attr__href=p;const x=(_=mS(p))===null||_===void 0?void 0:_.host,E=jn==null||(I=jn.location)===null||I===void 0?void 0:I.host;x&&E&&x!==E&&(m=p)}return{props:og((y=e.type,{$event_type:y,$ce_version:1}),r?{}:{$elements:h},{$elements_chain:(C=h,qr(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 T of E.attr_class)Q+=`.${T.replace(/"/g,"")}`}const w=Zt(Zt(Zt(Zt({},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 Bde(w).sort(([T],[R])=>(function(F,O){return O>F?-1:F>O?1:0})(T,R)).forEach(([T,R])=>M[wUt(T.toString())]=wUt(R.toString())),Q+=":",Q+=Bde(M).map(([T,R])=>`${T}="${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:sqo(E),attr_id:E.attr__id,nth_child:E.nth_child,nth_of_type:E.nth_of_type,attributes:{}};return Bde(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}:{},m&&e.type==="click"?{$external_click_url:m}:{},d),target:t};var C,y}var t$o=class{do(){this.vo=void 0,clearTimeout(this.fo),this.fo=void 0}po(e){var n;if(!JR(e))return!0;const o=(n=this.mo().css_selector_ignorelist)!==null&&n!==void 0?n:zRe,i=new Set;let r=e;for(;r;){if(i.size>=1e3||i.has(r))return!0;i.add(r);const s=r,a=QG(s);if(jr(a,"ph-no-capture")||jr(a,"ph-sensitive")||vG(s)||o.some(c=>URe(s,c)))return!0;const A=r.parentNode;r=ORe(A)?A.host:A&&t9(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=w$(e);var n;return void(e.isPrimary&&e.button===0&&!e.ctrlKey&&i&&t9(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=w$(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&&(BI(i,"html")||BI(i,"body"))){var r;if(o.excluded)return null;const s=(r=this.mo().css_selector_ignorelist)!==null&&r!==void 0?r:zRe;return[i,qo?.documentElement,qo?.body].some(a=>{if(!a)return!1;const A=QG(a);return jr(A,"ph-no-capture")||jr(A,"ph-sensitive")||!JR(a)||vG(a)||s.some(c=>URe(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 FKt(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 mTe.info("Disabling Automatic Event Collection because this browser is not supported");if(!jn||!qo)return;const e=this.Ao=n=>{n=n||jn?.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(yd(o))return;this.Fo(n,"$autocapture",o)}catch(o){mTe.error("Failed to capture event",o)}};if(Zc(jn,"blur",e),Zc(qo,"submit",e,{capture:!0}),Zc(qo,"change",e,{capture:!0}),Zc(qo,"click",e,{capture:!0}),Cl(["pointerdown","pointermove","pointerup","pointercancel"],n=>{Zc(qo,n,e,{capture:!0})}),this.mo().capture_copied_text){const n=this.Oo=o=>{o=o||jn?.event;try{this.Fo(o,hTe)}catch(i){mTe.error("Failed to capture clipboard event",i)}};Zc(qo,"copy",n,{capture:!0}),Zc(qo,"cut",n,{capture:!0}),Zc(qo,"paste",n,{capture:!0})}}Po(){this.do(),this.Ao&&(jn?.removeEventListener("blur",this.Ao),Cl(["pointerdown","pointermove","pointerup","pointercancel"],e=>{qo?.removeEventListener(e,this.Ao,!0)}),qo?.removeEventListener("submit",this.Ao,!0),qo?.removeEventListener("change",this.Ao,!0),qo?.removeEventListener("click",this.Ao,!0),this.Ao=void 0),this.Oo&&(qo?.removeEventListener("copy",this.Oo,!0),qo?.removeEventListener("cut",this.Oo,!0),qo?.removeEventListener("paste",this.Oo,!0),this.Oo=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;u2(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=qo?.querySelectorAll(r);s?.forEach(a=>{e!==a&&n!==a||jr(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(RYt),i=this.So,r=this.mo();if(!r.remoteRequestsDisabled&&!this.xo)return!1;const s=r.remoteRequestsDisabled&&!this.xo;if(yd(i)&&!u2(o)&&!s)return!1;const a=(n=this.So)!==null&&n!==void 0?n:!!o;return!!r.enabled&&!a}Fo(e,n="$autocapture",o){if(!this.isEnabled)return void this.do();let i=o||w$(e);dUt(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()))&&yUt(i,r.rageclick)&&this.Fo(e,"$rageclick",o);const a=n===hTe,A=a?Zt(Zt({},r),{},{dom_event_allowlist:void 0}):r;if(i&&(function(g,h,d,m,p,f){var _;if(!jn||WRe(g)||d?.url_allowlist&&!hUt(d.url_allowlist,f)||d?.url_ignorelist&&hUt(d.url_ignorelist,f))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}=xUt(g,m);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)||!KRe(C,d?.css_selector_allowlist)||KRe(C,(_=d?.css_selector_ignorelist)!==null&&_!==void 0?_:zRe))return!1;try{const x=jn.getComputedStyle(g);if(x&&x.getPropertyValue("cursor")==="pointer"&&h.type==="click")return!0}catch{}const y=g.tagName.toLowerCase();switch(y){case"html":return!1;case"form":return(p||["submit"]).indexOf(h.type)>=0;case"input":case"select":case"textarea":return(p||["change","click"]).indexOf(h.type)>=0;default:return I?(p||["click"]).indexOf(h.type)>=0:(p||["click"]).indexOf(h.type)>=0&&(YRe.indexOf(y)>-1||g.getAttribute("contenteditable")==="true")}})(i,e,A,a,a?["copy","cut","paste"]:void 0,{config:{get_current_url:r.getCurrentUrl}})){var c;const{props:g,explicitNoCapture:h,target:d}=e$o(i,{e,maskAllElementAttributes:r.maskAllElementAttributes,maskAllText:r.maskAllText,elementAttributeIgnoreList:r.element_attribute_ignorelist,elementsChainAsString:this.Co,disableCaptureUrlHashes:r.disableCaptureUrlHashes});if(h)return!1;const m=this.getElementSelectors(i,d);if(m&&m.length>0&&(g.$element_selectors=m),n===hTe){const p=e.type||"clipboard";if(p!=="paste"){var l,u;const f=jn==null||(l=jn.getSelection())===null||l===void 0?void 0:l.toString(),_=mUt(f);if(!_)return!1;g.$selected_content=_,g.$clipboard_text_length=(u=f?.length)!==null&&u!==void 0?u:0}g.$copy_type=p}return(c=this.bo)===null||c===void 0||c.capture(n,g),!0}}isBrowserSupported(){return pp(qo?.querySelectorAll)}},n$o=class{constructor(e){this._instance=e}refresh(e){const n=this._instance.config,o=va(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 U$=xd("[ExceptionAutocapture]"),LKt=()=>{},HKt=t=>{var e;if(pp(t))return(e=t.__posthog_layer__)!==null&&e!==void 0?e:t.__rrweb_layer__};function LG(t,e,n){try{if(!(e in t))return LKt;const o={next:t[e]},i=n(function(...r){return o.next.apply(this,r)});return pp(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=HKt(r);for(;s;){if(s.next===i)return void(s.next=o.next);r=s.next,s=HKt(r)}}}catch{return LKt}}const o$o=xd("[TracingHeaders]"),jR=xd("[Web Vitals]"),OKt=9e5,GKt=["CLS","FCP","INP","LCP"],i$o=["INP","LCP"],r$o=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],fTe="disabled",YKt="lazy_loading",_S=xd("[SessionRecording]"),s$o=[vRe,wRe,WYt,jYt,qYt,$Yt,XYt,ZYt,eUt],a$o=xd("[Heatmaps]");function _Te(t){return va(t)&&"clientX"in t&&"clientY"in t&&gh(t.clientX)&&gh(t.clientY)}const Fde=xd("[Product Tours]"),ITe=t=>{var e;return!t.config.disable_product_tours&&!!(!((e=t.persistence)===null||e===void 0)&&e.get_property(ERe))},A$o=["$set_once","$set"],T7=xd("[SiteApps]"),UKt="Error while initializing PostHog app with config id ",KKt=(t,e)=>t?.then?t.then(e):e(t),HG="SDK is not enabled or survey functionality is not yet loaded",zKt="Disabled. Not loading surveys.";var c$o=class{constructor(e,n){this.wo=e,this.Ic=n,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Mc=!1,this.Ec=!1,this.Pc=[],this.Rc=[],this.Ac=null,this.Fc=null,this.To=!1,this.Oc=new Set,this.onRemoteConfig=o=>{if(this.To||this.Mr.disableSurveys)return;if(!o.ok)return this.Ec=!0,this.Dc({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),yl.warn("Remote config unavailable. Not loading surveys.");const i=o.config.surveys;if(Hs(i))return yl.warn("Flags not loaded yet. Not loading surveys.");this.Lc=u2(i)?i:i.length>0,yl.info(`flags response received, isSurveysEnabled: ${this.Lc}`),this.loadIfEnabled()},this.Dc=o=>{this.Rc.slice().forEach(i=>this.Nc(i,o))}}setup(e){if(!this.To)return this.qc=e,KKt(e.kv.initialize(),()=>{if(this.qc!==e||this.To)return;this.qc=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.qc=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.Pc=[],this.Rc.forEach(s=>{s.active=!1}),this.Rc=[],(r=this.jc)===null||r===void 0||r.call(this),this.jc=void 0,this.Ac=null,this.Oc.forEach(s=>clearTimeout(s)),this.Oc.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.Dc()}loadIfEnabled(){if(this.To||!this.bo)return;const e=this.Mr;if(this._surveyManager)return;if(this.Mc)return void yl.info("Already initializing surveys, skipping...");if(e.disableSurveys)return void yl.info(zKt);if(e.cookielessMode&&this.wo.isOptedOut())return void yl.info("Not loading surveys in cookieless mode without consent.");const n=this.wo.getExtensions();if(!n)return void this.Bc("PostHog Extensions not found.");if(Eo(this.Lc)&&!e.advancedEnableSurveys)return;const o=this.Lc||e.advancedEnableSurveys;this.Mc=!0,this.Ec=!1;try{const i=n.generateSurveys;if(i)return this.zc(i,o),void(this.Mc=!1);const r=n.loadExternalDependency;if(!r)return this.Bc(PRe),void(this.Mc=!1);r(s=>{try{if(this.To)return;const a=this.wo.getExtensions();s||!a?.generateSurveys?this.Bc("Could not load surveys script",s):this.zc(a.generateSurveys,o)}finally{this.Mc=!1}})}catch(i){throw this.Mc=!1,this.Bc("Error initializing surveys",i),i}}zc(e,n){var o,i;if(this.To)return;this._surveyManager=e(n),this._surveyEventReceiver=this.wo.createEventReceiver(this.Dc);const r=(o=(i=this.bo)!==null&&i!==void 0?i:this.Ic)===null||o===void 0?void 0:o.kv.get(b$);r&&this.Hc(r),yl.info("Surveys loaded successfully"),this.Uc(),this.Dc(),this.Wc({isLoaded:!0})}Bc(e,n){this.Ec=!0,yl.error(e,n),this.Dc({isLoaded:!1,error:e}),this.Wc({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.Pc.push(e),this._surveyManager&&this.Wc({isLoaded:!0}),()=>{this.Pc=this.Pc.filter(n=>n!==e)}}getSurveys(e,n=!1){var o;const i=(o=this.bo)!==null&&o!==void 0?o:this.Ic;if(!i||this.To)return;if(this.Mr.disableSurveys)return yl.info(zKt),e([]);const r=i.kv.get(b$);if(r&&!n)return e(r,{isLoaded:!0}),void(this.Vc()&&this.getSurveys(()=>{},!0));if(this.Ac)return void this.Ac.then(({surveys:A,context:c})=>{this.To||e(A,c)}).catch(A=>yl.error("Error in survey callback",A));const s=this.Gc("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.Mr.requestTimeoutMs}).then(A=>{try{return this.Qc(i,A)}catch(c){return yl.error("Error processing surveys response",c),this.Qc(i,{statusCode:0,error:c})}},A=>this.Qc(i,{statusCode:0,error:A}));this.Ac=s;const a=()=>{this.Ac===s&&(this.Ac=null)};s.then(A=>{a(),this.To||(this.Dc(A.context),e(A.surveys,A.context))},a).catch(A=>yl.error("Error in survey callback",A))}Gc(e,n){const o=this.bo;return o?o.sendRequest(e,n):new Promise(i=>i({statusCode:0,error:new Error(HG)}))}Qc(e,n){if(this.To)return{surveys:[],context:{isLoaded:!1,error:HG}};const o=n.statusCode;if(o!==200||!n.json){const r=`Surveys API could not be loaded, status: ${o}`;return o!==0?yl.error(r):n.error||yl.warn(r),this.Fc=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Fc=null;const i=n.json.surveys||[];return e.kv.set({[b$]:i,[yde]:Date.now()}),this.Hc(i),{surveys:i,context:{isLoaded:!0}}}Hc(e){var n;const o=e.filter(i=>(function(r){return!(!r.start_date||r.end_date)})(i)&&(BKt(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)}Vc(){return this.Zc()&&!this.Ac&&!this.Jc()}Zc(){var e,n;const o=(e=(n=this.bo)!==null&&n!==void 0?n:this.Ic)===null||e===void 0?void 0:e.kv.get(yde);return gh(o)&&Date.now()-o>3e5}Jc(){return gh(this.Fc)&&3e5>Date.now()-this.Fc}markSurveyAsSeen(e,n){var o;const i={id:e,current_iteration:(o=n?.iteration)!==null&&o!==void 0?o:null};vKt(i);try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}this.Dc()}Wc(e){for(const n of this.Pc)try{if(!e.isLoaded)return n([],e);this.getSurveys(n)}catch(o){yl.error("Error in survey callback",o)}}getActiveMatchingSurveys(e,n=!1){if(!Hs(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,n);yl.warn("init was not called")}onActiveMatchingSurveysChanged(e){var n,o;if(this.To)return()=>{};const i={callback:e,active:!0,revision:0};this.Rc.push(i),this.Uc();const r=(n=(o=this.bo)!==null&&o!==void 0?o:this.Ic)===null||n===void 0?void 0:n.kv.get(b$);return this.Mr.disableSurveys||!this._surveyManager&&this.Ec&&!this.Mc||!r&&!Hs(this.Fc)&&!this.Ac?this.Nc(i,{isLoaded:!1}):this._surveyManager&&this.Nc(i),()=>{var s;i.active=!1,this.Rc=this.Rc.filter(a=>a!==i),this.Rc.length===0&&((s=this.jc)===null||s===void 0||s.call(this),this.jc=void 0)}}Uc(){var e,n,o;this._surveyManager&&this.Rc.length>0&&((e=this.jc)!==null&&e!==void 0||(this.jc=(n=(o=this.wo).onMatchingConditionsChanged)===null||n===void 0?void 0:n.call(o,this.Dc)))}Nc(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){yl.error("Error in active matching surveys callback",s)}};try{n&&!n.isLoaded?i([]):this.getActiveMatchingSurveys(i)}catch(r){yl.error("Error in active matching surveys callback",r)}}Kc(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}Xc(e){if(Hs(this._surveyManager))return{eligible:!1,reason:HG};const n=typeof e=="string"?this.Kc(e):e;return n?this._surveyManager.checkSurveyEligibility(n):{eligible:!1,reason:"Survey not found"}}Yc(e){if(!this.wo.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(Hs(this._surveyManager))return{eligible:!1,reason:HG};const n=typeof e=="string"?this.Kc(e):e;return n?this._surveyManager.checkSurveyRenderability(n):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(Hs(this._surveyManager))return yl.warn("init was not called"),{visible:!1,disabledReason:HG};const n=this.Yc(e);return{visible:n.eligible,disabledReason:n.reason}}canRenderSurveyAsync(e,n){return Hs(this._surveyManager)?(yl.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:HG})):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.Yc(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(Hs(this._surveyManager))return void yl.warn("init was not called");const r=typeof e=="string"?this.Kc(e):e;if(!r?.id)return void yl.warn("Survey not found");if(!Lqo.includes(r.type))return void yl.warn(`Surveys of type ${r.type} cannot be rendered in the app`);const s=qo?.querySelector(n);if(s){if(!((i=r.appearance)===null||i===void 0)&&i.surveyPopupDelaySeconds){yl.info(`Rendering survey ${r.id} with delay of ${r.appearance.surveyPopupDelaySeconds} seconds`);const a=setTimeout(()=>{var A,c;this.Oc.delete(a),!this.To&&this.wo.isCapturing()&&(yl.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),yl.info(`Survey ${r.id} rendered`))},1e3*r.appearance.surveyPopupDelaySeconds);return void this.Oc.add(a)}this._surveyManager.renderSurvey(r,s,o)}else yl.warn("Survey element not found")}displaySurvey(e,n){var o;if(!this.wo.isCapturing())return;if(Hs(this._surveyManager))return void yl.warn("init was not called");const i=this.Kc(e);if(!i)return void yl.warn("Survey not found");let r=i;if(!((o=i.appearance)===null||o===void 0)&&o.surveyPopupDelaySeconds&&n.ignoreDelay&&(r=Zt(Zt({},i),{},{appearance:Zt(Zt({},i.appearance),{},{surveyPopupDelaySeconds:0})})),n.displayType!==ZRe.Popover&&n.initialResponses&&yl.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),n.ignoreConditions===!1){const s=this.Xc(i);if(!s.eligible)return void yl.warn("Survey is not eligible to be displayed: ",s.reason)}n.displayType!==ZRe.Inline?this._surveyManager.handlePopoverSurvey(r,n):this.renderSurvey(r,n.selector,n.properties)}cancelPendingSurvey(e){Hs(this._surveyManager)?yl.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 OG(t,e,n){if(Hs(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 l$o=class{constructor(e){this._instance=e,this.th=new Set,this.eh=new Set,this.ih=new Rde,this.nh=(n,o)=>this.sh(n,o)&&this.rh(n,o)&&this.oh(n,o)&&this.ah(n,o),this.sh=(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.uh=(n=this._instance)===null||n===void 0?void 0:n._addCaptureHook((o,i)=>{this.on(o,i)}))}dispose(){var e,n;(e=this.uh)===null||e===void 0||e.call(this),this.uh=void 0,(n=this._instance)===null||n===void 0||(n=n.autocapture)===null||n===void 0||n.setElementSelectors(new Set,this),this.ih=new Rde}register(e){var n,o;if(!Eo((n=this._instance)===null||n===void 0?void 0:n._addCaptureHook)&&(e.forEach(i=>{var r;this.th.add(i),(r=i.steps)===null||r===void 0||r.forEach(s=>{this.eh.add(s?.event||"")})}),(o=this._instance)===null||o===void 0?void 0:o.autocapture)){const i=new Set;this.th.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.th.clear(),this.eh.clear(),this.register(e)}on(e,n){n!=null&&e.length!=0&&(this.eh.has(e)||this.eh.has(n.event))&&this.th.forEach(o=>{this.hh(n,o)&&this.ih.emit("actionCaptured",o.name)})}dh(e){this.onAction("actionCaptured",n=>e(n))}hh(e,n){if(n?.steps==null)return!1;for(const o of n.steps)if(this.nh(e,o))return!0;return!1}onAction(e,n){return this.ih.on(e,n)}rh(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"||!OG(i,n.url,n.url_matching||"contains"))return!1}return!0}oh(e,n){return!!this.fh(e,n)&&!!this.ph(e,n)&&!!this.gh(e,n)}fh(e,n){var o;if(!n?.href)return!0;const i=this.mh(e);if(i.length>0)return i.some(s=>OG(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&&OG((function(s){const a=s.match(/(?::|")href="(.*?)"/);return a?a[1]:""})(r),n.href,n.href_matching||"exact")}ph(e,n){var o;if(!n?.text)return!0;const i=this.mh(e);if(i.length>0)return i.some(c=>OG(c.text,n.text,n.text_matching||"exact")||OG(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=[],u=/(?::|")text="(.*?)"/g;let g;for(;!Hs(g=u.exec(c));)l.includes(g[1])||l.push(g[1]);return l})(r),a=n.text,A=n.text_matching||"exact",s.some(c=>OG(c,a,A)));var s,a,A}gh(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}mh(e){var n;return(e==null||(n=e.properties)===null||n===void 0?void 0:n.$elements)==null?[]:e?.properties.$elements}ah(e,n){return!n?.properties||n.properties.length===0||SKt(n.properties.reduce((o,i)=>{const r=qr(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)}},u$o=class{constructor(e,n){var o,i;this.yh=[],this._instance=e,this.bh=n,this._h=new Map,this.wh=new Map,this.kh=new Map,this.Sh=(o=this._instance)===null||o===void 0||(i=o.onSessionId)===null||i===void 0?void 0:i.call(o,r=>this.xh(r))}$h(e){return!1}Ch(){return null}Th(e){}Ih(){}Mh(e,n){return!!e&&SKt(e.propertyFilters,n?.properties)}Eh(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}Ph(e,n,o){const i=(o===R$.Activation?this._h:this.wh).get(e);let r=[];return this.Rh(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.Mh(A,n)})}register(e){this.Ah(e,!1)}replace(e){this.Ah(e,!0)}Ah(e,n){var o;Eo((o=this._instance)===null||o===void 0?void 0:o._addCaptureHook)||(this.Fh(e,n),this.Oh(e,n))}Oh(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.kh.clear(),o.length===0)return void(n&&((i=this.Dh)===null||i===void 0||i.replace([])));this.Dh||(this.Dh=new l$o(this._instance),this.Dh.init(),this.Dh.dh(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.kh.get(A.name))!==null&&c!==void 0?c:[];l.includes(s.id)||l.push(s.id),this.kh.set(A.name,l)}})}),n?this.Dh.replace(r):this.Dh.register(r)}Lh(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)})}Fh(e,n){var o,i;const r=e.filter(c=>{var l,u;return((l=c.conditions)===null||l===void 0?void 0:l.events)&&((u=c.conditions)===null||u===void 0||(u=u.events)===null||u===void 0||(u=u.values)===null||u===void 0?void 0:u.length)>0}),s=e.filter(c=>{var l,u;return((l=c.conditions)===null||l===void 0?void 0:l.cancelEvents)&&((u=c.conditions)===null||u===void 0||(u=u.cancelEvents)===null||u===void 0||(u=u.values)===null||u===void 0?void 0:u.length)>0}),a=this.Eh(e,R$.Activation),A=this.Eh(e,R$.Cancellation);n?(this._h=a,this.wh=A):(this.Lh(this._h,a),this.Lh(this.wh,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.uh)!==null&&o!==void 0||(this.uh=(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.Nh(),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.qh(e,s,n);if(A==="consume")return r.info("event consumed activated item, removing it",{event:e,itemId:s}),void this.jh([s]);if(A==="persist")return r.info("shown item promoted to persisted activation",{event:e,itemId:s}),this.Bh(s),void this.zh([s])}if(this.wh.has(e)){const A=this.Ph(e,n,R$.Cancellation);A.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:A.map(c=>c.id)}),this.jh(A.map(c=>c.id)),A.forEach(c=>this.Hh(c.id)))}if(!this._h.has(e))return;r.info("event name matched",{event:e,eventPayload:n,items:this._h.get(e)});const a=this.Ph(e,n,R$.Activation);this.Uh(a.map(A=>A.id))}onAction(e){this.kh.has(e)&&this.Uh(this.kh.get(e)||[])}Uh(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.$h(s)?this.Bh(s)&&this.Wh(s):r.push(s);r.length>0&&(this.yh=[...new Set([...this.yh,...r])]),this.Nh().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.Vh()}Bh(e){this.yh=this.yh.filter(o=>o!==e);const n=this.Gh();return!n.includes(e)&&(this.Qh([...n,e]),this.Zh(),!0)}jh(e){const n=new Set(e);this.yh=this.yh.filter(r=>!n.has(r));const o=this.Jh(),i=o.filter(r=>!n.has(r));i.length!==o.length&&(this.Qh(i),i.length===0&&this.Kh()),this.zh(e),this.Vh()}Vh(){try{var e;(e=this.bh)===null||e===void 0||e.call(this)}catch(n){this.Nh().error("Error while handling activated items change",n)}}Xh(){var e;const n=this.Ch();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:{}}Wh(e){if(!this.Ch())return;const n=this.Xh();this.Th(Zt(Zt({},n),{},{[e]:Date.now()}))}zh(e){if(!this.Ch())return;const n=this.Xh(),o={};let i=!1;for(const[r,s]of Object.entries(n))e.includes(r)?i=!0:o[r]=s;i&&(Jx(o)?this.Ih():this.Th(o))}Yh(){this.Ch()&&this.Ih()}getActivationTimestamp(e){if(!this.Gh().includes(e))return;const n=this.Xh()[e];return gh(n)?n:void 0}Jh(){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])||[]}Gh(){var e,n,o;const i=this.Jh();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:[]}Zh(){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)}Kh(){this.sd()}xh(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.Jh(),r=this.Xh();i.length>0&&(this.Qh([]),i.filter(s=>gh(r[s])).forEach(s=>this.Hh(s))),this.Kh(),this.Yh(),i.length>0&&this.Vh()}}getActivatedIds(){return[...new Set([...this.Gh(),...this.yh])].filter(e=>!this.rd(e))}dispose(){var e,n,o;(e=this.Sh)===null||e===void 0||e.call(this),this.Sh=void 0,(n=this.uh)===null||n===void 0||n.call(this),this.uh=void 0,(o=this.Dh)===null||o===void 0||o.dispose(),this.Dh=void 0}reset(){this.yh=[],this.Jh().length>0&&this.Qh([]),this.Kh(),this.Yh(),this.Vh()}getEventToItemsMap(){return this._h}od(){return this.Dh}},g$o=class extends u$o{constructor(t,e){super(t,e)}td(){return OYt}ed(){return GYt}Ch(){return YYt}Th(t){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.register({$surveys_activated_timestamps:t})}Ih(){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.unregister("$surveys_activated_timestamps")}$h(t){var e;let n;this.Rh(i=>{n=i.find(r=>r.id===t)});const o=n==null||(e=n.appearance)===null||e===void 0?void 0:e.surveyPopupDelaySeconds;return gh(o)&&o>0}ad(){return SE.SHOWN}Rh(t){var e;(e=this._instance)===null||e===void 0||e.getSurveys(t)}Hh(t){var e;(e=this._instance)===null||e===void 0||e.cancelPendingSurvey(t)}Nh(){return yl}Qh(t){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.register({$surveys_activated:t})}nd(t){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.register({$surveys_activated_session:t})}sd(){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.unregister("$surveys_activated_session")}rd(){return!1}qh(t,e,n){var o;if(t===SE.SENT&&(n==null||(o=n.properties)===null||o===void 0?void 0:o.$survey_completed)===!1)return"ignore";let i;return this.Rh(r=>{i=r.find(s=>s.id===e)}),!i||(function(r){var s;return BKt(r)&&!!(!((s=r.conditions)===null||s===void 0||(s=s.events)===null||s===void 0)&&s.repeatedActivation)||r.schedule==="always"})(i)?t===SE.SHOWN?"consume":"ignore":t===SE.SHOWN?"persist":t===SE.DISMISSED||t===SE.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},d$o=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)}},h$o=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=Kr?.__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 g$o(this._instance,e)}onMatchingConditionsChanged(e){const n=this._instance._addCaptureHook(s=>{s!=="$pageview"&&s!==SE.SHOWN&&s!==SE.DISMISSED&&s!==SE.SENT||e()}),o=()=>e();Zc(jn,"PHSurveyShown",o);let i=!1;const r=this._instance.onFeatureFlags(()=>{i&&e()});return i=!0,()=>{i=!1,n(),r(),jn?.removeEventListener("PHSurveyShown",o)}}};const m$o=jn?.location?Qde(jn.location.hash,"__posthog")||Qde(location.hash,"state"):null,VKt="_postHogToolbarParams",JKt=xd("[Toolbar]"),WKt=xd("[FeatureFlags]"),qR=xd("[FeatureFlags]",{debugEnabled:!0}),CTe=`" failed. Feature flags didn't load in time.`,p$o=[502,504],jKt=["click","keydown","wheel","touchstart","pointerdown"],qKt="connection_error",$Kt=t=>{const e={};for(let n=0;t.length>n;n++)e[t[n]]=!0;return e},XKt=t=>{const e={};for(const[n,o]of Bde(t||{}))o&&(e[n]=o);return e};var f$o=class{constructor(e){this.name="featureFlags",this.ld=!1,this.featureFlagEventHandlers=[],this.A=WKt,this.ud={},this.hd={},this.dd=[],this.vd=new Set,this.fd=new Set,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 n=this.xd();this.kd=0,n&&this.reloadFeatureFlags()},this.$d=()=>{var n,o;const i=this.Cd,r=(n=this.Td)!==null&&n!==void 0?n:i;Eo(i)||Eo(r)||this.Mr.remoteRequestsDisabled||!this.Id||this.Id.visibilityState==="hidden"||Date.now()-((o=this.Md)!==null&&o!==void 0?o:0)<r||(this.Td=this.Sd||!this.Mr.idleRefreshBackoff?i:Math.min(2*r,36e5),this.Sd=!1,this.reloadFeatureFlags(),this.Ed())},this.Pd=()=>{this.Sd&&this.Td===this.Cd||this.Rd()},this.sn=()=>{var n;((n=this.Id)===null||n===void 0?void 0:n.visibilityState)==="visible"&&this.Rd()},this.wo=e}get Ad(){}Fd(){this.bo&&this.Od()}setup(e){try{this.Dd=typeof window>"u"?void 0:window,this.Id=typeof document>"u"?void 0:document}catch{this.Dd=void 0,this.Id=void 0}return this.qc=e,this.A=e.logger.createLogger("[FeatureFlags]"),KKt(e.kv.initialize(),()=>{this.qc===e&&(this.qc=void 0,this.bo=e,this.Ld(e))})}Ld(e){var n;if(this.bo===e)return this.Dd&&Zc(this.Dd,"online",this.rn),this.Od(),this.Nd=e.registerDynamicEventProperties(()=>this.qd()?this.ud:this.hd),this.jd=(n=this.Ad)===null||n===void 0?void 0:n.onCrossTabFeatureFlagChange(()=>{this.Bd(),this.zd(),this.Hd()}),this.zd(),this.initialize()}Rd(){this.Sd=!0,this.Td=this.Cd,this.$d()}Od(){var e;const n=this.Mr.refreshIntervalMs,o=!this.Mr.remoteRequestsDisabled&&this.Id&&!Eo(n)&&n>0?n:void 0;this.Mr.idleRefreshBackoff||(this.Td=o),o!==this.Cd&&(this.Ud(),Eo(o)||(this.Cd=o,this.Td=o,this.Ed(),!((e=this.Id)===null||e===void 0)&&e.addEventListener&&(Zc(this.Id,x$,this.sn),BG(jKt,i=>{Zc(this.Id,i,this.Pd,{capture:!0})}))))}Ed(){Eo(this.Cd)||(Eo(this.Wd)||clearInterval(this.Wd),this.Md=Date.now(),this.Wd=setInterval(this.$d,this.Cd))}Ud(){var e,n;Eo(this.Wd)||(clearInterval(this.Wd),this.Wd=void 0,(e=this.Id)===null||e===void 0||(n=e.removeEventListener)===null||n===void 0||n.call(e,"visibilitychange",this.sn),BG(jKt,o=>{var i,r;(i=this.Id)===null||i===void 0||(r=i.removeEventListener)===null||r===void 0||r.call(i,o,this.Pd,{capture:!0})})),this.Cd=void 0,this.Td=void 0,this.Sd=!1,this.Md=void 0}destroy(){this.Vd()}dispose(){this.Vd()}Vd(){var e,n,o;this.Ud(),this.md++,this.bd=!1,this.qc=void 0,this.Gd(this.vd,"cancelled"),this.Gd(this.fd,"cancelled"),this.bo&&(this.Qd(),(e=this.Nd)===null||e===void 0||e.dispose(),this.Nd=void 0,(n=this.jd)===null||n===void 0||n.call(this),this.jd=void 0,this.dd=[],(o=this.Dd)===null||o===void 0||o.removeEventListener("online",this.rn),this.bo=void 0)}get Mr(){return this.wo.get()}Zd(e){var n;return this.Jd&&e in this.Jd?this.Jd[e]:(n=this.bo)===null||n===void 0?void 0:n.kv.get(e)}Bd(){return!!this.Jd&&(this.Jd=void 0,!0)}Kd(){var e;return!Eo((e=this.bo)===null||e===void 0?void 0:e.kv.get("$enabled_feature_flags"))&&this.Bd()}$t(e){this.Xd(()=>{var n;return(n=this.bo)===null||n===void 0?void 0:n.kv.set(e)})}Yd(e,n,o){if(!this.Ad||!e.$enabled_feature_flags)return;const i=this.Zd("$enabled_feature_flags")||{},r=e.$enabled_feature_flags||{},s=n.flags||n.featureFlags,a=n.flags?Object.entries(n.flags).filter(([,f])=>!f?.failed).map(([f])=>f):[],A=!!n.errorsWhileComputingFlags&&!!n.flags,c=A?a:o&&!qr(s)?Object.keys(s||{}):Array.from(new Set([...Object.keys(i),...Object.keys(r)])),l=this.Zd("$feature_flag_payloads")||{},u=e.$feature_flag_payloads||{},g=A||o?c:Array.from(new Set([...Object.keys(l),...Object.keys(u)])),h=!A&&!o,d=!!h||c,m=!!h||g,p={[dS]:d,[XB]:d,[rP]:m};e.$feature_flag_details&&(p[YR]=d);for(const f of[UR,tP,C$])Eo(e[f])||(p[f]=!0);this.Ad.markCrossTabFeatureFlagChanges(p)}Pt(e){this.Xd(()=>{var n;return(n=this.bo)===null||n===void 0?void 0:n.kv.remove(e)})}Xd(e){try{e()}catch(n){this.A.error("Failed to update feature flag persistence",n)}}zd(){const e={};for(const i of[dS,rP,UR,R7]){const r=this.Zd(i);Eo(r)||(e[i]=r)}this.ud=e;const n=Zt({},e),o=this.Zd(XB);if(o)for(const[i,r]of Object.entries(o))n[`$feature/${i}`]=r;this.hd=n}qd(){const e=this.Mr.cacheTtlMs;if(!e||0>=e)return!1;const n=this.Zd(tP);return typeof n!="number"||Date.now()-n>e}tv(){return!!this.qd()&&(this.wd||this.gd||(this.wd=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}ev(){const e=this.Mr.evaluationContexts;return e?.length?e.filter(n=>{const o=n&&typeof n=="string"&&n.trim().length>0;return o||this.A.error("Invalid evaluation context found:",n,"Expected non-empty string"),o}):[]}iv(){const e=this.Mr.flagKeys;if(!Eo(e))return e.filter(n=>{const o=n&&typeof n=="string"&&n.trim().length>0;return o||this.A.error("Invalid flag key found:",n,"Expected non-empty string"),o})}initialize(){var e,n;const o=this.Mr,i=(e=(n=o.bootstrap)===null||n===void 0?void 0:n.featureFlags)!==null&&e!==void 0?e:{};if(Object.keys(i).length){var r,s;const a=(r=(s=o.bootstrap)===null||s===void 0?void 0:s.featureFlagPayloads)!==null&&r!==void 0?r:{},A=Object.keys(i).filter(l=>!Eo(i[l])).reduce((l,u)=>(l[u]=i[u],l),{}),c=Object.keys(a).filter(l=>A[l]).reduce((l,u)=>(l[u]=a[u],l),{});return this.nv({featureFlags:A,featureFlagPayloads:c},void 0,{persist:!1})}}updateFlags(e,n,o){var i,r;const s=o?.merge&&(i=this.Zd("$enabled_feature_flags"))!==null&&i!==void 0?i:{},a=o?.merge&&(r=this.Zd("$feature_flag_payloads"))!==null&&r!==void 0?r:{},A=Zt(Zt({},s),e),c=Zt(Zt({},a),n),l={};for(const[u,g]of Object.entries(A))l[u]={key:u,enabled:rYt(g),variant:sYt(g),reason:void 0,metadata:Eo(c?.[u])?void 0:{id:0,version:void 0,description:void 0,payload:c[u]}};this.nv({flags:l})}get hasLoadedFlags(){return this.pd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const e=this.Zd(YR),n=this.Zd(R7),o=this.Zd(KR);if(!o&&!n)return e||{};const i=og({},e||{}),r=[...new Set([...Object.keys(o||{}),...Object.keys(n||{})])];for(const A of r){var s,a;const c=i[A],l=n?.[A],u=Eo(l)?(s=c?.enabled)!==null&&s!==void 0&&s:!!l,g=Eo(l)?c?.variant:typeof l=="string"?l:void 0,h=o?.[A],d=Zt(Zt({},c),{},{enabled:u,variant:u?g??c?.variant:void 0});u!==c?.enabled&&(d.original_enabled=c?.enabled),g!==c?.variant&&(d.original_variant=c?.variant),h&&(d.metadata=Zt(Zt({},c?.metadata),{},{payload:h,original_payload:c==null||(a=c.metadata)===null||a===void 0?void 0:a.payload})),i[A]=d}return this.ld||(this.A.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:o,finalDetails:i}),this.ld=!0),i}getAllFeatureFlags(){const e=this.getFlagVariants(),n=this.getFlagPayloads();return Object.keys(e).map(o=>{const i=e[o];return{key:o,enabled:rYt(i),variant:sYt(i),payload:iYt(n[o])}})}getFlagVariants(){const e=this.Zd(XB),n=this.Zd(R7);if(!n)return e||{};const o=og({},e||{}),i=Object.keys(n);for(let r=0;i.length>r;r++)o[i[r]]=n[i[r]];return this.ld||(this.A.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:n,finalFlags:o}),this.ld=!0),o}getFlagPayloads(){const e=this.Zd(rP),n=this.Zd(KR);if(!n)return e||{};const o=og({},e||{}),i=Object.keys(n);for(let r=0;i.length>r;r++)o[i[r]]=n[i[r]];return this.ld||(this.A.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:n,finalPayloads:o}),this.ld=!0),o}reloadFeatureFlags(){this.yd||this.Mr.featureFlagsDisabled||this.xd()||(this.gd&&(this.bd=!0),this.sv||(this.dd.slice().forEach(e=>{try{e()}catch(n){this.A.error("Error while running feature flags reloading callback",n)}}),this.sv=setTimeout(()=>{this.rv()},5)))}reloadFeatureFlagsAsync(){return!this.bo||this.yd||this.Mr.featureFlagsDisabled||this.Mr.remoteRequestsDisabled||this.xd()?Promise.resolve({status:"skipped"}):new Promise(e=>{this.vd.add(e),this.reloadFeatureFlags()})}Gd(e,n){e.forEach(o=>o({status:n})),e.clear()}Qd(){clearTimeout(this.sv),this.sv=void 0}onReloading(e){return this.dd.push(e),()=>{this.dd=this.dd.filter(n=>n!==e)}}ensureFlagsLoaded(){this.pd||this.gd||this.sv||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.yd=e}resetFlagCallReported(){this.Pt(iP)}rv(e){var n;this.Qd();const o=this.bo;if(!o||this.Mr.remoteRequestsDisabled||this.xd())return void this.Gd(this.vd,"skipped");if(this.gd)return void(this.bd=!0);const i={token:o.projectToken,distinct_id:o.distinctId,groups:o.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:Zt(Zt(Zt({},o.initialPersonProperties),this.Zd("$stored_person_properties")||{}),{},{$lib:o.library.name,$lib_version:o.library.version}),group_properties:this.Zd(nP),timezone:TUt()};Eo(o.deviceId)||(i.$device_id=o.deviceId),(e?.disableFlags||this.Mr.featureFlagsDisabled)&&(i.disable_flags=!0);const r=this.ev();r.length&&(i.evaluation_contexts=r);const s=this.iv();Eo(s)||(i.flag_keys=s);const a=this.Mr.onlyEvaluateSurveyFeatureFlags,A="/flags/?v=2"+(a?"&only_evaluate_survey_feature_flags=true":""),c=this.md,l=this.vd;this.vd=new Set,this.fd=l,this.gd=!0;const u=()=>{this.bd&&(this.bd=!1,this.rv())},g=f=>{var _,I;const C=(_=f.json)!==null&&_!==void 0?_:{},y=f.statusCode!==200;if(this.gd=!1,c!==this.md)return void u();if(this.ov(f.statusCode),y||this.bd||(this.$anon_distinct_id=void 0),i.disable_flags&&!this.bd)return void this.Gd(l,"skipped");this._d=!y;const x=[];f.error?x.push(f.error instanceof Error&&f.error.name==="AbortError"?"timeout":f.error instanceof Error?qKt:"unknown_error"):f.statusCode!==200&&x.push(`api_error_${f.statusCode}`),C.errorsWhileComputingFlags&&x.push("errors_while_computing_flags");const E=!!(!((I=C.quotaLimited)===null||I===void 0)&&I.includes("feature_flags"));E&&x.push("quota_limited"),this.$t({[I$]:x}),E?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."):i.disable_flags||this.nv(C,y,{partialResponse:a}),this.Gd(l,i.disable_flags?"skipped":x.length||!C.flags&&!C.featureFlags?"error":"loaded"),u()},h=f=>{this.gd=!1,c===this.md&&(this.$t({[I$]:[qKt]}),this.A.error("Feature flag request failed",f),this.Kd()&&this.Hd(!0),this.Gd(l,"error")),u()};let d=(n=this.Mr.requestMaxRetries)!==null&&n!==void 0?n:1;const m=()=>d>0&&c===this.md,p=()=>{if(c!==this.md||!this.bo||this.Mr.remoteRequestsDisabled)return this.gd=!1,this.Gd(l,"skipped"),void u();try{o.sendRequest(A,{target:"flags",method:"POST",body:i,compression:this.Mr.compression,sentAt:"body",timeoutMs:this.Mr.requestTimeoutMs}).then(f=>{if((_=>p$o.includes(_.statusCode)||(I=>I.statusCode===0&&I.error instanceof Error&&I.error.name==="AbortError")(_))(f)&&m())return d--,void setTimeout(p,500);g(f)}).catch(h)}catch(f){h(f)}};p()}xd(){return FUt(this.kd,3)}ov(e){this.kd=LUt(e,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(e,n={}){var o;if(n.fresh&&!this._d)return;if(!(this.pd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlag for key "'+e+CTe);if(this.tv())return;const i=this.getFeatureFlagResult(e,n);return(o=i?.variant)!==null&&o!==void 0?o:i?.enabled}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){const n=this.getFeatureFlagResult(e,{send_event:!1});return n?.payload}getFeatureFlagResult(e,n={}){if(n.fresh&&!this._d)return;if(!(this.pd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlagResult for key "'+e+CTe);if(this.tv())return;const o=this.getFlagVariants(),i=e in o,r=o[e],s=this.getFlagPayloads()[e],a=String(r),A=this.Zd("$feature_flag_request_id")||void 0,c=this.Zd("$feature_flag_evaluated_at")||void 0;let l,u=this.Zd("$flag_call_reported")||{};if(this.Mr.deduplicateCallsPerSession){var g;const Q=(g=this.bo)===null||g===void 0?void 0:g.session.sessionId,w=this.Zd(y$);Q&&Q!==w&&(u={},l=Q)}if(!n.send_event&&"send_event"in n)l&&this.$t({[iP]:u,[y$]:l});else if(e in u&&u[e].includes(a))l&&this.$t({[iP]:u,[y$]:l});else{var h,d,m,p,f,_,I,C,y,x,E,B,S;qr(u[e])?u[e].push(a):u[e]=[a],this.$t(Zt({[iP]:u},l?{[y$]:l}:{}));const Q=this.getFeatureFlagDetails(e),w=[...(h=this.Zd("$feature_flag_errors"))!==null&&h!==void 0?h:[]];Eo(r)&&w.push("flag_missing");const M={$feature_flag:e,$feature_flag_response:r,$feature_flag_payload:s??null,$feature_flag_request_id:A,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:(d=(m=this.Mr.bootstrap)===null||m===void 0||(m=m.featureFlags)===null||m===void 0?void 0:m[e])!==null&&d!==void 0?d:null,$feature_flag_bootstrapped_payload:(p=(f=this.Mr.bootstrap)===null||f===void 0||(f=f.featureFlagPayloads)===null||f===void 0?void 0:f[e])!==null&&p!==void 0?p:null,$used_bootstrap_value:!this._d};Eo(Q==null||(_=Q.metadata)===null||_===void 0?void 0:_.has_experiment)||(M.$feature_flag_has_experiment=Q.metadata.has_experiment),Eo(Q==null||(I=Q.metadata)===null||I===void 0?void 0:I.version)||(M.$feature_flag_version=Q.metadata.version);const T=(C=Q==null||(y=Q.reason)===null||y===void 0?void 0:y.description)!==null&&C!==void 0?C:Q==null||(x=Q.reason)===null||x===void 0?void 0:x.code;T&&(M.$feature_flag_reason=T),!(Q==null||(E=Q.metadata)===null||E===void 0)&&E.id&&(M.$feature_flag_id=Q.metadata.id),Eo(Q?.original_variant)&&Eo(Q?.original_enabled)||(M.$feature_flag_original_response=Eo(Q.original_variant)?Q.original_enabled:Q.original_variant),!(Q==null||(B=Q.metadata)===null||B===void 0)&&B.original_payload&&(M.$feature_flag_original_payload=Q==null||(S=Q.metadata)===null||S===void 0?void 0:S.original_payload),w.length&&(M.$feature_flag_error=w.join(",")),this.av(M)}return i?{key:e,enabled:!!r,variant:typeof r=="string"?r:void 0,payload:iYt(s)}:void 0}av(e){try{var n;(n=this.bo)===null||n===void 0||n.capture("$feature_flag_called",e)}catch(o){this.A.error("Failed to capture feature flag call",o)}}getRemoteConfigPayload(e,n){this.lv(e,n)}lv(e,n){var o=this;return ng(function*(){const i=o.bo;if(!i)return;const r={distinct_id:i.distinctId,token:i.projectToken,person_properties:{$lib:i.library.name,$lib_version:i.library.version}},s=o.ev();s.length&&(r.evaluation_contexts=s);const a=o.iv();let A;Eo(a)||(r.flag_keys=a);try{var c;const l=(c=(yield i.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:r,compression:o.Mr.compression,sentAt:"body",timeoutMs:o.Mr.requestTimeoutMs})).json)===null||c===void 0?void 0:c.featureFlagPayloads;A=l?.[e]||void 0}catch(l){return void o.A.error("Remote config feature flag request failed",l)}try{n(A)}catch(l){o.A.error("Remote config feature flag callback failed",l)}})()}isFeatureEnabled(e,n={}){if(n.fresh&&!this._d)return n.defaultValue;if(!(this.pd||this.getFlags()&&this.getFlags().length>0))return this.A.warn('isFeatureEnabled for key "'+e+CTe),n.defaultValue;const o=this.getFeatureFlag(e,n);return Eo(o)?n.defaultValue:!!o}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(n=>n!==e)}receivedFeatureFlags(e,n,o){this.nv(e,n,o)}nv(e,n,o){if(!this.bo)return;this.pd=!0;const i=((r,s={},a={},A={},c,l=WKt)=>{const u=((C,y)=>{const x=C.flags;if(x){const E=Object.fromEntries(Object.keys(x).map(S=>{var Q;return[S,(Q=x[S].variant)!==null&&Q!==void 0?Q:x[S].enabled]})),B=Object.fromEntries(Object.keys(x).filter(S=>x[S].enabled).filter(S=>{var Q;return!Eo((Q=x[S].metadata)===null||Q===void 0?void 0:Q.payload)}).map(S=>{var Q;return[S,(Q=x[S].metadata)===null||Q===void 0?void 0:Q.payload]}));return Zt(Zt({},C),{},{featureFlags:E,featureFlagPayloads:B})}return C.featureFlags&&y.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),C})(r,l),g=u.flags,h=u.featureFlags,d=u.featureFlagPayloads;if(!h)return;const m=r.requestId,p=r.evaluatedAt;if(qr(h)){l.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const C={};if(h)for(let y=0;h.length>y;y++)C[h[y]]=!0;return{[dS]:h,[XB]:C,[C$]:!1}}let f=h,_=d,I=g;if(c?.partialResponse){const C=Object.keys(f),y=_||{};f=Zt(Zt({},s),f),_=Zt(Zt({},a),y),C.forEach(x=>{x in y||_==null||delete _[x]}),I=Zt(Zt({},A),I)}else if(r.errorsWhileComputingFlags)if(g){const C=new Set(Object.keys(g).filter(x=>{var E;return!(!((E=g[x])===null||E===void 0)&&E.failed)}));f=Zt(Zt({},s),Object.fromEntries(Object.entries(f).filter(([x])=>C.has(x))));const y=Object.fromEntries(Object.entries(_||{}).filter(([x])=>C.has(x)));_=Zt(Zt({},a),y),C.forEach(x=>{x in y||_==null||delete _[x]}),I=Zt(Zt({},A),Object.fromEntries(Object.entries(I||{}).filter(([x])=>C.has(x))))}else f=Zt(Zt({},s),f),_=Zt(Zt({},a),_),I=Zt(Zt({},A),I);return Zt(Zt({[dS]:Object.keys(XKt(f)),[XB]:f||{},[rP]:_||{},[YR]:I||{},[C$]:r.minimalFlagCalledEvents===!0},m?{[UR]:m}:{}),p?{[tP]:p}:{})})(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),o,this.A);if(i)if(o?.persist===!1){const r=!Eo(this.bo.kv.get(XB));this.Jd=i,r||this.$t(i)}else this.Bd(),this.Yd(i,e,!!o?.partialResponse),this.$t(i);else n&&this.Kd();n||(this.wd=!1),this.Hd(n)}override(e,n=!1){this.A.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:n})}overrideFeatureFlags(e){this.uv(e)}uv(e){if(this.bo){if(e===!1)return this.Pt([R7,KR]),this.Hd(),void qR.info("All overrides cleared");if(qr(e))return this.$t({[R7]:$Kt(e)}),this.Hd(),void qR.info("Flag overrides set",{flags:e});if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var n;const o=e;this.ld=!!((n=o.suppressWarning)!==null&&n!==void 0&&n);const i={},r=o.flags,s=o.payloads;return r&&(i[R7]=qr(r)?$Kt(r):r),s&&(i[KR]=s),Object.keys(i).length&&this.$t(i),r===!1&&s===!1?this.Pt([R7,KR]):r===!1?this.Pt(R7):s===!1&&this.Pt(KR),this.Hd(),r===!1?qR.info("Flag overrides cleared"):r&&qR.info("Flag overrides set",{flags:r}),void(s===!1?qR.info("Payload overrides cleared"):s&&qR.info("Payload overrides set",{payloads:s}))}if(e&&typeof e=="object")return this.$t({[R7]:e}),this.Hd(),void qR.info("Flag overrides set",{flags:e});this.A.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}else this.A.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.pd){const{flags:n,flagVariants:o}=this.hv();try{e(n,o)}catch(i){this.A.error("Error while running feature flags callback",i)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,n,o){var i;const r=(this.Zd("$early_access_features")||[]).find(l=>l.flagKey===e),s={[`$feature_enrollment/${e}`]:n},a={$feature_flag:e,$feature_enrollment:n,$set:s};r&&(a.$early_access_feature_name=r.name),o&&(a.$feature_enrollment_stage=o);const A=Zt(Zt({},this.getFlagVariants()),{},{[e]:n});(i=this.Ad)===null||i===void 0||i.markCrossTabFeatureFlagChanges({$active_feature_flags:[e],$enabled_feature_flags:[e],$stored_person_properties:Object.keys(s)}),this.$t({[dS]:Object.keys(XKt(A)),[XB]:A,[oP]:Zt(Zt({},this.Zd("$stored_person_properties")||{}),s)}),this.Hd();try{var c;(c=this.bo)===null||c===void 0||c.capture("$feature_enrollment_update",a)}catch(l){this.A.error("Failed to capture early access feature enrollment",l)}}getEarlyAccessFeatures(e,n=!1,o){const i=this.Zd(hRe);!i||n?this.dv(e,o):e(i)}dv(e,n){var o=this;return ng(function*(){const i=o.bo;if(!i)return;const r=n?`&${n.map(a=>`stage=${a}`).join("&")}`:"";let s;try{const a=yield i.sendRequest(`/api/early_access_features/?token=${i.projectToken}${r}`,{target:"api",method:"GET",sentAt:"query"});if(!a.json)return;s=a.json.earlyAccessFeatures,o.$t({[hRe]:s})}catch(a){return void o.A.error("Early access feature request failed",a)}try{e(s)}catch(a){o.A.error("Early access feature callback failed",a)}})()}hv(){const e=this.getFlags(),n=this.getFlagVariants();return{flags:e.filter(o=>n[o]),flagVariants:Object.keys(n).filter(o=>n[o]).reduce((o,i)=>(o[i]=n[i],o),{})}}Hd(e){this.zd();const{flags:n,flagVariants:o}=this.hv();this.featureFlagEventHandlers.forEach(i=>{try{i(n,o,{errorsLoading:e})}catch(r){this.A.error("Error while running feature flags callback",r)}})}setPersonPropertiesForFlags(e,n=!0){this.vv(e,n)}vv(e,n=!0){const o=this.Zd("$stored_person_properties")||{},i=e?.$set||(e?.$set_once?{}:e),r=e?.$set_once,s={};if(r)for(const a in r)({}).hasOwnProperty.call(r,a)&&(a in o||(s[a]=r[a]));this.$t({[oP]:Zt(Zt(Zt({},o),s),i)}),n&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,n=!0){const o=Zt({},this.Zd("$stored_person_properties")||{});e.forEach(i=>{delete o[i]}),this.$t({[oP]:o}),n&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e=!0){this.Pt(oP),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,n=!0){const o=this.Zd("$stored_group_properties")||{},i=Zt({},o);for(const r of Object.keys(e))i[r]=Zt(Zt({},o[r]),e[r]);this.$t({[nP]:i}),n&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){const n=this.Zd("$stored_group_properties")||{};this.$t({[nP]:Zt(Zt({},n),{},{[e]:{}})})}else this.Pt(nP)}reset(){this.md++,this.Gd(this.vd,"cancelled"),this.Gd(this.fd,"cancelled"),this.bd=!1,this.ud={},this.hd={},this.Jd=void 0,this.pd=!1,this.yd=!1,this._d=!1,this.$anon_distinct_id=void 0,this.Qd(),this.ld=!1,this.kd=0}};const ZKt=xd("[FeatureFlags]");var _$o=class{constructor(e,n=!1){this.fv=!1,this.update(e,n)}update(e,n){this.pv=((o,i)=>{var r,s,a,A,c,l,u,g;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:(u=(g=o.evaluation_contexts)!==null&&g!==void 0?g:o.evaluation_environments)!==null&&u!==void 0?u:[],flagKeys:qr(o.flag_keys)?o.flag_keys:void 0}})(e,n),!e.evaluation_environments||e.evaluation_contexts||this.fv||(ZKt.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.fv=!0),Eo(e.flag_keys)||qr(e.flag_keys)||ZKt.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this.pv}};const ezt=t=>_G(t)&&(t.name==="RangeError"&&t.message.indexOf("Maximum call stack size exceeded")===0||t.name==="InternalError"&&t.message==="too much recursion"),n9=xd("[Error tracking]"),yTe="webkit-masked-url:",I$o=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],C$o=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",yTe],y$o=["__firefox__","__gCrWeb"],tzt="Refusing to render web experiment since the viewer is a likely bot",x$o={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>Tde(e,t),not_regex:(t,e)=>!Tde(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t},B4=xd("[Conversations]"),$R="Conversations not available yet.";function nzt(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,u=e?.consoleCapture?void 0:(i=t?.maxLogsPerInterval)!==null&&i!==void 0?i:1e3,g=Eo(u)?Math.max(l,2048):Math.max(l,u),h=Zt(Zt({},(function(){let d="",m="";try{const p=I_?.userAgent;p&&([d,m]=OGt(p))}catch{}return(function(p,f){const _=(function(I){if(I)return{}.hasOwnProperty.call(yYt,I)?yYt[I]:I})(p);return Zt(Zt({},_?{"os.name":_}:{}),f?{"os.version":f}:{})})(d,m)})()),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:g,maxBatchRecordsPerPost:100,rateCapWindowMs:c,maxLogsPerInterval:u,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const E$o=["debug","log","warn","error","info"],B$o=t=>{for(;t?.__rrweb_original__;)t=t.__rrweb_original__;return t},ozt="console",izt="__posthogHandledLogsRequestError",xTe=(t,e)=>{const n=t instanceof Error?t:new Error(e);return n[izt]=!0,n},rzt=t=>!!t&&typeof t=="object"&&t[izt]===!0,Lde=xd("[NetworkMetrics]"),ETe=()=>{var t;return!(jn==null||(t=jn.performance)===null||t===void 0)&&t.now?jn.performance.now():Date.now()},b$o={"http:":80,"https:":443},S$o=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),szt=(t,e)=>{var n;const o=String(e);return{method:String(t).toUpperCase(),url:((n=mS(o))===null||n===void 0?void 0:n.href)||o}},BTe=(t,e,n,o,i,r,s=!1)=>{try{var a,A;const c=i();if(!c)return;const l=n||void 0,u=ETe()-o,g=mS(e.url);if(g&&g.protocol!=="http:"&&g.protocol!=="https:")return;const h={url:g?.href||e.url,method:e.method},d=pp(c.name)?c.name(h):Za(c.name)?c.name:"http.client.request.duration";if(!d)return;const m=s&&!l?void 0:((f,_)=>f?400>f?void 0:String(f):_?.name||"_OTHER")(l,r),p=Zt(Zt(Zt(Zt(Zt({},(f=>{const _=S$o.has(f)?f:"_OTHER";return Zt({"http.request.method":_},_==="_OTHER"&&f!==_?{"http.request.method_original":f}:{})})(h.method)),g?(f=>{return{"server.address":f.hostname.startsWith("[")&&f.hostname.endsWith("]")?f.hostname.slice(1,-1):f.hostname,"server.port":Number(f.port)||b$o[f.protocol],"url.scheme":f.protocol.slice(0,-1),"url.template":(_=f.pathname,_.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 _})(g):{}),l?{"http.response.status_code":l}:{}),m?{"error.type":m}:{}),(a=c.attributes)===null||a===void 0?void 0:a.call(c,h,{status:l,durationMs:u}));(A=t.metrics)===null||A===void 0||A.histogram(d,u,{unit:"ms",attributes:p})}catch(c){Lde.error("Failed to record network metric",c)}},azt=()=>{},Q$o=(t,e)=>pp(jn?.fetch)?LG(jn,"fetch",n=>function(...o){const i=ETe(),r=n.apply(this,o);if(!e())return r;try{var s,a,A;const[c,l]=o,u=szt((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(g=>(BTe(t,u,g?.status,i,e,void 0,!0),g),g=>{throw BTe(t,u,void 0,i,e,g),g})}catch(c){return Lde.error("Failed to observe fetch",c),r}}):azt,v$o=(t,e)=>{var n;const o=jn==null||(n=jn.XMLHttpRequest)===null||n===void 0?void 0:n.prototype;if(!o)return azt;const i=new WeakMap,r=LG(o,"open",a=>function(...A){try{aKt.has(this)||i.set(this,szt(A[0],A[1]))}catch(c){Lde.error("Failed to observe XHR open",c)}return a.apply(this,A)}),s=LG(o,"send",a=>function(...A){let c;try{const l=i.get(this);if(l&&e()){const u=ETe();c=()=>{this.removeEventListener("loadend",c),BTe(t,l,this.status,u,e)},Zc(this,"loadend",c)}}catch(l){Lde.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()}},Azt=new WeakMap,w$o={maxStringLength:2048,truncationSuffix:"..."};function czt(t){if(t)return t===!0?{intent:!0,model:!0}:{intent:t.intent!==!1,model:t.model!==!1}}function AP(t,e){return{}.hasOwnProperty.call(t,e)}function bTe(t,e){const n=Object.create(t);return e&&Object.defineProperty(n,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:e}),n}function lzt(t,e,n=!1){if(!Za(t))return;const o=t.trim();return o?(n?ljo(o,w$o):o).slice(0,e):void 0}function uzt(t){try{return va(t)&&t.isError===!0}catch{return!1}}const Hde={featureFlags:class extends f$o{constructor(t){const e=new _$o(t.config,t.il());super(e),this.name="featureFlags",this._instance=t,this.gv=e}get Ad(){return this._instance.persistence}updateConfig(t,e){this.gv.update(t,e),this.Fd()}}},P$o={sessionRecording:class{get Mr(){return this._instance.config}get Il(){return this._instance.persistence}get started(){var t;return!!(!((t=this.mv)===null||t===void 0)&&t.isStarted)}get status(){var t,e;return this.yv==="awaiting_config"||this.yv==="missing_config"?this.yv:(t=(e=this.mv)===null||e===void 0?void 0:e.status)!==null&&t!==void 0?t:this.yv}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.yv=fTe,this.bv=void 0,this._v=!1,this.Je=(()=>{var e,n;if(!qo?.visibilityState||qo.visibilityState==="visible")return!0;const o=jn==null||(e=jn.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;qo?.visibilityState==="visible"&&(this.Je=!0,(e=this.mv)===null||e===void 0||(n=e.setDocumentWasEverVisible)===null||n===void 0||n.call(e,!0))},!this._instance.sessionManager)throw _S.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"');qo?.addEventListener&&Zc(qo,"visibilitychange",this.sn)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:t=!1}={}){var e;this._v=!0,qo==null||(e=qo.removeEventListener)===null||e===void 0||e.call(qo,"visibilitychange",this.sn),t?this.wv(!0):this.stopRecording()}get Sv(){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 jn&&e&&n&&!o}startIfEnabledOrStop(t){var e;if(this._v||this.Sv&&(!((e=this.mv)===null||e===void 0)&&e.isStarted))return;const n=!Eo(Object.assign)&&!Eo(Array.from);this.Sv&&n?(this.xv(t),_S.info("starting")):(this.yv=fTe,this.stopRecording())}xv(t){var e,n;if(this.Sv)if(this.yv!=="awaiting_config"&&this.yv!=="missing_config"&&(this.yv=YKt),(Kr==null||(e=Kr.__PosthogExtensions__)===null||e===void 0||(e=e.rrweb)===null||e===void 0?void 0:e.record)&&((n=Kr.__PosthogExtensions__)===null||n===void 0?void 0:n.initSessionRecording))this.$v(t);else{var o,i;const r=this._instance.sessionManager;(o=Kr.__PosthogExtensions__)===null||o===void 0||(i=o.loadExternalDependency)===null||i===void 0||i.call(o,this._instance,this.Cv,s=>{if(!this._v&&this.Sv&&this._instance.sessionManager===r)return s?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),_S.error("could not load recorder",s)):void this.$v(t);this.yv="disabled"})}}stopRecording(){var t,e;(t=this.bv)===null||t===void 0||t.call(this),this.bv=void 0,(e=this.mv)===null||e===void 0||e.stop()}wv(t=!1){var e,n;(e=this.bv)===null||e===void 0||e.call(this),this.bv=void 0,(n=this.mv)===null||n===void 0||n.discard({discardProducerEvents:t})}Tv(){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")}Iv(t,e){if(Hs(t))return null;const n=gh(t)?t:parseFloat(t);return typeof(o=n)!="number"||!Number.isFinite(o)||0>o||o>1?(_S.warn(`${e} must be between 0 and 1. Ignoring invalid value:`,t),null):n;var o}Mv(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.Iv((r=this.Mr.session_recording)===null||r===void 0?void 0:r.sampleRate,"session_recording.sampleRate"),A=this.Iv(s?.sampleRate,"remote config sampleRate"),c=a??A;Hs(c)&&this.Tv();const l=s?.minimumDurationMilliseconds;o.register({[B$]:Zt(Zt({cache_timestamp:Date.now(),enabled:!!s},s),{},{networkPayloadCapture:Zt({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.bv)===null||e===void 0||e.call(this),this.bv=(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.Mv(e),void this.wv()):(this.Mv(e),void this.startIfEnabledOrStop()):(this.yv==="awaiting_config"&&(this.yv="missing_config",this._instance.register_for_session({[wRe]:!0}),_S.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e="log"){var n;!((n=this.mv)===null||n===void 0)&&n.log?this.mv.log(t,e):_S.warn("log called before recorder was ready")}get Cv(){var t,e;const n=(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0?void 0:t.get_property(B$);return(n==null||(e=n.scriptConfig)===null||e===void 0?void 0:e.script)||"lazy-recorder"}Ev(){const t=this._instance.get_property(B$);if(!t)return!1;let e;try{e=typeof t=="object"?t:JSON.parse(t)}catch(n){return _S.warn("persisted remote config for session recording is invalid and will be ignored",n),!1}return!Hs(e.cache_timestamp)&&36e5>=Date.now()-e.cache_timestamp}$v(t){var e,n,o;if(!this._v&&this.Sv&&this._instance.sessionManager){if(!(!((e=Kr.__PosthogExtensions__)===null||e===void 0)&&e.initSessionRecording))return _S.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[vRe]:!0});var i;if(this.mv||(this.mv=(i=Kr.__PosthogExtensions__)===null||i===void 0?void 0:i.initSessionRecording(this._instance,this.Je),this.mv._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Ev())return this.yv==="missing_config"||this.yv==="awaiting_config"?void 0:(this.yv="awaiting_config",_S.info("persisted remote config is stale, requesting fresh config before starting"),void new $Ut(this._instance).load());this.yv=YKt,(n=(o=this.mv).setDocumentWasEverVisible)===null||n===void 0||n.call(o,this.Je),this.mv.start(t)}else this.yv=fTe}onRRwebEmit(t){var e,n;(e=this.mv)===null||e===void 0||(n=e.onRRwebEmit)===null||n===void 0||n.call(e,t)}overrideLinkedFlag(){var t,e;this.mv||(e=this.Il)===null||e===void 0||e.register({$replay_override_linked_flag:!0}),(t=this.mv)===null||t===void 0||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.mv||(e=this.Il)===null||e===void 0||e.register({$replay_override_sampling:!0}),(t=this.mv)===null||t===void 0||t.overrideSampling()}overrideTrigger(t){var e,n;this.mv||(n=this.Il)===null||n===void 0||n.register({[t==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(e=this.mv)===null||e===void 0||e.overrideTrigger(t)}get sdkDebugProperties(){var t;const e={};for(const o of s$o){var n;const i=(n=this._instance.sessionPersistence)===null||n===void 0?void 0:n.get_property(o);Eo(i)||(e[o]=i)}return Zt(Zt({},e),((t=this.mv)===null||t===void 0?void 0:t.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(t,e){var n;return!!(!((n=this.mv)===null||n===void 0)&&n.tryAddCustomEvent(t,e))}flushBeforeIdentityReset(){var t,e;(t=this.mv)===null||t===void 0||(e=t.flushBeforeIdentityReset)===null||e===void 0||e.call(t)}}},M$o={autocapture:class extends t$o{constructor(t){super(new n$o(t)),this.instance=t}},historyAutocapture:class{constructor(t){this.Pv=!1,this._instance=t,this.Rv=this.Av()}initialize(){this.startIfEnabled()}get isEnabled(){const t=this.Fv();return!!(t.path||t.search||this.Ov(t))}startIfEnabled(){this.isEnabled&&(li.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.Rv=this.Av(),this.startIfEnabled()}stop(){this.Dv&&this.Dv(),this.Dv=void 0,this.Lv&&this.Lv(),this.Lv=void 0,li.info("History API monitoring stopped")}monitorHistoryChanges(){jn&&jn.history&&(this.Nv("pushState"),this.Nv("replaceState"),this.qv(),this.Ov()&&this.jv())}Nv(t){var e;if(!jn||!((e=jn.history[t])===null||e===void 0)&&e.__posthog_wrapped__)return;const n=this;LG(jn.history,t,o=>function(i,r,s){var a;n.Bv(s)&&n.zv(),o.call(this,i,r,s),n.Hv(t,!n.Pv&&(jn==null||(a=jn.event)===null||a===void 0?void 0:a.type)!=="popstate")})}Av(){const t=jn?.location;if(t?.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}Fv(){const t=this._instance.config.capture_pageview;return t==="history_change"?{path:!0}:va(t)?t:{}}Ov(t=this.Fv()){return!!t.hash&&!this._instance.config.disable_capture_url_hashes}Uv(t){const e=this.Fv(),n=this.Rv;return!(!n||!(e.path&&t.pathname!==n.pathname||e.search&&t.search!==n.search||this.Ov(e)&&t.hash!==n.hash))}Hv(t,e=!1){try{e||this.zv();const n=this.Av();if(!n)return;if(this.Uv(n)){const o=()=>this._instance.capture(MRe,{navigation_type:t});e?(this.Wv=o,Promise.resolve().then(()=>this.zv())):o()}this.Rv=n}catch(n){li.error(`Error capturing ${t} pageview`,n)}}Bv(t){var e,n;return!(Hs(t)||!jn)&&((e=mS(String(t)))===null||e===void 0?void 0:e.href)!==((n=jn.location)===null||n===void 0?void 0:n.href)}zv(){const t=this.Wv;if(t){this.Wv=void 0,this.Pv=!0;try{t()}catch(e){li.error("Error capturing deferred pageview",e)}finally{this.Pv=!1}this.Rv=this.Av()}}qv(){if(this.Dv)return;const t=()=>{this.Hv("popstate")};Zc(jn,"popstate",t),this.Dv=()=>{jn&&jn.removeEventListener("popstate",t)}}jv(){if(this.Lv)return;const t=()=>{this.Hv("hashchange")};Zc(jn,"hashchange",t),this.Lv=()=>{jn&&jn.removeEventListener("hashchange",t)}}},heatmaps:class{get Mr(){return this.instance.config}constructor(t){var e;this.Vv=!1,this.ko=!1,this.Gv=null,this.instance=t,this.Vv=!!(!((e=this.instance.persistence)===null||e===void 0)&&e.props[_Re]),this.rageclicks=new FKt(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let t=5e3;return va(this.Mr.capture_heatmaps)&&this.Mr.capture_heatmaps.flush_interval_milliseconds&&(t=this.Mr.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return Hs(this.Mr.capture_heatmaps)?Hs(this.Mr.enable_heatmaps)?this.Vv:this.Mr.enable_heatmaps:this.Mr.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.ko)return;a$o.info("starting..."),this.Qv(),this.sn()}else{var t;clearInterval((t=this.Gv)!==null&&t!==void 0?t:void 0),this.Zv(),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({[_Re]:n}),this.Vv=n,this.startIfEnabled()}getAndClearBuffer(){const t=this.Rt;return this.Rt=void 0,t}Jv(t){_Te(t.originalEvent)&&this.Ir(t.originalEvent,"deadclick")}sn(){this.Gv&&clearInterval(this.Gv),this.Gv=qo?.visibilityState==="visible"?setInterval(this.fl.bind(this),this.flushIntervalMilliseconds):null}Qv(){jn&&qo&&(this.Kv=this.fl.bind(this),Zc(jn,Ede,this.Kv),this.Xv=t=>this.Ir(t||jn?.event),Zc(qo,"click",this.Xv,{capture:!0}),this.Yv=t=>this.tf(t||jn?.event),Zc(qo,"mousemove",this.Yv,{capture:!0}),this.ef=new PUt(this.instance,aqo,this.Jv.bind(this)),this.ef.startIfEnabledOrStop(),this.if=this.sn.bind(this),Zc(qo,x$,this.if),this.ko=!0)}Zv(){var t;jn&&qo&&(this.Kv&&jn.removeEventListener(Ede,this.Kv),this.Xv&&qo.removeEventListener("click",this.Xv,{capture:!0}),this.Yv&&qo.removeEventListener("mousemove",this.Yv,{capture:!0}),this.if&&qo.removeEventListener(x$,this.if),clearTimeout(this.nf),(t=this.ef)===null||t===void 0||t.stop(),this.ko=!1)}sf(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&&t9(c)&&!BI(c,"body");){if(c===A)return!1;let h;try{var l,u,g;h=(l=(u=(g=c.ownerDocument)===null||g===void 0?void 0:g.defaultView)!==null&&u!==void 0?u:jn)===null||l===void 0?void 0:l.getComputedStyle(c).position}catch{return!1}if(jr(a,h))return!0;c=pUt(c)}return!1})(w$(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(gUt(t.target)||!_Te(t))return;const o=this.sf(t,e);!((n=this.rageclicks)===null||n===void 0)&&n.isRageClick(t.clientX,t.clientY,new Date().getTime())&&yUt(w$(t),this.instance.config.rageclick)&&this.Qs(Zt(Zt({},o),{},{type:"rageclick"})),this.Qs(o)}tf(t){!gUt(t.target)&&_Te(t)&&(clearTimeout(this.nf),this.nf=setTimeout(()=>{this.Qs(this.sf(t,"mousemove"))},500))}Qs(t){if(!jn)return;const e=this.Mr.disable_capture_url_hashes?eP(jn.location.href):jn.location.href,n=this.Mr.custom_personal_data_properties,o=this.Mr.mask_personal_data_properties?[...DG,...n||[]]:[],i=D$(e,o,N$);this.Rt=this.Rt||{},this.Rt[i]||(this.Rt[i]=[]),this.Rt[i].push(t)}fl(){this.Rt&&!Jx(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:PUt,webVitalsAutocapture:class{constructor(t){var e;this._instance=t,this.Vv=!1,this.ko=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.rf=()=>{clearTimeout(this.af),this.af=void 0,this.Rt.metrics.length!==0&&(this._instance.capture("$web_vitals",Zt({$current_url:this.Rt.url},this.Rt.metrics.reduce((n,o)=>Zt(Zt({},n),{},{[`$web_vitals_${o.name}_event`]:Zt({},o),[`$web_vitals_${o.name}_value`]:o.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.lf=n=>{var o;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},Hs(n?.name)||Hs(n?.value))return void jR.error("Invalid metric received",n);const i=typeof n.navigationURL=="string"?n.navigationURL:void 0,r=this.uf(i);if(Eo(r))return;const s=gh(n.navigationId)||typeof n.navigationId=="string"?`navigation:${n.navigationId}`:`url:${r}`;if(this.cf&&n.value>=this.cf)return void jR.error("Ignoring metric with value >= "+this.cf,n);this.Rt.navigationKey!==s&&(this.rf(),this.af=setTimeout(this.rf,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=Zt(Zt(Zt({},n),i?{navigationURL:r}:{}),{},{$current_url:r,timestamp:Date.now()});if(delete A.entries,va(n.attribution)&&this.attributionMetrics.indexOf(n.name)>-1){const c={};for(const l of r$o){const u=l==="url"&&typeof n.attribution[l]=="string"?this.uf(n.attribution[l]):n.attribution[l];Eo(u)||(c[l]=u)}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.rf()},this.hf=()=>{if(this.ko)return;let n,o,i,r,s=!1;const a=Kr.__PosthogExtensions__,A=a?.postHogWebVitalsCallbacksByFlavor,c=A?.[this.df]||(this.df==="web-vitals"&&Eo(A)?a?.postHogWebVitalsCallbacks:void 0);if(!Eo(c)){const g=c.withoutAttribution,h=this.attributionMetrics;s=!Eo(g),n=h.indexOf("LCP")>-1?c.onLCP:g?.onLCP||c.onLCP,o=h.indexOf("CLS")>-1?c.onCLS:g?.onCLS||c.onCLS,i=h.indexOf("FCP")>-1?c.onFCP:g?.onFCP||c.onFCP,r=h.indexOf("INP")>-1?c.onINP:g?.onINP||c.onINP}if(!(n&&o&&i&&r))return void jR.error("web vitals callbacks not loaded - not starting");const l={reportSoftNavs:this.useSoftNavs},u=s&&this.attributionMetrics.indexOf("INP")>-1?Zt(Zt({},l),{},{includeProcessedEventEntries:!1}):l;this.allowedMetrics.indexOf("LCP")>-1&&n(this.lf.bind(this),l),this.allowedMetrics.indexOf("CLS")>-1&&o(this.lf.bind(this),l),this.allowedMetrics.indexOf("FCP")>-1&&i(this.lf.bind(this),l),this.allowedMetrics.indexOf("INP")>-1&&r(this.lf.bind(this),u),this.ko=!0},this.Vv=!!(!((e=this._instance.persistence)===null||e===void 0)&&e.props[yRe]),this.startIfEnabled()}get vf(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e;const n=va(this.vf)?(t=this.vf)===null||t===void 0?void 0:t.web_vitals_allowed_metrics:void 0;return Hs(n)?((e=this._instance.persistence)===null||e===void 0?void 0:e.props.$web_vitals_allowed_metrics)||GKt:n}get flushToCaptureTimeoutMs(){return(va(this.vf)?this.vf.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const t=va(this.vf)?this.vf.web_vitals_attribution:void 0;return u2(t)?t?GKt:[]:qr(t)?t:i$o}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const t=va(this.vf)?this.vf.__preview_web_vitals_soft_navs:void 0;return t!=null&&t}get cf(){const t=va(this.vf)&&gh(this.vf.__web_vitals_max_value)?this.vf.__web_vitals_max_value:OKt;return t>0&&6e4>=t?OKt:t}get isEnabled(){const t=tg?.protocol;if(t!=="http:"&&t!=="https:")return jR.info("Web Vitals are disabled on non-http/https protocols"),!1;const e=va(this.vf)?this.vf.web_vitals:u2(this.vf)?this.vf:void 0;return u2(e)?e:this.Vv}startIfEnabled(){this.isEnabled&&!this.ko&&(jR.info("enabled, starting..."),this.zo(this.hf))}onRemoteConfig(t){if(!t.ok)return;const e=t.config;if(!("capturePerformance"in e))return;const n=va(e.capturePerformance)&&!!e.capturePerformance.web_vitals,o=va(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[yRe]:n}),this._instance.persistence.register({[FYt]:o})),this.Vv=n,this.startIfEnabled()}get df(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}zo(t){var e;const n=Kr.__PosthogExtensions__,o=this.df,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?jR.error("failed to load script",r):t()})}uf(t){const e=t||jn?.location.href;if(!e)return void jR.error("Could not determine current URL");const n=this._instance.config.disable_capture_url_hashes?eP(e):e,o=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...DG,...o||[]]:[];return D$(n,i,N$)}}},D$o={exceptionObserver:class{constructor(t){var e;this.hf=()=>{var n;if(!jn||!this.isEnabled||!(!((n=Kr.__PosthogExtensions__)===null||n===void 0)&&n.errorWrappingFunctions))return;const o=Kr.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Kr.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=Kr.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.ff&&this.Mr.capture_unhandled_errors&&(this.ff=o(this.captureException.bind(this))),!this.pf&&this.Mr.capture_unhandled_rejections&&(this.pf=i(this.captureException.bind(this))),!this.gf&&this.Mr.capture_console_errors&&(this.gf=r(this.captureException.bind(this)))}catch(s){U$.error("failed to start",s),this.mf()}},this._instance=t,this.yf=!!(!((e=this._instance.persistence)===null||e===void 0)&&e.props[IRe]),this.wt=new ZJo(Zt(Zt({},(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:U$})),this.Mr=this.bf(),this.startIfEnabledOrStop()}bf(){const t=this._instance.config.capture_exceptions;let e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return va(t)?e=Zt(Zt({},e),t):(Eo(t)?this.yf:t)&&(e=Zt(Zt({},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?(U$.info("enabled"),this.mf(),this.zo(this.hf)):this.mf()}zo(t){var e,n,o;!((e=Kr.__PosthogExtensions__)===null||e===void 0)&&e.errorWrappingFunctions?t():(n=Kr.__PosthogExtensions__)===null||n===void 0||(o=n.loadExternalDependency)===null||o===void 0||o.call(n,this._instance,"exception-autocapture",i=>{if(i)return U$.error("failed to load script",i);t()})}mf(){var t,e,n;(t=this.ff)===null||t===void 0||t.call(this),this.ff=void 0,(e=this.pf)===null||e===void 0||e.call(this),this.pf=void 0,(n=this.gf)===null||n===void 0||n.call(this),this.gf=void 0}onRemoteConfig(t){if(!t.ok)return;const e=t.config;"autocaptureExceptions"in e&&(this.yf=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[IRe]:this.yf}),this.Mr=this.bf(),this.startIfEnabledOrStop())}onConfigChange(){this.Mr=this.bf()}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 U$.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._f=[],this.wf=new uWo([new SWo,new TWo,new vWo,new QWo,new NWo,new DWo,new PWo,new RWo],(function(o,...i){return(r,s=0)=>{const a=[],A=r.split(`
|
|
1067
|
+
`);const _=f.state[a];if(_==null)return;JSON.stringify(i.getState())!==JSON.stringify(_)&&h(_);return}i.dispatchFromDevtools&&typeof i.dispatch=="function"&&i.dispatch(f)});case"DISPATCH":switch(m.payload.type){case"RESET":return h(d),a===void 0?l?.init(i.getState()):l?.init(Wge(A.name));case"COMMIT":if(a===void 0){l?.init(i.getState());return}return l?.init(Wge(A.name));case"ROLLBACK":return mNe(m.state,f=>{if(a===void 0){h(f),l?.init(i.getState());return}h(f[a]),l?.init(Wge(A.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return mNe(m.state,f=>{if(a===void 0){h(f);return}JSON.stringify(i.getState())!==JSON.stringify(f[a])&&h(f[a])});case"IMPORT_STATE":{const{nextLiftedState:f}=m.payload,_=(p=f.computedStates.slice(-1)[0])==null?void 0:p.state;if(!_)return;h(a===void 0?_:_[a]),l?.send(null,f);return}case"PAUSE_RECORDING":return g=!g}return}}),d},mNe=(t,e)=>{let n;try{n=JSON.parse(t)}catch(o){console.error("[zustand devtools middleware] Could not parse the received json",o)}n!==void 0&&e(n)},UC=window.TSCIRCUIT_FILESERVER_API_BASE_URL??"/api",cVo=[".tsx",".ts",".jsx",".js",".mjs",".json",".kicad_pcb",".kicad_sym",".kicad_sch",".kicad_prl",".kicad_pro"],pNe=t=>cVo.some(e=>t.endsWith(e)),a$=VHt.extend("store");async function aOt(t,e){return(await(await fetch(`${UC}/files/upsert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:t,text_content:e})})).json()).file}async function fNe(t){return(await(await fetch(`${UC}/files/get?file_path=${encodeURIComponent(t)}`)).json()).file}async function lVo(t){const e=t?`${UC}/events/list?since=${encodeURIComponent(t)}`:`${UC}/events/list`;return(await(await fetch(e)).json()).event_list}async function uVo(){const t=await fetch(`${UC}/files/list`),{file_list:e}=await t.json(),n=new Map;for(const o of e){if(pNe(o.file_path)){const i=await fNe(o.file_path);n.set(o.file_path,i.text_content);continue}n.set(o.file_path,"__STATIC_ASSET__")}return n}const gVo=["manual-edits.json","manual_edits.json"],Id=rOt()(sOt((t,e)=>({fsMap:new Map,lastEventTime:new Date().toISOString(),isPolling:!1,error:null,circuitJson:null,lastManualEditsChangeSentAt:0,recentEvents:[],simulateScenarioOrder:void 0,currentMainComponentPath:null,recentlySavedFiles:[],loadInitialFiles:async()=>{const n=await uVo();a$("loaded initial files",{fsMap:n}),t({fsMap:n})},upsertFile:async(n,o)=>{try{const i=await aOt(n,o);t(r=>({fsMap:new Map(r.fsMap).set(i.file_path,i.text_content)}))}catch(i){t({error:i})}},getFile:async n=>{try{const o=await fNe(n);t(i=>({fsMap:new Map(i.fsMap).set(o.file_path,o.text_content)}))}catch(o){t({error:o})}},setCircuitJson:n=>{n!==e().circuitJson&&t({circuitJson:n})},addRecentlySavedFile:n=>{t(o=>{if(gVo.includes(n)||!pNe(n))return o;const i=o.recentlySavedFiles.filter(r=>r!==n);return{recentlySavedFiles:[n,...i].slice(0,10)}})},startPolling:()=>{const n=async()=>{const o=e();if(o.isPolling){try{const i=await lVo(o.lastEventTime);if(i.length>0){const r=i[i.length-1].created_at;a$("received events",i.map(A=>A.event_type)),t(A=>({recentEvents:[...A.recentEvents,...i].slice(0,100),lastEventTime:r}));let s=0;const a=new Map(o.fsMap);for(const A of i)if(A.event_type==="FILE_UPDATED"){s++;const c=await fNe(A.file_path);if(A.file_path==="manual_edits.json"&&Date.now()-o.lastManualEditsChangeSentAt<1e3)continue;pNe(c.file_path)?a.set(c.file_path,c.text_content??""):a.set(c.file_path,"__STATIC_ASSET__"),e().addRecentlySavedFile(A.file_path)}else A.event_type==="FILE_DELETED"&&(s++,a.delete(A.file_path));s>0&&(a$("updating fsMap, fsUpdateCount:",s),t({fsMap:a}))}}catch(i){t({error:i})}setTimeout(n,1e3)}};t({isPolling:!0}),n()},stopPolling:()=>{t({isPolling:!1})},pushEvent:async n=>{await fetch(`${UC}/events/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})},applyEditEventsAndUpdateManualEditsJson:async n=>{a$("applyEditEventsAndUpdateManualEditsJson",{editEvents:n});const o=e();if(!o.circuitJson)return;const i=o.fsMap.get("manual-edits.json"),r=i?JSON.parse(i):{},s=TFt({circuitJson:o.circuitJson,editEvents:n,manualEditsFile:r});a$("updatedManualEditsFileContent",s),t(a=>({lastManualEditsChangeSentAt:Date.now(),fsMap:new Map(a.fsMap).set("manual-edits.json",JSON.stringify(s))})),await aOt("manual-edits.json",JSON.stringify(s,null,2))},setSimulateScenarioOrder:n=>t({simulateScenarioOrder:n}),setCurrentMainComponentPath:n=>t({currentMainComponentPath:n})}),{name:"run-frame-store"})),dVo=VHt.extend("useEditEventController"),hVo=()=>{const t=Id(h=>h.applyEditEventsAndUpdateManualEditsJson),[e,n]=X.useState([]),[o,i]=X.useState(!1),r=e.filter(h=>!h._applied),s=e.filter(h=>h._applied),a=o?e:r,A=X.useCallback(h=>{n(d=>[...d,{...h,_applied:!1}])},[]),c=X.useCallback(h=>{n(d=>d.map(m=>m===h?{...m,_applied:!0}:m))},[]),l=X.useCallback(()=>{n(h=>h.map(d=>({...d,_applied:!0})))},[]),u=X.useCallback(()=>{i(!0),e.length!==0&&(dVo("removing edit events that are applied"),n(h=>h.filter(d=>!d._applied)))},[e]),g=X.useCallback(()=>{i(!1)},[]);return X.useEffect(()=>{if(e.filter(d=>!d._applied).length===0)return;const h=setTimeout(()=>{l(),t(e)},1e3);return()=>clearTimeout(h)},[e]),{unappliedEditEvents:r,appliedEditEvents:s,editEventsForRender:a,pushEditEvent:A,markEditEventApplied:c,markRenderStarted:u,markRenderComplete:g,markAllEditEventsApplied:l}},_Ne=vc("run-frame:useHasReceivedInitialFilesLoaded"),mVo=()=>{const[t,e]=X.useState(!1),n=Id(i=>i.recentEvents),o=Id(i=>i.loadInitialFiles);return X.useEffect(()=>{(async()=>{await o();try{const r=await fetch(`${UC}/events/list?event_type=INITIAL_FILES_UPLOADED`);if(r.ok){const{event_list:s}=await r.json();if(s.length>0){_Ne("INITIAL_FILES_UPLOADED found in history. Assuming ready."),e(!0);return}}}catch(r){console.error("Failed to check for event history",r)}_Ne("No INITIAL_FILES_UPLOADED in history, waiting for polling.")})()},[o]),X.useEffect(()=>{t||n.some(i=>i.event_type==="INITIAL_FILES_UPLOADED")&&(_Ne("INITIAL_FILES_UPLOADED received via polling. Assuming ready."),e(!0))},[n,t]),t};function uG(t,e,n){const[o,i]=X.useState(()=>{if(n!==void 0)return n;try{const r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return console.error("Error reading from localStorage:",r),e}});return X.useEffect(()=>{try{window.localStorage.setItem(t,JSON.stringify(o))}catch(r){console.error("Error writing to localStorage:",r)}},[t,o]),[o,i]}var pVo=Object.defineProperty,gG=(t,e)=>pVo(t,"name",{value:e,configurable:!0}),AOt=!!(typeof window<"u"&&window.document&&window.document.createElement);function rr(t,e,{checkForDefaultPrevented:n=!0}={}){return gG(function(i){if(t?.(i),n===!1||!i||!i.defaultPrevented)return e?.(i)},"handleEvent")}gG(rr,"composeEventHandlers");function fVo(t){if(!AOt)throw new Error("Cannot access window outside of the DOM");return t?.ownerDocument?.defaultView??window}gG(fVo,"getOwnerWindow");function INe(t){if(!AOt)throw new Error("Cannot access document outside of the DOM");return t?.ownerDocument??document}gG(INe,"getOwnerDocument");function cOt(t,e=!1){const{activeElement:n}=INe(t);if(!n?.nodeName)return null;if(lOt(n)&&n.contentDocument)return cOt(n.contentDocument.body,e);if(e){const o=n.getAttribute("aria-activedescendant");if(o){const i=INe(n).getElementById(o);if(i)return i}}return n}gG(cOt,"getActiveElement");function lOt(t){return t.tagName==="IFRAME"}gG(lOt,"isFrame");var _Vo=Object.defineProperty,y4=(t,e)=>_Vo(t,"name",{value:e,configurable:!0});function IVo(t,e){const n=X.createContext(e);n.displayName=t+"Context";const o=y4(r=>{const{children:s,...a}=r,A=X.useMemo(()=>a,Object.values(a));return K.jsx(n.Provider,{value:A,children:s})},"Provider");o.displayName=t+"Provider";function i(r,s={}){const{optional:a=!1}=s,A=X.useContext(n);if(A)return A;if(e!==void 0)return e;if(!a)throw new Error(`\`${r}\` must be used within \`${t}\``)}return y4(i,"useContext"),[o,i]}y4(IVo,"createContext");function Vx(t,e=[]){let n=[];function o(r,s){const a=X.createContext(s);a.displayName=r+"Context";const A=n.length;n=[...n,s];const c=y4(u=>{const{scope:g,children:h,...d}=u,m=g?.[t]?.[A]||a,p=X.useMemo(()=>d,Object.values(d));return K.jsx(m.Provider,{value:p,children:h})},"Provider");c.displayName=r+"Provider";function l(u,g,h={}){const{optional:d=!1}=h,m=g?.[t]?.[A]||a,p=X.useContext(m);if(p)return p;if(s!==void 0)return s;if(!d)throw new Error(`\`${u}\` must be used within \`${r}\``)}return y4(l,"useContext"),[c,l]}y4(o,"createContext");const i=y4(()=>{const r=n.map(s=>X.createContext(s));return y4(function(a){const A=a?.[t]||r;return X.useMemo(()=>({[`__scope${t}`]:{...a,[t]:A}}),[a,A])},"useScope")},"createScope");return i.scopeName=t,[o,uOt(i,...e)]}y4(Vx,"createContextScope");function uOt(...t){const e=t[0];if(t.length===1)return e;const n=y4(()=>{const o=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return y4(function(r){const s=o.reduce((a,{useScope:A,scopeName:c})=>{const u=A(r)[`__scope${c}`];return{...a,...u}},{});return X.useMemo(()=>({[`__scope${e.scopeName}`]:s}),[s])},"useComposedScopes")},"createScope");return n.scopeName=e.scopeName,n}y4(uOt,"composeContextScopes");var CVo=Object.defineProperty,CNe=(t,e)=>CVo(t,"name",{value:e,configurable:!0});function yNe(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}CNe(yNe,"setRef");function HR(...t){return e=>{let n=!1;const o=t.map(i=>{const r=yNe(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():yNe(t[i],null)}}}}CNe(HR,"composeRefs");function LA(...t){return X.useCallback(HR(...t),t)}CNe(LA,"useComposedRefs");var yVo=Object.defineProperty,x4=(t,e)=>yVo(t,"name",{value:e,configurable:!0});function jB(t){const e=X.forwardRef((n,o)=>{let{children:i,...r}=n,s=null,a=!1;const A=[];xNe(i)&&typeof jge=="function"&&(i=jge(i._payload)),X.Children.forEach(i,g=>{if(pOt(g)){a=!0;const h=g;let d="child"in h.props?h.props.child:h.props.children;xNe(d)&&typeof jge=="function"&&(d=jge(d._payload)),s=EVo(h,d),A.push(s?.props?.children)}else A.push(g)}),s?s=X.cloneElement(s,void 0,A):!a&&X.Children.count(i)===1&&X.isValidElement(i)&&(s=i);const c=s?mOt(s):void 0,l=LA(o,c);if(!s){if(i||i===0)throw new Error(a?SVo(t):bVo(t));return i}const u=hOt(r,s.props??{});return s.type!==X.Fragment&&(u.ref=o?l:c),X.cloneElement(s,u)});return e.displayName=`${t}.Slot`,e}x4(jB,"createSlot");var xVo=jB("Slot"),gOt=Symbol.for("radix.slottable");function dOt(t){const e=x4(n=>"child"in n?n.children(n.child):n.children,"Slottable");return e.displayName=`${t}.Slottable`,e.__radixId=gOt,e}x4(dOt,"createSlottable");var EVo=x4((t,e)=>{if("child"in t.props){const n=t.props.child;return X.isValidElement(n)?X.cloneElement(n,void 0,t.props.children(n.props.children)):null}return X.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(" "):o==="aria-describedby"&&(n[o]=_Ot(r,i))}return{...t,...n}}x4(hOt,"mergeProps");function mOt(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)}x4(mOt,"getElementRef");function pOt(t){return X.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===gOt}x4(pOt,"isSlottable");var BVo=Symbol.for("react.lazy");function xNe(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===BVo&&"_payload"in t&&fOt(t._payload)}x4(xNe,"isLazyComponent");function fOt(t){return typeof t=="object"&&t!==null&&"then"in t}x4(fOt,"isPromiseLike");function _Ot(...t){const e=new Set;for(const n of t)if(typeof n=="string")for(const o of String(n).trim().split(/\s+/))o&&e.add(o);return e.size>0?Array.from(e).join(" "):void 0}x4(_Ot,"concatAriaDescribedby");var bVo=x4(t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),SVo=x4(t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),jge=Y5[" use ".trim().toString()],QVo=Object.defineProperty,_1=(t,e)=>QVo(t,"name",{value:e,configurable:!0});function qge(t){const e=t+"CollectionProvider",[n,o]=Vx(e),[i,r]=n(e,{collectionRef:{current:null},itemMap:new Map}),s=_1(m=>{const{scope:p,children:f}=m,_=X.useRef(null),I=X.useRef(new Map).current;return K.jsx(i,{scope:p,itemMap:I,collectionRef:_,children:f})},"CollectionProvider");s.displayName=e;const a=t+"CollectionSlot",A=jB(a),c=X.forwardRef((m,p)=>{const{scope:f,children:_}=m,I=r(a,f),C=LA(p,I.collectionRef);return K.jsx(A,{ref:C,children:_})});c.displayName=a;const l=t+"CollectionItemSlot",u="data-radix-collection-item",g=jB(l),h=X.forwardRef((m,p)=>{const{scope:f,children:_,...I}=m,C=X.useRef(null),y=LA(p,C),x=r(l,f);return X.useEffect(()=>(x.itemMap.set(C,{ref:C,...I}),()=>{x.itemMap.delete(C)})),K.jsx(g,{[u]:"",ref:y,children:_})});h.displayName=l;function d(m){const p=r(t+"CollectionConsumer",m);return X.useCallback(()=>{const _=p.collectionRef.current;if(!_)return[];const I=Array.from(_.querySelectorAll(`[${u}]`));return Array.from(p.itemMap.values()).sort((x,E)=>I.indexOf(x.ref.current)-I.indexOf(E.ref.current))},[p.collectionRef,p.itemMap])}return _1(d,"useCollection"),[{Provider:s,Slot:c,ItemSlot:h},d,o]}_1(qge,"createCollection");var IOt=new WeakMap,ENe=(i5=class extends Map{constructor(n){super(n);tat(this,Pf);Fne(this,Pf,[...super.keys()]),IOt.set(this,!0)}set(n,o){return IOt.get(this)&&(this.has(n)?v0(this,Pf)[v0(this,Pf).indexOf(n)]=n:v0(this,Pf).push(n)),super.set(n,o),this}insert(n,o,i){const r=this.has(o),s=v0(this,Pf).length,a=BNe(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 u=[...v0(this,Pf)];let g,h=!1;for(let d=A;d<l;d++)if(A===d){let m=u[d];u[d]===o&&(m=u[d+1]),r&&this.delete(o),g=this.get(m),this.set(o,i)}else{!h&&u[d-1]===o&&(h=!0);const m=u[h?d:d-1],p=g;g=this.get(m),this.delete(m),this.set(m,p)}return this}with(n,o,i){const r=new i5(this);return r.insert(n,o,i),r}before(n){const o=v0(this,Pf).indexOf(n)-1;if(!(o<0))return this.entryAt(o)}setBefore(n,o,i){const r=v0(this,Pf).indexOf(n);return r===-1?this:this.insert(r,o,i)}after(n){let o=v0(this,Pf).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,Pf).indexOf(n);return r===-1?this:this.insert(r+1,o,i)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return Fne(this,Pf,[]),super.clear()}delete(n){const o=super.delete(n);return o&&v0(this,Pf).splice(v0(this,Pf).indexOf(n),1),o}deleteAt(n){const o=this.keyAt(n);return o!==void 0?this.delete(o):!1}at(n){const o=$ge(v0(this,Pf),n);if(o!==void 0)return this.get(o)}entryAt(n){const o=$ge(v0(this,Pf),n);if(o!==void 0)return[o,this.get(o)]}indexOf(n){return v0(this,Pf).indexOf(n)}keyAt(n){return $ge(v0(this,Pf),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 i5(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 i5(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 i5(o)}toReversed(){const n=new i5;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 i5(o)}slice(n,o){const i=new i5;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}},Pf=new WeakMap,_1(i5,"OrderedDict"),i5);function $ge(t,e){if("at"in Array.prototype)return Array.prototype.at.call(t,e);const n=COt(t,e);return n===-1?void 0:t[n]}_1($ge,"at");function COt(t,e){const n=t.length,o=BNe(e),i=o>=0?o:n+o;return i<0||i>=n?-1:i}_1(COt,"toSafeIndex");function BNe(t){return t!==t||t===0?0:Math.trunc(t)}_1(BNe,"toSafeInteger");function vVo(t){const e=t+"CollectionProvider",[n,o]=Vx(e),[i,r]=n(e,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new ENe,setItemMap:_1(()=>{},"setItemMap")}),s=_1(({state:I,...C})=>I?K.jsx(A,{...C,state:I}):K.jsx(a,{...C}),"CollectionProvider");s.displayName=e;const a=_1(I=>{const C=p();return K.jsx(A,{...I,state:C})},"CollectionInit");a.displayName=e+"Init";const A=_1(I=>{const{scope:C,children:y,state:x}=I,E=X.useRef(null),[B,S]=X.useState(null),Q=LA(E,S),[w,M]=x;return X.useEffect(()=>{if(!B)return;const T=EOt(()=>{});return T.observe(B,{childList:!0,subtree:!0}),()=>{T.disconnect()}},[B]),K.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=jB(c),u=X.forwardRef((I,C)=>{const{scope:y,children:x}=I,E=r(c,y),B=LA(C,E.collectionRef);return K.jsx(l,{ref:B,children:x})});u.displayName=c;const g=t+"CollectionItemSlot",h="data-radix-collection-item",d=jB(g),m=X.forwardRef((I,C)=>{const{scope:y,children:x,...E}=I,B=X.useRef(null),[S,Q]=X.useState(null),w=LA(C,B,Q),M=r(g,y),{setItemMap:T}=M,R=X.useRef(E);yOt(R.current,E)||(R.current=E);const F=R.current;return X.useEffect(()=>{const O=F;return T(U=>S?U.has(S)?U.set(S,{...O,element:S}).toSorted(bNe):(U.set(S,{...O,element:S}),U.toSorted(bNe)):U),()=>{T(U=>!S||!U.has(S)?U:(U.delete(S),new ENe(U)))}},[S,F,T]),K.jsx(d,{[h]:"",ref:w,children:x})});m.displayName=g;function p(){return X.useState(new ENe)}_1(p,"useInitCollection");function f(I){const{itemMap:C}=r(t+"CollectionConsumer",I);return C}return _1(f,"useCollection"),[{Provider:s,Slot:u,ItemSlot:m},{createCollectionScope:o,useCollection:f,useInitCollection:p}]}_1(vVo,"createCollection");function yOt(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}_1(yOt,"shallowEqual");function xOt(t,e){return!!(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_PRECEDING)}_1(xOt,"isElementPreceding");function bNe(t,e){return!t[1].element||!e[1].element?0:xOt(t[1].element,e[1].element)?-1:1}_1(bNe,"sortByDocumentPosition");function EOt(t){return new MutationObserver(n=>{for(const o of n)if(o.type==="childList"){t();return}})}_1(EOt,"getChildListObserver");var Sm=globalThis?.document?X.useLayoutEffect:()=>{},wVo=Object.defineProperty,PVo=(t,e)=>wVo(t,"name",{value:e,configurable:!0}),MVo=Y5[" useId ".trim().toString()]||(()=>{}),DVo=0;function Qm(t){const[e,n]=X.useState(MVo());return Sm(()=>{t||n(o=>o??String(DVo++))},[t]),t||(e?`radix-${e}`:"")}PVo(Qm,"useId");var M7=lxe();const BOt=SC(M7);var NVo=Object.defineProperty,RVo=(t,e)=>NVo(t,"name",{value:e,configurable:!0}),TVo=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ra=TVo.reduce((t,e)=>{const n=jB(`Primitive.${e}`),o=X.forwardRef((i,r)=>{const{asChild:s,...a}=i,A=s?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),K.jsx(A,{...a,ref:r})});return o.displayName=`Primitive.${e}`,{...t,[e]:o}},{});function SNe(t,e){t&&M7.flushSync(()=>t.dispatchEvent(e))}RVo(SNe,"dispatchDiscreteCustomEvent");var kVo=Object.defineProperty,FVo=(t,e)=>kVo(t,"name",{value:e,configurable:!0});function EE(t){const e=X.useRef(t);return X.useEffect(()=>{e.current=t}),X.useMemo(()=>((...n)=>e.current?.(...n)),[])}FVo(EE,"useCallbackRef");var LVo=Object.defineProperty,HVo=(t,e)=>LVo(t,"name",{value:e,configurable:!0}),bOt=Y5[" useEffectEvent ".trim().toString()],SOt=Y5[" useInsertionEffect ".trim().toString()];function QOt(t){if(typeof bOt=="function")return bOt(t);const e=X.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof SOt=="function"?SOt(()=>{e.current=t}):Sm(()=>{e.current=t}),X.useMemo(()=>((...n)=>e.current?.(...n)),[])}HVo(QOt,"useEffectEvent");var OVo=Object.defineProperty,A$=(t,e)=>OVo(t,"name",{value:e,configurable:!0}),GVo=Y5[" useInsertionEffect ".trim().toString()]||Sm;function qB({prop:t,defaultProp:e,onChange:n=A$(()=>{},"onChange"),caller:o}){const[i,r,s]=vOt({defaultProp:e,onChange:n}),a=t!==void 0,A=a?t:i,c=X.useCallback(l=>{if(a){const u=wOt(l)?l(t):l;u!==t&&s.current?.(u)}else r(l)},[a,t,r,s]);return[A,c]}A$(qB,"useControllableState");function vOt({defaultProp:t,onChange:e}){const[n,o]=X.useState(t),i=X.useRef(n),r=X.useRef(e);return GVo(()=>{r.current=e},[e]),X.useEffect(()=>{i.current!==n&&(r.current?.(n),i.current=n)},[n,i]),[n,o,r]}A$(vOt,"useUncontrolledState");function wOt(t){return typeof t=="function"}A$(wOt,"isFunction");var POt=Symbol("RADIX:SYNC_STATE");function YVo(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[u,g]=X.useReducer((p,f)=>{if(f.type===POt)return{...p,state:f.state};const _=t(p,f);return A&&!Object.is(_.state,p.state)&&c(_.state),_},...l),h=u.state,d=X.useRef(h);X.useEffect(()=>{d.current!==h&&(d.current=h,A||c(h))},[h,d,A]);const m=X.useMemo(()=>i!==void 0?{...u,state:i}:u,[u,i]);return X.useEffect(()=>{A&&!Object.is(i,u.state)&&g({type:POt,state:i})},[i,u.state,A]),[m,g]}A$(YVo,"useControllableStateReducer");var UVo=Object.defineProperty,KVo=(t,e)=>UVo(t,"name",{value:e,configurable:!0}),zVo={LTR:"ltr"},VVo=X.createContext(void 0);function c$(t){const e=X.useContext(VVo);return t||e||zVo.LTR}KVo(c$,"useDirection");var JVo=Object.defineProperty,QNe=(t,e)=>JVo(t,"name",{value:e,configurable:!0}),vNe=!1;function MOt(){const[t,e]=X.useState(vNe);return X.useEffect(()=>{vNe||(vNe=!0,e(!0))},[]),t}QNe(MOt,"useIsHydrated");var DOt=Y5[" useSyncExternalStore ".trim().toString()];function NOt(){return()=>{}}QNe(NOt,"subscribe");function ROt(){return DOt(NOt,()=>!0,()=>!1)}QNe(ROt,"useIsHydratedModern");var WVo=typeof DOt=="function"?ROt:MOt,jVo=Object.defineProperty,OR=(t,e)=>jVo(t,"name",{value:e,configurable:!0}),wNe="rovingFocusGroup.onEntryFocus",qVo={bubbles:!1,cancelable:!0},Xge="RovingFocusGroup",[PNe,TOt,$Vo]=qge(Xge),[XVo,Zge]=Vx(Xge,[$Vo]),kOt={Vertical:"vertical",Horizontal:"horizontal"},ZVo={RTL:"rtl"},[eJo,tJo]=XVo(Xge),FOt=X.forwardRef(OR(function(e,n){return K.jsx(PNe.Provider,{scope:e.__scopeRovingFocusGroup,children:K.jsx(PNe.Slot,{scope:e.__scopeRovingFocusGroup,children:K.jsx(nJo,{...e,ref:n})})})},"RovingFocusGroup")),nJo=X.forwardRef(OR(function(e,n){const{__scopeRovingFocusGroup:o,orientation:i,loop:r=!1,dir:s,currentTabStopId:a,defaultCurrentTabStopId:A,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...g}=e,h=X.useRef(null),d=LA(n,h),m=c$(s),[p,f]=qB({prop:a,defaultProp:A??null,onChange:c,caller:Xge}),[_,I]=X.useState(!1),C=EE(l),y=TOt(o),x=X.useRef(!1),[E,B]=X.useState(0);return X.useEffect(()=>{const S=h.current;if(S)return S.addEventListener(wNe,C),()=>S.removeEventListener(wNe,C)},[C]),K.jsx(eJo,{scope:o,orientation:i,dir:m,loop:r,currentTabStopId:p,onItemFocus:X.useCallback(S=>f(S),[f]),onItemShiftTab:X.useCallback(()=>I(!0),[]),onFocusableItemAdd:X.useCallback(()=>B(S=>S+1),[]),onFocusableItemRemove:X.useCallback(()=>B(S=>S-1),[]),children:K.jsx(Ra.div,{tabIndex:_||E===0?-1:0,"data-orientation":i,...g,ref:d,style:{outline:"none",...e.style},onMouseDown:rr(e.onMouseDown,()=>{x.current=!0}),onFocus:rr(e.onFocus,S=>{const Q=!x.current;if(S.target===S.currentTarget&&Q&&!_){const w=new CustomEvent(wNe,qVo);if(S.currentTarget.dispatchEvent(w),!w.defaultPrevented){const M=y().filter(U=>U.focusable),T=M.find(U=>U.active),R=M.find(U=>U.id===p),O=[T,R,...M].filter(Boolean).map(U=>U.ref.current);MNe(O,u)}}x.current=!1}),onBlur:rr(e.onBlur,()=>I(!1))})})},"RovingFocusGroupImpl")),oJo="RovingFocusGroupItem",LOt=X.forwardRef(OR(function(e,n){const{__scopeRovingFocusGroup:o,focusable:i=!0,active:r=!1,tabStopId:s,children:a,...A}=e,c=Qm(),l=s||c,u=tJo(oJo,o),g=u.currentTabStopId===l,h=TOt(o),{onFocusableItemAdd:d,onFocusableItemRemove:m,currentTabStopId:p}=u,f=WVo();return Sm(()=>{if(!(!f||!i))return d(),()=>m()},[f,i,d,m]),X.useEffect(()=>{if(!(f||!i))return d(),()=>m()},[f,i,d,m]),K.jsx(PNe.ItemSlot,{scope:o,id:l,focusable:i,active:r,children:K.jsx(Ra.span,{tabIndex:g?0:-1,"data-orientation":u.orientation,...A,ref:n,onMouseDown:rr(e.onMouseDown,_=>{i?u.onItemFocus(l):_.preventDefault()}),onFocus:rr(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:rr(e.onKeyDown,_=>{if(_.key==="Tab"&&_.shiftKey){u.onItemShiftTab();return}if(_.target!==_.currentTarget)return;const I=OOt(_,u.orientation,u.dir);if(I!==void 0){if(_.metaKey||_.ctrlKey||_.altKey||_.shiftKey)return;_.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(_.currentTarget);y=u.loop?GOt(y,x+1):y.slice(x+1)}setTimeout(()=>MNe(y))}}),children:typeof a=="function"?a({isCurrentTabStop:g,hasTabStop:p!=null}):a})})},"RovingFocusGroupItem")),iJo={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function HOt(t,e){return e!==ZVo.RTL?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}OR(HOt,"getDirectionAwareKey");function OOt(t,e,n){const o=HOt(t.key,n);if(!(e===kOt.Vertical&&["ArrowLeft","ArrowRight"].includes(o))&&!(e===kOt.Horizontal&&["ArrowUp","ArrowDown"].includes(o)))return iJo[o]}OR(OOt,"getFocusIntent");function MNe(t,e=!1){const n=document.activeElement;for(const o of t)if(o===n||(o.focus({preventScroll:e}),document.activeElement!==n))return}OR(MNe,"focusFirst");function GOt(t,e){return t.map((n,o)=>t[(e+o)%t.length])}OR(GOt,"wrapArray");var rJo=Object.defineProperty,cS=(t,e)=>rJo(t,"name",{value:e,configurable:!0});function YOt(t,e){return X.useReducer((n,o)=>e[n][o]??n,t)}cS(YOt,"useStateMachine");var BE=cS(t=>{const{present:e,children:n}=t,o=UOt(e),i=typeof n=="function"?n({present:o.isPresent}):X.Children.only(n),r=KOt(o.ref,zOt(i));return typeof n=="function"||o.isPresent?X.cloneElement(i,{ref:r}):null},"Presence");function UOt(t){const[e,n]=X.useState(),o=X.useRef(null),i=X.useRef(t),r=X.useRef("none"),s=X.useRef(void 0),a=t?"mounted":"unmounted",[A,c]=YOt(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return X.useEffect(()=>{A==="mounted"?(r.current=s.current??dG(o.current),s.current=void 0):r.current="none"},[A]),Sm(()=>{const l=o.current,u=i.current;if(u!==t){const h=r.current,d=dG(l);t?(s.current=d,c("MOUNT")):d==="none"||l?.display==="none"?c("UNMOUNT"):c(u&&h!==d?"ANIMATION_OUT":"UNMOUNT"),i.current=t}},[t,c]),Sm(()=>{if(e){let l;const u=e.ownerDocument.defaultView??window,g=cS(d=>{const p=dG(o.current).includes(CSS.escape(d.animationName));if(d.target===e&&p&&(c("ANIMATION_END"),!i.current)){const f=e.style.animationFillMode;e.style.animationFillMode="forwards",l=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=f)})}},"handleAnimationEnd"),h=cS(d=>{d.target===e&&(r.current=dG(o.current))},"handleAnimationStart");return e.addEventListener("animationstart",h),e.addEventListener("animationcancel",g),e.addEventListener("animationend",g),()=>{u.clearTimeout(l),e.removeEventListener("animationstart",h),e.removeEventListener("animationcancel",g),e.removeEventListener("animationend",g)}}else c("ANIMATION_END")},[e,c]),{isPresent:["mounted","unmountSuspended"].includes(A),ref:X.useCallback(l=>{if(l){const u=getComputedStyle(l);o.current=u,s.current=dG(u)}else o.current=null;n(l)},[])}}cS(UOt,"usePresence");function DNe(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}cS(DNe,"setRef");function KOt(...t){const e=X.useRef(t);return e.current=t,X.useCallback(n=>{const o=e.current;let i=!1;const r=o.map(s=>{const a=DNe(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():DNe(o[s],null)}}},[])}cS(KOt,"useStableComposedRefs");function dG(t){return t?.animationName||"none"}cS(dG,"getAnimationName");function zOt(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)}cS(zOt,"getElementRef");var sJo=Object.defineProperty,hG=(t,e)=>sJo(t,"name",{value:e,configurable:!0}),VOt={Automatic:"automatic",Manual:"manual"},NNe="Tabs",[aJo,_Er]=Vx(NNe,[Zge]),JOt=Zge(),[AJo,RNe]=aJo(NNe),cJo=X.forwardRef(hG(function(e,n){const{__scopeTabs:o,value:i,onValueChange:r,defaultValue:s,orientation:a="horizontal",dir:A,activationMode:c=VOt.Automatic,...l}=e,u=c$(A),[g,h]=qB({prop:i,onChange:r,defaultProp:s??"",caller:NNe});return K.jsx(AJo,{scope:o,baseId:Qm(),value:g,onValueChange:h,orientation:a,dir:u,activationMode:c,children:K.jsx(Ra.div,{dir:u,"data-orientation":a,...l,ref:n})})},"Tabs")),lJo="TabsList",WOt=X.forwardRef(hG(function(e,n){const{__scopeTabs:o,loop:i=!0,...r}=e,s=RNe(lJo,o),a=JOt(o);return K.jsx(FOt,{asChild:!0,...a,orientation:s.orientation,dir:s.dir,loop:i,children:K.jsx(Ra.div,{role:"tablist","aria-orientation":s.orientation,...r,ref:n})})},"TabsList")),uJo="TabsTrigger",jOt=X.forwardRef(hG(function(e,n){const{__scopeTabs:o,value:i,disabled:r=!1,...s}=e,a=RNe(uJo,o),A=JOt(o),c=TNe(a.baseId,i),l=kNe(a.baseId,i),u=i===a.value;return K.jsx(LOt,{asChild:!0,...A,focusable:!r,active:u,children:K.jsx(Ra.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":l,"data-state":u?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:c,...s,ref:n,onMouseDown:rr(e.onMouseDown,g=>{!r&&g.button===0&&g.ctrlKey===!1?(g.currentTarget.focus(),a.onValueChange(i)):g.preventDefault()}),onKeyDown:rr(e.onKeyDown,g=>{r||g.target!==g.currentTarget||[" ","Enter"].includes(g.key)&&a.onValueChange(i)}),onFocus:rr(e.onFocus,()=>{const g=a.activationMode!==VOt.Manual;!u&&!r&&g&&a.onValueChange(i)})})})},"TabsTrigger")),gJo="TabsContent",qOt=X.forwardRef(hG(function(e,n){const{__scopeTabs:o,value:i,forceMount:r,children:s,...a}=e,A=RNe(gJo,o),c=TNe(A.baseId,i),l=kNe(A.baseId,i),u=i===A.value,g=X.useRef(u);return X.useEffect(()=>{const h=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(h)},[]),K.jsx(BE,{present:r||u,children:({present:h})=>K.jsx(Ra.div,{"data-state":u?"active":"inactive","data-orientation":A.orientation,role:"tabpanel","aria-labelledby":c,hidden:!h,id:l,tabIndex:0,...a,ref:n,style:{...e.style,animationDuration:g.current?"0s":void 0},children:h&&s})})},"TabsContent"));function TNe(t,e){return`${t}-trigger-${e}`}hG(TNe,"makeTriggerId");function kNe(t,e){return`${t}-content-${e}`}hG(kNe,"makeContentId");function $Ot(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=$Ot(t[e]))&&(o&&(o+=" "),o+=n)}else for(n in t)t[n]&&(o&&(o+=" "),o+=n);return o}function $B(){for(var t,e,n=0,o="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=$Ot(t))&&(o&&(o+=" "),o+=e);return o}const FNe="-",dJo=t=>{const e=mJo(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=t;return{getClassGroupId:s=>{const a=s.split(FNe);return a[0]===""&&a.length!==1&&a.shift(),XOt(a,e)||hJo(s)},getConflictingClassGroupIds:(s,a)=>{const A=n[s]||[];return a&&o[s]?[...A,...o[s]]:A}}},XOt=(t,e)=>{if(t.length===0)return e.classGroupId;const n=t[0],o=e.nextPart.get(n),i=o?XOt(t.slice(1),o):void 0;if(i)return i;if(e.validators.length===0)return;const r=t.join(FNe);return e.validators.find(({validator:s})=>s(r))?.classGroupId},ZOt=/^\[(.+)\]$/,hJo=t=>{if(ZOt.test(t)){const e=ZOt.exec(t)[1],n=e?.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},mJo=t=>{const{theme:e,prefix:n}=t,o={nextPart:new Map,validators:[]};return fJo(Object.entries(t.classGroups),n).forEach(([r,s])=>{LNe(s,o,r,e)}),o},LNe=(t,e,n,o)=>{t.forEach(i=>{if(typeof i=="string"){const r=i===""?e:eGt(e,i);r.classGroupId=n;return}if(typeof i=="function"){if(pJo(i)){LNe(i(o),e,n,o);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([r,s])=>{LNe(s,eGt(e,r),n,o)})})},eGt=(t,e)=>{let n=t;return e.split(FNe).forEach(o=>{n.nextPart.has(o)||n.nextPart.set(o,{nextPart:new Map,validators:[]}),n=n.nextPart.get(o)}),n},pJo=t=>t.isThemeGetter,fJo=(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,_Jo=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)}}},tGt="!",IJo=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,u;for(let p=0;p<a.length;p++){let f=a[p];if(c===0){if(f===i&&(o||a.slice(p,p+r)===e)){A.push(a.slice(l,p)),l=p+r;continue}if(f==="/"){u=p;continue}}f==="["?c++:f==="]"&&c--}const g=A.length===0?a:a.substring(l),h=g.startsWith(tGt),d=h?g.substring(1):g,m=u&&u>l?u-l:void 0;return{modifiers:A,hasImportantModifier:h,baseClassName:d,maybePostfixModifierPosition:m}};return n?a=>n({className:a,parseClassName:s}):s},CJo=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},yJo=t=>({cache:_Jo(t.cacheSize),parseClassName:IJo(t),...dJo(t)}),xJo=/\s+/,EJo=(t,e)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:i}=e,r=[],s=t.trim().split(xJo);let a="";for(let A=s.length-1;A>=0;A-=1){const c=s[A],{modifiers:l,hasImportantModifier:u,baseClassName:g,maybePostfixModifierPosition:h}=n(c);let d=!!h,m=o(d?g.substring(0,h):g);if(!m){if(!d){a=c+(a.length>0?" "+a:a);continue}if(m=o(g),!m){a=c+(a.length>0?" "+a:a);continue}d=!1}const p=CJo(l).join(":"),f=u?p+tGt:p,_=f+m;if(r.includes(_))continue;r.push(_);const I=i(m,d);for(let C=0;C<I.length;++C){const y=I[C];r.push(f+y)}a=c+(a.length>0?" "+a:a)}return a};function BJo(){let t=0,e,n,o="";for(;t<arguments.length;)(e=arguments[t++])&&(n=nGt(e))&&(o&&(o+=" "),o+=n);return o}const nGt=t=>{if(typeof t=="string")return t;let e,n="";for(let o=0;o<t.length;o++)t[o]&&(e=nGt(t[o]))&&(n&&(n+=" "),n+=e);return n};function bJo(t,...e){let n,o,i,r=s;function s(A){const c=e.reduce((l,u)=>u(l),t());return n=yJo(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=EJo(A,n);return i(A,l),l}return function(){return r(BJo.apply(null,arguments))}}const Cd=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},oGt=/^\[(?:([a-z-]+):)?(.+)\]$/i,SJo=/^\d+\/\d+$/,QJo=new Set(["px","full","screen"]),vJo=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,wJo=/\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$/,PJo=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,MJo=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,DJo=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,lS=t=>mG(t)||QJo.has(t)||SJo.test(t),Xw=t=>pG(t,"length",OJo),mG=t=>!!t&&!Number.isNaN(Number(t)),HNe=t=>pG(t,"number",mG),l$=t=>!!t&&Number.isInteger(Number(t)),NJo=t=>t.endsWith("%")&&mG(t.slice(0,-1)),HA=t=>oGt.test(t),Zw=t=>vJo.test(t),RJo=new Set(["length","size","percentage"]),TJo=t=>pG(t,RJo,iGt),kJo=t=>pG(t,"position",iGt),FJo=new Set(["image","url"]),LJo=t=>pG(t,FJo,YJo),HJo=t=>pG(t,"",GJo),u$=()=>!0,pG=(t,e,n)=>{const o=oGt.exec(t);return o?o[1]?typeof e=="string"?o[1]===e:e.has(o[1]):n(o[2]):!1},OJo=t=>wJo.test(t)&&!PJo.test(t),iGt=()=>!1,GJo=t=>MJo.test(t),YJo=t=>DJo.test(t),UJo=bJo(()=>{const t=Cd("colors"),e=Cd("spacing"),n=Cd("blur"),o=Cd("brightness"),i=Cd("borderColor"),r=Cd("borderRadius"),s=Cd("borderSpacing"),a=Cd("borderWidth"),A=Cd("contrast"),c=Cd("grayscale"),l=Cd("hueRotate"),u=Cd("invert"),g=Cd("gap"),h=Cd("gradientColorStops"),d=Cd("gradientColorStopPositions"),m=Cd("inset"),p=Cd("margin"),f=Cd("opacity"),_=Cd("padding"),I=Cd("saturate"),C=Cd("scale"),y=Cd("sepia"),x=Cd("skew"),E=Cd("space"),B=Cd("translate"),S=()=>["auto","contain","none"],Q=()=>["auto","hidden","clip","visible","scroll"],w=()=>["auto",HA,e],M=()=>[HA,e],T=()=>["",lS,Xw],R=()=>["auto",mG,HA],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"],q=()=>["","0",HA],ee=()=>["auto","avoid","all","avoid-page","page","left","right","column"],W=()=>[mG,HA];return{cacheSize:500,separator:":",theme:{colors:[u$],spacing:[lS,Xw],blur:["none","",Zw,HA],brightness:W(),borderColor:[t],borderRadius:["none","","full",Zw,HA],borderSpacing:M(),borderWidth:T(),contrast:W(),grayscale:q(),hueRotate:W(),invert:q(),gap:M(),gradientColorStops:[t],gradientColorStopPositions:[NJo,Xw],inset:w(),margin:w(),opacity:W(),padding:M(),saturate:W(),scale:W(),sepia:q(),skew:W(),space:M(),translate:M()},classGroups:{aspect:[{aspect:["auto","square","video",HA]}],container:["container"],columns:[{columns:[Zw]}],"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(),HA]}],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:[m]}],"inset-x":[{"inset-x":[m]}],"inset-y":[{"inset-y":[m]}],start:[{start:[m]}],end:[{end:[m]}],top:[{top:[m]}],right:[{right:[m]}],bottom:[{bottom:[m]}],left:[{left:[m]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",l$,HA]}],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",HA]}],grow:[{grow:q()}],shrink:[{shrink:q()}],order:[{order:["first","last","none",l$,HA]}],"grid-cols":[{"grid-cols":[u$]}],"col-start-end":[{col:["auto",{span:["full",l$,HA]},HA]}],"col-start":[{"col-start":R()}],"col-end":[{"col-end":R()}],"grid-rows":[{"grid-rows":[u$]}],"row-start-end":[{row:["auto",{span:[l$,HA]},HA]}],"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",HA]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",HA]}],gap:[{gap:[g]}],"gap-x":[{"gap-x":[g]}],"gap-y":[{"gap-y":[g]}],"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:[_]}],px:[{px:[_]}],py:[{py:[_]}],ps:[{ps:[_]}],pe:[{pe:[_]}],pt:[{pt:[_]}],pr:[{pr:[_]}],pb:[{pb:[_]}],pl:[{pl:[_]}],m:[{m:[p]}],mx:[{mx:[p]}],my:[{my:[p]}],ms:[{ms:[p]}],me:[{me:[p]}],mt:[{mt:[p]}],mr:[{mr:[p]}],mb:[{mb:[p]}],ml:[{ml:[p]}],"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",HA,e]}],"min-w":[{"min-w":[HA,e,"min","max","fit"]}],"max-w":[{"max-w":[HA,e,"none","full","min","max","fit","prose",{screen:[Zw]},Zw]}],h:[{h:[HA,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[HA,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[HA,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[HA,e,"auto","min","max","fit"]}],"font-size":[{text:["base",Zw,Xw]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",HNe]}],"font-family":[{font:[u$]}],"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",HA]}],"line-clamp":[{"line-clamp":["none",mG,HNe]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",lS,HA]}],"list-image":[{"list-image":["none",HA]}],"list-style-type":[{list:["none","disc","decimal",HA]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[f]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[f]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...O(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",lS,Xw]}],"underline-offset":[{"underline-offset":["auto",lS,HA]}],"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",HA]}],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",HA]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[f]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...F(),kJo]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",TJo]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},LJo]}],"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":[f]}],"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":[f]}],"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":[lS,HA]}],"outline-w":[{outline:[lS,Xw]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:T()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[f]}],"ring-offset-w":[{"ring-offset":[lS,Xw]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Zw,HJo]}],"shadow-color":[{shadow:[u$]}],opacity:[{opacity:[f]}],"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",Zw,HA]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[l]}],invert:[{invert:[u]}],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":[u]}],"backdrop-opacity":[{"backdrop-opacity":[f]}],"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",HA]}],duration:[{duration:W()}],ease:[{ease:["linear","in","out","in-out",HA]}],delay:[{delay:W()}],animate:[{animate:["none","spin","ping","pulse","bounce",HA]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[C]}],"scale-x":[{"scale-x":[C]}],"scale-y":[{"scale-y":[C]}],rotate:[{rotate:[l$,HA]}],"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",HA]}],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",HA]}],"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",HA]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[lS,Xw,HNe]}],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"]}}}),jn="u">typeof window?window:void 0,KC="u">typeof globalThis?globalThis:jn,I_=KC?.navigator,qo=KC?.document,tg=KC?.location,g$=KC?.fetch,ONe=KC?.XMLHttpRequest&&"withCredentials"in new KC.XMLHttpRequest?KC.XMLHttpRequest:void 0,rGt=KC?.AbortController,KJo=KC?.CompressionStream,l2=I_?.userAgent,d$=typeof globalThis<"u"?globalThis:jn;d$&&typeof self>"u"&&(d$.self=d$),d$&&typeof File>"u"&&(d$.File=function(){});const Kr=jn??{},zJo="0.9.3",uS={DEBUG:!1,LIB_VERSION:zJo,LIB_NAME:"browser-common"};var D7=(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})({}),GNe=(function(t){return t.GZipJS="gzip-js",t.Base64="base64",t})({});const VJo=["$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"],JJo=["token"];function jr(t,e){return t.indexOf(e)!==-1}const fG=function(t){return t.trim()},YNe=function(t){return t.replace(/^\$/,"")};function sGt(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 aGt=Object.prototype,UNe=aGt.hasOwnProperty,ede=aGt.toString,qr=Array.isArray||function(t){return ede.call(t)==="[object Array]"},pp=t=>typeof t=="function",va=t=>t===Object(t)&&!qr(t),Jx=t=>{if(va(t)){for(const e in t)if(UNe.call(t,e))return!1;return!0}return!1},Eo=t=>t===void 0,Za=t=>ede.call(t)=="[object String]",h$=t=>Za(t)&&t.trim().length===0,yd=t=>t===null,Hs=t=>Eo(t)||yd(t),gh=t=>ede.call(t)=="[object Number]"&&t==t,gS=t=>gh(t)&&t>0,u2=t=>ede.call(t)==="[object Boolean]",WJo=t=>jr(VJo,t),jJo=t=>jr(JJo,t);function AGt(t){return t===null||typeof t!="object"}function tde(t,e){return{}.toString.call(t)===`[object ${e}]`}function _G(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 cGt(t,Error)}}function KNe(t){return"u">typeof Event&&cGt(t,Event)}function cGt(t,e){try{return t instanceof e}catch{return!1}}const qJo=[!0,"true",1,"1","yes"],zNe=t=>jr(qJo,t),$Jo=[!1,"false",0,"0","no"];function lGt(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 ng(t){return function(){var e=this,n=arguments;return new Promise(function(o,i){var r=t.apply(e,n);function s(A){lGt(r,o,i,s,a,"next",A)}function a(A){lGt(r,o,i,s,a,"throw",A)}s(void 0)})}}const XJo=["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"],nde=new Map,uGt=function(t,e=[]){if(!t)return!1;const n=(function(s,a){let A="";for(let c=0;a.length>c;c++){const l=a[c];A+=l.length+":"+l}return s.length+":"+s+"|"+a.length+":"+A})(t,e),o=nde.get(n);if(o!==void 0)return o;const i=t.toLowerCase(),r=XJo.concat(e).some(s=>i.indexOf(s.toLowerCase())!==-1);return 256>nde.size||nde.clear(),nde.set(n,r),r};function N7(t,e,n,o,i){return e>n&&(o.warn("min cannot be greater than max."),e=n),gh(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),N7(i??n,e,n,o))}var ZJo=class{constructor(e){this.C={},this.I=e.I,this.R=N7(e.bucketSize,0,100,e.A),this.$=N7(e.refillRate,0,this.R,e.A),this.O=N7(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 IG="Mobile",m$="Android",ode="Tablet",gGt="Android Tablet",dGt="iPad",hGt="Apple Watch",ide="Safari",rde="BlackBerry",mGt="Samsung Internet",sde="Chrome",pGt="Chrome iOS",fGt="Internet Explorer",_Gt="Internet Explorer Mobile",IGt="Opera",CGt="Microsoft Edge",ade="Firefox",yGt="Firefox iOS",Ade="Nintendo",cde="PlayStation",lde="Xbox",xGt="Android Mobile",EGt="Mobile Safari",VNe="Windows",BGt="Windows Phone",bGt="Nokia",JNe="Ouya",eWo="Generic "+IG.toLowerCase(),SGt="Generic "+ode.toLowerCase(),WNe="Konqueror",QGt="Oculus Browser",vGt="Vivaldi",wGt="Yandex",PGt="Whale",MGt="DuckDuckGo",DGt="Pale Moon",NGt="Waterfox",jNe="Brave",RGt="Claude",TGt="Codex",kGt="ChatGPT",FGt="Google Search App",qNe=new RegExp("Version/(\\d+(\\.\\d+)?)"),$Ne=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),tWo=new RegExp(lde,"i"),nWo=new RegExp("PlayStation \\w+","i"),oWo=new RegExp("Nintendo \\w+","i"),XNe=new RegExp("BlackBerry|PlayBook|BB10","i"),iWo={"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"},LGt=function(t,e,n,o){return e=e||"",(function(r){return r?.brave?jNe:null})(n)||(o?.detectGoogleSearchApp&&jr(t,"GSA/")?FGt:jr(t," OPR/")&&jr(t,"Mini")?"Opera Mini":jr(t," OPR/")?IGt:XNe.test(t)?rde:jr(t,"IEMobile")||jr(t,"WPDesktop")?_Gt:jr(t,"OculusBrowser")?QGt:jr(t,"SamsungBrowser")?mGt:jr(t,"Edge")||jr(t,"Edg/")?CGt:jr(t,"Vivaldi/")?vGt:jr(t,"YaBrowser/")?wGt:jr(t,"Whale/")?PGt:jr(t,"DuckDuckGo/")||jr(t,"Ddg/")?MGt:jr(t,"Claude/")?RGt:jr(t,"Codex/")?TGt:jr(t,"ChatGPT/")?kGt:jr(t,"FBIOS")?"Facebook Mobile":jr(t,"UCWEB")||jr(t,"UCBrowser")?"UC Browser":jr(t,"CriOS")?pGt:jr(t,"CrMo")||jr(t,sde)?sde:jr(t,m$)&&jr(t,ide)?xGt:jr(t,"FxiOS")?yGt:jr(t.toLowerCase(),WNe.toLowerCase())?WNe:jr(t,"Brave/")?jNe:((r,s)=>s&&jr(s,"Apple")||(function(a){return jr(a,ide)&&!jr(a,sde)&&!jr(a,m$)})(r))(t,e)?jr(t,IG)?EGt:ide:jr(t,"PaleMoon/")?DGt:jr(t,"Waterfox/")?NGt:jr(t,ade)?ade:jr(t,"MSIE")||jr(t,"Trident/")?fGt:jr(t,"Gecko")?ade:"")},rWo={[_Gt]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[CGt]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[sde]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[pGt]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[ide]:[qNe],[EGt]:[qNe],[IGt]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[ade]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[yGt]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[WNe]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[rde]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),qNe],[xGt]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[mGt]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[QGt]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[vGt]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[wGt]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[PGt]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[jNe]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[RGt]:[$Ne],[TGt]:[$Ne],[kGt]:[$Ne],[MGt]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[DGt]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[NGt]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[FGt]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[fGt]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},sWo=function(t,e,n,o){const i=LGt(t,e,n,o),r=rWo[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},HGt=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>[lde,t&&t[1]||""]],[new RegExp(Ade,"i"),[Ade,""]],[new RegExp(cde,"i"),[cde,""]],[XNe,[rde,""]],[new RegExp(VNe,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[BGt,""];if(new RegExp(IG).test(e)&&!/IEMobile\b/.test(e))return["Windows Mobile",""];const n=/Windows NT ([0-9.]+)/i.exec(e);if(n&&n[1]){let o=iWo[n[1]]||"";return/arm/i.test(e)&&(o="RT"),[VNe,o]}return[VNe,""]}],[/((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]?[m$,[t[2],t[3],t[4]||"0"].join(".")]:[m$,""]],[/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",""]]],OGt=function(t){for(let e=0;HGt.length>e;e++){const[n,o]=HGt[e],i=n.exec(t),r=i&&(pp(o)?o(i,t):o);if(r)return r}return["",""]},GGt=function(t){return oWo.test(t)?Ade:nWo.test(t)?cde:tWo.test(t)?lde:new RegExp(JNe,"i").test(t)?JNe:new RegExp("(Windows Phone|WPDesktop)","i").test(t)?BGt:/iPad/.test(t)?dGt:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?hGt:XNe.test(t)?rde:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(bGt,"i").test(t)?bGt:/(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(IG).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)?m$:gGt:new RegExp("(pda|Mobile)","i").test(t)?eWo:new RegExp(ode,"i").test(t)&&!new RegExp("Tablet pc","i").test(t)?SGt:""},aWo=function(t,e){var n;const o=GGt(t);return o===dGt||o===gGt||o==="Kobo"||o==="Kindle Fire"||o===SGt?ode:o===Ade||o===lde||o===cde||o===JNe?"Console":o===hGt?"Wearable":o?IG: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)?IG:ode:"Desktop";var i,r,s},ZNe=/\bFBAV\/(\d+(?:\.\d+)*)/i,YGt=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",ZNe],[/\bFBAN\/EMA\b/i,"Facebook Lite",ZNe],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",ZNe],[/\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"]],eRe="[Truncated]",p$="[Unserializable]";function CG(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 UGt(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=p$}Object.defineProperty(t,o,{value:i,enumerable:!0,writable:!0,configurable:!0})}return t}const ude=3e5;var KGt=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,ude);if(!n)return this.ts=o,void(this.es=o+i);this.es=Math.max(this.es,Math.min(o+i,this.ts+ude))}remainingMs(){const e=Date.now();if(this.ts-5e3>e)return this.reset(),0;const n=Math.min(ude,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 AWo=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function zGt(t,e){return typeof(n=t)=="string"&&AWo.test(n)?t:e();var n}function VGt(t,e){const n=new Error(e);try{Object.defineProperty(n,"name",{value:t,writable:!0,enumerable:!0,configurable:!0})}catch{}return n}function eP(t){return t&&t.split("#")[0]}function JGt(t){try{return t()}catch{return}}function WGt(t,e){const n=setTimeout(t,e);return n!=null&&n.unref&&n?.unref(),n}function jGt(t,e,n){return qGt.apply(this,arguments)}function qGt(){return(qGt=ng(function*(t,e,n){let o;try{return yield Promise.race([t,new Promise((i,r)=>{o=WGt(()=>{try{n?.(),i()}catch(s){r(s)}},e)})])}finally{clearTimeout(o)}})).apply(this,arguments)}let gde,$Gt,tRe;function cWo(t){const e=globalThis._posthogChunkIds;if(!e)return;const n=Object.keys(e);return tRe&&n.length===$Gt||($Gt=n.length,tRe=n.reduce((o,i)=>{gde||(gde={});const r=gde[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,gde[i]=[c,l];break}}}return o},{})),tRe}function f$(t){return f$=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},f$(t)}function lWo(t,e,n){return(e=(function(o){var i=(function(r){if(f$(r)!="object"||!r)return r;var s=r[Symbol.toPrimitive];if(s!==void 0){var a=s.call(r,"string");if(f$(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)})(o);return f$(i)=="symbol"?i:i+""})(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function XGt(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 Zt(t){for(var e=1;arguments.length>e;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?XGt(Object(n),!0).forEach(function(o){lWo(t,o,n[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):XGt(Object(n)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(n,o))})}return t}var uWo=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 ng(function*(){for(const o of e)o.stacktrace&&o.stacktrace.frames&&qr(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 Zt(Zt({},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 ng(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?Zt(Zt({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},u={type:r.type,value:r.value,mechanism:l};r.stack&&(u.stacktrace={type:"raw",frames:r.stack}),o.push(u),r.cause&&i(r.cause,c,"cause");for(const g of(A=r.errors)!==null&&A!==void 0?A:[])i(g,c,"member")};return i(e),o}buildParsingContext(e){var n;return{chunkIdMap:cWo(this.stackParser),skipFirstLines:(n=e.skipFirstLines)!==null&&n!==void 0?n:1}}getAggregateErrors(e){try{if(_G(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 qr(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,m=0)=>{const p=u(d,m),f=p.apply;if(p.apply=E=>{A.push(h);try{return f(E)}finally{A.pop()}},m>4||m>0&&A.indexOf(h)!==-1)return this.coerceFallback(p);const _=typeof h=="object"&&h!==null||typeof h=="function";if(m===0&&i>=50||_&&a.has(h))return;_&&a.add(h),m===0&&i++;const I=this.getAggregateErrors(h);let C,y;s||(s=!!I);try{if(C=this.applyCoercers(h,p),!C)throw c}catch(E){if(E===c)return void(m===0&&i--);if(!s)throw E;C=this.coerceFallback(p)}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=p.next(I[E])}catch{i++,B=this.coerceFallback(u(d+1))}B&&x.push(B)}return Zt(Zt({},C),{},{errors:x})},u=(h,d=0)=>Zt(Zt({},n),{},{syntheticException:h==0?n.syntheticException:void 0,mechanism:h==0?e:{},apply(m){const p=l(m,h,d+1);if(!p)throw c;return p},next:m=>l(m,h+1)}),g=u(o);return Zt(Zt({},g),{},{apply:h=>{var d;return(d=l(h,o))!==null&&d!==void 0?d:this.coerceFallback(g)}})}};const gWo=/^([a-z][a-z0-9.+-]+):/i,dWo=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function hWo(t){if(!t||t==="<anonymous>")return!1;const e=gWo.exec(t);return!e||dWo.includes(e[1].toLowerCase())}function nRe(t,e,n,o,i){const r={platform:t,filename:e,function:n==="<anonymous>"?"?":n,in_app:hWo(e)};return Eo(o)||(r.lineno=o),Eo(i)||(r.colno=i),r}const ZGt=(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]},mWo=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,pWo=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,fWo=/\((\S*)(?::(\d+))(?::(\d+))\)/,_Wo=(t,e)=>{const n=mWo.exec(t);if(n){const[,i,r,s]=n;return nRe(e,i,"?",+r,+s)}const o=pWo.exec(t);if(o){if(o[2]&&o[2].indexOf("eval")===0){const s=fWo.exec(o[2]);s&&(o[2]=s[1],o[3]=s[2],o[4]=s[3])}const[i,r]=ZGt(o[1]||"?",o[2]);return nRe(e,r,i,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},IWo=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,CWo=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,yWo=(t,e)=>{const n=IWo.exec(t);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){const r=CWo.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]=ZGt(i,o),nRe(e,o,i,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},eYt=/\(error: (.*)\)/;function oRe(t,e){return t.filename===e.filename&&t.function===e.function&&t.module===e.module&&t.lineno===e.lineno&&t.colno===e.colno}function xWo(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(!oRe(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 EWo(t,e){const n=e.start+e.length,o=nYt(t,e);o&&t.splice(n+o===t.length?n:e.start,o)}function tYt(t,e){let n=e.start;for(;n>0&&oRe(t[n-1],t[n-1+e.length]);)n--;return e.start-n}function nYt(t,e){const n=e.start+e.length;let o=n;for(;t.length>o&&oRe(t[o],t[o-e.length]);)o++;return o-n}function BWo(t,e){const n=e[0];let o=t.length-(n?tYt(t,n):0);for(const i of e)o-=nYt(t,i);return o}function bWo(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 SWo=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,n){const o=Za(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 tde(e,"DOMException")}isDOMError(e){return tde(e,"DOMError")}},QWo=class{match(e){return _G(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}}},vWo=class{match(e){return!!tde(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 Zt(Zt({},i),{},{stack:(o=this.lr(e))!==null&&o!==void 0?o:i.stack,synthetic:!0})}ar(e){return Za(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(Za(i.filename)&&i.filename.length!==0&&r!==0)return`Error
|
|
1068
|
+
at ${i.filename}:${r}:${s}`}};const wWo=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var PWo=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(wWo);return i&&(n=i[1],o=i[2]),[n,o]}};const MWo=["fatal","error","warning","log","info","debug"];function oYt(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 DWo=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(KNe(e))return e.constructor.name;const n="name"in e?e.name:void 0;return Za(n)&&!h$(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: ${oYt(e)}`}isSeverityLevel(e){return Za(e)&&!h$(e)&&MWo.indexOf(e)>=0}getStack(e){try{return Za(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:Za(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(_G(o))return o}}getObjectClassName(e){try{const n=Object.getPrototypeOf(e);return n?n.constructor.name:void 0}catch{return}}},NWo=class{match(e){return KNe(e)}coerce(e,n){var o;const i=e.constructor.name;return{type:i,value:`${i} captured as exception with keys: ${oYt(e)}`,stack:(o=n.syntheticException)===null||o===void 0?void 0:o.stack,synthetic:!0}}},RWo=class{match(e){return AGt(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}}},TWo=class{match(e){return tde(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!KNe(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 AGt(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 dde="$message",hde="$timestamp",kWo=new Set([dde,hde]),iRe={enabled:!0,max_bytes:32768};function mde(t){var e;return t?{enabled:(e=t.enabled)!==null&&e!==void 0?e:iRe.enabled,max_bytes:LWo(t.max_bytes,iRe.max_bytes)}:Zt({},iRe)}var FWo=class{constructor(e){this.ns=[],this.ss=0,this.Mr=mde(e)}setConfig(e){this.Mr=mde(e),this.rs()}add(e){const n=(function(i){let r;try{r=sGt(i)}catch{return}try{const s=JSON.parse(r);if(!va(s))return;const a=s,A=a[dde],c=a[hde];return!Za(A)||A.trim().length===0||!Za(c)&&!gh(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 LWo(t,e){if(!gh(t)||t===1/0||t===-1/0)return e;const n=Math.floor(t);return 0>n?e:n}const iYt=t=>{if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}};function rYt(t){return typeof t=="string"||t}function sYt(t){return typeof t=="string"?t:void 0}const HWo=["$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"],aYt="NativeGzipValidationError",rRe=t=>t.length>=2&&t[0]===31&&t[1]===139,AYt=(t,e)=>t===GNe.GZipJS||e===GNe.GZipJS||e==="gzip",cYt=t=>!(!t||typeof t!="object")&&("name"in t?String(t.name):"")==="NotReadableError";let _$;const pde=t=>{throw VGt(aYt,`Native gzip produced invalid output: ${t}`)},OWo=(lYt=ng(function*(t,e){18>t.size&&pde("too-short");const n=new Uint8Array(yield t.slice(0,10).arrayBuffer());rRe(n)&&n[2]===8||pde("invalid-header");const o=new DataView(yield t.slice(t.size-8).arrayBuffer());o.getUint32(0,!0)!==(r=>{const s=(()=>{if(_$)return _$;_$=[];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;_$[A]=c>>>0}return _$})();let a=4294967295;for(let A=0;r.length>A;A++)a=s[255&(a^r[A])]^a>>>8;return(4294967295^a)>>>0})(e)&&pde("invalid-crc");const i=e.length>>>0;o.getUint32(4,!0)!==i&&pde("invalid-size")}),function(t,e){return lYt.apply(this,arguments)});var lYt;function sRe(){return sRe=ng(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=ng(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 OWo(c,i),c}catch(i){if(n?.rethrow)throw i;return e&&console.error("Failed to gzip compress data",i),null}var o}),sRe.apply(this,arguments)}function uYt(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 zC="[redacted]",GWo=/^[A-Za-z0-9+/\n\r]+=*$/,YWo=/^[A-Za-z0-9_-]+={0,2}$/,UWo=/[-_]/,KWo=/^data:[^,\s]*;base64,/i,zWo=/^[A-Za-z0-9+/_-]+={0,2}$/,VWo=/\bph[a-z]_[A-Za-z0-9_-]{20,}\b/g,JWo=/^(authorization|cookie|set-cookie|x-api-key|api[-_]?key|api[-_]?token|access[-_]?token|refresh[-_]?token|token|password|secret|client[-_]?secret|private[-_]?key)$/i,gYt=/[a-z][a-z0-9+.-]{0,63}:[^\s<>"]+/gi,WWo=/[\s<>"]/,dYt=new RegExp(gYt.source,"i"),hYt=/[a-z][a-z0-9+.-]{0,63}:\/\//i,jWo=new RegExp(`^${hYt.source}`,"i"),qWo=new RegExp(hYt.source,"gi"),$Wo=/(^|[-_./;])(auth|token|secret|password|passwd|pwd|credential|signature|sig|key|hmac|sas|bearer|jwt|session|sessionid)([-_./;]|$)/i,XWo=/^(code|AWSAccessKeyId|GoogleAccessId|Policy)$/i,ZWo=/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g,ejo=/[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,24}/g,tjo=/\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g,njo=/(^|[^\w:])((?:(?:[0-9A-Fa-f]{1,4}:){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}){0,5}|::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,6})))(?=$|[^\w:])/g,ojo=/\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g,ijo=/\b\d(?:[ ./-]?\d){12,}\b/g,mYt=/\d+/g,rjo=/(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g,sjo=/(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;function aRe(t){return(function(e){return JWo.test(e)})(t)||$Wo.test(t)||XWo.test(t)}function ARe(t){return t.split("&",129).length>128}function ajo(t,e,n){return aRe(t)||e.includes(";")&&(function(o){return o.split(";").some(i=>aRe(i.split("=",1)[0]))})(e)?zC:dYt.test(e)?n?lRe(e,{allowNestedUrls:!1,stripPunctuation:!0}):zC:e}function pYt(t,e){const n=new URLSearchParams;let o=!1,i=!1;for(const[r,s]of new URLSearchParams(t)){const a=fde(r),A=fde(s);o||(o=a!==r||A!==s);const c=ajo(a,A,e);o||(o=c!==A),i=aRe(a)||c!==A,n.append(a,c)}return{changed:o,lastFieldSensitive:i,serialized:n.toString()}}function fYt(t,e){if(!t.includes("="))return{value:Ajo(t,e),lastFieldSensitive:!1};const n=pYt(t,e);return{value:n.changed?n.serialized:t,lastFieldSensitive:n.lastFieldSensitive}}function Ajo(t,e){return e?lRe(t,{allowNestedUrls:!1,stripPunctuation:!0}):dYt.test(t)?zC:t}function cjo(t,e,n){return t==="#"?!e.fragment&&(e.fragment=!0):t==="?"&&(e.fragment?n!=="="&&!e.fragmentQuery&&(e.fragmentQuery=!0):!e.query&&(e.query=!0))}function cRe(t,e){var n;if(t.length>8192&&jWo.test(t))return zC;const{address:o,suffix:i}=e.stripPunctuation?(function(p){let f=p.length;for(;f>0&&".,;:!?)]}'".includes(p[f-1]);)f--;return{address:p.slice(0,f),suffix:p.slice(f)}})(t):{address:t,suffix:""};let r;try{r=new URL(o)}catch{return zC+i}const s=r.search.slice(1),a=r.hash!=="",A=(function(p){const f=p.slice(1),_=f.indexOf("?");return 0>_?{head:f,tail:null}:{head:f.slice(0,_),tail:f.slice(_+1)}})(r.hash);if(ARe(s)||ARe(A.head)||ARe((n=A.tail)!==null&&n!==void 0?n:""))return zC+i;let c=!1;(r.username||r.password)&&(r.username=zC,r.password="",c=!0);const l=pYt(s,e.allowNestedUrls);l.changed&&(r.search=l.serialized,c=!0);const u=fYt(A.head,e.allowNestedUrls),g=A.tail===null?null:(h=A.tail,u.lastFieldSensitive?{value:h===""?"":zC,lastFieldSensitive:!0}:fYt(h,e.allowNestedUrls));var h;const d=g===null?u.value:`${u.value}?${g.value}`;d!==r.hash.slice(1)&&(r.hash=d,c=!0);const m=a?g??u:l;return(c?fde(r.toString()):o)+(m.lastFieldSensitive?"":i)}function lRe(t,e){return t.replace(gYt,n=>(function(o,i){const r=(function(A){if(!A.includes("://"))return[];const c=[...A.matchAll(qWo)].map(m=>m.index),l=[],u={query:!1,fragment:!1,fragmentQuery:!1};let g=0,h=!1,d="";for(let m=0;A.length>m&&c.length>g;m++){c[g]===m&&(m>0&&d!=="="&&l.push(m),g++);const p=A[m];cjo(p,u,d)?(d=p,h=!0):h&&"=&".includes(p)&&(d=p)}return l})(o);if(r.length===0)return cRe(o,i);let s="",a=0;for(const A of r)s+=cRe(o.slice(a,A),Zt(Zt({},i),{},{stripPunctuation:!1})),a=A;return s+cRe(o.slice(a),i)})(n,Zt(Zt({},e),{},{stripPunctuation:e.stripPunctuation&&n.length!==t.length})))}function fde(t){return t.replace(VWo,zC)}function ljo(t,e){return(function(n){return n.length>=10240&&(GWo.test(n)||(function(o){const i=KWo.exec(o);if(!i)return!1;let r;try{r=decodeURIComponent(o.slice(i[0].length))}catch{return!1}return zWo.test(r.replace(/[\r\n]/g,""))})(n)||UWo.test(n)&&YWo.test(n))})(t)?"[binary data redacted - not supported by PostHog MCP analytics]":(function(n,o,i){const r=4*i.maxStringLength;if(n.length>r){const s=o(n.slice(0,(function(a,A){let c=A;for(;c>0&&!WWo.test(a[c-1]);)c--;return c})(n,r)));if(s.length>=2*i.maxStringLength)return s+i.truncationSuffix}return o(n)})(t,n=>(function(o){return lRe(o,{allowNestedUrls:!0,stripPunctuation:!0})})((function(o){let i=o.replace(ZWo," ");return i=i.replace(ejo,zC),i=i.replace(tjo,zC),i=i.replace(njo,`$1${zC}`),i=i.replace(ijo,gjo),i=i.replace(ojo,zC),i=i.replace(rjo,`$1${zC}`),i=i.replace(sjo,`$1${zC}`),i})(fde(n))),e)}function ujo(t){let e=0,n=!1;for(let o=t.length-1;o>=0;o--){let i=t.charCodeAt(o)-48;if(0>i||i>9)return!1;n&&(i*=2,i>9&&(i-=9)),e+=i,n=!n}return e%10==0}function gjo(t){const e=[];for(let r=mYt.exec(t);r!==null;r=mYt.exec(t))e.push({digits:r[0],start:r.index,end:r.index+r[0].length});let n="",o=0,i=0;for(;e.length>i;){let r="",s=-1;for(let a=i;e.length>a&&(r+=e[a].digits,19>=r.length);a++)r.length>=13&&ujo(r)&&(s=a);0>s?i++:(n+=t.slice(o,e[i].start)+zC,o=e[s].end,i=s+1)}return n+t.slice(o)}const djo={}.propertyIsEnumerable;function _de(t,e){try{return _Yt(t,e,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch{return[]}}function uRe(t,e,n,o){if(0>=n.remainingNodes)return{stringValue:eRe};if(n.remainingNodes--,u2(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:CG(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:eRe};if(t instanceof Date){const i=t.getTime(),r=Number.isFinite(i)?t.toISOString():String(t);return{stringValue:typeof r=="string"?CG(r):String(r)}}n.ancestors.add(t);try{try{const i=t.toJSON;if(typeof i=="function")return uRe(i.call(t),e,n,o+1)}catch{}return qr(t)?{arrayValue:{values:hjo(t,e,n,o+1)}}:{kvlistValue:{values:_Yt(t,e,n,o+1)}}}finally{n.ancestors.delete(t)}}return{stringValue:CG(String(t))}}function hjo(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(Hs(a))continue;i.push(uRe(a,e,n,o))}catch{i.push({stringValue:p$})}return t.length>s&&i.push({stringValue:eRe}),i}function _Yt(t,e,n,o){const i=[];for(const r in t)if(djo.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(yd(s)||Eo(s))continue;i.push({key:CG(r),value:uRe(s,e,n,o)})}catch{i.push({key:CG(r),value:{stringValue:p$}})}}return i}function IYt(t,e,n){return Zt(Zt(Zt(Zt({},UGt({},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 mjo=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function CYt(t,e){const n=UGt({},t),o={};for(const i of mjo)({}).hasOwnProperty.call(n,i)&&(o[i]=n[i],delete n[i]);return[..._de(n,e),..._de(o,e)]}const yYt={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"},xYt={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}},pjo=xYt.info;function fjo(t){try{return CG(String(t))}catch{return p$}}function _jo(t,e,n,o){const i=t.level||"info",{text:r,number:s}=xYt[i]||pjo,a=(function(g=Date.now()){return String(g)+"000000"})(gh(o)?o:void 0),A={};e.distinctId&&(A.posthogDistinctId=e.distinctId),e.sessionId&&(A.sessionId=e.sessionId),e.windowId&&(A["window.id"]=e.windowId),Hs(e.sessionStartTimestamp)||(A.sessionStartTimestamp=String(e.sessionStartTimestamp)),Hs(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=Zt({},A),l=t.attributes;if(l){let g=[];try{g=Object.keys(l)}catch{g=[]}for(const h of g){let d;try{d=l[h]}catch{d=p$}Object.defineProperty(c,h,{value:d,enumerable:!0,writable:!0,configurable:!0})}}const u={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:s,severityText:r,body:{stringValue:fjo(t.body)},attributes:_de(c,n)};return t.trace_id&&(u.traceId=t.trace_id),t.span_id&&(u.spanId=t.span_id),Eo(t.trace_flags)||(u.flags=t.trace_flags),u}function EYt(t,e,n){return IYt(t,e,n)}function BYt(t,e,n,o){return{resourceLogs:[{resource:{attributes:CYt(e)},scopeLogs:[{scope:{name:n,version:o},logRecords:t}]}]}}var bYt=class{constructor(e){this.ls=e,this.us=0}get pending(){return!!this.cs}arm(e){this.clear(),this.us=Date.now()+e,this.cs=WGt(()=>{this.cs=void 0,this.ls()},e)}armNoEarlierThan(e){this.cs&&Date.now()+e<=this.us||this.arm(e)}clear(){this.cs&&(clearTimeout(this.cs),this.cs=void 0)}};function SYt(){return .75+.5*Math.random()}function QYt(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 Ijo=class{constructor(e,n,o,i,r,s=()=>Promise.resolve(),a){var A;this._instance=e,this.Mr=n,this.A=o,this.hs=i,this.ds=r,this.vs=s,this.fs=a,this.ps=new bYt(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new KGt,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(D7.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.Fs():this.gs()}captureLog(e,n){var o;if(this._instance.isDisabled||this._instance.optedOut||!e?.body)return;const i=this.Os(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:_jo(i,(o=n?.context)!==null&&o!==void 0?o:this.hs(),this.A,n?.occurredAtMs)};this.ds(()=>this.Ls(r))}Os(e){const n=this.Mr.beforeSend;if(!n)return e;const o=qr(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 ng(function*(){if(!e._instance.isDisabled)return e.ys||(e.ys=e.Ns().finally(()=>{e.ys=null})),e.ys})()}Ns(){var e=this;return ng(function*(){var n;e.ps.clear();let o=(n=e._instance.getPersistedProperty(D7.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),u=BYt(l.map(h=>h.record),e.qs(),(s=e.fs)!==null&&s!==void 0?s:e._instance.getLibraryId(),e._instance.getLibraryVersion()),g=yield e._instance.js(u);if(e._s!==A)return;if(g.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(g),e.ps.pending&&e.ps.arm(Math.max(e.Ms,e.ws.remainingMs())),g.kind==="retry-later"||(g.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."):g.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(D7.LogsQueue))!==null&&a!==void 0?a:[],r+=l.length,g.kind==="fatal"))throw g.error}})()}Bs(e){var n=this;return ng(function*(){var o;const i=Math.max(0,e-n.bs),r=(o=n._instance.getPersistedProperty(D7.LogsQueue))!==null&&o!==void 0?o:[];n._instance.setPersistedProperty(D7.LogsQueue,r.slice(i)),yield n.vs()})()}qs(){return EYt(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(e){var n;if(this._instance.optedOut)return;const o=(n=this._instance.getPersistedProperty(D7.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(D7.LogsQueue,o),this.Ts>o.length||this.ws.isOpen()?this.Fs():this.gs()}Fs(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}zs(){return Math.max(QYt(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){const e=this._instance.getPersistedProperty(D7.LogsQueue);return!!e&&e.length>0}shutdown(e){var n=this;return ng(function*(){n.ps.clear();const o=n.flush().catch(()=>{});e!==void 0?yield jGt(o,e):yield o})()}flushWithTimeout(e){var n=this;return ng(function*(){const o=n.flush();yield jGt(o,e,()=>{o.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},e=>{this.ks++,this.Ss=SYt(),this.A.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.zs())})}};const gRe=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function vYt(t){return String(t)+"000000"}function wYt(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 Cjo=class{constructor(e,n,o){this._instance=e,this.Mr=n,this.A=o,this.Hs=new Map,this.ps=new bYt(()=>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 KGt,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=ng(function*(){n&&(yield n.catch(()=>{})),yield e.Zs()});return function(){return i.apply(this,arguments)}})()().finally(()=>{this.ys===o&&(this.ys=null)});return this.ys=o,o}drainWindow(){if(this.Hs.size===0)return null;const e=this.Hs;return this.Hs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Js(e)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.Hs=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.Os(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?Zt({},n.attributes):void 0,i=wYt(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.Hs.get(i);if(!r){if(!this.Ks())return;r={name:n.name,type:n.type,unit:n.unit,attributes:o,windowStartMs:Date.now()},this.Hs.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.Fs()}Ks(){return this.Mr.maxSeriesPerFlush>this.Hs.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(gRe.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,gRe)]+=1;break}}}Os(e){const n=this.Mr.beforeSend;if(!n)return e;const o=qr(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}Fs(){this.ps.pending||this.ps.arm(this.zs())}zs(){return Math.max(QYt(this.Mr.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Zs(){var e=this;return ng(function*(){if(e.ps.clear(),e.Hs.size===0)return;const n=e.Hs;e.Hs=new Map,e.Us=!1,e.Ws=new Map,e.Vs=new Set;const o=e.Gs,i=yield e._instance.Ys(e.Js(n));if(o===e.Gs)switch(e.ws.record(i),i.kind==="retry-later"?(e.ks++,e.Ss=SYt()):(e.ks=0,e.Ss=1),e.ps.pending&&e.ps.arm(e.zs()),i.kind){case"ok":return;case"retry-later":return e.co(n),void e.ps.armNoEarlierThan(e.zs());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)}})()}Js(e){return n=this.ho(e),o=(function(s,a,A){return IYt(s,a,A)})(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),i=this._instance.getLibraryId(),r=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:CYt(o)},scopeMetrics:[{scope:{name:i,version:r},metrics:n}]}]};var n,o,i,r}ho(e){const n=vYt(Date.now()),o=new Map;for(const a of e.values()){var i;const A=wYt(a.type,a.name,a.unit,void 0);let c=o.get(A);c||(c=Zt({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=_de((i=a.attributes)!==null&&i!==void 0?i:{},this.A),u=vYt(a.windowStartMs);if(a.type==="count"){var r;const g={attributes:l,startTimeUnixNano:u,timeUnixNano:n,asDouble:(r=a.total)!==null&&r!==void 0?r:0};c.sum.dataPoints.push(g)}else if(a.type==="gauge"){var s;const g={attributes:l,timeUnixNano:n,asDouble:(s=a.last)!==null&&s!==void 0?s:0};c.gauge.dataPoints.push(g)}else a.hist&&c.histogram.dataPoints.push({attributes:l,startTimeUnixNano:u,timeUnixNano:n,count:a.hist.count,sum:a.hist.sum,min:a.hist.min,max:a.hist.max,bucketCounts:a.hist.bucketCounts,explicitBounds:gRe})}return Array.from(o.values())}co(e){for(const[i,r]of e){const s=this.Hs.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.Hs.set(i,r)}}};const PYt=(t,{debugEnabled:e}={})=>{const n={N(o,...i){let r;try{r=typeof window>"u"?void 0:window}catch{return}r&&(uS.DEBUG||r.POSTHOG_DEBUG||e)&&!Eo(r.console)&&r.console&&("__rrweb_original__"in r.console[o]?r.console[o].__rrweb_original__:r.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)=>PYt(`${t} ${o}`,i)};return n},li=PYt("[PostHog.js]"),xd=li.createLogger,yjo=xd("[ExternalScriptsLoader]"),Ide=t=>{const e=qo?.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]}},GR=(t,e,n)=>{if(t.config.disable_external_dependency_loading)return yjo.warn(`${e} was requested but loading of external scripts is disabled.`),n("Loading of external scripts is disabled");const o=Ide(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(!qo)return n("document not found");if(Ide(e))return GR(t,e,n);let r=qo.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")qo.head.appendChild(r);else{const a=qo.querySelectorAll("body > script");var s;a.length>0?(s=a[0].parentNode)===null||s===void 0||s.insertBefore(r,a[0]):qo.body.appendChild(r)}};qo?.body?i():qo?.addEventListener("DOMContentLoaded",i)},dRe={},MYt=(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)};Kr.__PosthogExtensions__=Kr.__PosthogExtensions__||{},Kr.__PosthogExtensions__.loadExternalDependency=(t,e,n)=>{if(e==="remote-config"){const i=t.requestRouter.endpointFor("assets",`/array/${t.config.token}/config.js`);return void GR(t,i,n)}const o=t.config.strict_script_versioning;if(o){const i=t.requestRouter.endpointFor("assets",`/static/${t.version}/${e}.js`),r=dRe[i];if(o==="fallback"&&r){if(Ide(r))return void GR(t,r,n);delete dRe[i]}return void GR(t,i,o==="fallback"?(s,a)=>{if(s)if(typeof s=="string")n(s);else{var A;const c=MYt(t,e);dRe[i]=c;const l=Ide(i);l==null||(A=l.parentNode)===null||A===void 0||A.removeChild(l),GR(t,c,n)}else n(void 0,a)}:n)}GR(t,MYt(t,e),n)},Kr.__PosthogExtensions__.loadSiteApp=(t,e,n)=>{const o=t.requestRouter.endpointFor("api",e);GR(t,o,n)},uS.DEBUG=!1,uS.LIB_VERSION="1.438.4",uS.LIB_NAME="web";var df=uS;const hRe="$early_access_features",dS="$active_feature_flags",YR="$feature_flag_details",I$="$feature_flag_errors",tP="$feature_flag_evaluated_at",UR="$feature_flag_request_id",C$="$minimal_flag_called_events",XB="$enabled_feature_flags",nP="$stored_group_properties",oP="$stored_person_properties",iP="$flag_call_reported",y$="$flag_call_reported_session_id",rP="$feature_flag_payloads",R7="$override_feature_flags",KR="$override_feature_flag_payloads",x$="visibilitychange",xjo="$people_distinct_id",ZB="distinct_id",mRe="$device_id",pRe="$device_model",Cde="__alias",Ejo="__cmpns",DYt="$fbc",yG="$fbc_persistence",NYt="$fbp",E$="$fbp_persistence",fRe="__timers",RYt="$autocapture_disabled_server_side",_Re="$heatmaps_enabled_server_side",IRe="$exception_capture_enabled_server_side",TYt="$error_tracking_suppression_rules",CRe="$error_tracking_capture_extension_exceptions",yRe="$web_vitals_enabled_server_side",xRe="$dead_clicks_enabled_server_side",ERe="$product_tours_enabled_server_side",kYt="$logs_capture_enabled_server_side",FYt="$web_vitals_allowed_metrics",B$="$session_recording_remote_config",Bjo="$session_recording_enabled_server_side",bjo="$replay_sample_rate",Sjo="$replay_override_sampling",Qjo="$replay_override_linked_flag",vjo="$replay_override_url_trigger",wjo="$replay_override_event_trigger",xG="$sesid",LYt="$session_is_sampled",Pjo="$session_past_minimum_duration",Mjo="$session_recording_url_trigger_activated_session",Djo="$session_recording_event_trigger_activated_session",Njo="$debug_first_full_snapshot_timestamp",Rjo="$sess_rec_flush_size",HYt="$groups",b$="$surveys",yde="$surveys_loaded_at",OYt="$surveys_activated",GYt="$surveys_activated_session",YYt="$surveys_activated_timestamps",BRe="ph_product_tours",Tjo="$product_tours_activated",kjo="$product_tours_activated_session",Fjo="$conversations_widget_session_id",Ljo="$conversations_ticket_id",Hjo="$conversations_widget_state",Ojo="$conversations_user_traits",g2="$user_state",bRe="$client_session_props",Gjo="$capture_rate_limit",UYt="$initial_campaign_params",KYt="$initial_referrer_info",EG="$initial_person_info",SRe="$epp",QRe="$posthog_cookieless",zYt="$cookieless_mode",VYt="$sdk_debug_extensions_init_method",JYt="$sdk_debug_extensions_init_time_ms",vRe="$sdk_debug_recording_script_not_loaded",wRe="$sdk_debug_replay_stale_config",WYt="$sdk_debug_replay_event_trigger_status",jYt="$sdk_debug_replay_linked_flag_trigger_status",qYt="$sdk_debug_replay_matched_recording_trigger_groups",$Yt="$sdk_debug_replay_pending_trigger_conditions",XYt="$sdk_debug_replay_remote_trigger_matching_config",ZYt="$sdk_debug_replay_trigger_groups_count",eUt="$sdk_debug_replay_url_trigger_status",Yjo="$session_recording_start_reason",PRe="PostHog loadExternalDependency extension not found.",hS="anonymous",xde="identified",tUt="identified_only",Ede="beforeunload",MRe="$pageview",nUt="$pageleave",oUt="$identify",iUt="$groupidentify";function BG(t,e){qr(t)&&t.forEach(e)}function Cl(t,e){if(!Hs(t))if(qr(t))t.forEach(e);else if((n=>n instanceof FormData)(t))t.forEach((n,o)=>e(n,o));else for(const n in t)UNe.call(t,n)&&e(t[n],n)}const og=function(t,...e){for(const n of e)for(const o in n)n[o]!==void 0&&(t[o]=n[o]);return t};function Bde(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 Ujo=function(t){return function(...e){try{return t.apply(this,e)}catch(n){li.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),li.critical(n)}}},DRe=function(t){const e={};return Cl(t,function(n,o){(Za(n)&&n.length>0||gh(n))&&(e[o]=n)}),e};function rUt(t){const e=Zt({},t);for(const n of["name","message","stack","cause","errors"])try{n in t&&(e[n]=t[n])}catch{}return e}const Kjo=["herokuapp.com","vercel.app","netlify.app"];function zjo(t){const e=t?.hostname;if(!Za(e))return!1;const n=e.split(".").slice(-2).join(".");for(const o of Kjo)if(n===o)return!1;return!0}function Zc(t,e,n,o){const{capture:i=!1,passive:r=!0}=o??{};t?.addEventListener(e,n,{capture:i,passive:r})}function NRe(t){return t.name==="ph_toolbar_internal"}const S$=t=>{if(qo){try{const e=t+"=",n=qo.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 gh(t)&&isFinite(t)&&Math.floor(t)===t});var Vjo=class dat{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 dat(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 dat(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}},Jjo=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 gh(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 Vjo.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 Wjo}};let sUt=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};jn&&!Eo(jn.crypto)&&crypto.getRandomValues&&(sUt=t=>crypto.getRandomValues(t));var Wjo=class{nextUint32(){return this.Rt.length>this.Et||(sUt(this.Rt),this.Et=0),this.Rt[this.Et++]}constructor(){this.Rt=new Uint32Array(8),this.Et=1/0}};let aUt;const e9=()=>jjo().toString(),jjo=()=>(aUt||(aUt=new Jjo)).generate();let Q$="";const qjo=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let bG=null;const Ed={At(){if(!yd(bG))return bG;if(bG=!1,qo)try{const t=`__ph_cookie_support_${e9()}`;Ed.$t(t,"xyz"),bG=S$(t)==='"xyz"',Ed.Pt(t)}catch{bG=!1}return bG},Dt(t){li.error("cookieStore error: "+t)},Ot:S$,Ft(t){let e;try{e=JSON.parse(Ed.Ot(t))||{}}catch{}return e},$t(t,e,n,o,i){if(!qo)return!1;try{let r="",s="";const a=(function(c,l){if(l){let u=(function(g,h=qo){if(Q$)return Q$;if(!h||["localhost","127.0.0.1"].includes(g))return"";const d=g.split(".");let m=Math.min(d.length,8);const p="dmn_chk_"+e9();for(;!Q$&&m--;){const f=d.slice(m).join("."),_=p+"=1;domain=."+f+";path=/";h.cookie=_+";max-age=3",h.cookie.includes(p)&&(h.cookie=_+";max-age=0",Q$=f)}return Q$})(c);if(!u){const g=(h=>{const d=h.match(qjo);return d?d[0]:""})(c);g!==u&&li.info("Warning: cookie subdomain discovery mismatch",g,u),u=g}return u?"; domain=."+u:""}return""})(qo.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&&li.warn("cookieStore warning: large cookie, len="+A.length),qo.cookie=A,!0}catch{return!1}},Pt(t,e){if(qo?.cookie&&(!e||!yd(S$(t))))try{Ed.$t(t,"",-1,e)}catch{return}}};let RRe=null;const hc={At(){if(!yd(RRe))return RRe;let t=!0;if(Eo(jn))t=!1;else try{const e="__mplssupport__";hc.$t(e,"xyz"),hc.Ot(e)!=='"xyz"'&&(t=!1),hc.Pt(e)}catch{t=!1}return t||li.error("localStorage unsupported; falling back to cookie store"),RRe=t,t},Dt(t){li.error("localStorage error: "+t)},Ot(t){try{return jn?.localStorage.getItem(t)}catch(e){hc.Dt(e)}return null},Ft(t){try{return JSON.parse(hc.Ot(t))||{}}catch{}return null},$t(t,e){try{return jn?.localStorage.setItem(t,JSON.stringify(e)),!0}catch(n){hc.Dt(n)}return!1},Pt(t){try{jn?.localStorage.removeItem(t)}catch(e){hc.Dt(e)}}},TRe=[oP,dS,XB,YR,rP,UR,tP,I$,iP],zR=[mRe,ZB,xG,LYt,SRe,EG,yG,g2],bde=t=>t+"_cpm",$jo=["__proto__","constructor","prototype"],kRe=t=>{if(!va(t))return{};const e={};return Object.keys(t).forEach(n=>{$jo.indexOf(n)===-1&&(e[n]=t[n])}),e},FRe=(t,e=[])=>{const n={};return[...zR,...e].forEach(o=>{const i=t[o];Eo(i)||yd(i)||i===""||(n[o]=i)}),n},AUt=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)},cUt=(t,e)=>({p:e,f:AUt(JSON.stringify(t))}),lUt=(t,e)=>{if(!e)return{properties:[],isValid:!1};try{const n=Ed.Ft(bde(t)),o=n?.f===AUt(e)&&qr(n.p);return{properties:o?n.p:[],isValid:o}}catch{return{properties:[],isValid:!1}}},LRe=(t,e)=>e+"|"+(Ed.Ot(bde(t))||""),SG={},HRe={At:()=>!0,Dt(t){li.error("memoryStorage error: "+t)},Ot:t=>t in SG?SG[t]:null,Ft:t=>t in SG?SG[t]:null,$t:(t,e)=>(SG[t]=e,!0),Pt(t){delete SG[t]}};let VR=null;const ou={At(){if(!yd(VR))return VR;if(VR=!0,Eo(jn))VR=!1;else try{const t="__support__";ou.$t(t,"xyz"),ou.Ot(t)!=='"xyz"'&&(VR=!1),ou.Pt(t)}catch{VR=!1}return VR},Dt(t){li.error("sessionStorage error: ",t)},Ot(t){try{return jn?.sessionStorage.getItem(t)}catch(e){ou.Dt(e)}return null},Ft(t){try{return JSON.parse(ou.Ot(t))||null}catch{}return null},$t(t,e){try{return jn?.sessionStorage.setItem(t,JSON.stringify(e)),!0}catch(n){ou.Dt(n)}return!1},Pt(t){try{jn?.sessionStorage.removeItem(t)}catch(e){ou.Dt(e)}}};var Xjo=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 zNe(e)?1:jr($Jo,e)?0:-1}get No(){const e=this.Mr.opt_out_capturing_persistence_type,n=e==="localStorage"?hc:Ed,o=n.At()?n:HRe;if(!this.jo||this.jo!==o){this.jo=o;const i=e==="localStorage"?Ed:hc;i.Ot(this.qo)&&(this.jo.Ot(this.qo)||this.optInOut(zNe(i.Ot(this.qo))),i.Pt(this.qo,this.Mr.cross_subdomain_cookie))}return this.jo}Do(){return!!this.Mr.respect_dnt&&[I_?.doNotTrack,I_?.msDoNotTrack,Kr.doNotTrack,I_?.globalPrivacyControl].some(e=>zNe(e))}};function uUt(t,e){var n;const o=t==null||(n=t.config)===null||n===void 0?void 0:n.get_current_url;if(!pp(o))return e;try{const i=o(e);return Za(i)&&i?i:e}catch(i){return li.error("Error in get_current_url, falling back to window.location.href",i),e}}function gUt(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 t9(t){return!!t&&t.nodeType===1}function BI(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function dUt(t){return!!t&&t.nodeType===3}function ORe(t){return!!t&&t.nodeType===11&&t9(t.host)}function GRe(t){return t?fG(t).split(/\s+/):[]}function hUt(t,e){const n=(function(o){var i;const r=jn==null||(i=jn.location)===null||i===void 0?void 0:i.href;return Eo(r)?void 0:uUt(o,r)})(e);return!!(n&&t&&t.some(o=>n.match(o)))}function QG(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 GRe(e)}function mUt(t){return Hs(t)?null:fG(t).split(/(\s+)/).filter(e=>wG(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function v$(t){let e="";return JR(t)&&!vG(t)&&t.childNodes&&t.childNodes.length&&Cl(t.childNodes,function(n){var o;dUt(n)&&n.textContent&&(e+=(o=mUt(n.textContent))!==null&&o!==void 0?o:"")}),fG(e)}function w$(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 YRe=["a","button","form","input","select","textarea","label"];function URe(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 KRe(t,e){if(Eo(e))return!0;for(const n of t)if(e.some(o=>URe(n,o)))return!0;return!1}function pUt(t){const e=t.parentNode;return!(!e||!t9(e))&&e}const zRe=[".ph-no-autocapture","[data-ph-no-autocapture]"],fUt=["next","previous","prev",">","<","→","←","›","‹","»","«","▶","◀","❯","❮"],VRe=[...fUt,"+","-","−","–"],_Ut=VRe.length+10,Zjo=["button","a","input","select","textarea","label"],eqo=["button","link","tab","menuitem","option"],IUt=(t,e)=>/[a-z0-9]/i.test(e)?jr(VRe,e)?new RegExp(`\\b${e}\\b`).test(t):t.includes(e):t===e,tqo=t=>jr(Zjo,t.tagName.toLowerCase())||jr(eqo,(t.getAttribute("role")||"").toLowerCase());function JRe(t){let e="",n="";const o=s=>{t9(s)&&JR(s)&&!vG(s)&&(e+=` ${v$(s)}`,n=n||s.getAttribute("aria-label")||"",Cl(s.childNodes,o))};o(t),e=fG(e.replace(/\s+/g," "));const i=(wG(e)?e:"").toLowerCase(),r=t.getAttribute("aria-label")||(i?"":n);return{safeText:i,ariaLabel:fG(r).toLowerCase()}}const CUt=[".ph-no-rageclick",".ph-no-capture"],nqo=["","text","search","email","password","url","tel","number"];function yUt(t,e){if(!jn||WRe(t))return!1;let n,o,i;var r,s;if(u2(e)?(n=!!e&&CUt,o=void 0,i=!1):(n=(r=e?.css_selector_ignorelist)!==null&&r!==void 0?r:CUt,o=e?.content_ignorelist,i=(s=e?.ignore_text_selection)!==null&&s!==void 0&&s),n===!1||i&&(function(A){return!(!A||!t9(A))&&(!!BI(A,"textarea")||(BI(A,"input")?jr(nqo,(A.getAttribute("type")||"").toLowerCase()):(function(c){var l;if(c.isContentEditable)return!0;const u=(l=c.getAttribute)===null||l===void 0?void 0:l.call(c,"contenteditable");return u==="true"||u===""})(A)))})(t))return!1;const{targetElementList:a}=xUt(t,!1);return!(o&&(function(A,{safeText:c,ariaLabel:l}){let u;if(A===!0)u=fUt;else{if(!qr(A))return!1;if(A.length>_Ut)return li.error(`[PostHog] content_ignorelist array cannot exceed ${_Ut} items. Use css_selector_ignorelist for more complex matching.`),!1;u=A.map(g=>g.toLowerCase())}return u.some(g=>IUt(c,g)||IUt(l,g))})(o,(function(A,c){for(const l of c)if(tqo(l))return JRe(l);for(const l of c){try{if(jn?.getComputedStyle(l).getPropertyValue("cursor")!=="pointer")break}catch{break}const u=JRe(l);if(u.safeText||u.ariaLabel)return u}return JRe(A)})(t,a))||KRe(a,n))}const WRe=t=>!t||BI(t,"html")||!t9(t),xUt=(t,e)=>{if(!jn||WRe(t))return{parentIsUsefulElement:!1,targetElementList:[]};let n=!1;const o=[t];let i=t;for(;i.parentNode&&!BI(i,"body");){if(ORe(i.parentNode)){o.push(i.parentNode.host),i=i.parentNode.host;continue}const r=pUt(i);if(!r)break;if(e||YRe.indexOf(r.tagName.toLowerCase())>-1)n=!0;else try{const s=jn.getComputedStyle(r);s&&s.getPropertyValue("cursor")==="pointer"&&(n=!0)}catch{}o.push(r),i=r}return{parentIsUsefulElement:n,targetElementList:o}};function JR(t){const e=new Set;let n=0;for(let r=t;r.parentNode&&!BI(r,"body");r=r.parentNode){if(n++>=1e3||e.has(r))return!1;e.add(r);const s=QG(r);if(jr(s,"ph-sensitive")||jr(s,"ph-no-capture"))return!1}if(jr(QG(t),"ph-include"))return!0;const o=t.type||"";if(Za(o))switch(o.toLowerCase()){case"hidden":case"password":return!1}const i=t.name||t.id||"";return!Za(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 vG(t){return!!(BI(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||BI(t,"select")||BI(t,"textarea")||t.getAttribute("contenteditable")==="true")}const EUt=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}))$"),BUt=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,oqo=[16,15,14,13],iqo=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),bUt=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),SUt=/[0-9A-Za-z_]/;function rqo(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 wG(t,e=!0){return!(Hs(t)||Za(t)&&(t=fG(t),(e?EUt.test((t||"").replace(/[- ]/g,"")):(function(n){let o;for(BUt.lastIndex=0;o=BUt.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 oqo){const A=s+a;if(r.length>=A){const c=r.slice(s,A);if(EUt.test(c)&&rqo(c))return!0}}}return!1})(t))||(e?iqo.test(t):(function(n){let o;for(bUt.lastIndex=0;o=bUt.exec(n);){const i=o[1],r=o[3];if(!(i&&r&&SUt.test(i)&&SUt.test(r)))return!0}return!1})(t))))}function QUt(t){let e=v$(t);return e=`${e} ${vUt(t)}`.trim(),wG(e)?e:""}function vUt(t){let e="";return t&&t.childNodes&&t.childNodes.length&&Cl(t.childNodes,function(n){var o;if(n&&((o=n.tagName)===null||o===void 0?void 0:o.toLowerCase())==="span")try{const i=v$(n);e=`${e} ${i}`.trim(),n.childNodes&&n.childNodes.length&&(e=`${e} ${vUt(n)}`.trim())}catch(i){li.error("[AutoCapture]",i)}}),e}function wUt(t){return t.replace(/"|\\"/g,'\\"')}function sqo(t){const e=t.attr__class;if(e)return qr(e)?e:GRe(e)}const Sde=xd("[Dead Clicks]"),aqo=()=>!0,Aqo=t=>{var e;const n=!!(!((e=t.instance.persistence)===null||e===void 0)&&e.get_property(xRe)),o=t.instance.config.capture_dead_clicks;return u2(o)?o:!!va(o)||n};var PUt=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({[xRe]:n.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.zo(()=>{this.Ho()}):this.stop()}zo(e){var n,o,i;!((n=Kr.__PosthogExtensions__)===null||n===void 0)&&n.initDeadClicksAutocapture?e():(o=Kr.__PosthogExtensions__)===null||o===void 0||(i=o.loadExternalDependency)===null||i===void 0||i.call(o,this.instance,"dead-clicks-autocapture",r=>{r?Sde.error("failed to load script",r):e()})}Ho(){var e;if(qo){if(!this.Bo&&(!((e=Kr.__PosthogExtensions__)===null||e===void 0)&&e.initDeadClicksAutocapture)){const n=va(this.instance.config.capture_dead_clicks)?Zt({},this.instance.config.capture_dead_clicks):{};n.__onCapture=this.onCapture,this.onCapture&&(n.capture_dead_swipes=!1),this.Bo=Kr.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this.Bo.start(qo),Sde.info("starting...")}}else Sde.error("`document` not found. Cannot start.")}stop(){this.Bo&&(this.Bo.stop(),this.Bo=void 0,Sde.info("stopping..."))}};const P$=xd("[SegmentIntegration]");function MUt(t,e,n=!0){const o=t.config.segment;if(!o)return e();const{analytics:i,filterProperties:r}=(a=>pp(a.register))(s=o)?{analytics:s}:s;var s;(function(a,A,c,l){const u=h=>{const d=()=>h.anonymousId()||e9();a.config.get_device_id=d,l&&h.id()&&(a.register({distinct_id:h.id(),$device_id:d()}),a.persistence.set_property(g2,xde)),c(l?void 0:h.anonymousId()||void 0)},g=A.user();"then"in g&&pp(g.then)?g.then(u):u(g)})(t,i,a=>{i.register(((A,c,{filterProperties:l}={})=>{typeof Promise<"u"&&Promise.resolve||P$.warn("This browser does not have Promise support, and can not use the segment integration");const u=(g,h)=>{if(!h)return g;const d=!!c&&g.event.anonymousId===c&&!g.event.userId;d||g.event.userId||g.event.anonymousId===A.get_distinct_id()||(P$.info("No userId set, resetting PostHog"),A.reset()),d||(c=void 0),g.event.userId&&g.event.userId!==A.get_distinct_id()&&(P$.info("UserId set, identifying with PostHog"),A.identify(g.event.userId));let m=A.calculateEventProperties(h,g.event.properties);if(!Hs(l)){const p=g.event.properties||{},f={};for(const I of Object.keys(m))UNe.call(p,I)||(f[I]=m[I]);const _=((I,C)=>{const y=qr(I)?I:[I];let x=Zt({},C);for(const E of y)try{if(x=E(x),Hs(x))return null}catch(B){return P$.error("Error in Segment filterProperties:",B),null}return x})(l,f);if(Hs(_))return g;m=_}return g.event.properties=Object.assign({},m,g.event.properties),g};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(g){return u(g,g.event.event)},page(g){return u(g,MRe)},identify(g){return u(g,oUt)},screen(g){return u(g,"$screen")}}})(t,a,{filterProperties:r})).then(()=>{e()},A=>{P$.error("Failed to register the Segment integration",A),e()})},n)}const DUt="posthog-js";function NUt(t,{organization:e,projectId:n,prefix:o,severityAllowList:i=["error"],sendExceptionsToPostHog:r=!0}={}){return s=>{var a,A,c,l,u;if(i!=="*"&&!i.includes(s.level)||!t.__loaded)return s;s.tags||(s.tags={});const g=t.requestRouter.endpointFor("ui",`/project/${t.config.token}/person/${t.get_distinct_id()}`);s.tags["PostHog Person URL"]=g,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(f=>Zt(Zt({},f),{},{stacktrace:f.stacktrace?Zt(Zt({},f.stacktrace),{},{type:"raw",frames:(f.stacktrace.frames||[]).map(_=>Zt(Zt({},_),{},{platform:"web:javascript"}))}):void 0})),m={$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:(u=h[0])===null||u===void 0?void 0:u.type,$sentry_tags:s.tags};var p;return e&&n&&(m.$sentry_url=(o||"https://sentry.io/organizations/")+e+"/issues/?project="+n+"&query="+s.event_id),r&&((p=t.exceptions)===null||p===void 0||p.sendExceptionEvent(m)),s}}var cqo=class{constructor(e,n,o,i,r,s){this.name=DUt,this.setupOnce=function(a){a(NUt(e,{organization:n,projectId:o,prefix:i,severityAllowList:r,sendExceptionsToPostHog:s==null||s}))}}},RUt=class{constructor(e){this.Uo=(n,o,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(li.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=jn?.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:u}=r;if(!(Eo(s)||Eo(a)||Eo(A)||Eo(c)||Eo(l)||Eo(u))){s=Math.ceil(s),a=Math.ceil(a),A=Math.ceil(A),c=Math.ceil(c),l=Math.ceil(l),u=Math.ceil(u);const g=s>1?N7(a/s,0,1,li):1,h=s>1?N7(A/s,0,1,li):1,d=c>1?N7(l/c,0,1,li):1,m=c>1?N7(u/c,0,1,li):1;i=og(i,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:g,$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:u,$prev_pageview_max_content_percentage:m})}}return o.pathname&&(i.$prev_pageview_pathname=o.pathname),o.timestamp&&(i.$prev_pageview_duration=(e.getTime()-o.timestamp.getTime())/1e3),i}};const M$=["flags","surveys"],lqo={[xjo]:{exposure:"hidden"},[Cde]:{exposure:"hidden"},[Ejo]:{exposure:"hidden"},[fRe]:{exposure:"hidden"},[yG]:{exposure:"hidden"},[E$]:{exposure:"hidden"},[RYt]:{exposure:"event"},[_Re]:{exposure:"hidden"},[kYt]:{exposure:"hidden"},[IRe]:{exposure:"event"},[TYt]:{exposure:"hidden"},[CRe]:{exposure:"event"},[yRe]:{exposure:"event"},[xRe]:{exposure:"event"},[ERe]:{exposure:"hidden"},[FYt]:{exposure:"event"},[B$]:{exposure:"hidden"},[Bjo]:{exposure:"hidden"},[xG]:{exposure:"hidden"},[LYt]:{exposure:"event"},[bjo]:{exposure:"event",shouldSkipFromEventProperties:t=>yd(t)},[Pjo]:{exposure:"event"},[Mjo]:{exposure:"event"},[Djo]:{exposure:"event"},[Njo]:{exposure:"event"},[Rjo]:{exposure:"hidden"},[XB]:{exposure:"hidden",storageGroup:"flags"},[dS]:{exposure:"hidden",storageGroup:"flags"},[hRe]:{exposure:"hidden"},[YR]:{exposure:"hidden",storageGroup:"flags"},[rP]:{exposure:"hidden",storageGroup:"flags"},[UR]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[C$]:{exposure:"hidden",storageGroup:"flags"},[R7]:{exposure:"hidden"},[KR]:{exposure:"hidden"},[oP]:{exposure:"hidden"},[nP]:{exposure:"hidden"},[b$]:{exposure:"hidden",storageGroup:"surveys"},[yde]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[OYt]:{exposure:"event"},[GYt]:{exposure:"hidden"},[YYt]:{exposure:"hidden"},[BRe]:{exposure:"hidden"},[Tjo]:{exposure:"hidden"},[kjo]:{exposure:"hidden"},[Fjo]:{exposure:"event"},[Ljo]:{exposure:"event"},[Hjo]:{exposure:"event"},[Ojo]:{exposure:"event"},[iP]:{exposure:"hidden"},[y$]:{exposure:"hidden"},[HYt]:{exposure:"event"},[I$]:{exposure:"hidden"},[tP]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[g2]:{exposure:"hidden"},[bRe]:{exposure:"hidden"},[Gjo]:{exposure:"hidden"},[UYt]:{exposure:"hidden"},[KYt]:{exposure:"hidden"},[EG]:{exposure:"hidden"},[SRe]:{exposure:"hidden"},[Sjo]:{exposure:"event"},[Qjo]:{exposure:"event"},[vjo]:{exposure:"event"},[wjo]:{exposure:"event"},[VYt]:{exposure:"event"},[JYt]:{exposure:"event"},[vRe]:{exposure:"hidden"},[wRe]:{exposure:"hidden"},[WYt]:{exposure:"hidden"},[jYt]:{exposure:"hidden"},[qYt]:{exposure:"hidden"},[$Yt]:{exposure:"hidden"},[XYt]:{exposure:"hidden"},[ZYt]:{exposure:"hidden"},[eUt]:{exposure:"hidden"},[Yjo]:{exposure:"event"}},uqo=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],I1=t=>{const e=lqo[t];if(e)return e;for(const[n,o]of uqo)if(t.indexOf(n)===0)return o};function TUt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}const kUt=()=>{try{return"u">typeof window&&window.navigator.onLine!==!1}catch{return!1}},FUt=(t,e)=>t>=e&&kUt(),LUt=(t,e,n,o)=>{if(t===0){if(kUt()){const i=e+1;return i===n&&o(),i}return e}return 0},PG=(t,e)=>{try{let n;return JSON.stringify(t,(o,i)=>{var r;return _G(i)?((r=n)!==null&&r!==void 0||(n=new WeakMap),n.has(i)||n.set(i,rUt(i)),n.get(i)):typeof i=="bigint"?i.toString():i},e)}catch{return sGt(t)}},mS=t=>{const e=qo?.createElement("a");return Eo(e)?null:(e.href=t,e)},MG=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(!qr(o)||2>o.length)return"";{let i=o[1];try{i=decodeURIComponent(i)}catch{li.error("Skipping decoding for malformed query param: "+i)}return i.replace(/\+/g," ")}},D$=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 u=0;A.length>u;u++){const g=A[u].split("=");qr(g)&&(e.includes(g[0])?c.push(g[0]+"="+n):c.push(A[u]))}let l=a;return s!=null&&(l+="?"+c.join("&")),i!=null&&(l+="#"+i),l},Qde=function(t,e){const n=t.match(new RegExp(e+"=([^&]*)"));return n?n[1]:null},DG=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","irclid","_kx"],gqo=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...DG],N$="<masked>",dqo=["li_fat_id"];function HUt(t,e,n){if(!qo)return{};const o=e?[...DG,...n||[]]:[],i=OUt(D$(qo.URL,o,N$),t),r=(function(){const s={};return Cl(dqo,function(a){const A=S$(a);s[a]=A||null}),s})();return og(r,i)}function OUt(t,e){const n=gqo.concat(e||[]),o={};return Cl(n,function(i){const r=MG(t,i);o[i]=r||null}),o}function GUt(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(!yd(e)){o.$search_engine=e;const i=qo?MG(qo.referrer,n):"";i.length&&(o.ph_keyword=i)}return o}function YUt(){return navigator.language||navigator.userLanguage}function hqo(){const t=YUt();return typeof t=="string"?t.split("-")[0]:void 0}const vde="$direct";function UUt(){return qo?.referrer||vde}function KUt(t,e,n=!1){const o=t?[...DG,...e||[]]:[],i=n?eP(tg?.href):tg?.href,r=i?.substring(0,1e3);return{r:UUt().substring(0,1e3),u:r?D$(r,o,N$):void 0}}function zUt(t,e=!1){var n;const{r:o,u:i}=t,r=e?eP(i):i,s={$referrer:o,$referring_domain:o==null?void 0:o==vde?vde:(n=mS(o))===null||n===void 0?void 0:n.host};if(r){s.$current_url=r;const a=mS(r);s.$host=a?.host,s.$pathname=a?.pathname;const A=OUt(r);og(s,A)}if(o){const a=GUt(o);og(s,a)}return s}function mqo(){try{return new Date().getTimezoneOffset()}catch{return}}const pqo={flags:tP,surveys:yde},fqo=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],wde=t=>`${t}_cookie_identity_change_pending`,Pde=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},hf="main",pS=[XB,dS,YR,rP,UR,tP,C$,oP],jRe=t=>pS.indexOf(t)!==-1,VUt=[yG,E$],JUt=t=>VUt.indexOf(t)!==-1,sP=(t,e)=>{try{return JSON.stringify(t)===JSON.stringify(e)}catch{return t===e}},NG=t=>{if(!t)return{};const e=JSON.parse(t);return va(e)?e:{}},WUt=(t,e)=>{Cl(t,(n,o)=>{const i=I1(o);i&&i.exposure!=="event"||{}.hasOwnProperty.call(e,o)||delete t[o]})};var qRe=class{constructor(e,n,o=!0,i=!e.cookieless_mode){if(this.Zo={},this.Jo=!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.ca(e),this.Xo=this.ha(e),this.load(i),this.da(),e.debug&&li.info("Persistence loaded",e.persistence,Zt({},this.props)),this.update_config(e,e,n),this.save(),jn){const r=()=>this.flush();Zc(jn,"beforeunload",r,{capture:!1}),Zc(jn,"pagehide",r,{capture:!1}),this.va=s=>{if(this.Jo&&(!s.storageArea||s.storageArea===jn?.localStorage)&&s.key)if(s.key!==this.ua){if(this.Xo){const a=M$.find(A=>s.key===this.fa(A));a&&this.pa(s.key,a)}}else this.pa(s.key,hf)},Zc(jn,"storage",this.va)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([n,o])=>{const i=this.ea.get(n);if(!jRe(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&&jn&&(jn.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=hc.Ot(e),yd(r)){const A=this.ma(n);return A.storageValue=null,n!==hf&&(A.persisted=!1),!1}i=NG(r)}catch{return!1}const s=n===hf?i:hc.Ft(this.ua);if(s&&this.ya(s))return!1;const a=this.ba(i,n,o);return n===hf&&this.Xo&&!sP(this._a().main,i)||this.wa(i,n,!0,r),a}ya(e){const n=this.props[ZB],o=e[ZB];return!Eo(n)&&!Eo(o)&&n!==o}wa(e,n,o,i){const r=this.ma(n);r.storageValue=i,n!==hf&&(r.persisted=o);try{r.fingerprint=this.ka(e,n)}catch{r.fingerprint=void 0}}ba(e,n,o){let i=!1;return pS.forEach(r=>{var s;const a=(s=I1(r))===null||s===void 0?void 0:s.storageGroup;if(n===hf&&this.Xo&&a||n!==hf&&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&&sP(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.Jo)return!1;try{this.sa=!1;const e=hc.Ot(this.ua),n=this.ma(hf);let o,i=!1,r=!1;if(e!==n.storageValue)if(yd(e))n.storageValue=null;else{if(o=NG(e),this.sa=!this.na&&this.ya(o),this.sa)return!1;r=this.ba(o,hf,!1),!this.Xo||sP(this._a().main,o)?this.wa(o,hf,!0,e):n.storageValue=e,i=!0}return this.Xo&&M$.forEach(s=>{const a=hc.Ot(this.fa(s)),A=this.ma(s),c=o||{},l=i&&pS.some(g=>{var h;return((h=I1(g))===null||h===void 0?void 0:h.storageGroup)===s&&g in c});if(a===A.storageValue&&!l)return;if(yd(a))return A.storageValue=null,A.persisted=!1,void(l&&(r=this.ba(c,s,!1)||r));const u=NG(a);r=this.ba(u,s,!1)||r,this.wa(u,s,!0,a)}),r}catch{return!1}}ga(e,n){this.ea.set(e,n);const o=I1(e);o?.volatile||(this.ma((this.Xo?o?.storageGroup:void 0)||hf).fingerprint=void 0,this.Ta(e))}Ia(){pS.forEach(e=>this.ea.set(e,!0))}da(){if(this.Jo)try{const e=hc.Ot(this.ua),n=NG(e);this.ma(hf).storageValue=e,pS.forEach(o=>{var i;const r=this.Xo?(i=I1(o))===null||i===void 0?void 0:i.storageGroup:void 0,s=r?hc.Ot(this.fa(r)):null;if(r){const A=this.ma(r);A.storageValue=s,A.persisted=!yd(s)}const a=r&&!yd(s)?NG(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(qr(n)?n:[]),a=new Set(qr(this.props[e])?this.props[e]:[]);return o.forEach(A=>a.has(A)?s.add(A):s.delete(A)),Array.from(s)}const i=va(n)?Zt({},n):{},r=va(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(!jRe(e))return;const i=this.ea.get(e);if(i===!0)return;let r=n;if(this.Jo)try{var s;const A=this.Xo?(s=I1(e))===null||s===void 0?void 0:s.storageGroup:void 0,c=A?this.fa(A):this.ua;r=NG(hc.Ot(c))[e]}catch{}const a=new Set(i||[]);if(e==="$active_feature_flags"){if(!Eo(n)&&!qr(n)||!Eo(r)&&!qr(r)||!qr(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(u=>{A.has(u)!==l.has(u)&&a.add(u)}),a.forEach(u=>{c.has(u)===l.has(u)&&a.delete(u)})}else{if(!va(o))return void(sP(r,o)?this.ea.delete(e):this.ga(e,!0));{if(!Eo(n)&&!va(n)||Eo(n)&&Jx(o)&&Eo(r))return void this.ga(e,!0);const A=va(n)?n:{},c=va(r)?r:{};new Set([...Object.keys(A),...Object.keys(o)]).forEach(l=>{l in A==l in o&&sP(A[l],o[l])||a.add(l)}),a.forEach(l=>{l in c==l in o&&sP(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 gh(n)&&n>0?n:0}Pa(e){if(this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie")if(e)try{const n=FRe(e,this.Mr.cookie_persisted_properties||[]),o=cUt(n,this.Mr.cookie_persisted_properties||[]),i=JSON.stringify(n)+"|"+JSON.stringify(o),r=Ed.Ot(this.ua)||void 0;r&&LRe(this.ua,r)===i&&(this.Ra=i,this.Aa=r)}catch{}else try{const n=Ed.Ot(this.ua)||void 0;this.Ra=n?LRe(this.ua,n):void 0,this.Aa=n}catch{}}syncCookieProperties(){return this.Fa(this.Mr)}Fa(e,n=!1){if(this.hi&&!n||this.ta||!e.cookieWinsOnConflict||e.persistence.toLowerCase()!=="localstorage+cookie")return!1;let o;try{o=Ed.Ot(this.ua)||void 0}catch{}if(!o||o===this.Aa)return!1;const i=LRe(this.ua,o);let r;try{r=kRe(JSON.parse(o))}catch{return!1}if((Ed.Ot(this.ua)||void 0)!==o)return!1;this.Ra=i,this.Aa=o;const s=lUt(this.ua,o),a=[...zR,...s.properties],A={};if(Object.keys(r).forEach(p=>{const f=r[p];(Eo(f)||yd(f)||f===""||p==="$user_state"&&f!=="anonymous"&&f!=="identified")&&(A[p]=!0,delete r[p])}),Jx(r))return!1;const c="distinct_id"in r||r.$user_state==="anonymous"||r.$user_state==="identified",l=this.props,u=l[ZB],g=l[g2],h=og({},l);[...zR,...e.cookie_persisted_properties||[]].forEach(p=>{if(a.indexOf(p)!==-1&&!(p in r)&&!A[p]&&(c||p!=="distinct_id"&&p!=="$user_state")){const f=h[p];(s.isValid||zR.indexOf(p)===-1||f!==!1&&f!==0)&&delete h[p]}}),this.props=og(h,r),pS.forEach(p=>{const f=p in this.props;p in l===f&&sP(l[p],this.props[p])||(f?this.Ma(p,l[p],this.props[p]):this.ga(p,!0))}),!c||"$user_state"in r||"$user_state"in this.props||this.xa(g2,hS);const d=this.props[ZB],m=this.props[g2];return!c||d===u&&m===g||(this.na=!0,this.Yo=!0,ou.$t(wde(this.ua),!0),this.$a(oP),this.$a(dS),this.$a(XB),this.$a(YR),this.$a(rP),this.$a(UR),this.$a(tP),this.$a(I$),this.$a(iP),m!=="anonymous"||g!=="identified"&&r.$user_state!=="anonymous"&&(Eo(u)||d===u)||(WUt(this.props,r),this.$a(nP)),m==="identified"?this.props.$user_id=d:delete this.props.$user_id,this.$a(Cde)),!0}consumeCookieIdentityChange(){const e=wde(this.ua),n=this.Yo||!!ou.Ot(e);return this.Yo=!1,n&&ou.Pt(e),n}Oa(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.Zo[hf],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}ca(e){fqo.indexOf(e.persistence.toLowerCase())===-1&&(li.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");const n=((a=[],A=!1,c=()=>!1)=>{const l=[...zR,...a];return Zt(Zt({},hc),{},{Ft(u){try{let h,d={};try{h=Ed.Ot(u)||void 0,d=h?kRe(JSON.parse(h)):{}}catch{}const m=JSON.parse(hc.Ot(u)||"{}");let p;if(A){const f=lUt(u,h),_=[...zR,...f.properties],I={};Object.keys(d).forEach(y=>{const x=d[y];yd(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 g;const y=m[ZB],x=(g=m.$user_state)!==null&&g!==void 0?g:hS;l.forEach(E=>{if(_.indexOf(E)!==-1&&!(E in d)&&(C||E!=="distinct_id"&&E!=="$user_state")){const B=m[E];(f.isValid||zR.indexOf(E)===-1||B!==!1&&B!==0)&&delete m[E]}}),!C||"$user_state"in d||"$user_state"in m||(m[g2]=hS),!C||("distinct_id"in I?I[ZB]:m[ZB])===y&&("$user_state"in I?I[g2]:m[g2])===x||(TRe.forEach(E=>delete m[E]),I.$user_state==="identified"&&"distinct_id"in I?m.$user_id=I[ZB]:delete m.$user_id,I.$user_state!=="identified"&&(delete m[HYt],delete m[nP]),delete m.__alias)}p=og(m,I)}else p=og(d,m);return c()||hc.$t(u,p),p}catch{}return null},$t(u,g,h,d,m,p){const f=hc.$t(u,g,void 0,void 0,p);try{const _=FRe(g,a);if(Object.keys(_).length){if(A){const I=bde(u),C=cUt(_,a);if(Ed.$t(I,C,h,d,m,p),Ed.Ot(I)!==JSON.stringify(C)){Ed.Pt(I,d);const y=FRe(g);return Ed.$t(u,y,h,d,m,p),f}}Ed.$t(u,_,h,d,m,p)}}catch(_){hc.Dt(_)}return f},Pt(u,g){try{jn?.localStorage.removeItem(u),Ed.Pt(u,g),Ed.Pt(bde(u),g)}catch(h){hc.Dt(h)}}})})(e.cookie_persisted_properties||[],e.cookieWinsOnConflict,()=>!!this.hi);let o,i=!1,r=!1;const s=e.persistence.toLowerCase();return s==="localstorage"&&hc.At()?(o=hc,r=!0):s==="localstorage+cookie"&&n.At()?(o=n,r=!0,i=!0):s==="sessionstorage"&&ou.At()?o=ou:s==="memory"?o=HRe:s==="cookie"&&Ed.At()?(o=Ed,i=!0):n.At()?(o=n,r=!0,i=!0):Ed.At()?(o=Ed,i=!0):o=HRe,this.Jo=r,this.Ko=i,o}fa(e){return`${this.ua}__${e}`}ha(e){return this.Jo&&!!e.split_storage}properties(){const e={};return Cl(this.props,(n,o)=>{const i=I1(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?hc.Ft(this.ua):null;let i={};if(n)try{i=kRe(Ed.Ft(this.ua)),Cl(i,(A,c)=>{(Eo(A)||yd(A)||A==="")&&delete i[c]})}catch{}const r=this.No.Ft(this.ua);if(r&&(this.props=og({},r)),this.Xo&&this.ja(),n&&r){var s,a;const A=o?.[ZB],c=(s=o?.$user_state)!==null&&s!==void 0?s:hS,l=r[ZB],u=(a=r.$user_state)!==null&&a!==void 0?a:hS;if(l!==A||u!==c){this.Yo=!0,this.hi||ou.$t(wde(this.ua),!0);const g=og({},this.props);TRe.forEach(d=>delete g[d]),u!=="anonymous"||c!=="identified"&&i.$user_state!=="anonymous"&&(Eo(A)||l===A)||(WUt(g,i),delete g[nP]),this.props=g;const h=new Set;TRe.forEach(d=>{var m;const p=(m=I1(d))===null||m===void 0?void 0:m.storageGroup;p&&h.add(p)}),h.forEach(d=>{if(this.hi)return;const m={};Cl(this.props,(p,f)=>{var _;((_=I1(f))===null||_===void 0?void 0:_.storageGroup)===d&&(m[f]=p)}),Jx(m)?(hc.Pt(this.fa(d)),this.Zo[d]={}):hc.$t(this.fa(d),m)&&(this.Zo[d]={persisted:!0,fingerprint:this.ka(m,d)})})}}ou.Ot(wde(this.ua))&&(this.Yo=!0)}ja(){for(const e of M$){const n=hc.Ft(this.fa(e));if(n&&!Jx(n)){const o=this.ma(e);o.persisted=!0,this.Ba(e)||(o.fingerprint=this.ka(n,e)),this.za(e,n)||og(this.props,n)}}}Ba(e){return Object.keys(this.props).some(n=>{var o;return((o=I1(n))===null||o===void 0?void 0:o.storageGroup)===e})}za(e,n){const o=pqo[e];if(!o)return!1;const i=n[o],r=this.props[o];return gh(i)&&gh(r)&&r>i}refreshKey(e){var n;if(this.hi||this.ra.has(e))return;const o=this.Xo?(n=I1(e))===null||n===void 0?void 0:n.storageGroup:void 0,i=o?hc.Ft(this.fa(o)):this.No.Ft(this.ua);if(i&&e in i)this.xa(e,i[e],!1);else{if(o){const r=this.No.Ft(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"||VUt.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&&li.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this.Xo)return this.Ha(),void(o&&this.oa.forEach(r=>r()));const i=this.Ua(this.No,this.ua,this.props,hf);i==="written"&&this.Pa(this.props),i!=="failed"&&(this.ea.clear(),this.na=!1,this.ra.clear()),o&&this.oa.forEach(r=>r())}Ha(){const{main:e,groups:n}=this._a(),o=this.Ua(this.No,this.ua,e,hf);o==="written"&&this.Pa(e),o!=="failed"&&(this.na=!1,this.ra.clear(),pS.forEach(r=>{var s;!((s=I1(r))===null||s===void 0)&&s.storageGroup||this.ea.delete(r)}));for(const r of M$){var i;const s=n[r];if(Jx(s)&&!(!((i=this.Zo[r])===null||i===void 0)&&i.persisted)){pS.forEach(A=>{var c;((c=I1(A))===null||c===void 0?void 0:c.storageGroup)===r&&this.ea.delete(A)});continue}const a=this.Ua(hc,this.fa(r),s,r);a!=="failed"&&pS.forEach(A=>{const c=I1(A);c?.storageGroup!==r||a!=="written"&&c.volatile||this.ea.delete(A)})}}_a(){const e={},n={flags:{},surveys:{}};return Cl(this.props,(o,i)=>{var r;const s=(r=I1(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===hf)return JSON.stringify(e)+"|"+this.Wa+"|"+this.Va+"|"+this.Ga;const o={};return Cl(e,(i,r)=>{var s;o[r]=!((s=I1(r))===null||s===void 0)&&s.volatile?"__volatile__":i}),JSON.stringify(o)}Ua(e,n,o,i){const r=this.ma(i);if(i!==hf&&!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!==hf&&(r.persisted=!0),Eo(s)||(r.fingerprint=s),this.Jo&&(r.storageValue=hc.Ot(n)),"written"):(this.Mr.debug&&li.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 M$)hc.Pt(this.fa(n));e?delete this.Zo[hf]:this.Zo={},this.Ra=void 0,this.Aa=void 0}clear(){this.remove(),this.props={}}register_once(e,n,o){if(va(e)){this.syncCookieProperties(),Eo(n)&&(n="None"),this.Wa=Eo(o)?this.Qa:o;let i=!1;if(Cl(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(va(e)){this.syncCookieProperties(),this.Wa=Eo(n)?this.Qa:n;let o=!1;if(Cl(e,(i,r)=>{e.hasOwnProperty(r)&&(this.props[r]!==i||va(i)||qr(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=qo?.URL;if(e===this.la)return;const n=HUt(this.Mr.custom_campaign_params,this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties),o=!Jx(DRe(n));return o&&this.register(n),this.la=e,o?n:void 0}update_search_keyword(){this.register((function(){const e=qo?.referrer;return e?GUt(e):{}})())}update_referrer_info(){var e;this.register_once({$referrer:UUt(),$referring_domain:qo?.referrer&&((e=mS(qo.referrer))===null||e===void 0?void 0:e.host)||vde},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const e=KUt(this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties,this.Mr.disable_capture_url_hashes);this.register_once({[EG]:this.Ko?{r:Pde(e.r),u:e.u?Pde(e.u):void 0}:e},void 0)}get_initial_props(){const e={};Cl([KYt,UYt],o=>{const i=this.props[o];i&&Cl(i,function(r,s){e["$initial_"+YNe(s)]=r})});const n=this.props[EG];if(n){const o=(function(i,r=!1){const s=zUt(i,r),a={};return Cl(s,function(A,c){a[`$initial_${YNe(c)}`]=A}),a})(n,this.Mr.disable_capture_url_hashes);og(e,o)}return e}safe_merge(e){return Cl(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,m)=>{if(d.length!==m.length)return!1;const p=[...d].sort(),f=[...m].sort();return p.every((_,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.Fa(n,c),this.Mr=e,!A&&(i||r||a)&&(this.Ra=void 0,this.Aa=void 0,this.Fa(Zt(Zt({},e),{},{cookie_persisted_properties:n.cookie_persisted_properties}),c));const l=s||a?this.ca(e):this.No;this.Za();const u=this.ha(e),g=s||u!==this.Xo,h=!A&&(g||e.cross_subdomain_cookie!==this.Va||e.secure_cookie!==this.Ga)&&this.Oa(c);this.ia=g;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),g){const d=this.props;this.clear(),this.No=l,this.Xo=u,this.props=d,this.save()}else a&&(this.No=l,A||(delete this.Zo[hf],this.Na()))}finally{this.ia=!1,h&&this.qa()}}Za(){const e=this.props[EG];if(!this.Ko||!va(e)||typeof e.r!="string")return;const n=Pde(e.r),o=typeof e.u=="string"?Pde(e.u):e.u;n===e.r&&o===e.u||this.xa(EG,Zt(Zt({},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(fRe,o),this.save()}remove_event_timer(e){const n=this.props.__timers||{},o=n[e];return Eo(o)||(delete n[e],this.xa(fRe,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),JUt(e)&&!sP(r,n)&&this.ra.add(e),this.Ma(e,r,n),!((i=I1(e))===null||i===void 0)&&i.volatile||this.Ta(e))}$a(e,n=!0){delete this.props[e],n&&(jRe(e)&&this.ga(e,!0),JUt(e)&&this.ra.add(e),this.Ta(e))}Ta(e){var n;const o=(n=I1(e))===null||n===void 0?void 0:n.storageGroup;o&&(this.ma(o).dirty=!0)}ma(e){return this.Zo[e]||(this.Zo[e]={})}};const bE={GZipJS:"gzip-js",Base64:"base64"},R$={Activation:"events",Cancellation:"cancelEvents"},$Re={Popover:"popover",API:"api",Widget:"widget"},SE={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},XRe={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},ZRe={Popover:"popover",Inline:"inline"};function Mde(t){let e=!0;return{dispose(){if(e){e=!1;const n=t();n&&pp(n.then)&&n.then(void 0,()=>{})}}}}const _qo={SHOWN:"product tour shown"},jUt={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},qUt=xd("[RateLimiter]");var Iqo=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=>{qUt.info(`${i||"events"} is quota limited.`),this.serverLimits[i]=new Date().getTime()+6e4})}catch(i){return void qUt.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=(gh(A.dropped)?A.dropped:0)+1;A.dropped=l,!this.lastEventRateLimited&&this.Ja(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!qr(n)||!n.includes(e)}Xa(){var e;if(this.Ka("$current_url")&&this.Ka("$pathname")&&tg?.pathname)return`${(e=tg.origin)!==null&&e!==void 0?e:""}${tg.pathname}`}Ja(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 aP=xd("[RemoteConfig]");var $Ut=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=Kr._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=Kr.__PosthogExtensions__)===null||n===void 0)&&n.loadExternalDependency?(o=Kr.__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 aP.info("Using preloaded remote config",this.remoteConfig),void this.el(this.remoteConfig);if(this._instance.il())return void aP.warn("Remote config is disabled. Falling back to local config.");this.Ya(e=>{if(!e)return aP.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){aP.error("Error loading remote config",e),this.el()}}el(e,n){!e&&n&&(n.statusCode===0?n.error||aP.warn("Failed to fetch remote config from PostHog."):aP.error("Failed to fetch remote config from PostHog."));try{this._instance.el(e?{ok:!0,config:e}:{ok:!1})}catch(i){aP.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){aP.error("Error loading feature flags",i)}}},E4=Uint8Array,Wx=Uint16Array,RG=Uint32Array,eTe=new E4([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]),tTe=new E4([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]),XUt=new E4([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ZUt=function(t,e){for(var n=new Wx(31),o=0;31>o;++o)n[o]=e+=1<<t[o-1];var i=new RG(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]},eKt=ZUt(eTe,2),nTe=eKt[1];eKt[0][28]=258,nTe[258]=28;for(var tKt=ZUt(tTe,0)[1],nKt=new Wx(32768),Bd=0;32768>Bd;++Bd){var TG=(43690&Bd)>>>1|(21845&Bd)<<1;nKt[Bd]=((65280&(TG=(61680&(TG=(52428&TG)>>>2|(13107&TG)<<2))>>>4|(3855&TG)<<4))>>>8|(255&TG)<<8)>>>1}var T$=function(t,e,n){for(var o=t.length,i=0,r=new Wx(e);o>i;++i)++r[t[i]-1];var s,a=new Wx(e);for(i=0;e>i;++i)a[i]=a[i-1]+r[i-1]<<1;for(s=new Wx(o),i=0;o>i;++i)s[i]=nKt[a[t[i]-1]++]>>>15-t[i];return s},WR=new E4(288);for(Bd=0;144>Bd;++Bd)WR[Bd]=8;for(Bd=144;256>Bd;++Bd)WR[Bd]=9;for(Bd=256;280>Bd;++Bd)WR[Bd]=7;for(Bd=280;288>Bd;++Bd)WR[Bd]=8;var Dde=new E4(32);for(Bd=0;32>Bd;++Bd)Dde[Bd]=5;var Cqo=T$(WR,9),yqo=T$(Dde,5),oKt=function(t){return(t/8|0)+(7&t&&1)},iKt=function(t,e,n){(n==null||n>t.length)&&(n=t.length);var o=new(t instanceof Wx?Wx:t instanceof RG?RG:E4)(n-e);return o.set(t.subarray(e,n)),o},fS=function(t,e,n){var o=e/8|0;t[o]|=n<<=7&e,t[o+1]|=n>>>8},k$=function(t,e,n){var o=e/8|0;t[o]|=n<<=7&e,t[o+1]|=n>>>8,t[o+2]|=n>>>16},oTe=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 E4(0),0];if(i==1){var s=new E4(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,u=2;for(n[0]={s:-1,f:a.f+A.f,l:a,r:A};l!=i-1;)a=n[n[u].f>n[c].f?c++:u++],A=n[c!=l&&n[u].f>n[c].f?c++:u++],n[l++]={s:-1,f:a.f+A.f,l:a,r:A};var g=r[0].s;for(o=1;i>o;++o)r[o].s>g&&(g=r[o].s);var h=new Wx(g+1),d=iTe(n[l-1],h,0);if(d>e){o=0;var m=0,p=d-e,f=1<<p;for(r.sort(function(y,x){return h[x.s]-h[y.s]||y.f-x.f});i>o;++o){var _=r[o].s;if(e>=h[_])break;m+=f-(1<<d-h[_]),h[_]=e}for(m>>>=p;m>0;){var I=r[o].s;e>h[I]?m-=1<<e-h[I]++-1:++o}for(;o>=0&&m;--o){var C=r[o].s;h[C]==e&&(--h[C],++m)}d=e}return[new E4(h),d]},iTe=function(t,e,n){return t.s==-1?Math.max(iTe(t.l,e,n+1),iTe(t.r,e,n+1)):e[t.s]=n},rKt=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new Wx(++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]},F$=function(t,e){for(var n=0,o=0;e.length>o;++o)n+=t[o]*e[o];return n},rTe=function(t,e,n){var o=n.length,i=oKt(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)},sKt=function(t,e,n,o,i,r,s,a,A,c,l){fS(e,l++,n),++i[256];for(var u=oTe(i,15),g=u[0],h=u[1],d=oTe(r,15),m=d[0],p=d[1],f=rKt(g),_=f[0],I=f[1],C=rKt(m),y=C[0],x=C[1],E=new Wx(19),B=0;_.length>B;++B)E[31&_[B]]++;for(B=0;y.length>B;++B)E[31&y[B]]++;for(var S=oTe(E,7),Q=S[0],w=S[1],M=19;M>4&&!Q[XUt[M-1]];--M);var T,R,F,O,U=c+5<<3,Y=F$(i,WR)+F$(r,Dde)+s,q=F$(i,g)+F$(r,m)+s+14+3*M+F$(E,Q)+(2*E[16]+3*E[17]+7*E[18]);if(Y>=U&&q>=U)return rTe(e,l,t.subarray(A,A+c));if(fS(e,l,1+(Y>q)),l+=2,Y>q){T=T$(g,h),R=g,F=T$(m,p),O=m;var ee=T$(Q,w);for(fS(e,l,I-257),fS(e,l+5,x-1),fS(e,l+10,M-4),l+=14,B=0;M>B;++B)fS(e,l+3*B,Q[XUt[B]]);l+=3*M;for(var W=[_,y],J=0;2>J;++J){var te=W[J];for(B=0;te.length>B;++B)fS(e,l,ee[ie=31&te[B]]),l+=Q[ie],ie>15&&(fS(e,l,te[B]>>>5&127),l+=te[B]>>>12)}}else T=Cqo,R=WR,F=yqo,O=Dde;for(B=0;a>B;++B)if(o[B]>255){var ie;k$(e,l,T[257+(ie=o[B]>>>18&31)]),l+=R[ie+257],ie>7&&(fS(e,l,o[B]>>>23&31),l+=eTe[ie]);var ne=31&o[B];k$(e,l,F[ne]),l+=O[ne],ne>3&&(k$(e,l,o[B]>>>5&8191),l+=tTe[ne])}else k$(e,l,T[o[B]]),l+=R[o[B]];return k$(e,l,T[256]),l+R[256]},xqo=new RG([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Eqo=(function(){for(var t=new RG(256),e=0;256>e;++e){for(var n=e,o=9;--o;)n=(1&n&&3988292384)^n>>>1;t[e]=n}return t})(),sTe=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8};function Bqo(t,e){e===void 0&&(e={});var n=(function(){var u=4294967295;return{p(g){for(var h=u,d=0;g.length>d;++d)h=Eqo[255&h^g[d]]^h>>>8;u=h},d(){return 4294967295^u}}})(),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(u,g,h,d,m,p){var f=u.length,_=new E4(d+f+5*(1+Math.floor(f/7e3))+m),I=_.subarray(d,_.length-m),C=0;if(!g||8>f)for(var y=0;f>=y;y+=65535){var x=y+65535;f>x?C=rTe(I,C,u.subarray(y,x)):(I[y]=p,C=rTe(I,C,u.subarray(y,f)))}else{for(var E=xqo[g-1],B=E>>>13,S=8191&E,Q=(1<<h)-1,w=new Wx(32768),M=new Wx(Q+1),T=Math.ceil(h/3),R=2*T,F=function(Ce){return(u[Ce]^u[Ce+1]<<T^u[Ce+2]<<R)&Q},O=new RG(25e3),U=new Wx(288),Y=new Wx(32),q=0,ee=0,W=(y=0,0),J=0,te=0;f>y;++y){var ie=F(y),ne=32767&y,le=M[ie];if(w[ne]=le,M[ie]=ne,y>=J){var de=f-y;if((q>7e3||W>24576)&&de>423){C=sKt(u,I,0,O,U,Y,ee,W,te,y-te,C),W=q=ee=0,te=y;for(var Ie=0;286>Ie;++Ie)U[Ie]=0;for(Ie=0;30>Ie;++Ie)Y[Ie]=0}var ce=2,fe=0,ue=S,pe=ne-le&32767;if(de>2&&ie==F(y-pe))for(var Me=Math.min(B,de)-1,Se=Math.min(32767,y),he=Math.min(258,de);Se>=pe&&--ue&&ne!=le;){if(u[y+ce]==u[y+ce-pe]){for(var Pe=0;he>Pe&&u[y+Pe]==u[y+Pe-pe];++Pe);if(Pe>ce){if(ce=Pe,fe=pe,Pe>Me)break;var we=Math.min(pe,Pe-2),Qe=0;for(Ie=0;we>Ie;++Ie){var Re=y-pe+Ie+32768&32767,De=Re-w[Re]+32768&32767;De>Qe&&(Qe=De,le=Re)}}}pe+=(ne=le)-(le=w[ne])+32768&32767}if(fe){O[W++]=268435456|nTe[ce]<<18|tKt[fe];var xe=31&nTe[ce],Te=31&tKt[fe];ee+=eTe[xe]+tTe[Te],++U[257+xe],++Y[Te],J=y+ce,++q}else O[W++]=u[y],++U[u[y]]}}C=sKt(u,I,p,O,U,Y,ee,W,te,y-te,C)}return iKt(_,0,d+oKt(C)+m)})(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(u,g){var h=g.filename;if(u[0]=31,u[1]=139,u[2]=8,u[8]=2>g.level?4:g.level==9?2:0,u[9]=3,g.mtime!=0&&sTe(u,4,Math.floor(new Date(g.mtime||Date.now())/1e3)),h){u[3]=8;for(var d=0;h.length>=d;++d)u[d+10]=h.charCodeAt(d)}})(c,e),sTe(c,l-8,n.d()),sTe(c,l-4,o),c}const bqo=!!ONe||!!g$,aKt=new WeakMap,AKt="text/plain";let aTe=0,Nde=!1;const cKt=(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}`:""}`},L$=(t,e,n=!0)=>{var o;const[i,r]=t.split("?"),s=Zt({},e),a=(o=r?.split("&").map(c=>{var l;const[u,g]=c.split("="),h=n&&(l=s[u])!==null&&l!==void 0?l:g;return delete s[u],`${u}=${h}`}))!==null&&o!==void 0?o:[],A=(function(c,l="&"){let u,g;const h=[];return Cl(c,function(d,m){Eo(d)||Eo(m)||m==="undefined"||(u=encodeURIComponent((p=>p instanceof File)(d)?d.name:d.toString()),g=encodeURIComponent(m),h[h.length]=g+"="+u)}),h.join(l)})(s);return A&&a.push(A),a.length>0?`${i}?${a.join("&")}`:i},ATe=t=>{if(t.nl)return t.nl;const{data:e,compression:n}=t;if(!e)return;if(n===bE.GZipJS){const i=Bqo((function(r){var s=r.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(r);for(var a=new E4(r.length+(r.length>>>1)),A=0,c=function(h){a[A++]=h},l=0;s>l;++l){if(A+5>a.length){var u=new E4(A+8+(s-l<<1));u.set(a),a=u}var g=r.charCodeAt(l);128>g?c(g):2048>g?(c(192|g>>>6),c(128|63&g)):g>55295&&57344>g?(c(240|(g=65536+(1047552&g)|1023&r.charCodeAt(++l))>>>18),c(128|g>>>12&63),c(128|g>>>6&63),c(128|63&g)):(c(224|g>>>12),c(128|g>>>6&63),c(128|63&g))}return iKt(a,0,A)})(PG(e)),{mtime:0});return{contentType:AKt,body:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),estimatedSize:i.byteLength}}if(n===bE.Base64){const i=(function(s){return s&&btoa(encodeURIComponent(s).replace(/%([0-9A-F]{2})/g,(a,A)=>String.fromCharCode(parseInt(A,16))))})(PG(e)),r=(s=>"data="+encodeURIComponent(typeof s=="string"?s:PG(s)))(i);return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}const o=PG(e);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}},lKt=t=>{const e=()=>t.transport==="sendBeacon"?{url:L$(t.url,{compression:bE.Base64}),encodedBody:ATe(Zt(Zt({},t),{},{compression:bE.Base64,nl:void 0}))}:{url:cKt(t.url,"compression"),encodedBody:ATe(Zt(Zt({},t),{},{compression:void 0,nl:void 0}))};let n;try{n=ATe(t)}catch(i){if(AYt(t.compression,MG(t.url,"compression")))return li.error("Failed to gzip request body, sending uncompressed payload",i),e();throw i}return n&&AYt(t.compression,MG(t.url,"compression"))&&!((o=n.body)instanceof ArrayBuffer?rRe(new Uint8Array(o)):ArrayBuffer.isView(o)&&rRe(new Uint8Array(o.buffer,o.byteOffset,o.byteLength)))?(Nde=!0,e()):{url:t.url,encodedBody:n};var o},uKt=t=>{try{return lKt(t)}catch(n){var e;return li.error(n),void((e=t.callback)===null||e===void 0||e.call(t,{statusCode:0,error:n}))}},Sqo=(function(){var t=ng(function*(e){const n=yield(function(i){return sRe.apply(this,arguments)})(PG(e.data),df.DEBUG,{rethrow:!0});if(!n)return e;const o=yield n.arrayBuffer();return Zt(Zt({},e),{},{nl:{contentType:AKt,body:o,estimatedSize:o.byteLength}})});return function(e){return t.apply(this,arguments)}})(),Qqo=/Failed to fetch|NetworkError|Load failed/i,gKt=t=>t?.name==="TypeError"&&Qqo.test(t?.message||""),dKt=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,ude):void 0})(t());return Eo(e)?void 0:Math.min(e,3e4)}catch{return}},hKt=t=>{const e=uKt(t);if(!e)return;const n=new ONe;aKt.set(n,!0);const{url:o,encodedBody:i}=e;n.open(t.method||"GET",o,!0);const{contentType:r,body:s}=i??{};Cl(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,dKt(()=>n.getResponseHeader("Retry-After")))}},n.send(s)},mKt=t=>{const e=uKt(t);if(!e)return;const{url:n,encodedBody:o}=e,{contentType:i,body:r,estimatedSize:s}=o??{},a=new Headers;Cl(t.headers,function(d,m){a.append(m,d)}),i&&a.append("Content-Type",i);let A=null,c=!1;if(rGt){const d=new rGt;A={signal:d.signal,timeout:setTimeout(()=>{c=!0;try{d.abort(VGt("AbortError","PostHog request timed out"+((m=t.timeout)?` after ${m}ms`:"")))}catch(p){u(p)}var m},t.timeout)}}let l=!1;const u=d=>{var m;l||(l=!0,c&&d?.name==="AbortError"||gKt(d)?li.warn(d):li.error(d),(m=t.callback)===null||m===void 0||m.call(t,{statusCode:0,error:d}))};let g=0;const h=()=>{aTe-=g,g=0,A&&clearTimeout(A.timeout)};try{const d=Zt({method:t?.method||"GET",headers:a,referrerPolicy:"strict-origin",body:r,signal:A?.signal},t.fetchOptions),m=s??(Eo(r)?0:void 0);d.keepalive=d.method==="POST"&&!t.sl&&d.keepalive!==!1&&d.body===r&&!Eo(m)&&m>=0&&52428.8>aTe+m,d.keepalive&&(g=m,aTe+=g),g$(n,d).then(p=>p.text().then(f=>{var _;if(l)return;const I={statusCode:p.status,text:f};if(p.status===200)try{I.json=JSON.parse(f)}catch(C){li.error(C)}l=!0,h(),(_=t.callback)===null||_===void 0||_.call(t,I,dKt(()=>p.headers.get("Retry-After")))})).catch(p=>{h(),u(p)}).finally(h)}catch(d){h(),u(d)}},cTe=t=>{try{var e;const{url:n,encodedBody:o}=lKt(t),{contentType:i,body:r,estimatedSize:s}=o??{};if(!r)return;const a=r instanceof Blob?r:new Blob([r],{type:i});if(I_.sendBeacon(n,a))return;const A=qr(t.data)?t.data:(e=t.data)===null||e===void 0?void 0:e.batch;if(qr(A)&&A.length>1&&(s??0)>16384){const c=Math.ceil(A.length/2),l=u=>qr(t.data)?u:Zt(Zt({},t.data),{},{batch:u});return cTe(Zt(Zt({},t),{},{data:l(A.slice(0,c))})),void cTe(Zt(Zt({},t),{},{data:l(A.slice(c))}))}li.warn(`Beacon of ~${s??0} bytes was rejected by the browser, falling back to ${g$?"fetch":"XHR"}`),g$?mKt(Zt(Zt({},t),{},{sl:!0})):hKt(t)}catch(n){li.warn("Beacon send failed",n)}},pKt=(t,e,n,o)=>{const i=o==="query"?e==="POST"?"sent_at":"_":void 0;return L$(n===bE.GZipJS?cKt(t,"compression"):t,Zt(Zt({},i?{[i]:Date.now().toString()}:{}),n===bE.GZipJS?{}:{compression:n}))},vqo=(()=>{const t=[];return g$&&t.push({transport:"fetch",method:mKt}),ONe&&t.push({transport:"XHR",method:hKt}),I_?.sendBeacon&&t.push({transport:"sendBeacon",method:cTe}),t})();let fKt=!bqo&&l2?.indexOf("MSIE")===-1&&l2?.indexOf("Mozilla")===-1;function _Kt(t,e,n){var o,i,r;n&&(e=Zt(Zt({},e),{},{callback:s=>n(s)})),t.__loaded?fKt?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=Zt(Zt({},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 u=Zt(Zt({},s),{},{callback:a??(p=>{var f;return(f=s.callback)===null||f===void 0?void 0:f.call(s,p)})});u.timeout=u.timeout||6e4;const g=(A=u.transport)!==null&&A!==void 0?A:"fetch";g==="sendBeacon"&&Eo(u.compression)&&u.data&&(u.compression=bE.Base64),u.method==="POST"&&u.data&&(u.timestampMode==="capture-body"?u.data=(p=>{var f,_;const I=(qr(p)?p:[p]).map(y=>Zt(Zt({},y),y.timestamp instanceof Date&&!isNaN(y.timestamp.getTime())?{timestamp:y.timestamp.toISOString()}:{})),C=I[0];return{api_key:(f=C==null||(_=C.properties)===null||_===void 0?void 0:_.token)!==null&&f!==void 0?f:C?.token,batch:I,sent_at:new Date().toISOString()}})(u.data):u.timestampMode==="body"&&(u.data=((p,f=new Date().toISOString())=>qr(p)?p.map(_=>Zt(Zt({},_),{},{sent_at:f})):Zt(Zt({},p),{},{sent_at:f}))(u.data))),u.url=pKt(u.url,u.method,u.compression,u.timestampMode);const h=vqo.filter(p=>!u.disableTransport||!p.transport||!u.disableTransport.includes(p.transport)),d=(c=(l=(function(p,f){for(let _=0;p.length>_;_++)if(f(p[_]))return p[_]})(h,p=>p.transport===g))===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 m=p=>{try{d(p)}catch(_){var f;gKt(_)?li.warn(_):li.error(_),(f=u.callback)===null||f===void 0||f.call(u,{statusCode:0,error:_})}};g!=="sendBeacon"&&!u.preferSyncCompression&&u.data&&u.compression===bE.GZipJS&&KJo&&typeof Promise<"u"&&!Nde?Sqo(u).then(p=>{m(p)}).catch(p=>{if(cYt(p))return Nde=!0,void m(Zt(Zt({},u),{},{compression:void 0,url:pKt(s.url,s.method,void 0,s.timestampMode)}));(f=>{if(!f||typeof f!="object")return!1;const _="name"in f?String(f.name):"";return cYt(f)||_===aYt})(p)&&(Nde=!0),m(u)}):m(u)})(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 wqo=class{constructor(t,e){this.rl=!0,this.ol=[],this.al=N7(e?.flush_interval_ms||3e3,250,5e3,li.createLogger("flush interval"),3e3),this.ll=t}enqueue(t){this.ol.push(t),this.ul||this.cl()}unload(){this.hl();const t=this.ol.length>0?this.dl():{},e=Object.values(t);[...e.filter(n=>n.url.indexOf("/e")===0),...e.filter(n=>n.url.indexOf("/e")!==0)].map(n=>{this.vl(Zt(Zt({},n),{},{callback:void 0}),"sendBeacon")})}enable(){this.rl=!1,this.cl()}cl(){this.rl||(this.ul=setTimeout(()=>{this.hl(),this.fl()},this.al))}fl(){if(this.ol.length>0){const t=this.dl();for(const e in t)this.vl(t[e])}}vl(t,e){try{this.ll(t,e)}catch(n){li.error(n)}}hl(){clearTimeout(this.ul),this.ul=void 0}dl(){const t={},e={};Cl(this.ol,n=>{var o;const i=n,r=((i?i.batchKey:null)||i.url)+(i.batchGroup?`:${i.batchGroup}`:"");Eo(t[r])&&(t[r]=Zt(Zt({},i),{},{data:[],callback:void 0,fireCallbackOnDrop:void 0}),e[r]=[]),(o=t[r].data)===null||o===void 0||o.push(i.data),i.callback&&e[r].push(i.callback)});for(const n in e){const o=e[n];o.length&&(t[n].callback=i=>{for(const r of o)r(i)})}return this.ol=[],t}};const Pqo=["retriesPerformedSoFar"];var Mqo=class{constructor(t){this._instance=t,this.pl=!1,this.gl=3e3,this.ol=[],this.ol=[],this.ml=!0,this.resume()}resume(){if(!Eo(jn)&&"onLine"in jn.navigator){if(this.ml=jn.navigator.onLine,this.yl)return;this.yl=()=>{this.ml=!0,this.fl()},this.bl=()=>{this.ml=!1},Zc(jn,"online",this.yl),Zc(jn,"offline",this.bl)}}get length(){return this.ol.length}retriableRequest(t,e){let{retriesPerformedSoFar:n}=t,o=uYt(t,Pqo);gS(n)&&(o.url=L$(o.url,{retry_count:n})),_Kt(this._instance,e?Zt(Zt({},o),{},{transport:e}):o,(i,r)=>{var s;if(i.statusCode!==200&&(400>i.statusCode||i.statusCode>=500)){if((i.statusCode===0?3:10)>(n??0))return void this.Ls(Zt({retriesPerformedSoFar:n},o),r);i.statusCode===0&&li.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after ${n??0} retries.`)}(s=o.callback)===null||s===void 0||s.call(o,i)})}Ls(t,e){const n=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=n+1;const o=Math.max((function(s){const a=3e3*Math.pow(2,s),A=a/2,c=Math.min(18e5,a),l=(Math.random()-.5)*(c-A);return Math.ceil(c+l)})(n),e??0),i=Date.now()+o;this.ol.push({retryAt:i,requestOptions:t});let r=`Enqueued failed request for retry in ${o}`;navigator.onLine||(r+=" (Browser is offline)"),li.warn(r),this.pl||(this.pl=!0,this._l())}_l(){if(this.wl&&clearTimeout(this.wl),this.ol.length===0)return this.pl=!1,void(this.wl=void 0);this.wl=setTimeout(()=>{this.ml&&this.ol.length>0&&this.fl(),this._l()},this.gl)}fl(){const t=Date.now(),e=[],n=this.ol.filter(o=>t>o.retryAt||(e.push(o),!1));if(this.ol=e,n.length>0)for(const{requestOptions:o}of n)this.retriableRequest(o)}unload(){this.wl&&(clearTimeout(this.wl),this.wl=void 0),this.pl=!1,Eo(jn)||(this.yl&&(jn.removeEventListener("online",this.yl),this.yl=void 0),this.bl&&(jn.removeEventListener("offline",this.bl),this.bl=void 0));for(const{requestOptions:t}of this.ol)try{this._instance._send_request(Zt(Zt({},t),{},{callback:qr(t.data)?void 0:t.callback,transport:"sendBeacon"}))}catch(e){li.error(e)}this.ol=[]}},Dqo=class{constructor(t){this._instance=t,this.kl=()=>{var e,n,o,i;this.Sl||(this.Sl={});const r=this.scrollElement(),s=this.scrollY(),a=r?Math.max(0,r.scrollHeight-r.clientHeight):0,A=s+(r?.clientHeight||0),c=r?.scrollHeight||0;this.Sl.lastScrollY=Math.ceil(s),this.Sl.maxScrollY=Math.max(s,(e=this.Sl.maxScrollY)!==null&&e!==void 0?e:0),this.Sl.maxScrollHeight=Math.max(a,(n=this.Sl.maxScrollHeight)!==null&&n!==void 0?n:0),this.Sl.lastContentY=A,this.Sl.maxContentY=Math.max(A,(o=this.Sl.maxContentY)!==null&&o!==void 0?o:0),this.Sl.maxContentHeight=Math.max(c,(i=this.Sl.maxContentHeight)!==null&&i!==void 0?i:0)}}get xl(){return this._instance.config.scroll_root_selector}getContext(){return this.Sl}resetContext(){const t=this.Sl;return this.Sl=void 0,setTimeout(this.kl,0),t}startMeasuringScrollPosition(){Zc(jn,"scroll",this.kl,{capture:!0}),Zc(jn,"scrollend",this.kl,{capture:!0}),Zc(jn,"resize",this.kl)}scrollElement(){if(this.xl){const n=qr(this.xl)?this.xl:[this.xl];for(const o of n){var t;const i=jn==null||(t=jn.document)===null||t===void 0?void 0:t.querySelector(o);if(i)return i}return}var e;return jn==null||(e=jn.document)===null||e===void 0?void 0:e.documentElement}$l(t){var e,n;const o=t==="y"?"scrollTop":"scrollLeft";if(this.xl){const i=this.scrollElement();return i&&i[o]||0}return jn?t==="y"?jn.scrollY||jn.pageYOffset||((e=jn.document)===null||e===void 0||(e=e.documentElement)===null||e===void 0?void 0:e.scrollTop)||0:jn.scrollX||jn.pageXOffset||((n=jn.document)===null||n===void 0||(n=n.documentElement)===null||n===void 0?void 0:n.scrollLeft)||0:0}scrollY(){return this.$l("y")}scrollX(){return this.$l("x")}};const Nqo=t=>KUt(t?.config.mask_personal_data_properties,t?.config.custom_personal_data_properties,t?.config.disable_capture_url_hashes);var IKt=class{constructor(t,e,n,o){this.qe=i=>{const r=this.Cl();if(r&&r.sessionId===i)return;const s={sessionId:i,props:this.Tl(this._instance)};this.Il.register({[bRe]:s})},this._instance=t,this.Ml=e,this.Il=n,this.Tl=o||Nqo,this.Ml.onSessionId(this.qe)}Cl(){return this.Il.props[bRe]}getSetOnceProps(){var t;const e=(t=this.Cl())===null||t===void 0?void 0:t.props;return e?"r"in e?zUt(e,this._instance.config.disable_capture_url_hashes):{$referring_domain:e.referringDomain,$pathname:e.initialPathName,utm_source:e.utm_source,utm_campaign:e.utm_campaign,utm_medium:e.utm_medium,utm_content:e.utm_content,utm_term:e.utm_term}:{}}getSessionProps(){const t={};return Cl(DRe(this.getSetOnceProps()),(e,n)=>{n==="$current_url"&&(n="url"),t[`$session_entry_${YNe(n)}`]=e}),t}},Rde=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 kG=xd("[SessionId]"),CKt=864e5;var yKt=class{on(t,e){return this.Pl.on(t,e)}constructor(t,e,n){var o;if(this.Rl=null,this.Al=null,this.Fl=[],this.Ol=void 0,this.Dl=!1,this.Pl=new Rde,this.Ll=(r,s)=>!(!gS(r)||!gS(s))&&Math.abs(r-s)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(t.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Mr=t.config,this.Il=t.persistence,this.je=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.Nl=void 0,this._sessionActivityTimestamp=null,this.ql=e||e9,this.jl=n||e9;const i=this.Mr.persistence_name||this.Mr.token;if(this._sessionTimeoutMs=1e3*N7(this.Mr.session_idle_timeout_seconds||1800,60,36e3,kG.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Bl(),this.zl="ph_"+i+"_window_id",this.Hl="ph_"+i+"_primary_window_exists",this.Ul()){const r=ou.Ft(this.zl),s=ou.Ft(this.Hl);r&&!s?this.je=r:ou.Pt(this.zl),ou.$t(this.Hl,!0)}!((o=this.Mr.bootstrap)===null||o===void 0)&&o.sessionID&&this.setBootstrapSessionId(this.Mr.bootstrap.sessionID),this.Wl()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return Eo(this.Fl)&&(this.Fl=[]),this.Fl.push(t),this.Xt&&t(this.Xt,this.je),()=>{this.Fl=this.Fl.filter(e=>e!==t)}}Ul(){return this.Mr.persistence!=="memory"&&!this.Il.hi&&ou.At()}Vl(t){t!==this.je&&(this.je=t,this.Ul()&&ou.$t(this.zl,t))}Gl(){return this.je?this.je:this.Ul()?ou.Ft(this.zl):null}Ql(t){const e=this.Rl;return!yd(e)&&!yd(t)&&5e3>Math.abs(t-e)}Zl(t,e,n){const o=e!==this._sessionActivityTimestamp,i=!(t!==this.Xt||n!==this._sessionStartTimestamp);this._sessionStartTimestamp=n,this._sessionActivityTimestamp=e,this.Xt=t,i&&!o||i&&this.Ql(e)||(this.Rl=e,this.Il.register({[xG]:[e,t,n]}))}Jl(){var t;const e=(t=this.Mr)===null||t===void 0?void 0:t.persistence_save_debounce_ms;return gS(e)&&e>0}Kl(){this.Jl()?this.Il.refreshKey(xG):(this.Il.flush(),this.Il.load())}Xl(){var t;if(yd(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this.Rl)return;this.Kl();const[,e,n]=this.Yl();e===this.Xt&&n===this._sessionStartTimestamp&&(this.Rl=this._sessionActivityTimestamp,this.Il.register({[xG]:[this._sessionActivityTimestamp,(t=this.Xt)!==null&&t!==void 0?t:null,this._sessionStartTimestamp]}),this.Il.flush())}tu(){const[t]=this.Yl(),e=gS(t)?t:0,n=gS(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(e,n)}eu(t){return this.Kl(),this.Ll(t,this.tu())}Yl(){const t=this.Il.props[xG];return qr(t)&&t.length===2&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.Rl=null,this.Nl=void 0,clearTimeout(this.iu),this.iu=void 0,this.Zl(null,null,null)}setBootstrapSessionId(t,e=!1){const n=((o,i=new Date().getTime())=>{try{const r=(s=>{const a=s.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)})(o);return r>i+6e4?void kG.error("Bootstrap sessionID cannot be in the future"):r}catch(r){return void kG.error("Invalid sessionID in bootstrap",r)}})(t);return!Eo(n)&&(e?this.Nl={sessionId:t,sessionStartTimestamp:n}:this.Zl(t,new Date().getTime(),n),!0)}destroy(){this.Dl=!0,this.Xl(),clearTimeout(this.iu),this.iu=void 0,this.Ol&&jn&&(jn.removeEventListener(Ede,this.Ol,{capture:!1}),this.Ol=void 0),this.Fl=[]}Wl(){this.Ol=()=>{this.Xl(),this.Ul()&&ou.Pt(this.Hl)},Zc(jn,Ede,this.Ol,{capture:!1})}checkAndGetSessionAndWindowId(t=!1,e=null,n=!1){if(this.Mr.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');const o=e||new Date().getTime(),i=this.Xt;if(n)this.Al=o;else if(yd(this.Al)||this.Al>o||o-this.Al>=1e3){var r,s;(r=(s=this.Il).syncCookieProperties)===null||r===void 0||r.call(s),this.Al=o}let[,a,A]=this.Yl();const c=!Eo(i)&&a!==i,l=this.tu();let u=this.Gl();const g=this.Nl,h=!!g&&(g.sessionStartTimestamp>o+6e4||o-g.sessionStartTimestamp>CKt),d=g?h:gS(A)&&Math.abs(o-A)>CKt;let m=!1,p=c,f=!a||!!g;const _=a;let I=!f&&!t&&this.Ll(o,l);if(I&&(I=this.eu(o),I||kG.info("cross-tab refresh kept the session alive",{sessionId:a}),[,a,A]=this.Yl(),I||(f=!a||!!g)),f||I||d){p=!1;const E=g&&!h;a=E?g.sessionId:this.ql(),u=this.jl(),kG.info("new session ID assigned",{sessionId:a,windowId:u,bootstrapped:!!E,changeReason:{noSessionId:f,activityTimeout:I,sessionPastMaximumLength:d}}),A=E?g.sessionStartTimestamp:o,this.Nl=void 0,m=!0}else u||(u=this.jl(),m=!0),p=p||a!==_,p&&(kG.info("adopted cross-tab session id",{sessionId:a,windowId:u}),m=!0);const C=gS(l)&&t&&!d?l:o,y=gS(A)?A:new Date().getTime();this.Vl(u),this.Zl(a,C,y),t||this.Bl();const x={noSessionId:f,activityTimeout:I,sessionPastMaximumLength:d,crossTabAdoption:p};return m&&this.Fl.forEach(E=>E(a,u,x)),{sessionId:a,windowId:u,sessionStartTimestamp:y,changeReason:m?x:void 0,lastActivityTimestamp:l}}Bl(){this.Dl||(clearTimeout(this.iu),this.iu=setTimeout(()=>{if(!this.Dl)if(this.eu(new Date().getTime())){const t=this.Xt;this.resetSessionId(),this.Pl.emit("forcedIdleReset",{idleSessionId:t})}else this.Bl()},1.1*this.sessionTimeoutMs))}};const xKt=function(t,e){if(!t)return!1;const n=t.userAgent;if(n&&uGt(n,e))return!0;try{const o=t?.userAgentData;if(o?.brands&&o.brands.some(i=>uGt(i?.brand,e)))return!0}catch{}return!!t.webdriver};function EKt(){return(EKt=ng(function*(){const t=I_?.userAgentData;if(t?.getHighEntropyValues)try{const e=yield t.getHighEntropyValues(["model"]),n=e?.model;return Za(n)&&n.length>0?n:void 0}catch(e){return void li.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}})).apply(this,arguments)}function Rqo(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 BKt(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 Tde=(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}},kde=t=>t.toLowerCase(),bKt={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=>Tde(n,o))),not_regex:(t,e)=>e.every(n=>t.every(o=>!Tde(n,o))),icontains:(t,e)=>e.map(kde).some(n=>t.map(kde).some(o=>n.includes(o))),not_icontains:(t,e)=>e.map(kde).every(n=>t.map(kde).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 SKt(t,e){return!t||Object.entries(t).every(([n,o])=>{const i=e?.[n];if(i==null)return!1;const r=bKt[o.operator];return!!r&&r(o.values.map(String),[String(i)])})}function lTe(t,e,n){return PG({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:n})}const uTe="custom",QKt="i.posthog.com",Tqo=/^\/static\//,kqo=["/s/","/e/","/i/"];var Fqo=class{constructor(t){this.nu={},this.instance=t}get apiHost(){const t=this.instance.config.api_host.trim().replace(/\/$/,"");return t==="https://app.posthog.com"?"https://us.i.posthog.com":t}get flagsApiHost(){const t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t;let e=(t=this.instance.config.ui_host)===null||t===void 0?void 0:t.replace(/\/$/,"");return e||(e=this.apiHost.replace(`.${QKt}`,".posthog.com")),e==="https://app.posthog.com"?"https://us.posthog.com":e}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":uTe),this.nu[this.apiHost]}su(t){if(!Tqo.test(t))return;const e=this.instance.config.asset_host;return typeof e=="string"&&e.trim().replace(/\/$/,"")||void 0}ru(t){const e=mS(t);return e?e.protocol+"//"+e.host+e.pathname:void 0}ou(t,e,n){if(t==="ui")return n;let o=n;const i=this.instance.config.rewriteRequestPath;if(i){var r;const s=((r=mS(n))===null||r===void 0?void 0:r.href)||n;o=i(new URL(s)).toString()}if(i&&t==="api"&&kqo.some(s=>e.indexOf(s)===0)){const s=this.ru(o);if(s){const a=this.apiHost;let A=this.au;A?.apiHost===a&&A.rewriteRequestPath===i||(A={apiHost:a,rewriteRequestPath:i,urls:new Set},this.au=A),A.urls.add(s)}}return o}isIngestionEndpoint(t){const e=this.au,n=this.ru(t);return e?.apiHost===this.apiHost&&e.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!n&&e.urls.has(n)}endpointFor(t,e=""){if(e&&(e=e[0]==="/"?e:`/${e}`),t==="ui")return this.ou(t,e,this.uiHost+e);if(t==="flags")return this.ou(t,e,this.flagsApiHost+e);if(t==="assets"){const o=this.su(e);if(o)return this.ou(t,e,`${o}${e}`)}if(this.region===uTe)return this.ou(t,e,this.apiHost+e);const n=QKt+e;switch(t){case"assets":return this.ou(t,e,`https://${this.region}-assets.${n}`);case"api":return this.ou(t,e,`https://${this.region}.${n}`)}}};const yl=xd("[Surveys]"),vKt=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){yl.error("Failed to persist survey seen state",e)}},Lqo=[$Re.Popover,$Re.Widget,$Re.API],Hqo={ignoreConditions:!1,ignoreDelay:!1,displayType:ZRe.Popover},Oqo=xd("[PostHog ExternalIntegrations]"),Gqo={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var Yqo=class{constructor(t){this._instance=t}zo(t,e){var n,o;(n=Kr.__PosthogExtensions__)===null||n===void 0||(o=n.loadExternalDependency)===null||o===void 0||o.call(n,this._instance,t,i=>{if(i)return Oqo.error("failed to load script",i);e()})}startIfEnabledOrStop(){var t;for(const[i,r]of Object.entries((t=this._instance.config.integrations)!==null&&t!==void 0?t:{})){var e,n,o;r&&!(!((e=Kr.__PosthogExtensions__)===null||e===void 0||(e=e.integrations)===null||e===void 0)&&e[i])&&this.zo(Gqo[i],()=>{var s;(s=Kr.__PosthogExtensions__)===null||s===void 0||(s=s.integrations)===null||s===void 0||(s=s[i])===null||s===void 0||s.start(this._instance)}),!r&&(!((n=Kr.__PosthogExtensions__)===null||n===void 0||(n=n.integrations)===null||n===void 0)&&n[i])&&((o=Kr.__PosthogExtensions__)===null||o===void 0||(o=o.integrations)===null||o===void 0||(o=o[i])===null||o===void 0||o.stop())}}},Uqo=class{constructor(t,e){this.A=t,this.bo=e,this.lu=new Map,this.To=!1}add(t){var e=this;return ng(function*(){if(e.To)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(e.lu.has(t.name))throw new Error(`Browser extension "${t.name}" is already registered`);e.lu.set(t.name,t);try{const n=t.setup(e.bo);n&&(yield n)}catch(n){const o=e.lu.get(t.name)===t;o&&e.lu.delete(t.name),e.A.error(`Failed to set up browser extension "${t.name}"`,n),o&&e.uu(t)}})()}getExtension(t){return this.lu.get(t)}dispose(){if(this.To)return;this.To=!0;const t=Array.from(this.lu.values()).reverse();this.lu.clear();for(const e of t)this.uu(e)}uu(t){try{var e;const n=(e=t.dispose)===null||e===void 0?void 0:e.call(t);n&&pp(n.then)&&n.then(void 0,o=>{this.A.error(`Failed to dispose browser extension "${t.name}"`,o)})}catch(n){this.A.error(`Failed to dispose browser extension "${t.name}"`,n)}}},Kqo=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 wKt="extensionsRemoteConfig";var zqo=class{constructor(e){this.instance=e,this.To=!1,this.A=li,this.cu=e.hu,this.kv=new Kqo(e),this.onEvent=n=>Mde(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 Mde(()=>{});const o=r=>{try{n(r)}catch(s){this.A.error("Browser extension remote config listener failed",s)}},i=this.instance.du.on(wKt,o);return this.cu&&o(this.cu),Mde(i)},this.vu=new Uqo(li.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(mRe);return typeof e=="string"?e:void 0}get library(){return{name:df.LIB_NAME,version:df.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 Mde(this.instance.fu(e))}handleRemoteConfig(e){this.To||(this.cu=e,this.instance.du.emit(wKt,e))}sendRequest(e){var n=this;return ng(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?L$(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"?GNe.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 H$={};let gTe=0;const O$=()=>{},PKt='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',FG="Surveys module not available",MKt="sanitize_properties is deprecated. Use before_send instead",DKt="Invalid value for property_denylist config: ",Vqo=["$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"],Jqo=["$feature_flag_called","$$heatmap","$snapshot"],NKt=t=>t.charAt(0)==="$"&&!jr(Jqo,t),Wqo=/^[A-Za-z0-9_-]{1,400}$/,RKt=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,TKt=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,jqo=["token","distinct_id",zYt],G$="posthog",qqo=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},dTe=t=>{var e;return Zt({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:zjo(qo?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:O$,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_replay_sync_fetch:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:tg&&Za(tg?.search)&&tg.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:(jn==null||(e=jn.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){li.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:tUt,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:O$},(n=>({rageclick:n&&n>="2026-05-30"?{content_ignorelist:VRe,ignore_text_selection:!0}:!n||"2025-11-30">n||{content_ignorelist:!0},capture_pageview:!n||"2025-05-24">n||"history_change",session_recording:qqo(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))},$qo=[["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"]],kKt=t=>{const e={};for(const[i,r]of $qo)Eo(t[i])||(e[r]=t[i]);const n=og({},e,t),o=t.__preview_external_dependency_versioned_paths;return Eo(o)||(Eo(t.strict_script_versioning)&&(n.strict_script_versioning=!!o),Za(o)&&Eo(t.asset_host)&&(n.asset_host=o)),qr(t.property_blacklist)&&(Eo(t.property_denylist)?n.property_denylist=t.property_blacklist:qr(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:li.error(DKt+t.property_denylist)),n};var Xqo=class{constructor(){this.__forceAllowLocalhost=!1}get pu(){return this.__forceAllowLocalhost}set pu(e){li.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Y$=class gD{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(e9());this.register({distinct_id:o,$device_id:o}),e.set_property(g2,hS)}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 Xqo,this.Mu=!1,this.version=df.LIB_VERSION,this.Eu=new Set,this.Pu="",this.du=new Rde,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=dTe(),this.SentryIntegration=cqo,this.sentryIntegration=o=>(function(i,r){const s=NUt(i,r);return{name:DUt,processEvent:a=>s(a)}})(this,o),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Fu=!1,this.Ou=null,this.Du=null,this.Lu=null,this.scrollManager=new Dqo(this),this.pageViewManager=new RUt(this),this.rateLimiter=new Iqo(this),this.requestRouter=new Fqo(this),this.consent=new Xjo(this),this.externalIntegrations=new Yqo(this);const n=(e=gD.__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=Za(o)?{[o]:i}:o;this.setPersonProperties(s),r?.({})},set_once:(o,i,r)=>{const s=Za(o)?{[o]:i}:o;this.setPersonProperties(void 0,s),r?.({})}},this.on("eventCaptured",o=>li.info(`send "${o?.event}"`,o))}init(e,n,o){if(o&&o!==G$){var i;const r=(i=H$[o])!==null&&i!==void 0?i:new gD;return r._init(e,n,o),H$[o]=r,H$[G$][o]=r,r}return this._init(e,n,o)}_init(e,n={},o){var i,r,s;const a=Za(e)?e.trim():"";if(!a)return li.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=dTe(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=dTe(n.defaults),l=kKt(n),u=og({},c,l,{name:o,token:a});va(c.rageclick)&&va(l.rageclick)&&(u.rageclick=og({},c.rageclick,l.rageclick)),va(c.session_recording)&&va(l.session_recording)&&(u.session_recording=og({},c.session_recording,l.session_recording)),this.set_config(u),this.config.on_xhr_error&&li.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:bE.GZipJS;const g=this.Cu(),h=!this.yu();if(this.persistence=new qRe(this.config,g,!0,h),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new qRe(Zt(Zt({},this.config),{},{persistence:"sessionStorage"}),g,!1,h),this.Pu="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!g&&ou.At()){const _=ou.Ft(this.Pu);qr(_)&&_.forEach(I=>{Za(I)&&this.Eu.add(I)})}else ou.Pt(this.Pu);const d=Zt({},this.persistence.props),m=Zt({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Bu=new wqo((_,I)=>this.zu(_,I),this.config.request_queue_config),this.Hu=new Mqo(this),this.__request_queue=[];const p=this.yu();p||(this.sessionManager=new yKt(this),this.sessionPropsManager=new IKt(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((_,I,C)=>{(C?.activityTimeout||C?.sessionPastMaximumLength||C?.crossTabAdoption)&&this.Uu()})),this.Wu(),this.config.__preview_deferred_init_extensions?(li.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.Vu(p)},0)):(li.info("Initializing extensions synchronously"),this.Vu(p)),df.DEBUG=df.DEBUG||this.config.debug,df.DEBUG&&li.info("Starting in debug mode",{this:this,config:n,thisC:Zt({},this.config),p:d,s:m}),this.config.identity_distinct_id&&!(!((i=n.bootstrap)===null||i===void 0)&&i.distinctID)&&(n.bootstrap=Zt(Zt({},n.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const f=(r=n.bootstrap)===null||r===void 0?void 0:r.distinctID;if(this.wu=!!f&&!h$(f),(s=n.bootstrap)===null||s===void 0?void 0:s.distinctID){const _=n.bootstrap.distinctID,I=this.get_distinct_id(),C=this.persistence.get_property(g2);if(n.bootstrap.isIdentifiedID&&I!=null&&I!==_&&C==="anonymous")this.identify(_);else if(n.bootstrap.isIdentifiedID&&I!=null&&I!==_&&C==="identified")li.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(e9()),x=n.bootstrap.isIdentifiedID?y:_;this.persistence.set_property(g2,n.bootstrap.isIdentifiedID?xde:hS),this.register({distinct_id:_,$device_id:x})}}if(p)this.register_once({distinct_id:QRe,$device_id:null},"");else if(!this.get_distinct_id()){const _=this.config.get_device_id(e9());this.register_once({distinct_id:_,$device_id:_},""),this.persistence.set_property(g2,hS)}return Zc(jn,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),Zc(jn,"pageshow",()=>{var _;this.Tu=!1,this.Iu||(_=this.Hu)===null||_===void 0||_.resume()}),n.segment?MUt(this,()=>this.Gu()):this.Gu(),pp(this.config._onCapture)&&this.config._onCapture!==O$&&(li.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",_=>this.config._onCapture(_.event,_))),this.config.ip&&li.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 EKt.apply(this,arguments)})().then(_=>{_&&this.register({[pRe]:_})}).catch(O$),this}Qu(e){const n=e;return Za(n.name)&&pp(n.setup)}Zu(e,n){this.Qu(e)?n.push(()=>{this.Ju().add(e).catch(()=>{var o;return(o=e.dispose)===null||o===void 0?void 0:o.call(e)}).catch(o=>{li.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=gD.__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)),pp(this.featureFlags.onReloading)&&pp(this.featureFlags.setup)?this.Ku||(this.Ku=this.featureFlags.onReloading(()=>{this.du.emit("featureFlagsReloading",!0)}),this.Ju().add(this.featureFlags)):(s=(a=this.featureFlags).initialize)===null||s===void 0||s.call(a))}Vu(e){const n=performance.now(),o=Zt(Zt({},gD.__defaultExtensionClasses),this.config.__extensionClasses),i=[];var r,s,a,A,c,l,u,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.Zu(this.autocapture=new o.autocapture(this),i),o.surveys&&this.Zu(this.surveys=(s=this.surveys)!==null&&s!==void 0?s:new o.surveys(this),i),o.logs&&this.Zu(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,Aqo)),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=(u=this.experiments)!==null&&u!==void 0?u:new o.experiments(this)),o.webMCP&&this.lu.push(this.webMCP=(g=this.webMCP)!==null&&g!==void 0?g:new o.webMCP(this)),this.lu.forEach(h=>{h.initialize&&i.push(()=>{var d;(d=h.initialize)===null||d===void 0||d.call(h)})}),i.push(()=>{if(this.Xu){const h=this.Xu;this.Xu=void 0,this.lu.forEach(d=>{var m;return(m=d.onRemoteConfig)===null||m===void 0?void 0:m.call(d,h)})}}),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){li.error("Error initializing extension:",r)}}const o=Math.round(performance.now()-n);this.register_for_session({[VYt]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[JYt]:o}),this.config.__preview_deferred_init_extensions&&li.info(`PostHog extensions initialized (${o}ms)`)}el(e){var n;if(!qo||!qo.body)return li.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.hu=e,this.compression=void 0,e.ok){var o;const i=e.config;i.supportedCompression&&!this.config.disable_compression&&(this.compression=jr(i.supportedCompression,bE.GZipJS)?bE.GZipJS:jr(i.supportedCompression,bE.Base64)?bE.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:tUt}),(n=this.tc)===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){li.critical("`loaded` function failed",e)}if(this.ec(),this.config.internal_or_test_user_hostname&&tg?.hostname){const e=tg.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.nc()},1),this.sc=new $Ut(this),this.sc.load()}ec(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Bu)===null||e===void 0||e.enable())}_dom_loaded(){this.is_capturing()&&BG(this.__request_queue,e=>this.zu(e)),this.__request_queue=[],this.ec()}_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.rc()&&this.capture(nUt),(i=this.logs)===null||i===void 0||i.flushLogs("sendBeacon"),(r=this.Bu)===null||r===void 0||r.unload(),(s=this.Hu)===null||s===void 0||s.unload()):this.rc()&&this.capture(nUt,null,{transport:"sendBeacon"})}_send_request(e){_Kt(this,e)}zu(e,n){this.Hu?this.Hu.retriableRequest(e,n):this._send_request(n?Zt(Zt({},e),{},{transport:n}):e)}_execute_array(e){gTe++;try{let n;const o=[],i=[],r=[];BG(e,a=>{if(a)if(n=a[0],qr(n))r.push(a);else if(pp(a))try{a.call(this)}catch(A){li.error("Error executing queued PostHog call",a,A)}else qr(a)&&n==="alias"?o.push(a):qr(a)&&n.indexOf("capture")!==-1&&pp(this[n])?r.push(a):i.push(a)});const s=function(a,A){BG(a,function(c){try{if(qr(c[0])){let l=A;Cl(c,function(u){l=l[u[0]].apply(l,u.slice(1))})}else A[c[0]].apply(A,c.slice(1))}catch(l){li.error("Error executing queued PostHog call",c,l)}})};s(o,this),s(i,this),s(r,this)}finally{gTe--}}push(e){if(gTe>0&&qr(e)&&Za(e[0])){const n=gD.prototype[e[0]];return void(pp(n)&&n.apply(this,e.slice(1)))}this._execute_array([e])}get oc(){return{property:DYt,persistenceKey:yG,cookieName:"_fbc",pattern:RKt,register:(e,n)=>{var o;return(o=this.persistence)===null||o===void 0?void 0:o.register({[yG]:{value:e,delivered:n}})},unregister:()=>{var e;return(e=this.persistence)===null||e===void 0?void 0:e.unregister(yG)}}}get ac(){return{property:NYt,persistenceKey:E$,cookieName:"_fbp",pattern:TKt,register:(e,n)=>{var o;return(o=this.persistence)===null||o===void 0?void 0:o.register({[E$]:{value:e,delivered:n}})},unregister:()=>{var e;return(e=this.persistence)===null||e===void 0?void 0:e.unregister(E$)}}}lc(e){var n;const o=(n=this.persistence)===null||n===void 0?void 0:n.get_property(e.persistenceKey);return Za(o)&&e.pattern.test(o)?{value:o,delivered:!1}:va(o)&&Za(o.value)&&e.pattern.test(o.value)?{value:o.value,delivered:o.delivered===!0}:void 0}uc(e,n,o){return n===o?.value?{value:n,pending:!o.delivered}:(e.register(n,!1),{value:n,pending:!0})}cc(e){if(!this.config.save_campaign_params||this.yu())return;const n=S$(e.cookieName);return Za(n)&&e.pattern.test(n)?n:void 0}hc(e,n,o,i){if(!this.persistence)return;const r=this.oc;this.persistence.refreshKey(r.persistenceKey);const s=this.lc(r);if(i)return void r.unregister();if(o)return Za(n)&&RKt.test(n)?this.uc(r,n,s):void r.unregister();const a=Za(e)&&Wqo.test(e)?e:void 0,A=this.cc(r);return A&&((c,l,u)=>{const g=c.split(".");if(l)return g[3]===l;if(!u)return!0;const h=u.value.split(".");return g[3]===h[3]||Number(g[2])>Number(h[2])})(A,a,s)?this.uc(r,A,s):a?s?.value.split(".")[3]===a?{value:s.value,pending:!s.delivered}:this.uc(r,`fb.1.${Date.now()}.${a}`,s):s?{value:s.value,pending:!s.delivered}:void 0}dc(e,n,o){if(!this.persistence)return;const i=this.ac;this.persistence.refreshKey(i.persistenceKey);const r=this.lc(i);if(o)return void i.unregister();if(n)return Za(e)&&TKt.test(e)?this.uc(i,e,r):void i.unregister();const s=this.cc(i);return s?this.uc(i,s,r):r?{value:r.value,pending:!r.delivered}:void 0}vc(e,n){if(!this.persistence)return;this.persistence.refreshKey(e.persistenceKey);const o=this.lc(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 li.uninitializedWarning("posthog.capture");if(!this.is_capturing())return;if(Eo(e)||!Za(e))return void li.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 li.critical("This capture call is ignored due to client rate limiting.");let A;n?.$current_url&&!Za(n?.$current_url)&&(li.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?.fc||li.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,u=zGt(o?.uuid,e9);let g={uuid:u,event:e,properties:this.calculateEventProperties(e,n||{},l,u)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&s&&(g.event="$bot_pageview",g.properties.$browser_type="bot"),a&&(g.properties.$lib_rate_limit_remaining_tokens=a.remainingTokens);const h=e==="$feature_flag_called"&&g.properties.$feature_flag_has_experiment===!1&&this.get_property("$minimal_flag_called_events")===!0;o?.$set&&!h&&(g.$set=o?.$set);const d=va(n?.$set)?n.$set:void 0,m=qr(n?.$unset)?n.$unset:[],p=o?.$unset||[],f=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:m.indexOf(R)!==-1||p.indexOf(R)!==-1}},_=f(DYt),I=f(NYt),C=[{channel:this.oc,hasProvided:_.hasProvided,update:this.hc(A?.fbclid,_.provided,_.hasProvided,_.unset)},{channel:this.ac,hasProvided:I.hasProvided,update:this.dc(I.provided,I.hasProvided,I.unset)}];for(const{channel:R,hasProvided:F,update:O}of C)O&&g.properties.$process_person_profile===!0&&O.pending&&!F&&!h&&(g.$set=Zt({[R.property]:O.value},g.$set));const y=o?.$unset;y&&(g.$unset=y);const x=h?void 0:this.gc(o?.$set_once,e!==iUt,e===oUt);if(x&&(g.$set_once=x),o?._noTruncate||(E=this.config.properties_string_max_length,g=(function(R,F){const O=new Set;return(function U(Y,q){if(Y!==Object(Y))return F?F(Y):Y;if(O.has(Y))return;let ee;if(O.add(Y),qr(Y))ee=[],BG(Y,W=>{ee.push(U(W))});else{const W={};Cl(_G(Y)?rUt(Y):Y,(J,te)=>{O.has(J)||(W[te]=U(J))}),ee=W}return ee})(R)})(g,R=>Za(R)?R.slice(0,E):R)),g.timestamp=l,Eo(o?.timestamp)||(g.properties.$event_time_override_provided=!0,g.properties.$event_time_override_system_time=c),h&&(g.properties=((R,F=[])=>{const O={},U=Y=>{R[Y]!==void 0&&(O[Y]=R[Y])};return HWo.forEach(U),F.forEach(U),O})(g.properties,jqo)),e===SE.DISMISSED||e===SE.SENT){const R=n?.[XRe.SURVEY_ID],F=n?.[XRe.SURVEY_ITERATION];vKt({id:R,current_iteration:F}),g.$set=Zt(Zt({},g.$set),{},{[Rqo({id:R,current_iteration:F},e===SE.SENT?"responded":"dismissed")]:!0})}else e===SE.SHOWN&&(g.$set=Zt(Zt({},g.$set),{},{[XRe.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var E;if(e===_qo.SHOWN){const R=n?.[jUt.TOUR_TYPE];R&&(g.$set=Zt(Zt({},g.$set),{},{[`${jUt.TOUR_LAST_SEEN_DATE}/${R}`]:new Date().toISOString()}))}const B=Zt(Zt({},g.properties.$set),g.$set);if(Jx(B)||this.setPersonPropertiesForFlags(B),!Hs(this.config.before_send)){const R=this.Os(g);if(!R)return;g=R,g.uuid=zGt(g.uuid,e9)}this.sessionRecording&&!this.Au&&NKt(e)&&(this.Au=!0,setTimeout(()=>this.Au=!1,3e4));const S=C.filter(({channel:R,update:F})=>{var O,U,Y;const q=(O=(U=g.$set)===null||U===void 0?void 0:U[R.property])!==null&&O!==void 0?O:va((Y=g.properties)===null||Y===void 0?void 0:Y.$set)?g.properties.$set[R.property]:void 0;return F?.pending&&q===F.value});this.du.emit("eventCaptured",g);const Q=(i=o?._url)!==null&&i!==void 0?i:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),w=o?._batchKey==="recordings"||/\/s\/(?:\?|$)/.test(Q),M=Zt(Zt(Zt({method:"POST",url:Q,data:g,compression:"best-available",preferSyncCompression:o?.send_instantly,timestampMode:w?"body":"capture-body",batchKey:o?._batchKey},w&&(!((r=g.properties)===null||r===void 0)&&r.$session_id)?{batchGroup:g.properties.$session_id+(g.properties.$window_id?`-${g.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.vc(F,O.value)}}:{});if(!this.config.request_batching||o&&!o?._batchKey||o?.send_instantly){var T;let R;!M.transport&&!M.callback&&Jx((T=this.config.request_headers)!==null&&T!==void 0?T:{})&&this.Tu&&(R="sendBeacon"),this.zu(M,R)}else this.Bu.enqueue(M);return g}_addCaptureHook(e){return this.on("eventCaptured",n=>e(n.event,n))}getExtension(e){var n;return(n=this.tc)===null||n===void 0?void 0:n.getExtension(e)}Ju(){var e;return(e=this.tc)!==null&&e!==void 0?e:this.tc=new zqo(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)}}mc(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.yc()),(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.mc();const s=r?void 0:this.persistence.remove_event_timer(e);let a=Zt({},n);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,this.yu()&&(a[zYt]=!0),e==="$snapshot"){const _=Zt(Zt({},this.persistence.properties()),this.sessionPersistence.properties());return a.distinct_id=_.distinct_id,(!Za(a.distinct_id)&&!gh(a.distinct_id)||h$(a.distinct_id))&&li.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}const A=(function(_,I,C,y=!1){var x,E,B,S;if(!l2)return{};const Q=_?[...DG,...I||[]]:[],[w,M]=OGt(l2),[T,R]=(function(ie){for(let ne=0;YGt.length>ne;ne++){const[le,de,Ie]=YGt[ne],ce=ie.match(le);if(ce){const fe=Ie&&ie.match(Ie)||ce;return[de,fe?.[1]||""]}}return["",""]})(l2),F=(function(){const ie="u">typeof navigator?navigator:void 0;return ie?.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,q=(E=navigator)===null||E===void 0?void 0:E.maxTouchPoints,ee=jn==null||(B=jn.screen)===null||B===void 0?void 0:B.width,W=jn==null||(S=jn.screen)===null||S===void 0?void 0:S.height,J=jn?.devicePixelRatio;Eo(Y)||(U.userAgentDataPlatform=Y),Eo(q)||(U.maxTouchPoints=q),Eo(ee)||(U.screenWidth=ee),Eo(W)||(U.screenHeight=W),Eo(J)||(U.devicePixelRatio=J);const te=og(DRe({$os:w,$os_version:M,$browser:LGt(l2,navigator.vendor,F,O),$webview_app:T,$webview_app_version:R,$device:GGt(l2),$device_type:aWo(l2,U),$timezone:TUt(),$timezone_offset:mqo()}),{$current_url:D$(y?eP(tg?.href):tg?.href,Q,N$),$host:tg?.host,$pathname:tg?.pathname,$raw_user_agent:l2.length>1e3?l2.substring(0,997)+"...":l2,$browser_version:sWo(l2,navigator.vendor,F,O),$browser_language:YUt(),$browser_language_prefix:hqo(),$screen_height:jn?.screen.height,$screen_width:jn?.screen.width,$viewport_height:jn?.innerHeight,$viewport_width:jn?.innerWidth,$lib:uS.LIB_NAME,$lib_version:uS.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return uS.SDK_DIST_CHANNEL&&(te.$sdk_dist_channel=uS.SDK_DIST_CHANNEL),te})(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:_,windowId:I}=this.sessionManager.checkAndGetSessionAndWindowId(r,o.getTime(),!0);a.$session_id=_,a.$window_id=I}this.sessionPropsManager&&og(a,this.sessionPropsManager.getSessionProps());try{var c;if(this.sessionRecording){const _=this.sessionRecording.sdkDebugProperties,I=!this.Au&&NKt(e);for(const C in _)(I||jr(Vqo,C))&&(a[C]=_[C])}a.$sdk_debug_retry_queue_size=(c=this.Hu)===null||c===void 0?void 0:c.length}catch(_){a.$sdk_debug_error_capturing_properties=String(_)}let l;if(this.requestRouter.region===uTe&&(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=og(a,l),e==="$pageview"&&qo&&(a.title=qo.title),!Eo(s)){const _=o.getTime()-s;a.$duration=parseFloat((_/1e3).toFixed(3))}l2&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser");const u=this.persistence.properties(),g=this.sessionPersistence.properties(),h=a.$groups,d=u.$groups;va(h)&&!Jx(h)&&(a.$groups=Zt(Zt({},va(d)?d:{}),h)),Cl(["$referrer","$referring_domain"],_=>{_ in u&&delete g[_]});const m={};if(this.Ru.length>0)for(const _ of this.Ru.slice())try{og(m,_())}catch(I){li.error("Failed to produce browser extension event properties",I)}a=og({},A,u,g,Zt(Zt({},m),a)),a.$is_identified=this._isIdentified(),qr(this.config.property_denylist)?Cl(this.config.property_denylist,function(_){delete a[_]}):li.error(DKt+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const p=this.config.sanitize_properties;p&&(li.error(MKt),a=p(a,e));const f=this.bc();return a.$process_person_profile=f,f&&!r&&this._c("_calculate_event_properties"),a}gc(e,n=!0,o=!1){var i;if(!this.persistence||!this.bc()||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=og({},r,s||{},e||{});const A=this.config.sanitize_properties;return A&&(li.error(MKt),a=A(a,"$set_once")),n&&(this.Mu=!0),Jx(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.mc(),(o=this.sessionPersistence)===null||o===void 0||o.register(e),Object.keys(e).forEach(i=>this.Eu.add(i)),this.yc()}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.yc()}wc(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.yc()}yc(){var e;if(!this.Pu)return;if(this.config.persistence==="memory"||!((e=this.sessionPersistence)===null||e===void 0)&&e.hi||!ou.At())return void ou.Pt(this.Pu);const n=[];this.Eu.forEach(o=>n.push(o)),n.length>0?ou.$t(this.Pu,n):ou.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:FG}),()=>{})}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:FG})}getActiveMatchingSurveys(e,n=!1){this.surveys?this.surveys.getActiveMatchingSurveys(e,n):e([],{isLoaded:!1,error:FG})}onActiveMatchingSurveysChanged(e){return this.surveys?this.surveys.onActiveMatchingSurveysChanged(e):(e([],{isLoaded:!1,error:FG}),()=>{})}renderSurvey(e,n){var o;(o=this.surveys)===null||o===void 0||o.renderSurvey(e,n)}displaySurvey(e,n=Hqo){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:FG}}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:FG})}kc(e){return!e||h$(e)?(li.critical("Unique user id has not been set in posthog.identify"),!1):e==="$posthog_cookieless"?(li.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())||(li.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 li.uninitializedWarning("posthog.identify");if(gh(e)&&(e=e.toString(),li.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!this.kc(e)||!this._c("posthog.identify"))return;this.ku();const i=this.get_distinct_id(),r=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==i,s=this.mc(!1),a=this.persistence.Oa();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(Cde),this.register({distinct_id:e}));const u=(this.persistence.get_property("$user_state")||"anonymous")===hS,g=e!==l,h=!g&&u;if(g&&u){var c;const d=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:l};this.persistence.set_property(g2,xde),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=lTe(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(g2,xde);const d=n||{},m=o||{};this.setPersonPropertiesForFlags({$set:d,$set_once:m},!1),this.config.cookieWinsOnConflict&&this.persistence.Da(),this.capture("$set",{$set:d,$set_once:m})&&(this.Lu=lTe(e,n,o))}else(n||o)&&this.setPersonProperties(n,o);g||r||s?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(iP)):h&&(n||o)&&this.reloadFeatureFlags(),A=!0}finally{a&&this.persistence.qa(A)}}setPersonProperties(e,n){if(!e&&!n||!this._c("posthog.setPersonProperties"))return;const o=lTe(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)):li.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(e){var n;const o=(qr(e)?e:[e]).filter(i=>Za(i)&&i.length>0);o.length!==0&&this._c("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 li.error("posthog.group requires a group type and group key");(i=this.persistence)===null||i===void 0||i.syncCookieProperties(),this.mc();const r=this.getGroups(),s=r[e]!==n;if(s&&this.resetGroupPropertiesForFlags(e),this.register({$groups:Zt(Zt({},r),{},{[e]:n})}),(s||o)&&this.bc()){const a={$group_type:e,$group_key:n};o&&(a.$group_set=o),this.capture(iUt,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._c("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=u2(e)?e:e?.resetDeviceID,o=u2(e)||e==null?void 0:e.bootstrap;this.Sc(n,!1,o)}Sc(e,n=!1,o){var i,r,s,a,A,c;if(li.info("reset"),!this.__loaded)return li.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 u=this.get_property(mRe),g=this.get_property(pRe),h=this.get_property(B$);(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 m=(A=this.persistence)===null||A===void 0||(c=A.Oa)===null||c===void 0?void 0:c.call(A),p=this.Su;this.Su=p||n;let f=!1;try{var _,I,C,y,x,E,B,S,Q,w,M,T,R;if((_=this.persistence)===null||_===void 0||_.clear(),(I=this.sessionPersistence)===null||I===void 0||I.clear(),this.Eu.clear(),this.yc(),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:QRe,$device_id:null},"");else{const U=this.config.get_device_id(e9());this.register_once({distinct_id:U,$device_id:e?U:u},""),e||Eo(g)||this.register({[pRe]:g})}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(),!Hs(l)&&!(!((T=this.sessionManager)===null||T===void 0)&&T.setBootstrapSessionId(l,!0)))){const U=Zt({},o);delete U.sessionID,this.config.bootstrap=U}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,f=!0}finally{var F,O;this.Su=p,m&&((F=this.persistence)===null||F===void 0||(O=F.qa)===null||O===void 0||O.call(F,f))}this.reloadFeatureFlags()}shutdown(e){var n=this;return ng(function*(){var o,i,r,s,a,A,c,l;if(n.__loaded){n.Iu=!0,n.Ju().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.Hu)===null||A===void 0||A.unload();try{var u;(u=n.featureFlags)===null||u===void 0||u.destroy()}catch(g){li.error("Error while destroying feature flags",g)}(c=n.persistence)===null||c===void 0||c.destroy(),(l=n.sessionPersistence)===null||l===void 0||l.destroy()}else li.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.xc()}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.$c()}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")?(li.critical("Attempting to create alias for existing People user - aborting."),-2):this._c("posthog.alias")?(Eo(n)&&(n=this.get_distinct_id()),e!==n?(this.wc(Cde,e),this.capture("$create_alias",{alias:e,distinct_id:n})):(li.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){const n=Zt({},this.config);if(va(e)){var o,i,r,s,a,A,c,l,u,g,h,d,m,p;og(this.config,kKt(e));const y=this.Cu();if(this.persistence){const E=this.config.persistence==="sessionStorage"||this.config.persistence==="memory";var f,_;if(E&&this.sessionPersistence!==this.persistence&&((f=this.sessionPersistence)===null||f===void 0||f.remove(),(_=this.sessionPersistence)===null||_===void 0||_.destroy()),this.persistence.update_config(this.config,n,y),E)this.sessionPersistence=this.persistence;else if(this.sessionPersistence===this.persistence)this.sessionPersistence=new qRe(Zt(Zt({},this.config),{},{persistence:"sessionStorage"}),y,!1);else{var I;(I=this.sessionPersistence)===null||I===void 0||I.update_config(Zt(Zt({},this.config),{},{persistence:"sessionStorage"}),Zt(Zt({},n),{},{persistence:"sessionStorage"}),y)}}const x=this.Nu(this.config.debug);var C;u2(x)&&(this.config.debug=x),u2(this.config.debug)&&(this.config.debug?(df.DEBUG=!0,hc.At()&&hc.$t("ph_debug",!0),li.info("set_config",{config:e,oldConfig:n,newConfig:Zt({},this.config)})):(df.DEBUG=!1,hc.At()&&hc.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.webMCP)===null||A===void 0||A.startIfEnabled(),(c=this.sessionRecording)===null||c===void 0||c.startIfEnabledOrStop(),(l=this.tracingHeaders)===null||l===void 0||l.startIfEnabledOrStop(),(u=this.autocapture)===null||u===void 0||u.startIfEnabled(),(g=this.heatmaps)===null||g===void 0||g.startIfEnabled(),("capture_pageview"in e||"disable_capture_url_hashes"in e)&&((C=this.historyAutocapture)===null||C===void 0||C.startIfEnabledOrStop()),(h=this.exceptionObserver)===null||h===void 0||h.startIfEnabledOrStop(),(d=this.deadClicksAutocapture)===null||d===void 0||d.startIfEnabledOrStop(),(m=this.surveys)===null||m===void 0||m.loadIfEnabled(),this.xu(),(p=this.externalIntegrations)===null||p===void 0||p.startIfEnabledOrStop(),!n.segment&&this.config.segment&&this.persistence&&MUt(this,O$,!1)}}_overrideSDKInfo(e,n){df.LIB_NAME=e,df.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(Zt(Zt({},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:gD.Cc}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:G$;return n!==G$&&(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"}bc(){var e,n;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&Jx(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))}rc(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&!!this.config.capture_pageview}createPersonProfile(){this.bc()||this._c("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this._c("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}_c(e){return this.config.person_profiles==="never"?(li.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.bu(),this.wc(SRe,!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.Tc(),((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.yc(),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.Sc(!0,!0),(i=this.sessionManager)===null||i===void 0||i.destroy(),(r=this.pageViewManager)===null||r===void 0||r.destroy(),this.sessionManager=new yKt(this),this.pageViewManager=new RUt(this),this.persistence&&(this.sessionPropsManager=new IKt(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=gD.__defaultExtensionClasses)===null||A===void 0?void 0:A.sessionRecording;var c,l;h&&(this.sessionRecording=this.mu(this.sessionRecording,new h(this)),this.hu&&((c=this.sessionRecording)===null||c===void 0||(l=c.onRemoteConfig)===null||l===void 0||l.call(c,this.hu)))}var u,g;this.consent.optInOut(!0),this.xu(),this.ec(),(n=this.sessionRecording)===null||n===void 0||n.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&((u=this.surveys)===null||u===void 0||u.loadIfEnabled()),(Eo(e?.captureEventName)||e?.captureEventName)&&this.capture((g=e?.captureEventName)!==null&&g!==void 0?g:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.nc()}else li.warn(PKt)}opt_out_capturing(){this.config.cookieless_mode!=="always"?(this.consent.optInOut(!1),this.xu(),this.config.cookieless_mode==="on_reject"&&this.$u()):li.warn(PKt)}$u(){var e,n;const o=this.sessionRecording;o?.dispose({discardBufferedEvents:!0}),this.get_distinct_id()!=="$posthog_cookieless"&&this.Sc(!0,!0),this.register({distinct_id:QRe,$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.nc(),this.ec()}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 I_?xKt(I_,this.config.custom_blocked_useragents):void 0}nc(){qo&&(qo.visibilityState==="visible"?this.Fu||(this.Fu=!0,this.capture(MRe,{title:qo.title},{send_instantly:!0}),this.Ou&&(qo.removeEventListener(x$,this.Ou),this.Ou=null)):this.Ou||(this.Ou=this.nc.bind(this),Zc(qo,x$,this.Ou)))}debug(e){e===!1?(jn?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(jn?.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?(li.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&&!Hs(n[o]),A=i in n&&!Hs(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,li)}Os(e){var n;if(Hs(this.config.before_send))return e;const o=Object.keys((n=e.properties)!==null&&n!==void 0?n:{}).filter(jJo),i=qr(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),Hs(r)){const a=`Event '${e.event}' was rejected in beforeSend function`;return WJo(e.event)?li.warn(`${a}. This can cause unexpected behavior.`):li.info(a),null}r.properties&&!Jx(r.properties)||li.warn(`Event '${e.event}' has no properties after beforeSend function, this is likely an error.`)}catch(a){return li.error(`Error in beforeSend function for event '${e.event}':`,a),null}for(const s of o)if(r.properties&&Hs(r.properties[s]))return li.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=u2(e)&&!e,o=hc.At()&&hc.Ot("ph_debug")==="true";return!n&&(!!o||e)}};Y$.__defaultExtensionClasses={},Y$.Cc=(()=>{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]]=Ujo(t.prototype[e[n]])})(Y$,["identify"]);var FKt=class{constructor(e){this.disabled=e===!1;const n=va(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 hTe="$copy_autocapture",mTe=xd("[AutoCapture]");function pTe(t,e){return e.length>t?e.slice(0,t)+"...":e}function Zqo(t){if(t.previousElementSibling)return t.previousElementSibling;let e=t;do e=e.previousSibling;while(e&&!t9(e));return e}function e$o(t,{e,maskAllElementAttributes:n,maskAllText:o,elementAttributeIgnoreList:i,elementsChainAsString:r,disableCaptureUrlHashes:s}){var a,A;if(!t9(t))return{props:{}};const c=[t],l=new Set([t]);let u=t;for(;u.parentNode&&!BI(u,"body")&&1e3>c.length;){if(ORe(u.parentNode)){const x=u.parentNode.host;if(l.has(x))break;l.add(x),c.push(x),u=x;continue}if(!t9(u.parentNode)||l.has(u.parentNode))break;l.add(u.parentNode),c.push(u.parentNode),u=u.parentNode}const g=e.type==="click"&&t.namespaceURI==="http://www.w3.org/2000/svg"?c.findIndex(x=>BI(x,"button")||BI(x,"a")):-1;g>0&&(o=o||c.slice(0,g+1).some(x=>!JR(x)||vG(x)));const h=[],d={};let m,p=!1,f=!1;if(Cl(c,x=>{const E=JR(x);if(BI(x,"a")&&!n&&!i?.includes("href")){const B=x.getAttribute("href");p=!!(E&&B&&wG(B))&&(s?eP(B):B)}jr(QG(x),"ph-no-capture")&&(f=!0),h.push((function(B,S,Q,w,M=!1){const T=B.tagName.toLowerCase(),R={tag_name:T};YRe.indexOf(T)>-1&&!Q&&(R.$el_text=T.toLowerCase()==="a"||T.toLowerCase()==="button"?pTe(1024,QUt(B)):pTe(1024,v$(B)));const F=QG(B);S||w?.includes("class")||0>=F.length||(R.classes=F.filter(function(q){return q!==""})),Cl(B.attributes,function(q){var ee;if((!vG(B)||["name","id","class","aria-label"].indexOf(q.name)!==-1)&&!w?.includes(q.name)&&!S&&wG(q.value)&&(!Za(ee=q.name)||ee.substring(0,10)!=="_ngcontent"&&ee.substring(0,7)!=="_nghost")){let W=q.value;q.name==="class"&&(W=GRe(W).join(" ")),R["attr__"+q.name]=pTe(1024,q.name==="href"&&M?eP(W):W)}});let O=1,U=1,Y=B;for(;Y=Zqo(Y);)O++,Y.tagName===B.tagName&&U++;return R.nth_child=O,R.nth_of_type=U,R})(x,n,o,i,s)),Cl((function(B){if(!JR(B))return{};const S={};return Cl(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&&wG(M)&&(S[w]=M)}}),S})(x),(B,S)=>{({}).hasOwnProperty.call(d,S)||(d[S]=B)})}),f)return{props:{},explicitNoCapture:f};if(g>0&&(t=c[g],h.splice(0,g)),o||(h[0].$el_text=BI(t,"a")||BI(t,"button")?QUt(t):v$(t)),p){var _,I;h[0].attr__href=p;const x=(_=mS(p))===null||_===void 0?void 0:_.host,E=jn==null||(I=jn.location)===null||I===void 0?void 0:I.host;x&&E&&x!==E&&(m=p)}return{props:og((y=e.type,{$event_type:y,$ce_version:1}),r?{}:{$elements:h},{$elements_chain:(C=h,qr(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 T of E.attr_class)Q+=`.${T.replace(/"/g,"")}`}const w=Zt(Zt(Zt(Zt({},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 Bde(w).sort(([T],[R])=>(function(F,O){return O>F?-1:F>O?1:0})(T,R)).forEach(([T,R])=>M[wUt(T.toString())]=wUt(R.toString())),Q+=":",Q+=Bde(M).map(([T,R])=>`${T}="${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:sqo(E),attr_id:E.attr__id,nth_child:E.nth_child,nth_of_type:E.nth_of_type,attributes:{}};return Bde(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}:{},m&&e.type==="click"?{$external_click_url:m}:{},d),target:t};var C,y}var t$o=class{do(){this.vo=void 0,clearTimeout(this.fo),this.fo=void 0}po(e){var n;if(!JR(e))return!0;const o=(n=this.mo().css_selector_ignorelist)!==null&&n!==void 0?n:zRe,i=new Set;let r=e;for(;r;){if(i.size>=1e3||i.has(r))return!0;i.add(r);const s=r,a=QG(s);if(jr(a,"ph-no-capture")||jr(a,"ph-sensitive")||vG(s)||o.some(c=>URe(s,c)))return!0;const A=r.parentNode;r=ORe(A)?A.host:A&&t9(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=w$(e);var n;return void(e.isPrimary&&e.button===0&&!e.ctrlKey&&i&&t9(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=w$(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&&(BI(i,"html")||BI(i,"body"))){var r;if(o.excluded)return null;const s=(r=this.mo().css_selector_ignorelist)!==null&&r!==void 0?r:zRe;return[i,qo?.documentElement,qo?.body].some(a=>{if(!a)return!1;const A=QG(a);return jr(A,"ph-no-capture")||jr(A,"ph-sensitive")||!JR(a)||vG(a)||s.some(c=>URe(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 FKt(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 mTe.info("Disabling Automatic Event Collection because this browser is not supported");if(!jn||!qo)return;const e=this.Ao=n=>{n=n||jn?.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(yd(o))return;this.Fo(n,"$autocapture",o)}catch(o){mTe.error("Failed to capture event",o)}};if(Zc(jn,"blur",e),Zc(qo,"submit",e,{capture:!0}),Zc(qo,"change",e,{capture:!0}),Zc(qo,"click",e,{capture:!0}),Cl(["pointerdown","pointermove","pointerup","pointercancel"],n=>{Zc(qo,n,e,{capture:!0})}),this.mo().capture_copied_text){const n=this.Oo=o=>{o=o||jn?.event;try{this.Fo(o,hTe)}catch(i){mTe.error("Failed to capture clipboard event",i)}};Zc(qo,"copy",n,{capture:!0}),Zc(qo,"cut",n,{capture:!0}),Zc(qo,"paste",n,{capture:!0})}}Po(){this.do(),this.Ao&&(jn?.removeEventListener("blur",this.Ao),Cl(["pointerdown","pointermove","pointerup","pointercancel"],e=>{qo?.removeEventListener(e,this.Ao,!0)}),qo?.removeEventListener("submit",this.Ao,!0),qo?.removeEventListener("change",this.Ao,!0),qo?.removeEventListener("click",this.Ao,!0),this.Ao=void 0),this.Oo&&(qo?.removeEventListener("copy",this.Oo,!0),qo?.removeEventListener("cut",this.Oo,!0),qo?.removeEventListener("paste",this.Oo,!0),this.Oo=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;u2(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=qo?.querySelectorAll(r);s?.forEach(a=>{e!==a&&n!==a||jr(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(RYt),i=this.So,r=this.mo();if(!r.remoteRequestsDisabled&&!this.xo)return!1;const s=r.remoteRequestsDisabled&&!this.xo;if(yd(i)&&!u2(o)&&!s)return!1;const a=(n=this.So)!==null&&n!==void 0?n:!!o;return!!r.enabled&&!a}Fo(e,n="$autocapture",o){if(!this.isEnabled)return void this.do();let i=o||w$(e);dUt(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()))&&yUt(i,r.rageclick)&&this.Fo(e,"$rageclick",o);const a=n===hTe,A=a?Zt(Zt({},r),{},{dom_event_allowlist:void 0}):r;if(i&&(function(g,h,d,m,p,f){var _;if(!jn||WRe(g)||d?.url_allowlist&&!hUt(d.url_allowlist,f)||d?.url_ignorelist&&hUt(d.url_ignorelist,f))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}=xUt(g,m);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)||!KRe(C,d?.css_selector_allowlist)||KRe(C,(_=d?.css_selector_ignorelist)!==null&&_!==void 0?_:zRe))return!1;try{const x=jn.getComputedStyle(g);if(x&&x.getPropertyValue("cursor")==="pointer"&&h.type==="click")return!0}catch{}const y=g.tagName.toLowerCase();switch(y){case"html":return!1;case"form":return(p||["submit"]).indexOf(h.type)>=0;case"input":case"select":case"textarea":return(p||["change","click"]).indexOf(h.type)>=0;default:return I?(p||["click"]).indexOf(h.type)>=0:(p||["click"]).indexOf(h.type)>=0&&(YRe.indexOf(y)>-1||g.getAttribute("contenteditable")==="true")}})(i,e,A,a,a?["copy","cut","paste"]:void 0,{config:{get_current_url:r.getCurrentUrl}})){var c;const{props:g,explicitNoCapture:h,target:d}=e$o(i,{e,maskAllElementAttributes:r.maskAllElementAttributes,maskAllText:r.maskAllText,elementAttributeIgnoreList:r.element_attribute_ignorelist,elementsChainAsString:this.Co,disableCaptureUrlHashes:r.disableCaptureUrlHashes});if(h)return!1;const m=this.getElementSelectors(i,d);if(m&&m.length>0&&(g.$element_selectors=m),n===hTe){const p=e.type||"clipboard";if(p!=="paste"){var l,u;const f=jn==null||(l=jn.getSelection())===null||l===void 0?void 0:l.toString(),_=mUt(f);if(!_)return!1;g.$selected_content=_,g.$clipboard_text_length=(u=f?.length)!==null&&u!==void 0?u:0}g.$copy_type=p}return(c=this.bo)===null||c===void 0||c.capture(n,g),!0}}isBrowserSupported(){return pp(qo?.querySelectorAll)}},n$o=class{constructor(e){this._instance=e}refresh(e){const n=this._instance.config,o=va(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 U$=xd("[ExceptionAutocapture]"),LKt=()=>{},HKt=t=>{var e;if(pp(t))return(e=t.__posthog_layer__)!==null&&e!==void 0?e:t.__rrweb_layer__};function LG(t,e,n){try{if(!(e in t))return LKt;const o={next:t[e]},i=n(function(...r){return o.next.apply(this,r)});return pp(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=HKt(r);for(;s;){if(s.next===i)return void(s.next=o.next);r=s.next,s=HKt(r)}}}catch{return LKt}}const o$o=xd("[TracingHeaders]"),jR=xd("[Web Vitals]"),OKt=9e5,GKt=["CLS","FCP","INP","LCP"],i$o=["INP","LCP"],r$o=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],fTe="disabled",YKt="lazy_loading",_S=xd("[SessionRecording]"),s$o=[vRe,wRe,WYt,jYt,qYt,$Yt,XYt,ZYt,eUt],a$o=xd("[Heatmaps]");function _Te(t){return va(t)&&"clientX"in t&&"clientY"in t&&gh(t.clientX)&&gh(t.clientY)}const Fde=xd("[Product Tours]"),ITe=t=>{var e;return!t.config.disable_product_tours&&!!(!((e=t.persistence)===null||e===void 0)&&e.get_property(ERe))},A$o=["$set_once","$set"],T7=xd("[SiteApps]"),UKt="Error while initializing PostHog app with config id ",KKt=(t,e)=>t?.then?t.then(e):e(t),HG="SDK is not enabled or survey functionality is not yet loaded",zKt="Disabled. Not loading surveys.";var c$o=class{constructor(e,n){this.wo=e,this.Ic=n,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Mc=!1,this.Ec=!1,this.Pc=[],this.Rc=[],this.Ac=null,this.Fc=null,this.To=!1,this.Oc=new Set,this.onRemoteConfig=o=>{if(this.To||this.Mr.disableSurveys)return;if(!o.ok)return this.Ec=!0,this.Dc({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),yl.warn("Remote config unavailable. Not loading surveys.");const i=o.config.surveys;if(Hs(i))return yl.warn("Flags not loaded yet. Not loading surveys.");this.Lc=u2(i)?i:i.length>0,yl.info(`flags response received, isSurveysEnabled: ${this.Lc}`),this.loadIfEnabled()},this.Dc=o=>{this.Rc.slice().forEach(i=>this.Nc(i,o))}}setup(e){if(!this.To)return this.qc=e,KKt(e.kv.initialize(),()=>{if(this.qc!==e||this.To)return;this.qc=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.qc=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.Pc=[],this.Rc.forEach(s=>{s.active=!1}),this.Rc=[],(r=this.jc)===null||r===void 0||r.call(this),this.jc=void 0,this.Ac=null,this.Oc.forEach(s=>clearTimeout(s)),this.Oc.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.Dc()}loadIfEnabled(){if(this.To||!this.bo)return;const e=this.Mr;if(this._surveyManager)return;if(this.Mc)return void yl.info("Already initializing surveys, skipping...");if(e.disableSurveys)return void yl.info(zKt);if(e.cookielessMode&&this.wo.isOptedOut())return void yl.info("Not loading surveys in cookieless mode without consent.");const n=this.wo.getExtensions();if(!n)return void this.Bc("PostHog Extensions not found.");if(Eo(this.Lc)&&!e.advancedEnableSurveys)return;const o=this.Lc||e.advancedEnableSurveys;this.Mc=!0,this.Ec=!1;try{const i=n.generateSurveys;if(i)return this.zc(i,o),void(this.Mc=!1);const r=n.loadExternalDependency;if(!r)return this.Bc(PRe),void(this.Mc=!1);r(s=>{try{if(this.To)return;const a=this.wo.getExtensions();s||!a?.generateSurveys?this.Bc("Could not load surveys script",s):this.zc(a.generateSurveys,o)}finally{this.Mc=!1}})}catch(i){throw this.Mc=!1,this.Bc("Error initializing surveys",i),i}}zc(e,n){var o,i;if(this.To)return;this._surveyManager=e(n),this._surveyEventReceiver=this.wo.createEventReceiver(this.Dc);const r=(o=(i=this.bo)!==null&&i!==void 0?i:this.Ic)===null||o===void 0?void 0:o.kv.get(b$);r&&this.Hc(r),yl.info("Surveys loaded successfully"),this.Uc(),this.Dc(),this.Wc({isLoaded:!0})}Bc(e,n){this.Ec=!0,yl.error(e,n),this.Dc({isLoaded:!1,error:e}),this.Wc({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.Pc.push(e),this._surveyManager&&this.Wc({isLoaded:!0}),()=>{this.Pc=this.Pc.filter(n=>n!==e)}}getSurveys(e,n=!1){var o;const i=(o=this.bo)!==null&&o!==void 0?o:this.Ic;if(!i||this.To)return;if(this.Mr.disableSurveys)return yl.info(zKt),e([]);const r=i.kv.get(b$);if(r&&!n)return e(r,{isLoaded:!0}),void(this.Vc()&&this.getSurveys(()=>{},!0));if(this.Ac)return void this.Ac.then(({surveys:A,context:c})=>{this.To||e(A,c)}).catch(A=>yl.error("Error in survey callback",A));const s=this.Gc("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.Mr.requestTimeoutMs}).then(A=>{try{return this.Qc(i,A)}catch(c){return yl.error("Error processing surveys response",c),this.Qc(i,{statusCode:0,error:c})}},A=>this.Qc(i,{statusCode:0,error:A}));this.Ac=s;const a=()=>{this.Ac===s&&(this.Ac=null)};s.then(A=>{a(),this.To||(this.Dc(A.context),e(A.surveys,A.context))},a).catch(A=>yl.error("Error in survey callback",A))}Gc(e,n){const o=this.bo;return o?o.sendRequest(e,n):new Promise(i=>i({statusCode:0,error:new Error(HG)}))}Qc(e,n){if(this.To)return{surveys:[],context:{isLoaded:!1,error:HG}};const o=n.statusCode;if(o!==200||!n.json){const r=`Surveys API could not be loaded, status: ${o}`;return o!==0?yl.error(r):n.error||yl.warn(r),this.Fc=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Fc=null;const i=n.json.surveys||[];return e.kv.set({[b$]:i,[yde]:Date.now()}),this.Hc(i),{surveys:i,context:{isLoaded:!0}}}Hc(e){var n;const o=e.filter(i=>(function(r){return!(!r.start_date||r.end_date)})(i)&&(BKt(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)}Vc(){return this.Zc()&&!this.Ac&&!this.Jc()}Zc(){var e,n;const o=(e=(n=this.bo)!==null&&n!==void 0?n:this.Ic)===null||e===void 0?void 0:e.kv.get(yde);return gh(o)&&Date.now()-o>3e5}Jc(){return gh(this.Fc)&&3e5>Date.now()-this.Fc}markSurveyAsSeen(e,n){var o;const i={id:e,current_iteration:(o=n?.iteration)!==null&&o!==void 0?o:null};vKt(i);try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}this.Dc()}Wc(e){for(const n of this.Pc)try{if(!e.isLoaded)return n([],e);this.getSurveys(n)}catch(o){yl.error("Error in survey callback",o)}}getActiveMatchingSurveys(e,n=!1){if(!Hs(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,n);yl.warn("init was not called")}onActiveMatchingSurveysChanged(e){var n,o;if(this.To)return()=>{};const i={callback:e,active:!0,revision:0};this.Rc.push(i),this.Uc();const r=(n=(o=this.bo)!==null&&o!==void 0?o:this.Ic)===null||n===void 0?void 0:n.kv.get(b$);return this.Mr.disableSurveys||!this._surveyManager&&this.Ec&&!this.Mc||!r&&!Hs(this.Fc)&&!this.Ac?this.Nc(i,{isLoaded:!1}):this._surveyManager&&this.Nc(i),()=>{var s;i.active=!1,this.Rc=this.Rc.filter(a=>a!==i),this.Rc.length===0&&((s=this.jc)===null||s===void 0||s.call(this),this.jc=void 0)}}Uc(){var e,n,o;this._surveyManager&&this.Rc.length>0&&((e=this.jc)!==null&&e!==void 0||(this.jc=(n=(o=this.wo).onMatchingConditionsChanged)===null||n===void 0?void 0:n.call(o,this.Dc)))}Nc(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){yl.error("Error in active matching surveys callback",s)}};try{n&&!n.isLoaded?i([]):this.getActiveMatchingSurveys(i)}catch(r){yl.error("Error in active matching surveys callback",r)}}Kc(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}Xc(e){if(Hs(this._surveyManager))return{eligible:!1,reason:HG};const n=typeof e=="string"?this.Kc(e):e;return n?this._surveyManager.checkSurveyEligibility(n):{eligible:!1,reason:"Survey not found"}}Yc(e){if(!this.wo.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(Hs(this._surveyManager))return{eligible:!1,reason:HG};const n=typeof e=="string"?this.Kc(e):e;return n?this._surveyManager.checkSurveyRenderability(n):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(Hs(this._surveyManager))return yl.warn("init was not called"),{visible:!1,disabledReason:HG};const n=this.Yc(e);return{visible:n.eligible,disabledReason:n.reason}}canRenderSurveyAsync(e,n){return Hs(this._surveyManager)?(yl.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:HG})):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.Yc(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(Hs(this._surveyManager))return void yl.warn("init was not called");const r=typeof e=="string"?this.Kc(e):e;if(!r?.id)return void yl.warn("Survey not found");if(!Lqo.includes(r.type))return void yl.warn(`Surveys of type ${r.type} cannot be rendered in the app`);const s=qo?.querySelector(n);if(s){if(!((i=r.appearance)===null||i===void 0)&&i.surveyPopupDelaySeconds){yl.info(`Rendering survey ${r.id} with delay of ${r.appearance.surveyPopupDelaySeconds} seconds`);const a=setTimeout(()=>{var A,c;this.Oc.delete(a),!this.To&&this.wo.isCapturing()&&(yl.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),yl.info(`Survey ${r.id} rendered`))},1e3*r.appearance.surveyPopupDelaySeconds);return void this.Oc.add(a)}this._surveyManager.renderSurvey(r,s,o)}else yl.warn("Survey element not found")}displaySurvey(e,n){var o;if(!this.wo.isCapturing())return;if(Hs(this._surveyManager))return void yl.warn("init was not called");const i=this.Kc(e);if(!i)return void yl.warn("Survey not found");let r=i;if(!((o=i.appearance)===null||o===void 0)&&o.surveyPopupDelaySeconds&&n.ignoreDelay&&(r=Zt(Zt({},i),{},{appearance:Zt(Zt({},i.appearance),{},{surveyPopupDelaySeconds:0})})),n.displayType!==ZRe.Popover&&n.initialResponses&&yl.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),n.ignoreConditions===!1){const s=this.Xc(i);if(!s.eligible)return void yl.warn("Survey is not eligible to be displayed: ",s.reason)}n.displayType!==ZRe.Inline?this._surveyManager.handlePopoverSurvey(r,n):this.renderSurvey(r,n.selector,n.properties)}cancelPendingSurvey(e){Hs(this._surveyManager)?yl.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 OG(t,e,n){if(Hs(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 l$o=class{constructor(e){this._instance=e,this.th=new Set,this.eh=new Set,this.ih=new Rde,this.nh=(n,o)=>this.sh(n,o)&&this.rh(n,o)&&this.oh(n,o)&&this.ah(n,o),this.sh=(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.uh=(n=this._instance)===null||n===void 0?void 0:n._addCaptureHook((o,i)=>{this.on(o,i)}))}dispose(){var e,n;(e=this.uh)===null||e===void 0||e.call(this),this.uh=void 0,(n=this._instance)===null||n===void 0||(n=n.autocapture)===null||n===void 0||n.setElementSelectors(new Set,this),this.ih=new Rde}register(e){var n,o;if(!Eo((n=this._instance)===null||n===void 0?void 0:n._addCaptureHook)&&(e.forEach(i=>{var r;this.th.add(i),(r=i.steps)===null||r===void 0||r.forEach(s=>{this.eh.add(s?.event||"")})}),(o=this._instance)===null||o===void 0?void 0:o.autocapture)){const i=new Set;this.th.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.th.clear(),this.eh.clear(),this.register(e)}on(e,n){n!=null&&e.length!=0&&(this.eh.has(e)||this.eh.has(n.event))&&this.th.forEach(o=>{this.hh(n,o)&&this.ih.emit("actionCaptured",o.name)})}dh(e){this.onAction("actionCaptured",n=>e(n))}hh(e,n){if(n?.steps==null)return!1;for(const o of n.steps)if(this.nh(e,o))return!0;return!1}onAction(e,n){return this.ih.on(e,n)}rh(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"||!OG(i,n.url,n.url_matching||"contains"))return!1}return!0}oh(e,n){return!!this.fh(e,n)&&!!this.ph(e,n)&&!!this.gh(e,n)}fh(e,n){var o;if(!n?.href)return!0;const i=this.mh(e);if(i.length>0)return i.some(s=>OG(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&&OG((function(s){const a=s.match(/(?::|")href="(.*?)"/);return a?a[1]:""})(r),n.href,n.href_matching||"exact")}ph(e,n){var o;if(!n?.text)return!0;const i=this.mh(e);if(i.length>0)return i.some(c=>OG(c.text,n.text,n.text_matching||"exact")||OG(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=[],u=/(?::|")text="(.*?)"/g;let g;for(;!Hs(g=u.exec(c));)l.includes(g[1])||l.push(g[1]);return l})(r),a=n.text,A=n.text_matching||"exact",s.some(c=>OG(c,a,A)));var s,a,A}gh(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}mh(e){var n;return(e==null||(n=e.properties)===null||n===void 0?void 0:n.$elements)==null?[]:e?.properties.$elements}ah(e,n){return!n?.properties||n.properties.length===0||SKt(n.properties.reduce((o,i)=>{const r=qr(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)}},u$o=class{constructor(e,n){var o,i;this.yh=[],this._instance=e,this.bh=n,this._h=new Map,this.wh=new Map,this.kh=new Map,this.Sh=(o=this._instance)===null||o===void 0||(i=o.onSessionId)===null||i===void 0?void 0:i.call(o,r=>this.xh(r))}$h(e){return!1}Ch(){return null}Th(e){}Ih(){}Mh(e,n){return!!e&&SKt(e.propertyFilters,n?.properties)}Eh(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}Ph(e,n,o){const i=(o===R$.Activation?this._h:this.wh).get(e);let r=[];return this.Rh(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.Mh(A,n)})}register(e){this.Ah(e,!1)}replace(e){this.Ah(e,!0)}Ah(e,n){var o;Eo((o=this._instance)===null||o===void 0?void 0:o._addCaptureHook)||(this.Fh(e,n),this.Oh(e,n))}Oh(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.kh.clear(),o.length===0)return void(n&&((i=this.Dh)===null||i===void 0||i.replace([])));this.Dh||(this.Dh=new l$o(this._instance),this.Dh.init(),this.Dh.dh(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.kh.get(A.name))!==null&&c!==void 0?c:[];l.includes(s.id)||l.push(s.id),this.kh.set(A.name,l)}})}),n?this.Dh.replace(r):this.Dh.register(r)}Lh(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)})}Fh(e,n){var o,i;const r=e.filter(c=>{var l,u;return((l=c.conditions)===null||l===void 0?void 0:l.events)&&((u=c.conditions)===null||u===void 0||(u=u.events)===null||u===void 0||(u=u.values)===null||u===void 0?void 0:u.length)>0}),s=e.filter(c=>{var l,u;return((l=c.conditions)===null||l===void 0?void 0:l.cancelEvents)&&((u=c.conditions)===null||u===void 0||(u=u.cancelEvents)===null||u===void 0||(u=u.values)===null||u===void 0?void 0:u.length)>0}),a=this.Eh(e,R$.Activation),A=this.Eh(e,R$.Cancellation);n?(this._h=a,this.wh=A):(this.Lh(this._h,a),this.Lh(this.wh,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.uh)!==null&&o!==void 0||(this.uh=(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.Nh(),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.qh(e,s,n);if(A==="consume")return r.info("event consumed activated item, removing it",{event:e,itemId:s}),void this.jh([s]);if(A==="persist")return r.info("shown item promoted to persisted activation",{event:e,itemId:s}),this.Bh(s),void this.zh([s])}if(this.wh.has(e)){const A=this.Ph(e,n,R$.Cancellation);A.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:A.map(c=>c.id)}),this.jh(A.map(c=>c.id)),A.forEach(c=>this.Hh(c.id)))}if(!this._h.has(e))return;r.info("event name matched",{event:e,eventPayload:n,items:this._h.get(e)});const a=this.Ph(e,n,R$.Activation);this.Uh(a.map(A=>A.id))}onAction(e){this.kh.has(e)&&this.Uh(this.kh.get(e)||[])}Uh(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.$h(s)?this.Bh(s)&&this.Wh(s):r.push(s);r.length>0&&(this.yh=[...new Set([...this.yh,...r])]),this.Nh().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.Vh()}Bh(e){this.yh=this.yh.filter(o=>o!==e);const n=this.Gh();return!n.includes(e)&&(this.Qh([...n,e]),this.Zh(),!0)}jh(e){const n=new Set(e);this.yh=this.yh.filter(r=>!n.has(r));const o=this.Jh(),i=o.filter(r=>!n.has(r));i.length!==o.length&&(this.Qh(i),i.length===0&&this.Kh()),this.zh(e),this.Vh()}Vh(){try{var e;(e=this.bh)===null||e===void 0||e.call(this)}catch(n){this.Nh().error("Error while handling activated items change",n)}}Xh(){var e;const n=this.Ch();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:{}}Wh(e){if(!this.Ch())return;const n=this.Xh();this.Th(Zt(Zt({},n),{},{[e]:Date.now()}))}zh(e){if(!this.Ch())return;const n=this.Xh(),o={};let i=!1;for(const[r,s]of Object.entries(n))e.includes(r)?i=!0:o[r]=s;i&&(Jx(o)?this.Ih():this.Th(o))}Yh(){this.Ch()&&this.Ih()}getActivationTimestamp(e){if(!this.Gh().includes(e))return;const n=this.Xh()[e];return gh(n)?n:void 0}Jh(){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])||[]}Gh(){var e,n,o;const i=this.Jh();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:[]}Zh(){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)}Kh(){this.sd()}xh(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.Jh(),r=this.Xh();i.length>0&&(this.Qh([]),i.filter(s=>gh(r[s])).forEach(s=>this.Hh(s))),this.Kh(),this.Yh(),i.length>0&&this.Vh()}}getActivatedIds(){return[...new Set([...this.Gh(),...this.yh])].filter(e=>!this.rd(e))}dispose(){var e,n,o;(e=this.Sh)===null||e===void 0||e.call(this),this.Sh=void 0,(n=this.uh)===null||n===void 0||n.call(this),this.uh=void 0,(o=this.Dh)===null||o===void 0||o.dispose(),this.Dh=void 0}reset(){this.yh=[],this.Jh().length>0&&this.Qh([]),this.Kh(),this.Yh(),this.Vh()}getEventToItemsMap(){return this._h}od(){return this.Dh}},g$o=class extends u$o{constructor(t,e){super(t,e)}td(){return OYt}ed(){return GYt}Ch(){return YYt}Th(t){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.register({$surveys_activated_timestamps:t})}Ih(){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.unregister("$surveys_activated_timestamps")}$h(t){var e;let n;this.Rh(i=>{n=i.find(r=>r.id===t)});const o=n==null||(e=n.appearance)===null||e===void 0?void 0:e.surveyPopupDelaySeconds;return gh(o)&&o>0}ad(){return SE.SHOWN}Rh(t){var e;(e=this._instance)===null||e===void 0||e.getSurveys(t)}Hh(t){var e;(e=this._instance)===null||e===void 0||e.cancelPendingSurvey(t)}Nh(){return yl}Qh(t){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.register({$surveys_activated:t})}nd(t){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.register({$surveys_activated_session:t})}sd(){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.unregister("$surveys_activated_session")}rd(){return!1}qh(t,e,n){var o;if(t===SE.SENT&&(n==null||(o=n.properties)===null||o===void 0?void 0:o.$survey_completed)===!1)return"ignore";let i;return this.Rh(r=>{i=r.find(s=>s.id===e)}),!i||(function(r){var s;return BKt(r)&&!!(!((s=r.conditions)===null||s===void 0||(s=s.events)===null||s===void 0)&&s.repeatedActivation)||r.schedule==="always"})(i)?t===SE.SHOWN?"consume":"ignore":t===SE.SHOWN?"persist":t===SE.DISMISSED||t===SE.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},d$o=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)}},h$o=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=Kr?.__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 g$o(this._instance,e)}onMatchingConditionsChanged(e){const n=this._instance._addCaptureHook(s=>{s!=="$pageview"&&s!==SE.SHOWN&&s!==SE.DISMISSED&&s!==SE.SENT||e()}),o=()=>e();Zc(jn,"PHSurveyShown",o);let i=!1;const r=this._instance.onFeatureFlags(()=>{i&&e()});return i=!0,()=>{i=!1,n(),r(),jn?.removeEventListener("PHSurveyShown",o)}}};const m$o=jn?.location?Qde(jn.location.hash,"__posthog")||Qde(location.hash,"state"):null,VKt="_postHogToolbarParams",JKt=xd("[Toolbar]"),WKt=xd("[FeatureFlags]"),qR=xd("[FeatureFlags]",{debugEnabled:!0}),CTe=`" failed. Feature flags didn't load in time.`,p$o=[502,504],jKt=["click","keydown","wheel","touchstart","pointerdown"],qKt="connection_error",$Kt=t=>{const e={};for(let n=0;t.length>n;n++)e[t[n]]=!0;return e},XKt=t=>{const e={};for(const[n,o]of Bde(t||{}))o&&(e[n]=o);return e};var f$o=class{constructor(e){this.name="featureFlags",this.ld=!1,this.featureFlagEventHandlers=[],this.A=WKt,this.ud={},this.hd={},this.dd=[],this.vd=new Set,this.fd=new Set,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 n=this.xd();this.kd=0,n&&this.reloadFeatureFlags()},this.$d=()=>{var n,o;const i=this.Cd,r=(n=this.Td)!==null&&n!==void 0?n:i;Eo(i)||Eo(r)||this.Mr.remoteRequestsDisabled||!this.Id||this.Id.visibilityState==="hidden"||Date.now()-((o=this.Md)!==null&&o!==void 0?o:0)<r||(this.Td=this.Sd||!this.Mr.idleRefreshBackoff?i:Math.min(2*r,36e5),this.Sd=!1,this.reloadFeatureFlags(),this.Ed())},this.Pd=()=>{this.Sd&&this.Td===this.Cd||this.Rd()},this.sn=()=>{var n;((n=this.Id)===null||n===void 0?void 0:n.visibilityState)==="visible"&&this.Rd()},this.wo=e}get Ad(){}Fd(){this.bo&&this.Od()}setup(e){try{this.Dd=typeof window>"u"?void 0:window,this.Id=typeof document>"u"?void 0:document}catch{this.Dd=void 0,this.Id=void 0}return this.qc=e,this.A=e.logger.createLogger("[FeatureFlags]"),KKt(e.kv.initialize(),()=>{this.qc===e&&(this.qc=void 0,this.bo=e,this.Ld(e))})}Ld(e){var n;if(this.bo===e)return this.Dd&&Zc(this.Dd,"online",this.rn),this.Od(),this.Nd=e.registerDynamicEventProperties(()=>this.qd()?this.ud:this.hd),this.jd=(n=this.Ad)===null||n===void 0?void 0:n.onCrossTabFeatureFlagChange(()=>{this.Bd(),this.zd(),this.Hd()}),this.zd(),this.initialize()}Rd(){this.Sd=!0,this.Td=this.Cd,this.$d()}Od(){var e;const n=this.Mr.refreshIntervalMs,o=!this.Mr.remoteRequestsDisabled&&this.Id&&!Eo(n)&&n>0?n:void 0;this.Mr.idleRefreshBackoff||(this.Td=o),o!==this.Cd&&(this.Ud(),Eo(o)||(this.Cd=o,this.Td=o,this.Ed(),!((e=this.Id)===null||e===void 0)&&e.addEventListener&&(Zc(this.Id,x$,this.sn),BG(jKt,i=>{Zc(this.Id,i,this.Pd,{capture:!0})}))))}Ed(){Eo(this.Cd)||(Eo(this.Wd)||clearInterval(this.Wd),this.Md=Date.now(),this.Wd=setInterval(this.$d,this.Cd))}Ud(){var e,n;Eo(this.Wd)||(clearInterval(this.Wd),this.Wd=void 0,(e=this.Id)===null||e===void 0||(n=e.removeEventListener)===null||n===void 0||n.call(e,"visibilitychange",this.sn),BG(jKt,o=>{var i,r;(i=this.Id)===null||i===void 0||(r=i.removeEventListener)===null||r===void 0||r.call(i,o,this.Pd,{capture:!0})})),this.Cd=void 0,this.Td=void 0,this.Sd=!1,this.Md=void 0}destroy(){this.Vd()}dispose(){this.Vd()}Vd(){var e,n,o;this.Ud(),this.md++,this.bd=!1,this.qc=void 0,this.Gd(this.vd,"cancelled"),this.Gd(this.fd,"cancelled"),this.bo&&(this.Qd(),(e=this.Nd)===null||e===void 0||e.dispose(),this.Nd=void 0,(n=this.jd)===null||n===void 0||n.call(this),this.jd=void 0,this.dd=[],(o=this.Dd)===null||o===void 0||o.removeEventListener("online",this.rn),this.bo=void 0)}get Mr(){return this.wo.get()}Zd(e){var n;return this.Jd&&e in this.Jd?this.Jd[e]:(n=this.bo)===null||n===void 0?void 0:n.kv.get(e)}Bd(){return!!this.Jd&&(this.Jd=void 0,!0)}Kd(){var e;return!Eo((e=this.bo)===null||e===void 0?void 0:e.kv.get("$enabled_feature_flags"))&&this.Bd()}$t(e){this.Xd(()=>{var n;return(n=this.bo)===null||n===void 0?void 0:n.kv.set(e)})}Yd(e,n,o){if(!this.Ad||!e.$enabled_feature_flags)return;const i=this.Zd("$enabled_feature_flags")||{},r=e.$enabled_feature_flags||{},s=n.flags||n.featureFlags,a=n.flags?Object.entries(n.flags).filter(([,f])=>!f?.failed).map(([f])=>f):[],A=!!n.errorsWhileComputingFlags&&!!n.flags,c=A?a:o&&!qr(s)?Object.keys(s||{}):Array.from(new Set([...Object.keys(i),...Object.keys(r)])),l=this.Zd("$feature_flag_payloads")||{},u=e.$feature_flag_payloads||{},g=A||o?c:Array.from(new Set([...Object.keys(l),...Object.keys(u)])),h=!A&&!o,d=!!h||c,m=!!h||g,p={[dS]:d,[XB]:d,[rP]:m};e.$feature_flag_details&&(p[YR]=d);for(const f of[UR,tP,C$])Eo(e[f])||(p[f]=!0);this.Ad.markCrossTabFeatureFlagChanges(p)}Pt(e){this.Xd(()=>{var n;return(n=this.bo)===null||n===void 0?void 0:n.kv.remove(e)})}Xd(e){try{e()}catch(n){this.A.error("Failed to update feature flag persistence",n)}}zd(){const e={};for(const i of[dS,rP,UR,R7]){const r=this.Zd(i);Eo(r)||(e[i]=r)}this.ud=e;const n=Zt({},e),o=this.Zd(XB);if(o)for(const[i,r]of Object.entries(o))n[`$feature/${i}`]=r;this.hd=n}qd(){const e=this.Mr.cacheTtlMs;if(!e||0>=e)return!1;const n=this.Zd(tP);return typeof n!="number"||Date.now()-n>e}tv(){return!!this.qd()&&(this.wd||this.gd||(this.wd=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}ev(){const e=this.Mr.evaluationContexts;return e?.length?e.filter(n=>{const o=n&&typeof n=="string"&&n.trim().length>0;return o||this.A.error("Invalid evaluation context found:",n,"Expected non-empty string"),o}):[]}iv(){const e=this.Mr.flagKeys;if(!Eo(e))return e.filter(n=>{const o=n&&typeof n=="string"&&n.trim().length>0;return o||this.A.error("Invalid flag key found:",n,"Expected non-empty string"),o})}initialize(){var e,n;const o=this.Mr,i=(e=(n=o.bootstrap)===null||n===void 0?void 0:n.featureFlags)!==null&&e!==void 0?e:{};if(Object.keys(i).length){var r,s;const a=(r=(s=o.bootstrap)===null||s===void 0?void 0:s.featureFlagPayloads)!==null&&r!==void 0?r:{},A=Object.keys(i).filter(l=>!Eo(i[l])).reduce((l,u)=>(l[u]=i[u],l),{}),c=Object.keys(a).filter(l=>A[l]).reduce((l,u)=>(l[u]=a[u],l),{});return this.nv({featureFlags:A,featureFlagPayloads:c},void 0,{persist:!1})}}updateFlags(e,n,o){var i,r;const s=o?.merge&&(i=this.Zd("$enabled_feature_flags"))!==null&&i!==void 0?i:{},a=o?.merge&&(r=this.Zd("$feature_flag_payloads"))!==null&&r!==void 0?r:{},A=Zt(Zt({},s),e),c=Zt(Zt({},a),n),l={};for(const[u,g]of Object.entries(A))l[u]={key:u,enabled:rYt(g),variant:sYt(g),reason:void 0,metadata:Eo(c?.[u])?void 0:{id:0,version:void 0,description:void 0,payload:c[u]}};this.nv({flags:l})}get hasLoadedFlags(){return this.pd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const e=this.Zd(YR),n=this.Zd(R7),o=this.Zd(KR);if(!o&&!n)return e||{};const i=og({},e||{}),r=[...new Set([...Object.keys(o||{}),...Object.keys(n||{})])];for(const A of r){var s,a;const c=i[A],l=n?.[A],u=Eo(l)?(s=c?.enabled)!==null&&s!==void 0&&s:!!l,g=Eo(l)?c?.variant:typeof l=="string"?l:void 0,h=o?.[A],d=Zt(Zt({},c),{},{enabled:u,variant:u?g??c?.variant:void 0});u!==c?.enabled&&(d.original_enabled=c?.enabled),g!==c?.variant&&(d.original_variant=c?.variant),h&&(d.metadata=Zt(Zt({},c?.metadata),{},{payload:h,original_payload:c==null||(a=c.metadata)===null||a===void 0?void 0:a.payload})),i[A]=d}return this.ld||(this.A.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:o,finalDetails:i}),this.ld=!0),i}getAllFeatureFlags(){const e=this.getFlagVariants(),n=this.getFlagPayloads();return Object.keys(e).map(o=>{const i=e[o];return{key:o,enabled:rYt(i),variant:sYt(i),payload:iYt(n[o])}})}getFlagVariants(){const e=this.Zd(XB),n=this.Zd(R7);if(!n)return e||{};const o=og({},e||{}),i=Object.keys(n);for(let r=0;i.length>r;r++)o[i[r]]=n[i[r]];return this.ld||(this.A.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:n,finalFlags:o}),this.ld=!0),o}getFlagPayloads(){const e=this.Zd(rP),n=this.Zd(KR);if(!n)return e||{};const o=og({},e||{}),i=Object.keys(n);for(let r=0;i.length>r;r++)o[i[r]]=n[i[r]];return this.ld||(this.A.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:n,finalPayloads:o}),this.ld=!0),o}reloadFeatureFlags(){this.yd||this.Mr.featureFlagsDisabled||this.xd()||(this.gd&&(this.bd=!0),this.sv||(this.dd.slice().forEach(e=>{try{e()}catch(n){this.A.error("Error while running feature flags reloading callback",n)}}),this.sv=setTimeout(()=>{this.rv()},5)))}reloadFeatureFlagsAsync(){return!this.bo||this.yd||this.Mr.featureFlagsDisabled||this.Mr.remoteRequestsDisabled||this.xd()?Promise.resolve({status:"skipped"}):new Promise(e=>{this.vd.add(e),this.reloadFeatureFlags()})}Gd(e,n){e.forEach(o=>o({status:n})),e.clear()}Qd(){clearTimeout(this.sv),this.sv=void 0}onReloading(e){return this.dd.push(e),()=>{this.dd=this.dd.filter(n=>n!==e)}}ensureFlagsLoaded(){this.pd||this.gd||this.sv||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.yd=e}resetFlagCallReported(){this.Pt(iP)}rv(e){var n;this.Qd();const o=this.bo;if(!o||this.Mr.remoteRequestsDisabled||this.xd())return void this.Gd(this.vd,"skipped");if(this.gd)return void(this.bd=!0);const i={token:o.projectToken,distinct_id:o.distinctId,groups:o.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:Zt(Zt(Zt({},o.initialPersonProperties),this.Zd("$stored_person_properties")||{}),{},{$lib:o.library.name,$lib_version:o.library.version}),group_properties:this.Zd(nP),timezone:TUt()};Eo(o.deviceId)||(i.$device_id=o.deviceId),(e?.disableFlags||this.Mr.featureFlagsDisabled)&&(i.disable_flags=!0);const r=this.ev();r.length&&(i.evaluation_contexts=r);const s=this.iv();Eo(s)||(i.flag_keys=s);const a=this.Mr.onlyEvaluateSurveyFeatureFlags,A="/flags/?v=2"+(a?"&only_evaluate_survey_feature_flags=true":""),c=this.md,l=this.vd;this.vd=new Set,this.fd=l,this.gd=!0;const u=()=>{this.bd&&(this.bd=!1,this.rv())},g=f=>{var _,I;const C=(_=f.json)!==null&&_!==void 0?_:{},y=f.statusCode!==200;if(this.gd=!1,c!==this.md)return void u();if(this.ov(f.statusCode),y||this.bd||(this.$anon_distinct_id=void 0),i.disable_flags&&!this.bd)return void this.Gd(l,"skipped");this._d=!y;const x=[];f.error?x.push(f.error instanceof Error&&f.error.name==="AbortError"?"timeout":f.error instanceof Error?qKt:"unknown_error"):f.statusCode!==200&&x.push(`api_error_${f.statusCode}`),C.errorsWhileComputingFlags&&x.push("errors_while_computing_flags");const E=!!(!((I=C.quotaLimited)===null||I===void 0)&&I.includes("feature_flags"));E&&x.push("quota_limited"),this.$t({[I$]:x}),E?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."):i.disable_flags||this.nv(C,y,{partialResponse:a}),this.Gd(l,i.disable_flags?"skipped":x.length||!C.flags&&!C.featureFlags?"error":"loaded"),u()},h=f=>{this.gd=!1,c===this.md&&(this.$t({[I$]:[qKt]}),this.A.error("Feature flag request failed",f),this.Kd()&&this.Hd(!0),this.Gd(l,"error")),u()};let d=(n=this.Mr.requestMaxRetries)!==null&&n!==void 0?n:1;const m=()=>d>0&&c===this.md,p=()=>{if(c!==this.md||!this.bo||this.Mr.remoteRequestsDisabled)return this.gd=!1,this.Gd(l,"skipped"),void u();try{o.sendRequest(A,{target:"flags",method:"POST",body:i,compression:this.Mr.compression,sentAt:"body",timeoutMs:this.Mr.requestTimeoutMs}).then(f=>{if((_=>p$o.includes(_.statusCode)||(I=>I.statusCode===0&&I.error instanceof Error&&I.error.name==="AbortError")(_))(f)&&m())return d--,void setTimeout(p,500);g(f)}).catch(h)}catch(f){h(f)}};p()}xd(){return FUt(this.kd,3)}ov(e){this.kd=LUt(e,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(e,n={}){var o;if(n.fresh&&!this._d)return;if(!(this.pd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlag for key "'+e+CTe);if(this.tv())return;const i=this.getFeatureFlagResult(e,n);return(o=i?.variant)!==null&&o!==void 0?o:i?.enabled}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){const n=this.getFeatureFlagResult(e,{send_event:!1});return n?.payload}getFeatureFlagResult(e,n={}){if(n.fresh&&!this._d)return;if(!(this.pd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlagResult for key "'+e+CTe);if(this.tv())return;const o=this.getFlagVariants(),i=e in o,r=o[e],s=this.getFlagPayloads()[e],a=String(r),A=this.Zd("$feature_flag_request_id")||void 0,c=this.Zd("$feature_flag_evaluated_at")||void 0;let l,u=this.Zd("$flag_call_reported")||{};if(this.Mr.deduplicateCallsPerSession){var g;const Q=(g=this.bo)===null||g===void 0?void 0:g.session.sessionId,w=this.Zd(y$);Q&&Q!==w&&(u={},l=Q)}if(!n.send_event&&"send_event"in n)l&&this.$t({[iP]:u,[y$]:l});else if(e in u&&u[e].includes(a))l&&this.$t({[iP]:u,[y$]:l});else{var h,d,m,p,f,_,I,C,y,x,E,B,S;qr(u[e])?u[e].push(a):u[e]=[a],this.$t(Zt({[iP]:u},l?{[y$]:l}:{}));const Q=this.getFeatureFlagDetails(e),w=[...(h=this.Zd("$feature_flag_errors"))!==null&&h!==void 0?h:[]];Eo(r)&&w.push("flag_missing");const M={$feature_flag:e,$feature_flag_response:r,$feature_flag_payload:s??null,$feature_flag_request_id:A,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:(d=(m=this.Mr.bootstrap)===null||m===void 0||(m=m.featureFlags)===null||m===void 0?void 0:m[e])!==null&&d!==void 0?d:null,$feature_flag_bootstrapped_payload:(p=(f=this.Mr.bootstrap)===null||f===void 0||(f=f.featureFlagPayloads)===null||f===void 0?void 0:f[e])!==null&&p!==void 0?p:null,$used_bootstrap_value:!this._d};Eo(Q==null||(_=Q.metadata)===null||_===void 0?void 0:_.has_experiment)||(M.$feature_flag_has_experiment=Q.metadata.has_experiment),Eo(Q==null||(I=Q.metadata)===null||I===void 0?void 0:I.version)||(M.$feature_flag_version=Q.metadata.version);const T=(C=Q==null||(y=Q.reason)===null||y===void 0?void 0:y.description)!==null&&C!==void 0?C:Q==null||(x=Q.reason)===null||x===void 0?void 0:x.code;T&&(M.$feature_flag_reason=T),!(Q==null||(E=Q.metadata)===null||E===void 0)&&E.id&&(M.$feature_flag_id=Q.metadata.id),Eo(Q?.original_variant)&&Eo(Q?.original_enabled)||(M.$feature_flag_original_response=Eo(Q.original_variant)?Q.original_enabled:Q.original_variant),!(Q==null||(B=Q.metadata)===null||B===void 0)&&B.original_payload&&(M.$feature_flag_original_payload=Q==null||(S=Q.metadata)===null||S===void 0?void 0:S.original_payload),w.length&&(M.$feature_flag_error=w.join(",")),this.av(M)}return i?{key:e,enabled:!!r,variant:typeof r=="string"?r:void 0,payload:iYt(s)}:void 0}av(e){try{var n;(n=this.bo)===null||n===void 0||n.capture("$feature_flag_called",e)}catch(o){this.A.error("Failed to capture feature flag call",o)}}getRemoteConfigPayload(e,n){this.lv(e,n)}lv(e,n){var o=this;return ng(function*(){const i=o.bo;if(!i)return;const r={distinct_id:i.distinctId,token:i.projectToken,person_properties:{$lib:i.library.name,$lib_version:i.library.version}},s=o.ev();s.length&&(r.evaluation_contexts=s);const a=o.iv();let A;Eo(a)||(r.flag_keys=a);try{var c;const l=(c=(yield i.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:r,compression:o.Mr.compression,sentAt:"body",timeoutMs:o.Mr.requestTimeoutMs})).json)===null||c===void 0?void 0:c.featureFlagPayloads;A=l?.[e]||void 0}catch(l){return void o.A.error("Remote config feature flag request failed",l)}try{n(A)}catch(l){o.A.error("Remote config feature flag callback failed",l)}})()}isFeatureEnabled(e,n={}){if(n.fresh&&!this._d)return n.defaultValue;if(!(this.pd||this.getFlags()&&this.getFlags().length>0))return this.A.warn('isFeatureEnabled for key "'+e+CTe),n.defaultValue;const o=this.getFeatureFlag(e,n);return Eo(o)?n.defaultValue:!!o}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(n=>n!==e)}receivedFeatureFlags(e,n,o){this.nv(e,n,o)}nv(e,n,o){if(!this.bo)return;this.pd=!0;const i=((r,s={},a={},A={},c,l=WKt)=>{const u=((C,y)=>{const x=C.flags;if(x){const E=Object.fromEntries(Object.keys(x).map(S=>{var Q;return[S,(Q=x[S].variant)!==null&&Q!==void 0?Q:x[S].enabled]})),B=Object.fromEntries(Object.keys(x).filter(S=>x[S].enabled).filter(S=>{var Q;return!Eo((Q=x[S].metadata)===null||Q===void 0?void 0:Q.payload)}).map(S=>{var Q;return[S,(Q=x[S].metadata)===null||Q===void 0?void 0:Q.payload]}));return Zt(Zt({},C),{},{featureFlags:E,featureFlagPayloads:B})}return C.featureFlags&&y.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),C})(r,l),g=u.flags,h=u.featureFlags,d=u.featureFlagPayloads;if(!h)return;const m=r.requestId,p=r.evaluatedAt;if(qr(h)){l.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const C={};if(h)for(let y=0;h.length>y;y++)C[h[y]]=!0;return{[dS]:h,[XB]:C,[C$]:!1}}let f=h,_=d,I=g;if(c?.partialResponse){const C=Object.keys(f),y=_||{};f=Zt(Zt({},s),f),_=Zt(Zt({},a),y),C.forEach(x=>{x in y||_==null||delete _[x]}),I=Zt(Zt({},A),I)}else if(r.errorsWhileComputingFlags)if(g){const C=new Set(Object.keys(g).filter(x=>{var E;return!(!((E=g[x])===null||E===void 0)&&E.failed)}));f=Zt(Zt({},s),Object.fromEntries(Object.entries(f).filter(([x])=>C.has(x))));const y=Object.fromEntries(Object.entries(_||{}).filter(([x])=>C.has(x)));_=Zt(Zt({},a),y),C.forEach(x=>{x in y||_==null||delete _[x]}),I=Zt(Zt({},A),Object.fromEntries(Object.entries(I||{}).filter(([x])=>C.has(x))))}else f=Zt(Zt({},s),f),_=Zt(Zt({},a),_),I=Zt(Zt({},A),I);return Zt(Zt({[dS]:Object.keys(XKt(f)),[XB]:f||{},[rP]:_||{},[YR]:I||{},[C$]:r.minimalFlagCalledEvents===!0},m?{[UR]:m}:{}),p?{[tP]:p}:{})})(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),o,this.A);if(i)if(o?.persist===!1){const r=!Eo(this.bo.kv.get(XB));this.Jd=i,r||this.$t(i)}else this.Bd(),this.Yd(i,e,!!o?.partialResponse),this.$t(i);else n&&this.Kd();n||(this.wd=!1),this.Hd(n)}override(e,n=!1){this.A.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:n})}overrideFeatureFlags(e){this.uv(e)}uv(e){if(this.bo){if(e===!1)return this.Pt([R7,KR]),this.Hd(),void qR.info("All overrides cleared");if(qr(e))return this.$t({[R7]:$Kt(e)}),this.Hd(),void qR.info("Flag overrides set",{flags:e});if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var n;const o=e;this.ld=!!((n=o.suppressWarning)!==null&&n!==void 0&&n);const i={},r=o.flags,s=o.payloads;return r&&(i[R7]=qr(r)?$Kt(r):r),s&&(i[KR]=s),Object.keys(i).length&&this.$t(i),r===!1&&s===!1?this.Pt([R7,KR]):r===!1?this.Pt(R7):s===!1&&this.Pt(KR),this.Hd(),r===!1?qR.info("Flag overrides cleared"):r&&qR.info("Flag overrides set",{flags:r}),void(s===!1?qR.info("Payload overrides cleared"):s&&qR.info("Payload overrides set",{payloads:s}))}if(e&&typeof e=="object")return this.$t({[R7]:e}),this.Hd(),void qR.info("Flag overrides set",{flags:e});this.A.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}else this.A.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.pd){const{flags:n,flagVariants:o}=this.hv();try{e(n,o)}catch(i){this.A.error("Error while running feature flags callback",i)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,n,o){var i;const r=(this.Zd("$early_access_features")||[]).find(l=>l.flagKey===e),s={[`$feature_enrollment/${e}`]:n},a={$feature_flag:e,$feature_enrollment:n,$set:s};r&&(a.$early_access_feature_name=r.name),o&&(a.$feature_enrollment_stage=o);const A=Zt(Zt({},this.getFlagVariants()),{},{[e]:n});(i=this.Ad)===null||i===void 0||i.markCrossTabFeatureFlagChanges({$active_feature_flags:[e],$enabled_feature_flags:[e],$stored_person_properties:Object.keys(s)}),this.$t({[dS]:Object.keys(XKt(A)),[XB]:A,[oP]:Zt(Zt({},this.Zd("$stored_person_properties")||{}),s)}),this.Hd();try{var c;(c=this.bo)===null||c===void 0||c.capture("$feature_enrollment_update",a)}catch(l){this.A.error("Failed to capture early access feature enrollment",l)}}getEarlyAccessFeatures(e,n=!1,o){const i=this.Zd(hRe);!i||n?this.dv(e,o):e(i)}dv(e,n){var o=this;return ng(function*(){const i=o.bo;if(!i)return;const r=n?`&${n.map(a=>`stage=${a}`).join("&")}`:"";let s;try{const a=yield i.sendRequest(`/api/early_access_features/?token=${i.projectToken}${r}`,{target:"api",method:"GET",sentAt:"query"});if(!a.json)return;s=a.json.earlyAccessFeatures,o.$t({[hRe]:s})}catch(a){return void o.A.error("Early access feature request failed",a)}try{e(s)}catch(a){o.A.error("Early access feature callback failed",a)}})()}hv(){const e=this.getFlags(),n=this.getFlagVariants();return{flags:e.filter(o=>n[o]),flagVariants:Object.keys(n).filter(o=>n[o]).reduce((o,i)=>(o[i]=n[i],o),{})}}Hd(e){this.zd();const{flags:n,flagVariants:o}=this.hv();this.featureFlagEventHandlers.forEach(i=>{try{i(n,o,{errorsLoading:e})}catch(r){this.A.error("Error while running feature flags callback",r)}})}setPersonPropertiesForFlags(e,n=!0){this.vv(e,n)}vv(e,n=!0){const o=this.Zd("$stored_person_properties")||{},i=e?.$set||(e?.$set_once?{}:e),r=e?.$set_once,s={};if(r)for(const a in r)({}).hasOwnProperty.call(r,a)&&(a in o||(s[a]=r[a]));this.$t({[oP]:Zt(Zt(Zt({},o),s),i)}),n&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,n=!0){const o=Zt({},this.Zd("$stored_person_properties")||{});e.forEach(i=>{delete o[i]}),this.$t({[oP]:o}),n&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e=!0){this.Pt(oP),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,n=!0){const o=this.Zd("$stored_group_properties")||{},i=Zt({},o);for(const r of Object.keys(e))i[r]=Zt(Zt({},o[r]),e[r]);this.$t({[nP]:i}),n&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){const n=this.Zd("$stored_group_properties")||{};this.$t({[nP]:Zt(Zt({},n),{},{[e]:{}})})}else this.Pt(nP)}reset(){this.md++,this.Gd(this.vd,"cancelled"),this.Gd(this.fd,"cancelled"),this.bd=!1,this.ud={},this.hd={},this.Jd=void 0,this.pd=!1,this.yd=!1,this._d=!1,this.$anon_distinct_id=void 0,this.Qd(),this.ld=!1,this.kd=0}};const ZKt=xd("[FeatureFlags]");var _$o=class{constructor(e,n=!1){this.fv=!1,this.update(e,n)}update(e,n){this.pv=((o,i)=>{var r,s,a,A,c,l,u,g;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:(u=(g=o.evaluation_contexts)!==null&&g!==void 0?g:o.evaluation_environments)!==null&&u!==void 0?u:[],flagKeys:qr(o.flag_keys)?o.flag_keys:void 0}})(e,n),!e.evaluation_environments||e.evaluation_contexts||this.fv||(ZKt.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.fv=!0),Eo(e.flag_keys)||qr(e.flag_keys)||ZKt.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this.pv}};const ezt=t=>_G(t)&&(t.name==="RangeError"&&t.message.indexOf("Maximum call stack size exceeded")===0||t.name==="InternalError"&&t.message==="too much recursion"),n9=xd("[Error tracking]"),yTe="webkit-masked-url:",I$o=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],C$o=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",yTe],y$o=["__firefox__","__gCrWeb"],tzt="Refusing to render web experiment since the viewer is a likely bot",x$o={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>Tde(e,t),not_regex:(t,e)=>!Tde(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t},B4=xd("[Conversations]"),$R="Conversations not available yet.";function nzt(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,u=e?.consoleCapture?void 0:(i=t?.maxLogsPerInterval)!==null&&i!==void 0?i:1e3,g=Eo(u)?Math.max(l,2048):Math.max(l,u),h=Zt(Zt({},(function(){let d="",m="";try{const p=I_?.userAgent;p&&([d,m]=OGt(p))}catch{}return(function(p,f){const _=(function(I){if(I)return{}.hasOwnProperty.call(yYt,I)?yYt[I]:I})(p);return Zt(Zt({},_?{"os.name":_}:{}),f?{"os.version":f}:{})})(d,m)})()),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:g,maxBatchRecordsPerPost:100,rateCapWindowMs:c,maxLogsPerInterval:u,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const E$o=["debug","log","warn","error","info"],B$o=t=>{for(;t?.__rrweb_original__;)t=t.__rrweb_original__;return t},ozt="console",izt="__posthogHandledLogsRequestError",xTe=(t,e)=>{const n=t instanceof Error?t:new Error(e);return n[izt]=!0,n},rzt=t=>!!t&&typeof t=="object"&&t[izt]===!0,Lde=xd("[NetworkMetrics]"),ETe=()=>{var t;return!(jn==null||(t=jn.performance)===null||t===void 0)&&t.now?jn.performance.now():Date.now()},b$o={"http:":80,"https:":443},S$o=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),szt=(t,e)=>{var n;const o=String(e);return{method:String(t).toUpperCase(),url:((n=mS(o))===null||n===void 0?void 0:n.href)||o}},BTe=(t,e,n,o,i,r,s=!1)=>{try{var a,A;const c=i();if(!c)return;const l=n||void 0,u=ETe()-o,g=mS(e.url);if(g&&g.protocol!=="http:"&&g.protocol!=="https:")return;const h={url:g?.href||e.url,method:e.method},d=pp(c.name)?c.name(h):Za(c.name)?c.name:"http.client.request.duration";if(!d)return;const m=s&&!l?void 0:((f,_)=>f?400>f?void 0:String(f):_?.name||"_OTHER")(l,r),p=Zt(Zt(Zt(Zt(Zt({},(f=>{const _=S$o.has(f)?f:"_OTHER";return Zt({"http.request.method":_},_==="_OTHER"&&f!==_?{"http.request.method_original":f}:{})})(h.method)),g?(f=>{return{"server.address":f.hostname.startsWith("[")&&f.hostname.endsWith("]")?f.hostname.slice(1,-1):f.hostname,"server.port":Number(f.port)||b$o[f.protocol],"url.scheme":f.protocol.slice(0,-1),"url.template":(_=f.pathname,_.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 _})(g):{}),l?{"http.response.status_code":l}:{}),m?{"error.type":m}:{}),(a=c.attributes)===null||a===void 0?void 0:a.call(c,h,{status:l,durationMs:u}));(A=t.metrics)===null||A===void 0||A.histogram(d,u,{unit:"ms",attributes:p})}catch(c){Lde.error("Failed to record network metric",c)}},azt=()=>{},Q$o=(t,e)=>pp(jn?.fetch)?LG(jn,"fetch",n=>function(...o){const i=ETe(),r=n.apply(this,o);if(!e())return r;try{var s,a,A;const[c,l]=o,u=szt((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(g=>(BTe(t,u,g?.status,i,e,void 0,!0),g),g=>{throw BTe(t,u,void 0,i,e,g),g})}catch(c){return Lde.error("Failed to observe fetch",c),r}}):azt,v$o=(t,e)=>{var n;const o=jn==null||(n=jn.XMLHttpRequest)===null||n===void 0?void 0:n.prototype;if(!o)return azt;const i=new WeakMap,r=LG(o,"open",a=>function(...A){try{aKt.has(this)||i.set(this,szt(A[0],A[1]))}catch(c){Lde.error("Failed to observe XHR open",c)}return a.apply(this,A)}),s=LG(o,"send",a=>function(...A){let c;try{const l=i.get(this);if(l&&e()){const u=ETe();c=()=>{this.removeEventListener("loadend",c),BTe(t,l,this.status,u,e)},Zc(this,"loadend",c)}}catch(l){Lde.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()}},Azt=new WeakMap,w$o={maxStringLength:2048,truncationSuffix:"..."};function czt(t){if(t)return t===!0?{intent:!0,model:!0}:{intent:t.intent!==!1,model:t.model!==!1}}function AP(t,e){return{}.hasOwnProperty.call(t,e)}function bTe(t,e){const n=Object.create(t);return e&&Object.defineProperty(n,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:e}),n}function lzt(t,e,n=!1){if(!Za(t))return;const o=t.trim();return o?(n?ljo(o,w$o):o).slice(0,e):void 0}function uzt(t){try{return va(t)&&t.isError===!0}catch{return!1}}const Hde={featureFlags:class extends f$o{constructor(t){const e=new _$o(t.config,t.il());super(e),this.name="featureFlags",this._instance=t,this.gv=e}get Ad(){return this._instance.persistence}updateConfig(t,e){this.gv.update(t,e),this.Fd()}}},P$o={sessionRecording:class{get Mr(){return this._instance.config}get Il(){return this._instance.persistence}get started(){var t;return!!(!((t=this.mv)===null||t===void 0)&&t.isStarted)}get status(){var t,e;return this.yv==="awaiting_config"||this.yv==="missing_config"?this.yv:(t=(e=this.mv)===null||e===void 0?void 0:e.status)!==null&&t!==void 0?t:this.yv}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.yv=fTe,this.bv=void 0,this._v=!1,this.Je=(()=>{var e,n;if(!qo?.visibilityState||qo.visibilityState==="visible")return!0;const o=jn==null||(e=jn.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;qo?.visibilityState==="visible"&&(this.Je=!0,(e=this.mv)===null||e===void 0||(n=e.setDocumentWasEverVisible)===null||n===void 0||n.call(e,!0))},!this._instance.sessionManager)throw _S.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"');qo?.addEventListener&&Zc(qo,"visibilitychange",this.sn)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:t=!1}={}){var e;this._v=!0,qo==null||(e=qo.removeEventListener)===null||e===void 0||e.call(qo,"visibilitychange",this.sn),t?this.wv(!0):this.stopRecording()}get Sv(){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 jn&&e&&n&&!o}startIfEnabledOrStop(t){var e;if(this._v||this.Sv&&(!((e=this.mv)===null||e===void 0)&&e.isStarted))return;const n=!Eo(Object.assign)&&!Eo(Array.from);this.Sv&&n?(this.xv(t),_S.info("starting")):(this.yv=fTe,this.stopRecording())}xv(t){var e,n;if(this.Sv)if(this.yv!=="awaiting_config"&&this.yv!=="missing_config"&&(this.yv=YKt),(Kr==null||(e=Kr.__PosthogExtensions__)===null||e===void 0||(e=e.rrweb)===null||e===void 0?void 0:e.record)&&((n=Kr.__PosthogExtensions__)===null||n===void 0?void 0:n.initSessionRecording))this.$v(t);else{var o,i;const r=this._instance.sessionManager;(o=Kr.__PosthogExtensions__)===null||o===void 0||(i=o.loadExternalDependency)===null||i===void 0||i.call(o,this._instance,this.Cv,s=>{if(!this._v&&this.Sv&&this._instance.sessionManager===r)return s?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),_S.error("could not load recorder",s)):void this.$v(t);this.yv="disabled"})}}stopRecording(){var t,e;(t=this.bv)===null||t===void 0||t.call(this),this.bv=void 0,(e=this.mv)===null||e===void 0||e.stop()}wv(t=!1){var e,n;(e=this.bv)===null||e===void 0||e.call(this),this.bv=void 0,(n=this.mv)===null||n===void 0||n.discard({discardProducerEvents:t})}Tv(){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")}Iv(t,e){if(Hs(t))return null;const n=gh(t)?t:parseFloat(t);return typeof(o=n)!="number"||!Number.isFinite(o)||0>o||o>1?(_S.warn(`${e} must be between 0 and 1. Ignoring invalid value:`,t),null):n;var o}Mv(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.Iv((r=this.Mr.session_recording)===null||r===void 0?void 0:r.sampleRate,"session_recording.sampleRate"),A=this.Iv(s?.sampleRate,"remote config sampleRate"),c=a??A;Hs(c)&&this.Tv();const l=s?.minimumDurationMilliseconds;o.register({[B$]:Zt(Zt({cache_timestamp:Date.now(),enabled:!!s},s),{},{networkPayloadCapture:Zt({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.bv)===null||e===void 0||e.call(this),this.bv=(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.Mv(e),void this.wv()):(this.Mv(e),void this.startIfEnabledOrStop()):(this.yv==="awaiting_config"&&(this.yv="missing_config",this._instance.register_for_session({[wRe]:!0}),_S.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e="log"){var n;!((n=this.mv)===null||n===void 0)&&n.log?this.mv.log(t,e):_S.warn("log called before recorder was ready")}get Cv(){var t,e;const n=(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0?void 0:t.get_property(B$);return(n==null||(e=n.scriptConfig)===null||e===void 0?void 0:e.script)||"lazy-recorder"}Ev(){const t=this._instance.get_property(B$);if(!t)return!1;let e;try{e=typeof t=="object"?t:JSON.parse(t)}catch(n){return _S.warn("persisted remote config for session recording is invalid and will be ignored",n),!1}return!Hs(e.cache_timestamp)&&36e5>=Date.now()-e.cache_timestamp}$v(t){var e,n,o;if(!this._v&&this.Sv&&this._instance.sessionManager){if(!(!((e=Kr.__PosthogExtensions__)===null||e===void 0)&&e.initSessionRecording))return _S.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[vRe]:!0});var i;if(this.mv||(this.mv=(i=Kr.__PosthogExtensions__)===null||i===void 0?void 0:i.initSessionRecording(this._instance,this.Je),this.mv._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Ev())return this.yv==="missing_config"||this.yv==="awaiting_config"?void 0:(this.yv="awaiting_config",_S.info("persisted remote config is stale, requesting fresh config before starting"),void new $Ut(this._instance).load());this.yv=YKt,(n=(o=this.mv).setDocumentWasEverVisible)===null||n===void 0||n.call(o,this.Je),this.mv.start(t)}else this.yv=fTe}onRRwebEmit(t){var e,n;(e=this.mv)===null||e===void 0||(n=e.onRRwebEmit)===null||n===void 0||n.call(e,t)}overrideLinkedFlag(){var t,e;this.mv||(e=this.Il)===null||e===void 0||e.register({$replay_override_linked_flag:!0}),(t=this.mv)===null||t===void 0||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.mv||(e=this.Il)===null||e===void 0||e.register({$replay_override_sampling:!0}),(t=this.mv)===null||t===void 0||t.overrideSampling()}overrideTrigger(t){var e,n;this.mv||(n=this.Il)===null||n===void 0||n.register({[t==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(e=this.mv)===null||e===void 0||e.overrideTrigger(t)}get sdkDebugProperties(){var t;const e={};for(const o of s$o){var n;const i=(n=this._instance.sessionPersistence)===null||n===void 0?void 0:n.get_property(o);Eo(i)||(e[o]=i)}return Zt(Zt({},e),((t=this.mv)===null||t===void 0?void 0:t.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(t,e){var n;return!!(!((n=this.mv)===null||n===void 0)&&n.tryAddCustomEvent(t,e))}flushBeforeIdentityReset(){var t,e;(t=this.mv)===null||t===void 0||(e=t.flushBeforeIdentityReset)===null||e===void 0||e.call(t)}}},M$o={autocapture:class extends t$o{constructor(t){super(new n$o(t)),this.instance=t}},historyAutocapture:class{constructor(t){this.Pv=!1,this._instance=t,this.Rv=this.Av()}initialize(){this.startIfEnabled()}get isEnabled(){const t=this.Fv();return!!(t.path||t.search||this.Ov(t))}startIfEnabled(){this.isEnabled&&(li.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.Rv=this.Av(),this.startIfEnabled()}stop(){this.Dv&&this.Dv(),this.Dv=void 0,this.Lv&&this.Lv(),this.Lv=void 0,li.info("History API monitoring stopped")}monitorHistoryChanges(){jn&&jn.history&&(this.Nv("pushState"),this.Nv("replaceState"),this.qv(),this.Ov()&&this.jv())}Nv(t){var e;if(!jn||!((e=jn.history[t])===null||e===void 0)&&e.__posthog_wrapped__)return;const n=this;LG(jn.history,t,o=>function(i,r,s){var a;n.Bv(s)&&n.zv(),o.call(this,i,r,s),n.Hv(t,!n.Pv&&(jn==null||(a=jn.event)===null||a===void 0?void 0:a.type)!=="popstate")})}Av(){const t=jn?.location;if(t?.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}Fv(){const t=this._instance.config.capture_pageview;return t==="history_change"?{path:!0}:va(t)?t:{}}Ov(t=this.Fv()){return!!t.hash&&!this._instance.config.disable_capture_url_hashes}Uv(t){const e=this.Fv(),n=this.Rv;return!(!n||!(e.path&&t.pathname!==n.pathname||e.search&&t.search!==n.search||this.Ov(e)&&t.hash!==n.hash))}Hv(t,e=!1){try{e||this.zv();const n=this.Av();if(!n)return;if(this.Uv(n)){const o=()=>this._instance.capture(MRe,{navigation_type:t});e?(this.Wv=o,Promise.resolve().then(()=>this.zv())):o()}this.Rv=n}catch(n){li.error(`Error capturing ${t} pageview`,n)}}Bv(t){var e,n;return!(Hs(t)||!jn)&&((e=mS(String(t)))===null||e===void 0?void 0:e.href)!==((n=jn.location)===null||n===void 0?void 0:n.href)}zv(){const t=this.Wv;if(t){this.Wv=void 0,this.Pv=!0;try{t()}catch(e){li.error("Error capturing deferred pageview",e)}finally{this.Pv=!1}this.Rv=this.Av()}}qv(){if(this.Dv)return;const t=()=>{this.Hv("popstate")};Zc(jn,"popstate",t),this.Dv=()=>{jn&&jn.removeEventListener("popstate",t)}}jv(){if(this.Lv)return;const t=()=>{this.Hv("hashchange")};Zc(jn,"hashchange",t),this.Lv=()=>{jn&&jn.removeEventListener("hashchange",t)}}},heatmaps:class{get Mr(){return this.instance.config}constructor(t){var e;this.Vv=!1,this.ko=!1,this.Gv=null,this.instance=t,this.Vv=!!(!((e=this.instance.persistence)===null||e===void 0)&&e.props[_Re]),this.rageclicks=new FKt(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let t=5e3;return va(this.Mr.capture_heatmaps)&&this.Mr.capture_heatmaps.flush_interval_milliseconds&&(t=this.Mr.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return Hs(this.Mr.capture_heatmaps)?Hs(this.Mr.enable_heatmaps)?this.Vv:this.Mr.enable_heatmaps:this.Mr.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.ko)return;a$o.info("starting..."),this.Qv(),this.sn()}else{var t;clearInterval((t=this.Gv)!==null&&t!==void 0?t:void 0),this.Zv(),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({[_Re]:n}),this.Vv=n,this.startIfEnabled()}getAndClearBuffer(){const t=this.Rt;return this.Rt=void 0,t}Jv(t){_Te(t.originalEvent)&&this.Ir(t.originalEvent,"deadclick")}sn(){this.Gv&&clearInterval(this.Gv),this.Gv=qo?.visibilityState==="visible"?setInterval(this.fl.bind(this),this.flushIntervalMilliseconds):null}Qv(){jn&&qo&&(this.Kv=this.fl.bind(this),Zc(jn,Ede,this.Kv),this.Xv=t=>this.Ir(t||jn?.event),Zc(qo,"click",this.Xv,{capture:!0}),this.Yv=t=>this.tf(t||jn?.event),Zc(qo,"mousemove",this.Yv,{capture:!0}),this.ef=new PUt(this.instance,aqo,this.Jv.bind(this)),this.ef.startIfEnabledOrStop(),this.if=this.sn.bind(this),Zc(qo,x$,this.if),this.ko=!0)}Zv(){var t;jn&&qo&&(this.Kv&&jn.removeEventListener(Ede,this.Kv),this.Xv&&qo.removeEventListener("click",this.Xv,{capture:!0}),this.Yv&&qo.removeEventListener("mousemove",this.Yv,{capture:!0}),this.if&&qo.removeEventListener(x$,this.if),clearTimeout(this.nf),(t=this.ef)===null||t===void 0||t.stop(),this.ko=!1)}sf(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&&t9(c)&&!BI(c,"body");){if(c===A)return!1;let h;try{var l,u,g;h=(l=(u=(g=c.ownerDocument)===null||g===void 0?void 0:g.defaultView)!==null&&u!==void 0?u:jn)===null||l===void 0?void 0:l.getComputedStyle(c).position}catch{return!1}if(jr(a,h))return!0;c=pUt(c)}return!1})(w$(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(gUt(t.target)||!_Te(t))return;const o=this.sf(t,e);!((n=this.rageclicks)===null||n===void 0)&&n.isRageClick(t.clientX,t.clientY,new Date().getTime())&&yUt(w$(t),this.instance.config.rageclick)&&this.Qs(Zt(Zt({},o),{},{type:"rageclick"})),this.Qs(o)}tf(t){!gUt(t.target)&&_Te(t)&&(clearTimeout(this.nf),this.nf=setTimeout(()=>{this.Qs(this.sf(t,"mousemove"))},500))}Qs(t){if(!jn)return;const e=this.Mr.disable_capture_url_hashes?eP(jn.location.href):jn.location.href,n=this.Mr.custom_personal_data_properties,o=this.Mr.mask_personal_data_properties?[...DG,...n||[]]:[],i=D$(e,o,N$);this.Rt=this.Rt||{},this.Rt[i]||(this.Rt[i]=[]),this.Rt[i].push(t)}fl(){this.Rt&&!Jx(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:PUt,webVitalsAutocapture:class{constructor(t){var e;this._instance=t,this.Vv=!1,this.ko=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.rf=()=>{clearTimeout(this.af),this.af=void 0,this.Rt.metrics.length!==0&&(this._instance.capture("$web_vitals",Zt({$current_url:this.Rt.url},this.Rt.metrics.reduce((n,o)=>Zt(Zt({},n),{},{[`$web_vitals_${o.name}_event`]:Zt({},o),[`$web_vitals_${o.name}_value`]:o.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.lf=n=>{var o;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},Hs(n?.name)||Hs(n?.value))return void jR.error("Invalid metric received",n);const i=typeof n.navigationURL=="string"?n.navigationURL:void 0,r=this.uf(i);if(Eo(r))return;const s=gh(n.navigationId)||typeof n.navigationId=="string"?`navigation:${n.navigationId}`:`url:${r}`;if(this.cf&&n.value>=this.cf)return void jR.error("Ignoring metric with value >= "+this.cf,n);this.Rt.navigationKey!==s&&(this.rf(),this.af=setTimeout(this.rf,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=Zt(Zt(Zt({},n),i?{navigationURL:r}:{}),{},{$current_url:r,timestamp:Date.now()});if(delete A.entries,va(n.attribution)&&this.attributionMetrics.indexOf(n.name)>-1){const c={};for(const l of r$o){const u=l==="url"&&typeof n.attribution[l]=="string"?this.uf(n.attribution[l]):n.attribution[l];Eo(u)||(c[l]=u)}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.rf()},this.hf=()=>{if(this.ko)return;let n,o,i,r,s=!1;const a=Kr.__PosthogExtensions__,A=a?.postHogWebVitalsCallbacksByFlavor,c=A?.[this.df]||(this.df==="web-vitals"&&Eo(A)?a?.postHogWebVitalsCallbacks:void 0);if(!Eo(c)){const g=c.withoutAttribution,h=this.attributionMetrics;s=!Eo(g),n=h.indexOf("LCP")>-1?c.onLCP:g?.onLCP||c.onLCP,o=h.indexOf("CLS")>-1?c.onCLS:g?.onCLS||c.onCLS,i=h.indexOf("FCP")>-1?c.onFCP:g?.onFCP||c.onFCP,r=h.indexOf("INP")>-1?c.onINP:g?.onINP||c.onINP}if(!(n&&o&&i&&r))return void jR.error("web vitals callbacks not loaded - not starting");const l={reportSoftNavs:this.useSoftNavs},u=s&&this.attributionMetrics.indexOf("INP")>-1?Zt(Zt({},l),{},{includeProcessedEventEntries:!1}):l;this.allowedMetrics.indexOf("LCP")>-1&&n(this.lf.bind(this),l),this.allowedMetrics.indexOf("CLS")>-1&&o(this.lf.bind(this),l),this.allowedMetrics.indexOf("FCP")>-1&&i(this.lf.bind(this),l),this.allowedMetrics.indexOf("INP")>-1&&r(this.lf.bind(this),u),this.ko=!0},this.Vv=!!(!((e=this._instance.persistence)===null||e===void 0)&&e.props[yRe]),this.startIfEnabled()}get vf(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e;const n=va(this.vf)?(t=this.vf)===null||t===void 0?void 0:t.web_vitals_allowed_metrics:void 0;return Hs(n)?((e=this._instance.persistence)===null||e===void 0?void 0:e.props.$web_vitals_allowed_metrics)||GKt:n}get flushToCaptureTimeoutMs(){return(va(this.vf)?this.vf.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const t=va(this.vf)?this.vf.web_vitals_attribution:void 0;return u2(t)?t?GKt:[]:qr(t)?t:i$o}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const t=va(this.vf)?this.vf.__preview_web_vitals_soft_navs:void 0;return t!=null&&t}get cf(){const t=va(this.vf)&&gh(this.vf.__web_vitals_max_value)?this.vf.__web_vitals_max_value:OKt;return t>0&&6e4>=t?OKt:t}get isEnabled(){const t=tg?.protocol;if(t!=="http:"&&t!=="https:")return jR.info("Web Vitals are disabled on non-http/https protocols"),!1;const e=va(this.vf)?this.vf.web_vitals:u2(this.vf)?this.vf:void 0;return u2(e)?e:this.Vv}startIfEnabled(){this.isEnabled&&!this.ko&&(jR.info("enabled, starting..."),this.zo(this.hf))}onRemoteConfig(t){if(!t.ok)return;const e=t.config;if(!("capturePerformance"in e))return;const n=va(e.capturePerformance)&&!!e.capturePerformance.web_vitals,o=va(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[yRe]:n}),this._instance.persistence.register({[FYt]:o})),this.Vv=n,this.startIfEnabled()}get df(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}zo(t){var e;const n=Kr.__PosthogExtensions__,o=this.df,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?jR.error("failed to load script",r):t()})}uf(t){const e=t||jn?.location.href;if(!e)return void jR.error("Could not determine current URL");const n=this._instance.config.disable_capture_url_hashes?eP(e):e,o=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...DG,...o||[]]:[];return D$(n,i,N$)}}},D$o={exceptionObserver:class{constructor(t){var e;this.hf=()=>{var n;if(!jn||!this.isEnabled||!(!((n=Kr.__PosthogExtensions__)===null||n===void 0)&&n.errorWrappingFunctions))return;const o=Kr.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Kr.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=Kr.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.ff&&this.Mr.capture_unhandled_errors&&(this.ff=o(this.captureException.bind(this))),!this.pf&&this.Mr.capture_unhandled_rejections&&(this.pf=i(this.captureException.bind(this))),!this.gf&&this.Mr.capture_console_errors&&(this.gf=r(this.captureException.bind(this)))}catch(s){U$.error("failed to start",s),this.mf()}},this._instance=t,this.yf=!!(!((e=this._instance.persistence)===null||e===void 0)&&e.props[IRe]),this.wt=new ZJo(Zt(Zt({},(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:U$})),this.Mr=this.bf(),this.startIfEnabledOrStop()}bf(){const t=this._instance.config.capture_exceptions;let e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return va(t)?e=Zt(Zt({},e),t):(Eo(t)?this.yf:t)&&(e=Zt(Zt({},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?(U$.info("enabled"),this.mf(),this.zo(this.hf)):this.mf()}zo(t){var e,n,o;!((e=Kr.__PosthogExtensions__)===null||e===void 0)&&e.errorWrappingFunctions?t():(n=Kr.__PosthogExtensions__)===null||n===void 0||(o=n.loadExternalDependency)===null||o===void 0||o.call(n,this._instance,"exception-autocapture",i=>{if(i)return U$.error("failed to load script",i);t()})}mf(){var t,e,n;(t=this.ff)===null||t===void 0||t.call(this),this.ff=void 0,(e=this.pf)===null||e===void 0||e.call(this),this.pf=void 0,(n=this.gf)===null||n===void 0||n.call(this),this.gf=void 0}onRemoteConfig(t){if(!t.ok)return;const e=t.config;"autocaptureExceptions"in e&&(this.yf=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[IRe]:this.yf}),this.Mr=this.bf(),this.startIfEnabledOrStop())}onConfigChange(){this.Mr=this.bf()}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 U$.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._f=[],this.wf=new uWo([new SWo,new TWo,new vWo,new QWo,new NWo,new DWo,new PWo,new RWo],(function(o,...i){return(r,s=0)=>{const a=[],A=r.split(`
|
|
1069
1069
|
`),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 m=eYt.test(d)?d.replace(eYt,"$1"):d;if(!m.match(/\S*Error: /)){for(const p of i){const f=p(m,o);if(f){a.push(f);const _=xWo(a);if(_){for(let I=l.length-1;I>=0;I--){const C=l[I];if(_.start>=C.start+C.length)break;l.pop()}l.push(_)}break}}if(BWo(a,l)>=50)break}}const u=[...l].sort((h,d)=>d.start-h.start),g=u[u.length-1];if(g){const h=tYt(a,g);a.splice(g.start-h,h);for(const d of u)d.start-=h}for(const h of u)EWo(a,h);return l.some(h=>h.start===0&&a.length===h.length)&&(function(h){const d=h.map(p=>`${p.function}|${p.filename}|${p.lineno}|${p.colno}|${p.module}`);let m=0;for(let p=1;d.length>p;p++)bWo(d,p,m)&&(m=p);h.push(...h.splice(0,m))})(a),(function(h){if(!h.length)return[];const d=Array.from(h);return d.reverse(),d.slice(0,50).map(m=>{return Zt(Zt({},m),{},{filename:m.filename||(p=d,p[p.length-1]||{}).filename,function:m.function||"?"});var p})})(a)}})("web:javascript",_Wo,yWo)),this._instance=t,this._f=(e=(n=this._instance.persistence)===null||n===void 0?void 0:n.get_property("$error_tracking_suppression_rules"))!==null&&e!==void 0?e:[],this.kf=mde(this.Sf()),this.xf=new FWo(this.kf)}onConfigChange(){this.kf=mde(this.Sf()),this.xf.setConfig(this.kf)}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._f=r,this._instance.persistence&&this._instance.persistence.register({[TYt]:this._f,[CRe]:s})}get $f(){var t;const e=!!this._instance.get_property(CRe),n=this._instance.config.error_tracking.captureExtensionExceptions;return(t=n??e)!==null&&t!==void 0&&t}buildProperties(t,e){return this.wf.buildFromUnknown(t,{syntheticException:e?.syntheticException,mechanism:{handled:e?.handled}})}addExceptionStep(t,e){if(this.kf.enabled)try{if(!Za(t)||t.trim().length===0)return void n9.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)=>kWo.has(a)?(r.push(a),s):(s[a]=i[a],s),{}),droppedKeys:r}})(this.Cf(e));o.length>0&&n9.warn("Ignoring reserved exception step fields",{droppedKeys:o}),this.xf.add(Zt({[dde]:t,[hde]:new Date().toISOString()},n))}catch(n){n9.error("Failed to add exception step. Ignoring breadcrumb.",n)}}sendExceptionEvent(t){try{const e=t.$exception_list;if(this.Tf(e)){if(this.If(e))return this.Mf("Exception dropped: matched a suppression rule"),void n9.info("Skipping exception capture because a suppression rule matched");if(!this.$f&&this.Ef(e))return this.Mf("Exception dropped: thrown by a browser extension"),void n9.info("Skipping exception capture because it was thrown by an extension");if(!this.$f&&this.Pf(e))return this.Mf("Exception dropped: thrown by an injected browser script"),void n9.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Rf(e))return this.Mf("Exception dropped: thrown by the PostHog SDK"),void n9.info("Skipping exception capture because it was thrown by the PostHog SDK")}const n=this.kf.enabled&&Hs(t.$exception_steps)?this.Af(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",fc:!0});return i&&this.xf.clear(),i}catch(i){return ezt(i)||n9.error("Failed to capture exception event. Dropping this exception.",i),void this.xf.clear()}}catch(e){return void(ezt(e)||n9.error("Failed to process exception event. Ignoring this exception.",e))}}Af(t){try{const e=this.xf.getAttachable();return e.length===0?t:Zt(Zt({},t),{},{$exception_steps:e})}catch(e){return n9.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}Mf(t){this.kf.enabled&&this.xf.add({[dde]:t,[hde]:new Date().toISOString()})}Cf(t){return va(t)?Zt({},t):{}}Sf(){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:{}}If(t){if(t.length===0)return!1;try{const e=t.reduce((n,{type:o,value:i})=>(Za(o)&&o.length>0&&n.$exception_types.push(o),Za(i)&&i.length>0&&n.$exception_values.push(i),n),{$exception_types:[],$exception_values:[]});return this._f.some(n=>{const o=n.values.map(i=>{const r=bKt[i.operator],s=e[i.key];if(!r||!s)return!1;const a=qr(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 n9.warn("Failed to evaluate suppression rules. Capturing the exception.",e),!1}}Ef(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&&C$o.some(i=>o.startsWith(i)));return n.length!==0&&(!n.every(({filename:o})=>!!o&&o.startsWith(yTe))||t.some(({type:o,value:i})=>o==="NoResponse"||Za(i)&&I$o.some(({value:r,exact:s})=>s?i===r:i.includes(r)))&&!e.some(({in_app:o,filename:i})=>o&&!i?.startsWith(yTe)))}Pf(t){return t.some(({value:e})=>Za(e)&&y$o.some(n=>e.includes(n)))}Rf(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}Tf(t){return!Hs(t)&&qr(t)}}},N$o=Zt({productTours:class{get Il(){return this._instance.persistence}constructor(t){this.Ff=null,this.Of=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({[ERe]:!!e.productTours}),!ITe(this._instance))return!this.Ff&&Hs((n=this.Il)===null||n===void 0?void 0:n.props.ph_product_tours)||Fde.info("product tours disabled; stopping and clearing cached tours"),(o=this.Ff)===null||o===void 0||o.stop(),this.Ff=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.Ff&&ITe(this._instance)&&this.zo(()=>this.Df())}zo(t){var e,n,o;!((e=Kr.__PosthogExtensions__)===null||e===void 0)&&e.generateProductTours?t():(n=Kr.__PosthogExtensions__)===null||n===void 0||(o=n.loadExternalDependency)===null||o===void 0||o.call(n,this._instance,"product-tours",i=>{i?Fde.error("Could not load product tours script",i):t()})}Df(){var t;!this.Ff&&(!((t=Kr.__PosthogExtensions__)===null||t===void 0)&&t.generateProductTours)&&(this.Ff=Kr.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e=!1){if(qr(this.Of)&&!e)return void t(this.Of,{isLoaded:!0});const n=this.Il;if(n){const o=n.props[BRe];if(qr(o)&&!e)return this.Of=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(!ITe(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||Fde.warn(s):Fde.error(s),void t([],{isLoaded:!1,error:s})}const r=qr(o.json.product_tours)?o.json.product_tours:[];this.Of=r,n&&n.register({[BRe]:r}),t(r,{isLoaded:!0})}})}getActiveProductTours(t){Hs(this.Ff)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Ff.getActiveProductTours(t)}showProductTour(t){var e;(e=this.Ff)===null||e===void 0||e.showTourById(t)}previewTour(t){this.Ff?this.Ff.previewTour(t):this.zo(()=>{var e;this.Df(),(e=this.Ff)===null||e===void 0||e.previewTour(t)})}dismissProductTour(){var t;(t=this.Ff)===null||t===void 0||t.dismissTour("user_clicked_skip")}nextStep(){var t;(t=this.Ff)===null||t===void 0||t.nextStep()}previousStep(){var t;(t=this.Ff)===null||t===void 0||t.previousStep()}clearCache(){var t;this.Of=null,(t=this.Il)===null||t===void 0||t.unregister("ph_product_tours")}resetTour(t){var e;(e=this.Ff)===null||e===void 0||e.resetTour(t)}resetAllTours(){var t;(t=this.Ff)===null||t===void 0||t.resetAllTours()}cancelPendingTour(t){var e;(e=this.Ff)===null||e===void 0||e.cancelPendingTour(t)}}},Hde),R$o={siteApps:class{constructor(t){this._instance=t,this.Lf=0,this.Nf=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}qf(t,e){if(!e)return;const n=this.globalsForEvent(e);this.Nf.push(n),this.Nf.length>1e3&&(this.Nf=this.Nf.slice(10))}get siteAppLoaders(){var t;return(t=Kr._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.qf.bind(this));this.jf=()=>{t(),this.Nf=[],this.jf=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:u,$set:g}=t;return{event:Zt(Zt({},uYt(t,A$o)),{},{properties:Zt(Zt(Zt({},t.properties),g?{$set:Zt(Zt({},(e=(n=t.properties)===null||n===void 0?void 0:n.$set)!==null&&e!==void 0?e:{}),g)}:{}),u?{$set_once:Zt(Zt({},(o=(i=t.properties)===null||i===void 0?void 0:i.$set_once)!==null&&o!==void 0?o:{}),u)}:{}),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}}Bf(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)||(T7.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)||(T7.error("prepare_external_dependency_script returned null"),null):t}zf(){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=qo?.defaultView,c=A==null||(t=A.Node)===null||t===void 0?void 0:t.prototype;if(!A||!c)return()=>{};if(this.Lf++,this.Hf)return this.Uf();const l=[],u=this,g=new WeakSet,h=(p,f,_)=>{if(!p?.[f])return;const I=p[f];p[f]=_(I),l.push(()=>{p[f]=I})},d=p=>{if(g.has(p))return p;const f=u.Bf(p);return f&&g.add(f),f},m=p=>p.map(f=>typeof f=="string"?f:d(f)).filter(f=>!yd(f));return h(c,"appendChild",p=>function(f){const _=d(f);return _?p.call(this,_):f}),h(c,"insertBefore",p=>function(f,_){const I=d(f);return I?p.call(this,I,_):f}),h(c,"replaceChild",p=>function(f,_){const I=d(f);return I?p.call(this,I,_):_}),[(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(p=>{h(p,"append",f=>function(..._){return f.apply(this,m(_))}),h(p,"prepend",f=>function(..._){return f.apply(this,m(_))})}),[(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(p=>{h(p,"before",f=>function(..._){return f.apply(this,m(_))}),h(p,"after",f=>function(..._){return f.apply(this,m(_))}),h(p,"replaceWith",f=>function(..._){const I=m(_);return _.length&&!I.length?void 0:f.apply(this,I)})}),h((a=A.Element)===null||a===void 0?void 0:a.prototype,"insertAdjacentElement",p=>function(f,_){const I=d(_);return I?p.call(this,f,I):null}),this.Hf=()=>{l.forEach(p=>p()),this.Hf=void 0},this.Uf()}Uf(){let t=!1;return()=>{var e;t||(t=!0,this.Lf--,this.Lf===0&&((e=this.Hf)===null||e===void 0||e.call(this)))}}Wf(t,e=!0){const n=this.zf();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.Nf.length&&(T7.info(`Processing ${this.Nf.length} events for site app with id ${t.id}`),this.Nf.forEach(s=>this.Wf(()=>{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.jf)===null||r===void 0||r.call(this))};let o=!1;const i=r=>{e.errored=!r,e.loaded=!0,T7.info(`Site app with id ${t.id} ${r?"loaded":"errored"}`),o&&n()};try{const{processEvent:r}=this.Wf(s=>t.init({posthog:this._instance,callback(a){s(),i(a)}}),!1);r&&(e.processEvent=r),o=!0}catch(r){T7.error(UKt+t.id,r),i(!1)}if(o&&e.loaded)try{n()}catch(r){T7.error(`Error while processing buffered events PostHog app with config id ${t.id}`,r),e.errored=!0}}Vf(){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)}Gf(t){if(Object.keys(this.apps).length===0)return;const e=this.globalsForEvent(t);for(const n of Object.values(this.apps))try{this.Wf(()=>{var o;return(o=n.processEvent)===null||o===void 0?void 0:o.call(n,e)})}catch(o){T7.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.Vf(),void this._instance.on("eventCaptured",a=>this.Gf(a))):void T7.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((n=this.jf)===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;Kr[`__$$ph_site_app_${a}`]=this._instance,(r=Kr.__PosthogExtensions__)===null||r===void 0||(s=r.loadSiteApp)===null||s===void 0||s.call(r,this._instance,A,c=>{if(c)return T7.error(UKt+a,c)})}else T7.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},T$o={tracingHeaders:class{constructor(t){this._instance=t,this.Qf=void 0,this.Zf=void 0,this.Jf=void 0,this.hf=()=>{const e=this.Kf();var n,o;e?(Eo(this.Qf)&&(this.Qf=(n=Kr.__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.Zf)&&(this.Zf=(o=Kr.__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.mf()}}initialize(){this.startIfEnabledOrStop()}zo(t){var e,n,o;!((e=Kr.__PosthogExtensions__)===null||e===void 0)&&e.tracingHeadersPatchFns?t():(n=Kr.__PosthogExtensions__)===null||n===void 0||(o=n.loadExternalDependency)===null||o===void 0||o.call(n,this._instance,"tracing-headers",i=>{if(i)return o$o.error("failed to load script",i);t()})}Xf(){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}Kf(){const t=this.Xf();return qr(t)?(qr(this.Jf)?this.Jf.splice(0,this.Jf.length,...t):this.Jf=[...t],t.length>0?this.Jf:void 0):(qr(this.Jf)&&this.Jf.splice(0),this.Jf=t||void 0,this.Jf)}mf(){var t,e;(t=this.Qf)===null||t===void 0||t.call(this),(e=this.Zf)===null||e===void 0||e.call(this),this.Qf=void 0,this.Zf=void 0}startIfEnabledOrStop(){this.Kf()?this.zo(this.hf):this.mf()}}},k$o=Zt({surveys:class extends c$o{constructor(t){var e;super(new h$o(t),(e=t,{get projectToken(){return e.config.token},kv:new d$o(e)})),this._instance=t}Gc(t,e){const n=e.query?L$(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})})}}},Hde),F$o={toolbar:class{constructor(t){this.instance=t}Yf(t){Kr.ph_toolbar_state=t}tp(){var t;return(t=Kr.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(NRe(this.instance.config)||!jn||!qo)return!1;t=(o=t)!==null&&o!==void 0?o:jn.location,n=(i=n)!==null&&i!==void 0?i:jn.history;try{if(!e){try{jn.localStorage.setItem("test","test"),jn.localStorage.removeItem("test")}catch{return!1}e=jn?.localStorage}const r=m$o||Qde(t.hash,"__posthog")||Qde(t.hash,"state");let s;const a=r?JGt(()=>JSON.parse(atob(decodeURIComponent(r))))||JGt(()=>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(VKt)||"{}"),s.source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token||(this.loadToolbar(s),0))}catch{return!1}}ep(t){const e=Kr.ph_load_toolbar||Kr.ph_load_editor;!Hs(e)&&pp(e)?e(t,this.instance):JKt.warn("No toolbar load function found")}loadToolbar(t){const e=!!qo?.getElementById("__POSTHOG_TOOLBAR__");if(!jn||e)return!1;const n=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,o=Zt(Zt({token:this.instance.config.token},t),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},n?{instrument:!1}:{});if(jn.localStorage.setItem(VKt,JSON.stringify(Zt(Zt({},o),{},{source:void 0}))),this.tp()===2)this.ep(o);else if(this.tp()===0){var i,r;this.Yf(1),(i=Kr.__PosthogExtensions__)===null||i===void 0||(r=i.loadExternalDependency)===null||r===void 0||r.call(i,this.instance,"toolbar",s=>{if(s)return JKt.error("[Toolbar] Failed to load",s),void this.Yf(0);this.Yf(2),this.ep(o)}),Zc(jn,"turbolinks:load",()=>{this.Yf(0),this.loadToolbar(o)})}return!0}np(t){return this.loadToolbar(t)}maybeLoadEditor(t=void 0,e=void 0,n=void 0){return this.maybeLoadToolbar(t,e,n)}}},L$o=Zt({experiments:class Ix{get Mr(){return this._instance.config}constructor(e){this._instance=e,this.getWebExperimentsAndEvaluateDisplayLogic=(n=!1)=>{this.getWebExperiments(o=>{Ix.sp("retrieved web experiments from the server"),this.rp=new Map,o.forEach(i=>{if(i.feature_flag_key){var r;this.rp&&(Ix.sp("setting flag key ",i.feature_flag_key," to web experiment ",i),(r=this.rp)===null||r===void 0||r.set(i.feature_flag_key,i));const s=this._instance.getFeatureFlag(i.feature_flag_key);Za(s)&&i.variants[s]&&this.op(i.name,s,i.variants[s].transforms)}else if(i.variants)for(const s in i.variants){const a=i.variants[s];Ix.ap(a,this._instance)&&this.op(i.name,s,a.transforms)}})},n)},this._instance.onFeatureFlags(n=>{this.onFeatureFlags(n)})}initialize(){}onFeatureFlags(e){if(this._is_bot())Ix.sp(tzt);else if(!this.Mr.disable_web_experiments){if(Hs(this.rp))return this.rp=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Ix.sp("applying feature flags",e),e.forEach(n=>{var o;if(this.rp&&(!((o=this.rp)===null||o===void 0)&&o.has(n))){var i;const r=this._instance.getFeatureFlag(n),s=(i=this.rp)===null||i===void 0?void 0:i.get(n);r&&s?.variants[r]&&this.op(s.name,r,s.variants[r].transforms)}})}}previewWebExperiment(){const e=Ix.getWindowLocation();if(e?.search){const n=MG(e?.search,"__experiment_id"),o=MG(e?.search,"__experiment_variant");n&&o&&(Ix.sp(`previewing web experiments ${n} && ${o}`),this.getWebExperiments(i=>{this.lp(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||[])})}lp(e,n,o){const i=o.filter(r=>r.id===e);i&&i.length>0&&(Ix.sp(`Previewing web experiment [${i[0].name}] with variant [${n}]`),this.op(i[0].name,n,i[0].variants[n].transforms))}static ap(e,n){return!Hs(e.conditions)&&Ix.up(e,n)&&Ix.cp(e)}static up(e,n){var o;if(Hs(e.conditions)||Hs((o=e.conditions)===null||o===void 0?void 0:o.url))return!0;const i=Ix.getWindowLocation();if(i){var r,s,a;const A=uUt(n,i.href);return!(!((r=e.conditions)===null||r===void 0)&&r.url)||x$o[(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 jn?.location}static cp(e){var n;if(Hs(e.conditions)||Hs((n=e.conditions)===null||n===void 0?void 0:n.utm))return!0;const o=HUt();if(o.utm_source){var i,r,s,a,A,c,l,u;const g=!(!((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,m=!(!((l=e.conditions)===null||l===void 0||(l=l.utm)===null||l===void 0)&&l.utm_term)||((u=e.conditions)===null||u===void 0||(u=u.utm)===null||u===void 0?void 0:u.utm_term)==o.utm_term;return g&&d&&m&&h}return!1}static sp(e,...n){li.info(`[WebExperiments] ${e}`,n)}op(e,n,o){this._is_bot()?Ix.sp(tzt):n!=="control"?o.forEach(i=>{if(i.selector){var r;Ix.sp(`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)})}}):Ix.sp("Control variants leave the page unmodified.")}_is_bot(){return I_&&this._instance?xKt(I_,this.Mr.custom_blocked_useragents):void 0}}},Hde),H$o={conversations:class{constructor(t){this._instance=t,this.hp=void 0,this._conversationsManager=null,this.dp=!1,this.ne=null,this.vp=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(this._instance.config.disable_conversations||(this.fp=t.ok,!t.ok))return;const e=t.config.conversations;Hs(e)||(u2(e)?this.hp=e:(this.hp=e.enabled,this.ne=e),this.loadIfEnabled())}reset(){var t;(t=this._conversationsManager)===null||t===void 0||t.reset(),this._conversationsManager=null,this.hp=void 0,this.ne=null,this.fp=void 0,this.vp=!1}loadIfEnabled(){if(this._conversationsManager||this.dp||this._instance.config.disable_conversations||NRe(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;const t=Kr?.__PosthogExtensions__;if(t&&!Eo(this.hp)&&this.hp)if(this.ne&&this.ne.token){this.dp=!0;try{const e=t.initConversations;if(e)return this.pp(e),void(this.dp=!1);const n=t.loadExternalDependency;if(!n)return void this.gp(PRe);n(this._instance,"conversations",o=>{o||!t.initConversations?this.gp("Could not load conversations script",o):this.pp(t.initConversations),this.dp=!1})}catch(e){this.gp("Error initializing conversations",e),this.dp=!1}}else B4.error("Conversations enabled but missing token in remote config.")}pp(t){if(this.ne)try{this._conversationsManager=t(this.ne,this._instance),this.vp=!1,B4.info("Conversations loaded successfully")}catch(e){this.gp("Error completing conversations initialization",e)}else B4.error("Cannot complete initialization: remote config is null")}gp(t,e){B4.error(t,e),this._conversationsManager=null,this.dp=!1,this.vp=!0}show(){this._conversationsManager?this._conversationsManager.show():B4.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.hp===!0&&!yd(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":NRe(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":this.fp===!1?"remote_config_failed":Eo(this.hp)?this.fp?"disabled_in_project":"remote_config_pending":this.hp?Hs(this.ne)||!this.ne.token?"missing_token":Kr?.__PosthogExtensions__?this.dp?"initializing":this.vp?"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 ng(function*(){return o._conversationsManager?o._conversationsManager.sendMessage(t,e,n):(B4.warn($R),null)})()}getMessages(t,e){var n=this;return ng(function*(){return n._conversationsManager?n._conversationsManager.getMessages(t,e):(B4.warn($R),null)})()}markAsRead(t){var e=this;return ng(function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(B4.warn($R),null)})()}getTickets(t){var e=this;return ng(function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(B4.warn($R),null)})()}requestRestoreLink(t){var e=this;return ng(function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(B4.warn($R),null)})()}restoreFromToken(t){var e=this;return ng(function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(B4.warn($R),null)})()}restoreFromUrlToken(){var t=this;return ng(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(B4.warn($R),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}xc(){var t;(t=this._conversationsManager)===null||t===void 0||t.setIdentity()}$c(){var t;(t=this._conversationsManager)===null||t===void 0||t.clearIdentity()}}},O$o={logs:class{constructor(t){var e;this._instance=t,this.name="logs",this.mp=!1,this.yp=!1,this.bp=!1,this.A=xd("[logs]"),this._p=Zt(Zt({},this.A),{},{error:(...n)=>{n.some(rzt)||this.A.error(...n)}}),this.ol=[],this.wp=[],this.kd=0,this.To=!1,this.kp=[],this.Sp=[],this.xp=!1,this.$p=!1,this.Cp=()=>{var n,o;this.To||(this.kd=0,(n=this.Tp)===null||n===void 0||n.onReconnect(),(o=this.Ip)===null||o===void 0||o.onReconnect())},this._instance&&(!((e=this._instance.config.logs)===null||e===void 0)&&e.captureConsoleLogs)&&(this.mp=!0),jn&&Zc(jn,"online",this.Cp)}Mp(t,e,n,o){var i;const r=nzt((i=this._instance)===null||i===void 0||(i=i.config)===null||i===void 0?void 0:i.logs,n);return[new Ijo(this.Ep(t,e),r,this._p,()=>this.Pp(),s=>s(),void 0,o),r]}Rp(){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.Tp&&this.Ap===e||((n=this.Tp)===null||n===void 0||n.reset(),this.Ap=e,[this.Tp,this.Fp]=this.Mp(()=>this.ol,o=>{this.ol=o})),this.Tp}Op(){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.Ip&&this.Dp===e||((n=this.Ip)===null||n===void 0||n.reset(),this.Dp=e,[this.Ip,this.Lp]=this.Mp(()=>this.wp,o=>{this.wp=o},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},ozt)),this.Ip}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.mp=!0),(this.mp||this.Np()&&this.qp())&&this.jp();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.Bp(),(t=this.Eo)===null||t===void 0||t.dispose(),this.Eo=void 0,this.bo=void 0,this.bp=!1,jn?.removeEventListener("online",this.Cp),(e=this.zp)===null||e===void 0||e.call(this),this.zp=void 0,(n=this.Tp)===null||n===void 0||n.reset(),(o=this.Ip)===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;Hs(o)?this.Hp():((n=this._instance)===null||n===void 0||(n=n.persistence)===null||n===void 0||n.register({$logs_capture_enabled_server_side:!!o}),o?(this.mp=!0,this.yp||this.jp(),this.loadIfEnabled()):this.Hp())}reset(){var t,e,n,o;this.Bp(),(t=this.Tp)===null||t===void 0||t.clearQueue(),this.ol=[],(e=this.Tp)===null||e===void 0||e.reset(),(n=this.Ip)===null||n===void 0||n.clearQueue(),this.wp=[],(o=this.Ip)===null||o===void 0||o.reset(),this.kd=0}captureLog(t){this.To||this.Rp().captureLog(t)}captureConsoleLog(t){this.To||this.Op().captureLog(t)}captureBufferedConsoleLog(t,e,n){this.To||this.Op().captureLog(t,{context:e,occurredAtMs:n})}qp(){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[kYt])}Np(){var t,e,n;return!(!((t=this._instance)===null||t===void 0||(e=t.il)===null||e===void 0)&&e.call(t))||!!(!((n=Kr._POSTHOG_REMOTE_CONFIG)===null||n===void 0||(n=n[this._instance.config.token])===null||n===void 0)&&n.config)}Tc(){var t;this.Bp(),(t=this.Ip)===null||t===void 0||t.clearQueue(),this.wp=[]}Hp(){this.mp||this.Bp()}jp(){var t;if(this.xp||!Kr?.console)return;const e=nzt((t=this._instance)===null||t===void 0||(t=t.config)===null||t===void 0?void 0:t.logs).maxBufferSize;let n=!0;this.Sp.push(()=>{n=!1});for(const o of E$o){let i;try{i=B$o(Kr.console[o])}catch{continue}i&&this.Sp.push(LG(Kr.console,o,r=>{const s=(...a)=>{try{n&&this.Up(o,a,e)}catch{}return r.apply(Kr.console,a)};return s.__rrweb_original__=i,s}))}this.xp=!0,this.Wp=setTimeout(()=>{this.Bp()},3e4)}Up(t,e,n){var o;if(this.xp&&!this.$p&&e.length!==0)if(!((o=this._instance)===null||o===void 0)&&o.is_capturing()){if(n>this.kp.length){this.$p=!0;try{this.kp.push({level:t,args:e,occurredAtMs:Date.now(),context:this.Pp()})}finally{this.$p=!1}}}else this.Bp()}Bp(){if(this.kp=[],this.xp){this.xp=!1,this.Wp&&(clearTimeout(this.Wp),this.Wp=void 0);for(const t of this.Sp)t();this.Sp=[]}}Vp(){const t=this.kp;return this.Bp(),t}get logger(){return this.Gp||(this.Gp={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.Gp}flushLogs(t){t?this.Qp(t):(this.Tp&&this.Tp.flush().catch(e=>this.Zp(e)),this.Ip&&this.Ip.flush().catch(e=>this.Zp(e)))}Zp(t){rzt(t)||this.A.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(this.To||!this.mp||this.yp||this.bp)return;const t=Kr?.__PosthogExtensions__;if(!t)return this.A.error("PostHog Extensions not found."),void this.Bp();const e=t.loadExternalDependency;if(!e)return this.A.error(PRe),void this.Bp();this.bp=!0;try{e(this._instance,"logs",n=>{if(this.bp=!1,this.To||!this.mp)return;const o=t.logs;if(n||!o?.initializeLogs)this.A.error("Could not load logs script",n),this.Bp();else{var i;const a=this.Vp();var r,s;this.zp=o.initializeLogs((i=this.bo)!==null&&i!==void 0?i:this._instance),this.yp=!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.bp=!1,n}}Ep(t,e){const n=this._instance;return{get isDisabled(){return!1},get optedOut(){return!n.is_capturing()},getPersistedProperty:o=>o===D7.LogsQueue?t():void 0,setPersistedProperty(o,i){var r;o===D7.LogsQueue&&e((r=i)!==null&&r!==void 0?r:[])},js:o=>this.js(o),getLibraryId:()=>df.LIB_NAME,getLibraryVersion:()=>df.LIB_VERSION}}js(t){return new Promise(e=>{if(FUt(this.kd,3))return void e({kind:"fatal",error:xTe(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:xTe(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.Jp(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:r=>{const s=r.statusCode;if(this.Kp(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:xTe(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}`)})}}})})}Kp(t){(t!==0||this._instance.__loaded)&&(this.kd=LUt(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.")))}Qp(t){this.ol.length>0&&this.Xp(t,this.ol,this.Fp,df.LIB_NAME,e=>{this.ol=e}),this.wp.length>0&&this.Xp(t,this.wp,this.Lp,ozt,e=>{this.wp=e})}Xp(t,e,n,o,i){if(e.length===0)return;const r=e.map(a=>a.record);i([]);const s=BYt(r,EYt(n,df.LIB_NAME,df.LIB_VERSION),o,df.LIB_VERSION);this._instance._send_request({method:"POST",url:this.Jp(),data:s,compression:"best-available",batchKey:"logs",transport:t})}Jp(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}Pp(){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,Hs(i)||(e.sessionStartTimestamp=i),Hs(r)||(e.lastActivityTimestamp=r)}if(!(Kr==null||(t=Kr.location)===null||t===void 0)&&t.href&&(e.currentUrl=this._instance.config.disable_capture_url_hashes?eP(Kr.location.href):Kr.location.href),this._instance.featureFlags){const n=this._instance.featureFlags.getFlags();n&&n.length>0&&(e.activeFeatureFlags=n)}return e}}},G$o={metrics:class{constructor(t){this._instance=t,this.A=xd("[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.Yp?this.Yp=(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=Q$o(n,i),s=v$o(n,i);return()=>{o=!1,r(),s()}})(this._instance):!e&&this.Yp&&(this.Yp(),this.Yp=void 0)}Rp(){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.Tp&&this.Ap===e||((n=this.Tp)===null||n===void 0||n.reset(),this.Ap=e,this.Tp=new Cjo(this.Ep(),(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.Tp}count(t,e=1,n){this.Rp().count(t,e,n)}gauge(t,e,n){this.Rp().gauge(t,e,n)}histogram(t,e,n){this.Rp().histogram(t,e,n)}flush(t){if(!this.Tp)return Promise.resolve();if(t){const e=this.Tp.drainWindow();return e&&this.Ys(e,t),Promise.resolve()}return this.Tp.flush().catch(e=>this.A.error("PostHog metrics flush failed:",e))}reset(){var t;(t=this.Tp)===null||t===void 0||t.reset()}dispose(){var t,e;this.To=!0,(t=this.Yp)===null||t===void 0||t.call(this),this.Yp=void 0,(e=this.Tp)===null||e===void 0||e.reset()}Ep(){const t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Ys:n=>e.Ys(n),getLibraryId:()=>df.LIB_NAME,getLibraryVersion:()=>df.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(Zt(Zt({method:"POST",url:this.tg(),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}`)})}}}))})}tg(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Y$o={webMCP:class{constructor(t){this._instance=t,this.eg=!1}initialize(){this.startIfEnabled()}startIfEnabled(){if(!this._instance.config.capture_webmcp||this.eg)return;const t=qo?.modelContext;if(!t||!pp(t.registerTool))return;const e=Azt.get(t);if(e)return e.instances.add(this._instance),void(this.eg=!0);const n={instances:new Set([this._instance])},o=t.registerTool,i=this;LG(t,"registerTool",r=>{const s=r;return function(a,...A){let c=a;try{c=i.ig(a,n)}catch{return s.call(this,a,...A)}return s.call(this,c,...A)}}),t.registerTool!==o&&(Azt.set(t,n),this.eg=!0)}ig(t,e){if(!t||!pp(t.execute))return t;const n=t.execute,o=this,{tool:i,injected:r}=(function(s,a){const A={intent:!1,model:!1},c=s.inputSchema;if(c&&(AP(c,"$ref")||AP(c,"oneOf")||AP(c,"anyOf")||AP(c,"allOf")||c.additionalProperties===!0||va(c.additionalProperties)||c.type&&c.type!=="object"||c.properties&&!va(c.properties)||c.required&&!qr(c.required))||!Eo(c)&&!va(c))return{tool:bTe(s),injected:A};const l=c?.properties||{};if(A.intent=a.intent&&!AP(l,"context"),A.model=a.model&&!AP(l,"llm_model"),!A.intent&&!A.model)return{tool:bTe(s),injected:A};const u=Zt({},l),g=qr(c?.required)?[...c.required]:[];return A.intent&&(u.context={type:"string",description:`Explain why this tool is called and how it supports the user's goal. Describe the abstract purpose only. Do not include personal or identifying information. Generalize specific entities as roles such as "a customer".`},g.includes("context")||g.push("context")),A.model&&(u.llm_model={type:"string",description:'The exact model identifier you are running as, taken from your system prompt or environment. Pass "unknown" if you do not know it. Never guess.'},g.includes("llm_model")||g.push("llm_model")),{tool:bTe(s,Zt(Zt({},c),{},{type:c?.type||"object",properties:u,required:g})),injected:A}})(t,(function(s){const a={intent:!1,model:!1};for(const A of s.instances){const c=czt(A.config.capture_webmcp);a.intent||(a.intent=c?.intent===!0),a.model||(a.model=c?.model===!0)}return a})(e));return Object.defineProperty(i,"execute",{configurable:!0,enumerable:!0,writable:!0,value(...s){const a=new Date,A=(function(g,h){if(!va(g))return{};try{const d=h.intent?lzt(g.context,2048,!0):void 0,m=h.model?lzt(g.llm_model,256):void 0;return Zt(Zt({},d&&d!=="{}"?{intent:d}:{}),m&&m.toLowerCase()!=="unknown"?{model:m}:{})}catch{return{}}})(s[0],r),c=(function(g,h){const d=g[0];if(!va(d))return g;try{const m=h.intent&&AP(d,"context"),p=h.model&&AP(d,"llm_model");if(!m&&!p)return g;const f=Zt({},d);return m&&delete f.context,p&&delete f.llm_model,[f,...g.slice(1)]}catch{return g}})(s,r);let l;try{l=n.apply(this===i?t:this,c)}catch(g){throw o.ng(e,i,a,!0,A),g}return(u=l)&&typeof u.then=="function"?Promise.resolve(l).then(g=>(o.ng(e,i,a,uzt(g),A),g),g=>{throw o.ng(e,i,a,!0,A),g}):(o.ng(e,i,a,uzt(l),A),l);var u}}),i}ng(t,e,n,o,i){const r=Date.now()-n.getTime();for(const s of t.instances){const a=czt(s.config.capture_webmcp);if(a)try{s.capture("$mcp_tool_call",Zt(Zt({$mcp_source:"posthog_mcp_analytics",$mcp_interface:"webmcp",$mcp_tool_name:e.name,$mcp_resource_name:e.name,$mcp_tool_description:e.description,$mcp_server_name:tg?.hostname,$mcp_duration_ms:r,$mcp_is_error:o},a.intent&&i.intent?{$mcp_intent:i.intent,$mcp_intent_source:"context_parameter"}:{}),a.model&&i.model?{$mcp_llm_model:i.model,$mcp_llm_model_source:"self_reported"}:{}),{timestamp:n})}catch{continue}}}}};Y$.__defaultExtensionClasses=Zt({},Zt(Zt(Zt(Zt(Zt(Zt(Zt(Zt(Zt(Zt(Zt(Zt(Zt(Zt({},Hde),P$o),M$o),D$o),N$o),R$o),k$o),T$o),F$o),L$o),H$o),O$o),G$o),Y$o));var GG=(function(){df.SDK_DIST_CHANNEL="npm";const t=H$[G$]=new Y$;return(function(){function e(){e.done||(e.done=!0,fKt=!1,Cl(H$,function(n){n._dom_loaded()}))}qo?.addEventListener?qo.readyState==="complete"?e():Zc(qo,"DOMContentLoaded",e,{capture:!1}):jn&&li.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),t})();class IS 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 gzt 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 STe extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const n=e?.cause?e.cause instanceof Error?e.cause:new gzt(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 dzt=(()=>{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})(),U$o=typeof globalThis.AbortController=="function",hzt=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",K$o=typeof globalThis.ReadableStream=="function",z$o=typeof globalThis.FormData=="function",mzt=["get","post","put","patch","head","delete"],V$o={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},QTe=2147483647,J$o=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,pzt=Symbol("stop");class fzt{options;constructor(e){this.options=e}}const W$o=t=>new fzt(t),j$o={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},q$o={next:!0},$$o={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},X$o=t=>{if(!t)return 0;if(t instanceof FormData){let e=0;for(const[n,o]of t)e+=J$o,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},_zt=(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))}}))},Z$o=(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(_zt(t.body,n,e),{status:t.status,statusText:t.statusText,headers:t.headers})},eXo=(t,e,n)=>{if(!t.body)return t;const o=X$o(n??t.body);return new Request(t,{duplex:"half",body:_zt(t.body,o,e)})},XR=t=>t!==null&&typeof t=="object",Ode=(...t)=>{for(const e of t)if((!XR(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return vTe({},...t)},Izt=(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 Gde(t,e,n){return Object.hasOwn(e,n)&&e[n]===void 0?[]:vTe(t[n]??[],e[n]??[])}const Czt=(t={},e={})=>({beforeRequest:Gde(t,e,"beforeRequest"),beforeRetry:Gde(t,e,"beforeRetry"),afterResponse:Gde(t,e,"afterResponse"),beforeError:Gde(t,e,"beforeError")}),tXo=(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(XR(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},vTe=(...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(XR(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&&(!XR(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:tXo(i,A);continue}XR(A)&&a in e&&(A=vTe(e[a],A)),e={...e,[a]:A}}XR(s.hooks)&&(o=Czt(o,s.hooks),e.hooks=o),XR(s.headers)&&(n=Izt(n,s.headers),e.headers=n)}return i!==void 0&&(e.searchParams=i),r.length>0&&(r.length===1?e.signal=r[0]:hzt?e.signal=AbortSignal.any(r):e.signal=r.at(-1)),e},nXo=t=>mzt.includes(t)?t.toUpperCase():t,yzt={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},oXo=(t={})=>{if(typeof t=="number")return{...yzt,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{...yzt,...e}};class wTe extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}}async function iXo(t,e,n,o){return new Promise((i,r)=>{const s=setTimeout(()=>{n&&n.abort(),r(new wTe(t))},o.timeout);o.fetch(t,e).then(i).catch(r).then(()=>{clearTimeout(s)})})}async function rXo(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 sXo=(t,e)=>{const n={};for(const o in e)Object.hasOwn(e,o)&&!(o in $$o)&&!(o in j$o)&&(!(o in t)||o in q$o)&&(n[o]=e[o]);return n},aXo=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 AXo(t){return t instanceof IS||t?.name===IS.name}function cXo(t){return t instanceof wTe||t?.name===wTe.name}let xzt=class hat{static create(e,n){const o=new hat(e,n),i=async()=>{if(typeof o.#e.timeout=="number"&&o.#e.timeout>QTe)throw new RangeError(`The \`timeout\` option cannot be greater than ${QTe}`);await Promise.resolve();let s=await o.#f();for(const a of o.#e.hooks.afterResponse){const A=o.#g(s.clone());let c;try{c=await a(o.request,o.#u(),A,{retryCount:o.#i})}catch(u){throw o.#A(A),o.#A(s),u}if(c instanceof fzt)throw o.#A(A),o.#A(s),new STe(c.options);const l=c instanceof globalThis.Response?c:s;A!==l&&o.#A(A),s!==l&&o.#A(s),s=l}if(o.#g(s),!s.ok&&(typeof o.#e.throwHttpErrors=="function"?o.#e.throwHttpErrors(s.status):o.#e.throwHttpErrors)){let a=new IS(s,o.request,o.#u());for(const A of o.#e.hooks.beforeError)a=await A(a,{retryCount:o.#i});throw a}if(o.#e.onDownloadProgress){if(typeof o.#e.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!K$o)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");const a=s.clone();return o.#A(s),Z$o(a,o.#e.onDownloadProgress)}return s},r=o.#p(i).finally(()=>{const s=o.#s;o.#d(s?.body??void 0),o.#d(o.request.body??void 0)});for(const[s,a]of Object.entries(V$o))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#o(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof URLSearchParams)?Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0)):e}request;#n;#i=0;#t;#e;#s;#r;#c;constructor(e,n={}){if(this.#t=e,this.#e={...n,headers:Izt(this.#t.headers,n.headers),hooks:Czt({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},n.hooks),method:nXo(n.method??this.#t.method??"GET"),prefixUrl:String(n.prefixUrl||""),retry:oXo(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}U$o&&hzt&&(this.#r=this.#e.signal??this.#t.signal,this.#n=new globalThis.AbortController,this.#e.signal=this.#r?AbortSignal.any([this.#r,this.#n.signal]):this.#n.signal),dzt&&(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&&(z$o&&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),aXo(this.#e.searchParams)){const r="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(hat.#o(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(!dzt)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#m(this.request,this.#e.body??void 0)}}#a(){const e=this.#e.retry.delay(this.#i);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#l(e){if(this.#i++,this.#i>this.#e.retry.limit)throw e;const n=e instanceof Error?e:new gzt(e);if(n instanceof STe)return n.customDelay??this.#a();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.#i});if(o===!1)throw e;if(o===!0)return this.#a()}if(cXo(e)&&!this.#e.retry.retryOnTimeout)throw e;if(AXo(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.#a()}#g(e){return this.#e.parseJson&&(e.json=async()=>this.#e.parseJson(await e.text())),e}#d(e){e&&e.cancel().catch(()=>{})}#A(e){this.#d(e.body??void 0)}async#p(e){try{return await e()}catch(n){const o=Math.min(await this.#l(n),QTe);if(this.#i<1)throw n;if(await rXo(o,this.#r?{signal:this.#r}:{}),n instanceof STe&&n.customRequest){const i=this.#e.signal?new globalThis.Request(n.customRequest,{signal:this.#e.signal}):new globalThis.Request(n.customRequest);this.#h(i)}for(const i of this.#e.hooks.beforeRetry){const r=await i({request:this.request,options:this.#u(),error:n,retryCount:this.#i});if(r instanceof globalThis.Request){this.#h(r);break}if(r instanceof globalThis.Response)return r;if(r===pzt)return}return this.#p(e)}}async#f(){this.#n?.signal.aborted&&(this.#n=new globalThis.AbortController,this.#e.signal=this.#r?AbortSignal.any([this.#r,this.#n.signal]):this.#n.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.#u(),{retryCount:this.#i});if(o instanceof Response)return o;if(o instanceof globalThis.Request){this.#h(o);break}}const e=sXo(this.request,this.#e);return this.#s=this.request,this.request=this.#s.clone(),this.#e.timeout===!1?this.#e.fetch(this.#s,e):iXo(this.#s,e,this.#n,this.#e)}#u(){if(!this.#c){const{hooks:e,...n}=this.#e;this.#c=Object.freeze(n)}return this.#c}#h(e){this.#c=void 0,this.request=this.#m(e)}#m(e,n){return!this.#e.onUploadProgress||!e.body?e:eXo(e,this.#e.onUploadProgress,n??this.#e.body??void 0)}};const PTe=t=>{const e=(n,o)=>xzt.create(n,Ode(t,o));for(const n of mzt)e[n]=(o,i)=>xzt.create(o,Ode(t,i,{method:n}));return e.create=n=>PTe(Ode(n)),e.extend=n=>(typeof n=="function"&&(n=n(t??{})),PTe(Ode(t,n))),e.stop=pzt,e.retry=W$o,e},lXo=PTe();class uXo extends IS{constructor(e,n,o,i){super(e,n,o),this.name="RegistryHTTPError",this.message=i}}function K$(t){return typeof window<"u"?window[t]:null}function cP(){const t=K$("TSCIRCUIT_REGISTRY_API_BASE_URL")||void 0||"https://registry-api.tscircuit.com",e=K$("TSCIRCUIT_REGISTRY_TOKEN");return lXo.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(u){console.error("Failed to parse registry error response",u)}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 uXo(i,n,o,l.join(" | "))}]}})}function Yde(){return!!K$("TSCIRCUIT_REGISTRY_TOKEN")}const z$={get:(t,e)=>cP().get(t,e),post:(t,e)=>cP().post(t,e),put:(t,e)=>cP().put(t,e),delete:(t,e)=>cP().delete(t,e),patch:(t,e)=>cP().patch(t,e)},gXo="phc_htd8AQjSfVEsFCLQMAiUooG4Q0DKBCjqYuQglc9V3Wo",dXo="https://postpig.tscircuit.com",Ezt="runframe:anonymous-id",MTe=()=>typeof window<"u",Bzt=t=>t.includes("localhost")||t.includes("127.0.0.1"),hXo=t=>{try{return new URL(t).hostname}catch{return null}},mXo=()=>{if(!MTe())return null;let t=null;return document.referrer&&(t=hXo(document.referrer)),t??window.location.hostname},pXo=()=>typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,fXo=()=>{if(!MTe())return null;try{const t=window.localStorage.getItem(Ezt);if(t)return t;const e=pXo();return window.localStorage.setItem(Ezt,e),e}catch{return null}},_Xo=()=>K$("TSCIRCUIT_USE_RUNFRAME_FOR_CLI")===!0,bzt=()=>!MTe()||Bzt(window.location.hostname)&&!_Xo()?!1:(GG.__loaded||GG.init(gXo,{api_host:dXo,person_profiles:"always"}),!0),IXo=()=>{if(!bzt())return null;const t=mXo(),e=t!=null&&!Bzt(t);let n=null;e||(n=fXo());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}},CXo=(t,{source:e,...n})=>{const o=IXo();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),GG.identify(s,A)}GG.capture(t,{...n,source:e,embed_domain:i,runframe_anonymous_id:r,identity_type:a})},yXo=t=>{CXo("runframe_activity",t)};bzt();function xXo(t){const e=String.fromCodePoint(...t);return btoa(e)}function EXo(t,e){const n=JSON.stringify(t),o=Vve(Jve(n));return`https://tscircuit.com/editor?#data:application/gzip;base64,${xXo(o)}`}function Fi(...t){return UJo($B(t))}const Szt=t=>t.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()),DTe=cJo,Ude=X.forwardRef(({className:t,...e},n)=>K.jsx(WOt,{ref:n,className:Fi("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}));Ude.displayName=WOt.displayName;const k7=X.forwardRef(({className:t,...e},n)=>K.jsx(jOt,{ref:n,className:Fi("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}));k7.displayName=jOt.displayName;const bI=X.forwardRef(({className:t,...e},n)=>K.jsx(qOt,{ref:n,className:Fi("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}));bI.displayName=qOt.displayName;function dn(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 BXo=/^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 bXo(t){const e=t.match(BXo);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 SXo(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 V$(t){return typeof t>"u"}function mf(t,e=0){return{a:1,c:0,e:t,b:0,d:1,f:e}}function J$(...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 J$(r,...i)}}}function e0(...t){return J$(...t)}const{cos:QXo,sin:vXo}=Math;function F7(t,e,n){const o=QXo(t),i=vXo(t),r={a:o,c:-i,e:0,b:i,d:o,f:0};return V$(e)||V$(n)?r:J$([mf(e,n),r,mf(-e,-n)])}function jx(t,e=void 0,n=void 0,o=void 0){V$(e)&&(e=t);const i={a:t,c:0,e:0,b:0,d:e,f:0};return V$(n)||V$(o)?i:J$([mf(n,o),i,mf(-n,-o)])}function wXo(t){return L7(t)}function L7(t){return`matrix(${t.a},${t.b},${t.c},${t.d},${t.e},${t.f})`}function PXo(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 MXo(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],u=t[2].y!=null?t[2].y:t[2][1],g=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-u,c:s-l,d:a-u,e:l,f:u},m={a:i-g,b:r-h,c:A-g,d:c-h,e:g,f:h},p=SXo(d),f=J$([m,p]);return PXo(f)}function DXo(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n}function Kde(t,e,n,o){var i=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(i,Kde.prototype),i.expected=e,i.found=n,i.location=o,i.name="SyntaxError",i}DXo(Kde,Error);function NTe(t,e,n){return n=n||" ",t.length>e?t:(e-=t.length,n+=n.repeat(e),t+n.slice(0,e))}Kde.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=NTe("",r.line.toString().length," "),c=n[i.line-1],l=i.line===a.line?a.column:c.length+1,u=l-i.column||1;e+=`
|
|
1070
1070
|
--> `+s+`
|
|
1071
1071
|
`+A+` |
|
|
@@ -5668,7 +5668,7 @@ test("${c} should solve problem correctly", () => {
|
|
|
5668
5668
|
// Add more specific assertions based on expected output
|
|
5669
5669
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5670
5670
|
})
|
|
5671
|
-
`,u=new Blob([l],{type:"text/plain"}),g=URL.createObjectURL(u),h=document.createElement("a");h.href=g,h.download=`${c}.test.ts`,h.click(),URL.revokeObjectURL(g)}catch(A){alert(`Error generating test.ts for ${t.getSolverName()}: ${A instanceof Error?A.message:String(A)}`)}o(!1)};return K.jsxs("div",{className:`relative ${e}`,ref:i,children:[K.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&&K.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:[K.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),K.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),K.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},E2n=t=>t.activeSubSolver?[t,...E2n(t.activeSubSolver)]:[t],OXi=({solver:t})=>{const e=E2n(t);return K.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>K.jsxs("div",{className:"flex items-center",children:[o>0&&K.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),K.jsx(HXi,{solver:n})]},n.getSolverName()))})},GXi=({solver:t,triggerRender:e,animationSpeed:n=25,renderer:o,onRendererChange:i,onAnimationSpeedChange:r,onDownloadVisualization:s,onSolverStarted:a,onSolverCompleted:A})=>{const[c,l]=X.useReducer(B=>!B,!1),u=X.useRef(void 0),g=X.useRef(null),h="solver-debugger-last-iteration",[d,m]=X.useState(null),p=X.useRef(null),f=X.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"}],[]),_=()=>{const B=Math.max(1,n),S=n<1?Math.round(1/n):1;u.current=setInterval(()=>{if(t.solved||t.failed){u.current&&(clearInterval(u.current),u.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=()=>{u.current&&(clearInterval(u.current),u.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(),_())},E=()=>{if(t.solved||t.failed||c)return;g.current===null&&typeof window<"u"&&(g.current=window.localStorage.getItem(h));const B=window.prompt("Step until which iteration?",g.current??`${t.iterations}`);if(B===null)return;g.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 X.useEffect(()=>()=>{I()},[]),X.useEffect(()=>{(t.solved||t.failed)&&c&&(I(),l())},[t.solved,t.failed,c]),X.useEffect(()=>{c&&(I(),_())},[n,c]),X.useEffect(()=>{if(typeof document>"u")return;const B=S=>{p.current&&!p.current.contains(S.target)&&m(null)};return document.addEventListener("mousedown",B),()=>{document.removeEventListener("mousedown",B)}},[]),K.jsxs("div",{className:"space-y-2 p-2 border-b",children:[K.jsx("div",{className:"flex items-center",children:K.jsxs("div",{className:"flex items-center gap-2",ref:p,children:[K.jsxs("div",{className:"flex h-9 items-center space-x-1 rounded-md border border-slate-200 bg-white p-1 shadow-sm",children:[K.jsxs("div",{className:"relative",children:[K.jsx("button",{type:"button",onClick:()=>m(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"&&K.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=>K.jsxs("button",{type:"button",onClick:()=>{i(B),m(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&&K.jsx("span",{className:"ml-auto text-xs text-slate-500",children:"✓"})]},B))})]}),K.jsxs("div",{className:"relative",children:[K.jsx("button",{type:"button",onClick:()=>m(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"&&K.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:K.jsx("button",{type:"button",onClick:()=>{s(),m(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:"Download Visualization"})})]}),K.jsxs("div",{className:"relative",children:[K.jsx("button",{type:"button",onClick:()=>m(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"&&K.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:f.map(B=>K.jsxs("button",{type:"button",onClick:()=>{r(B.value),m(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:[B.label,K.jsx("span",{className:"ml-auto text-xs text-slate-500",children:B.description}),n===B.value&&K.jsx("span",{className:"ml-2 text-xs text-slate-500",children:"✓"})]},B.value))})]})]}),K.jsx(OXi,{solver:t})]})}),K.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[K.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"}),K.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"}),K.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"}),K.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"}),K.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&K.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),t.solved&&K.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&K.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&K.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},YXi=t=>t!==null&&"pipelineDef"in t&&Array.isArray(t.pipelineDef),UXi=(t,e,n)=>{const o=t.currentPipelineStageIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},KXi=(t,e)=>{const o=t.pipelineDef[e].solverName,i=UXi(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 g=t.pipelineDef[e+1],h=g?t.firstIterationOfStage?.[g.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 u=r?.stats??null;return{index:e,name:o,status:i,firstIteration:s,iterations:A,progress:l,timeSpent:c,stats:u&&Object.keys(u).length>0?u:null,solverInstance:r??null}},zXi=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return K.jsx("span",{className:`font-medium ${e[t]}`,children:t})},VXi=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return K.jsxs("div",{className:"flex items-center gap-2",children:[K.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:K.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),K.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},B2n=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)},JXi=t=>Object.entries(t).map(([e,n])=>`${e}: ${B2n(n)}`).join(", "),WXi=({stats:t})=>{if(!t||Object.keys(t).length===0)return K.jsx("span",{children:"-"});const e=Object.entries(t),n=JXi(t);return K.jsxs("details",{className:"cursor-pointer",children:[K.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),K.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>K.jsxs("div",{children:[o,": ",B2n(i)]},o))})]})},EZe=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(EZe);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=EZe(o));return e},jXi=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=EZe(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)}`)}},qXi=({expanded:t})=>K.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:K.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"})}),b2n=t=>{let e=t;for(;e.activeSubSolver;)e=e.activeSubSolver;return e},S2n=({solver:t,onStepUntilPhase:e,onDownloadInput:n,isNested:o=!1,indentLevel:i=0,triggerRender:r})=>{const[s,a]=X.useState(new Set),A=t.pipelineDef.map((p,f)=>KXi(t,f)),c=p=>{a(f=>{const _=new Set(f);return _.has(p)?_.delete(p):_.add(p),_})},l=p=>{e?.(p)},u=p=>{p.solverInstance&&(n?n(p.solverInstance,p.name):jXi(p.solverInstance,p.name))},g=p=>`${(p/1e3).toFixed(2)}s`,h=()=>{if(!t.solved&&!t.failed){const p=t.activeSubSolver;for(;!t.solved&&!t.failed&&(t.step(),!(t.activeSubSolver&&t.activeSubSolver!==p)););r?.()}},d=()=>{if(!t.solved&&!t.failed){const p=b2n(t);for(;!t.solved&&!t.failed&&(t.step(),b2n(t)===p););r?.()}},m=i*24;return K.jsxs("div",{className:o?"":"border-t border-gray-200",children:[!o&&K.jsxs("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200 flex items-center justify-between",children:[K.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Stages"}),K.jsxs("div",{className:"flex gap-2",children:[K.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"}),K.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"})]})]}),K.jsx("div",{className:"overflow-x-auto",children:K.jsxs("table",{className:"w-full text-sm",children:[!o&&K.jsx("thead",{children:K.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stage"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),K.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",K.jsx("sub",{children:"0"})]}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),K.jsx("tbody",{children:A.map(p=>{const f=YXi(p.solverInstance),_=s.has(p.name);return K.jsxs(Fs.Fragment,{children:[K.jsxs("tr",{className:`border-b border-gray-100 ${p.status==="In Progress"?"bg-yellow-50":""}`,children:[K.jsx("td",{className:"px-4 py-2",children:K.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:m},children:[f?K.jsx("button",{onClick:()=>c(p.name),className:"text-gray-500 hover:text-gray-700",title:_?"Collapse":"Expand",children:K.jsx(qXi,{expanded:_})}):K.jsx("span",{className:"w-4"}),K.jsx("span",{className:"text-gray-400 w-6",children:String(p.index+1).padStart(2,"0")}),K.jsx("button",{onClick:()=>l(p.name),disabled:p.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 ${p.name} completes`,children:K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:K.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"})})}),K.jsx("span",{className:"font-medium text-gray-900",children:p.name})]})}),K.jsx("td",{className:"px-4 py-2",children:K.jsx(zXi,{status:p.status})}),K.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:p.firstIteration!==null?p.firstIteration:""}),K.jsx("td",{className:"px-4 py-2 text-gray-600",children:p.iterations}),K.jsx("td",{className:"px-4 py-2",children:K.jsx(VXi,{progress:p.progress})}),K.jsx("td",{className:"px-4 py-2 text-gray-600",children:g(p.timeSpent)}),K.jsx("td",{className:"px-4 py-2 text-gray-500",children:K.jsx(WXi,{stats:p.stats})}),K.jsx("td",{className:"px-4 py-2",children:p.solverInstance?K.jsxs("button",{onClick:()=>u(p),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${p.name}`,children:[K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:K.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"})}),K.jsx("span",{children:"Input"})]}):null})]}),f&&_&&K.jsx("tr",{children:K.jsx("td",{colSpan:8,className:"p-0",children:K.jsx(S2n,{solver:p.solverInstance,onStepUntilPhase:e,onDownloadInput:n,isNested:!0,indentLevel:i+1,triggerRender:r})})})]},p.name)})})]})})]})};function $Xi({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=(p,f)=>{typeof p=="number"&&(p<s&&(s=p),p>A&&(A=p)),typeof f=="number"&&(f<a&&(a=f),f>c&&(c=f))};for(const p of e)l(p.x,p.y);for(const p of n){const f=p.points??[];for(const _ of f)l(_.x,_.y)}for(const p of o){const f=p.x??0,_=p.y??0,I=p.width??0,C=p.height??0;l(f,_),l(f+I,_+C)}for(const p of i){const f=p.x??0,_=p.y??0,I=p.radius??1;l(f-I,_-I),l(f+I,_+I)}for(const p of r)l(p.x,p.y);(!isFinite(s)||!isFinite(a)||!isFinite(A)||!isFinite(c))&&(s=-20,a=-20,A=20,c=20);const u=10,g=s-u,h=a-u,d=Math.max(1,A-s+2*u),m=Math.max(1,c-a+2*u);return K.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${g} ${h} ${d} ${m}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,f)=>K.jsx("rect",{x:p.x??0,y:p.y??0,width:p.width??0,height:p.height??0,fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`rect-${f}`)),n.map((p,f)=>K.jsx("polyline",{fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1,points:(p.points??[]).map(_=>`${_.x??0},${_.y??0}`).join(" ")},`line-${f}`)),i.map((p,f)=>K.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.fillColor??"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`circle-${f}`)),e.map((p,f)=>K.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.color??"black"},`point-${f}`)),r.map((p,f)=>K.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${f}`))]})}var XXi=class extends Fs.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}},ZXi=({solver:t,createSolver:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=X.useReducer(_=>_+1,0),[a]=X.useState(()=>{if(e)return e();if(!t)throw new Error("GenericSolverDebugger requires solver or createSolver");return t}),[A,c]=X.useState(()=>typeof window>"u"?"vector":window.localStorage.getItem("solver-utils-renderer")==="canvas"?"canvas":"vector"),[l,u]=X.useState(n),g=X.useMemo(()=>{try{return a.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(_){return console.error("Visualization error:",_),{points:[],lines:[],rects:[],circles:[]}}},[a,r]),h=X.useMemo(()=>(g.rects?.length||0)===0&&(g.lines?.length||0)===0&&(g.points?.length||0)===0&&(g.circles?.length||0)===0,[g]);X.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const _=document.createElement("script");_.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(_)}},[]),X.useEffect(()=>{u(n)},[n]);const d=a.pipelineDef!==void 0,m=_=>{const I=a;if(!a.solved&&!a.failed){for(;!a.solved&&!a.failed&&I.currentPipelineStageIndex<=I.pipelineDef.findIndex(C=>C.solverName===_);)a.step();s()}},p=()=>{const _=JSON.stringify(g,null,2),I=new Blob([_],{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(_),typeof window<"u"&&window.localStorage.setItem("solver-utils-renderer",_)};return K.jsxs("div",{children:[K.jsx(GXi,{solver:a,triggerRender:s,animationSpeed:l,renderer:A,onRendererChange:f,onAnimationSpeedChange:u,onDownloadVisualization:p,onSolverStarted:o,onSolverCompleted:i}),h?K.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):K.jsx(XXi,{fallback:K.jsx($Xi,{graphics:g}),children:A==="canvas"?K.jsx(LXi,{graphics:g}):K.jsx(TXi,{graphics:g})}),d&&K.jsx(S2n,{solver:a,onStepUntilPhase:m,triggerRender:s})]})};const eZi=()=>{X.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)},[])},tZi=1e3,XE=(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)},tZi)},BZe=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"},nZi=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]},b8="https://github.com/tscircuit/tscircuit-autorouter/issues/new",Q2n="https://github.com/tscircuit/copper-pour-solver/issues/new",v2n="https://github.com/tscircuit/calculate-packing/issues/new",oZi="https://github.com/tscircuit/matchpack/issues/new",w2n="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",iZi={PackSolver2:v2n,LayoutPipelineSolver:oZi,AutoroutingPipelineSolver:b8,AssignableAutoroutingPipeline2:b8,AssignableAutoroutingPipeline3:b8,AutoroutingPipeline1_OriginalUnravel:b8,AutoroutingPipelineSolver3_HgPortPointPathing:b8,AutoroutingPipelineSolver4:b8,AutoroutingPipelineSolver5:b8,AutoroutingPipelineSolver7_MultiGraph:b8,AutoroutingPipelineSolver8:b8,CopperPourPipelineSolver:Q2n,SchematicTracePipelineSolver:w2n},rZi=t=>t.toLowerCase().includes("pack")?cIn:t.toLowerCase().includes("rout")?uIn:JUi,P2n=t=>{const e=iZi[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?b8:n.includes("schematic")&&n.includes("trace")?w2n:n.includes("copperpour")?Q2n:n.includes("pack")?v2n:null},sZi=t=>`${BZe(`${t.componentName}-${t.solverName}`)}-solver-input.json`,M2n=t=>{XE(JSON.stringify(t.solverParams,null,2),{fileName:sZi(t),mimeType:"application/json"})},aZi=({solverEvent:t})=>{const e=P2n(t.solverName);return K.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:[K.jsxs(IA,{type:"button",variant:"outline",size:"sm",onClick:()=>M2n(t),children:[K.jsx(Fee,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?K.jsx(IA,{asChild:!0,variant:"outline",size:"sm",children:K.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[K.jsx(p_e,{className:"rf-w-4 rf-h-4"}),"Report"]})}):K.jsxs(IA,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[K.jsx(p_e,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},AZi=({solverEvent:t})=>{const e=P2n(t.solverName);return e?K.jsx(IA,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:K.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:K.jsx(p_e,{className:"rf-w-4 rf-h-4"})})}):K.jsx(IA,{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:K.jsx(p_e,{className:"rf-w-4 rf-h-4"})})},cZi=({solverEvents:t=[]})=>{const[e,n]=X.useState(null);eZi();const o=X.useMemo(()=>{const a=new Map;for(const A of t){const c=`${A.componentName}-${A.solverName}`;a.set(c,A)}return a},[t]),i=X.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=X.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=vDe[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(vDe).join(", ")}`,classFound:!1};try{return{instance:new a(...nZi(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?K.jsx("div",{className:"rf-p-4",children:K.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:K.jsxs("div",{className:"rf-p-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),K.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."})]})})}):K.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[K.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[K.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 K.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=rZi(A.solverName);return K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[K.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),K.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[K.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:A.componentName}),K.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:A.solverName})]})]})})()},a)})]}),K.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?K.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[K.jsx(aZi,{solverEvent:r}),K.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:K.jsx(zE,{fallback:K.jsx("div",{className:"rf-p-4",children:K.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),K.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:K.jsx(ZXi,{solver:s.instance})})})]}):K.jsxs("div",{className:"rf-p-4",children:[K.jsxs("div",{className:"rf-mb-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),K.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&K.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:K.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),K.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[K.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:[K.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[K.jsx(AZi,{solverEvent:r}),K.jsx(IA,{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:()=>M2n(r),children:K.jsx(Fee,{className:"rf-w-4 rf-h-4"})})]})]}),K.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:K.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)})})]})]}):K.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:K.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},lZi=["subcircuit_id","componentDisplayName","phaseName","routingPhaseIndex","phaseOrdinal","phaseCount","phaseStageIndex","phaseStageCount","connectionCount","obstacleCount","previousTraceCount","isReroutePhase","autorouterName","autorouterVersion","solverName","effort","cacheStatus"],uZi=["phaseOrdinal","routingPhaseIndex","phaseName","phaseStageIndex"];function gZi(t,e){let n=-1,o=-1;for(let i=t.length-1;i>=0;i--){const r=t[i];if(r.status!=="running"||r.subcircuit_id!==e.subcircuit_id||r.componentDisplayName!==e.componentDisplayName)continue;let s=0,a=!1;for(const A of uZi)if(!(r[A]===void 0||e[A]===void 0)){if(r[A]!==e[A]){a=!0;break}s++}!a&&s>o&&(n=i,o=s)}return n}function dZi(t,e){const n=Object.fromEntries(lZi.filter(s=>e[s]!==void 0).map(s=>[s,e[s]])),o=e.simpleRouteJson?structuredClone(e.simpleRouteJson):void 0,i=e.type==="autorouting:start"?-1:gZi(t,e),r={...i===-1?{id:`autorouting_phase_${t.length+1}`}:t[i],...n,status:e.type==="autorouting:start"?"running":e.type==="autorouting:end"?"complete":"error",...e.type==="autorouting:start"?{startSimpleRouteJson:o}:e.type==="autorouting:end"?{endSimpleRouteJson:o}:{errorSimpleRouteJson:o,error:e.error?{...e.error}:void 0}};return i===-1?[...t,r]:t.map((s,a)=>a===i?r:s)}const hZi=new Map([["custom","Custom"],["fanout","Fanout"],["single_layer_fanout","Single layer fanout"],["tscircuit_simplify","Simplify"]]),mZi=new Set(["tscircuit","default","auto","auto_local"]);function pZi(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 fZi(t){const e=t.autorouterName?.trim(),n=e?.replace(/-/g,"_"),o=n&&hZi.get(n);if(o)return o;if(n&&!mZi.has(n))return e;const i=t.solverName?.trim();if(i)return pZi(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 bZe="#fbbf24";function _Zi(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 D2n(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 IZi(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 N2n(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,...IZi(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,u)=>{if(l.route_type!=="wire")return;const g=Math.hypot(l.x-a.x,l.y-a.y);g<c&&(c=g,A=u)}),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 CZi(t){const e=[],n=[],o=t.endSimpleRouteJson;if(!o)return{lines:e,circles:n};const i=new Set(D2n(t));for(const r of o.traces??[])if(i.has(r.pcb_trace_id))for(const s of N2n(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:bZe,layer:c}),A.route_type==="via"&&n.push({center:{x:A.x,y:A.y},radius:A.outer_diameter/2,stroke:bZe,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 yZi(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 xZi=new Set(["pcb_trace","pcb_via","pcb_copper_pour","pcb_ground_plane","pcb_ground_plane_region","pcb_thermal_spoke","pcb_breakout_point"]);function EZi(t,e,n){const o=n==="input"?e.startSimpleRouteJson??e.errorSimpleRouteJson:e.endSimpleRouteJson,i=t.filter(c=>!xZi.has(c.type)&&!c.type.endsWith("_error")&&!c.type.endsWith("_warning"));if(!o)return i;const r=n==="input"?o.traces??[]:_Zi(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 u=o.connections.find(h=>h.name===c.connection_name||h.source_trace_id===c.connection_name)?.source_trace_id??c.connection_name??"",g=N2n(c,o);for(const[h,d]of g.entries()){const m={type:"pcb_trace",pcb_trace_id:`${e.id}_${n}_${c.pcb_trace_id}_${h}_${yZi(d)}`,subcircuit_id:e.subcircuit_id??void 0,source_trace_id:s.has(u)?u:void 0,route:d};A.push(m);for(const[p,f]of d.entries()){if(f.route_type!=="via")continue;const _=a.indexOf(f.from_layer),I=a.indexOf(f.to_layer),C={type:"pcb_via",pcb_via_id:`${m.pcb_trace_id}_via_${p}`,pcb_trace_id:m.pcb_trace_id,subcircuit_id:e.subcircuit_id??void 0,x:f.x,y:f.y,outer_diameter:f.outer_diameter,hole_diameter:f.hole_diameter,layers:_>=0&&I>=0?a.slice(Math.min(_,I),Math.max(_,I)+1):[f.from_layer,f.to_layer]};A.push(C)}}}return[...i,...A]}const SZe=(t,e)=>t.phaseName||`Phase ${t.phaseOrdinal??e+1}`,R2n=t=>t.componentDisplayName?.match(/name="([^"]+)"/)?.[1]?.replace(/^\./,"")||t.componentDisplayName||t.subcircuit_id||"Board",T2n=t=>t.startSimpleRouteJson??t.endSimpleRouteJson??t.errorSimpleRouteJson,BZi={is_showing_autorouting:!0,is_showing_rats_nest:!1,is_showing_drc_errors:!1,is_showing_drc_warnings:!1,is_showing_pcb_groups:!1},bZi=({circuitJson:t,phases:e=[],isRunning:n=!1})=>{const[o,i]=X.useState(null),[r,s]=X.useState("output"),[a,A]=X.useState(!0),[c,l]=X.useState(!1),u=X.useRef(null),[g,h]=X.useState(480),d=o?e.findIndex(R=>R.id===o.id&&T2n(R)===T2n(o)):-1,m=d<0?e.length-1:d,p=e[m],f=d<0,_=!!p?.endSimpleRouteJson,I=p?.startSimpleRouteJson??p?.errorSimpleRouteJson,C=!!I,y=r==="output"&&!_?"input":r==="input"&&!C?"output":r,x=y==="input"?I:p?.endSimpleRouteJson,E=X.useMemo(()=>!p||!x?null:EZi(t??[],p,y),[t,p,x,y]),B=X.useMemo(()=>p&&y==="output"&&a?CZi(p):{lines:[],circles:[]},[p,y,a]);if(X.useLayoutEffect(()=>{const R=u.current;if(!R)return;const F=()=>h(Math.max(360,R.clientHeight));F();const O=new ResizeObserver(F);return O.observe(R),()=>O.disconnect()},[!!p]),!p)return K.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:[K.jsx(uIn,{className:"rf-h-7 rf-w-7 rf-text-blue-500"}),K.jsx("h3",{className:"rf-text-base rf-font-medium",children:n?"Waiting for autorouting":"No autorouting captures"}),K.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=SZe(p,m),Q=p.status==="running"&&n,w=!_,M=I?.connections.length,T=E?.filter(R=>R.type==="pcb_trace").length??0;return K.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:[K.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:[K.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:[K.jsx("span",{children:"Routing phases"}),K.jsx("span",{children:e.length})]}),K.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=D2n(R).length,U=R.endSimpleRouteJson?`${O} ${O===1?"trace":"traces"} routed`:R.status==="error"?"Failed":R.status==="running"&&n?"Routing…":"No output";return K.jsxs("button",{type:"button","aria-pressed":F===m,title:`${R2n(R)} · ${U}`,onClick:()=>i(R),className:Fi("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===m?"rf-border-blue-200 rf-bg-blue-50":"rf-border-transparent hover:rf-bg-gray-50"),children:[K.jsx("span",{className:Fi("rf-flex rf-h-5 rf-w-5 rf-shrink-0 rf-items-center rf-justify-center rf-rounded-full rf-text-[11px]",F===m?"rf-bg-blue-600 rf-text-white":"rf-bg-gray-100 rf-text-gray-500"),children:F+1}),K.jsxs("span",{className:"rf-min-w-0 rf-flex-1",children:[K.jsxs("span",{className:"rf-flex rf-items-center rf-gap-1",children:[K.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:SZe(R,F),children:SZe(R,F)}),R.status==="complete"?K.jsx(VS,{"aria-label":"Captured",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-green-600"}):R.status==="error"?K.jsx(X$e,{"aria-label":"Failed",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-red-500"}):n?K.jsx(VE,{"aria-label":"Routing",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-animate-spin rf-text-blue-500"}):null]}),K.jsxs("span",{className:"rf-block rf-text-[11px] rf-leading-4 rf-text-gray-500",children:[fZi(R)," · ",U]})]})]},R.id)})})]}),K.jsxs("div",{className:"rf-flex rf-min-w-0 rf-flex-1 rf-flex-col",children:[K.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:[K.jsxs("h3",{className:"rf-mr-auto rf-flex rf-items-center rf-gap-2 rf-text-sm rf-font-medium",children:[S,K.jsxs("span",{className:"rf-text-xs rf-font-normal rf-text-gray-500",children:[m+1," of ",e.length]})]}),n&&K.jsx("button",{type:"button",onClick:()=>i(null),disabled:f,className:"rf-text-xs rf-text-blue-600 disabled:rf-text-gray-500",children:f?"Following latest":"Follow latest"}),K.jsx("div",{className:"rf-flex rf-rounded-md rf-bg-gray-100 rf-p-1","aria-label":"Phase snapshot",children:["input","output"].map(R=>K.jsx("button",{type:"button","aria-pressed":y===R,disabled:R==="input"?!C:!_,onClick:()=>s(R),className:Fi("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))})]}),K.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:[K.jsxs("label",{className:"rf-flex rf-items-center rf-gap-2",children:[K.jsx("input",{type:"checkbox",checked:a,disabled:y!=="output",onChange:R=>A(R.target.checked),className:"rf-accent-blue-600"}),K.jsx("span",{"aria-hidden":"true",className:"rf-inline-block rf-h-0.5 rf-w-3",style:{backgroundColor:bZe}}),"Highlight changes (all layers)"]}),K.jsxs("span",{children:[y==="input"?"Before this phase":"After this phase"," ","· ",T," traces"]})]}),w&&K.jsx("div",{className:Fi("rf-border-y rf-px-4 rf-py-2 rf-text-xs",p.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:p.status==="error"?`Routing failed: ${p.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."}),K.jsx("div",{ref:u,className:"rf-relative rf-min-h-[360px] rf-flex-1","data-testid":"autorouting-pcb",children:E?K.jsx(j$e,{circuitJson:E,height:g,allowEditing:!1,clickToInteractEnabled:!1,initialState:BZi,debugGraphics:B}):K.jsx("div",{className:"rf-p-6 rf-text-sm rf-text-gray-500",children:"No PCB snapshot available for this capture."})}),K.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:[K.jsxs("span",{children:[M===void 0?"Input unavailable":`${M} input connections`,` · ${R2n(p)}`]}),K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-4",children:[K.jsxs("button",{type:"button",disabled:!x,onClick:()=>XE(JSON.stringify(x,null,2),{fileName:`${p.id}-${y}.srj.json`,mimeType:"application/json"}),className:"rf-flex rf-items-center rf-gap-1 disabled:rf-opacity-40",children:[K.jsx(Fee,{className:"rf-h-3 rf-w-3"}),"Download SRJ"]}),K.jsxs("button",{type:"button","aria-expanded":c,onClick:()=>l(!c),className:"rf-flex rf-items-center rf-gap-1",children:[K.jsx(ik,{className:Fi("rf-h-3 rf-w-3",c&&"rf-rotate-90")}),"Inspect SRJ"]})]})]}),c&&K.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."})]})]})},k2n=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{X.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{GG.captureException(o)}catch{}}},[t,e]),X.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{GG.captureException(i,{error_type:o.type})}catch{}}},[n])},F2n=t=>{X.useEffect(()=>{try{yXo(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},L2n="0.0.2939",SZi={version:L2n},v1e=rOt()(sOt(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),QZi=t=>{const[e,n]=X.useState([]),[o,i]=X.useState(null),[r,s]=X.useState(""),[a,A]=uG("eval-version-selection",null),c=v1e(h=>h.setLastRunEvalVersion),l=v1e(h=>h.lastRunEvalVersion);return X.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(h=>h.json()).then(h=>{if(Array.isArray(h?.versions)){let d=[...h.versions];h.tags?.latest&&(i(h.tags.latest),d=d.filter(m=>m!==h.tags.latest)),n(d)}}).catch(()=>{})},[t]),X.useEffect(()=>{t&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,c(a)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,c(o)))},[t,a,o]),{versions:X.useMemo(()=>e.filter(h=>h.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:l,search:r,setSearch:s,selectVersion:h=>{A(h),s("")}}},vZi=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=X.useState(""),[s,a]=X.useState("");if(!o)return null;const A=t.filter(u=>u.toLowerCase().includes(s.toLowerCase())),c=s&&!t.includes(s),l=u=>{u.key==="Enter"&&(A.length===1?r(A[0]):c&&r(s))};return K.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:K.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[K.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),K.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:u=>a(u.target.value),onKeyDown:l}),K.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[A.map(u=>K.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${i===u?"bg-blue-50":""}`,onClick:()=>r(u),children:u},u)),c&&K.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${i===s?"bg-blue-50":""}`,onClick:()=>r(s),children:['Create new "',s,'"']})]}),K.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[K.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),K.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>i&&e(i),disabled:!i,children:i===s?`Create "${i}"`:`Save to ${i}`})]})]})})},wZi=t=>{const e=X.useRef(null),n=Id(o=>o.recentEvents);X.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};var PZi=Object.defineProperty,eQ=(t,e)=>PZi(t,"name",{value:e,configurable:!0}),MZi="AlertDialog",[DZi,i4r]=Vx(MZi,[LCn]),tQ=LCn(),NZi=eQ(t=>{const{__scopeAlertDialog:e,...n}=t,o=tQ(e);return K.jsx(Z_e,{...o,...n,modal:!0})},"AlertDialog");X.forwardRef(eQ(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=tQ(o);return K.jsx(_Ji,{...r,...i,ref:n})},"AlertDialogTrigger"));var RZi=eQ(t=>{const{__scopeAlertDialog:e,...n}=t,o=tQ(e);return K.jsx(e1e,{...o,...n})},"AlertDialogPortal"),H2n=X.forwardRef(eQ(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=tQ(o);return K.jsx(qee,{...r,...i,ref:n})},"AlertDialogOverlay")),TZi="AlertDialogContent",[kZi,FZi]=DZi(TZi),O2n=X.forwardRef(eQ(function(e,n){const{__scopeAlertDialog:o,children:i,...r}=e,s=tQ(o),a=X.useRef(null),A=LA(n,a),c=X.useRef(null);return K.jsx(kZi,{scope:o,cancelRef:c,children:K.jsx(Xee,{role:"alertdialog",...s,...r,ref:A,onOpenAutoFocus:rr(r.onOpenAutoFocus,l=>{l.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:l=>l.preventDefault(),onInteractOutside:l=>l.preventDefault(),children:i})})},"AlertDialogContent")),G2n=X.forwardRef(eQ(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=tQ(o);return K.jsx(t1e,{...r,...i,ref:n})},"AlertDialogTitle")),Y2n=X.forwardRef(eQ(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=tQ(o);return K.jsx(n1e,{...r,...i,ref:n})},"AlertDialogDescription")),U2n=X.forwardRef(eQ(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=tQ(o);return K.jsx(GXe,{...r,...i,ref:n})},"AlertDialogAction")),LZi="AlertDialogCancel",K2n=X.forwardRef(eQ(function(e,n){const{__scopeAlertDialog:o,...i}=e,{cancelRef:r}=FZi(LZi,o),s=tQ(o),a=LA(n,r);return K.jsx(GXe,{...s,...i,ref:a})},"AlertDialogCancel"));const z2n=NZi,HZi=RZi,V2n=X.forwardRef(({className:t,...e},n)=>K.jsx(H2n,{className:Fi("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));V2n.displayName=H2n.displayName;const QZe=X.forwardRef(({className:t,...e},n)=>K.jsxs(HZi,{children:[K.jsx(V2n,{}),K.jsx(O2n,{ref:n,className:Fi("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...e})]}));QZe.displayName=O2n.displayName;const vZe=({className:t,...e})=>K.jsx("div",{className:Fi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});vZe.displayName="AlertDialogHeader";const wZe=({className:t,...e})=>K.jsx("div",{className:Fi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});wZe.displayName="AlertDialogFooter";const PZe=X.forwardRef(({className:t,...e},n)=>K.jsx(G2n,{ref:n,className:Fi("rf-text-lg rf-font-semibold",t),...e}));PZe.displayName=G2n.displayName;const MZe=X.forwardRef(({className:t,...e},n)=>K.jsx(Y2n,{ref:n,className:Fi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));MZe.displayName=Y2n.displayName;const OZi=X.forwardRef(({className:t,...e},n)=>K.jsx(U2n,{ref:n,className:Fi(AK(),t),...e}));OZi.displayName=U2n.displayName;const DZe=X.forwardRef(({className:t,...e},n)=>K.jsx(K2n,{ref:n,className:Fi(AK({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));DZe.displayName=K2n.displayName;var GZi=Object.defineProperty,nQ=(t,e)=>GZi(t,"name",{value:e,configurable:!0}),NZe="Checkbox",[YZi,r4r]=Vx(NZe),[UZi,RZe]=YZi(NZe);function J2n(t){const{__scopeCheckbox:e,checked:n,children:o,defaultChecked:i,disabled:r,form:s,name:a,onCheckedChange:A,required:c,value:l="on",internal_do_not_use_render:u}=t,[g,h]=qB({prop:n,defaultProp:i??!1,onChange:A,caller:NZe}),[d,m]=X.useState(null),[p,f]=X.useState(null),_=X.useRef(!1),[I,C]=X.useReducer(E=>E+1,0),y=d?!!s||!!d.closest("form"):!0,x={checked:g,disabled:r,setChecked:h,control:d,setControl:m,name:a,form:s,value:l,hasConsumerStoppedPropagationRef:_,userInteractionCount:I,onUserInteraction:C,required:c,defaultChecked:oQ(i)?!1:i,isFormControl:y,bubbleInput:p,setBubbleInput:f};return K.jsx(UZi,{scope:e,...x,children:j2n(u)?u(x):o})}nQ(J2n,"CheckboxProvider");var KZi="CheckboxTrigger",zZi=X.forwardRef(nQ(function({__scopeCheckbox:e,onKeyDown:n,onClick:o,...i},r){const{control:s,value:a,disabled:A,checked:c,required:l,setControl:u,setChecked:g,hasConsumerStoppedPropagationRef:h,onUserInteraction:d,isFormControl:m,bubbleInput:p}=RZe(KZi,e),f=LA(r,u),_=X.useRef(c);return X.useEffect(()=>{const I=s?.form;if(I){const C=nQ(()=>g(_.current),"reset");return I.addEventListener("reset",C),()=>I.removeEventListener("reset",C)}},[s,g]),K.jsx(Ra.button,{type:"button",role:"checkbox","aria-checked":oQ(c)?"mixed":c,"aria-required":l,"data-state":TZe(c),"data-disabled":A?"":void 0,disabled:A,value:a,...i,ref:f,onKeyDown:rr(n,I=>{I.key==="Enter"&&I.preventDefault()}),onClick:rr(o,I=>{d(),g(C=>oQ(C)?!0:!C),p&&m&&(h.current=I.isPropagationStopped(),h.current||I.stopPropagation())})})},"CheckboxTrigger")),W2n=X.forwardRef(nQ(function(e,n){const{__scopeCheckbox:o,name:i,checked:r,defaultChecked:s,required:a,disabled:A,value:c,onCheckedChange:l,form:u,...g}=e;return K.jsx(J2n,{__scopeCheckbox:o,checked:r,defaultChecked:s,disabled:A,required:a,onCheckedChange:l,name:i,form:u,value:c,internal_do_not_use_render:({isFormControl:h})=>K.jsxs(K.Fragment,{children:[K.jsx(zZi,{...g,ref:n,__scopeCheckbox:o}),h&&K.jsx(jZi,{__scopeCheckbox:o})]})})},"Checkbox")),VZi="CheckboxIndicator",JZi=X.forwardRef(nQ(function(e,n){const{__scopeCheckbox:o,forceMount:i,...r}=e,s=RZe(VZi,o);return K.jsx(BE,{present:i||oQ(s.checked)||s.checked===!0,children:K.jsx(Ra.span,{"data-state":TZe(s.checked),"data-disabled":s.disabled?"":void 0,...r,ref:n,style:{pointerEvents:"none",...e.style}})})},"CheckboxIndicator")),WZi="CheckboxBubbleInput",jZi=X.forwardRef(nQ(function({__scopeCheckbox:e,onClick:n,...o},i){const{control:r,hasConsumerStoppedPropagationRef:s,userInteractionCount:a,checked:A,defaultChecked:c,required:l,disabled:u,name:g,value:h,form:d,bubbleInput:m,setBubbleInput:p}=RZe(WZi,e),f=LA(i,p),_=xXe(r),I=X.useRef(!1),C=X.useRef(A),y=X.useRef(a);X.useEffect(()=>{const E=m;if(!E)return;const B=window.HTMLInputElement.prototype,Q=Object.getOwnPropertyDescriptor(B,"checked").set,w=a!==y.current;y.current=a;const M=C.current!==A;C.current=A;const T=!(w&&s.current);if(M&&Q){I.current=!w;const R=new Event("click",{bubbles:T});E.indeterminate=oQ(A),Q.call(E,oQ(A)?!1:A),E.dispatchEvent(R),I.current=!1}},[m,A,s,a]);const x=X.useRef(oQ(A)?!1:A);return K.jsx(Ra.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??x.current,required:l,disabled:u,name:g,value:h,form:d,...o,tabIndex:-1,ref:f,onClick:rr(n,E=>{I.current&&E.stopPropagation()}),style:{...o.style,..._,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function j2n(t){return typeof t=="function"}nQ(j2n,"isFunction");function oQ(t){return t==="indeterminate"}nQ(oQ,"isIndeterminate");function TZe(t){return oQ(t)?"indeterminate":t?"checked":"unchecked"}nQ(TZe,"getState");const mte=X.forwardRef(({className:t,...e},n)=>K.jsx(W2n,{ref:n,className:Fi("rf-peer rf-h-4 rf-w-4 rf-shrink-0 rf-rounded-sm rf-border rf-border-zinc-200 rf-border-zinc-900 rf-shadow focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 data-[state=checked]:rf-bg-zinc-900 data-[state=checked]:rf-text-zinc-50 dark:rf-border-zinc-800 dark:rf-border-zinc-50 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=checked]:rf-bg-zinc-50 dark:data-[state=checked]:rf-text-zinc-900",t),...e,children:K.jsx(JZi,{className:Fi("rf-flex rf-items-center rf-justify-center rf-text-current"),children:K.jsx(VS,{className:"rf-h-4 rf-w-4"})})}));mte.displayName=W2n.displayName;const hk=Z_e,qZi=e1e,q2n=X.forwardRef(({className:t,...e},n)=>K.jsx(qee,{className:Fi("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));q2n.displayName=qee.displayName;const mM=X.forwardRef(({className:t,children:e,showOverlay:n=!0,...o},i)=>K.jsxs(qZi,{children:[K.jsx(q2n,{className:Fi(n?"":"rf-hidden")}),K.jsx(Xee,{ref:i,className:Fi("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...o,children:e})]}));mM.displayName=Xee.displayName;const pM=({className:t,...e})=>K.jsx("div",{className:Fi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});pM.displayName="DialogHeader";const MK=({className:t,...e})=>K.jsx("div",{className:Fi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});MK.displayName="DialogFooter";const fM=X.forwardRef(({className:t,...e},n)=>K.jsx(t1e,{ref:n,className:Fi("rf-text-lg rf-font-semibold",t),...e}));fM.displayName=t1e.displayName;const mk=X.forwardRef(({className:t,...e},n)=>K.jsx(n1e,{ref:n,className:Fi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));mk.displayName=n1e.displayName;const w1e={"tscircuit.com":{label:"tscircuit.com",placeholder:"Search tscircuit packages...",emptyMessage:"No packages found"},jlcpcb:{label:"JLCPCB Parts",placeholder:"Search JLCPCB parts (e.g. C14663)...",emptyMessage:"No parts found"},kicad:{label:"KiCad Footprints",placeholder:"Search KiCad footprints...",emptyMessage:"No footprints found"}},$Zi="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let kZe=null;const FZe=async()=>(kZe||(kZe=import($Zi)),kZe),XZi=t=>(e,n)=>{const o=new Headers(n?.headers),i={};return o.forEach((r,s)=>{i[s]=r}),fetch(`${t?.apiBase??UC}/proxy`,{...n,headers:{...i,"X-Target-Url":e.toString(),"X-Sender-Origin":i.origin??"","X-Sender-Host":i.host??"https://easyeda.com","X-Sender-Referer":i.referer??"","X-Sender-User-Agent":i["user-agent"]??"","X-Sender-Cookie":i.cookie??"",authority:i.authority??"","content-type":i["content-type"]??"",...t?.headers}})},ZZi=async(t,e=10)=>{const n=encodeURIComponent(t),o=await fetch(`https://jlcsearch.tscircuit.com/api/search?limit=${e}&q=${n}`);if(!o.ok)throw new Error(`JLCPCB API error: ${o.status}`);return(await o.json()).components??[]},eer=t=>({lcscId:t.lcsc,manufacturer:t.mfr,description:t.description,partNumber:`C${t.lcsc}`,package:t.package,price:t.price,stock:t.stock,isBasic:t.is_basic}),$2n=async(t,e)=>{const{fetchEasyEDAComponent:n}=await FZe();return n(t,{fetch:XZi(e),includeModelMetadata:e?.includeModelMetadata})},ter=async(t,e)=>{const{convertRawEasyToTsx:n}=await FZe(),o=await $2n(t,e);return n({rawEasy:o})},ner=async(t,e)=>{const{EasyEdaJsonSchema:n,convertEasyEdaJsonToCircuitJson:o}=await FZe(),i=await $2n(t,{...e,includeModelMetadata:!1}),r=n.parse(i);return o(r,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function _M(t){return Array.isArray?Array.isArray(t):Z2n(t)==="[object Array]"}function oer(t){if(typeof t=="string")return t;if(typeof t=="bigint")return t.toString();const e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function LZe(t){return t==null?"":oer(t)}function XC(t){return typeof t=="string"}function P1e(t){return typeof t=="number"}function ier(t){return t===!0||t===!1||rer(t)&&Z2n(t)=="[object Boolean]"}function X2n(t){return typeof t=="object"}function rer(t){return X2n(t)&&t!==null}function ZE(t){return t!=null}function M1e(t){return!t.trim().length}function Z2n(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const ser="Incorrect 'index' type",HZe="Invalid doc index: must be a non-negative integer within the bounds of the docs array",aer=t=>`Invalid value for key ${t}`,Aer=t=>`Pattern length exceeds max of ${t}.`,cer=t=>`Missing ${t} property in key`,ler=t=>`Property 'weight' in key '${t}' must be a positive integer`,uer="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",exn=Object.prototype.hasOwnProperty;var ger=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(n=>{const o=txn(n);this._keys.push(o),this._keyMap[o.id]=o,e+=o.weight}),this._keys.forEach(n=>{n.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function txn(t){let e=null,n=null,o=null,i=1,r=null;if(XC(t)||_M(t))o=t,e=nxn(t),n=D1e(t);else{if(!exn.call(t,"name"))throw new Error(cer("name"));const s=t.name;if(o=s,exn.call(t,"weight")&&t.weight!==void 0&&(i=t.weight,i<=0))throw new Error(ler(D1e(s)));e=nxn(s),n=D1e(s),r=t.getFn??null}return{path:e,id:n,weight:i,src:o,getFn:r}}function nxn(t){return _M(t)?t:t.split(".")}function D1e(t){return _M(t)?t.join("."):t}function der(t,e){const n=[];let o=!1;const i=(r,s,a,A)=>{if(ZE(r))if(!s[a])n.push(A!==void 0?{v:r,i:A}:r);else{const c=r[s[a]];if(!ZE(c))return;if(a===s.length-1&&(XC(c)||P1e(c)||ier(c)||typeof c=="bigint"))n.push(A!==void 0?{v:LZe(c),i:A}:LZe(c));else if(_M(c)){o=!0;for(let l=0,u=c.length;l<u;l+=1)i(c[l],s,a+1,l)}else s.length&&i(c,s,a+1,A)}};return i(t,XC(e)?e.split("."):e,0),o?n:n[0]}const Pa=Object.freeze({...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:der,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function her(t){return t>=9&&t<=13||t===32||t===160}function mer(t=1,e=3){const n=new Map,o=Math.pow(10,e);return{get(i){let r=0,s=!1;for(let A=0;A<i.length;A++)her(i.charCodeAt(A))?s=!1:s||(r++,s=!0);if(r===0&&(r=1),n.has(r))return n.get(r);const a=Math.round(o/Math.pow(r,.5*t))/o;return n.set(r,a),a},clear(){n.clear()}}}var OZe=class{constructor({getFn:t=Pa.getFn,fieldNormWeight:e=Pa.fieldNormWeight}={}){this.norm=mer(e,3),this.getFn=t,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,n)=>{this._keysMap[e.id]=n})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const t=this.docs.length;this.records=new Array(t);let e=0;if(XC(this.docs[0]))for(let n=0;n<t;n++){const o=this._createStringRecord(this.docs[n],n);o&&(this.records[e++]=o)}else for(let n=0;n<t;n++)this.records[e++]=this._createObjectRecord(this.docs[n],n);this.records.length=e,this.norm.clear()}add(t,e){if(!Number.isInteger(e)||e<0)throw new Error(HZe);if(XC(t)){const o=this._createStringRecord(t,e);return o&&this.records.push(o),o}const n=this._createObjectRecord(t,e);return this.records.push(n),n}removeAt(t){if(!Number.isInteger(t)||t<0)throw new Error(HZe);for(let e=0,n=this.records.length;e<n;e+=1)if(this.records[e].i===t){this.records.splice(e,1);break}for(let e=0,n=this.records.length;e<n;e+=1)this.records[e].i>t&&(this.records[e].i-=1)}removeAll(t){const e=new Set;for(const o of t)Number.isInteger(o)&&o>=0&&e.add(o);if(e.size===0)return;this.records=this.records.filter(o=>!e.has(o.i));const n=Array.from(e).sort((o,i)=>o-i);for(const o of this.records){let i=0,r=n.length;for(;i<r;){const s=i+r>>>1;n[s]<o.i?i=s+1:r=s}o.i-=i}}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_createStringRecord(t,e){return!ZE(t)||M1e(t)?null:{v:t,i:e,n:this.norm.get(t)}}_createObjectRecord(t,e){const n={i:e,$:{}};for(let o=0,i=this.keys.length;o<i;o++){const r=this.keys[o],s=r.getFn?r.getFn(t):this.getFn(t,r.path);if(ZE(s)){if(_M(s)){const a=[];for(let A=0,c=s.length;A<c;A+=1){const l=s[A];if(ZE(l)){if(XC(l)){if(!M1e(l)){const u={v:l,i:A,n:this.norm.get(l)};a.push(u)}}else if(ZE(l.v)){const u=XC(l.v)?l.v:LZe(l.v);if(!M1e(u)){const g={v:u,i:l.i,n:this.norm.get(u)};a.push(g)}}}}n.$[o]=a}else if(XC(s)&&!M1e(s)){const a={v:s,n:this.norm.get(s)};n.$[o]=a}}}return n}toJSON(){return{keys:this.keys.map(({getFn:t,...e})=>e),records:this.records}}};function oxn(t,e,{getFn:n=Pa.getFn,fieldNormWeight:o=Pa.fieldNormWeight}={}){const i=new OZe({getFn:n,fieldNormWeight:o});return i.setKeys(t.map(txn)),i.setSources(e),i.create(),i}function per(t,{getFn:e=Pa.getFn,fieldNormWeight:n=Pa.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new OZe({getFn:e,fieldNormWeight:n});return r.setKeys(o),r.setIndexRecords(i),r}function fer(t=[],e=Pa.minMatchCharLength){const n=[];let o=-1,i=-1,r=0;for(let s=t.length;r<s;r+=1){const a=t[r];a&&o===-1?o=r:!a&&o!==-1&&(i=r-1,i-o+1>=e&&n.push([o,i]),o=-1)}return t[r-1]&&r-o>=e&&n.push([o,r-1]),n}function _er(t,e,n,{location:o=Pa.location,distance:i=Pa.distance,threshold:r=Pa.threshold,findAllMatches:s=Pa.findAllMatches,minMatchCharLength:a=Pa.minMatchCharLength,includeMatches:A=Pa.includeMatches,ignoreLocation:c=Pa.ignoreLocation}={}){if(e.length>32)throw new Error(Aer(32));const l=e.length,u=t.length,g=Math.max(0,Math.min(o,u));let h=r,d=g;const m=(S,Q)=>{const w=S/l;if(c)return w;const M=Math.abs(g-Q);return i?w+M/i:M?1:w},p=a>1||A,f=p?Array(u):[];let _;for(;(_=t.indexOf(e,d))>-1;){const S=m(0,_);if(h=Math.min(S,h),d=_+l,p){let Q=0;for(;Q<l;)f[_+Q]=1,Q+=1}}d=-1;let I=[],C=1,y=0,x=l+u;const E=1<<l-1;for(let S=0;S<l;S+=1){let Q=0,w=x;for(;Q<w;)m(S,g+w)<=h?Q=w:x=w,w=Math.floor((x-Q)/2+Q);x=w;let M=Math.max(1,g-w+1);const T=s?u:Math.min(g+w,u)+l,R=Array(T+2);R[T+1]=(1<<S)-1;for(let F=T;F>=M;F-=1){const O=F-1,U=n[t[O]];if(R[F]=(R[F+1]<<1|1)&U,S&&(R[F]|=(I[F+1]|I[F])<<1|1|I[F+1]),R[F]&E&&(C=m(S,O),C<=h)){if(h=C,d=O,y=S,d<=g)break;M=Math.max(1,2*g-d)}}if(m(S+1,g)>h)break;I=R}if(p&&d>=0){const S=Math.min(u-1,d+l-1+y);for(let Q=d;Q<=S;Q+=1)n[t[Q]]&&(f[Q]=1)}const B={isMatch:d>=0,score:Math.max(.001,C)};if(p){const S=fer(f,a);S.length?A&&(B.indices=S):B.isMatch=!1}return B}function Ier(t){const e={};for(let n=0,o=t.length;n<o;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<o-n-1}return e}function GZe(t){if(t.length<=1)return t;t.sort((n,o)=>n[0]-o[0]||n[1]-o[1]);const e=[t[0]];for(let n=1,o=t.length;n<o;n+=1){const i=e[e.length-1],r=t[n];r[0]<=i[1]+1?i[1]=Math.max(i[1],r[1]):e.push(r)}return e}const ixn={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},Cer=new RegExp("["+Object.keys(ixn).join("")+"]","g"),pte=typeof String.prototype.normalize=="function"?t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(Cer,e=>ixn[e]):t=>t;var YZe=class{constructor(t,{location:e=Pa.location,threshold:n=Pa.threshold,distance:o=Pa.distance,includeMatches:i=Pa.includeMatches,findAllMatches:r=Pa.findAllMatches,minMatchCharLength:s=Pa.minMatchCharLength,isCaseSensitive:a=Pa.isCaseSensitive,ignoreDiacritics:A=Pa.ignoreDiacritics,ignoreLocation:c=Pa.ignoreLocation}={}){if(this.options={location:e,threshold:n,distance:o,includeMatches:i,findAllMatches:r,minMatchCharLength:s,isCaseSensitive:a,ignoreDiacritics:A,ignoreLocation:c},t=a?t:t.toLowerCase(),t=A?pte(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const l=(g,h)=>{this.chunks.push({pattern:g,alphabet:Ier(g),startIndex:h})},u=this.pattern.length;if(u>32){let g=0;const h=u%32,d=u-h;for(;g<d;)l(this.pattern.substr(g,32),g),g+=32;if(h){const m=u-32;l(this.pattern.substr(m),m)}}else l(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o}=this.options;if(t=e?t:t.toLowerCase(),t=n?pte(t):t,this.pattern===t){if(t.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const d={isMatch:!0,score:0};return o&&(d.indices=[[0,t.length-1]]),d}const{location:i,distance:r,threshold:s,findAllMatches:a,minMatchCharLength:A,ignoreLocation:c}=this.options,l=[];let u=0,g=!1;this.chunks.forEach(({pattern:d,alphabet:m,startIndex:p})=>{const{isMatch:f,score:_,indices:I}=_er(t,d,m,{location:i+p,distance:r,threshold:s,findAllMatches:a,minMatchCharLength:A,includeMatches:o,ignoreLocation:c});f&&(g=!0),u+=_,f&&I&&l.push(...I)});const h={isMatch:g,score:g?u/this.chunks.length:1};return g&&o&&(h.indices=GZe(l)),h}};const yer=new Set(["fuzzy","include"]);function xer(t){return t.startsWith("inverse")}const UZe=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:t=>({type:"exact",search(e){const n=e===t;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:t=>({type:"include",search(e){let n=0,o;const i=[],r=t.length;for(;(o=e.indexOf(t,n))>-1;)n=o+r,i.push([o,n-1]);const s=!!i.length;return{isMatch:s,score:s?0:1,indices:i}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:t=>({type:"prefix-exact",search(e){const n=e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:t=>({type:"inverse-prefix-exact",search(e){const n=!e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:t=>({type:"inverse-suffix-exact",search(e){const n=!e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:t=>({type:"suffix-exact",search(e){const n=e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[e.length-t.length,e.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:t=>({type:"inverse-exact",search(e){const n=e.indexOf(t)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(t,e={})=>{const n=new YZe(t,{location:e.location??Pa.location,threshold:e.threshold??Pa.threshold,distance:e.distance??Pa.distance,includeMatches:e.includeMatches??Pa.includeMatches,findAllMatches:e.findAllMatches??Pa.findAllMatches,minMatchCharLength:e.minMatchCharLength??Pa.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??Pa.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??Pa.ignoreDiacritics,ignoreLocation:e.ignoreLocation??Pa.ignoreLocation});return{type:"fuzzy",search(o){return n.searchIn(o)}}}}],rxn=UZe.length,Eer="\0",Ber="|";function ber(t){const e=[],n=t.length;let o=0;for(;o<n;){for(;o<n&&t[o]===" ";)o++;if(o>=n)break;let i=o;for(;i<n&&t[i]!==" "&&t[i]!=='"';)i++;if(i<n&&t[i]==='"'){for(i++;i<n;){if(t[i]==='"'){const r=i+1;if(r>=n||t[r]===" "){i++;break}if(t[r]==="$"&&(r+1>=n||t[r+1]===" ")){i+=2;break}}i++}e.push(t.substring(o,i)),o=i}else{for(;i<n&&t[i]!==" ";)i++;e.push(t.substring(o,i)),o=i}}return e}function sxn(t,e){const n=t.match(e);return n?n[1]:null}function Ser(t,e={}){return t.replace(/\\\|/g,Eer).split(Ber).map(n=>{const o=ber(n.replace(/\u0000/g,"|").trim()).filter(r=>r&&!!r.trim()),i=[];for(let r=0,s=o.length;r<s;r+=1){const a=o[r];let A=!1,c=-1;for(;!A&&++c<rxn;){const l=UZe[c],u=sxn(a,l.multiRegex);u&&(i.push(l.create(u,e)),A=!0)}if(!A)for(c=-1;++c<rxn;){const l=UZe[c],u=sxn(a,l.singleRegex);if(u){i.push(l.create(u,e));break}}}return i})}var Qer=class{constructor(t,{isCaseSensitive:e=Pa.isCaseSensitive,ignoreDiacritics:n=Pa.ignoreDiacritics,includeMatches:o=Pa.includeMatches,minMatchCharLength:i=Pa.minMatchCharLength,ignoreLocation:r=Pa.ignoreLocation,findAllMatches:s=Pa.findAllMatches,location:a=Pa.location,threshold:A=Pa.threshold,distance:c=Pa.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o,minMatchCharLength:i,findAllMatches:s,ignoreLocation:r,location:a,threshold:A,distance:c},t=e?t:t.toLowerCase(),t=n?pte(t):t,this.pattern=t,this.query=Ser(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:o,ignoreDiacritics:i}=this.options;t=o?t:t.toLowerCase(),t=i?pte(t):t;let r=0;const s=[];let a=0,A=!1;for(let c=0,l=e.length;c<l;c+=1){const u=e[c];s.length=0,r=0,A=!1;for(let g=0,h=u.length;g<h;g+=1){const d=u[g],{isMatch:m,indices:p,score:f}=d.search(t);if(m)r+=1,a+=f,xer(d.type)&&(A=!0),n&&(yer.has(d.type)?s.push(...p):s.push(p));else{a=0,r=0,s.length=0,A=!1;break}}if(r){const g={isMatch:!0,score:a/r};return A&&(g.hasInverse=!0),n&&(g.indices=GZe(s)),g}}return{isMatch:!1,score:1}}};const KZe=[];function zZe(...t){KZe.push(...t)}function N1e(t,e){for(let n=0,o=KZe.length;n<o;n+=1){const i=KZe[n];if(i.condition(t,e))return new i(t,e)}return new YZe(t,e)}const R1e={AND:"$and",OR:"$or"},VZe={PATH:"$path",PATTERN:"$val"},JZe=t=>!!(t[R1e.AND]||t[R1e.OR]),ver=t=>!!t[VZe.PATH],wer=t=>!_M(t)&&X2n(t)&&!JZe(t),axn=t=>({[R1e.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function Axn(t,e,{auto:n=!0}={}){const o=i=>{if(XC(i)){const A={keyId:null,pattern:i};return n&&(A.searcher=N1e(i,e)),A}const r=Object.keys(i),s=ver(i);if(!s&&r.length>1&&!JZe(i))return o(axn(i));if(wer(i)){const A=s?i[VZe.PATH]:r[0],c=s?i[VZe.PATTERN]:i[A];if(!XC(c))throw new Error(aer(A));const l={keyId:D1e(A),pattern:c};return n&&(l.searcher=N1e(c,e)),l}const a={children:[],operator:r[0]};return r.forEach(A=>{const c=i[A];_M(c)&&c.forEach(l=>{a.children.push(o(l))})}),a};return JZe(t)||(t=axn(t)),o(t)}function WZe(t,{ignoreFieldNorm:e=Pa.ignoreFieldNorm}){let n=1;return t.forEach(({key:o,norm:i,score:r})=>{const s=o?o.weight:null;n*=Math.pow(r===0&&s?Number.EPSILON:r,(s||1)*(e?1:i))}),n}function Per(t,{ignoreFieldNorm:e=Pa.ignoreFieldNorm}){t.forEach(n=>{n.score=WZe(n.matches,{ignoreFieldNorm:e})})}var Mer=class{constructor(t,e){this.limit=t,this.heap=[],this.comparator=e}get size(){return this.heap.length}insert(t){this.size<this.limit?(this.heap.push(t),this._bubbleUp(this.size-1)):this.comparator(t,this.heap[0])<0&&(this.heap[0]=t,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(t){const e=this.heap;for(;t>0;){const n=t-1>>1;if(this.comparator(e[t],e[n])<=0)break;const o=e[t];e[t]=e[n],e[n]=o,t=n}}_sinkDown(t){const e=this.heap,n=e.length;let o=t;do{t=o;const i=2*t+1,r=2*t+2;if(i<n&&this.comparator(e[i],e[o])>0&&(o=i),r<n&&this.comparator(e[r],e[o])>0&&(o=r),o!==t){const s=e[t];e[t]=e[o],e[o]=s}}while(o!==t)}};function Der(t){const e=[];return t.matches.forEach(n=>{if(!ZE(n.indices)||!n.indices.length)return;const o={indices:n.indices,value:n.value};n.key&&(o.key=n.key.id),n.idx>-1&&(o.refIndex=n.idx),e.push(o)}),e}function Ner(t,e,{includeMatches:n=Pa.includeMatches,includeScore:o=Pa.includeScore}={}){return t.map(i=>{const{idx:r}=i,s={item:e[r],refIndex:r};return n&&(s.matches=Der(i)),o&&(s.score=i.score),s})}const Rer=/[\p{L}\p{M}\p{N}_]+/gu,cxn=new WeakSet;function Ter(t){cxn.has(t)||(cxn.add(t),console.warn(`[Fuse] tokenize regex ${t} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function ker(t){if(typeof t=="function"){let e=!1;return n=>{const o=t(n);if(!e&&(e=!0,!Array.isArray(o)||o.some(i=>typeof i!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(o)?"array containing non-strings":typeof o}.`);return o}}return t instanceof RegExp?(t.global||Ter(t),e=>e.match(t)||[]):e=>e.match(Rer)||[]}function jZe({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const o=ker(n);return{tokenize(i){return t||(i=i.toLowerCase()),e&&(i=pte(i)),o(i)}}}var Fer=class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=jZe({isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,tokenize:e.tokenize});const n=this.analyzer.tokenize(t),{df:o,fieldCount:i}=e._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const r of n){this.termSearchers.push(new YZe(r,{location:e.location,threshold:e.threshold,distance:e.distance,includeMatches:e.includeMatches,findAllMatches:e.findAllMatches,minMatchCharLength:e.minMatchCharLength,isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,ignoreLocation:!0}));const s=o.get(r)||0,a=Math.log(1+(i-s+.5)/(s+.5));this.idfWeights.push(a)}this.combineAll=e.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(t){if(!this.termSearchers.length)return{isMatch:!1,score:1};const e=[];let n=0,o=0,i=0,r=0;const s=this.combineAll&&!this.useMask?new Set:null;for(let c=0;c<this.termSearchers.length;c++){const l=this.termSearchers[c].searchIn(t),u=this.idfWeights[c];o+=u,l.isMatch&&(i++,n+=u*(1-l.score),l.indices&&e.push(...l.indices),this.combineAll&&(this.useMask?r|=1<<c:s.add(c)))}if(i===0)return{isMatch:!1,score:1};const a=o>0?1-n/o:0,A={isMatch:!0,score:Math.max(.001,a)};return this.options.includeMatches&&e.length&&(A.indices=GZe(e)),this.combineAll&&(this.useMask?A.matchedMask=r:A.matchedTerms=s,A.termCount=this.numTerms),A}};function qZe(t,e,n,o){const i=o.tokenize(e);if(!i.length)return;t.fieldCount++,t.docFieldCount.set(n,(t.docFieldCount.get(n)||0)+1);const r=new Set(i);let s=t.docTermFieldHits.get(n);s||(s=new Map,t.docTermFieldHits.set(n,s));for(const a of r)s.set(a,(s.get(a)||0)+1),t.df.set(a,(t.df.get(a)||0)+1)}function lxn(t,e,n,o){const{i,v:r,$:s}=e;if(r!==void 0){qZe(t,r,i,o);return}if(s)for(let a=0;a<n;a++){const A=s[a];if(A)if(Array.isArray(A))for(const c of A)qZe(t,c.v,i,o);else qZe(t,A.v,i,o)}}function Ler(t,e,n){const o={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const i of t)lxn(o,i,e,n);return o}function Her(t,e,n,o){lxn(t,e,n,o)}function Oer(t,e){const n=t.docFieldCount.get(e);if(n===void 0)return;t.fieldCount-=n,t.docFieldCount.delete(e);const o=t.docTermFieldHits.get(e);if(o){for(const[i,r]of o){const s=(t.df.get(i)||0)-r;s<=0?t.df.delete(i):t.df.set(i,s)}t.docTermFieldHits.delete(e)}}function uxn(t,e){if(e.length===0)return;const n=Array.from(new Set(e)).sort((a,A)=>a-A);for(const a of n)Oer(t,a);const o=a=>{let A=0,c=n.length;for(;A<c;){const l=A+c>>>1;n[l]<a?A=l+1:c=l}return a-A},i=n[0],r=new Map;for(const[a,A]of t.docFieldCount)r.set(a>i?o(a):a,A);t.docFieldCount=r;const s=new Map;for(const[a,A]of t.docTermFieldHits)s.set(a>i?o(a):a,A);t.docTermFieldHits=s}var IM=class{constructor(t,e,n){this.options={...Pa,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new ger(this.options.keys),this._docs=t,this._myIndex=null,this._invertedIndex=null,this.setCollection(t,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(t){if(this._lastQuery===t)return this._lastSearcher;const e=N1e(t,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=t,this._lastSearcher=e,e}setCollection(t,e){if(this._docs=t,e&&!(e instanceof OZe))throw new Error(ser);if(this._myIndex=e||oxn(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const n=jZe({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=Ler(this._myIndex.records,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}add(t){if(!ZE(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const n=jZe({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});Her(this._invertedIndex,e,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}remove(t=()=>!1){const e=[],n=[];for(let o=0,i=this._docs.length;o<i;o+=1)t(this._docs[o],o)&&(e.push(this._docs[o]),n.push(o));if(n.length){this._invertedIndex&&uxn(this._invertedIndex,n);const o=new Set(n);this._docs=this._docs.filter((i,r)=>!o.has(r)),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return e}removeAt(t){if(!Number.isInteger(t)||t<0||t>=this._docs.length)throw new Error(HZe);this._invertedIndex&&uxn(this._invertedIndex,[t]);const e=this._docs.splice(t,1)[0];return this._myIndex.removeAt(t),this._invalidateSearcherCache(),e}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(t=>this._keyStore.get(t.id)||t)}search(t,e){const{limit:n=-1}=e||{},{includeMatches:o,includeScore:i,shouldSort:r,sortFn:s,ignoreFieldNorm:a}=this.options;if(XC(t)&&!t.trim()){let g=this._docs.map((h,d)=>({item:h,refIndex:d}));return P1e(n)&&n>-1&&(g=g.slice(0,n)),g}const A=r&&P1e(n)&&n>0&&XC(t),c=s,l=(g,h)=>c(g,h)||g.idx-h.idx;let u;if(A){const g=new Mer(n,l);XC(this._docs[0])?this._searchStringList(t,{heap:g,ignoreFieldNorm:a}):this._searchObjectList(t,{heap:g,ignoreFieldNorm:a}),u=g.extractSorted()}else u=XC(t)?XC(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),Per(u,{ignoreFieldNorm:a}),r&&u.sort(XC(t)?l:c),P1e(n)&&n>-1&&(u=u.slice(0,n));return Ner(u,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,s=e?null:[];return r.forEach(({v:a,i:A,n:c})=>{if(!ZE(a))return;const l=o.searchIn(a);if(l.isMatch){const u={score:l.score,value:a,norm:c,indices:l.indices};i&&(u.matchedMask=l.matchedMask,u.matchedTerms=l.matchedTerms,u.termCount=l.termCount);const g=[u];if(!i||this._coversAllTokens(g)){const h={item:a,idx:A,matches:g};e?(h.score=WZe(h.matches,{ignoreFieldNorm:n}),e.insert(h)):s.push(h)}}}),s}_searchLogical(t){const e=Axn(t,this.options),n=this._normalizedKeys(),o=(a,A,c)=>{if(!("children"in a)){const{keyId:h,searcher:d}=a;let m;return h===null?(m=[],n.forEach((p,f)=>{m.push(...this._findMatches({key:p,value:A[f],searcher:d}))})):m=this._findMatches({key:this._keyStore.get(h),value:this._myIndex.getValueForItemAtKeyId(A,h),searcher:d}),m&&m.length?[{idx:c,item:A,matches:m}]:[]}const{children:l,operator:u}=a,g=[];for(let h=0,d=l.length;h<d;h+=1){const m=l[h],p=o(m,A,c);if(p.length)g.push(...p);else if(u===R1e.AND)return[]}return g},i=this._myIndex.records,r=new Map,s=[];return i.forEach(({$:a,i:A})=>{if(ZE(a)){const c=o(e,a,A);c.length&&(r.has(A)||(r.set(A,{idx:A,item:a,matches:[]}),s.push(r.get(A))),c.forEach(({matches:l})=>{r.get(A).matches.push(...l)}))}}),s}_searchObjectList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,s=this._normalizedKeys(),a=e?null:[];return r.forEach(({$:A,i:c})=>{if(!ZE(A))return;const l=[];let u=!1,g=!1;if(s.forEach((h,d)=>{const m=this._findMatches({key:h,value:A[d],searcher:o});m.length?(l.push(...m),m[0].hasInverse&&(g=!0)):u=!0}),!(g&&u)&&l.length&&(!i||this._coversAllTokens(l))){const h={idx:c,item:A,matches:l};e?(h.score=WZe(h.matches,{ignoreFieldNorm:n}),e.insert(h)):a.push(h)}}),a}_findMatches({key:t,value:e,searcher:n}){if(!ZE(e))return[];const o=[];if(_M(e))e.forEach(({v:i,i:r,n:s})=>{if(!ZE(i))return;const a=n.searchIn(i);if(a.isMatch){const A={score:a.score,key:t,value:i,idx:r,norm:s,indices:a.indices,hasInverse:a.hasInverse};a.termCount!==void 0&&(A.matchedMask=a.matchedMask,A.matchedTerms=a.matchedTerms,A.termCount=a.termCount),o.push(A)}});else{const{v:i,n:r}=e,s=n.searchIn(i);if(s.isMatch){const a={score:s.score,key:t,value:i,norm:r,indices:s.indices,hasInverse:s.hasInverse};s.termCount!==void 0&&(a.matchedMask=s.matchedMask,a.matchedTerms=s.matchedTerms,a.termCount=s.termCount),o.push(a)}}return o}_coversAllTokens(t){const e=t.length?t[0].termCount:void 0;if(e===void 0)return!0;if(e<=31){let o=0;for(let i=0;i<t.length;i++)o|=t[i].matchedMask||0;return o===2**e-1}const n=new Set;for(let o=0;o<t.length;o++){const i=t[o].matchedTerms;if(i)for(const r of i)n.add(r)}return n.size===e}};IM.version="7.5.0",IM.createIndex=oxn,IM.parseIndex=per,IM.config=Pa,IM.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error(uer);return N1e(t,{...Pa,...n}).searchIn(e)},IM.parseQuery=Axn,zZe(Qer),zZe(Fer),IM.use=function(...t){t.forEach(e=>zZe(e))};var Ger=IM;const Yer="https://kicad-mod-cache.tscircuit.com";let $Ze=null,fte=null,XZe=null;const Uer=async()=>$Ze||fte||(fte=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>($Ze=t,fte=null,t)),fte),Ker=async(t,e=20)=>{const n=await Uer();return XZe||(XZe=new Ger(n)),XZe.search(t).slice(0,e).map(o=>o.item)},zer=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},Ver=t=>t.replace(/^\/+/,"").split("/").map(e=>encodeURIComponent(e)).join("/"),Jer=async t=>{const e=await fetch(`${Yer}/${Ver(t)}`);if(!e.ok)throw new Error(`KiCad footprint fetch failed: ${e.status}`);const n=await e.text(),{KicadFootprintToCircuitJsonConverter:o}=await $E("kicad-to-circuit-json"),i=new o;return i.addFile(t.split("/").pop()??"selected-footprint.kicad_mod",n),i.runUntilFinished(),i.getOutput()},gxn=t=>t?.source==="jlcpcb"||t?.source==="kicad",Wer=async(t,e)=>{if(t.source==="jlcpcb")return ner(t.component.partNumber,e?.jlcpcb);if(t.source==="kicad")return Jer(t.footprint.path);throw new Error("Footprint preview is not available for this source")},jer=({query:t,placeholder:e,isSearching:n,onQueryChange:o,onSubmit:i})=>{const r=X.useCallback(s=>{s.key==="Enter"&&(s.preventDefault(),i())},[i]);return K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[K.jsxs("div",{className:"rf-relative rf-flex-grow",children:[K.jsx(Z$e,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),K.jsx(fZe,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:s=>o(s.target.value),onKeyDown:r})]}),K.jsx(IA,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?K.jsx(VE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):K.jsxs(K.Fragment,{children:[K.jsx(Z$e,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),K.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},qer=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),$er=t=>qer.format(t),dxn=t=>{switch(t.source){case"tscircuit.com":{const e=t.package;return`tscircuit-${e.package_id??`${e.org_owner_tscircuit_handle??"unknown"}-${e.unscoped_name??e.name??"package"}`}`}case"jlcpcb":return`jlc-${t.component.lcscId}`;case"kicad":return`kicad-${t.footprint.path}`;default:return"unknown"}},Xer=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.isDirectLookup?t.component.partNumber:t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},Zer=t=>{switch(t.source){case"tscircuit.com":return t.package.description||(t.package.org_owner_tscircuit_handle?`Component by ${t.package.org_owner_tscircuit_handle}`:void 0);case"jlcpcb":return t.component.description;case"kicad":return t.footprint.description}},etr=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.isDirectLookup?void 0:t.component.partNumber;case"kicad":return}},ttr=({results:t,selected:e,onSelect:n,onShowDetails:o})=>{const i=e?dxn(e):null;return K.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(r=>{const s=dxn(r),a=i===s,A=Xer(r),c=Zer(r),l=etr(r),u=r.source==="jlcpcb"?r.component.stock:null,g=r.source==="jlcpcb"?r.component.price:null,h=r.source==="jlcpcb"?r.component.isBasic:null,d=r.source==="jlcpcb"?r.component.isDirectLookup:!1;return K.jsxs("div",{className:`rf-p-3 rf-flex rf-flex-col sm:rf-grid sm:rf-grid-cols-[minmax(0,1fr)_auto] rf-items-start sm:rf-items-center rf-cursor-pointer hover:rf-bg-zinc-100 rf-gap-2 rf-overflow-hidden ${a?"rf-bg-zinc-100":""}`,onClick:()=>n(r),children:[K.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[K.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[K.jsxs("div",{className:"rf-font-medium rf-text-sm rf-truncate rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-gap-1.5",children:[A,r.source==="jlcpcb"&&h!=null&&K.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${h?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:h?"Basic":"Extended"}),d&&K.jsx("span",{className:"rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 rf-bg-blue-100 rf-text-blue-700",children:"Direct lookup"}),r.source==="tscircuit.com"&&r.package.is_private&&K.jsx(cKi,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),r.source==="jlcpcb"&&u!=null?K.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[u.toLocaleString()," in stock"]}):null]}),K.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[l?K.jsx("span",{className:"rf-mr-2",children:l}):null,c]})]}),K.jsxs("div",{children:[r.source==="tscircuit.com"&&o?K.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:K.jsx(IA,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:m=>{m.stopPropagation(),o(r)},children:"See Details"})}):r.source==="jlcpcb"&&u!=null?K.jsxs("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0",children:[u.toLocaleString()," in stock"]}):null,g!=null&&K.jsx("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 rf-text-right",children:$er(g)})]})]},s)})})},ntr=({circuitJson:t,error:e,isLoading:n,height:o})=>K.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:o},children:n?K.jsxs("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-gap-2 rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:[K.jsx(VE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):e?K.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-p-4",style:{height:o},children:K.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[K.jsx(X$e,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),K.jsx("span",{children:e})]})}):t?K.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:K.jsx(j$e,{circuitJson:t,height:o,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):K.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:"No preview"})}),hxn={importComponentDialog:101,importComponentDetailsDialog:102},otr=({packageResult:t,isOpen:e,onOpenChange:n,isLoading:o,details:i,previewTab:r,onPreviewTabChange:s,isSubmitting:a,onImport:A})=>{const c=t?.package??null,l=c?.latest_pcb_preview_image_url,u=c?.latest_sch_preview_image_url,g=c?.latest_cad_preview_image_url,h=c?.unscoped_name?.split("/").pop()??c?.unscoped_name,d=c?.org_owner_tscircuit_handle??void 0,m=d?`https://tscircuit.com/${d}`:void 0,p=d&&h?`https://tscircuit.com/${d}/${h}`:void 0;return K.jsx(hk,{open:e,onOpenChange:n,children:K.jsxs(mM,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:hxn.importComponentDetailsDialog},className:"rf-max-w-5xl no-scrollbar !rf-overflow-y-auto rf-max-h-[90vh] rf-overflow-hidden rf-flex rf-flex-col rf-rounded-sm",children:[K.jsx(pM,{className:"rf-pb-4 rf-border-b",children:K.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:K.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[K.jsx(fM,{className:"rf-text-xl rf-font-semibold rf-truncate",children:h}),K.jsx(mk,{children:c?.description})]})})}),K.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[d?K.jsxs("div",{children:[K.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),K.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:m?K.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:d}):d})]}):null,(g||l||u)&&K.jsx(K.Fragment,{children:K.jsxs("div",{children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),K.jsxs(DTe,{value:r,onValueChange:f=>s(f),children:[K.jsxs(Ude,{className:"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",children:[l&&K.jsx(k7,{value:"pcb",children:"PCB"}),u&&K.jsx(k7,{value:"schematic",children:"Schematic"}),g&&K.jsx(k7,{value:"3d",children:"3D"})]}),K.jsxs("div",{className:"rf-mt-4",children:[K.jsx(bI,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:l?K.jsx("img",{src:l,alt:`${h??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),K.jsx(bI,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?K.jsx("img",{src:u,alt:`${h??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),K.jsx(bI,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:g?K.jsx("img",{src:g,alt:`${h??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?K.jsxs("section",{children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),K.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:K.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?K.jsxs("section",{children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),K.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:K.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,o?K.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[K.jsx(VE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),K.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),K.jsxs(MK,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[K.jsx("div",{className:"rf-flex-1",children:p?K.jsxs(IA,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(p,"_blank"),children:[K.jsx(nKi,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),K.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[K.jsx(IA,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),K.jsx(IA,{onClick:A,disabled:a,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:a?K.jsx(VE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},itr=()=>{const[t,e]=X.useState(null),[n,o]=X.useState(!1),i=X.useCallback(async(s,a)=>{o(!0);try{const A=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${s}/${a}`)}`);if(!A.ok)throw new Error(`Failed to load package details: ${A.status}`);const c=await A.json();e(c.package??null)}catch(A){console.error("Failed to fetch package details",A),e(null)}finally{o(!1)}},[]),r=X.useCallback(()=>{e(null),o(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:r}},rtr=(t,e)=>{const[n,o]=X.useState({circuitJson:null,error:null,isLoading:!1});return X.useEffect(()=>{if(!t||!gxn(t)){o({circuitJson:null,error:null,isLoading:!1});return}let i=!1;return o({circuitJson:null,error:null,isLoading:!0}),Wer(t,e).then(r=>{i||o({circuitJson:r,error:null,isLoading:!1})}).catch(r=>{i||o({circuitJson:null,error:r instanceof Error?r.message:"Failed to load footprint preview",isLoading:!1})}),()=>{i=!0}},[t,e]),n},str=async(t,e)=>{const n={"Content-Type":"application/json"};e&&(n.Authorization=`Bearer ${e}`);const o=await fetch("https://registry-api.tscircuit.com/packages/search",{method:"POST",headers:n,body:JSON.stringify({query:t})});if(!o.ok)throw new Error(`tscircuit registry error: ${o.status}`);return(await o.json()).packages??[]},atr=({sessionToken:t})=>{const[e,n]=X.useState([]),[o,i]=X.useState(!1),[r,s]=X.useState(null),[a,A]=X.useState(!1),c=X.useCallback(async u=>{const g=u.trim();if(!g)return[];i(!0),s(null);try{const d=(await str(g,t)).map(m=>({source:"tscircuit.com",package:m}));return n(d),d}catch(h){return console.error("Error searching tscircuit packages",h),n([]),s(h instanceof Error?h.message:"Failed to search tscircuit packages"),[]}finally{i(!1),A(!0)}},[t]),l=X.useCallback(()=>{n([]),i(!1),s(null),A(!1)},[]);return{results:e,isSearching:o,error:r,hasSearched:a,search:c,reset:l}},Atr=t=>{const e=/^C(\d+)$/i.exec(t.trim());if(!e)return null;const n=Number(e[1]);if(!Number.isSafeInteger(n))return null;const o=`C${e[1]}`;return{source:"jlcpcb",component:{lcscId:n,manufacturer:o,partNumber:o,description:"Import directly from EasyEDA; stock and availability are unknown",package:"",isDirectLookup:!0}}},mxn=(t,e)=>{const n=Atr(t);return n?e.some(i=>i.component.partNumber.toUpperCase()===n.component.partNumber)?e:[n,...e]:e},ctr=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},ltr=()=>{const[t,e]=X.useState([]),[n,o]=X.useState(!1),[i,r]=X.useState(null),[s,a]=X.useState(!1),A=X.useCallback(async l=>{const u=ctr(l);if(!u)return[];o(!0),r(null);try{const g=await ZZi(u,10),h=mxn(l,g.map(d=>({source:"jlcpcb",component:eer(d)})));return e(h),h}catch(g){console.error("Error searching JLCPCB components",g);const h=mxn(l,[]);return e(h),r(h.length>0?null:g instanceof Error?g.message:"Failed to search JLCPCB components"),h}finally{o(!1),a(!0)}},[]),c=X.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:A,reset:c}},utr=()=>{const[t,e]=X.useState([]),[n,o]=X.useState(!1),[i,r]=X.useState(null),[s,a]=X.useState(!1),A=X.useCallback(async l=>{const u=l.trim();if(!u)return[];o(!0),r(null);try{const h=(await Ker(u,20)).map(d=>({source:"kicad",footprint:zer(d)}));return e(h),h}catch(g){return console.error("Error searching KiCad footprints",g),e([]),r(g instanceof Error?g.message:"Failed to search KiCad footprints"),[]}finally{o(!1),a(!0)}},[]),c=X.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:A,reset:c}},gtr=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const o=[];return t&&o.push("tscircuit.com"),e&&o.push("jlcpcb"),n&&o.push("kicad"),o},dtr=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r,jlcpcbProxyApiBase:s,tscircuitSessionToken:a})=>{gte();const A=X.useMemo(()=>gtr({onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r}),[o,i,r]),c=A.length>0,l=A.length===1,[u,g]=X.useState(A[0]??"tscircuit.com"),[h,d]=X.useState(""),[m,p]=X.useState(null),{results:f,isSearching:_,error:I,hasSearched:C,search:y,reset:x}=atr({sessionToken:a}),{results:E,isSearching:B,error:S,hasSearched:Q,search:w,reset:M}=ltr(),{results:T,isSearching:R,error:F,hasSearched:O,search:U,reset:Y}=utr(),{details:q,isLoading:ee,fetchDetails:W,reset:J}=itr(),[te,ie]=X.useState(null),[ne,le]=X.useState(!1),[de,Ie]=X.useState("pcb"),[ce,fe]=X.useState(null),[ue,pe]=X.useState(!1),Me=X.useMemo(()=>({jlcpcb:{headers:n,apiBase:s}}),[s,n]),{circuitJson:Se,error:he,isLoading:Pe}=rtr(m,Me),we=gxn(m);X.useEffect(()=>{fe(null)},[m]);const Qe=X.useCallback(()=>{x(),M(),Y(),p(null)},[M,Y,x]);X.useEffect(()=>{t||(Qe(),d(""),le(!1),ie(null),fe(null))},[t,Qe]),X.useEffect(()=>{d(""),p(null),u==="tscircuit.com"?x():u==="jlcpcb"?M():u==="kicad"&&Y()},[u,M,Y,x]);const Re=tt=>{p(tt),ie(tt),Ie("pcb"),le(!0),J();const dt=tt.package.org_owner_tscircuit_handle,St=tt.package.unscoped_name;if(dt&&St){const Ct=St.split("/").pop()??St;W(dt,Ct)}},De=async()=>{h.trim()&&(p(null),u==="tscircuit.com"?await y(h):u==="jlcpcb"?await w(h):u==="kicad"&&await U(h))},xe=async tt=>{try{if(fe(null),pe(!0),tt.source==="kicad"){if(!o)throw new Error("KiCad handler not provided");await o({result:tt,footprint:tt.footprint.qualifiedName})}else if(tt.source==="jlcpcb"){if(!r)throw new Error("JLCPCB handler not provided");const dt=await ter(tt.component.partNumber,{headers:n,apiBase:s});await r({result:tt,tsx:dt})}else if(tt.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const dt=tt.package.org_owner_tscircuit_handle,St=tt.package.unscoped_name;if(!dt||!St)throw new Error("Missing package metadata");const Ct=St.split("/").pop()??St,Nt=`@tsci/${dt}.${Ct}`;await i({result:tt,fullPackageName:Nt})}return!0}catch(dt){return console.error("Failed to import component",dt),fe(dt instanceof Error?dt.message:"Failed to import component"),!1}finally{pe(!1)}};let Te=[],Ce=!1,Fe=null,Ge=!1;u==="tscircuit.com"?(Te=f,Ce=_,Fe=I,Ge=C):u==="jlcpcb"?(Te=E,Ce=B,Fe=S,Ge=Q):u==="kicad"&&(Te=T,Ce=R,Fe=F,Ge=O);const Xe=async()=>{if(!m)return;await xe(m)&&(e(),Qe(),d(""))},st=tt=>{tt||e()},rt=tt=>{le(tt),tt||ie(null)};return K.jsxs(hk,{open:t,onOpenChange:st,children:[K.jsxs(mM,{style:{width:"calc(100vw - 2rem)",maxWidth:we?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:hxn.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[K.jsxs(pM,{children:[K.jsxs(fM,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",l?w1e[u].label:""," ","Component"]}),K.jsx(mk,{className:"rf-text-sm",children:c?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),c?K.jsxs(DTe,{value:u,onValueChange:tt=>g(tt),className:"rf-min-w-0 rf-w-full",children:[!l&&K.jsx(Ude,{className:"rf-flex rf-w-full rf-gap-2",children:A.map(tt=>K.jsx(k7,{value:tt,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:w1e[tt].label},tt))}),K.jsxs("div",{className:"rf-min-w-0",style:we?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[K.jsxs("div",{className:"rf-min-w-0",children:[K.jsx(jer,{query:h,placeholder:w1e[u].placeholder,isSearching:Ce,onQueryChange:d,onSubmit:De}),K.jsx("div",{className:"no-scrollbar rf-mt-4 rf-flex-1 rf-min-h-[200px] !rf-max-h-[40vh] !rf-overflow-y-auto rf-overflow-x-hidden rf-border rf-rounded-md rf-min-w-0",children:Ce?K.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[K.jsx(VE,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),K.jsx("p",{children:"Searching..."})]}):Te.length>0?K.jsx(ttr,{results:Te,selected:m,onSelect:p,onShowDetails:u==="tscircuit.com"?Re:void 0}):K.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:Fe?`Error: ${Fe}`:Ge?w1e[u].emptyMessage:"Enter a search term to find components"})})]}),we?K.jsx("div",{className:"rf-mt-4",children:K.jsx(ntr,{circuitJson:Se,error:he,isLoading:Pe,height:325})}):null]})]}):null,ce?K.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:ce}):null,K.jsxs(MK,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[K.jsx(IA,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),K.jsx(IA,{onClick:Xe,disabled:!m||ue,className:"rf-order-1 sm:rf-order-2",children:ue?K.jsx(VE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),K.jsx(otr,{packageResult:te,isOpen:ne,onOpenChange:rt,isLoading:ee,details:q,previewTab:de,onPreviewTabChange:tt=>Ie(tt),isSubmitting:ue,onImport:()=>{te&&xe(te).then(tt=>{tt&&(le(!1),e(),Qe(),d(""))})}})]})},htr=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},pxn=t=>{const e=Id(s=>s.pushEvent),n=Id(s=>s.upsertFile),o=async({result:s,fullPackageName:a})=>{const c=s.package.unscoped_name??s.package.name;await ua.promise(e({event_type:"INSTALL_PACKAGE",full_package_name:a}),{loading:`Requesting install for "${c}"`,success:`Install requested for "${c}"`,error:l=>`Failed to request install: ${l instanceof Error?l.message:String(l)}`})},i=async({footprint:s})=>{await ua.promise(navigator.clipboard.writeText(s),{loading:`Copying "${s}"`,success:`Copied "${s}" to clipboard`,error:a=>`Failed to copy footprint: ${a instanceof Error?a.message:String(a)}`})},r=async({result:s,tsx:a})=>{const c=`imports/${htr(a)}.tsx`;await ua.promise(n(c,a),{loading:`Importing ${s.component.partNumber}`,success:`Imported to "${c}"`,error:l=>`Failed to import component: ${l instanceof Error?l.message:String(l)}`})};return K.jsx(dtr,{...t,onTscircuitPackageSelected:o,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:r})};pxn.displayName="ImportComponentDialogForCli";const mtr=async({circuitJson:t,projectName:e})=>{const{convertCircuitJsonToAltiumZip:n}=await Promise.resolve().then(()=>Rxr),o=await n(t,e);return new Blob([new Uint8Array(o)],{type:"application/zip"})},ptr=async({circuitJson:t,projectName:e})=>{await ua.promise((async()=>{const n=await mtr({circuitJson:t,projectName:e});XE(n,{fileName:`${e}_altium_project.zip`})})(),{loading:"Generating Altium project...",success:"Altium project ZIP ready",error:n=>`Failed to generate Altium project: ${n instanceof Error?n.message:String(n)}`})};var ZZe={exports:{}},fxn;function ftr(){return fxn||(fxn=1,(function(t,e){var n={env:{},version:""};(function(o){t.exports=o()})(function(){return(function o(i,r,s){function a(l,u){if(!r[l]){if(!i[l]){var g=typeof db=="function"&&db;if(!u&&g)return g(l,!0);if(A)return A(l,!0);var h=new Error("Cannot find module '"+l+"'");throw h.code="MODULE_NOT_FOUND",h}var d=r[l]={exports:{}};i[l][0].call(d.exports,function(m){var p=i[l][1][m];return a(p||m)},d,d.exports,o,i,r,s)}return r[l].exports}for(var A=typeof db=="function"&&db,c=0;c<s.length;c++)a(s[c]);return a})({1:[function(o,i,r){var s=o("./utils"),a=o("./support"),A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(c){for(var l,u,g,h,d,m,p,f=[],_=0,I=c.length,C=I,y=s.getTypeOf(c)!=="string";_<c.length;)C=I-_,g=y?(l=c[_++],u=_<I?c[_++]:0,_<I?c[_++]:0):(l=c.charCodeAt(_++),u=_<I?c.charCodeAt(_++):0,_<I?c.charCodeAt(_++):0),h=l>>2,d=(3&l)<<4|u>>4,m=1<C?(15&u)<<2|g>>6:64,p=2<C?63&g:64,f.push(A.charAt(h)+A.charAt(d)+A.charAt(m)+A.charAt(p));return f.join("")},r.decode=function(c){var l,u,g,h,d,m,p=0,f=0,_="data:";if(c.substr(0,_.length)===_)throw new Error("Invalid base64 input, it looks like a data url.");var I,C=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===A.charAt(64)&&C--,c.charAt(c.length-2)===A.charAt(64)&&C--,C%1!=0)throw new Error("Invalid base64 input, bad content length.");for(I=a.uint8array?new Uint8Array(0|C):new Array(0|C);p<c.length;)l=A.indexOf(c.charAt(p++))<<2|(h=A.indexOf(c.charAt(p++)))>>4,u=(15&h)<<4|(d=A.indexOf(c.charAt(p++)))>>2,g=(3&d)<<6|(m=A.indexOf(c.charAt(p++))),I[f++]=l,d!==64&&(I[f++]=u),m!==64&&(I[f++]=g);return I}},{"./support":30,"./utils":32}],2:[function(o,i,r){var s=o("./external"),a=o("./stream/DataWorker"),A=o("./stream/Crc32Probe"),c=o("./stream/DataLengthProbe");function l(u,g,h,d,m){this.compressedSize=u,this.uncompressedSize=g,this.crc32=h,this.compression=d,this.compressedContent=m}l.prototype={getContentWorker:function(){var u=new a(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),g=this;return u.on("end",function(){if(this.streamInfo.data_length!==g.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},getCompressedWorker:function(){return new a(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},l.createWorkerFrom=function(u,g,h){return u.pipe(new A).pipe(new c("uncompressedSize")).pipe(g.compressWorker(h)).pipe(new c("compressedSize")).withStreamInfo("compression",g)},i.exports=l},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(o,i,r){var s=o("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},r.DEFLATE=o("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(o,i,r){var s=o("./utils"),a=(function(){for(var A,c=[],l=0;l<256;l++){A=l;for(var u=0;u<8;u++)A=1&A?3988292384^A>>>1:A>>>1;c[l]=A}return c})();i.exports=function(A,c){return A!==void 0&&A.length?s.getTypeOf(A)!=="string"?(function(l,u,g,h){var d=a,m=h+g;l^=-1;for(var p=h;p<m;p++)l=l>>>8^d[255&(l^u[p])];return-1^l})(0|c,A,A.length,0):(function(l,u,g,h){var d=a,m=h+g;l^=-1;for(var p=h;p<m;p++)l=l>>>8^d[255&(l^u.charCodeAt(p))];return-1^l})(0|c,A,A.length,0):0}},{"./utils":32}],5:[function(o,i,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(o,i,r){var s=null;s=typeof Promise<"u"?Promise:o("lie"),i.exports={Promise:s}},{lie:37}],7:[function(o,i,r){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=o("pako"),A=o("./utils"),c=o("./stream/GenericWorker"),l=s?"uint8array":"array";function u(g,h){c.call(this,"FlateWorker/"+g),this._pako=null,this._pakoAction=g,this._pakoOptions=h,this.meta={}}r.magic="\b\0",A.inherits(u,c),u.prototype.processChunk=function(g){this.meta=g.meta,this._pako===null&&this._createPako(),this._pako.push(A.transformTo(l,g.data),!1)},u.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var g=this;this._pako.onData=function(h){g.push({data:h,meta:g.meta})}},r.compressWorker=function(g){return new u("Deflate",g)},r.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(o,i,r){function s(d,m){var p,f="";for(p=0;p<m;p++)f+=String.fromCharCode(255&d),d>>>=8;return f}function a(d,m,p,f,_,I){var C,y,x=d.file,E=d.compression,B=I!==l.utf8encode,S=A.transformTo("string",I(x.name)),Q=A.transformTo("string",l.utf8encode(x.name)),w=x.comment,M=A.transformTo("string",I(w)),T=A.transformTo("string",l.utf8encode(w)),R=Q.length!==x.name.length,F=T.length!==w.length,O="",U="",Y="",q=x.dir,ee=x.date,W={crc32:0,compressedSize:0,uncompressedSize:0};m&&!p||(W.crc32=d.crc32,W.compressedSize=d.compressedSize,W.uncompressedSize=d.uncompressedSize);var J=0;m&&(J|=8),B||!R&&!F||(J|=2048);var te=0,ie=0;q&&(te|=16),_==="UNIX"?(ie=798,te|=(function(le,de){var Ie=le;return le||(Ie=de?16893:33204),(65535&Ie)<<16})(x.unixPermissions,q)):(ie=20,te|=(function(le){return 63&(le||0)})(x.dosPermissions)),C=ee.getUTCHours(),C<<=6,C|=ee.getUTCMinutes(),C<<=5,C|=ee.getUTCSeconds()/2,y=ee.getUTCFullYear()-1980,y<<=4,y|=ee.getUTCMonth()+1,y<<=5,y|=ee.getUTCDate(),R&&(U=s(1,1)+s(u(S),4)+Q,O+="up"+s(U.length,2)+U),F&&(Y=s(1,1)+s(u(M),4)+T,O+="uc"+s(Y.length,2)+Y);var ne="";return ne+=`
|
|
5671
|
+
`,u=new Blob([l],{type:"text/plain"}),g=URL.createObjectURL(u),h=document.createElement("a");h.href=g,h.download=`${c}.test.ts`,h.click(),URL.revokeObjectURL(g)}catch(A){alert(`Error generating test.ts for ${t.getSolverName()}: ${A instanceof Error?A.message:String(A)}`)}o(!1)};return K.jsxs("div",{className:`relative ${e}`,ref:i,children:[K.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&&K.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:[K.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),K.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),K.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},E2n=t=>t.activeSubSolver?[t,...E2n(t.activeSubSolver)]:[t],OXi=({solver:t})=>{const e=E2n(t);return K.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>K.jsxs("div",{className:"flex items-center",children:[o>0&&K.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),K.jsx(HXi,{solver:n})]},n.getSolverName()))})},GXi=({solver:t,triggerRender:e,animationSpeed:n=25,renderer:o,onRendererChange:i,onAnimationSpeedChange:r,onDownloadVisualization:s,onSolverStarted:a,onSolverCompleted:A})=>{const[c,l]=X.useReducer(B=>!B,!1),u=X.useRef(void 0),g=X.useRef(null),h="solver-debugger-last-iteration",[d,m]=X.useState(null),p=X.useRef(null),f=X.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"}],[]),_=()=>{const B=Math.max(1,n),S=n<1?Math.round(1/n):1;u.current=setInterval(()=>{if(t.solved||t.failed){u.current&&(clearInterval(u.current),u.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=()=>{u.current&&(clearInterval(u.current),u.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(),_())},E=()=>{if(t.solved||t.failed||c)return;g.current===null&&typeof window<"u"&&(g.current=window.localStorage.getItem(h));const B=window.prompt("Step until which iteration?",g.current??`${t.iterations}`);if(B===null)return;g.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 X.useEffect(()=>()=>{I()},[]),X.useEffect(()=>{(t.solved||t.failed)&&c&&(I(),l())},[t.solved,t.failed,c]),X.useEffect(()=>{c&&(I(),_())},[n,c]),X.useEffect(()=>{if(typeof document>"u")return;const B=S=>{p.current&&!p.current.contains(S.target)&&m(null)};return document.addEventListener("mousedown",B),()=>{document.removeEventListener("mousedown",B)}},[]),K.jsxs("div",{className:"space-y-2 p-2 border-b",children:[K.jsx("div",{className:"flex items-center",children:K.jsxs("div",{className:"flex items-center gap-2",ref:p,children:[K.jsxs("div",{className:"flex h-9 items-center space-x-1 rounded-md border border-slate-200 bg-white p-1 shadow-sm",children:[K.jsxs("div",{className:"relative",children:[K.jsx("button",{type:"button",onClick:()=>m(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"&&K.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=>K.jsxs("button",{type:"button",onClick:()=>{i(B),m(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&&K.jsx("span",{className:"ml-auto text-xs text-slate-500",children:"✓"})]},B))})]}),K.jsxs("div",{className:"relative",children:[K.jsx("button",{type:"button",onClick:()=>m(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"&&K.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:K.jsx("button",{type:"button",onClick:()=>{s(),m(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:"Download Visualization"})})]}),K.jsxs("div",{className:"relative",children:[K.jsx("button",{type:"button",onClick:()=>m(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"&&K.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:f.map(B=>K.jsxs("button",{type:"button",onClick:()=>{r(B.value),m(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:[B.label,K.jsx("span",{className:"ml-auto text-xs text-slate-500",children:B.description}),n===B.value&&K.jsx("span",{className:"ml-2 text-xs text-slate-500",children:"✓"})]},B.value))})]})]}),K.jsx(OXi,{solver:t})]})}),K.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[K.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"}),K.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"}),K.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"}),K.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"}),K.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&K.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),t.solved&&K.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&K.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&K.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},YXi=t=>t!==null&&"pipelineDef"in t&&Array.isArray(t.pipelineDef),UXi=(t,e,n)=>{const o=t.currentPipelineStageIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},KXi=(t,e)=>{const o=t.pipelineDef[e].solverName,i=UXi(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 g=t.pipelineDef[e+1],h=g?t.firstIterationOfStage?.[g.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 u=r?.stats??null;return{index:e,name:o,status:i,firstIteration:s,iterations:A,progress:l,timeSpent:c,stats:u&&Object.keys(u).length>0?u:null,solverInstance:r??null}},zXi=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return K.jsx("span",{className:`font-medium ${e[t]}`,children:t})},VXi=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return K.jsxs("div",{className:"flex items-center gap-2",children:[K.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:K.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),K.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},B2n=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)},JXi=t=>Object.entries(t).map(([e,n])=>`${e}: ${B2n(n)}`).join(", "),WXi=({stats:t})=>{if(!t||Object.keys(t).length===0)return K.jsx("span",{children:"-"});const e=Object.entries(t),n=JXi(t);return K.jsxs("details",{className:"cursor-pointer",children:[K.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),K.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>K.jsxs("div",{children:[o,": ",B2n(i)]},o))})]})},EZe=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(EZe);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=EZe(o));return e},jXi=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=EZe(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)}`)}},qXi=({expanded:t})=>K.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:K.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"})}),b2n=t=>{let e=t;for(;e.activeSubSolver;)e=e.activeSubSolver;return e},S2n=({solver:t,onStepUntilPhase:e,onDownloadInput:n,isNested:o=!1,indentLevel:i=0,triggerRender:r})=>{const[s,a]=X.useState(new Set),A=t.pipelineDef.map((p,f)=>KXi(t,f)),c=p=>{a(f=>{const _=new Set(f);return _.has(p)?_.delete(p):_.add(p),_})},l=p=>{e?.(p)},u=p=>{p.solverInstance&&(n?n(p.solverInstance,p.name):jXi(p.solverInstance,p.name))},g=p=>`${(p/1e3).toFixed(2)}s`,h=()=>{if(!t.solved&&!t.failed){const p=t.activeSubSolver;for(;!t.solved&&!t.failed&&(t.step(),!(t.activeSubSolver&&t.activeSubSolver!==p)););r?.()}},d=()=>{if(!t.solved&&!t.failed){const p=b2n(t);for(;!t.solved&&!t.failed&&(t.step(),b2n(t)===p););r?.()}},m=i*24;return K.jsxs("div",{className:o?"":"border-t border-gray-200",children:[!o&&K.jsxs("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200 flex items-center justify-between",children:[K.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Stages"}),K.jsxs("div",{className:"flex gap-2",children:[K.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"}),K.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"})]})]}),K.jsx("div",{className:"overflow-x-auto",children:K.jsxs("table",{className:"w-full text-sm",children:[!o&&K.jsx("thead",{children:K.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stage"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),K.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",K.jsx("sub",{children:"0"})]}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),K.jsx("tbody",{children:A.map(p=>{const f=YXi(p.solverInstance),_=s.has(p.name);return K.jsxs(Fs.Fragment,{children:[K.jsxs("tr",{className:`border-b border-gray-100 ${p.status==="In Progress"?"bg-yellow-50":""}`,children:[K.jsx("td",{className:"px-4 py-2",children:K.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:m},children:[f?K.jsx("button",{onClick:()=>c(p.name),className:"text-gray-500 hover:text-gray-700",title:_?"Collapse":"Expand",children:K.jsx(qXi,{expanded:_})}):K.jsx("span",{className:"w-4"}),K.jsx("span",{className:"text-gray-400 w-6",children:String(p.index+1).padStart(2,"0")}),K.jsx("button",{onClick:()=>l(p.name),disabled:p.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 ${p.name} completes`,children:K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:K.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"})})}),K.jsx("span",{className:"font-medium text-gray-900",children:p.name})]})}),K.jsx("td",{className:"px-4 py-2",children:K.jsx(zXi,{status:p.status})}),K.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:p.firstIteration!==null?p.firstIteration:""}),K.jsx("td",{className:"px-4 py-2 text-gray-600",children:p.iterations}),K.jsx("td",{className:"px-4 py-2",children:K.jsx(VXi,{progress:p.progress})}),K.jsx("td",{className:"px-4 py-2 text-gray-600",children:g(p.timeSpent)}),K.jsx("td",{className:"px-4 py-2 text-gray-500",children:K.jsx(WXi,{stats:p.stats})}),K.jsx("td",{className:"px-4 py-2",children:p.solverInstance?K.jsxs("button",{onClick:()=>u(p),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${p.name}`,children:[K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:K.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"})}),K.jsx("span",{children:"Input"})]}):null})]}),f&&_&&K.jsx("tr",{children:K.jsx("td",{colSpan:8,className:"p-0",children:K.jsx(S2n,{solver:p.solverInstance,onStepUntilPhase:e,onDownloadInput:n,isNested:!0,indentLevel:i+1,triggerRender:r})})})]},p.name)})})]})})]})};function $Xi({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=(p,f)=>{typeof p=="number"&&(p<s&&(s=p),p>A&&(A=p)),typeof f=="number"&&(f<a&&(a=f),f>c&&(c=f))};for(const p of e)l(p.x,p.y);for(const p of n){const f=p.points??[];for(const _ of f)l(_.x,_.y)}for(const p of o){const f=p.x??0,_=p.y??0,I=p.width??0,C=p.height??0;l(f,_),l(f+I,_+C)}for(const p of i){const f=p.x??0,_=p.y??0,I=p.radius??1;l(f-I,_-I),l(f+I,_+I)}for(const p of r)l(p.x,p.y);(!isFinite(s)||!isFinite(a)||!isFinite(A)||!isFinite(c))&&(s=-20,a=-20,A=20,c=20);const u=10,g=s-u,h=a-u,d=Math.max(1,A-s+2*u),m=Math.max(1,c-a+2*u);return K.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${g} ${h} ${d} ${m}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,f)=>K.jsx("rect",{x:p.x??0,y:p.y??0,width:p.width??0,height:p.height??0,fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`rect-${f}`)),n.map((p,f)=>K.jsx("polyline",{fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1,points:(p.points??[]).map(_=>`${_.x??0},${_.y??0}`).join(" ")},`line-${f}`)),i.map((p,f)=>K.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.fillColor??"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`circle-${f}`)),e.map((p,f)=>K.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.color??"black"},`point-${f}`)),r.map((p,f)=>K.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${f}`))]})}var XXi=class extends Fs.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}},ZXi=({solver:t,createSolver:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=X.useReducer(_=>_+1,0),[a]=X.useState(()=>{if(e)return e();if(!t)throw new Error("GenericSolverDebugger requires solver or createSolver");return t}),[A,c]=X.useState(()=>typeof window>"u"?"vector":window.localStorage.getItem("solver-utils-renderer")==="canvas"?"canvas":"vector"),[l,u]=X.useState(n),g=X.useMemo(()=>{try{return a.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(_){return console.error("Visualization error:",_),{points:[],lines:[],rects:[],circles:[]}}},[a,r]),h=X.useMemo(()=>(g.rects?.length||0)===0&&(g.lines?.length||0)===0&&(g.points?.length||0)===0&&(g.circles?.length||0)===0,[g]);X.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const _=document.createElement("script");_.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(_)}},[]),X.useEffect(()=>{u(n)},[n]);const d=a.pipelineDef!==void 0,m=_=>{const I=a;if(!a.solved&&!a.failed){for(;!a.solved&&!a.failed&&I.currentPipelineStageIndex<=I.pipelineDef.findIndex(C=>C.solverName===_);)a.step();s()}},p=()=>{const _=JSON.stringify(g,null,2),I=new Blob([_],{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(_),typeof window<"u"&&window.localStorage.setItem("solver-utils-renderer",_)};return K.jsxs("div",{children:[K.jsx(GXi,{solver:a,triggerRender:s,animationSpeed:l,renderer:A,onRendererChange:f,onAnimationSpeedChange:u,onDownloadVisualization:p,onSolverStarted:o,onSolverCompleted:i}),h?K.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):K.jsx(XXi,{fallback:K.jsx($Xi,{graphics:g}),children:A==="canvas"?K.jsx(LXi,{graphics:g}):K.jsx(TXi,{graphics:g})}),d&&K.jsx(S2n,{solver:a,onStepUntilPhase:m,triggerRender:s})]})};const eZi=()=>{X.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)},[])},tZi=1e3,XE=(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)},tZi)},BZe=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"},nZi=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]},b8="https://github.com/tscircuit/tscircuit-autorouter/issues/new",Q2n="https://github.com/tscircuit/copper-pour-solver/issues/new",v2n="https://github.com/tscircuit/calculate-packing/issues/new",oZi="https://github.com/tscircuit/matchpack/issues/new",w2n="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",iZi={PackSolver2:v2n,LayoutPipelineSolver:oZi,AutoroutingPipelineSolver:b8,AssignableAutoroutingPipeline2:b8,AssignableAutoroutingPipeline3:b8,AutoroutingPipeline1_OriginalUnravel:b8,AutoroutingPipelineSolver3_HgPortPointPathing:b8,AutoroutingPipelineSolver4:b8,AutoroutingPipelineSolver5:b8,AutoroutingPipelineSolver7_MultiGraph:b8,AutoroutingPipelineSolver8:b8,CopperPourPipelineSolver:Q2n,SchematicTracePipelineSolver:w2n},rZi=t=>t.toLowerCase().includes("pack")?cIn:t.toLowerCase().includes("rout")?uIn:JUi,P2n=t=>{const e=iZi[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?b8:n.includes("schematic")&&n.includes("trace")?w2n:n.includes("copperpour")?Q2n:n.includes("pack")?v2n:null},sZi=t=>`${BZe(`${t.componentName}-${t.solverName}`)}-solver-input.json`,M2n=t=>{XE(JSON.stringify(t.solverParams,null,2),{fileName:sZi(t),mimeType:"application/json"})},aZi=({solverEvent:t})=>{const e=P2n(t.solverName);return K.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:[K.jsxs(IA,{type:"button",variant:"outline",size:"sm",onClick:()=>M2n(t),children:[K.jsx(Fee,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?K.jsx(IA,{asChild:!0,variant:"outline",size:"sm",children:K.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[K.jsx(p_e,{className:"rf-w-4 rf-h-4"}),"Report"]})}):K.jsxs(IA,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[K.jsx(p_e,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},AZi=({solverEvent:t})=>{const e=P2n(t.solverName);return e?K.jsx(IA,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:K.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:K.jsx(p_e,{className:"rf-w-4 rf-h-4"})})}):K.jsx(IA,{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:K.jsx(p_e,{className:"rf-w-4 rf-h-4"})})},cZi=({solverEvents:t=[]})=>{const[e,n]=X.useState(null);eZi();const o=X.useMemo(()=>{const a=new Map;for(const A of t){const c=`${A.componentName}-${A.solverName}`;a.set(c,A)}return a},[t]),i=X.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=X.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=vDe[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(vDe).join(", ")}`,classFound:!1};try{return{instance:new a(...nZi(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?K.jsx("div",{className:"rf-p-4",children:K.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:K.jsxs("div",{className:"rf-p-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),K.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."})]})})}):K.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[K.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[K.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 K.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=rZi(A.solverName);return K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[K.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),K.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[K.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:A.componentName}),K.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:A.solverName})]})]})})()},a)})]}),K.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?K.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[K.jsx(aZi,{solverEvent:r}),K.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:K.jsx(zE,{fallback:K.jsx("div",{className:"rf-p-4",children:K.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),K.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:K.jsx(ZXi,{solver:s.instance})})})]}):K.jsxs("div",{className:"rf-p-4",children:[K.jsxs("div",{className:"rf-mb-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),K.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&K.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:K.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),K.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[K.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:[K.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[K.jsx(AZi,{solverEvent:r}),K.jsx(IA,{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:()=>M2n(r),children:K.jsx(Fee,{className:"rf-w-4 rf-h-4"})})]})]}),K.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:K.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)})})]})]}):K.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:K.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},lZi=["subcircuit_id","componentDisplayName","phaseName","routingPhaseIndex","phaseOrdinal","phaseCount","phaseStageIndex","phaseStageCount","connectionCount","obstacleCount","previousTraceCount","isReroutePhase","autorouterName","autorouterVersion","solverName","effort","cacheStatus"],uZi=["phaseOrdinal","routingPhaseIndex","phaseName","phaseStageIndex"];function gZi(t,e){let n=-1,o=-1;for(let i=t.length-1;i>=0;i--){const r=t[i];if(r.status!=="running"||r.subcircuit_id!==e.subcircuit_id||r.componentDisplayName!==e.componentDisplayName)continue;let s=0,a=!1;for(const A of uZi)if(!(r[A]===void 0||e[A]===void 0)){if(r[A]!==e[A]){a=!0;break}s++}!a&&s>o&&(n=i,o=s)}return n}function dZi(t,e){const n=Object.fromEntries(lZi.filter(s=>e[s]!==void 0).map(s=>[s,e[s]])),o=e.simpleRouteJson?structuredClone(e.simpleRouteJson):void 0,i=e.type==="autorouting:start"?-1:gZi(t,e),r={...i===-1?{id:`autorouting_phase_${t.length+1}`}:t[i],...n,status:e.type==="autorouting:start"?"running":e.type==="autorouting:end"?"complete":"error",...e.type==="autorouting:start"?{startSimpleRouteJson:o}:e.type==="autorouting:end"?{endSimpleRouteJson:o}:{errorSimpleRouteJson:o,error:e.error?{...e.error}:void 0}};return i===-1?[...t,r]:t.map((s,a)=>a===i?r:s)}const hZi=new Map([["custom","Custom"],["fanout","Fanout"],["single_layer_fanout","Single layer fanout"],["tscircuit_simplify","Simplify"]]),mZi=new Set(["tscircuit","default","auto","auto_local"]);function pZi(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 fZi(t){const e=t.autorouterName?.trim(),n=e?.replace(/-/g,"_"),o=n&&hZi.get(n);if(o)return o;if(n&&!mZi.has(n))return e;const i=t.solverName?.trim();if(i)return pZi(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 bZe="#fbbf24";function _Zi(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 D2n(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 IZi(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 N2n(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,...IZi(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,u)=>{if(l.route_type!=="wire")return;const g=Math.hypot(l.x-a.x,l.y-a.y);g<c&&(c=g,A=u)}),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 CZi(t){const e=[],n=[],o=t.endSimpleRouteJson;if(!o)return{lines:e,circles:n};const i=new Set(D2n(t));for(const r of o.traces??[])if(i.has(r.pcb_trace_id))for(const s of N2n(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:bZe,layer:c}),A.route_type==="via"&&n.push({center:{x:A.x,y:A.y},radius:A.outer_diameter/2,stroke:bZe,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 yZi(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 xZi=new Set(["pcb_trace","pcb_via","pcb_copper_pour","pcb_ground_plane","pcb_ground_plane_region","pcb_thermal_spoke","pcb_breakout_point"]);function EZi(t,e,n){const o=n==="input"?e.startSimpleRouteJson??e.errorSimpleRouteJson:e.endSimpleRouteJson,i=t.filter(c=>!xZi.has(c.type)&&!c.type.endsWith("_error")&&!c.type.endsWith("_warning"));if(!o)return i;const r=n==="input"?o.traces??[]:_Zi(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 u=o.connections.find(h=>h.name===c.connection_name||h.source_trace_id===c.connection_name)?.source_trace_id??c.connection_name??"",g=N2n(c,o);for(const[h,d]of g.entries()){const m={type:"pcb_trace",pcb_trace_id:`${e.id}_${n}_${c.pcb_trace_id}_${h}_${yZi(d)}`,subcircuit_id:e.subcircuit_id??void 0,source_trace_id:s.has(u)?u:void 0,route:d};A.push(m);for(const[p,f]of d.entries()){if(f.route_type!=="via")continue;const _=a.indexOf(f.from_layer),I=a.indexOf(f.to_layer),C={type:"pcb_via",pcb_via_id:`${m.pcb_trace_id}_via_${p}`,pcb_trace_id:m.pcb_trace_id,subcircuit_id:e.subcircuit_id??void 0,x:f.x,y:f.y,outer_diameter:f.outer_diameter,hole_diameter:f.hole_diameter,layers:_>=0&&I>=0?a.slice(Math.min(_,I),Math.max(_,I)+1):[f.from_layer,f.to_layer]};A.push(C)}}}return[...i,...A]}const SZe=(t,e)=>t.phaseName||`Phase ${t.phaseOrdinal??e+1}`,R2n=t=>t.componentDisplayName?.match(/name="([^"]+)"/)?.[1]?.replace(/^\./,"")||t.componentDisplayName||t.subcircuit_id||"Board",T2n=t=>t.startSimpleRouteJson??t.endSimpleRouteJson??t.errorSimpleRouteJson,BZi={is_showing_autorouting:!0,is_showing_rats_nest:!1,is_showing_drc_errors:!1,is_showing_drc_warnings:!1,is_showing_pcb_groups:!1},bZi=({circuitJson:t,phases:e=[],isRunning:n=!1})=>{const[o,i]=X.useState(null),[r,s]=X.useState("output"),[a,A]=X.useState(!0),[c,l]=X.useState(!1),u=X.useRef(null),[g,h]=X.useState(480),d=o?e.findIndex(R=>R.id===o.id&&T2n(R)===T2n(o)):-1,m=d<0?e.length-1:d,p=e[m],f=d<0,_=!!p?.endSimpleRouteJson,I=p?.startSimpleRouteJson??p?.errorSimpleRouteJson,C=!!I,y=r==="output"&&!_?"input":r==="input"&&!C?"output":r,x=y==="input"?I:p?.endSimpleRouteJson,E=X.useMemo(()=>!p||!x?null:EZi(t??[],p,y),[t,p,x,y]),B=X.useMemo(()=>p&&y==="output"&&a?CZi(p):{lines:[],circles:[]},[p,y,a]);if(X.useLayoutEffect(()=>{const R=u.current;if(!R)return;const F=()=>h(Math.max(360,R.clientHeight));F();const O=new ResizeObserver(F);return O.observe(R),()=>O.disconnect()},[!!p]),!p)return K.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:[K.jsx(uIn,{className:"rf-h-7 rf-w-7 rf-text-blue-500"}),K.jsx("h3",{className:"rf-text-base rf-font-medium",children:n?"Waiting for autorouting":"No autorouting captures"}),K.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=SZe(p,m),Q=p.status==="running"&&n,w=!_,M=I?.connections.length,T=E?.filter(R=>R.type==="pcb_trace").length??0;return K.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:[K.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:[K.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:[K.jsx("span",{children:"Routing phases"}),K.jsx("span",{children:e.length})]}),K.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=D2n(R).length,U=R.endSimpleRouteJson?`${O} ${O===1?"trace":"traces"} routed`:R.status==="error"?"Failed":R.status==="running"&&n?"Routing…":"No output";return K.jsxs("button",{type:"button","aria-pressed":F===m,title:`${R2n(R)} · ${U}`,onClick:()=>i(R),className:Fi("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===m?"rf-border-blue-200 rf-bg-blue-50":"rf-border-transparent hover:rf-bg-gray-50"),children:[K.jsx("span",{className:Fi("rf-flex rf-h-5 rf-w-5 rf-shrink-0 rf-items-center rf-justify-center rf-rounded-full rf-text-[11px]",F===m?"rf-bg-blue-600 rf-text-white":"rf-bg-gray-100 rf-text-gray-500"),children:F+1}),K.jsxs("span",{className:"rf-min-w-0 rf-flex-1",children:[K.jsxs("span",{className:"rf-flex rf-items-center rf-gap-1",children:[K.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:SZe(R,F),children:SZe(R,F)}),R.status==="complete"?K.jsx(VS,{"aria-label":"Captured",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-green-600"}):R.status==="error"?K.jsx(X$e,{"aria-label":"Failed",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-red-500"}):n?K.jsx(VE,{"aria-label":"Routing",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-animate-spin rf-text-blue-500"}):null]}),K.jsxs("span",{className:"rf-block rf-text-[11px] rf-leading-4 rf-text-gray-500",children:[fZi(R)," · ",U]})]})]},R.id)})})]}),K.jsxs("div",{className:"rf-flex rf-min-w-0 rf-flex-1 rf-flex-col",children:[K.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:[K.jsxs("h3",{className:"rf-mr-auto rf-flex rf-items-center rf-gap-2 rf-text-sm rf-font-medium",children:[S,K.jsxs("span",{className:"rf-text-xs rf-font-normal rf-text-gray-500",children:[m+1," of ",e.length]})]}),n&&K.jsx("button",{type:"button",onClick:()=>i(null),disabled:f,className:"rf-text-xs rf-text-blue-600 disabled:rf-text-gray-500",children:f?"Following latest":"Follow latest"}),K.jsx("div",{className:"rf-flex rf-rounded-md rf-bg-gray-100 rf-p-1","aria-label":"Phase snapshot",children:["input","output"].map(R=>K.jsx("button",{type:"button","aria-pressed":y===R,disabled:R==="input"?!C:!_,onClick:()=>s(R),className:Fi("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))})]}),K.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:[K.jsxs("label",{className:"rf-flex rf-items-center rf-gap-2",children:[K.jsx("input",{type:"checkbox",checked:a,disabled:y!=="output",onChange:R=>A(R.target.checked),className:"rf-accent-blue-600"}),K.jsx("span",{"aria-hidden":"true",className:"rf-inline-block rf-h-0.5 rf-w-3",style:{backgroundColor:bZe}}),"Highlight changes (all layers)"]}),K.jsxs("span",{children:[y==="input"?"Before this phase":"After this phase"," ","· ",T," traces"]})]}),w&&K.jsx("div",{className:Fi("rf-border-y rf-px-4 rf-py-2 rf-text-xs",p.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:p.status==="error"?`Routing failed: ${p.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."}),K.jsx("div",{ref:u,className:"rf-relative rf-min-h-[360px] rf-flex-1","data-testid":"autorouting-pcb",children:E?K.jsx(j$e,{circuitJson:E,height:g,allowEditing:!1,clickToInteractEnabled:!1,initialState:BZi,debugGraphics:B}):K.jsx("div",{className:"rf-p-6 rf-text-sm rf-text-gray-500",children:"No PCB snapshot available for this capture."})}),K.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:[K.jsxs("span",{children:[M===void 0?"Input unavailable":`${M} input connections`,` · ${R2n(p)}`]}),K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-4",children:[K.jsxs("button",{type:"button",disabled:!x,onClick:()=>XE(JSON.stringify(x,null,2),{fileName:`${p.id}-${y}.srj.json`,mimeType:"application/json"}),className:"rf-flex rf-items-center rf-gap-1 disabled:rf-opacity-40",children:[K.jsx(Fee,{className:"rf-h-3 rf-w-3"}),"Download SRJ"]}),K.jsxs("button",{type:"button","aria-expanded":c,onClick:()=>l(!c),className:"rf-flex rf-items-center rf-gap-1",children:[K.jsx(ik,{className:Fi("rf-h-3 rf-w-3",c&&"rf-rotate-90")}),"Inspect SRJ"]})]})]}),c&&K.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."})]})]})},k2n=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{X.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{GG.captureException(o)}catch{}}},[t,e]),X.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{GG.captureException(i,{error_type:o.type})}catch{}}},[n])},F2n=t=>{X.useEffect(()=>{try{yXo(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},L2n="0.0.2941",SZi={version:L2n},v1e=rOt()(sOt(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),QZi=t=>{const[e,n]=X.useState([]),[o,i]=X.useState(null),[r,s]=X.useState(""),[a,A]=uG("eval-version-selection",null),c=v1e(h=>h.setLastRunEvalVersion),l=v1e(h=>h.lastRunEvalVersion);return X.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(h=>h.json()).then(h=>{if(Array.isArray(h?.versions)){let d=[...h.versions];h.tags?.latest&&(i(h.tags.latest),d=d.filter(m=>m!==h.tags.latest)),n(d)}}).catch(()=>{})},[t]),X.useEffect(()=>{t&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,c(a)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,c(o)))},[t,a,o]),{versions:X.useMemo(()=>e.filter(h=>h.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:l,search:r,setSearch:s,selectVersion:h=>{A(h),s("")}}},vZi=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=X.useState(""),[s,a]=X.useState("");if(!o)return null;const A=t.filter(u=>u.toLowerCase().includes(s.toLowerCase())),c=s&&!t.includes(s),l=u=>{u.key==="Enter"&&(A.length===1?r(A[0]):c&&r(s))};return K.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:K.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[K.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),K.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:u=>a(u.target.value),onKeyDown:l}),K.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[A.map(u=>K.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${i===u?"bg-blue-50":""}`,onClick:()=>r(u),children:u},u)),c&&K.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${i===s?"bg-blue-50":""}`,onClick:()=>r(s),children:['Create new "',s,'"']})]}),K.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[K.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),K.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>i&&e(i),disabled:!i,children:i===s?`Create "${i}"`:`Save to ${i}`})]})]})})},wZi=t=>{const e=X.useRef(null),n=Id(o=>o.recentEvents);X.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};var PZi=Object.defineProperty,eQ=(t,e)=>PZi(t,"name",{value:e,configurable:!0}),MZi="AlertDialog",[DZi,i4r]=Vx(MZi,[LCn]),tQ=LCn(),NZi=eQ(t=>{const{__scopeAlertDialog:e,...n}=t,o=tQ(e);return K.jsx(Z_e,{...o,...n,modal:!0})},"AlertDialog");X.forwardRef(eQ(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=tQ(o);return K.jsx(_Ji,{...r,...i,ref:n})},"AlertDialogTrigger"));var RZi=eQ(t=>{const{__scopeAlertDialog:e,...n}=t,o=tQ(e);return K.jsx(e1e,{...o,...n})},"AlertDialogPortal"),H2n=X.forwardRef(eQ(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=tQ(o);return K.jsx(qee,{...r,...i,ref:n})},"AlertDialogOverlay")),TZi="AlertDialogContent",[kZi,FZi]=DZi(TZi),O2n=X.forwardRef(eQ(function(e,n){const{__scopeAlertDialog:o,children:i,...r}=e,s=tQ(o),a=X.useRef(null),A=LA(n,a),c=X.useRef(null);return K.jsx(kZi,{scope:o,cancelRef:c,children:K.jsx(Xee,{role:"alertdialog",...s,...r,ref:A,onOpenAutoFocus:rr(r.onOpenAutoFocus,l=>{l.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:l=>l.preventDefault(),onInteractOutside:l=>l.preventDefault(),children:i})})},"AlertDialogContent")),G2n=X.forwardRef(eQ(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=tQ(o);return K.jsx(t1e,{...r,...i,ref:n})},"AlertDialogTitle")),Y2n=X.forwardRef(eQ(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=tQ(o);return K.jsx(n1e,{...r,...i,ref:n})},"AlertDialogDescription")),U2n=X.forwardRef(eQ(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=tQ(o);return K.jsx(GXe,{...r,...i,ref:n})},"AlertDialogAction")),LZi="AlertDialogCancel",K2n=X.forwardRef(eQ(function(e,n){const{__scopeAlertDialog:o,...i}=e,{cancelRef:r}=FZi(LZi,o),s=tQ(o),a=LA(n,r);return K.jsx(GXe,{...s,...i,ref:a})},"AlertDialogCancel"));const z2n=NZi,HZi=RZi,V2n=X.forwardRef(({className:t,...e},n)=>K.jsx(H2n,{className:Fi("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));V2n.displayName=H2n.displayName;const QZe=X.forwardRef(({className:t,...e},n)=>K.jsxs(HZi,{children:[K.jsx(V2n,{}),K.jsx(O2n,{ref:n,className:Fi("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...e})]}));QZe.displayName=O2n.displayName;const vZe=({className:t,...e})=>K.jsx("div",{className:Fi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});vZe.displayName="AlertDialogHeader";const wZe=({className:t,...e})=>K.jsx("div",{className:Fi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});wZe.displayName="AlertDialogFooter";const PZe=X.forwardRef(({className:t,...e},n)=>K.jsx(G2n,{ref:n,className:Fi("rf-text-lg rf-font-semibold",t),...e}));PZe.displayName=G2n.displayName;const MZe=X.forwardRef(({className:t,...e},n)=>K.jsx(Y2n,{ref:n,className:Fi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));MZe.displayName=Y2n.displayName;const OZi=X.forwardRef(({className:t,...e},n)=>K.jsx(U2n,{ref:n,className:Fi(AK(),t),...e}));OZi.displayName=U2n.displayName;const DZe=X.forwardRef(({className:t,...e},n)=>K.jsx(K2n,{ref:n,className:Fi(AK({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));DZe.displayName=K2n.displayName;var GZi=Object.defineProperty,nQ=(t,e)=>GZi(t,"name",{value:e,configurable:!0}),NZe="Checkbox",[YZi,r4r]=Vx(NZe),[UZi,RZe]=YZi(NZe);function J2n(t){const{__scopeCheckbox:e,checked:n,children:o,defaultChecked:i,disabled:r,form:s,name:a,onCheckedChange:A,required:c,value:l="on",internal_do_not_use_render:u}=t,[g,h]=qB({prop:n,defaultProp:i??!1,onChange:A,caller:NZe}),[d,m]=X.useState(null),[p,f]=X.useState(null),_=X.useRef(!1),[I,C]=X.useReducer(E=>E+1,0),y=d?!!s||!!d.closest("form"):!0,x={checked:g,disabled:r,setChecked:h,control:d,setControl:m,name:a,form:s,value:l,hasConsumerStoppedPropagationRef:_,userInteractionCount:I,onUserInteraction:C,required:c,defaultChecked:oQ(i)?!1:i,isFormControl:y,bubbleInput:p,setBubbleInput:f};return K.jsx(UZi,{scope:e,...x,children:j2n(u)?u(x):o})}nQ(J2n,"CheckboxProvider");var KZi="CheckboxTrigger",zZi=X.forwardRef(nQ(function({__scopeCheckbox:e,onKeyDown:n,onClick:o,...i},r){const{control:s,value:a,disabled:A,checked:c,required:l,setControl:u,setChecked:g,hasConsumerStoppedPropagationRef:h,onUserInteraction:d,isFormControl:m,bubbleInput:p}=RZe(KZi,e),f=LA(r,u),_=X.useRef(c);return X.useEffect(()=>{const I=s?.form;if(I){const C=nQ(()=>g(_.current),"reset");return I.addEventListener("reset",C),()=>I.removeEventListener("reset",C)}},[s,g]),K.jsx(Ra.button,{type:"button",role:"checkbox","aria-checked":oQ(c)?"mixed":c,"aria-required":l,"data-state":TZe(c),"data-disabled":A?"":void 0,disabled:A,value:a,...i,ref:f,onKeyDown:rr(n,I=>{I.key==="Enter"&&I.preventDefault()}),onClick:rr(o,I=>{d(),g(C=>oQ(C)?!0:!C),p&&m&&(h.current=I.isPropagationStopped(),h.current||I.stopPropagation())})})},"CheckboxTrigger")),W2n=X.forwardRef(nQ(function(e,n){const{__scopeCheckbox:o,name:i,checked:r,defaultChecked:s,required:a,disabled:A,value:c,onCheckedChange:l,form:u,...g}=e;return K.jsx(J2n,{__scopeCheckbox:o,checked:r,defaultChecked:s,disabled:A,required:a,onCheckedChange:l,name:i,form:u,value:c,internal_do_not_use_render:({isFormControl:h})=>K.jsxs(K.Fragment,{children:[K.jsx(zZi,{...g,ref:n,__scopeCheckbox:o}),h&&K.jsx(jZi,{__scopeCheckbox:o})]})})},"Checkbox")),VZi="CheckboxIndicator",JZi=X.forwardRef(nQ(function(e,n){const{__scopeCheckbox:o,forceMount:i,...r}=e,s=RZe(VZi,o);return K.jsx(BE,{present:i||oQ(s.checked)||s.checked===!0,children:K.jsx(Ra.span,{"data-state":TZe(s.checked),"data-disabled":s.disabled?"":void 0,...r,ref:n,style:{pointerEvents:"none",...e.style}})})},"CheckboxIndicator")),WZi="CheckboxBubbleInput",jZi=X.forwardRef(nQ(function({__scopeCheckbox:e,onClick:n,...o},i){const{control:r,hasConsumerStoppedPropagationRef:s,userInteractionCount:a,checked:A,defaultChecked:c,required:l,disabled:u,name:g,value:h,form:d,bubbleInput:m,setBubbleInput:p}=RZe(WZi,e),f=LA(i,p),_=xXe(r),I=X.useRef(!1),C=X.useRef(A),y=X.useRef(a);X.useEffect(()=>{const E=m;if(!E)return;const B=window.HTMLInputElement.prototype,Q=Object.getOwnPropertyDescriptor(B,"checked").set,w=a!==y.current;y.current=a;const M=C.current!==A;C.current=A;const T=!(w&&s.current);if(M&&Q){I.current=!w;const R=new Event("click",{bubbles:T});E.indeterminate=oQ(A),Q.call(E,oQ(A)?!1:A),E.dispatchEvent(R),I.current=!1}},[m,A,s,a]);const x=X.useRef(oQ(A)?!1:A);return K.jsx(Ra.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??x.current,required:l,disabled:u,name:g,value:h,form:d,...o,tabIndex:-1,ref:f,onClick:rr(n,E=>{I.current&&E.stopPropagation()}),style:{...o.style,..._,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function j2n(t){return typeof t=="function"}nQ(j2n,"isFunction");function oQ(t){return t==="indeterminate"}nQ(oQ,"isIndeterminate");function TZe(t){return oQ(t)?"indeterminate":t?"checked":"unchecked"}nQ(TZe,"getState");const mte=X.forwardRef(({className:t,...e},n)=>K.jsx(W2n,{ref:n,className:Fi("rf-peer rf-h-4 rf-w-4 rf-shrink-0 rf-rounded-sm rf-border rf-border-zinc-200 rf-border-zinc-900 rf-shadow focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 data-[state=checked]:rf-bg-zinc-900 data-[state=checked]:rf-text-zinc-50 dark:rf-border-zinc-800 dark:rf-border-zinc-50 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=checked]:rf-bg-zinc-50 dark:data-[state=checked]:rf-text-zinc-900",t),...e,children:K.jsx(JZi,{className:Fi("rf-flex rf-items-center rf-justify-center rf-text-current"),children:K.jsx(VS,{className:"rf-h-4 rf-w-4"})})}));mte.displayName=W2n.displayName;const hk=Z_e,qZi=e1e,q2n=X.forwardRef(({className:t,...e},n)=>K.jsx(qee,{className:Fi("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));q2n.displayName=qee.displayName;const mM=X.forwardRef(({className:t,children:e,showOverlay:n=!0,...o},i)=>K.jsxs(qZi,{children:[K.jsx(q2n,{className:Fi(n?"":"rf-hidden")}),K.jsx(Xee,{ref:i,className:Fi("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...o,children:e})]}));mM.displayName=Xee.displayName;const pM=({className:t,...e})=>K.jsx("div",{className:Fi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});pM.displayName="DialogHeader";const MK=({className:t,...e})=>K.jsx("div",{className:Fi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});MK.displayName="DialogFooter";const fM=X.forwardRef(({className:t,...e},n)=>K.jsx(t1e,{ref:n,className:Fi("rf-text-lg rf-font-semibold",t),...e}));fM.displayName=t1e.displayName;const mk=X.forwardRef(({className:t,...e},n)=>K.jsx(n1e,{ref:n,className:Fi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));mk.displayName=n1e.displayName;const w1e={"tscircuit.com":{label:"tscircuit.com",placeholder:"Search tscircuit packages...",emptyMessage:"No packages found"},jlcpcb:{label:"JLCPCB Parts",placeholder:"Search JLCPCB parts (e.g. C14663)...",emptyMessage:"No parts found"},kicad:{label:"KiCad Footprints",placeholder:"Search KiCad footprints...",emptyMessage:"No footprints found"}},$Zi="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let kZe=null;const FZe=async()=>(kZe||(kZe=import($Zi)),kZe),XZi=t=>(e,n)=>{const o=new Headers(n?.headers),i={};return o.forEach((r,s)=>{i[s]=r}),fetch(`${t?.apiBase??UC}/proxy`,{...n,headers:{...i,"X-Target-Url":e.toString(),"X-Sender-Origin":i.origin??"","X-Sender-Host":i.host??"https://easyeda.com","X-Sender-Referer":i.referer??"","X-Sender-User-Agent":i["user-agent"]??"","X-Sender-Cookie":i.cookie??"",authority:i.authority??"","content-type":i["content-type"]??"",...t?.headers}})},ZZi=async(t,e=10)=>{const n=encodeURIComponent(t),o=await fetch(`https://jlcsearch.tscircuit.com/api/search?limit=${e}&q=${n}`);if(!o.ok)throw new Error(`JLCPCB API error: ${o.status}`);return(await o.json()).components??[]},eer=t=>({lcscId:t.lcsc,manufacturer:t.mfr,description:t.description,partNumber:`C${t.lcsc}`,package:t.package,price:t.price,stock:t.stock,isBasic:t.is_basic}),$2n=async(t,e)=>{const{fetchEasyEDAComponent:n}=await FZe();return n(t,{fetch:XZi(e),includeModelMetadata:e?.includeModelMetadata})},ter=async(t,e)=>{const{convertRawEasyToTsx:n}=await FZe(),o=await $2n(t,e);return n({rawEasy:o})},ner=async(t,e)=>{const{EasyEdaJsonSchema:n,convertEasyEdaJsonToCircuitJson:o}=await FZe(),i=await $2n(t,{...e,includeModelMetadata:!1}),r=n.parse(i);return o(r,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function _M(t){return Array.isArray?Array.isArray(t):Z2n(t)==="[object Array]"}function oer(t){if(typeof t=="string")return t;if(typeof t=="bigint")return t.toString();const e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function LZe(t){return t==null?"":oer(t)}function XC(t){return typeof t=="string"}function P1e(t){return typeof t=="number"}function ier(t){return t===!0||t===!1||rer(t)&&Z2n(t)=="[object Boolean]"}function X2n(t){return typeof t=="object"}function rer(t){return X2n(t)&&t!==null}function ZE(t){return t!=null}function M1e(t){return!t.trim().length}function Z2n(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const ser="Incorrect 'index' type",HZe="Invalid doc index: must be a non-negative integer within the bounds of the docs array",aer=t=>`Invalid value for key ${t}`,Aer=t=>`Pattern length exceeds max of ${t}.`,cer=t=>`Missing ${t} property in key`,ler=t=>`Property 'weight' in key '${t}' must be a positive integer`,uer="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",exn=Object.prototype.hasOwnProperty;var ger=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(n=>{const o=txn(n);this._keys.push(o),this._keyMap[o.id]=o,e+=o.weight}),this._keys.forEach(n=>{n.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function txn(t){let e=null,n=null,o=null,i=1,r=null;if(XC(t)||_M(t))o=t,e=nxn(t),n=D1e(t);else{if(!exn.call(t,"name"))throw new Error(cer("name"));const s=t.name;if(o=s,exn.call(t,"weight")&&t.weight!==void 0&&(i=t.weight,i<=0))throw new Error(ler(D1e(s)));e=nxn(s),n=D1e(s),r=t.getFn??null}return{path:e,id:n,weight:i,src:o,getFn:r}}function nxn(t){return _M(t)?t:t.split(".")}function D1e(t){return _M(t)?t.join("."):t}function der(t,e){const n=[];let o=!1;const i=(r,s,a,A)=>{if(ZE(r))if(!s[a])n.push(A!==void 0?{v:r,i:A}:r);else{const c=r[s[a]];if(!ZE(c))return;if(a===s.length-1&&(XC(c)||P1e(c)||ier(c)||typeof c=="bigint"))n.push(A!==void 0?{v:LZe(c),i:A}:LZe(c));else if(_M(c)){o=!0;for(let l=0,u=c.length;l<u;l+=1)i(c[l],s,a+1,l)}else s.length&&i(c,s,a+1,A)}};return i(t,XC(e)?e.split("."):e,0),o?n:n[0]}const Pa=Object.freeze({...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:der,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function her(t){return t>=9&&t<=13||t===32||t===160}function mer(t=1,e=3){const n=new Map,o=Math.pow(10,e);return{get(i){let r=0,s=!1;for(let A=0;A<i.length;A++)her(i.charCodeAt(A))?s=!1:s||(r++,s=!0);if(r===0&&(r=1),n.has(r))return n.get(r);const a=Math.round(o/Math.pow(r,.5*t))/o;return n.set(r,a),a},clear(){n.clear()}}}var OZe=class{constructor({getFn:t=Pa.getFn,fieldNormWeight:e=Pa.fieldNormWeight}={}){this.norm=mer(e,3),this.getFn=t,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,n)=>{this._keysMap[e.id]=n})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const t=this.docs.length;this.records=new Array(t);let e=0;if(XC(this.docs[0]))for(let n=0;n<t;n++){const o=this._createStringRecord(this.docs[n],n);o&&(this.records[e++]=o)}else for(let n=0;n<t;n++)this.records[e++]=this._createObjectRecord(this.docs[n],n);this.records.length=e,this.norm.clear()}add(t,e){if(!Number.isInteger(e)||e<0)throw new Error(HZe);if(XC(t)){const o=this._createStringRecord(t,e);return o&&this.records.push(o),o}const n=this._createObjectRecord(t,e);return this.records.push(n),n}removeAt(t){if(!Number.isInteger(t)||t<0)throw new Error(HZe);for(let e=0,n=this.records.length;e<n;e+=1)if(this.records[e].i===t){this.records.splice(e,1);break}for(let e=0,n=this.records.length;e<n;e+=1)this.records[e].i>t&&(this.records[e].i-=1)}removeAll(t){const e=new Set;for(const o of t)Number.isInteger(o)&&o>=0&&e.add(o);if(e.size===0)return;this.records=this.records.filter(o=>!e.has(o.i));const n=Array.from(e).sort((o,i)=>o-i);for(const o of this.records){let i=0,r=n.length;for(;i<r;){const s=i+r>>>1;n[s]<o.i?i=s+1:r=s}o.i-=i}}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_createStringRecord(t,e){return!ZE(t)||M1e(t)?null:{v:t,i:e,n:this.norm.get(t)}}_createObjectRecord(t,e){const n={i:e,$:{}};for(let o=0,i=this.keys.length;o<i;o++){const r=this.keys[o],s=r.getFn?r.getFn(t):this.getFn(t,r.path);if(ZE(s)){if(_M(s)){const a=[];for(let A=0,c=s.length;A<c;A+=1){const l=s[A];if(ZE(l)){if(XC(l)){if(!M1e(l)){const u={v:l,i:A,n:this.norm.get(l)};a.push(u)}}else if(ZE(l.v)){const u=XC(l.v)?l.v:LZe(l.v);if(!M1e(u)){const g={v:u,i:l.i,n:this.norm.get(u)};a.push(g)}}}}n.$[o]=a}else if(XC(s)&&!M1e(s)){const a={v:s,n:this.norm.get(s)};n.$[o]=a}}}return n}toJSON(){return{keys:this.keys.map(({getFn:t,...e})=>e),records:this.records}}};function oxn(t,e,{getFn:n=Pa.getFn,fieldNormWeight:o=Pa.fieldNormWeight}={}){const i=new OZe({getFn:n,fieldNormWeight:o});return i.setKeys(t.map(txn)),i.setSources(e),i.create(),i}function per(t,{getFn:e=Pa.getFn,fieldNormWeight:n=Pa.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new OZe({getFn:e,fieldNormWeight:n});return r.setKeys(o),r.setIndexRecords(i),r}function fer(t=[],e=Pa.minMatchCharLength){const n=[];let o=-1,i=-1,r=0;for(let s=t.length;r<s;r+=1){const a=t[r];a&&o===-1?o=r:!a&&o!==-1&&(i=r-1,i-o+1>=e&&n.push([o,i]),o=-1)}return t[r-1]&&r-o>=e&&n.push([o,r-1]),n}function _er(t,e,n,{location:o=Pa.location,distance:i=Pa.distance,threshold:r=Pa.threshold,findAllMatches:s=Pa.findAllMatches,minMatchCharLength:a=Pa.minMatchCharLength,includeMatches:A=Pa.includeMatches,ignoreLocation:c=Pa.ignoreLocation}={}){if(e.length>32)throw new Error(Aer(32));const l=e.length,u=t.length,g=Math.max(0,Math.min(o,u));let h=r,d=g;const m=(S,Q)=>{const w=S/l;if(c)return w;const M=Math.abs(g-Q);return i?w+M/i:M?1:w},p=a>1||A,f=p?Array(u):[];let _;for(;(_=t.indexOf(e,d))>-1;){const S=m(0,_);if(h=Math.min(S,h),d=_+l,p){let Q=0;for(;Q<l;)f[_+Q]=1,Q+=1}}d=-1;let I=[],C=1,y=0,x=l+u;const E=1<<l-1;for(let S=0;S<l;S+=1){let Q=0,w=x;for(;Q<w;)m(S,g+w)<=h?Q=w:x=w,w=Math.floor((x-Q)/2+Q);x=w;let M=Math.max(1,g-w+1);const T=s?u:Math.min(g+w,u)+l,R=Array(T+2);R[T+1]=(1<<S)-1;for(let F=T;F>=M;F-=1){const O=F-1,U=n[t[O]];if(R[F]=(R[F+1]<<1|1)&U,S&&(R[F]|=(I[F+1]|I[F])<<1|1|I[F+1]),R[F]&E&&(C=m(S,O),C<=h)){if(h=C,d=O,y=S,d<=g)break;M=Math.max(1,2*g-d)}}if(m(S+1,g)>h)break;I=R}if(p&&d>=0){const S=Math.min(u-1,d+l-1+y);for(let Q=d;Q<=S;Q+=1)n[t[Q]]&&(f[Q]=1)}const B={isMatch:d>=0,score:Math.max(.001,C)};if(p){const S=fer(f,a);S.length?A&&(B.indices=S):B.isMatch=!1}return B}function Ier(t){const e={};for(let n=0,o=t.length;n<o;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<o-n-1}return e}function GZe(t){if(t.length<=1)return t;t.sort((n,o)=>n[0]-o[0]||n[1]-o[1]);const e=[t[0]];for(let n=1,o=t.length;n<o;n+=1){const i=e[e.length-1],r=t[n];r[0]<=i[1]+1?i[1]=Math.max(i[1],r[1]):e.push(r)}return e}const ixn={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},Cer=new RegExp("["+Object.keys(ixn).join("")+"]","g"),pte=typeof String.prototype.normalize=="function"?t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(Cer,e=>ixn[e]):t=>t;var YZe=class{constructor(t,{location:e=Pa.location,threshold:n=Pa.threshold,distance:o=Pa.distance,includeMatches:i=Pa.includeMatches,findAllMatches:r=Pa.findAllMatches,minMatchCharLength:s=Pa.minMatchCharLength,isCaseSensitive:a=Pa.isCaseSensitive,ignoreDiacritics:A=Pa.ignoreDiacritics,ignoreLocation:c=Pa.ignoreLocation}={}){if(this.options={location:e,threshold:n,distance:o,includeMatches:i,findAllMatches:r,minMatchCharLength:s,isCaseSensitive:a,ignoreDiacritics:A,ignoreLocation:c},t=a?t:t.toLowerCase(),t=A?pte(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const l=(g,h)=>{this.chunks.push({pattern:g,alphabet:Ier(g),startIndex:h})},u=this.pattern.length;if(u>32){let g=0;const h=u%32,d=u-h;for(;g<d;)l(this.pattern.substr(g,32),g),g+=32;if(h){const m=u-32;l(this.pattern.substr(m),m)}}else l(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o}=this.options;if(t=e?t:t.toLowerCase(),t=n?pte(t):t,this.pattern===t){if(t.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const d={isMatch:!0,score:0};return o&&(d.indices=[[0,t.length-1]]),d}const{location:i,distance:r,threshold:s,findAllMatches:a,minMatchCharLength:A,ignoreLocation:c}=this.options,l=[];let u=0,g=!1;this.chunks.forEach(({pattern:d,alphabet:m,startIndex:p})=>{const{isMatch:f,score:_,indices:I}=_er(t,d,m,{location:i+p,distance:r,threshold:s,findAllMatches:a,minMatchCharLength:A,includeMatches:o,ignoreLocation:c});f&&(g=!0),u+=_,f&&I&&l.push(...I)});const h={isMatch:g,score:g?u/this.chunks.length:1};return g&&o&&(h.indices=GZe(l)),h}};const yer=new Set(["fuzzy","include"]);function xer(t){return t.startsWith("inverse")}const UZe=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:t=>({type:"exact",search(e){const n=e===t;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:t=>({type:"include",search(e){let n=0,o;const i=[],r=t.length;for(;(o=e.indexOf(t,n))>-1;)n=o+r,i.push([o,n-1]);const s=!!i.length;return{isMatch:s,score:s?0:1,indices:i}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:t=>({type:"prefix-exact",search(e){const n=e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:t=>({type:"inverse-prefix-exact",search(e){const n=!e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:t=>({type:"inverse-suffix-exact",search(e){const n=!e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:t=>({type:"suffix-exact",search(e){const n=e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[e.length-t.length,e.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:t=>({type:"inverse-exact",search(e){const n=e.indexOf(t)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(t,e={})=>{const n=new YZe(t,{location:e.location??Pa.location,threshold:e.threshold??Pa.threshold,distance:e.distance??Pa.distance,includeMatches:e.includeMatches??Pa.includeMatches,findAllMatches:e.findAllMatches??Pa.findAllMatches,minMatchCharLength:e.minMatchCharLength??Pa.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??Pa.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??Pa.ignoreDiacritics,ignoreLocation:e.ignoreLocation??Pa.ignoreLocation});return{type:"fuzzy",search(o){return n.searchIn(o)}}}}],rxn=UZe.length,Eer="\0",Ber="|";function ber(t){const e=[],n=t.length;let o=0;for(;o<n;){for(;o<n&&t[o]===" ";)o++;if(o>=n)break;let i=o;for(;i<n&&t[i]!==" "&&t[i]!=='"';)i++;if(i<n&&t[i]==='"'){for(i++;i<n;){if(t[i]==='"'){const r=i+1;if(r>=n||t[r]===" "){i++;break}if(t[r]==="$"&&(r+1>=n||t[r+1]===" ")){i+=2;break}}i++}e.push(t.substring(o,i)),o=i}else{for(;i<n&&t[i]!==" ";)i++;e.push(t.substring(o,i)),o=i}}return e}function sxn(t,e){const n=t.match(e);return n?n[1]:null}function Ser(t,e={}){return t.replace(/\\\|/g,Eer).split(Ber).map(n=>{const o=ber(n.replace(/\u0000/g,"|").trim()).filter(r=>r&&!!r.trim()),i=[];for(let r=0,s=o.length;r<s;r+=1){const a=o[r];let A=!1,c=-1;for(;!A&&++c<rxn;){const l=UZe[c],u=sxn(a,l.multiRegex);u&&(i.push(l.create(u,e)),A=!0)}if(!A)for(c=-1;++c<rxn;){const l=UZe[c],u=sxn(a,l.singleRegex);if(u){i.push(l.create(u,e));break}}}return i})}var Qer=class{constructor(t,{isCaseSensitive:e=Pa.isCaseSensitive,ignoreDiacritics:n=Pa.ignoreDiacritics,includeMatches:o=Pa.includeMatches,minMatchCharLength:i=Pa.minMatchCharLength,ignoreLocation:r=Pa.ignoreLocation,findAllMatches:s=Pa.findAllMatches,location:a=Pa.location,threshold:A=Pa.threshold,distance:c=Pa.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o,minMatchCharLength:i,findAllMatches:s,ignoreLocation:r,location:a,threshold:A,distance:c},t=e?t:t.toLowerCase(),t=n?pte(t):t,this.pattern=t,this.query=Ser(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:o,ignoreDiacritics:i}=this.options;t=o?t:t.toLowerCase(),t=i?pte(t):t;let r=0;const s=[];let a=0,A=!1;for(let c=0,l=e.length;c<l;c+=1){const u=e[c];s.length=0,r=0,A=!1;for(let g=0,h=u.length;g<h;g+=1){const d=u[g],{isMatch:m,indices:p,score:f}=d.search(t);if(m)r+=1,a+=f,xer(d.type)&&(A=!0),n&&(yer.has(d.type)?s.push(...p):s.push(p));else{a=0,r=0,s.length=0,A=!1;break}}if(r){const g={isMatch:!0,score:a/r};return A&&(g.hasInverse=!0),n&&(g.indices=GZe(s)),g}}return{isMatch:!1,score:1}}};const KZe=[];function zZe(...t){KZe.push(...t)}function N1e(t,e){for(let n=0,o=KZe.length;n<o;n+=1){const i=KZe[n];if(i.condition(t,e))return new i(t,e)}return new YZe(t,e)}const R1e={AND:"$and",OR:"$or"},VZe={PATH:"$path",PATTERN:"$val"},JZe=t=>!!(t[R1e.AND]||t[R1e.OR]),ver=t=>!!t[VZe.PATH],wer=t=>!_M(t)&&X2n(t)&&!JZe(t),axn=t=>({[R1e.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function Axn(t,e,{auto:n=!0}={}){const o=i=>{if(XC(i)){const A={keyId:null,pattern:i};return n&&(A.searcher=N1e(i,e)),A}const r=Object.keys(i),s=ver(i);if(!s&&r.length>1&&!JZe(i))return o(axn(i));if(wer(i)){const A=s?i[VZe.PATH]:r[0],c=s?i[VZe.PATTERN]:i[A];if(!XC(c))throw new Error(aer(A));const l={keyId:D1e(A),pattern:c};return n&&(l.searcher=N1e(c,e)),l}const a={children:[],operator:r[0]};return r.forEach(A=>{const c=i[A];_M(c)&&c.forEach(l=>{a.children.push(o(l))})}),a};return JZe(t)||(t=axn(t)),o(t)}function WZe(t,{ignoreFieldNorm:e=Pa.ignoreFieldNorm}){let n=1;return t.forEach(({key:o,norm:i,score:r})=>{const s=o?o.weight:null;n*=Math.pow(r===0&&s?Number.EPSILON:r,(s||1)*(e?1:i))}),n}function Per(t,{ignoreFieldNorm:e=Pa.ignoreFieldNorm}){t.forEach(n=>{n.score=WZe(n.matches,{ignoreFieldNorm:e})})}var Mer=class{constructor(t,e){this.limit=t,this.heap=[],this.comparator=e}get size(){return this.heap.length}insert(t){this.size<this.limit?(this.heap.push(t),this._bubbleUp(this.size-1)):this.comparator(t,this.heap[0])<0&&(this.heap[0]=t,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(t){const e=this.heap;for(;t>0;){const n=t-1>>1;if(this.comparator(e[t],e[n])<=0)break;const o=e[t];e[t]=e[n],e[n]=o,t=n}}_sinkDown(t){const e=this.heap,n=e.length;let o=t;do{t=o;const i=2*t+1,r=2*t+2;if(i<n&&this.comparator(e[i],e[o])>0&&(o=i),r<n&&this.comparator(e[r],e[o])>0&&(o=r),o!==t){const s=e[t];e[t]=e[o],e[o]=s}}while(o!==t)}};function Der(t){const e=[];return t.matches.forEach(n=>{if(!ZE(n.indices)||!n.indices.length)return;const o={indices:n.indices,value:n.value};n.key&&(o.key=n.key.id),n.idx>-1&&(o.refIndex=n.idx),e.push(o)}),e}function Ner(t,e,{includeMatches:n=Pa.includeMatches,includeScore:o=Pa.includeScore}={}){return t.map(i=>{const{idx:r}=i,s={item:e[r],refIndex:r};return n&&(s.matches=Der(i)),o&&(s.score=i.score),s})}const Rer=/[\p{L}\p{M}\p{N}_]+/gu,cxn=new WeakSet;function Ter(t){cxn.has(t)||(cxn.add(t),console.warn(`[Fuse] tokenize regex ${t} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function ker(t){if(typeof t=="function"){let e=!1;return n=>{const o=t(n);if(!e&&(e=!0,!Array.isArray(o)||o.some(i=>typeof i!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(o)?"array containing non-strings":typeof o}.`);return o}}return t instanceof RegExp?(t.global||Ter(t),e=>e.match(t)||[]):e=>e.match(Rer)||[]}function jZe({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const o=ker(n);return{tokenize(i){return t||(i=i.toLowerCase()),e&&(i=pte(i)),o(i)}}}var Fer=class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=jZe({isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,tokenize:e.tokenize});const n=this.analyzer.tokenize(t),{df:o,fieldCount:i}=e._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const r of n){this.termSearchers.push(new YZe(r,{location:e.location,threshold:e.threshold,distance:e.distance,includeMatches:e.includeMatches,findAllMatches:e.findAllMatches,minMatchCharLength:e.minMatchCharLength,isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,ignoreLocation:!0}));const s=o.get(r)||0,a=Math.log(1+(i-s+.5)/(s+.5));this.idfWeights.push(a)}this.combineAll=e.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(t){if(!this.termSearchers.length)return{isMatch:!1,score:1};const e=[];let n=0,o=0,i=0,r=0;const s=this.combineAll&&!this.useMask?new Set:null;for(let c=0;c<this.termSearchers.length;c++){const l=this.termSearchers[c].searchIn(t),u=this.idfWeights[c];o+=u,l.isMatch&&(i++,n+=u*(1-l.score),l.indices&&e.push(...l.indices),this.combineAll&&(this.useMask?r|=1<<c:s.add(c)))}if(i===0)return{isMatch:!1,score:1};const a=o>0?1-n/o:0,A={isMatch:!0,score:Math.max(.001,a)};return this.options.includeMatches&&e.length&&(A.indices=GZe(e)),this.combineAll&&(this.useMask?A.matchedMask=r:A.matchedTerms=s,A.termCount=this.numTerms),A}};function qZe(t,e,n,o){const i=o.tokenize(e);if(!i.length)return;t.fieldCount++,t.docFieldCount.set(n,(t.docFieldCount.get(n)||0)+1);const r=new Set(i);let s=t.docTermFieldHits.get(n);s||(s=new Map,t.docTermFieldHits.set(n,s));for(const a of r)s.set(a,(s.get(a)||0)+1),t.df.set(a,(t.df.get(a)||0)+1)}function lxn(t,e,n,o){const{i,v:r,$:s}=e;if(r!==void 0){qZe(t,r,i,o);return}if(s)for(let a=0;a<n;a++){const A=s[a];if(A)if(Array.isArray(A))for(const c of A)qZe(t,c.v,i,o);else qZe(t,A.v,i,o)}}function Ler(t,e,n){const o={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const i of t)lxn(o,i,e,n);return o}function Her(t,e,n,o){lxn(t,e,n,o)}function Oer(t,e){const n=t.docFieldCount.get(e);if(n===void 0)return;t.fieldCount-=n,t.docFieldCount.delete(e);const o=t.docTermFieldHits.get(e);if(o){for(const[i,r]of o){const s=(t.df.get(i)||0)-r;s<=0?t.df.delete(i):t.df.set(i,s)}t.docTermFieldHits.delete(e)}}function uxn(t,e){if(e.length===0)return;const n=Array.from(new Set(e)).sort((a,A)=>a-A);for(const a of n)Oer(t,a);const o=a=>{let A=0,c=n.length;for(;A<c;){const l=A+c>>>1;n[l]<a?A=l+1:c=l}return a-A},i=n[0],r=new Map;for(const[a,A]of t.docFieldCount)r.set(a>i?o(a):a,A);t.docFieldCount=r;const s=new Map;for(const[a,A]of t.docTermFieldHits)s.set(a>i?o(a):a,A);t.docTermFieldHits=s}var IM=class{constructor(t,e,n){this.options={...Pa,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new ger(this.options.keys),this._docs=t,this._myIndex=null,this._invertedIndex=null,this.setCollection(t,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(t){if(this._lastQuery===t)return this._lastSearcher;const e=N1e(t,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=t,this._lastSearcher=e,e}setCollection(t,e){if(this._docs=t,e&&!(e instanceof OZe))throw new Error(ser);if(this._myIndex=e||oxn(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const n=jZe({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=Ler(this._myIndex.records,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}add(t){if(!ZE(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const n=jZe({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});Her(this._invertedIndex,e,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}remove(t=()=>!1){const e=[],n=[];for(let o=0,i=this._docs.length;o<i;o+=1)t(this._docs[o],o)&&(e.push(this._docs[o]),n.push(o));if(n.length){this._invertedIndex&&uxn(this._invertedIndex,n);const o=new Set(n);this._docs=this._docs.filter((i,r)=>!o.has(r)),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return e}removeAt(t){if(!Number.isInteger(t)||t<0||t>=this._docs.length)throw new Error(HZe);this._invertedIndex&&uxn(this._invertedIndex,[t]);const e=this._docs.splice(t,1)[0];return this._myIndex.removeAt(t),this._invalidateSearcherCache(),e}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(t=>this._keyStore.get(t.id)||t)}search(t,e){const{limit:n=-1}=e||{},{includeMatches:o,includeScore:i,shouldSort:r,sortFn:s,ignoreFieldNorm:a}=this.options;if(XC(t)&&!t.trim()){let g=this._docs.map((h,d)=>({item:h,refIndex:d}));return P1e(n)&&n>-1&&(g=g.slice(0,n)),g}const A=r&&P1e(n)&&n>0&&XC(t),c=s,l=(g,h)=>c(g,h)||g.idx-h.idx;let u;if(A){const g=new Mer(n,l);XC(this._docs[0])?this._searchStringList(t,{heap:g,ignoreFieldNorm:a}):this._searchObjectList(t,{heap:g,ignoreFieldNorm:a}),u=g.extractSorted()}else u=XC(t)?XC(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),Per(u,{ignoreFieldNorm:a}),r&&u.sort(XC(t)?l:c),P1e(n)&&n>-1&&(u=u.slice(0,n));return Ner(u,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,s=e?null:[];return r.forEach(({v:a,i:A,n:c})=>{if(!ZE(a))return;const l=o.searchIn(a);if(l.isMatch){const u={score:l.score,value:a,norm:c,indices:l.indices};i&&(u.matchedMask=l.matchedMask,u.matchedTerms=l.matchedTerms,u.termCount=l.termCount);const g=[u];if(!i||this._coversAllTokens(g)){const h={item:a,idx:A,matches:g};e?(h.score=WZe(h.matches,{ignoreFieldNorm:n}),e.insert(h)):s.push(h)}}}),s}_searchLogical(t){const e=Axn(t,this.options),n=this._normalizedKeys(),o=(a,A,c)=>{if(!("children"in a)){const{keyId:h,searcher:d}=a;let m;return h===null?(m=[],n.forEach((p,f)=>{m.push(...this._findMatches({key:p,value:A[f],searcher:d}))})):m=this._findMatches({key:this._keyStore.get(h),value:this._myIndex.getValueForItemAtKeyId(A,h),searcher:d}),m&&m.length?[{idx:c,item:A,matches:m}]:[]}const{children:l,operator:u}=a,g=[];for(let h=0,d=l.length;h<d;h+=1){const m=l[h],p=o(m,A,c);if(p.length)g.push(...p);else if(u===R1e.AND)return[]}return g},i=this._myIndex.records,r=new Map,s=[];return i.forEach(({$:a,i:A})=>{if(ZE(a)){const c=o(e,a,A);c.length&&(r.has(A)||(r.set(A,{idx:A,item:a,matches:[]}),s.push(r.get(A))),c.forEach(({matches:l})=>{r.get(A).matches.push(...l)}))}}),s}_searchObjectList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,s=this._normalizedKeys(),a=e?null:[];return r.forEach(({$:A,i:c})=>{if(!ZE(A))return;const l=[];let u=!1,g=!1;if(s.forEach((h,d)=>{const m=this._findMatches({key:h,value:A[d],searcher:o});m.length?(l.push(...m),m[0].hasInverse&&(g=!0)):u=!0}),!(g&&u)&&l.length&&(!i||this._coversAllTokens(l))){const h={idx:c,item:A,matches:l};e?(h.score=WZe(h.matches,{ignoreFieldNorm:n}),e.insert(h)):a.push(h)}}),a}_findMatches({key:t,value:e,searcher:n}){if(!ZE(e))return[];const o=[];if(_M(e))e.forEach(({v:i,i:r,n:s})=>{if(!ZE(i))return;const a=n.searchIn(i);if(a.isMatch){const A={score:a.score,key:t,value:i,idx:r,norm:s,indices:a.indices,hasInverse:a.hasInverse};a.termCount!==void 0&&(A.matchedMask=a.matchedMask,A.matchedTerms=a.matchedTerms,A.termCount=a.termCount),o.push(A)}});else{const{v:i,n:r}=e,s=n.searchIn(i);if(s.isMatch){const a={score:s.score,key:t,value:i,norm:r,indices:s.indices,hasInverse:s.hasInverse};s.termCount!==void 0&&(a.matchedMask=s.matchedMask,a.matchedTerms=s.matchedTerms,a.termCount=s.termCount),o.push(a)}}return o}_coversAllTokens(t){const e=t.length?t[0].termCount:void 0;if(e===void 0)return!0;if(e<=31){let o=0;for(let i=0;i<t.length;i++)o|=t[i].matchedMask||0;return o===2**e-1}const n=new Set;for(let o=0;o<t.length;o++){const i=t[o].matchedTerms;if(i)for(const r of i)n.add(r)}return n.size===e}};IM.version="7.5.0",IM.createIndex=oxn,IM.parseIndex=per,IM.config=Pa,IM.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error(uer);return N1e(t,{...Pa,...n}).searchIn(e)},IM.parseQuery=Axn,zZe(Qer),zZe(Fer),IM.use=function(...t){t.forEach(e=>zZe(e))};var Ger=IM;const Yer="https://kicad-mod-cache.tscircuit.com";let $Ze=null,fte=null,XZe=null;const Uer=async()=>$Ze||fte||(fte=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>($Ze=t,fte=null,t)),fte),Ker=async(t,e=20)=>{const n=await Uer();return XZe||(XZe=new Ger(n)),XZe.search(t).slice(0,e).map(o=>o.item)},zer=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},Ver=t=>t.replace(/^\/+/,"").split("/").map(e=>encodeURIComponent(e)).join("/"),Jer=async t=>{const e=await fetch(`${Yer}/${Ver(t)}`);if(!e.ok)throw new Error(`KiCad footprint fetch failed: ${e.status}`);const n=await e.text(),{KicadFootprintToCircuitJsonConverter:o}=await $E("kicad-to-circuit-json"),i=new o;return i.addFile(t.split("/").pop()??"selected-footprint.kicad_mod",n),i.runUntilFinished(),i.getOutput()},gxn=t=>t?.source==="jlcpcb"||t?.source==="kicad",Wer=async(t,e)=>{if(t.source==="jlcpcb")return ner(t.component.partNumber,e?.jlcpcb);if(t.source==="kicad")return Jer(t.footprint.path);throw new Error("Footprint preview is not available for this source")},jer=({query:t,placeholder:e,isSearching:n,onQueryChange:o,onSubmit:i})=>{const r=X.useCallback(s=>{s.key==="Enter"&&(s.preventDefault(),i())},[i]);return K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[K.jsxs("div",{className:"rf-relative rf-flex-grow",children:[K.jsx(Z$e,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),K.jsx(fZe,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:s=>o(s.target.value),onKeyDown:r})]}),K.jsx(IA,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?K.jsx(VE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):K.jsxs(K.Fragment,{children:[K.jsx(Z$e,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),K.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},qer=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),$er=t=>qer.format(t),dxn=t=>{switch(t.source){case"tscircuit.com":{const e=t.package;return`tscircuit-${e.package_id??`${e.org_owner_tscircuit_handle??"unknown"}-${e.unscoped_name??e.name??"package"}`}`}case"jlcpcb":return`jlc-${t.component.lcscId}`;case"kicad":return`kicad-${t.footprint.path}`;default:return"unknown"}},Xer=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.isDirectLookup?t.component.partNumber:t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},Zer=t=>{switch(t.source){case"tscircuit.com":return t.package.description||(t.package.org_owner_tscircuit_handle?`Component by ${t.package.org_owner_tscircuit_handle}`:void 0);case"jlcpcb":return t.component.description;case"kicad":return t.footprint.description}},etr=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.isDirectLookup?void 0:t.component.partNumber;case"kicad":return}},ttr=({results:t,selected:e,onSelect:n,onShowDetails:o})=>{const i=e?dxn(e):null;return K.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(r=>{const s=dxn(r),a=i===s,A=Xer(r),c=Zer(r),l=etr(r),u=r.source==="jlcpcb"?r.component.stock:null,g=r.source==="jlcpcb"?r.component.price:null,h=r.source==="jlcpcb"?r.component.isBasic:null,d=r.source==="jlcpcb"?r.component.isDirectLookup:!1;return K.jsxs("div",{className:`rf-p-3 rf-flex rf-flex-col sm:rf-grid sm:rf-grid-cols-[minmax(0,1fr)_auto] rf-items-start sm:rf-items-center rf-cursor-pointer hover:rf-bg-zinc-100 rf-gap-2 rf-overflow-hidden ${a?"rf-bg-zinc-100":""}`,onClick:()=>n(r),children:[K.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[K.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[K.jsxs("div",{className:"rf-font-medium rf-text-sm rf-truncate rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-gap-1.5",children:[A,r.source==="jlcpcb"&&h!=null&&K.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${h?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:h?"Basic":"Extended"}),d&&K.jsx("span",{className:"rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 rf-bg-blue-100 rf-text-blue-700",children:"Direct lookup"}),r.source==="tscircuit.com"&&r.package.is_private&&K.jsx(cKi,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),r.source==="jlcpcb"&&u!=null?K.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[u.toLocaleString()," in stock"]}):null]}),K.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[l?K.jsx("span",{className:"rf-mr-2",children:l}):null,c]})]}),K.jsxs("div",{children:[r.source==="tscircuit.com"&&o?K.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:K.jsx(IA,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:m=>{m.stopPropagation(),o(r)},children:"See Details"})}):r.source==="jlcpcb"&&u!=null?K.jsxs("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0",children:[u.toLocaleString()," in stock"]}):null,g!=null&&K.jsx("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 rf-text-right",children:$er(g)})]})]},s)})})},ntr=({circuitJson:t,error:e,isLoading:n,height:o})=>K.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:o},children:n?K.jsxs("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-gap-2 rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:[K.jsx(VE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):e?K.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-p-4",style:{height:o},children:K.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[K.jsx(X$e,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),K.jsx("span",{children:e})]})}):t?K.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:K.jsx(j$e,{circuitJson:t,height:o,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):K.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:"No preview"})}),hxn={importComponentDialog:101,importComponentDetailsDialog:102},otr=({packageResult:t,isOpen:e,onOpenChange:n,isLoading:o,details:i,previewTab:r,onPreviewTabChange:s,isSubmitting:a,onImport:A})=>{const c=t?.package??null,l=c?.latest_pcb_preview_image_url,u=c?.latest_sch_preview_image_url,g=c?.latest_cad_preview_image_url,h=c?.unscoped_name?.split("/").pop()??c?.unscoped_name,d=c?.org_owner_tscircuit_handle??void 0,m=d?`https://tscircuit.com/${d}`:void 0,p=d&&h?`https://tscircuit.com/${d}/${h}`:void 0;return K.jsx(hk,{open:e,onOpenChange:n,children:K.jsxs(mM,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:hxn.importComponentDetailsDialog},className:"rf-max-w-5xl no-scrollbar !rf-overflow-y-auto rf-max-h-[90vh] rf-overflow-hidden rf-flex rf-flex-col rf-rounded-sm",children:[K.jsx(pM,{className:"rf-pb-4 rf-border-b",children:K.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:K.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[K.jsx(fM,{className:"rf-text-xl rf-font-semibold rf-truncate",children:h}),K.jsx(mk,{children:c?.description})]})})}),K.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[d?K.jsxs("div",{children:[K.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),K.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:m?K.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:d}):d})]}):null,(g||l||u)&&K.jsx(K.Fragment,{children:K.jsxs("div",{children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),K.jsxs(DTe,{value:r,onValueChange:f=>s(f),children:[K.jsxs(Ude,{className:"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",children:[l&&K.jsx(k7,{value:"pcb",children:"PCB"}),u&&K.jsx(k7,{value:"schematic",children:"Schematic"}),g&&K.jsx(k7,{value:"3d",children:"3D"})]}),K.jsxs("div",{className:"rf-mt-4",children:[K.jsx(bI,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:l?K.jsx("img",{src:l,alt:`${h??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),K.jsx(bI,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?K.jsx("img",{src:u,alt:`${h??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),K.jsx(bI,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:g?K.jsx("img",{src:g,alt:`${h??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?K.jsxs("section",{children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),K.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:K.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?K.jsxs("section",{children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),K.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:K.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,o?K.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[K.jsx(VE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),K.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),K.jsxs(MK,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[K.jsx("div",{className:"rf-flex-1",children:p?K.jsxs(IA,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(p,"_blank"),children:[K.jsx(nKi,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),K.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[K.jsx(IA,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),K.jsx(IA,{onClick:A,disabled:a,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:a?K.jsx(VE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},itr=()=>{const[t,e]=X.useState(null),[n,o]=X.useState(!1),i=X.useCallback(async(s,a)=>{o(!0);try{const A=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${s}/${a}`)}`);if(!A.ok)throw new Error(`Failed to load package details: ${A.status}`);const c=await A.json();e(c.package??null)}catch(A){console.error("Failed to fetch package details",A),e(null)}finally{o(!1)}},[]),r=X.useCallback(()=>{e(null),o(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:r}},rtr=(t,e)=>{const[n,o]=X.useState({circuitJson:null,error:null,isLoading:!1});return X.useEffect(()=>{if(!t||!gxn(t)){o({circuitJson:null,error:null,isLoading:!1});return}let i=!1;return o({circuitJson:null,error:null,isLoading:!0}),Wer(t,e).then(r=>{i||o({circuitJson:r,error:null,isLoading:!1})}).catch(r=>{i||o({circuitJson:null,error:r instanceof Error?r.message:"Failed to load footprint preview",isLoading:!1})}),()=>{i=!0}},[t,e]),n},str=async(t,e)=>{const n={"Content-Type":"application/json"};e&&(n.Authorization=`Bearer ${e}`);const o=await fetch("https://registry-api.tscircuit.com/packages/search",{method:"POST",headers:n,body:JSON.stringify({query:t})});if(!o.ok)throw new Error(`tscircuit registry error: ${o.status}`);return(await o.json()).packages??[]},atr=({sessionToken:t})=>{const[e,n]=X.useState([]),[o,i]=X.useState(!1),[r,s]=X.useState(null),[a,A]=X.useState(!1),c=X.useCallback(async u=>{const g=u.trim();if(!g)return[];i(!0),s(null);try{const d=(await str(g,t)).map(m=>({source:"tscircuit.com",package:m}));return n(d),d}catch(h){return console.error("Error searching tscircuit packages",h),n([]),s(h instanceof Error?h.message:"Failed to search tscircuit packages"),[]}finally{i(!1),A(!0)}},[t]),l=X.useCallback(()=>{n([]),i(!1),s(null),A(!1)},[]);return{results:e,isSearching:o,error:r,hasSearched:a,search:c,reset:l}},Atr=t=>{const e=/^C(\d+)$/i.exec(t.trim());if(!e)return null;const n=Number(e[1]);if(!Number.isSafeInteger(n))return null;const o=`C${e[1]}`;return{source:"jlcpcb",component:{lcscId:n,manufacturer:o,partNumber:o,description:"Import directly from EasyEDA; stock and availability are unknown",package:"",isDirectLookup:!0}}},mxn=(t,e)=>{const n=Atr(t);return n?e.some(i=>i.component.partNumber.toUpperCase()===n.component.partNumber)?e:[n,...e]:e},ctr=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},ltr=()=>{const[t,e]=X.useState([]),[n,o]=X.useState(!1),[i,r]=X.useState(null),[s,a]=X.useState(!1),A=X.useCallback(async l=>{const u=ctr(l);if(!u)return[];o(!0),r(null);try{const g=await ZZi(u,10),h=mxn(l,g.map(d=>({source:"jlcpcb",component:eer(d)})));return e(h),h}catch(g){console.error("Error searching JLCPCB components",g);const h=mxn(l,[]);return e(h),r(h.length>0?null:g instanceof Error?g.message:"Failed to search JLCPCB components"),h}finally{o(!1),a(!0)}},[]),c=X.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:A,reset:c}},utr=()=>{const[t,e]=X.useState([]),[n,o]=X.useState(!1),[i,r]=X.useState(null),[s,a]=X.useState(!1),A=X.useCallback(async l=>{const u=l.trim();if(!u)return[];o(!0),r(null);try{const h=(await Ker(u,20)).map(d=>({source:"kicad",footprint:zer(d)}));return e(h),h}catch(g){return console.error("Error searching KiCad footprints",g),e([]),r(g instanceof Error?g.message:"Failed to search KiCad footprints"),[]}finally{o(!1),a(!0)}},[]),c=X.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:A,reset:c}},gtr=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const o=[];return t&&o.push("tscircuit.com"),e&&o.push("jlcpcb"),n&&o.push("kicad"),o},dtr=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r,jlcpcbProxyApiBase:s,tscircuitSessionToken:a})=>{gte();const A=X.useMemo(()=>gtr({onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r}),[o,i,r]),c=A.length>0,l=A.length===1,[u,g]=X.useState(A[0]??"tscircuit.com"),[h,d]=X.useState(""),[m,p]=X.useState(null),{results:f,isSearching:_,error:I,hasSearched:C,search:y,reset:x}=atr({sessionToken:a}),{results:E,isSearching:B,error:S,hasSearched:Q,search:w,reset:M}=ltr(),{results:T,isSearching:R,error:F,hasSearched:O,search:U,reset:Y}=utr(),{details:q,isLoading:ee,fetchDetails:W,reset:J}=itr(),[te,ie]=X.useState(null),[ne,le]=X.useState(!1),[de,Ie]=X.useState("pcb"),[ce,fe]=X.useState(null),[ue,pe]=X.useState(!1),Me=X.useMemo(()=>({jlcpcb:{headers:n,apiBase:s}}),[s,n]),{circuitJson:Se,error:he,isLoading:Pe}=rtr(m,Me),we=gxn(m);X.useEffect(()=>{fe(null)},[m]);const Qe=X.useCallback(()=>{x(),M(),Y(),p(null)},[M,Y,x]);X.useEffect(()=>{t||(Qe(),d(""),le(!1),ie(null),fe(null))},[t,Qe]),X.useEffect(()=>{d(""),p(null),u==="tscircuit.com"?x():u==="jlcpcb"?M():u==="kicad"&&Y()},[u,M,Y,x]);const Re=tt=>{p(tt),ie(tt),Ie("pcb"),le(!0),J();const dt=tt.package.org_owner_tscircuit_handle,St=tt.package.unscoped_name;if(dt&&St){const Ct=St.split("/").pop()??St;W(dt,Ct)}},De=async()=>{h.trim()&&(p(null),u==="tscircuit.com"?await y(h):u==="jlcpcb"?await w(h):u==="kicad"&&await U(h))},xe=async tt=>{try{if(fe(null),pe(!0),tt.source==="kicad"){if(!o)throw new Error("KiCad handler not provided");await o({result:tt,footprint:tt.footprint.qualifiedName})}else if(tt.source==="jlcpcb"){if(!r)throw new Error("JLCPCB handler not provided");const dt=await ter(tt.component.partNumber,{headers:n,apiBase:s});await r({result:tt,tsx:dt})}else if(tt.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const dt=tt.package.org_owner_tscircuit_handle,St=tt.package.unscoped_name;if(!dt||!St)throw new Error("Missing package metadata");const Ct=St.split("/").pop()??St,Nt=`@tsci/${dt}.${Ct}`;await i({result:tt,fullPackageName:Nt})}return!0}catch(dt){return console.error("Failed to import component",dt),fe(dt instanceof Error?dt.message:"Failed to import component"),!1}finally{pe(!1)}};let Te=[],Ce=!1,Fe=null,Ge=!1;u==="tscircuit.com"?(Te=f,Ce=_,Fe=I,Ge=C):u==="jlcpcb"?(Te=E,Ce=B,Fe=S,Ge=Q):u==="kicad"&&(Te=T,Ce=R,Fe=F,Ge=O);const Xe=async()=>{if(!m)return;await xe(m)&&(e(),Qe(),d(""))},st=tt=>{tt||e()},rt=tt=>{le(tt),tt||ie(null)};return K.jsxs(hk,{open:t,onOpenChange:st,children:[K.jsxs(mM,{style:{width:"calc(100vw - 2rem)",maxWidth:we?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:hxn.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[K.jsxs(pM,{children:[K.jsxs(fM,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",l?w1e[u].label:""," ","Component"]}),K.jsx(mk,{className:"rf-text-sm",children:c?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),c?K.jsxs(DTe,{value:u,onValueChange:tt=>g(tt),className:"rf-min-w-0 rf-w-full",children:[!l&&K.jsx(Ude,{className:"rf-flex rf-w-full rf-gap-2",children:A.map(tt=>K.jsx(k7,{value:tt,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:w1e[tt].label},tt))}),K.jsxs("div",{className:"rf-min-w-0",style:we?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[K.jsxs("div",{className:"rf-min-w-0",children:[K.jsx(jer,{query:h,placeholder:w1e[u].placeholder,isSearching:Ce,onQueryChange:d,onSubmit:De}),K.jsx("div",{className:"no-scrollbar rf-mt-4 rf-flex-1 rf-min-h-[200px] !rf-max-h-[40vh] !rf-overflow-y-auto rf-overflow-x-hidden rf-border rf-rounded-md rf-min-w-0",children:Ce?K.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[K.jsx(VE,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),K.jsx("p",{children:"Searching..."})]}):Te.length>0?K.jsx(ttr,{results:Te,selected:m,onSelect:p,onShowDetails:u==="tscircuit.com"?Re:void 0}):K.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:Fe?`Error: ${Fe}`:Ge?w1e[u].emptyMessage:"Enter a search term to find components"})})]}),we?K.jsx("div",{className:"rf-mt-4",children:K.jsx(ntr,{circuitJson:Se,error:he,isLoading:Pe,height:325})}):null]})]}):null,ce?K.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:ce}):null,K.jsxs(MK,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[K.jsx(IA,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),K.jsx(IA,{onClick:Xe,disabled:!m||ue,className:"rf-order-1 sm:rf-order-2",children:ue?K.jsx(VE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),K.jsx(otr,{packageResult:te,isOpen:ne,onOpenChange:rt,isLoading:ee,details:q,previewTab:de,onPreviewTabChange:tt=>Ie(tt),isSubmitting:ue,onImport:()=>{te&&xe(te).then(tt=>{tt&&(le(!1),e(),Qe(),d(""))})}})]})},htr=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},pxn=t=>{const e=Id(s=>s.pushEvent),n=Id(s=>s.upsertFile),o=async({result:s,fullPackageName:a})=>{const c=s.package.unscoped_name??s.package.name;await ua.promise(e({event_type:"INSTALL_PACKAGE",full_package_name:a}),{loading:`Requesting install for "${c}"`,success:`Install requested for "${c}"`,error:l=>`Failed to request install: ${l instanceof Error?l.message:String(l)}`})},i=async({footprint:s})=>{await ua.promise(navigator.clipboard.writeText(s),{loading:`Copying "${s}"`,success:`Copied "${s}" to clipboard`,error:a=>`Failed to copy footprint: ${a instanceof Error?a.message:String(a)}`})},r=async({result:s,tsx:a})=>{const c=`imports/${htr(a)}.tsx`;await ua.promise(n(c,a),{loading:`Importing ${s.component.partNumber}`,success:`Imported to "${c}"`,error:l=>`Failed to import component: ${l instanceof Error?l.message:String(l)}`})};return K.jsx(dtr,{...t,onTscircuitPackageSelected:o,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:r})};pxn.displayName="ImportComponentDialogForCli";const mtr=async({circuitJson:t,projectName:e})=>{const{convertCircuitJsonToAltiumZip:n}=await Promise.resolve().then(()=>Rxr),o=await n(t,e);return new Blob([new Uint8Array(o)],{type:"application/zip"})},ptr=async({circuitJson:t,projectName:e})=>{await ua.promise((async()=>{const n=await mtr({circuitJson:t,projectName:e});XE(n,{fileName:`${e}_altium_project.zip`})})(),{loading:"Generating Altium project...",success:"Altium project ZIP ready",error:n=>`Failed to generate Altium project: ${n instanceof Error?n.message:String(n)}`})};var ZZe={exports:{}},fxn;function ftr(){return fxn||(fxn=1,(function(t,e){var n={env:{},version:""};(function(o){t.exports=o()})(function(){return(function o(i,r,s){function a(l,u){if(!r[l]){if(!i[l]){var g=typeof db=="function"&&db;if(!u&&g)return g(l,!0);if(A)return A(l,!0);var h=new Error("Cannot find module '"+l+"'");throw h.code="MODULE_NOT_FOUND",h}var d=r[l]={exports:{}};i[l][0].call(d.exports,function(m){var p=i[l][1][m];return a(p||m)},d,d.exports,o,i,r,s)}return r[l].exports}for(var A=typeof db=="function"&&db,c=0;c<s.length;c++)a(s[c]);return a})({1:[function(o,i,r){var s=o("./utils"),a=o("./support"),A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(c){for(var l,u,g,h,d,m,p,f=[],_=0,I=c.length,C=I,y=s.getTypeOf(c)!=="string";_<c.length;)C=I-_,g=y?(l=c[_++],u=_<I?c[_++]:0,_<I?c[_++]:0):(l=c.charCodeAt(_++),u=_<I?c.charCodeAt(_++):0,_<I?c.charCodeAt(_++):0),h=l>>2,d=(3&l)<<4|u>>4,m=1<C?(15&u)<<2|g>>6:64,p=2<C?63&g:64,f.push(A.charAt(h)+A.charAt(d)+A.charAt(m)+A.charAt(p));return f.join("")},r.decode=function(c){var l,u,g,h,d,m,p=0,f=0,_="data:";if(c.substr(0,_.length)===_)throw new Error("Invalid base64 input, it looks like a data url.");var I,C=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===A.charAt(64)&&C--,c.charAt(c.length-2)===A.charAt(64)&&C--,C%1!=0)throw new Error("Invalid base64 input, bad content length.");for(I=a.uint8array?new Uint8Array(0|C):new Array(0|C);p<c.length;)l=A.indexOf(c.charAt(p++))<<2|(h=A.indexOf(c.charAt(p++)))>>4,u=(15&h)<<4|(d=A.indexOf(c.charAt(p++)))>>2,g=(3&d)<<6|(m=A.indexOf(c.charAt(p++))),I[f++]=l,d!==64&&(I[f++]=u),m!==64&&(I[f++]=g);return I}},{"./support":30,"./utils":32}],2:[function(o,i,r){var s=o("./external"),a=o("./stream/DataWorker"),A=o("./stream/Crc32Probe"),c=o("./stream/DataLengthProbe");function l(u,g,h,d,m){this.compressedSize=u,this.uncompressedSize=g,this.crc32=h,this.compression=d,this.compressedContent=m}l.prototype={getContentWorker:function(){var u=new a(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),g=this;return u.on("end",function(){if(this.streamInfo.data_length!==g.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},getCompressedWorker:function(){return new a(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},l.createWorkerFrom=function(u,g,h){return u.pipe(new A).pipe(new c("uncompressedSize")).pipe(g.compressWorker(h)).pipe(new c("compressedSize")).withStreamInfo("compression",g)},i.exports=l},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(o,i,r){var s=o("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},r.DEFLATE=o("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(o,i,r){var s=o("./utils"),a=(function(){for(var A,c=[],l=0;l<256;l++){A=l;for(var u=0;u<8;u++)A=1&A?3988292384^A>>>1:A>>>1;c[l]=A}return c})();i.exports=function(A,c){return A!==void 0&&A.length?s.getTypeOf(A)!=="string"?(function(l,u,g,h){var d=a,m=h+g;l^=-1;for(var p=h;p<m;p++)l=l>>>8^d[255&(l^u[p])];return-1^l})(0|c,A,A.length,0):(function(l,u,g,h){var d=a,m=h+g;l^=-1;for(var p=h;p<m;p++)l=l>>>8^d[255&(l^u.charCodeAt(p))];return-1^l})(0|c,A,A.length,0):0}},{"./utils":32}],5:[function(o,i,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(o,i,r){var s=null;s=typeof Promise<"u"?Promise:o("lie"),i.exports={Promise:s}},{lie:37}],7:[function(o,i,r){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=o("pako"),A=o("./utils"),c=o("./stream/GenericWorker"),l=s?"uint8array":"array";function u(g,h){c.call(this,"FlateWorker/"+g),this._pako=null,this._pakoAction=g,this._pakoOptions=h,this.meta={}}r.magic="\b\0",A.inherits(u,c),u.prototype.processChunk=function(g){this.meta=g.meta,this._pako===null&&this._createPako(),this._pako.push(A.transformTo(l,g.data),!1)},u.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var g=this;this._pako.onData=function(h){g.push({data:h,meta:g.meta})}},r.compressWorker=function(g){return new u("Deflate",g)},r.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(o,i,r){function s(d,m){var p,f="";for(p=0;p<m;p++)f+=String.fromCharCode(255&d),d>>>=8;return f}function a(d,m,p,f,_,I){var C,y,x=d.file,E=d.compression,B=I!==l.utf8encode,S=A.transformTo("string",I(x.name)),Q=A.transformTo("string",l.utf8encode(x.name)),w=x.comment,M=A.transformTo("string",I(w)),T=A.transformTo("string",l.utf8encode(w)),R=Q.length!==x.name.length,F=T.length!==w.length,O="",U="",Y="",q=x.dir,ee=x.date,W={crc32:0,compressedSize:0,uncompressedSize:0};m&&!p||(W.crc32=d.crc32,W.compressedSize=d.compressedSize,W.uncompressedSize=d.uncompressedSize);var J=0;m&&(J|=8),B||!R&&!F||(J|=2048);var te=0,ie=0;q&&(te|=16),_==="UNIX"?(ie=798,te|=(function(le,de){var Ie=le;return le||(Ie=de?16893:33204),(65535&Ie)<<16})(x.unixPermissions,q)):(ie=20,te|=(function(le){return 63&(le||0)})(x.dosPermissions)),C=ee.getUTCHours(),C<<=6,C|=ee.getUTCMinutes(),C<<=5,C|=ee.getUTCSeconds()/2,y=ee.getUTCFullYear()-1980,y<<=4,y|=ee.getUTCMonth()+1,y<<=5,y|=ee.getUTCDate(),R&&(U=s(1,1)+s(u(S),4)+Q,O+="up"+s(U.length,2)+U),F&&(Y=s(1,1)+s(u(M),4)+T,O+="uc"+s(Y.length,2)+Y);var ne="";return ne+=`
|
|
5672
5672
|
\0`,ne+=s(J,2),ne+=E.magic,ne+=s(C,2),ne+=s(y,2),ne+=s(W.crc32,4),ne+=s(W.compressedSize,4),ne+=s(W.uncompressedSize,4),ne+=s(S.length,2),ne+=s(O.length,2),{fileRecord:g.LOCAL_FILE_HEADER+ne+S+O,dirRecord:g.CENTRAL_FILE_HEADER+s(ie,2)+ne+s(M.length,2)+"\0\0\0\0"+s(te,4)+s(f,4)+S+O+M}}var A=o("../utils"),c=o("../stream/GenericWorker"),l=o("../utf8"),u=o("../crc32"),g=o("../signature");function h(d,m,p,f){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=m,this.zipPlatform=p,this.encodeFileName=f,this.streamFiles=d,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}A.inherits(h,c),h.prototype.push=function(d){var m=d.meta.percent||0,p=this.entriesCount,f=this._sources.length;this.accumulate?this.contentBuffer.push(d):(this.bytesWritten+=d.data.length,c.prototype.push.call(this,{data:d.data,meta:{currentFile:this.currentFile,percent:p?(m+100*(p-f-1))/p:100}}))},h.prototype.openedSource=function(d){this.currentSourceOffset=this.bytesWritten,this.currentFile=d.file.name;var m=this.streamFiles&&!d.file.dir;if(m){var p=a(d,m,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:p.fileRecord,meta:{percent:0}})}else this.accumulate=!0},h.prototype.closedSource=function(d){this.accumulate=!1;var m=this.streamFiles&&!d.file.dir,p=a(d,m,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(p.dirRecord),m)this.push({data:(function(f){return g.DATA_DESCRIPTOR+s(f.crc32,4)+s(f.compressedSize,4)+s(f.uncompressedSize,4)})(d),meta:{percent:100}});else for(this.push({data:p.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var d=this.bytesWritten,m=0;m<this.dirRecords.length;m++)this.push({data:this.dirRecords[m],meta:{percent:100}});var p=this.bytesWritten-d,f=(function(_,I,C,y,x){var E=A.transformTo("string",x(y));return g.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(_,2)+s(_,2)+s(I,4)+s(C,4)+s(E.length,2)+E})(this.dirRecords.length,p,d,this.zipComment,this.encodeFileName);this.push({data:f,meta:{percent:100}})},h.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},h.prototype.registerPrevious=function(d){this._sources.push(d);var m=this;return d.on("data",function(p){m.processChunk(p)}),d.on("end",function(){m.closedSource(m.previous.streamInfo),m._sources.length?m.prepareNextSource():m.end()}),d.on("error",function(p){m.error(p)}),this},h.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},h.prototype.error=function(d){var m=this._sources;if(!c.prototype.error.call(this,d))return!1;for(var p=0;p<m.length;p++)try{m[p].error(d)}catch{}return!0},h.prototype.lock=function(){c.prototype.lock.call(this);for(var d=this._sources,m=0;m<d.length;m++)d[m].lock()},i.exports=h},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(o,i,r){var s=o("../compressions"),a=o("./ZipFileWorker");r.generateWorker=function(A,c,l){var u=new a(c.streamFiles,l,c.platform,c.encodeFileName),g=0;try{A.forEach(function(h,d){g++;var m=(function(I,C){var y=I||C,x=s[y];if(!x)throw new Error(y+" is not a valid compression method !");return x})(d.options.compression,c.compression),p=d.options.compressionOptions||c.compressionOptions||{},f=d.dir,_=d.date;d._compressWorker(m,p).withStreamInfo("file",{name:h,dir:f,date:_,comment:d.comment||"",unixPermissions:d.unixPermissions,dosPermissions:d.dosPermissions}).pipe(u)}),u.entriesCount=g}catch(h){u.error(h)}return u}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(o,i,r){function s(){if(!(this instanceof s))return new s;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var a=new s;for(var A in this)typeof this[A]!="function"&&(a[A]=this[A]);return a}}(s.prototype=o("./object")).loadAsync=o("./load"),s.support=o("./support"),s.defaults=o("./defaults"),s.version="3.10.2",s.loadAsync=function(a,A){return new s().loadAsync(a,A)},s.external=o("./external"),i.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(o,i,r){var s=o("./utils"),a=o("./external"),A=o("./utf8"),c=o("./zipEntries"),l=o("./stream/Crc32Probe"),u=o("./nodejsUtils");function g(h){return new a.Promise(function(d,m){var p=h.decompressed.getContentWorker().pipe(new l);p.on("error",function(f){m(f)}).on("end",function(){p.streamInfo.crc32!==h.decompressed.crc32?m(new Error("Corrupted zip : CRC32 mismatch")):d()}).resume()})}i.exports=function(h,d){var m=this;return d=s.extend(d||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:A.utf8decode}),u.isNode&&u.isStream(h)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",h,!0,d.optimizedBinaryString,d.base64).then(function(p){var f=new c(d);return f.load(p),f}).then(function(p){var f=[a.Promise.resolve(p)],_=p.files;if(d.checkCRC32)for(var I=0;I<_.length;I++)f.push(g(_[I]));return a.Promise.all(f)}).then(function(p){for(var f=p.shift(),_=f.files,I=0;I<_.length;I++){var C=_[I],y=C.fileNameStr,x=s.resolve(C.fileNameStr);m.file(x,C.decompressed,{binary:!0,optimizedBinaryString:!0,date:C.date,dir:C.dir,comment:C.fileCommentStr.length?C.fileCommentStr:null,unixPermissions:C.unixPermissions,dosPermissions:C.dosPermissions,createFolders:d.createFolders}),C.dir||(m.file(x).unsafeOriginalName=y)}return f.zipComment.length&&(m.comment=f.zipComment),m})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(o,i,r){var s=o("../utils"),a=o("../stream/GenericWorker");function A(c,l){a.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(l)}s.inherits(A,a),A.prototype._bindStream=function(c){var l=this;(this._stream=c).pause(),c.on("data",function(u){l.push({data:u,meta:{percent:0}})}).on("error",function(u){l.isPaused?this.generatedError=u:l.error(u)}).on("end",function(){l.isPaused?l._upstreamEnded=!0:l.end()})},A.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},A.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},i.exports=A},{"../stream/GenericWorker":28,"../utils":32}],13:[function(o,i,r){var s=o("readable-stream").Readable;function a(A,c,l){s.call(this,c),this._helper=A;var u=this;A.on("data",function(g,h){u.push(g)||u._helper.pause(),l&&l(h)}).on("error",function(g){u.emit("error",g)}).on("end",function(){u.push(null)})}o("../utils").inherits(a,s),a.prototype._read=function(){this._helper.resume()},i.exports=a},{"../utils":32,"readable-stream":16}],14:[function(o,i,r){i.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,a);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,a)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var a=new Buffer(s);return a.fill(0),a},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(o,i,r){function s(x,E,B){var S,Q=A.getTypeOf(E),w=A.extend(B||{},u);w.date=w.date||new Date,w.compression!==null&&(w.compression=w.compression.toUpperCase()),typeof w.unixPermissions=="string"&&(w.unixPermissions=parseInt(w.unixPermissions,8)),w.unixPermissions&&16384&w.unixPermissions&&(w.dir=!0),w.dosPermissions&&16&w.dosPermissions&&(w.dir=!0),w.dir&&(x=_(x)),w.createFolders&&(S=f(x))&&I.call(this,S,!0);var M=Q==="string"&&w.binary===!1&&w.base64===!1;B&&B.binary!==void 0||(w.binary=!M),(E instanceof g&&E.uncompressedSize===0||w.dir||!E||E.length===0)&&(w.base64=!1,w.binary=!0,E="",w.compression="STORE",Q="string");var T=null;T=E instanceof g||E instanceof c?E:m.isNode&&m.isStream(E)?new p(x,E):A.prepareContent(x,E,w.binary,w.optimizedBinaryString,w.base64);var R=new h(x,T,w);this.files[x]=R}var a=o("./utf8"),A=o("./utils"),c=o("./stream/GenericWorker"),l=o("./stream/StreamHelper"),u=o("./defaults"),g=o("./compressedObject"),h=o("./zipObject"),d=o("./generate"),m=o("./nodejsUtils"),p=o("./nodejs/NodejsStreamInputAdapter"),f=function(x){x.slice(-1)==="/"&&(x=x.substring(0,x.length-1));var E=x.lastIndexOf("/");return 0<E?x.substring(0,E):""},_=function(x){return x.slice(-1)!=="/"&&(x+="/"),x},I=function(x,E){return E=E!==void 0?E:u.createFolders,x=_(x),this.files[x]||s.call(this,x,null,{dir:!0,createFolders:E}),this.files[x]};function C(x){return Object.prototype.toString.call(x)==="[object RegExp]"}var y={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(x){var E,B,S;for(E in this.files)S=this.files[E],(B=E.slice(this.root.length,E.length))&&E.slice(0,this.root.length)===this.root&&x(B,S)},filter:function(x){var E=[];return this.forEach(function(B,S){x(B,S)&&E.push(S)}),E},file:function(x,E,B){if(arguments.length!==1)return x=this.root+x,s.call(this,x,E,B),this;if(C(x)){var S=x;return this.filter(function(w,M){return!M.dir&&S.test(w)})}var Q=this.files[this.root+x];return Q&&!Q.dir?Q:null},folder:function(x){if(!x)return this;if(C(x))return this.filter(function(Q,w){return w.dir&&x.test(Q)});var E=this.root+x,B=I.call(this,E),S=this.clone();return S.root=B.name,S},remove:function(x){x=this.root+x;var E=this.files[x];if(E||(x.slice(-1)!=="/"&&(x+="/"),E=this.files[x]),E&&!E.dir)delete this.files[x];else for(var B=this.filter(function(Q,w){return w.name.slice(0,x.length)===x}),S=0;S<B.length;S++)delete this.files[B[S].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(x){var E,B={};try{if((B=A.extend(x||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=B.type.toLowerCase(),B.compression=B.compression.toUpperCase(),B.type==="binarystring"&&(B.type="string"),!B.type)throw new Error("No output type specified.");A.checkSupport(B.type),B.platform!=="darwin"&&B.platform!=="freebsd"&&B.platform!=="linux"&&B.platform!=="sunos"||(B.platform="UNIX"),B.platform==="win32"&&(B.platform="DOS");var S=B.comment||this.comment||"";E=d.generateWorker(this,B,S)}catch(Q){(E=new c("error")).error(Q)}return new l(E,B.type||"string",B.mimeType)},generateAsync:function(x,E){return this.generateInternalStream(x).accumulate(E)},generateNodeStream:function(x,E){return(x=x||{}).type||(x.type="nodebuffer"),this.generateInternalStream(x).toNodejsStream(E)}};i.exports=y},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(o,i,r){i.exports=o("stream")},{stream:void 0}],17:[function(o,i,r){var s=o("./DataReader");function a(A){s.call(this,A);for(var c=0;c<this.data.length;c++)A[c]=255&A[c]}o("../utils").inherits(a,s),a.prototype.byteAt=function(A){return this.data[this.zero+A]},a.prototype.lastIndexOfSignature=function(A){for(var c=A.charCodeAt(0),l=A.charCodeAt(1),u=A.charCodeAt(2),g=A.charCodeAt(3),h=this.length-4;0<=h;--h)if(this.data[h]===c&&this.data[h+1]===l&&this.data[h+2]===u&&this.data[h+3]===g)return h-this.zero;return-1},a.prototype.readAndCheckSignature=function(A){var c=A.charCodeAt(0),l=A.charCodeAt(1),u=A.charCodeAt(2),g=A.charCodeAt(3),h=this.readData(4);return c===h[0]&&l===h[1]&&u===h[2]&&g===h[3]},a.prototype.readData=function(A){if(this.checkOffset(A),A===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+A);return this.index+=A,c},i.exports=a},{"../utils":32,"./DataReader":18}],18:[function(o,i,r){var s=o("../utils");function a(A){this.data=A,this.length=A.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(A){this.checkIndex(this.index+A)},checkIndex:function(A){if(this.length<this.zero+A||A<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+A+"). Corrupted zip ?")},setIndex:function(A){this.checkIndex(A),this.index=A},skip:function(A){this.setIndex(this.index+A)},byteAt:function(){},readInt:function(A){var c,l=0;for(this.checkOffset(A),c=this.index+A-1;c>=this.index;c--)l=(l<<8)+this.byteAt(c);return this.index+=A,l},readString:function(A){return s.transformTo("string",this.readData(A))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var A=this.readInt(4);return new Date(Date.UTC(1980+(A>>25&127),(A>>21&15)-1,A>>16&31,A>>11&31,A>>5&63,(31&A)<<1))}},i.exports=a},{"../utils":32}],19:[function(o,i,r){var s=o("./Uint8ArrayReader");function a(A){s.call(this,A)}o("../utils").inherits(a,s),a.prototype.readData=function(A){this.checkOffset(A);var c=this.data.slice(this.zero+this.index,this.zero+this.index+A);return this.index+=A,c},i.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(o,i,r){var s=o("./DataReader");function a(A){s.call(this,A)}o("../utils").inherits(a,s),a.prototype.byteAt=function(A){return this.data.charCodeAt(this.zero+A)},a.prototype.lastIndexOfSignature=function(A){return this.data.lastIndexOf(A)-this.zero},a.prototype.readAndCheckSignature=function(A){return A===this.readData(4)},a.prototype.readData=function(A){this.checkOffset(A);var c=this.data.slice(this.zero+this.index,this.zero+this.index+A);return this.index+=A,c},i.exports=a},{"../utils":32,"./DataReader":18}],21:[function(o,i,r){var s=o("./ArrayReader");function a(A){s.call(this,A)}o("../utils").inherits(a,s),a.prototype.readData=function(A){if(this.checkOffset(A),A===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+A);return this.index+=A,c},i.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(o,i,r){var s=o("../utils"),a=o("../support"),A=o("./ArrayReader"),c=o("./StringReader"),l=o("./NodeBufferReader"),u=o("./Uint8ArrayReader");i.exports=function(g){var h=s.getTypeOf(g);return s.checkSupport(h),h!=="string"||a.uint8array?h==="nodebuffer"?new l(g):a.uint8array?new u(s.transformTo("uint8array",g)):new A(s.transformTo("array",g)):new c(g)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(o,i,r){r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(o,i,r){var s=o("./GenericWorker"),a=o("../utils");function A(c){s.call(this,"ConvertWorker to "+c),this.destType=c}a.inherits(A,s),A.prototype.processChunk=function(c){this.push({data:a.transformTo(this.destType,c.data),meta:c.meta})},i.exports=A},{"../utils":32,"./GenericWorker":28}],25:[function(o,i,r){var s=o("./GenericWorker"),a=o("../crc32");function A(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}o("../utils").inherits(A,s),A.prototype.processChunk=function(c){this.streamInfo.crc32=a(c.data,this.streamInfo.crc32||0),this.push(c)},i.exports=A},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(o,i,r){var s=o("../utils"),a=o("./GenericWorker");function A(c){a.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}s.inherits(A,a),A.prototype.processChunk=function(c){if(c){var l=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=l+c.data.length}a.prototype.processChunk.call(this,c)},i.exports=A},{"../utils":32,"./GenericWorker":28}],27:[function(o,i,r){var s=o("../utils"),a=o("./GenericWorker");function A(c){a.call(this,"DataWorker");var l=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(u){l.dataIsReady=!0,l.data=u,l.max=u&&u.length||0,l.type=s.getTypeOf(u),l.isPaused||l._tickAndRepeat()},function(u){l.error(u)})}s.inherits(A,a),A.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},A.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},A.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},A.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,l=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,l);break;case"uint8array":c=this.data.subarray(this.index,l);break;case"array":case"nodebuffer":c=this.data.slice(this.index,l)}return this.index=l,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=A},{"../utils":32,"./GenericWorker":28}],28:[function(o,i,r){function s(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,A){return this._listeners[a].push(A),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,A){if(this._listeners[a])for(var c=0;c<this._listeners[a].length;c++)this._listeners[a][c].call(this,A)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var A=this;return a.on("data",function(c){A.processChunk(c)}),a.on("end",function(){A.end()}),a.on("error",function(c){A.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var a=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,A){return this.extraStreamInfo[a]=A,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},i.exports=s},{}],29:[function(o,i,r){var s=o("../utils"),a=o("./ConvertWorker"),A=o("./GenericWorker"),c=o("../base64"),l=o("../support"),u=o("../external"),g=null;if(l.nodestream)try{g=o("../nodejs/NodejsStreamOutputAdapter")}catch{}function h(m,p){return new u.Promise(function(f,_){var I=[],C=m._internalType,y=m._outputType,x=m._mimeType;m.on("data",function(E,B){I.push(E),p&&p(B)}).on("error",function(E){I=[],_(E)}).on("end",function(){try{var E=(function(B,S,Q){switch(B){case"blob":return s.newBlob(s.transformTo("arraybuffer",S),Q);case"base64":return c.encode(S);default:return s.transformTo(B,S)}})(y,(function(B,S){var Q,w=0,M=null,T=0;for(Q=0;Q<S.length;Q++)T+=S[Q].length;switch(B){case"string":return S.join("");case"array":return Array.prototype.concat.apply([],S);case"uint8array":for(M=new Uint8Array(T),Q=0;Q<S.length;Q++)M.set(S[Q],w),w+=S[Q].length;return M;case"nodebuffer":return Buffer.concat(S);default:throw new Error("concat : unsupported type '"+B+"'")}})(C,I),x);f(E)}catch(B){_(B)}I=[]}).resume()})}function d(m,p,f){var _=p;switch(p){case"blob":case"arraybuffer":_="uint8array";break;case"base64":_="string"}try{this._internalType=_,this._outputType=p,this._mimeType=f,s.checkSupport(_),this._worker=m.pipe(new a(_)),m.lock()}catch(I){this._worker=new A("error"),this._worker.error(I)}}d.prototype={accumulate:function(m){return h(this,m)},on:function(m,p){var f=this;return m==="data"?this._worker.on(m,function(_){p.call(f,_.data,_.meta)}):this._worker.on(m,function(){s.delay(p,arguments,f)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(m){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new g(this,{objectMode:this._outputType!=="nodebuffer"},m)}},i.exports=d},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(o,i,r){if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",r.nodebuffer=typeof Buffer<"u",r.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")r.blob=!1;else{var s=new ArrayBuffer(0);try{r.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(s),r.blob=a.getBlob("application/zip").size===0}catch{r.blob=!1}}}try{r.nodestream=!!o("readable-stream").Readable}catch{r.nodestream=!1}},{"readable-stream":16}],31:[function(o,i,r){for(var s=o("./utils"),a=o("./support"),A=o("./nodejsUtils"),c=o("./stream/GenericWorker"),l=new Array(256),u=0;u<256;u++)l[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;l[254]=l[254]=1;function g(){c.call(this,"utf-8 decode"),this.leftOver=null}function h(){c.call(this,"utf-8 encode")}r.utf8encode=function(d){return a.nodebuffer?A.newBufferFrom(d,"utf-8"):(function(m){var p,f,_,I,C,y=m.length,x=0;for(I=0;I<y;I++)(64512&(f=m.charCodeAt(I)))==55296&&I+1<y&&(64512&(_=m.charCodeAt(I+1)))==56320&&(f=65536+(f-55296<<10)+(_-56320),I++),x+=f<128?1:f<2048?2:f<65536?3:4;for(p=a.uint8array?new Uint8Array(x):new Array(x),I=C=0;C<x;I++)(64512&(f=m.charCodeAt(I)))==55296&&I+1<y&&(64512&(_=m.charCodeAt(I+1)))==56320&&(f=65536+(f-55296<<10)+(_-56320),I++),f<128?p[C++]=f:(f<2048?p[C++]=192|f>>>6:(f<65536?p[C++]=224|f>>>12:(p[C++]=240|f>>>18,p[C++]=128|f>>>12&63),p[C++]=128|f>>>6&63),p[C++]=128|63&f);return p})(d)},r.utf8decode=function(d){return a.nodebuffer?s.transformTo("nodebuffer",d).toString("utf-8"):(function(m){var p,f,_,I,C=m.length,y=new Array(2*C);for(p=f=0;p<C;)if((_=m[p++])<128)y[f++]=_;else if(4<(I=l[_]))y[f++]=65533,p+=I-1;else{for(_&=I===2?31:I===3?15:7;1<I&&p<C;)_=_<<6|63&m[p++],I--;1<I?y[f++]=65533:_<65536?y[f++]=_:(_-=65536,y[f++]=55296|_>>10&1023,y[f++]=56320|1023&_)}return y.length!==f&&(y.subarray?y=y.subarray(0,f):y.length=f),s.applyFromCharCode(y)})(d=s.transformTo(a.uint8array?"uint8array":"array",d))},s.inherits(g,c),g.prototype.processChunk=function(d){var m=s.transformTo(a.uint8array?"uint8array":"array",d.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var p=m;(m=new Uint8Array(p.length+this.leftOver.length)).set(this.leftOver,0),m.set(p,this.leftOver.length)}else m=this.leftOver.concat(m);this.leftOver=null}var f=(function(I,C){var y;for((C=C||I.length)>I.length&&(C=I.length),y=C-1;0<=y&&(192&I[y])==128;)y--;return y<0||y===0?C:y+l[I[y]]>C?y:C})(m),_=m;f!==m.length&&(a.uint8array?(_=m.subarray(0,f),this.leftOver=m.subarray(f,m.length)):(_=m.slice(0,f),this.leftOver=m.slice(f,m.length))),this.push({data:r.utf8decode(_),meta:d.meta})},g.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:r.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},r.Utf8DecodeWorker=g,s.inherits(h,c),h.prototype.processChunk=function(d){this.push({data:r.utf8encode(d.data),meta:d.meta})},r.Utf8EncodeWorker=h},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(o,i,r){var s=o("./support"),a=o("./base64"),A=o("./nodejsUtils"),c=o("./external");function l(p){return p}function u(p,f){for(var _=0;_<p.length;++_)f[_]=255&p.charCodeAt(_);return f}o("setimmediate"),r.newBlob=function(p,f){r.checkSupport("blob");try{return new Blob([p],{type:f})}catch{try{var _=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return _.append(p),_.getBlob(f)}catch{throw new Error("Bug : can't construct the Blob.")}}};var g={stringifyByChunk:function(p,f,_){var I=[],C=0,y=p.length;if(y<=_)return String.fromCharCode.apply(null,p);for(;C<y;)f==="array"||f==="nodebuffer"?I.push(String.fromCharCode.apply(null,p.slice(C,Math.min(C+_,y)))):I.push(String.fromCharCode.apply(null,p.subarray(C,Math.min(C+_,y)))),C+=_;return I.join("")},stringifyByChar:function(p){for(var f="",_=0;_<p.length;_++)f+=String.fromCharCode(p[_]);return f},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,A.allocBuffer(1)).length===1}catch{return!1}})()}};function h(p){var f=65536,_=r.getTypeOf(p),I=!0;if(_==="uint8array"?I=g.applyCanBeUsed.uint8array:_==="nodebuffer"&&(I=g.applyCanBeUsed.nodebuffer),I)for(;1<f;)try{return g.stringifyByChunk(p,_,f)}catch{f=Math.floor(f/2)}return g.stringifyByChar(p)}function d(p,f){for(var _=0;_<p.length;_++)f[_]=p[_];return f}r.applyFromCharCode=h;var m={};m.string={string:l,array:function(p){return u(p,new Array(p.length))},arraybuffer:function(p){return m.string.uint8array(p).buffer},uint8array:function(p){return u(p,new Uint8Array(p.length))},nodebuffer:function(p){return u(p,A.allocBuffer(p.length))}},m.array={string:h,array:l,arraybuffer:function(p){return new Uint8Array(p).buffer},uint8array:function(p){return new Uint8Array(p)},nodebuffer:function(p){return A.newBufferFrom(p)}},m.arraybuffer={string:function(p){return h(new Uint8Array(p))},array:function(p){return d(new Uint8Array(p),new Array(p.byteLength))},arraybuffer:l,uint8array:function(p){return new Uint8Array(p)},nodebuffer:function(p){return A.newBufferFrom(new Uint8Array(p))}},m.uint8array={string:h,array:function(p){return d(p,new Array(p.length))},arraybuffer:function(p){return p.buffer},uint8array:l,nodebuffer:function(p){return A.newBufferFrom(p)}},m.nodebuffer={string:h,array:function(p){return d(p,new Array(p.length))},arraybuffer:function(p){return m.nodebuffer.uint8array(p).buffer},uint8array:function(p){return d(p,new Uint8Array(p.length))},nodebuffer:l},r.transformTo=function(p,f){if(f=f||"",!p)return f;r.checkSupport(p);var _=r.getTypeOf(f);return m[_][p](f)},r.resolve=function(p){for(var f=p.split("/"),_=[],I=0;I<f.length;I++){var C=f[I];C==="."||C===""&&I!==0&&I!==f.length-1||(C===".."?_.pop():_.push(C))}return _.join("/")},r.getTypeOf=function(p){if(typeof p=="string")return"string";var f=Object.prototype.toString.call(p);return f==="[object Array]"?"array":s.nodebuffer&&A.isBuffer(p)?"nodebuffer":s.uint8array&&f==="[object Uint8Array]"?"uint8array":s.arraybuffer&&f==="[object ArrayBuffer]"?"arraybuffer":void 0},r.checkSupport=function(p){if(!s[p.toLowerCase()])throw new Error(p+" is not supported by this platform")},r.MAX_VALUE_16BITS=65535,r.MAX_VALUE_32BITS=-1,r.pretty=function(p){var f,_,I="";for(_=0;_<(p||"").length;_++)I+="\\x"+((f=p.charCodeAt(_))<16?"0":"")+f.toString(16).toUpperCase();return I},r.delay=function(p,f,_){setImmediate(function(){p.apply(_||null,f||[])})},r.inherits=function(p,f){function _(){}_.prototype=f.prototype,p.prototype=new _},r.extend=function(){var p,f,_={};for(p=0;p<arguments.length;p++)for(f in arguments[p])Object.prototype.hasOwnProperty.call(arguments[p],f)&&_[f]===void 0&&(_[f]=arguments[p][f]);return _},r.prepareContent=function(p,f,_,I,C){return c.Promise.resolve(f).then(function(y){return s.blob&&(y instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(y))!==-1)?Blob.prototype.arrayBuffer!==void 0?y.arrayBuffer():typeof FileReader<"u"?new c.Promise(function(x,E){var B=new FileReader;B.onload=function(S){x(S.target.result)},B.onerror=function(S){E(S.target.error)},B.readAsArrayBuffer(y)}):c.Promise.reject(new Error(p+" is a Blob, but we have no way of reading it.")):y}).then(function(y){var x=r.getTypeOf(y);return x?(x==="arraybuffer"?y=r.transformTo("uint8array",y):x==="string"&&(C?y=a.decode(y):_&&I!==!0&&(y=(function(E){return u(E,s.uint8array?new Uint8Array(E.length):new Array(E.length))})(y))),y):c.Promise.reject(new Error("Can't read the data of '"+p+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(o,i,r){var s=o("./reader/readerFor"),a=o("./utils"),A=o("./signature"),c=o("./zipEntry"),l=o("./support");function u(g){this.files=[],this.loadOptions=g}u.prototype={checkSignature:function(g){if(!this.reader.readAndCheckSignature(g)){this.reader.index-=4;var h=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(h)+", expected "+a.pretty(g)+")")}},isSignature:function(g,h){var d=this.reader.index;this.reader.setIndex(g);var m=this.reader.readString(4)===h;return this.reader.setIndex(d),m},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var g=this.reader.readData(this.zipCommentLength),h=l.uint8array?"uint8array":"array",d=a.transformTo(h,g);this.zipComment=this.loadOptions.decodeFileName(d)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var g,h,d,m=this.zip64EndOfCentralSize-44;0<m;)g=this.reader.readInt(2),h=this.reader.readInt(4),d=this.reader.readData(h),this.zip64ExtensibleData[g]={id:g,length:h,value:d}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var g,h;for(g=0;g<this.files.length;g++)h=this.files[g],this.reader.setIndex(h.localHeaderOffset),this.checkSignature(A.LOCAL_FILE_HEADER),h.readLocalPart(this.reader),h.handleUTF8(),h.processAttributes()},readCentralDir:function(){var g;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(A.CENTRAL_FILE_HEADER);)(g=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(g);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var g=this.reader.lastIndexOfSignature(A.CENTRAL_DIRECTORY_END);if(g<0)throw this.isSignature(0,A.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(g);var h=g;if(this.checkSignature(A.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(g=this.reader.lastIndexOfSignature(A.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(g),this.checkSignature(A.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,A.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(A.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(A.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var d=this.centralDirOffset+this.centralDirSize;this.zip64&&(d+=20,d+=12+this.zip64EndOfCentralSize);var m=h-d;if(0<m)this.isSignature(h,A.CENTRAL_FILE_HEADER)||(this.reader.zero=m);else if(m<0)throw new Error("Corrupted zip: missing "+Math.abs(m)+" bytes.")},prepareReader:function(g){this.reader=s(g)},load:function(g){this.prepareReader(g),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=u},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(o,i,r){var s=o("./reader/readerFor"),a=o("./utils"),A=o("./compressedObject"),c=o("./crc32"),l=o("./utf8"),u=o("./compressions"),g=o("./support");function h(d,m){this.options=d,this.loadOptions=m}h.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(d){var m,p;if(d.skip(22),this.fileNameLength=d.readInt(2),p=d.readInt(2),this.fileName=d.readData(this.fileNameLength),d.skip(p),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((m=(function(f){for(var _ in u)if(Object.prototype.hasOwnProperty.call(u,_)&&u[_].magic===f)return u[_];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new A(this.compressedSize,this.uncompressedSize,this.crc32,m,d.readData(this.compressedSize))},readCentralPart:function(d){this.versionMadeBy=d.readInt(2),d.skip(2),this.bitFlag=d.readInt(2),this.compressionMethod=d.readString(2),this.date=d.readDate(),this.crc32=d.readInt(4),this.compressedSize=d.readInt(4),this.uncompressedSize=d.readInt(4);var m=d.readInt(2);if(this.extraFieldsLength=d.readInt(2),this.fileCommentLength=d.readInt(2),this.diskNumberStart=d.readInt(2),this.internalFileAttributes=d.readInt(2),this.externalFileAttributes=d.readInt(4),this.localHeaderOffset=d.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");d.skip(m),this.readExtraFields(d),this.parseZIP64ExtraField(d),this.fileComment=d.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var d=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),d==0&&(this.dosPermissions=63&this.externalFileAttributes),d==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var d=s(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=d.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=d.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=d.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=d.readInt(4))}},readExtraFields:function(d){var m,p,f,_=d.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});d.index+4<_;)m=d.readInt(2),p=d.readInt(2),f=d.readData(p),this.extraFields[m]={id:m,length:p,value:f};d.setIndex(_)},handleUTF8:function(){var d=g.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=l.utf8decode(this.fileName),this.fileCommentStr=l.utf8decode(this.fileComment);else{var m=this.findExtraFieldUnicodePath();if(m!==null)this.fileNameStr=m;else{var p=a.transformTo(d,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(p)}var f=this.findExtraFieldUnicodeComment();if(f!==null)this.fileCommentStr=f;else{var _=a.transformTo(d,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(_)}}},findExtraFieldUnicodePath:function(){var d=this.extraFields[28789];if(d){var m=s(d.value);return m.readInt(1)!==1||c(this.fileName)!==m.readInt(4)?null:l.utf8decode(m.readData(d.length-5))}return null},findExtraFieldUnicodeComment:function(){var d=this.extraFields[25461];if(d){var m=s(d.value);return m.readInt(1)!==1||c(this.fileComment)!==m.readInt(4)?null:l.utf8decode(m.readData(d.length-5))}return null}},i.exports=h},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(o,i,r){function s(m,p,f){this.name=m,this.dir=f.dir,this.date=f.date,this.comment=f.comment,this.unixPermissions=f.unixPermissions,this.dosPermissions=f.dosPermissions,this._data=p,this._dataBinary=f.binary,this.options={compression:f.compression,compressionOptions:f.compressionOptions}}var a=o("./stream/StreamHelper"),A=o("./stream/DataWorker"),c=o("./utf8"),l=o("./compressedObject"),u=o("./stream/GenericWorker");s.prototype={internalStream:function(m){var p=null,f="string";try{if(!m)throw new Error("No output type specified.");var _=(f=m.toLowerCase())==="string"||f==="text";f!=="binarystring"&&f!=="text"||(f="string"),p=this._decompressWorker();var I=!this._dataBinary;I&&!_&&(p=p.pipe(new c.Utf8EncodeWorker)),!I&&_&&(p=p.pipe(new c.Utf8DecodeWorker))}catch(C){(p=new u("error")).error(C)}return new a(p,f,"")},async:function(m,p){return this.internalStream(m).accumulate(p)},nodeStream:function(m,p){return this.internalStream(m||"nodebuffer").toNodejsStream(p)},_compressWorker:function(m,p){if(this._data instanceof l&&this._data.compression.magic===m.magic)return this._data.getCompressedWorker();var f=this._decompressWorker();return this._dataBinary||(f=f.pipe(new c.Utf8EncodeWorker)),l.createWorkerFrom(f,m,p)},_decompressWorker:function(){return this._data instanceof l?this._data.getContentWorker():this._data instanceof u?this._data:new A(this._data)}};for(var g=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],h=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},d=0;d<g.length;d++)s.prototype[g[d]]=h;i.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(o,i,r){(function(s){var a,A,c=s.MutationObserver||s.WebKitMutationObserver;if(c){var l=0,u=new c(m),g=s.document.createTextNode("");u.observe(g,{characterData:!0}),a=function(){g.data=l=++l%2}}else if(s.setImmediate||s.MessageChannel===void 0)a="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var p=s.document.createElement("script");p.onreadystatechange=function(){m(),p.onreadystatechange=null,p.parentNode.removeChild(p),p=null},s.document.documentElement.appendChild(p)}:function(){setTimeout(m,0)};else{var h=new s.MessageChannel;h.port1.onmessage=m,a=function(){h.port2.postMessage(0)}}var d=[];function m(){var p,f;A=!0;for(var _=d.length;_;){for(f=d,d=[],p=-1;++p<_;)f[p]();_=d.length}A=!1}i.exports=function(p){d.push(p)!==1||A||a()}}).call(this,typeof Ny<"u"?Ny:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(o,i,r){var s=o("immediate");function a(){}var A={},c=["REJECTED"],l=["FULFILLED"],u=["PENDING"];function g(_){if(typeof _!="function")throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,_!==a&&p(this,_)}function h(_,I,C){this.promise=_,typeof I=="function"&&(this.onFulfilled=I,this.callFulfilled=this.otherCallFulfilled),typeof C=="function"&&(this.onRejected=C,this.callRejected=this.otherCallRejected)}function d(_,I,C){s(function(){var y;try{y=I(C)}catch(x){return A.reject(_,x)}y===_?A.reject(_,new TypeError("Cannot resolve promise with itself")):A.resolve(_,y)})}function m(_){var I=_&&_.then;if(_&&(typeof _=="object"||typeof _=="function")&&typeof I=="function")return function(){I.apply(_,arguments)}}function p(_,I){var C=!1;function y(B){C||(C=!0,A.reject(_,B))}function x(B){C||(C=!0,A.resolve(_,B))}var E=f(function(){I(x,y)});E.status==="error"&&y(E.value)}function f(_,I){var C={};try{C.value=_(I),C.status="success"}catch(y){C.status="error",C.value=y}return C}(i.exports=g).prototype.finally=function(_){if(typeof _!="function")return this;var I=this.constructor;return this.then(function(C){return I.resolve(_()).then(function(){return C})},function(C){return I.resolve(_()).then(function(){throw C})})},g.prototype.catch=function(_){return this.then(null,_)},g.prototype.then=function(_,I){if(typeof _!="function"&&this.state===l||typeof I!="function"&&this.state===c)return this;var C=new this.constructor(a);return this.state!==u?d(C,this.state===l?_:I,this.outcome):this.queue.push(new h(C,_,I)),C},h.prototype.callFulfilled=function(_){A.resolve(this.promise,_)},h.prototype.otherCallFulfilled=function(_){d(this.promise,this.onFulfilled,_)},h.prototype.callRejected=function(_){A.reject(this.promise,_)},h.prototype.otherCallRejected=function(_){d(this.promise,this.onRejected,_)},A.resolve=function(_,I){var C=f(m,I);if(C.status==="error")return A.reject(_,C.value);var y=C.value;if(y)p(_,y);else{_.state=l,_.outcome=I;for(var x=-1,E=_.queue.length;++x<E;)_.queue[x].callFulfilled(I)}return _},A.reject=function(_,I){_.state=c,_.outcome=I;for(var C=-1,y=_.queue.length;++C<y;)_.queue[C].callRejected(I);return _},g.resolve=function(_){return _ instanceof this?_:A.resolve(new this(a),_)},g.reject=function(_){var I=new this(a);return A.reject(I,_)},g.all=function(_){var I=this;if(Object.prototype.toString.call(_)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=_.length,y=!1;if(!C)return this.resolve([]);for(var x=new Array(C),E=0,B=-1,S=new this(a);++B<C;)Q(_[B],B);return S;function Q(w,M){I.resolve(w).then(function(T){x[M]=T,++E!==C||y||(y=!0,A.resolve(S,x))},function(T){y||(y=!0,A.reject(S,T))})}},g.race=function(_){var I=this;if(Object.prototype.toString.call(_)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=_.length,y=!1;if(!C)return this.resolve([]);for(var x=-1,E=new this(a);++x<C;)B=_[x],I.resolve(B).then(function(S){y||(y=!0,A.resolve(E,S))},function(S){y||(y=!0,A.reject(E,S))});var B;return E}},{immediate:36}],38:[function(o,i,r){var s={};(0,o("./lib/utils/common").assign)(s,o("./lib/deflate"),o("./lib/inflate"),o("./lib/zlib/constants")),i.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(o,i,r){var s=o("./zlib/deflate"),a=o("./utils/common"),A=o("./utils/strings"),c=o("./zlib/messages"),l=o("./zlib/zstream"),u=Object.prototype.toString,g=0,h=-1,d=0,m=8;function p(_){if(!(this instanceof p))return new p(_);this.options=a.assign({level:h,method:m,chunkSize:16384,windowBits:15,memLevel:8,strategy:d,to:""},_||{});var I=this.options;I.raw&&0<I.windowBits?I.windowBits=-I.windowBits:I.gzip&&0<I.windowBits&&I.windowBits<16&&(I.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var C=s.deflateInit2(this.strm,I.level,I.method,I.windowBits,I.memLevel,I.strategy);if(C!==g)throw new Error(c[C]);if(I.header&&s.deflateSetHeader(this.strm,I.header),I.dictionary){var y;if(y=typeof I.dictionary=="string"?A.string2buf(I.dictionary):u.call(I.dictionary)==="[object ArrayBuffer]"?new Uint8Array(I.dictionary):I.dictionary,(C=s.deflateSetDictionary(this.strm,y))!==g)throw new Error(c[C]);this._dict_set=!0}}function f(_,I){var C=new p(I);if(C.push(_,!0),C.err)throw C.msg||c[C.err];return C.result}p.prototype.push=function(_,I){var C,y,x=this.strm,E=this.options.chunkSize;if(this.ended)return!1;y=I===~~I?I:I===!0?4:0,typeof _=="string"?x.input=A.string2buf(_):u.call(_)==="[object ArrayBuffer]"?x.input=new Uint8Array(_):x.input=_,x.next_in=0,x.avail_in=x.input.length;do{if(x.avail_out===0&&(x.output=new a.Buf8(E),x.next_out=0,x.avail_out=E),(C=s.deflate(x,y))!==1&&C!==g)return this.onEnd(C),!(this.ended=!0);x.avail_out!==0&&(x.avail_in!==0||y!==4&&y!==2)||(this.options.to==="string"?this.onData(A.buf2binstring(a.shrinkBuf(x.output,x.next_out))):this.onData(a.shrinkBuf(x.output,x.next_out)))}while((0<x.avail_in||x.avail_out===0)&&C!==1);return y===4?(C=s.deflateEnd(this.strm),this.onEnd(C),this.ended=!0,C===g):y!==2||(this.onEnd(g),!(x.avail_out=0))},p.prototype.onData=function(_){this.chunks.push(_)},p.prototype.onEnd=function(_){_===g&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=_,this.msg=this.strm.msg},r.Deflate=p,r.deflate=f,r.deflateRaw=function(_,I){return(I=I||{}).raw=!0,f(_,I)},r.gzip=function(_,I){return(I=I||{}).gzip=!0,f(_,I)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(o,i,r){var s=o("./zlib/inflate"),a=o("./utils/common"),A=o("./utils/strings"),c=o("./zlib/constants"),l=o("./zlib/messages"),u=o("./zlib/zstream"),g=o("./zlib/gzheader"),h=Object.prototype.toString;function d(p){if(!(this instanceof d))return new d(p);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},p||{});var f=this.options;f.raw&&0<=f.windowBits&&f.windowBits<16&&(f.windowBits=-f.windowBits,f.windowBits===0&&(f.windowBits=-15)),!(0<=f.windowBits&&f.windowBits<16)||p&&p.windowBits||(f.windowBits+=32),15<f.windowBits&&f.windowBits<48&&(15&f.windowBits)==0&&(f.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var _=s.inflateInit2(this.strm,f.windowBits);if(_!==c.Z_OK)throw new Error(l[_]);this.header=new g,s.inflateGetHeader(this.strm,this.header)}function m(p,f){var _=new d(f);if(_.push(p,!0),_.err)throw _.msg||l[_.err];return _.result}d.prototype.push=function(p,f){var _,I,C,y,x,E,B=this.strm,S=this.options.chunkSize,Q=this.options.dictionary,w=!1;if(this.ended)return!1;I=f===~~f?f:f===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof p=="string"?B.input=A.binstring2buf(p):h.call(p)==="[object ArrayBuffer]"?B.input=new Uint8Array(p):B.input=p,B.next_in=0,B.avail_in=B.input.length;do{if(B.avail_out===0&&(B.output=new a.Buf8(S),B.next_out=0,B.avail_out=S),(_=s.inflate(B,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&Q&&(E=typeof Q=="string"?A.string2buf(Q):h.call(Q)==="[object ArrayBuffer]"?new Uint8Array(Q):Q,_=s.inflateSetDictionary(this.strm,E)),_===c.Z_BUF_ERROR&&w===!0&&(_=c.Z_OK,w=!1),_!==c.Z_STREAM_END&&_!==c.Z_OK)return this.onEnd(_),!(this.ended=!0);B.next_out&&(B.avail_out!==0&&_!==c.Z_STREAM_END&&(B.avail_in!==0||I!==c.Z_FINISH&&I!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(C=A.utf8border(B.output,B.next_out),y=B.next_out-C,x=A.buf2string(B.output,C),B.next_out=y,B.avail_out=S-y,y&&a.arraySet(B.output,B.output,C,y,0),this.onData(x)):this.onData(a.shrinkBuf(B.output,B.next_out)))),B.avail_in===0&&B.avail_out===0&&(w=!0)}while((0<B.avail_in||B.avail_out===0)&&_!==c.Z_STREAM_END);return _===c.Z_STREAM_END&&(I=c.Z_FINISH),I===c.Z_FINISH?(_=s.inflateEnd(this.strm),this.onEnd(_),this.ended=!0,_===c.Z_OK):I!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(B.avail_out=0))},d.prototype.onData=function(p){this.chunks.push(p)},d.prototype.onEnd=function(p){p===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=p,this.msg=this.strm.msg},r.Inflate=d,r.inflate=m,r.inflateRaw=function(p,f){return(f=f||{}).raw=!0,m(p,f)},r.ungzip=m},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(o,i,r){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";r.assign=function(c){for(var l=Array.prototype.slice.call(arguments,1);l.length;){var u=l.shift();if(u){if(typeof u!="object")throw new TypeError(u+"must be non-object");for(var g in u)u.hasOwnProperty(g)&&(c[g]=u[g])}}return c},r.shrinkBuf=function(c,l){return c.length===l?c:c.subarray?c.subarray(0,l):(c.length=l,c)};var a={arraySet:function(c,l,u,g,h){if(l.subarray&&c.subarray)c.set(l.subarray(u,u+g),h);else for(var d=0;d<g;d++)c[h+d]=l[u+d]},flattenChunks:function(c){var l,u,g,h,d,m;for(l=g=0,u=c.length;l<u;l++)g+=c[l].length;for(m=new Uint8Array(g),l=h=0,u=c.length;l<u;l++)d=c[l],m.set(d,h),h+=d.length;return m}},A={arraySet:function(c,l,u,g,h){for(var d=0;d<g;d++)c[h+d]=l[u+d]},flattenChunks:function(c){return[].concat.apply([],c)}};r.setTyped=function(c){c?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,a)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,A))},r.setTyped(s)},{}],42:[function(o,i,r){var s=o("./common"),a=!0,A=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{A=!1}for(var c=new s.Buf8(256),l=0;l<256;l++)c[l]=252<=l?6:248<=l?5:240<=l?4:224<=l?3:192<=l?2:1;function u(g,h){if(h<65537&&(g.subarray&&A||!g.subarray&&a))return String.fromCharCode.apply(null,s.shrinkBuf(g,h));for(var d="",m=0;m<h;m++)d+=String.fromCharCode(g[m]);return d}c[254]=c[254]=1,r.string2buf=function(g){var h,d,m,p,f,_=g.length,I=0;for(p=0;p<_;p++)(64512&(d=g.charCodeAt(p)))==55296&&p+1<_&&(64512&(m=g.charCodeAt(p+1)))==56320&&(d=65536+(d-55296<<10)+(m-56320),p++),I+=d<128?1:d<2048?2:d<65536?3:4;for(h=new s.Buf8(I),p=f=0;f<I;p++)(64512&(d=g.charCodeAt(p)))==55296&&p+1<_&&(64512&(m=g.charCodeAt(p+1)))==56320&&(d=65536+(d-55296<<10)+(m-56320),p++),d<128?h[f++]=d:(d<2048?h[f++]=192|d>>>6:(d<65536?h[f++]=224|d>>>12:(h[f++]=240|d>>>18,h[f++]=128|d>>>12&63),h[f++]=128|d>>>6&63),h[f++]=128|63&d);return h},r.buf2binstring=function(g){return u(g,g.length)},r.binstring2buf=function(g){for(var h=new s.Buf8(g.length),d=0,m=h.length;d<m;d++)h[d]=g.charCodeAt(d);return h},r.buf2string=function(g,h){var d,m,p,f,_=h||g.length,I=new Array(2*_);for(d=m=0;d<_;)if((p=g[d++])<128)I[m++]=p;else if(4<(f=c[p]))I[m++]=65533,d+=f-1;else{for(p&=f===2?31:f===3?15:7;1<f&&d<_;)p=p<<6|63&g[d++],f--;1<f?I[m++]=65533:p<65536?I[m++]=p:(p-=65536,I[m++]=55296|p>>10&1023,I[m++]=56320|1023&p)}return u(I,m)},r.utf8border=function(g,h){var d;for((h=h||g.length)>g.length&&(h=g.length),d=h-1;0<=d&&(192&g[d])==128;)d--;return d<0||d===0?h:d+c[g[d]]>h?d:h}},{"./common":41}],43:[function(o,i,r){i.exports=function(s,a,A,c){for(var l=65535&s|0,u=s>>>16&65535|0,g=0;A!==0;){for(A-=g=2e3<A?2e3:A;u=u+(l=l+a[c++]|0)|0,--g;);l%=65521,u%=65521}return l|u<<16|0}},{}],44:[function(o,i,r){i.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(o,i,r){var s=(function(){for(var a,A=[],c=0;c<256;c++){a=c;for(var l=0;l<8;l++)a=1&a?3988292384^a>>>1:a>>>1;A[c]=a}return A})();i.exports=function(a,A,c,l){var u=s,g=l+c;a^=-1;for(var h=l;h<g;h++)a=a>>>8^u[255&(a^A[h])];return-1^a}},{}],46:[function(o,i,r){var s,a=o("../utils/common"),A=o("./trees"),c=o("./adler32"),l=o("./crc32"),u=o("./messages"),g=0,h=4,d=0,m=-2,p=-1,f=4,_=2,I=8,C=9,y=286,x=30,E=19,B=2*y+1,S=15,Q=3,w=258,M=w+Q+1,T=42,R=113,F=1,O=2,U=3,Y=4;function q(he,Pe){return he.msg=u[Pe],Pe}function ee(he){return(he<<1)-(4<he?9:0)}function W(he){for(var Pe=he.length;0<=--Pe;)he[Pe]=0}function J(he){var Pe=he.state,we=Pe.pending;we>he.avail_out&&(we=he.avail_out),we!==0&&(a.arraySet(he.output,Pe.pending_buf,Pe.pending_out,we,he.next_out),he.next_out+=we,Pe.pending_out+=we,he.total_out+=we,he.avail_out-=we,Pe.pending-=we,Pe.pending===0&&(Pe.pending_out=0))}function te(he,Pe){A._tr_flush_block(he,0<=he.block_start?he.block_start:-1,he.strstart-he.block_start,Pe),he.block_start=he.strstart,J(he.strm)}function ie(he,Pe){he.pending_buf[he.pending++]=Pe}function ne(he,Pe){he.pending_buf[he.pending++]=Pe>>>8&255,he.pending_buf[he.pending++]=255&Pe}function le(he,Pe){var we,Qe,Re=he.max_chain_length,De=he.strstart,xe=he.prev_length,Te=he.nice_match,Ce=he.strstart>he.w_size-M?he.strstart-(he.w_size-M):0,Fe=he.window,Ge=he.w_mask,Xe=he.prev,st=he.strstart+w,rt=Fe[De+xe-1],tt=Fe[De+xe];he.prev_length>=he.good_match&&(Re>>=2),Te>he.lookahead&&(Te=he.lookahead);do if(Fe[(we=Pe)+xe]===tt&&Fe[we+xe-1]===rt&&Fe[we]===Fe[De]&&Fe[++we]===Fe[De+1]){De+=2,we++;do;while(Fe[++De]===Fe[++we]&&Fe[++De]===Fe[++we]&&Fe[++De]===Fe[++we]&&Fe[++De]===Fe[++we]&&Fe[++De]===Fe[++we]&&Fe[++De]===Fe[++we]&&Fe[++De]===Fe[++we]&&Fe[++De]===Fe[++we]&&De<st);if(Qe=w-(st-De),De=st-w,xe<Qe){if(he.match_start=Pe,Te<=(xe=Qe))break;rt=Fe[De+xe-1],tt=Fe[De+xe]}}while((Pe=Xe[Pe&Ge])>Ce&&--Re!=0);return xe<=he.lookahead?xe:he.lookahead}function de(he){var Pe,we,Qe,Re,De,xe,Te,Ce,Fe,Ge,Xe=he.w_size;do{if(Re=he.window_size-he.lookahead-he.strstart,he.strstart>=Xe+(Xe-M)){for(a.arraySet(he.window,he.window,Xe,Xe,0),he.match_start-=Xe,he.strstart-=Xe,he.block_start-=Xe,Pe=we=he.hash_size;Qe=he.head[--Pe],he.head[Pe]=Xe<=Qe?Qe-Xe:0,--we;);for(Pe=we=Xe;Qe=he.prev[--Pe],he.prev[Pe]=Xe<=Qe?Qe-Xe:0,--we;);Re+=Xe}if(he.strm.avail_in===0)break;if(xe=he.strm,Te=he.window,Ce=he.strstart+he.lookahead,Fe=Re,Ge=void 0,Ge=xe.avail_in,Fe<Ge&&(Ge=Fe),we=Ge===0?0:(xe.avail_in-=Ge,a.arraySet(Te,xe.input,xe.next_in,Ge,Ce),xe.state.wrap===1?xe.adler=c(xe.adler,Te,Ge,Ce):xe.state.wrap===2&&(xe.adler=l(xe.adler,Te,Ge,Ce)),xe.next_in+=Ge,xe.total_in+=Ge,Ge),he.lookahead+=we,he.lookahead+he.insert>=Q)for(De=he.strstart-he.insert,he.ins_h=he.window[De],he.ins_h=(he.ins_h<<he.hash_shift^he.window[De+1])&he.hash_mask;he.insert&&(he.ins_h=(he.ins_h<<he.hash_shift^he.window[De+Q-1])&he.hash_mask,he.prev[De&he.w_mask]=he.head[he.ins_h],he.head[he.ins_h]=De,De++,he.insert--,!(he.lookahead+he.insert<Q)););}while(he.lookahead<M&&he.strm.avail_in!==0)}function Ie(he,Pe){for(var we,Qe;;){if(he.lookahead<M){if(de(he),he.lookahead<M&&Pe===g)return F;if(he.lookahead===0)break}if(we=0,he.lookahead>=Q&&(he.ins_h=(he.ins_h<<he.hash_shift^he.window[he.strstart+Q-1])&he.hash_mask,we=he.prev[he.strstart&he.w_mask]=he.head[he.ins_h],he.head[he.ins_h]=he.strstart),we!==0&&he.strstart-we<=he.w_size-M&&(he.match_length=le(he,we)),he.match_length>=Q)if(Qe=A._tr_tally(he,he.strstart-he.match_start,he.match_length-Q),he.lookahead-=he.match_length,he.match_length<=he.max_lazy_match&&he.lookahead>=Q){for(he.match_length--;he.strstart++,he.ins_h=(he.ins_h<<he.hash_shift^he.window[he.strstart+Q-1])&he.hash_mask,we=he.prev[he.strstart&he.w_mask]=he.head[he.ins_h],he.head[he.ins_h]=he.strstart,--he.match_length!=0;);he.strstart++}else he.strstart+=he.match_length,he.match_length=0,he.ins_h=he.window[he.strstart],he.ins_h=(he.ins_h<<he.hash_shift^he.window[he.strstart+1])&he.hash_mask;else Qe=A._tr_tally(he,0,he.window[he.strstart]),he.lookahead--,he.strstart++;if(Qe&&(te(he,!1),he.strm.avail_out===0))return F}return he.insert=he.strstart<Q-1?he.strstart:Q-1,Pe===h?(te(he,!0),he.strm.avail_out===0?U:Y):he.last_lit&&(te(he,!1),he.strm.avail_out===0)?F:O}function ce(he,Pe){for(var we,Qe,Re;;){if(he.lookahead<M){if(de(he),he.lookahead<M&&Pe===g)return F;if(he.lookahead===0)break}if(we=0,he.lookahead>=Q&&(he.ins_h=(he.ins_h<<he.hash_shift^he.window[he.strstart+Q-1])&he.hash_mask,we=he.prev[he.strstart&he.w_mask]=he.head[he.ins_h],he.head[he.ins_h]=he.strstart),he.prev_length=he.match_length,he.prev_match=he.match_start,he.match_length=Q-1,we!==0&&he.prev_length<he.max_lazy_match&&he.strstart-we<=he.w_size-M&&(he.match_length=le(he,we),he.match_length<=5&&(he.strategy===1||he.match_length===Q&&4096<he.strstart-he.match_start)&&(he.match_length=Q-1)),he.prev_length>=Q&&he.match_length<=he.prev_length){for(Re=he.strstart+he.lookahead-Q,Qe=A._tr_tally(he,he.strstart-1-he.prev_match,he.prev_length-Q),he.lookahead-=he.prev_length-1,he.prev_length-=2;++he.strstart<=Re&&(he.ins_h=(he.ins_h<<he.hash_shift^he.window[he.strstart+Q-1])&he.hash_mask,we=he.prev[he.strstart&he.w_mask]=he.head[he.ins_h],he.head[he.ins_h]=he.strstart),--he.prev_length!=0;);if(he.match_available=0,he.match_length=Q-1,he.strstart++,Qe&&(te(he,!1),he.strm.avail_out===0))return F}else if(he.match_available){if((Qe=A._tr_tally(he,0,he.window[he.strstart-1]))&&te(he,!1),he.strstart++,he.lookahead--,he.strm.avail_out===0)return F}else he.match_available=1,he.strstart++,he.lookahead--}return he.match_available&&(Qe=A._tr_tally(he,0,he.window[he.strstart-1]),he.match_available=0),he.insert=he.strstart<Q-1?he.strstart:Q-1,Pe===h?(te(he,!0),he.strm.avail_out===0?U:Y):he.last_lit&&(te(he,!1),he.strm.avail_out===0)?F:O}function fe(he,Pe,we,Qe,Re){this.good_length=he,this.max_lazy=Pe,this.nice_length=we,this.max_chain=Qe,this.func=Re}function ue(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=I,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new a.Buf16(2*B),this.dyn_dtree=new a.Buf16(2*(2*x+1)),this.bl_tree=new a.Buf16(2*(2*E+1)),W(this.dyn_ltree),W(this.dyn_dtree),W(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(S+1),this.heap=new a.Buf16(2*y+1),W(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*y+1),W(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function pe(he){var Pe;return he&&he.state?(he.total_in=he.total_out=0,he.data_type=_,(Pe=he.state).pending=0,Pe.pending_out=0,Pe.wrap<0&&(Pe.wrap=-Pe.wrap),Pe.status=Pe.wrap?T:R,he.adler=Pe.wrap===2?0:1,Pe.last_flush=g,A._tr_init(Pe),d):q(he,m)}function Me(he){var Pe=pe(he);return Pe===d&&(function(we){we.window_size=2*we.w_size,W(we.head),we.max_lazy_match=s[we.level].max_lazy,we.good_match=s[we.level].good_length,we.nice_match=s[we.level].nice_length,we.max_chain_length=s[we.level].max_chain,we.strstart=0,we.block_start=0,we.lookahead=0,we.insert=0,we.match_length=we.prev_length=Q-1,we.match_available=0,we.ins_h=0})(he.state),Pe}function Se(he,Pe,we,Qe,Re,De){if(!he)return m;var xe=1;if(Pe===p&&(Pe=6),Qe<0?(xe=0,Qe=-Qe):15<Qe&&(xe=2,Qe-=16),Re<1||C<Re||we!==I||Qe<8||15<Qe||Pe<0||9<Pe||De<0||f<De)return q(he,m);Qe===8&&(Qe=9);var Te=new ue;return(he.state=Te).strm=he,Te.wrap=xe,Te.gzhead=null,Te.w_bits=Qe,Te.w_size=1<<Te.w_bits,Te.w_mask=Te.w_size-1,Te.hash_bits=Re+7,Te.hash_size=1<<Te.hash_bits,Te.hash_mask=Te.hash_size-1,Te.hash_shift=~~((Te.hash_bits+Q-1)/Q),Te.window=new a.Buf8(2*Te.w_size),Te.head=new a.Buf16(Te.hash_size),Te.prev=new a.Buf16(Te.w_size),Te.lit_bufsize=1<<Re+6,Te.pending_buf_size=4*Te.lit_bufsize,Te.pending_buf=new a.Buf8(Te.pending_buf_size),Te.d_buf=1*Te.lit_bufsize,Te.l_buf=3*Te.lit_bufsize,Te.level=Pe,Te.strategy=De,Te.method=we,Me(he)}s=[new fe(0,0,0,0,function(he,Pe){var we=65535;for(we>he.pending_buf_size-5&&(we=he.pending_buf_size-5);;){if(he.lookahead<=1){if(de(he),he.lookahead===0&&Pe===g)return F;if(he.lookahead===0)break}he.strstart+=he.lookahead,he.lookahead=0;var Qe=he.block_start+we;if((he.strstart===0||he.strstart>=Qe)&&(he.lookahead=he.strstart-Qe,he.strstart=Qe,te(he,!1),he.strm.avail_out===0)||he.strstart-he.block_start>=he.w_size-M&&(te(he,!1),he.strm.avail_out===0))return F}return he.insert=0,Pe===h?(te(he,!0),he.strm.avail_out===0?U:Y):(he.strstart>he.block_start&&(te(he,!1),he.strm.avail_out),F)}),new fe(4,4,8,4,Ie),new fe(4,5,16,8,Ie),new fe(4,6,32,32,Ie),new fe(4,4,16,16,ce),new fe(8,16,32,32,ce),new fe(8,16,128,128,ce),new fe(8,32,128,256,ce),new fe(32,128,258,1024,ce),new fe(32,258,258,4096,ce)],r.deflateInit=function(he,Pe){return Se(he,Pe,I,15,8,0)},r.deflateInit2=Se,r.deflateReset=Me,r.deflateResetKeep=pe,r.deflateSetHeader=function(he,Pe){return he&&he.state?he.state.wrap!==2?m:(he.state.gzhead=Pe,d):m},r.deflate=function(he,Pe){var we,Qe,Re,De;if(!he||!he.state||5<Pe||Pe<0)return he?q(he,m):m;if(Qe=he.state,!he.output||!he.input&&he.avail_in!==0||Qe.status===666&&Pe!==h)return q(he,he.avail_out===0?-5:m);if(Qe.strm=he,we=Qe.last_flush,Qe.last_flush=Pe,Qe.status===T)if(Qe.wrap===2)he.adler=0,ie(Qe,31),ie(Qe,139),ie(Qe,8),Qe.gzhead?(ie(Qe,(Qe.gzhead.text?1:0)+(Qe.gzhead.hcrc?2:0)+(Qe.gzhead.extra?4:0)+(Qe.gzhead.name?8:0)+(Qe.gzhead.comment?16:0)),ie(Qe,255&Qe.gzhead.time),ie(Qe,Qe.gzhead.time>>8&255),ie(Qe,Qe.gzhead.time>>16&255),ie(Qe,Qe.gzhead.time>>24&255),ie(Qe,Qe.level===9?2:2<=Qe.strategy||Qe.level<2?4:0),ie(Qe,255&Qe.gzhead.os),Qe.gzhead.extra&&Qe.gzhead.extra.length&&(ie(Qe,255&Qe.gzhead.extra.length),ie(Qe,Qe.gzhead.extra.length>>8&255)),Qe.gzhead.hcrc&&(he.adler=l(he.adler,Qe.pending_buf,Qe.pending,0)),Qe.gzindex=0,Qe.status=69):(ie(Qe,0),ie(Qe,0),ie(Qe,0),ie(Qe,0),ie(Qe,0),ie(Qe,Qe.level===9?2:2<=Qe.strategy||Qe.level<2?4:0),ie(Qe,3),Qe.status=R);else{var xe=I+(Qe.w_bits-8<<4)<<8;xe|=(2<=Qe.strategy||Qe.level<2?0:Qe.level<6?1:Qe.level===6?2:3)<<6,Qe.strstart!==0&&(xe|=32),xe+=31-xe%31,Qe.status=R,ne(Qe,xe),Qe.strstart!==0&&(ne(Qe,he.adler>>>16),ne(Qe,65535&he.adler)),he.adler=1}if(Qe.status===69)if(Qe.gzhead.extra){for(Re=Qe.pending;Qe.gzindex<(65535&Qe.gzhead.extra.length)&&(Qe.pending!==Qe.pending_buf_size||(Qe.gzhead.hcrc&&Qe.pending>Re&&(he.adler=l(he.adler,Qe.pending_buf,Qe.pending-Re,Re)),J(he),Re=Qe.pending,Qe.pending!==Qe.pending_buf_size));)ie(Qe,255&Qe.gzhead.extra[Qe.gzindex]),Qe.gzindex++;Qe.gzhead.hcrc&&Qe.pending>Re&&(he.adler=l(he.adler,Qe.pending_buf,Qe.pending-Re,Re)),Qe.gzindex===Qe.gzhead.extra.length&&(Qe.gzindex=0,Qe.status=73)}else Qe.status=73;if(Qe.status===73)if(Qe.gzhead.name){Re=Qe.pending;do{if(Qe.pending===Qe.pending_buf_size&&(Qe.gzhead.hcrc&&Qe.pending>Re&&(he.adler=l(he.adler,Qe.pending_buf,Qe.pending-Re,Re)),J(he),Re=Qe.pending,Qe.pending===Qe.pending_buf_size)){De=1;break}De=Qe.gzindex<Qe.gzhead.name.length?255&Qe.gzhead.name.charCodeAt(Qe.gzindex++):0,ie(Qe,De)}while(De!==0);Qe.gzhead.hcrc&&Qe.pending>Re&&(he.adler=l(he.adler,Qe.pending_buf,Qe.pending-Re,Re)),De===0&&(Qe.gzindex=0,Qe.status=91)}else Qe.status=91;if(Qe.status===91)if(Qe.gzhead.comment){Re=Qe.pending;do{if(Qe.pending===Qe.pending_buf_size&&(Qe.gzhead.hcrc&&Qe.pending>Re&&(he.adler=l(he.adler,Qe.pending_buf,Qe.pending-Re,Re)),J(he),Re=Qe.pending,Qe.pending===Qe.pending_buf_size)){De=1;break}De=Qe.gzindex<Qe.gzhead.comment.length?255&Qe.gzhead.comment.charCodeAt(Qe.gzindex++):0,ie(Qe,De)}while(De!==0);Qe.gzhead.hcrc&&Qe.pending>Re&&(he.adler=l(he.adler,Qe.pending_buf,Qe.pending-Re,Re)),De===0&&(Qe.status=103)}else Qe.status=103;if(Qe.status===103&&(Qe.gzhead.hcrc?(Qe.pending+2>Qe.pending_buf_size&&J(he),Qe.pending+2<=Qe.pending_buf_size&&(ie(Qe,255&he.adler),ie(Qe,he.adler>>8&255),he.adler=0,Qe.status=R)):Qe.status=R),Qe.pending!==0){if(J(he),he.avail_out===0)return Qe.last_flush=-1,d}else if(he.avail_in===0&&ee(Pe)<=ee(we)&&Pe!==h)return q(he,-5);if(Qe.status===666&&he.avail_in!==0)return q(he,-5);if(he.avail_in!==0||Qe.lookahead!==0||Pe!==g&&Qe.status!==666){var Te=Qe.strategy===2?(function(Ce,Fe){for(var Ge;;){if(Ce.lookahead===0&&(de(Ce),Ce.lookahead===0)){if(Fe===g)return F;break}if(Ce.match_length=0,Ge=A._tr_tally(Ce,0,Ce.window[Ce.strstart]),Ce.lookahead--,Ce.strstart++,Ge&&(te(Ce,!1),Ce.strm.avail_out===0))return F}return Ce.insert=0,Fe===h?(te(Ce,!0),Ce.strm.avail_out===0?U:Y):Ce.last_lit&&(te(Ce,!1),Ce.strm.avail_out===0)?F:O})(Qe,Pe):Qe.strategy===3?(function(Ce,Fe){for(var Ge,Xe,st,rt,tt=Ce.window;;){if(Ce.lookahead<=w){if(de(Ce),Ce.lookahead<=w&&Fe===g)return F;if(Ce.lookahead===0)break}if(Ce.match_length=0,Ce.lookahead>=Q&&0<Ce.strstart&&(Xe=tt[st=Ce.strstart-1])===tt[++st]&&Xe===tt[++st]&&Xe===tt[++st]){rt=Ce.strstart+w;do;while(Xe===tt[++st]&&Xe===tt[++st]&&Xe===tt[++st]&&Xe===tt[++st]&&Xe===tt[++st]&&Xe===tt[++st]&&Xe===tt[++st]&&Xe===tt[++st]&&st<rt);Ce.match_length=w-(rt-st),Ce.match_length>Ce.lookahead&&(Ce.match_length=Ce.lookahead)}if(Ce.match_length>=Q?(Ge=A._tr_tally(Ce,1,Ce.match_length-Q),Ce.lookahead-=Ce.match_length,Ce.strstart+=Ce.match_length,Ce.match_length=0):(Ge=A._tr_tally(Ce,0,Ce.window[Ce.strstart]),Ce.lookahead--,Ce.strstart++),Ge&&(te(Ce,!1),Ce.strm.avail_out===0))return F}return Ce.insert=0,Fe===h?(te(Ce,!0),Ce.strm.avail_out===0?U:Y):Ce.last_lit&&(te(Ce,!1),Ce.strm.avail_out===0)?F:O})(Qe,Pe):s[Qe.level].func(Qe,Pe);if(Te!==U&&Te!==Y||(Qe.status=666),Te===F||Te===U)return he.avail_out===0&&(Qe.last_flush=-1),d;if(Te===O&&(Pe===1?A._tr_align(Qe):Pe!==5&&(A._tr_stored_block(Qe,0,0,!1),Pe===3&&(W(Qe.head),Qe.lookahead===0&&(Qe.strstart=0,Qe.block_start=0,Qe.insert=0))),J(he),he.avail_out===0))return Qe.last_flush=-1,d}return Pe!==h?d:Qe.wrap<=0?1:(Qe.wrap===2?(ie(Qe,255&he.adler),ie(Qe,he.adler>>8&255),ie(Qe,he.adler>>16&255),ie(Qe,he.adler>>24&255),ie(Qe,255&he.total_in),ie(Qe,he.total_in>>8&255),ie(Qe,he.total_in>>16&255),ie(Qe,he.total_in>>24&255)):(ne(Qe,he.adler>>>16),ne(Qe,65535&he.adler)),J(he),0<Qe.wrap&&(Qe.wrap=-Qe.wrap),Qe.pending!==0?d:1)},r.deflateEnd=function(he){var Pe;return he&&he.state?(Pe=he.state.status)!==T&&Pe!==69&&Pe!==73&&Pe!==91&&Pe!==103&&Pe!==R&&Pe!==666?q(he,m):(he.state=null,Pe===R?q(he,-3):d):m},r.deflateSetDictionary=function(he,Pe){var we,Qe,Re,De,xe,Te,Ce,Fe,Ge=Pe.length;if(!he||!he.state||(De=(we=he.state).wrap)===2||De===1&&we.status!==T||we.lookahead)return m;for(De===1&&(he.adler=c(he.adler,Pe,Ge,0)),we.wrap=0,Ge>=we.w_size&&(De===0&&(W(we.head),we.strstart=0,we.block_start=0,we.insert=0),Fe=new a.Buf8(we.w_size),a.arraySet(Fe,Pe,Ge-we.w_size,we.w_size,0),Pe=Fe,Ge=we.w_size),xe=he.avail_in,Te=he.next_in,Ce=he.input,he.avail_in=Ge,he.next_in=0,he.input=Pe,de(we);we.lookahead>=Q;){for(Qe=we.strstart,Re=we.lookahead-(Q-1);we.ins_h=(we.ins_h<<we.hash_shift^we.window[Qe+Q-1])&we.hash_mask,we.prev[Qe&we.w_mask]=we.head[we.ins_h],we.head[we.ins_h]=Qe,Qe++,--Re;);we.strstart=Qe,we.lookahead=Q-1,de(we)}return we.strstart+=we.lookahead,we.block_start=we.strstart,we.insert=we.lookahead,we.lookahead=0,we.match_length=we.prev_length=Q-1,we.match_available=0,he.next_in=Te,he.input=Ce,he.avail_in=xe,we.wrap=De,d},r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(o,i,r){i.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(o,i,r){i.exports=function(s,a){var A,c,l,u,g,h,d,m,p,f,_,I,C,y,x,E,B,S,Q,w,M,T,R,F,O;A=s.state,c=s.next_in,F=s.input,l=c+(s.avail_in-5),u=s.next_out,O=s.output,g=u-(a-s.avail_out),h=u+(s.avail_out-257),d=A.dmax,m=A.wsize,p=A.whave,f=A.wnext,_=A.window,I=A.hold,C=A.bits,y=A.lencode,x=A.distcode,E=(1<<A.lenbits)-1,B=(1<<A.distbits)-1;e:do{C<15&&(I+=F[c++]<<C,C+=8,I+=F[c++]<<C,C+=8),S=y[I&E];t:for(;;){if(I>>>=Q=S>>>24,C-=Q,(Q=S>>>16&255)===0)O[u++]=65535&S;else{if(!(16&Q)){if((64&Q)==0){S=y[(65535&S)+(I&(1<<Q)-1)];continue t}if(32&Q){A.mode=12;break e}s.msg="invalid literal/length code",A.mode=30;break e}w=65535&S,(Q&=15)&&(C<Q&&(I+=F[c++]<<C,C+=8),w+=I&(1<<Q)-1,I>>>=Q,C-=Q),C<15&&(I+=F[c++]<<C,C+=8,I+=F[c++]<<C,C+=8),S=x[I&B];n:for(;;){if(I>>>=Q=S>>>24,C-=Q,!(16&(Q=S>>>16&255))){if((64&Q)==0){S=x[(65535&S)+(I&(1<<Q)-1)];continue n}s.msg="invalid distance code",A.mode=30;break e}if(M=65535&S,C<(Q&=15)&&(I+=F[c++]<<C,(C+=8)<Q&&(I+=F[c++]<<C,C+=8)),d<(M+=I&(1<<Q)-1)){s.msg="invalid distance too far back",A.mode=30;break e}if(I>>>=Q,C-=Q,(Q=u-g)<M){if(p<(Q=M-Q)&&A.sane){s.msg="invalid distance too far back",A.mode=30;break e}if(R=_,(T=0)===f){if(T+=m-Q,Q<w){for(w-=Q;O[u++]=_[T++],--Q;);T=u-M,R=O}}else if(f<Q){if(T+=m+f-Q,(Q-=f)<w){for(w-=Q;O[u++]=_[T++],--Q;);if(T=0,f<w){for(w-=Q=f;O[u++]=_[T++],--Q;);T=u-M,R=O}}}else if(T+=f-Q,Q<w){for(w-=Q;O[u++]=_[T++],--Q;);T=u-M,R=O}for(;2<w;)O[u++]=R[T++],O[u++]=R[T++],O[u++]=R[T++],w-=3;w&&(O[u++]=R[T++],1<w&&(O[u++]=R[T++]))}else{for(T=u-M;O[u++]=O[T++],O[u++]=O[T++],O[u++]=O[T++],2<(w-=3););w&&(O[u++]=O[T++],1<w&&(O[u++]=O[T++]))}break}}break}}while(c<l&&u<h);c-=w=C>>3,I&=(1<<(C-=w<<3))-1,s.next_in=c,s.next_out=u,s.avail_in=c<l?l-c+5:5-(c-l),s.avail_out=u<h?h-u+257:257-(u-h),A.hold=I,A.bits=C}},{}],49:[function(o,i,r){var s=o("../utils/common"),a=o("./adler32"),A=o("./crc32"),c=o("./inffast"),l=o("./inftrees"),u=1,g=2,h=0,d=-2,m=1,p=852,f=592;function _(T){return(T>>>24&255)+(T>>>8&65280)+((65280&T)<<8)+((255&T)<<24)}function I(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function C(T){var R;return T&&T.state?(R=T.state,T.total_in=T.total_out=R.total=0,T.msg="",R.wrap&&(T.adler=1&R.wrap),R.mode=m,R.last=0,R.havedict=0,R.dmax=32768,R.head=null,R.hold=0,R.bits=0,R.lencode=R.lendyn=new s.Buf32(p),R.distcode=R.distdyn=new s.Buf32(f),R.sane=1,R.back=-1,h):d}function y(T){var R;return T&&T.state?((R=T.state).wsize=0,R.whave=0,R.wnext=0,C(T)):d}function x(T,R){var F,O;return T&&T.state?(O=T.state,R<0?(F=0,R=-R):(F=1+(R>>4),R<48&&(R&=15)),R&&(R<8||15<R)?d:(O.window!==null&&O.wbits!==R&&(O.window=null),O.wrap=F,O.wbits=R,y(T))):d}function E(T,R){var F,O;return T?(O=new I,(T.state=O).window=null,(F=x(T,R))!==h&&(T.state=null),F):d}var B,S,Q=!0;function w(T){if(Q){var R;for(B=new s.Buf32(512),S=new s.Buf32(32),R=0;R<144;)T.lens[R++]=8;for(;R<256;)T.lens[R++]=9;for(;R<280;)T.lens[R++]=7;for(;R<288;)T.lens[R++]=8;for(l(u,T.lens,0,288,B,0,T.work,{bits:9}),R=0;R<32;)T.lens[R++]=5;l(g,T.lens,0,32,S,0,T.work,{bits:5}),Q=!1}T.lencode=B,T.lenbits=9,T.distcode=S,T.distbits=5}function M(T,R,F,O){var U,Y=T.state;return Y.window===null&&(Y.wsize=1<<Y.wbits,Y.wnext=0,Y.whave=0,Y.window=new s.Buf8(Y.wsize)),O>=Y.wsize?(s.arraySet(Y.window,R,F-Y.wsize,Y.wsize,0),Y.wnext=0,Y.whave=Y.wsize):(O<(U=Y.wsize-Y.wnext)&&(U=O),s.arraySet(Y.window,R,F-O,U,Y.wnext),(O-=U)?(s.arraySet(Y.window,R,F-O,O,0),Y.wnext=O,Y.whave=Y.wsize):(Y.wnext+=U,Y.wnext===Y.wsize&&(Y.wnext=0),Y.whave<Y.wsize&&(Y.whave+=U))),0}r.inflateReset=y,r.inflateReset2=x,r.inflateResetKeep=C,r.inflateInit=function(T){return E(T,15)},r.inflateInit2=E,r.inflate=function(T,R){var F,O,U,Y,q,ee,W,J,te,ie,ne,le,de,Ie,ce,fe,ue,pe,Me,Se,he,Pe,we,Qe,Re=0,De=new s.Buf8(4),xe=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!T||!T.state||!T.output||!T.input&&T.avail_in!==0)return d;(F=T.state).mode===12&&(F.mode=13),q=T.next_out,U=T.output,W=T.avail_out,Y=T.next_in,O=T.input,ee=T.avail_in,J=F.hold,te=F.bits,ie=ee,ne=W,Pe=h;e:for(;;)switch(F.mode){case m:if(F.wrap===0){F.mode=13;break}for(;te<16;){if(ee===0)break e;ee--,J+=O[Y++]<<te,te+=8}if(2&F.wrap&&J===35615){De[F.check=0]=255&J,De[1]=J>>>8&255,F.check=A(F.check,De,2,0),te=J=0,F.mode=2;break}if(F.flags=0,F.head&&(F.head.done=!1),!(1&F.wrap)||(((255&J)<<8)+(J>>8))%31){T.msg="incorrect header check",F.mode=30;break}if((15&J)!=8){T.msg="unknown compression method",F.mode=30;break}if(te-=4,he=8+(15&(J>>>=4)),F.wbits===0)F.wbits=he;else if(he>F.wbits){T.msg="invalid window size",F.mode=30;break}F.dmax=1<<he,T.adler=F.check=1,F.mode=512&J?10:12,te=J=0;break;case 2:for(;te<16;){if(ee===0)break e;ee--,J+=O[Y++]<<te,te+=8}if(F.flags=J,(255&F.flags)!=8){T.msg="unknown compression method",F.mode=30;break}if(57344&F.flags){T.msg="unknown header flags set",F.mode=30;break}F.head&&(F.head.text=J>>8&1),512&F.flags&&(De[0]=255&J,De[1]=J>>>8&255,F.check=A(F.check,De,2,0)),te=J=0,F.mode=3;case 3:for(;te<32;){if(ee===0)break e;ee--,J+=O[Y++]<<te,te+=8}F.head&&(F.head.time=J),512&F.flags&&(De[0]=255&J,De[1]=J>>>8&255,De[2]=J>>>16&255,De[3]=J>>>24&255,F.check=A(F.check,De,4,0)),te=J=0,F.mode=4;case 4:for(;te<16;){if(ee===0)break e;ee--,J+=O[Y++]<<te,te+=8}F.head&&(F.head.xflags=255&J,F.head.os=J>>8),512&F.flags&&(De[0]=255&J,De[1]=J>>>8&255,F.check=A(F.check,De,2,0)),te=J=0,F.mode=5;case 5:if(1024&F.flags){for(;te<16;){if(ee===0)break e;ee--,J+=O[Y++]<<te,te+=8}F.length=J,F.head&&(F.head.extra_len=J),512&F.flags&&(De[0]=255&J,De[1]=J>>>8&255,F.check=A(F.check,De,2,0)),te=J=0}else F.head&&(F.head.extra=null);F.mode=6;case 6:if(1024&F.flags&&(ee<(le=F.length)&&(le=ee),le&&(F.head&&(he=F.head.extra_len-F.length,F.head.extra||(F.head.extra=new Array(F.head.extra_len)),s.arraySet(F.head.extra,O,Y,le,he)),512&F.flags&&(F.check=A(F.check,O,le,Y)),ee-=le,Y+=le,F.length-=le),F.length))break e;F.length=0,F.mode=7;case 7:if(2048&F.flags){if(ee===0)break e;for(le=0;he=O[Y+le++],F.head&&he&&F.length<65536&&(F.head.name+=String.fromCharCode(he)),he&&le<ee;);if(512&F.flags&&(F.check=A(F.check,O,le,Y)),ee-=le,Y+=le,he)break e}else F.head&&(F.head.name=null);F.length=0,F.mode=8;case 8:if(4096&F.flags){if(ee===0)break e;for(le=0;he=O[Y+le++],F.head&&he&&F.length<65536&&(F.head.comment+=String.fromCharCode(he)),he&&le<ee;);if(512&F.flags&&(F.check=A(F.check,O,le,Y)),ee-=le,Y+=le,he)break e}else F.head&&(F.head.comment=null);F.mode=9;case 9:if(512&F.flags){for(;te<16;){if(ee===0)break e;ee--,J+=O[Y++]<<te,te+=8}if(J!==(65535&F.check)){T.msg="header crc mismatch",F.mode=30;break}te=J=0}F.head&&(F.head.hcrc=F.flags>>9&1,F.head.done=!0),T.adler=F.check=0,F.mode=12;break;case 10:for(;te<32;){if(ee===0)break e;ee--,J+=O[Y++]<<te,te+=8}T.adler=F.check=_(J),te=J=0,F.mode=11;case 11:if(F.havedict===0)return T.next_out=q,T.avail_out=W,T.next_in=Y,T.avail_in=ee,F.hold=J,F.bits=te,2;T.adler=F.check=1,F.mode=12;case 12:if(R===5||R===6)break e;case 13:if(F.last){J>>>=7&te,te-=7&te,F.mode=27;break}for(;te<3;){if(ee===0)break e;ee--,J+=O[Y++]<<te,te+=8}switch(F.last=1&J,te-=1,3&(J>>>=1)){case 0:F.mode=14;break;case 1:if(w(F),F.mode=20,R!==6)break;J>>>=2,te-=2;break e;case 2:F.mode=17;break;case 3:T.msg="invalid block type",F.mode=30}J>>>=2,te-=2;break;case 14:for(J>>>=7&te,te-=7&te;te<32;){if(ee===0)break e;ee--,J+=O[Y++]<<te,te+=8}if((65535&J)!=(J>>>16^65535)){T.msg="invalid stored block lengths",F.mode=30;break}if(F.length=65535&J,te=J=0,F.mode=15,R===6)break e;case 15:F.mode=16;case 16:if(le=F.length){if(ee<le&&(le=ee),W<le&&(le=W),le===0)break e;s.arraySet(U,O,Y,le,q),ee-=le,Y+=le,W-=le,q+=le,F.length-=le;break}F.mode=12;break;case 17:for(;te<14;){if(ee===0)break e;ee--,J+=O[Y++]<<te,te+=8}if(F.nlen=257+(31&J),J>>>=5,te-=5,F.ndist=1+(31&J),J>>>=5,te-=5,F.ncode=4+(15&J),J>>>=4,te-=4,286<F.nlen||30<F.ndist){T.msg="too many length or distance symbols",F.mode=30;break}F.have=0,F.mode=18;case 18:for(;F.have<F.ncode;){for(;te<3;){if(ee===0)break e;ee--,J+=O[Y++]<<te,te+=8}F.lens[xe[F.have++]]=7&J,J>>>=3,te-=3}for(;F.have<19;)F.lens[xe[F.have++]]=0;if(F.lencode=F.lendyn,F.lenbits=7,we={bits:F.lenbits},Pe=l(0,F.lens,0,19,F.lencode,0,F.work,we),F.lenbits=we.bits,Pe){T.msg="invalid code lengths set",F.mode=30;break}F.have=0,F.mode=19;case 19:for(;F.have<F.nlen+F.ndist;){for(;fe=(Re=F.lencode[J&(1<<F.lenbits)-1])>>>16&255,ue=65535&Re,!((ce=Re>>>24)<=te);){if(ee===0)break e;ee--,J+=O[Y++]<<te,te+=8}if(ue<16)J>>>=ce,te-=ce,F.lens[F.have++]=ue;else{if(ue===16){for(Qe=ce+2;te<Qe;){if(ee===0)break e;ee--,J+=O[Y++]<<te,te+=8}if(J>>>=ce,te-=ce,F.have===0){T.msg="invalid bit length repeat",F.mode=30;break}he=F.lens[F.have-1],le=3+(3&J),J>>>=2,te-=2}else if(ue===17){for(Qe=ce+3;te<Qe;){if(ee===0)break e;ee--,J+=O[Y++]<<te,te+=8}te-=ce,he=0,le=3+(7&(J>>>=ce)),J>>>=3,te-=3}else{for(Qe=ce+7;te<Qe;){if(ee===0)break e;ee--,J+=O[Y++]<<te,te+=8}te-=ce,he=0,le=11+(127&(J>>>=ce)),J>>>=7,te-=7}if(F.have+le>F.nlen+F.ndist){T.msg="invalid bit length repeat",F.mode=30;break}for(;le--;)F.lens[F.have++]=he}}if(F.mode===30)break;if(F.lens[256]===0){T.msg="invalid code -- missing end-of-block",F.mode=30;break}if(F.lenbits=9,we={bits:F.lenbits},Pe=l(u,F.lens,0,F.nlen,F.lencode,0,F.work,we),F.lenbits=we.bits,Pe){T.msg="invalid literal/lengths set",F.mode=30;break}if(F.distbits=6,F.distcode=F.distdyn,we={bits:F.distbits},Pe=l(g,F.lens,F.nlen,F.ndist,F.distcode,0,F.work,we),F.distbits=we.bits,Pe){T.msg="invalid distances set",F.mode=30;break}if(F.mode=20,R===6)break e;case 20:F.mode=21;case 21:if(6<=ee&&258<=W){T.next_out=q,T.avail_out=W,T.next_in=Y,T.avail_in=ee,F.hold=J,F.bits=te,c(T,ne),q=T.next_out,U=T.output,W=T.avail_out,Y=T.next_in,O=T.input,ee=T.avail_in,J=F.hold,te=F.bits,F.mode===12&&(F.back=-1);break}for(F.back=0;fe=(Re=F.lencode[J&(1<<F.lenbits)-1])>>>16&255,ue=65535&Re,!((ce=Re>>>24)<=te);){if(ee===0)break e;ee--,J+=O[Y++]<<te,te+=8}if(fe&&(240&fe)==0){for(pe=ce,Me=fe,Se=ue;fe=(Re=F.lencode[Se+((J&(1<<pe+Me)-1)>>pe)])>>>16&255,ue=65535&Re,!(pe+(ce=Re>>>24)<=te);){if(ee===0)break e;ee--,J+=O[Y++]<<te,te+=8}J>>>=pe,te-=pe,F.back+=pe}if(J>>>=ce,te-=ce,F.back+=ce,F.length=ue,fe===0){F.mode=26;break}if(32&fe){F.back=-1,F.mode=12;break}if(64&fe){T.msg="invalid literal/length code",F.mode=30;break}F.extra=15&fe,F.mode=22;case 22:if(F.extra){for(Qe=F.extra;te<Qe;){if(ee===0)break e;ee--,J+=O[Y++]<<te,te+=8}F.length+=J&(1<<F.extra)-1,J>>>=F.extra,te-=F.extra,F.back+=F.extra}F.was=F.length,F.mode=23;case 23:for(;fe=(Re=F.distcode[J&(1<<F.distbits)-1])>>>16&255,ue=65535&Re,!((ce=Re>>>24)<=te);){if(ee===0)break e;ee--,J+=O[Y++]<<te,te+=8}if((240&fe)==0){for(pe=ce,Me=fe,Se=ue;fe=(Re=F.distcode[Se+((J&(1<<pe+Me)-1)>>pe)])>>>16&255,ue=65535&Re,!(pe+(ce=Re>>>24)<=te);){if(ee===0)break e;ee--,J+=O[Y++]<<te,te+=8}J>>>=pe,te-=pe,F.back+=pe}if(J>>>=ce,te-=ce,F.back+=ce,64&fe){T.msg="invalid distance code",F.mode=30;break}F.offset=ue,F.extra=15&fe,F.mode=24;case 24:if(F.extra){for(Qe=F.extra;te<Qe;){if(ee===0)break e;ee--,J+=O[Y++]<<te,te+=8}F.offset+=J&(1<<F.extra)-1,J>>>=F.extra,te-=F.extra,F.back+=F.extra}if(F.offset>F.dmax){T.msg="invalid distance too far back",F.mode=30;break}F.mode=25;case 25:if(W===0)break e;if(le=ne-W,F.offset>le){if((le=F.offset-le)>F.whave&&F.sane){T.msg="invalid distance too far back",F.mode=30;break}de=le>F.wnext?(le-=F.wnext,F.wsize-le):F.wnext-le,le>F.length&&(le=F.length),Ie=F.window}else Ie=U,de=q-F.offset,le=F.length;for(W<le&&(le=W),W-=le,F.length-=le;U[q++]=Ie[de++],--le;);F.length===0&&(F.mode=21);break;case 26:if(W===0)break e;U[q++]=F.length,W--,F.mode=21;break;case 27:if(F.wrap){for(;te<32;){if(ee===0)break e;ee--,J|=O[Y++]<<te,te+=8}if(ne-=W,T.total_out+=ne,F.total+=ne,ne&&(T.adler=F.check=F.flags?A(F.check,U,ne,q-ne):a(F.check,U,ne,q-ne)),ne=W,(F.flags?J:_(J))!==F.check){T.msg="incorrect data check",F.mode=30;break}te=J=0}F.mode=28;case 28:if(F.wrap&&F.flags){for(;te<32;){if(ee===0)break e;ee--,J+=O[Y++]<<te,te+=8}if(J!==(4294967295&F.total)){T.msg="incorrect length check",F.mode=30;break}te=J=0}F.mode=29;case 29:Pe=1;break e;case 30:Pe=-3;break e;case 31:return-4;default:return d}return T.next_out=q,T.avail_out=W,T.next_in=Y,T.avail_in=ee,F.hold=J,F.bits=te,(F.wsize||ne!==T.avail_out&&F.mode<30&&(F.mode<27||R!==4))&&M(T,T.output,T.next_out,ne-T.avail_out)?(F.mode=31,-4):(ie-=T.avail_in,ne-=T.avail_out,T.total_in+=ie,T.total_out+=ne,F.total+=ne,F.wrap&&ne&&(T.adler=F.check=F.flags?A(F.check,U,ne,T.next_out-ne):a(F.check,U,ne,T.next_out-ne)),T.data_type=F.bits+(F.last?64:0)+(F.mode===12?128:0)+(F.mode===20||F.mode===15?256:0),(ie==0&&ne===0||R===4)&&Pe===h&&(Pe=-5),Pe)},r.inflateEnd=function(T){if(!T||!T.state)return d;var R=T.state;return R.window&&(R.window=null),T.state=null,h},r.inflateGetHeader=function(T,R){var F;return T&&T.state?(2&(F=T.state).wrap)==0?d:((F.head=R).done=!1,h):d},r.inflateSetDictionary=function(T,R){var F,O=R.length;return T&&T.state?(F=T.state).wrap!==0&&F.mode!==11?d:F.mode===11&&a(1,R,O,0)!==F.check?-3:M(T,R,O,O)?(F.mode=31,-4):(F.havedict=1,h):d},r.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(o,i,r){var s=o("../utils/common"),a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],A=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],l=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];i.exports=function(u,g,h,d,m,p,f,_){var I,C,y,x,E,B,S,Q,w,M=_.bits,T=0,R=0,F=0,O=0,U=0,Y=0,q=0,ee=0,W=0,J=0,te=null,ie=0,ne=new s.Buf16(16),le=new s.Buf16(16),de=null,Ie=0;for(T=0;T<=15;T++)ne[T]=0;for(R=0;R<d;R++)ne[g[h+R]]++;for(U=M,O=15;1<=O&&ne[O]===0;O--);if(O<U&&(U=O),O===0)return m[p++]=20971520,m[p++]=20971520,_.bits=1,0;for(F=1;F<O&&ne[F]===0;F++);for(U<F&&(U=F),T=ee=1;T<=15;T++)if(ee<<=1,(ee-=ne[T])<0)return-1;if(0<ee&&(u===0||O!==1))return-1;for(le[1]=0,T=1;T<15;T++)le[T+1]=le[T]+ne[T];for(R=0;R<d;R++)g[h+R]!==0&&(f[le[g[h+R]]++]=R);if(B=u===0?(te=de=f,19):u===1?(te=a,ie-=257,de=A,Ie-=257,256):(te=c,de=l,-1),T=F,E=p,q=R=J=0,y=-1,x=(W=1<<(Y=U))-1,u===1&&852<W||u===2&&592<W)return 1;for(;;){for(S=T-q,w=f[R]<B?(Q=0,f[R]):f[R]>B?(Q=de[Ie+f[R]],te[ie+f[R]]):(Q=96,0),I=1<<T-q,F=C=1<<Y;m[E+(J>>q)+(C-=I)]=S<<24|Q<<16|w|0,C!==0;);for(I=1<<T-1;J&I;)I>>=1;if(I!==0?(J&=I-1,J+=I):J=0,R++,--ne[T]==0){if(T===O)break;T=g[h+f[R]]}if(U<T&&(J&x)!==y){for(q===0&&(q=U),E+=F,ee=1<<(Y=T-q);Y+q<O&&!((ee-=ne[Y+q])<=0);)Y++,ee<<=1;if(W+=1<<Y,u===1&&852<W||u===2&&592<W)return 1;m[y=J&x]=U<<24|Y<<16|E-p|0}}return J!==0&&(m[E+J]=T-q<<24|64<<16|0),_.bits=U,0}},{"../utils/common":41}],51:[function(o,i,r){i.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(o,i,r){var s=o("../utils/common"),a=0,A=1;function c(Re){for(var De=Re.length;0<=--De;)Re[De]=0}var l=0,u=29,g=256,h=g+1+u,d=30,m=19,p=2*h+1,f=15,_=16,I=7,C=256,y=16,x=17,E=18,B=[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],S=[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],Q=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],w=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],M=new Array(2*(h+2));c(M);var T=new Array(2*d);c(T);var R=new Array(512);c(R);var F=new Array(256);c(F);var O=new Array(u);c(O);var U,Y,q,ee=new Array(d);function W(Re,De,xe,Te,Ce){this.static_tree=Re,this.extra_bits=De,this.extra_base=xe,this.elems=Te,this.max_length=Ce,this.has_stree=Re&&Re.length}function J(Re,De){this.dyn_tree=Re,this.max_code=0,this.stat_desc=De}function te(Re){return Re<256?R[Re]:R[256+(Re>>>7)]}function ie(Re,De){Re.pending_buf[Re.pending++]=255&De,Re.pending_buf[Re.pending++]=De>>>8&255}function ne(Re,De,xe){Re.bi_valid>_-xe?(Re.bi_buf|=De<<Re.bi_valid&65535,ie(Re,Re.bi_buf),Re.bi_buf=De>>_-Re.bi_valid,Re.bi_valid+=xe-_):(Re.bi_buf|=De<<Re.bi_valid&65535,Re.bi_valid+=xe)}function le(Re,De,xe){ne(Re,xe[2*De],xe[2*De+1])}function de(Re,De){for(var xe=0;xe|=1&Re,Re>>>=1,xe<<=1,0<--De;);return xe>>>1}function Ie(Re,De,xe){var Te,Ce,Fe=new Array(f+1),Ge=0;for(Te=1;Te<=f;Te++)Fe[Te]=Ge=Ge+xe[Te-1]<<1;for(Ce=0;Ce<=De;Ce++){var Xe=Re[2*Ce+1];Xe!==0&&(Re[2*Ce]=de(Fe[Xe]++,Xe))}}function ce(Re){var De;for(De=0;De<h;De++)Re.dyn_ltree[2*De]=0;for(De=0;De<d;De++)Re.dyn_dtree[2*De]=0;for(De=0;De<m;De++)Re.bl_tree[2*De]=0;Re.dyn_ltree[2*C]=1,Re.opt_len=Re.static_len=0,Re.last_lit=Re.matches=0}function fe(Re){8<Re.bi_valid?ie(Re,Re.bi_buf):0<Re.bi_valid&&(Re.pending_buf[Re.pending++]=Re.bi_buf),Re.bi_buf=0,Re.bi_valid=0}function ue(Re,De,xe,Te){var Ce=2*De,Fe=2*xe;return Re[Ce]<Re[Fe]||Re[Ce]===Re[Fe]&&Te[De]<=Te[xe]}function pe(Re,De,xe){for(var Te=Re.heap[xe],Ce=xe<<1;Ce<=Re.heap_len&&(Ce<Re.heap_len&&ue(De,Re.heap[Ce+1],Re.heap[Ce],Re.depth)&&Ce++,!ue(De,Te,Re.heap[Ce],Re.depth));)Re.heap[xe]=Re.heap[Ce],xe=Ce,Ce<<=1;Re.heap[xe]=Te}function Me(Re,De,xe){var Te,Ce,Fe,Ge,Xe=0;if(Re.last_lit!==0)for(;Te=Re.pending_buf[Re.d_buf+2*Xe]<<8|Re.pending_buf[Re.d_buf+2*Xe+1],Ce=Re.pending_buf[Re.l_buf+Xe],Xe++,Te===0?le(Re,Ce,De):(le(Re,(Fe=F[Ce])+g+1,De),(Ge=B[Fe])!==0&&ne(Re,Ce-=O[Fe],Ge),le(Re,Fe=te(--Te),xe),(Ge=S[Fe])!==0&&ne(Re,Te-=ee[Fe],Ge)),Xe<Re.last_lit;);le(Re,C,De)}function Se(Re,De){var xe,Te,Ce,Fe=De.dyn_tree,Ge=De.stat_desc.static_tree,Xe=De.stat_desc.has_stree,st=De.stat_desc.elems,rt=-1;for(Re.heap_len=0,Re.heap_max=p,xe=0;xe<st;xe++)Fe[2*xe]!==0?(Re.heap[++Re.heap_len]=rt=xe,Re.depth[xe]=0):Fe[2*xe+1]=0;for(;Re.heap_len<2;)Fe[2*(Ce=Re.heap[++Re.heap_len]=rt<2?++rt:0)]=1,Re.depth[Ce]=0,Re.opt_len--,Xe&&(Re.static_len-=Ge[2*Ce+1]);for(De.max_code=rt,xe=Re.heap_len>>1;1<=xe;xe--)pe(Re,Fe,xe);for(Ce=st;xe=Re.heap[1],Re.heap[1]=Re.heap[Re.heap_len--],pe(Re,Fe,1),Te=Re.heap[1],Re.heap[--Re.heap_max]=xe,Re.heap[--Re.heap_max]=Te,Fe[2*Ce]=Fe[2*xe]+Fe[2*Te],Re.depth[Ce]=(Re.depth[xe]>=Re.depth[Te]?Re.depth[xe]:Re.depth[Te])+1,Fe[2*xe+1]=Fe[2*Te+1]=Ce,Re.heap[1]=Ce++,pe(Re,Fe,1),2<=Re.heap_len;);Re.heap[--Re.heap_max]=Re.heap[1],(function(tt,dt){var St,Ct,Nt,Ft,nt,Yt,cn=dt.dyn_tree,Ee=dt.max_code,Ze=dt.stat_desc.static_tree,It=dt.stat_desc.has_stree,bt=dt.stat_desc.extra_bits,pt=dt.stat_desc.extra_base,Et=dt.stat_desc.max_length,ft=0;for(Ft=0;Ft<=f;Ft++)tt.bl_count[Ft]=0;for(cn[2*tt.heap[tt.heap_max]+1]=0,St=tt.heap_max+1;St<p;St++)Et<(Ft=cn[2*cn[2*(Ct=tt.heap[St])+1]+1]+1)&&(Ft=Et,ft++),cn[2*Ct+1]=Ft,Ee<Ct||(tt.bl_count[Ft]++,nt=0,pt<=Ct&&(nt=bt[Ct-pt]),Yt=cn[2*Ct],tt.opt_len+=Yt*(Ft+nt),It&&(tt.static_len+=Yt*(Ze[2*Ct+1]+nt)));if(ft!==0){do{for(Ft=Et-1;tt.bl_count[Ft]===0;)Ft--;tt.bl_count[Ft]--,tt.bl_count[Ft+1]+=2,tt.bl_count[Et]--,ft-=2}while(0<ft);for(Ft=Et;Ft!==0;Ft--)for(Ct=tt.bl_count[Ft];Ct!==0;)Ee<(Nt=tt.heap[--St])||(cn[2*Nt+1]!==Ft&&(tt.opt_len+=(Ft-cn[2*Nt+1])*cn[2*Nt],cn[2*Nt+1]=Ft),Ct--)}})(Re,De),Ie(Fe,rt,Re.bl_count)}function he(Re,De,xe){var Te,Ce,Fe=-1,Ge=De[1],Xe=0,st=7,rt=4;for(Ge===0&&(st=138,rt=3),De[2*(xe+1)+1]=65535,Te=0;Te<=xe;Te++)Ce=Ge,Ge=De[2*(Te+1)+1],++Xe<st&&Ce===Ge||(Xe<rt?Re.bl_tree[2*Ce]+=Xe:Ce!==0?(Ce!==Fe&&Re.bl_tree[2*Ce]++,Re.bl_tree[2*y]++):Xe<=10?Re.bl_tree[2*x]++:Re.bl_tree[2*E]++,Fe=Ce,rt=(Xe=0)===Ge?(st=138,3):Ce===Ge?(st=6,3):(st=7,4))}function Pe(Re,De,xe){var Te,Ce,Fe=-1,Ge=De[1],Xe=0,st=7,rt=4;for(Ge===0&&(st=138,rt=3),Te=0;Te<=xe;Te++)if(Ce=Ge,Ge=De[2*(Te+1)+1],!(++Xe<st&&Ce===Ge)){if(Xe<rt)for(;le(Re,Ce,Re.bl_tree),--Xe!=0;);else Ce!==0?(Ce!==Fe&&(le(Re,Ce,Re.bl_tree),Xe--),le(Re,y,Re.bl_tree),ne(Re,Xe-3,2)):Xe<=10?(le(Re,x,Re.bl_tree),ne(Re,Xe-3,3)):(le(Re,E,Re.bl_tree),ne(Re,Xe-11,7));Fe=Ce,rt=(Xe=0)===Ge?(st=138,3):Ce===Ge?(st=6,3):(st=7,4)}}c(ee);var we=!1;function Qe(Re,De,xe,Te){ne(Re,(l<<1)+(Te?1:0),3),(function(Ce,Fe,Ge,Xe){fe(Ce),ie(Ce,Ge),ie(Ce,~Ge),s.arraySet(Ce.pending_buf,Ce.window,Fe,Ge,Ce.pending),Ce.pending+=Ge})(Re,De,xe)}r._tr_init=function(Re){we||((function(){var De,xe,Te,Ce,Fe,Ge=new Array(f+1);for(Ce=Te=0;Ce<u-1;Ce++)for(O[Ce]=Te,De=0;De<1<<B[Ce];De++)F[Te++]=Ce;for(F[Te-1]=Ce,Ce=Fe=0;Ce<16;Ce++)for(ee[Ce]=Fe,De=0;De<1<<S[Ce];De++)R[Fe++]=Ce;for(Fe>>=7;Ce<d;Ce++)for(ee[Ce]=Fe<<7,De=0;De<1<<S[Ce]-7;De++)R[256+Fe++]=Ce;for(xe=0;xe<=f;xe++)Ge[xe]=0;for(De=0;De<=143;)M[2*De+1]=8,De++,Ge[8]++;for(;De<=255;)M[2*De+1]=9,De++,Ge[9]++;for(;De<=279;)M[2*De+1]=7,De++,Ge[7]++;for(;De<=287;)M[2*De+1]=8,De++,Ge[8]++;for(Ie(M,h+1,Ge),De=0;De<d;De++)T[2*De+1]=5,T[2*De]=de(De,5);U=new W(M,B,g+1,h,f),Y=new W(T,S,0,d,f),q=new W(new Array(0),Q,0,m,I)})(),we=!0),Re.l_desc=new J(Re.dyn_ltree,U),Re.d_desc=new J(Re.dyn_dtree,Y),Re.bl_desc=new J(Re.bl_tree,q),Re.bi_buf=0,Re.bi_valid=0,ce(Re)},r._tr_stored_block=Qe,r._tr_flush_block=function(Re,De,xe,Te){var Ce,Fe,Ge=0;0<Re.level?(Re.strm.data_type===2&&(Re.strm.data_type=(function(Xe){var st,rt=4093624447;for(st=0;st<=31;st++,rt>>>=1)if(1&rt&&Xe.dyn_ltree[2*st]!==0)return a;if(Xe.dyn_ltree[18]!==0||Xe.dyn_ltree[20]!==0||Xe.dyn_ltree[26]!==0)return A;for(st=32;st<g;st++)if(Xe.dyn_ltree[2*st]!==0)return A;return a})(Re)),Se(Re,Re.l_desc),Se(Re,Re.d_desc),Ge=(function(Xe){var st;for(he(Xe,Xe.dyn_ltree,Xe.l_desc.max_code),he(Xe,Xe.dyn_dtree,Xe.d_desc.max_code),Se(Xe,Xe.bl_desc),st=m-1;3<=st&&Xe.bl_tree[2*w[st]+1]===0;st--);return Xe.opt_len+=3*(st+1)+5+5+4,st})(Re),Ce=Re.opt_len+3+7>>>3,(Fe=Re.static_len+3+7>>>3)<=Ce&&(Ce=Fe)):Ce=Fe=xe+5,xe+4<=Ce&&De!==-1?Qe(Re,De,xe,Te):Re.strategy===4||Fe===Ce?(ne(Re,2+(Te?1:0),3),Me(Re,M,T)):(ne(Re,4+(Te?1:0),3),(function(Xe,st,rt,tt){var dt;for(ne(Xe,st-257,5),ne(Xe,rt-1,5),ne(Xe,tt-4,4),dt=0;dt<tt;dt++)ne(Xe,Xe.bl_tree[2*w[dt]+1],3);Pe(Xe,Xe.dyn_ltree,st-1),Pe(Xe,Xe.dyn_dtree,rt-1)})(Re,Re.l_desc.max_code+1,Re.d_desc.max_code+1,Ge+1),Me(Re,Re.dyn_ltree,Re.dyn_dtree)),ce(Re),Te&&fe(Re)},r._tr_tally=function(Re,De,xe){return Re.pending_buf[Re.d_buf+2*Re.last_lit]=De>>>8&255,Re.pending_buf[Re.d_buf+2*Re.last_lit+1]=255&De,Re.pending_buf[Re.l_buf+Re.last_lit]=255&xe,Re.last_lit++,De===0?Re.dyn_ltree[2*xe]++:(Re.matches++,De--,Re.dyn_ltree[2*(F[xe]+g+1)]++,Re.dyn_dtree[2*te(De)]++),Re.last_lit===Re.lit_bufsize-1},r._tr_align=function(Re){ne(Re,2,3),le(Re,C,M),(function(De){De.bi_valid===16?(ie(De,De.bi_buf),De.bi_buf=0,De.bi_valid=0):8<=De.bi_valid&&(De.pending_buf[De.pending++]=255&De.bi_buf,De.bi_buf>>=8,De.bi_valid-=8)})(Re)}},{"../utils/common":41}],53:[function(o,i,r){i.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(o,i,r){(function(s){(function(a,A){if(!a.setImmediate){var c,l,u,g,h=1,d={},m=!1,p=a.document,f=Object.getPrototypeOf&&Object.getPrototypeOf(a);f=f&&f.setTimeout?f:a,c={}.toString.call(a.process)==="[object process]"?function(y){n.nextTick(function(){I(y)})}:(function(){if(a.postMessage&&!a.importScripts){var y=!0,x=a.onmessage;return a.onmessage=function(){y=!1},a.postMessage("","*"),a.onmessage=x,y}})()?(g="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",C,!1):a.attachEvent("onmessage",C),function(y){a.postMessage(g+y,"*")}):a.MessageChannel?((u=new MessageChannel).port1.onmessage=function(y){I(y.data)},function(y){u.port2.postMessage(y)}):p&&"onreadystatechange"in p.createElement("script")?(l=p.documentElement,function(y){var x=p.createElement("script");x.onreadystatechange=function(){I(y),x.onreadystatechange=null,l.removeChild(x),x=null},l.appendChild(x)}):function(y){setTimeout(I,0,y)},f.setImmediate=function(y){typeof y!="function"&&(y=new Function(""+y));for(var x=new Array(arguments.length-1),E=0;E<x.length;E++)x[E]=arguments[E+1];var B={callback:y,args:x};return d[h]=B,c(h),h++},f.clearImmediate=_}function _(y){delete d[y]}function I(y){if(m)setTimeout(I,0,y);else{var x=d[y];if(x){m=!0;try{(function(E){var B=E.callback,S=E.args;switch(S.length){case 0:B();break;case 1:B(S[0]);break;case 2:B(S[0],S[1]);break;case 3:B(S[0],S[1],S[2]);break;default:B.apply(A,S)}})(x)}finally{_(y),m=!1}}}}function C(y){y.source===a&&typeof y.data=="string"&&y.data.indexOf(g)===0&&I(+y.data.slice(g.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof Ny<"u"?Ny:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(ZZe)),ZZe.exports}var _tr=ftr();const T1e=SC(_tr),Itr=async({circuitJson:t,projectName:e})=>{await ua.promise((async()=>{const n=new T1e,[o,{convertCircuitJsonToBomRows:i,convertBomRowsToCsv:r},{convertCircuitJsonToPickAndPlaceCsv:s}]=await Promise.all([$E("circuit-json-to-gerber"),$E("circuit-json-to-bom-csv"),$E("circuit-json-to-pnp-csv")]),a=t.filter(h=>!("error_type"in h)&&!("warning_type"in h)),A=o.convertCircuitJsonToGerberFiles(a,{flip_y_axis:!1});for(const[h,d]of Object.entries(A))n.file(`gerber/${h}`,d);const c=await i({circuitJson:t}),l=await r(c);n.file("bom.csv",l);const u=await s(t,{supplier:"jlcpcb"});n.file("pick_and_place.csv",u);const g=await n.generateAsync({type:"blob"});XE(g,{fileName:`${e}_fabrication_files.zip`})})(),{loading:"Generating fabrication files...",success:"Fabrication ZIP ready",error:n=>`Failed to generate fabrication files: ${n instanceof Error?n.message:String(n)}`})},Ctr=async t=>{const{createFdmComponentBox:e,renderFdmComponentBoxPng:n}=await $E("circuit-json-to-fdm-component-box"),[o,i]=await Promise.all([e(t),n(t,{},{width:960,height:640})]);return{...o,previewPng:i}},ytr=async t=>{const{createFdmComponentBox:e}=await $E("circuit-json-to-fdm-component-box");return e(t)},_xn=({generatedBox:t,projectName:e})=>{const n=Uint8Array.from(t.threeMf);XE(new Blob([n.buffer],{type:"model/3mf"}),{fileName:`${BZe(e)}-component-box.3mf`})},xtr=async({circuitJson:t,projectName:e})=>{await ua.promise((async()=>{const n=await ytr(t);_xn({generatedBox:n,projectName:e})})(),{loading:"Generating component box...",success:"Component box 3MF ready",error:n=>`Failed to generate component box: ${n instanceof Error?n.message:String(n)}`})},Etr=async({circuitJson:t,projectName:e})=>{let n;try{const{convertCircuitJsonToGltf:o}=await $E("circuit-json-to-gltf");console.log("convertCircuitJsonToGltf",o);const i=await o(t,{format:"glb",boardTextureResolution:1024});if(!i||!(i instanceof ArrayBuffer))throw new Error("Invalid GLB data returned from converter");n=new Blob([i],{type:"model/gltf-binary"})}catch(o){console.error("GLB Export Error:",o);return}XE(n,{fileName:`${e}.glb`})},Btr=async({circuitJson:t,libraryName:e})=>{const{CircuitJsonToKicadLibraryConverter:n}=await $E("circuit-json-to-kicad"),o=new n(t,{libraryName:e,footprintLibraryName:e});o.runUntilFinished();const i=o.getOutput(),r=new T1e;r.file(`${e}.kicad_sym`,i.kicadSymString);for(const s of i.footprints){const a=r.folder(`${e}.pretty`);a&&a.file(`${s.footprintName}.kicad_mod`,`${s.kicadModString}
|
|
5673
5673
|
`)}if(i.model3dSourcePaths.length>0){const s=r.folder(`${e}.3dshapes`);if(s)for(const a of i.model3dSourcePaths)try{const A=a.split("/").pop()||a,c=await fetch(a);if(c.ok){const l=await c.arrayBuffer();s.file(A,l)}}catch{}}return r.file("fp-lib-table",i.fpLibTableString),r.file("sym-lib-table",i.symLibTableString),r},btr=async({circuitJson:t,projectName:e})=>{await ua.promise((async()=>{const o=await(await Btr({circuitJson:t,libraryName:e})).generateAsync({type:"blob"});XE(o,{fileName:`${e}_kicad_library.zip`})})(),{loading:"Generating KiCad library...",success:"KiCad library ZIP ready",error:n=>`Failed to generate KiCad library: ${n instanceof Error?n.message:String(n)}`})},Str=async({circuitJson:t,projectName:e})=>{const{CircuitJsonToKicadPcbConverter:n,CircuitJsonToKicadSchConverter:o,CircuitJsonToKicadProConverter:i,resolveAndLoadKicad3dModelFiles:r}=await $E("circuit-json-to-kicad"),s=new o(t);s.runUntilFinished();const a=s.getOutputString(),A=new n(t,{includeBuiltin3dModels:!0,projectName:e});A.runUntilFinished();const c=A.getOutputString(),l=new i(t,{projectName:e,schematicFilename:`${e}.kicad_sch`,pcbFilename:`${e}.kicad_pcb`});l.runUntilFinished();const u=l.getOutputString(),g=new T1e;return g.file(`${e}.kicad_sch`,a),g.file(`${e}.kicad_pcb`,c),g.file(`${e}.kicad_pro`,u),await r({projectName:e,model3dSourcePaths:A.getModel3dSourcePaths(),fetch,onModelFile:({outputPath:h,content:d})=>{g.file(h,d)},onError:({sourcePath:h})=>{console.warn(`Failed to load 3D model from ${h}`)}}),g},Qtr=async({circuitJson:t,projectName:e})=>{await ua.promise((async()=>{const o=await(await Str({circuitJson:t,projectName:e})).generateAsync({type:"blob"});XE(o,{fileName:`${e}_kicad_project.zip`})})(),{loading:"Generating KiCad project...",success:"KiCad project ZIP ready",error:n=>`Failed to generate KiCad project: ${n instanceof Error?n.message:String(n)}`})},Ixn=async({circuitJson:t,projectName:e,options:n={}})=>{try{const{convertCircuitJsonToLbrn:o}=await $E("circuit-json-to-lbrn"),r=(await o(t,{includeSilkscreen:n.includeSilkscreen??!1,includeOxidationCleaningLayer:n.includeOxidationCleaningLayer??!0})).toXml(),s=new Blob([r],{type:"application/lbrn"});XE(s,{fileName:`${e}.lbrn2`})}catch(o){const i=o instanceof Error?o.message:"Unknown error";ua.error(`Failed to export to LBRN format: ${i}`)}},vtr=async({circuitJson:t,projectName:e})=>{const{convertCircuitJsonToPinoutSvg:n}=await $E("circuit-to-svg"),o=n(t);XE(o,{fileName:`${e}-pinout.svg`,mimeType:"image/svg+xml"})},wtr=async({circuitJson:t,projectName:e})=>{const{circuitJsonToStep:n}=await $E("circuit-json-to-step"),o=t.find(c=>c.type==="pcb_board"),i=o&&"width"in o?o.width:void 0,r=o&&"height"in o?o.height:void 0,s=o&&"thickness"in o?o.thickness:void 0;if(i===void 0||r===void 0||s===void 0){ua.error("Board dimensions not found. Please add a pcb_board with width, height, and thickness to your circuit.");return}let a;try{a=await n(t,{boardWidth:i,boardHeight:r,boardThickness:s,productName:e,includeComponents:!0,includeExternalMeshes:!0})}catch(c){const l=c instanceof Error?c.message:"Unknown error";ua.error(`Failed to convert circuit to STEP format: ${l}`);return}const A=new Blob([a],{type:"application/step"});try{XE(A,{fileName:`${e}.step`})}catch(c){const l=c instanceof Error?c.message:"Unknown error";ua.error(`Failed to download STEP file: ${l}`)}},Ptr=[{extension:"json",name:"Circuit JSON"},{extension:"json",name:"Simple Route JSON"},{extension:"zip",name:"Fabrication Files"},{extension:"zip",name:"KiCad Project"},{extension:"zip",name:"Altium Project"},{extension:"zip",name:"KiCad Library"},{extension:"glb",name:"GLB (Binary GLTF)"},{extension:"svg",name:"Pinout SVG"},{extension:"step",name:"STEP"},{extension:"lbrn2",name:"LightBurn"}],Mtr=async({exportName:t,circuitJson:e,simpleRouteJson:n,projectName:o})=>{const i=BZe(o);if(t==="Fabrication Files"){await Itr({circuitJson:e,projectName:i});return}if(t==="KiCad Project"){await Qtr({circuitJson:e,projectName:i});return}if(t==="Altium Project"){await ptr({circuitJson:e,projectName:i});return}if(t==="KiCad Library"){await btr({circuitJson:e,projectName:i});return}if(t==="Circuit JSON"){XE(JSON.stringify(e,null,2),{fileName:`${i}.circuit.json`,mimeType:"application/json"});return}if(t==="Simple Route JSON"){if(!n)throw new Error("No Simple Route JSON available to export");XE(JSON.stringify(n,null,2),{fileName:`${i}.simple-route.json`,mimeType:"application/json"});return}if(t==="GLB (Binary GLTF)"){await Etr({circuitJson:e,projectName:i});return}if(t==="Pinout SVG"){vtr({circuitJson:e,projectName:i});return}if(t==="STEP"){await wtr({circuitJson:e,projectName:i});return}if(t==="Component Box (3MF)"){await xtr({circuitJson:e,projectName:i});return}if(t==="LightBurn"){await Ixn({circuitJson:e,projectName:i});return}throw new Error(`Unsupported export type: "${t}"`)},Dtr=({packageName:t,onSelectReview:e})=>{const n=Id(u=>u.fsMap),o=Id(u=>u.circuitJson),[i,r]=X.useState([]),[s,a]=X.useState(!1),[A,c]=X.useState(!1);X.useEffect(()=>{!t||!Yde()||(a(!0),z$.get("ai_reviews/list",{searchParams:{package_name:t}}).json().then(u=>r(u.ai_reviews)).catch(u=>{console.error("Failed to load AI reviews",u),ua.error("Failed to load AI reviews")}).finally(()=>a(!1)))},[t]);const l=async()=>{if(!o){ua.error("Need Circuit JSON to Request AI Review");return}if(!Yde()){ua.error("Missing registry token");return}c(!0);try{const{ai_review:u}=await z$.post("ai_reviews/create",{json:{package_name:t??"unknown",fs_map:Object.fromEntries(n),circuit_json:o}}).json();r(g=>[u,...g]),e(u),ua.success("AI review requested")}catch(u){console.error("Failed to create AI review",u),ua.error("Failed to request AI review")}finally{c(!1)}};return K.jsxs(K.Fragment,{children:[K.jsxs(pM,{children:[K.jsx(fM,{children:"AI Review"}),K.jsx(mk,{children:"Select an AI review or request a new one."})]}),K.jsx("div",{className:"rf-flex rf-gap-4 rf-mt-4",children:K.jsx("div",{className:"rf-w-48 rf-h-64 rf-overflow-y-auto rf-border rf-rounded rf-p-2 rf-flex-shrink-0",children:s?K.jsx("div",{className:"rf-text-sm",children:"Loading..."}):i.length>0?i.map(u=>K.jsx("div",{className:"rf-text-sm rf-p-2 rf-cursor-pointer rf-rounded hover:rf-bg-zinc-100",onClick:()=>e(u),children:new Date(u.created_at||"").toLocaleString()},u.ai_review_id)):K.jsx("div",{className:"rf-text-sm rf-text-muted-foreground",children:"No AI reviews found."})})}),K.jsx(MK,{className:"rf-mt-4",children:K.jsx(IA,{onClick:l,disabled:A,children:A?"Requesting...":"Review my Board"})})]})};function eet(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var pk=eet();function Cxn(t){pk=t}var _te={exec:()=>null};function H0(t,e=""){let n=typeof t=="string"?t:t.source;const o={replace:(i,r)=>{let s=typeof r=="string"?r:r.source;return s=s.replace(b2.caret,"$1"),n=n.replace(i,s),o},getRegex:()=>new RegExp(n,e)};return o}var b2={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},Ntr=/^(?:[ \t]*(?:\n|$))+/,Rtr=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Ttr=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ite=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ktr=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,tet=/(?:[*+-]|\d{1,9}[.)])/,yxn=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,xxn=H0(yxn).replace(/bull/g,tet).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Ftr=H0(yxn).replace(/bull/g,tet).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),net=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Ltr=/^[^\n]+/,oet=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Htr=H0(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",oet).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Otr=H0(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,tet).getRegex(),k1e="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",iet=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Gtr=H0("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",iet).replace("tag",k1e).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Exn=H0(net).replace("hr",Ite).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",k1e).getRegex(),Ytr=H0(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Exn).getRegex(),ret={blockquote:Ytr,code:Rtr,def:Htr,fences:Ttr,heading:ktr,hr:Ite,html:Gtr,lheading:xxn,list:Otr,newline:Ntr,paragraph:Exn,table:_te,text:Ltr},Bxn=H0("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ite).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",k1e).getRegex(),Utr={...ret,lheading:Ftr,table:Bxn,paragraph:H0(net).replace("hr",Ite).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Bxn).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",k1e).getRegex()},Ktr={...ret,html:H0(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",iet).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:_te,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:H0(net).replace("hr",Ite).replace("heading",` *#{1,6} *[^
|
|
5674
5674
|
]`).replace("lheading",xxn).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ztr=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Vtr=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,bxn=/^( {2,}|\\)\n(?!\s*$)/,Jtr=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,F1e=/[\p{P}\p{S}]/u,set=/[\s\p{P}\p{S}]/u,Sxn=/[^\s\p{P}\p{S}]/u,Wtr=H0(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,set).getRegex(),Qxn=/(?!~)[\p{P}\p{S}]/u,jtr=/(?!~)[\s\p{P}\p{S}]/u,qtr=/(?:[^\s\p{P}\p{S}]|~)/u,$tr=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,vxn=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Xtr=H0(vxn,"u").replace(/punct/g,F1e).getRegex(),Ztr=H0(vxn,"u").replace(/punct/g,Qxn).getRegex(),wxn="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",enr=H0(wxn,"gu").replace(/notPunctSpace/g,Sxn).replace(/punctSpace/g,set).replace(/punct/g,F1e).getRegex(),tnr=H0(wxn,"gu").replace(/notPunctSpace/g,qtr).replace(/punctSpace/g,jtr).replace(/punct/g,Qxn).getRegex(),nnr=H0("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Sxn).replace(/punctSpace/g,set).replace(/punct/g,F1e).getRegex(),onr=H0(/\\(punct)/,"gu").replace(/punct/g,F1e).getRegex(),inr=H0(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),rnr=H0(iet).replace("(?:-->|$)","-->").getRegex(),snr=H0("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",rnr).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),L1e=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,anr=H0(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",L1e).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Pxn=H0(/^!?\[(label)\]\[(ref)\]/).replace("label",L1e).replace("ref",oet).getRegex(),Mxn=H0(/^!?\[(ref)\](?:\[\])?/).replace("ref",oet).getRegex(),Anr=H0("reflink|nolink(?!\\()","g").replace("reflink",Pxn).replace("nolink",Mxn).getRegex(),aet={_backpedal:_te,anyPunctuation:onr,autolink:inr,blockSkip:$tr,br:bxn,code:Vtr,del:_te,emStrongLDelim:Xtr,emStrongRDelimAst:enr,emStrongRDelimUnd:nnr,escape:ztr,link:anr,nolink:Mxn,punctuation:Wtr,reflink:Pxn,reflinkSearch:Anr,tag:snr,text:Jtr,url:_te},cnr={...aet,link:H0(/^!?\[(label)\]\((.*?)\)/).replace("label",L1e).getRegex(),reflink:H0(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",L1e).getRegex()},Aet={...aet,emStrongRDelimAst:tnr,emStrongLDelim:Ztr,url:H0(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},lnr={...Aet,br:H0(bxn).replace("{2,}","*").getRegex(),text:H0(Aet.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},H1e={normal:ret,gfm:Utr,pedantic:Ktr},Cte={normal:aet,gfm:Aet,breaks:lnr,pedantic:cnr},unr={"&":"&","<":"<",">":">",'"':""","'":"'"},Dxn=t=>unr[t];function S8(t,e){if(e){if(b2.escapeTest.test(t))return t.replace(b2.escapeReplace,Dxn)}else if(b2.escapeTestNoEncode.test(t))return t.replace(b2.escapeReplaceNoEncode,Dxn);return t}function Nxn(t){try{t=encodeURI(t).replace(b2.percentDecode,"%")}catch{return null}return t}function Rxn(t,e){const n=t.replace(b2.findPipe,(r,s,a)=>{let A=!1,c=s;for(;--c>=0&&a[c]==="\\";)A=!A;return A?"|":" |"}),o=n.split(b2.splitPipe);let i=0;if(o[0].trim()||o.shift(),o.length>0&&!o.at(-1)?.trim()&&o.pop(),e)if(o.length>e)o.splice(e);else for(;o.length<e;)o.push("");for(;i<o.length;i++)o[i]=o[i].trim().replace(b2.slashPipe,"|");return o}function yte(t,e,n){const o=t.length;if(o===0)return"";let i=0;for(;i<o&&t.charAt(o-i-1)===e;)i++;return t.slice(0,o-i)}function gnr(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let o=0;o<t.length;o++)if(t[o]==="\\")o++;else if(t[o]===e[0])n++;else if(t[o]===e[1]&&(n--,n<0))return o;return n>0?-2:-1}function Txn(t,e,n,o,i){const r=e.href,s=e.title||null,a=t[1].replace(i.other.outputLinkReplace,"$1");o.state.inLink=!0;const A={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:r,title:s,text:a,tokens:o.inlineTokens(a)};return o.state.inLink=!1,A}function dnr(t,e,n){const o=t.match(n.other.indentCodeCompensation);if(o===null)return e;const i=o[1];return e.split(`
|