{"version":3,"file":"TabSlot.js","names":[],"sources":["esm/ui/TabSlot.js"],"sourcesContent":["import { Activity, Fragment, useState } from \"react\";\nimport { useNavigatorContext } from \"../views/Navigator\";\nimport { TabContext } from \"./TabContext\";\nimport { jsx } from \"react/jsx-runtime\";\nfunction useTabSlot({\n  detachInactiveScreens = true,\n  renderFn = defaultTabsSlotRender\n} = {}) {\n  const { state, descriptorsRef } = useNavigatorContext();\n  const descriptors = descriptorsRef.current;\n  const focusedRouteKey = state.routes[state.index].key;\n  const [loaded, setLoaded] = useState({ [focusedRouteKey]: true });\n  if (!loaded[focusedRouteKey]) {\n    setLoaded({ ...loaded, [focusedRouteKey]: true });\n  }\n  return /* @__PURE__ */ jsx(Fragment, { children: state.routes.map((route, index) => {\n    const descriptor = descriptors[route.key];\n    return /* @__PURE__ */ jsx(TabContext.Provider, { value: descriptor.options, children: renderFn(descriptor, {\n      index,\n      isFocused: state.index === index,\n      loaded: loaded[route.key],\n      detachInactiveScreens\n    }) }, descriptor.route.key);\n  }) });\n}\nfunction TabSlot(props) {\n  return useTabSlot(props);\n}\nfunction defaultTabsSlotRender(descriptor, { isFocused, loaded, detachInactiveScreens }) {\n  const { lazy = true, unmountOnBlur } = descriptor.options;\n  if ((unmountOnBlur || detachInactiveScreens) && !isFocused) return null;\n  if (lazy && !loaded && !isFocused) return null;\n  if (!isFocused) {\n    return /* @__PURE__ */ jsx(Activity, { mode: \"hidden\", children: descriptor.render() }, descriptor.route.key);\n  }\n  return /* @__PURE__ */ jsx(Fragment, { children: descriptor.render() }, descriptor.route.key);\n}\nfunction isTabSlot(child) {\n  return child.type === TabSlot;\n}\nexport {\n  TabSlot,\n  defaultTabsSlotRender,\n  isTabSlot,\n  useTabSlot\n};\n//# sourceMappingURL=TabSlot.js.map\n"],"mappings":";;;;;;AAIA,SAAS,WAAW,EAClB,wBAAwB,MACxB,WAAW,0BACT,CAAC,GAAG;CACN,MAAM,EAAE,OAAO,mBAAmB,oBAAoB;CACtD,MAAM,cA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