{"version":3,"file":"deeplink.mjs","sources":["../../src/platform/deeplink.ts"],"sourcesContent":["import { Linking as RNLinking, LinkingStatic } from \"react-native\"\n\nimport { RNv64Compat } from \"../react_native_v64_compat\"\n\nlet Linking: RNLinking\ntry {\n  Linking = require(\"expo-linking\")\n} catch (err) {\n  Linking = RNLinking\n}\n\nexport type UrlChangeEvent = {\n  url: string\n}\n\nexport const onUrlChange = (fn: (event: UrlChangeEvent) => void, dispatchBufferSeconds = 5) => {\n  const dispatchTimes: Record<string, Date> = {}\n  const callback = (event: UrlChangeEvent) => {\n    const now = new Date()\n    const url = event.url\n    if (\n      !(url in dispatchTimes) ||\n      dispatchTimes[url].getTime() + dispatchBufferSeconds < now.getTime()\n    ) {\n      dispatchTimes[event.url] = now\n      fn(event)\n    }\n  }\n\n  const sub = Linking.addEventListener(\"url\", callback)\n\n  /* removeEventListener is deprecated but addEventListener does not return a\n   * subscription object in versions of React Native v0.64 or below. We can\n   * remove this condition when v64 (or below) is no longer supported.\n   */\n  return () =>\n    sub\n      ? sub.remove()\n      : (Linking as RNv64Compat<LinkingStatic>).removeEventListener(\"url\", callback)\n}\n"],"names":["Linking","RNLinking","onUrlChange","fn","dispatchBufferSeconds","dispatchTimes","callback","event","now","url","sub"],"mappings":";AAIA,IAAIA;AACJ,IAAI;AACF,EAAAA,IAAU,QAAQ,cAAc;AAClC,QAAc;AACZ,EAAAA,IAAUC;AACZ;AAMO,MAAMC,IAAc,CAACC,GAAqCC,IAAwB,MAAM;AAC7F,QAAMC,IAAsC,CAAA,GACtCC,IAAW,CAACC,MAA0B;AAC1C,UAAMC,wBAAU,KAAA,GACVC,IAAMF,EAAM;AAClB,KACE,EAAEE,KAAOJ,MACTA,EAAcI,CAAG,EAAE,YAAYL,IAAwBI,EAAI,QAAA,OAE3DH,EAAcE,EAAM,GAAG,IAAIC,GAC3BL,EAAGI,CAAK;AAAA,EAEZ,GAEMG,IAAMV,EAAQ,iBAAiB,OAAOM,CAAQ;AAMpD,SAAO,MACLI,IACIA,EAAI,OAAA,IACHV,EAAuC,oBAAoB,OAAOM,CAAQ;AACnF;"}