{"version":3,"file":"use-window-event.mjs","names":[],"sources":["../../src/use-window-event/use-window-event.ts"],"sourcesContent":["import { useEffect, useEffectEvent } from 'react';\n\nexport function useWindowEvent<K extends string>(\n  type: K,\n  listener: K extends keyof WindowEventMap\n    ? (this: Window, ev: WindowEventMap[K]) => void\n    : (this: Window, ev: CustomEvent) => void,\n  options?: boolean | AddEventListenerOptions\n) {\n  const stableListener = useEffectEvent(listener);\n\n  useEffect(() => {\n    window.addEventListener(type as any, stableListener, options);\n    return () => window.removeEventListener(type as any, stableListener, options);\n  }, [type]);\n}\n"],"mappings":";;;AAEA,SAAgB,eACd,MACA,UAGA,SACA;CACA,MAAM,iBAAiB,eAAe,QAAQ;CAE9C,gBAAgB;EACd,OAAO,iBAAiB,MAAa,gBAAgB,OAAO;EAC5D,aAAa,OAAO,oBAAoB,MAAa,gBAAgB,OAAO;CAC9E,GAAG,CAAC,IAAI,CAAC;AACX"}