{"version":3,"sources":["../../../../src/elements/useWindowFocus/core.ts"],"sourcesContent":["import { observable, type Observable } from \"@legendapp/state\";\nimport { onMount } from \"@usels/core\";\nimport { defaultDocument } from \"@shared/configurable\";\nimport { createEventListener } from \"../../browser/useEventListener/core\";\n\nexport type UseWindowFocusReturn = Observable<boolean>;\n\n/**\n * Framework-agnostic reactive window focus tracker.\n *\n * Exposes an `Observable<boolean>` that reflects whether the browser window\n * currently has focus. Initial value is synced from `document.hasFocus()` in\n * `onMount` to match SSR output and avoid hydration mismatch. Updates via\n * `focus` / `blur` events on `window`.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function createWindowFocus(): UseWindowFocusReturn {\n  // Always initialize with false to match SSR output and avoid hydration mismatch.\n  // The actual value is synced after mount.\n  const focused$ = observable<boolean>(false);\n\n  onMount(() => {\n    focused$.set(defaultDocument?.hasFocus() ?? false);\n  });\n\n  createEventListener(\"focus\", () => focused$.set(true), { passive: true });\n  createEventListener(\"blur\", () => focused$.set(false), { passive: true });\n\n  return focused$;\n}\n"],"mappings":"AAAA,SAAS,kBAAmC;AAC5C,SAAS,eAAe;AACxB,SAAS,uBAAuB;AAChC,SAAS,2BAA2B;AAAA;AAa7B,SAAS,oBAA0C;AAGxD,QAAM,WAAW,WAAoB,KAAK;AAE1C,UAAQ,MAAM;AACZ,aAAS,IAAI,iBAAiB,SAAS,KAAK,KAAK;AAAA,EACnD,CAAC;AAED,sBAAoB,SAAS,MAAM,SAAS,IAAI,IAAI,GAAG,EAAE,SAAS,KAAK,CAAC;AACxE,sBAAoB,QAAQ,MAAM,SAAS,IAAI,KAAK,GAAG,EAAE,SAAS,KAAK,CAAC;AAExE,SAAO;AACT;","names":[]}