const r={};export function prepareReader(n=location.pathname){const e=/^\/backpack\/([^/]+)\/inspect$/.exec(n),t=n==="/immersion/read"?new URLSearchParams(location.search).get("id"):null;if((t||e&&history.state?.retained?.item===e[1])&&import("./inspection-client.mjs").then(({prepareInspection:a})=>a()).catch(()=>{}),t&&navigator.onLine!==!1&&r.source?.id!==t){const a=fetch("/api/immersion?"+new URLSearchParams({id:t,open:"1"}),{signal:AbortSignal.timeout(1e4)}).then(i=>i.ok?i.json():null).catch(()=>null);r.source={id:t,answer:a}}}export function earlySource(n){const e=r.source;return e?.id!==n?null:(r.source=null,e.answer)}prepareReader();const o=()=>globalThis.mtwEarlyInput??{};export function earlyTap(){const n=o(),e=n.tap;if(n.tap=null,!e||performance.now()-e.at>=8e3)return null;const t=e.glyph?.startContainer.isConnected?e.glyph.getBoundingClientRect():null;return t?.width?{...e,clientX:t.x+t.width/2,clientY:t.y+t.height/2}:e}export const restingPointer=()=>o().resting??null;const l=n=>{const e=o(),t=e[n];return e[n]=null,t!=null&&performance.now()-t<8e3};export const earlyPoster=()=>l("poster"),earlyPlay=()=>l("play"),earlySpeed=()=>{const n=o(),e=n.speed??0;return n.speed=0,e};
