{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "lib-content-provider",
  "title": "Content provider",
  "description": "The one provider of an app's wording: block, shell, page, document, review and Casework wording, each area overridden as a whole set of words, with the defaults for any area left out.",
  "dependencies": [
    "@base-ui/react@1.8.0",
    "@registrystack/app-runtime@~0.43.0-next.0"
  ],
  "registryDependencies": [
    "@registrystack/lib-content",
    "@registrystack/shell-content",
    "@registrystack/pages-content",
    "@registrystack/documents-content",
    "@registrystack/casework-content",
    "@registrystack/pages-casework-review-content",
    "@registrystack/dashboard-content"
  ],
  "files": [
    {
      "path": "lib/content-provider.tsx",
      "content": "import { useContext, useEffect, useMemo, type ReactNode } from \"react\";\nimport { DirectionProvider } from \"@base-ui/react/direction-provider\";\nimport {\n  applyLanguage,\n  formatLocale,\n  textDirection,\n} from \"@registrystack/app-runtime\";\nimport { useModel } from \"@registrystack/app-runtime/react\";\nimport {\n  CaseworkContentProvider,\n  type CaseworkContent,\n} from \"@/blocks/casework/casework-content\";\nimport type { DashboardContent } from \"@/blocks/dashboard/dashboard-content\";\nimport type { DocumentsContent } from \"@/blocks/documents/documents-content\";\nimport {\n  ContentContext,\n  LocaleContext,\n  MessagesContext,\n  type BlockContent,\n} from \"@/blocks/lib/content\";\nimport type { ReviewPageContent } from \"@/blocks/pages/casework-review-content\";\nimport type { PagesContent } from \"@/blocks/pages/pages-content\";\nimport type { ShellContent } from \"@/blocks/shell/shell-content\";\n\n/** The wording of every area of the blocks, each a full set of words. */\nexport interface AppContent {\n  block: BlockContent;\n  shell: ShellContent;\n  pages: PagesContent;\n  documents: DocumentsContent;\n  casework: CaseworkContent;\n  review: ReviewPageContent;\n  dashboard: DashboardContent;\n}\n\nconst noContent: Partial<AppContent> = {};\nconst noAreas: Readonly<Record<string, unknown>> = {};\n\n/**\n * The one provider of an app's wording. An area left out keeps its defaults,\n * or whatever an outer provider set for it; an area set here is a full set of\n * words, usually the area's default spread with a few words changed. `areas`\n * holds the app's own areas, for the pages it ejected or built, which read\n * them with `useContentArea`; a kit area set in `content` wins over one of the\n * same name there.\n */\nexport function ContentProvider({\n  content = noContent,\n  areas = noAreas,\n  children,\n}: {\n  content?: Partial<AppContent>;\n  areas?: Readonly<Record<string, unknown>>;\n  children: ReactNode;\n}) {\n  const outer = useContext(ContentContext);\n  const value = useMemo(\n    () => ({ ...outer, ...areas, ...content }),\n    [outer, areas, content],\n  );\n  const tree = (\n    <ContentContext.Provider value={value}>{children}</ContentContext.Provider>\n  );\n  return content.casework ? (\n    <CaseworkContentProvider content={content.casework}>\n      {tree}\n    </CaseworkContentProvider>\n  ) : (\n    tree\n  );\n}\n\nconst noMessages: Readonly<Record<string, string>> = {};\n\n/**\n * Sets the session's UI model texts for the kit's wording over the app's own,\n * the locale blocks format in, and the page's language and direction to those\n * the texts are in, for Base UI's parts as for the page. It reads the model, so\n * it sits inside the authenticated session; until the model arrives the app's\n * wording, the kit's English formats and the page's own language show, left to\n * right. The providers are always rendered, so the arrival of the texts does not\n * remount the app below them.\n */\nexport function ModelMessages({ children }: { children: ReactNode }) {\n  const model = useModel().data;\n  const messages = model?.messages ?? noMessages;\n  const language = model?.language;\n  useEffect(\n    () => applyLanguage(document.documentElement, language),\n    [language],\n  );\n  return (\n    <MessagesContext.Provider value={messages}>\n      <LocaleContext.Provider value={formatLocale(language)}>\n        <DirectionProvider\n          direction={language ? textDirection(language) : \"ltr\"}\n        >\n          {children}\n        </DirectionProvider>\n      </LocaleContext.Provider>\n    </MessagesContext.Provider>\n  );\n}\n",
      "type": "registry:lib",
      "target": "@lib/content-provider.tsx"
    }
  ],
  "type": "registry:lib"
}