{"version":3,"file":"IntlayerProvider.cjs","names":["registerRequestLocaleResolver","IntlayerServerProvider","IntlayerClientProvider"],"sources":["../../../src/server/IntlayerProvider.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport type { IntlayerProviderProps as IntlayerClientProviderProps } from 'react-intlayer';\nimport {\n  IntlayerServerProvider,\n  type IntlayerServerProviderProps,\n} from 'react-intlayer/server';\nimport { IntlayerClientProvider } from '../client/IntlayerClientProvider';\nimport { registerRequestLocaleResolver } from './ambientLocale';\n\n// The provider sits in the root layout, so every route under it can await the\n// request locale from `getIntlayerAsync` / `getDictionaryAsync`.\nregisterRequestLocaleResolver();\n\nexport type IntlayerProviderProps = IntlayerClientProviderProps &\n  IntlayerServerProviderProps;\n\n/**\n * Unified Intlayer provider for the Next.js App Router.\n *\n * Server component that seeds the request-scoped server context (locale and\n * ambient variant) read by the server hooks, and mounts the client provider so\n * client components receive the same values — one provider for both halves.\n *\n * Mount it once, in the locale layout:\n *\n * ```tsx\n * import { IntlayerProvider } from 'next-intlayer/server';\n *\n * const LocaleLayout: NextLayoutIntlayer = async ({ children, params }) => {\n *   const { locale } = await params;\n *\n *   return (\n *     <IntlayerProvider locale={locale}>\n *       <html lang={locale}>\n *         <body>{children}</body>\n *       </html>\n *     </IntlayerProvider>\n *   );\n * };\n * ```\n *\n * The server context is request-scoped, not tree-scoped: on client-side\n * navigations that only re-render the page segment, the layout — and with it\n * this provider — does not re-run. The server hooks then fall back to the\n * locale carried by the request (the `x-intlayer-locale` header set by the\n * intlayer proxy, then the locale cookie), so content stays correct without a\n * per-page provider. The ambient `variant` has no request-carried fallback:\n * seed it per request with `setVariant` when server components read it outside\n * a full render of this provider.\n */\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n  children,\n  locale,\n  variant,\n  ...clientProps\n}) => (\n  <IntlayerServerProvider locale={locale} variant={variant}>\n    <IntlayerClientProvider locale={locale} variant={variant} {...clientProps}>\n      {children}\n    </IntlayerClientProvider>\n  </IntlayerServerProvider>\n);\n"],"mappings":";;;;;;;AAWAA,2DAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuC9B,MAAa,oBAA+C,EAC1D,UACA,QACA,SACA,GAAG,kBAEH,2CAACC,8CAAD;CAAgC;CAAiB;WAC/C,2CAACC,8DAAD;EAAgC;EAAiB;EAAS,GAAI;EAC3D;CACqB;AACF"}