@burdenoff/fe-libs 2026.1007.4 → 2026.1007.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chrome/AutoBreadcrumbs.d.ts.map +1 -1
- package/dist/chrome/AutoBreadcrumbs.js +65 -76
- package/dist/chrome/Breadcrumb.d.ts.map +1 -1
- package/dist/chrome/Breadcrumbs.d.ts.map +1 -1
- package/dist/chrome/Breadcrumbs.js +47 -46
- package/dist/chrome/ContextSwitcher.js +86 -86
- package/dist/chrome/HeaderBar.d.ts.map +1 -1
- package/dist/chrome/HeaderBar.js +111 -107
- package/dist/chrome/HeaderThemeSwitcher.d.ts.map +1 -1
- package/dist/chrome/HeaderThemeSwitcher.js +46 -45
- package/dist/chrome/LanguageSwitcher.js +4 -4
- package/dist/chrome/MobileTabBar.js +4 -4
- package/dist/chrome/PageHeader.d.ts.map +1 -1
- package/dist/chrome/PageHeader.js +32 -30
- package/dist/chrome/PersonaSurfaceControls.js +8 -8
- package/dist/chrome/ProductSideNav.js +6 -6
- package/dist/chrome/ProfileSwitcher.d.ts.map +1 -1
- package/dist/chrome/ProfileSwitcher.js +89 -88
- package/dist/chrome/SideNavigation.js +4 -4
- package/dist/chrome/Tabs.d.ts.map +1 -1
- package/dist/chrome/Tabs.js +30 -29
- package/dist/chrome/breadcrumbLabel.d.ts +10 -0
- package/dist/chrome/breadcrumbLabel.d.ts.map +1 -0
- package/dist/chrome/breadcrumbLabel.js +31 -0
- package/dist/chrome/contextSwitcher/TriggerButton.d.ts.map +1 -1
- package/dist/chrome/contextSwitcher/TriggerButton.js +40 -36
- package/dist/chrome/notificationCenter/BellButton.d.ts.map +1 -1
- package/dist/chrome/notificationCenter/BellButton.js +29 -25
- package/dist/chrome/shellLabelManifest.d.ts +27 -0
- package/dist/chrome/shellLabelManifest.d.ts.map +1 -0
- package/dist/chrome/sideNavigation/SidebarHeader.d.ts.map +1 -1
- package/dist/chrome/sideNavigation/SidebarHeader.js +23 -22
- package/dist/shared/assistant/api.d.ts +11 -0
- package/dist/shared/assistant/api.d.ts.map +1 -1
- package/dist/shared/assistant/api.js +6 -2
- package/dist/shared/assistant/appControls/languageReply.d.ts +6 -1
- package/dist/shared/assistant/appControls/languageReply.d.ts.map +1 -1
- package/dist/shared/assistant/conversation.d.ts +14 -0
- package/dist/shared/assistant/conversation.d.ts.map +1 -1
- package/dist/shared/assistant/createSandboxAssistantTransport.d.ts +8 -1
- package/dist/shared/assistant/createSandboxAssistantTransport.d.ts.map +1 -1
- package/dist/shared/assistant/createSandboxAssistantTransport.js +70 -51
- package/dist/shared/assistant/history/historyMapping.d.ts.map +1 -1
- package/dist/shared/assistant/history/historyMapping.js +19 -12
- package/dist/shared/assistant/i18nManifest.d.ts +26 -5
- package/dist/shared/assistant/i18nManifest.d.ts.map +1 -1
- package/dist/shared/assistant/i18nManifest.js +36 -22
- package/dist/shared/assistant/index.d.ts +7 -0
- package/dist/shared/assistant/index.d.ts.map +1 -1
- package/dist/shared/assistant/localUiCommandCopy.d.ts +23 -0
- package/dist/shared/assistant/localUiCommandCopy.d.ts.map +1 -1
- package/dist/shared/assistant/localUiCommandCopy.js +60 -23
- package/dist/shared/assistant/localUiCommands.d.ts +29 -0
- package/dist/shared/assistant/localUiCommands.d.ts.map +1 -1
- package/dist/shared/assistant/localUiCommands.js +18 -7
- package/dist/shared/assistant/productCopy.d.ts +78 -0
- package/dist/shared/assistant/productCopy.d.ts.map +1 -0
- package/dist/shared/assistant/productCopy.js +45 -0
- package/dist/shared/assistant/types.d.ts +19 -8
- package/dist/shared/assistant/types.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantChatArea.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantChatArea.js +1479 -1140
- package/dist/shared/assistant/ui/AssistantEmptyState.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantEmptyState.js +30 -22
- package/dist/shared/assistant/ui/AssistantHeader.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantHeader.js +46 -45
- package/dist/shared/assistant/ui/AssistantMarkdownRenderer.d.ts +18 -3
- package/dist/shared/assistant/ui/AssistantMarkdownRenderer.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantMarkdownRenderer.js +1 -1
- package/dist/shared/assistant/ui/AssistantMessageItem.d.ts +5 -0
- package/dist/shared/assistant/ui/AssistantMessageItem.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantMessageItem.js +89 -84
- package/dist/shared/assistant/ui/AssistantMessageList.d.ts +5 -0
- package/dist/shared/assistant/ui/AssistantMessageList.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantMessageList.js +26 -25
- package/dist/shared/assistant/ui/AssistantUiOfferLink.d.ts +45 -0
- package/dist/shared/assistant/ui/AssistantUiOfferLink.d.ts.map +1 -0
- package/dist/shared/assistant/ui/AssistantUiOfferLink.js +56 -0
- package/dist/shared/assistant/ui/assistantOverlayState.d.ts +9 -0
- package/dist/shared/assistant/ui/assistantOverlayState.d.ts.map +1 -1
- package/dist/shared/assistant/ui/assistantOverlayState.js +37 -28
- package/dist/shared/assistant/ui/composer/AssistantConnectSourceItem.d.ts.map +1 -1
- package/dist/shared/assistant/ui/composer/AssistantConnectSourceItem.js +1 -1
- package/dist/shared/assistant/ui/voice/AssistantVoiceSession.d.ts +5 -0
- package/dist/shared/assistant/ui/voice/AssistantVoiceSession.d.ts.map +1 -1
- package/dist/shared/assistant/ui/voice/AssistantVoiceSession.js +12 -11
- package/dist/shared/assistant/ui/voice/VoiceConversationView.d.ts +6 -1
- package/dist/shared/assistant/ui/voice/VoiceConversationView.d.ts.map +1 -1
- package/dist/shared/assistant/ui/voice/VoiceConversationView.js +7 -7
- package/dist/shared/assistant/ui/voice/VoiceTranscriptDrawer.d.ts +6 -1
- package/dist/shared/assistant/ui/voice/VoiceTranscriptDrawer.d.ts.map +1 -1
- package/dist/shared/assistant/ui/voice/VoiceTranscriptDrawer.js +15 -12
- package/dist/shared/assistant/uiActions/actOnResolve.d.ts +108 -0
- package/dist/shared/assistant/uiActions/actOnResolve.d.ts.map +1 -0
- package/dist/shared/assistant/uiActions/actOnResolve.js +51 -0
- package/dist/shared/assistant/uiActions/linkContext.d.ts +29 -0
- package/dist/shared/assistant/uiActions/linkContext.d.ts.map +1 -1
- package/dist/shared/assistant/uiActions/linkContext.js +37 -10
- package/dist/shared/assistant/uiActions/navIntent.d.ts +58 -0
- package/dist/shared/assistant/uiActions/navIntent.d.ts.map +1 -0
- package/dist/shared/assistant/uiActions/navIntent.js +79 -0
- package/dist/shared/assistant/uiActions/navigateAction.d.ts +6 -1
- package/dist/shared/assistant/uiActions/navigateAction.d.ts.map +1 -1
- package/dist/shared/assistant/uiActions/navigateAction.js +18 -14
- package/dist/shared/assistant/uiActions/navigationOutcome.d.ts +16 -2
- package/dist/shared/assistant/uiActions/navigationOutcome.d.ts.map +1 -1
- package/dist/shared/assistant/uiActions/navigationOutcome.js +6 -2
- package/dist/shared/assistant/uiActions/offerYesOnSurface.d.ts +39 -0
- package/dist/shared/assistant/uiActions/offerYesOnSurface.d.ts.map +1 -0
- package/dist/shared/assistant/uiActions/offerYesOnSurface.js +34 -0
- package/dist/shared/assistant/uiActions/uiCatalogue.d.ts +14 -0
- package/dist/shared/assistant/uiActions/uiCatalogue.d.ts.map +1 -1
- package/dist/shared/assistant/uiActions/uiCatalogue.js +23 -3
- package/dist/shared/assistant/uiActions/uiOffers.d.ts +249 -0
- package/dist/shared/assistant/uiActions/uiOffers.d.ts.map +1 -0
- package/dist/shared/assistant/uiActions/uiOffers.js +195 -0
- package/dist/shared/assistant/writeProposals.d.ts +6 -0
- package/dist/shared/assistant/writeProposals.d.ts.map +1 -1
- package/dist/shared/assistant/writeReplyBinder.d.ts +40 -0
- package/dist/shared/assistant/writeReplyBinder.d.ts.map +1 -1
- package/dist/shared/assistant/writeReplyBinder.js +100 -83
- package/dist/shared/assistant/writeReplySend.d.ts +14 -0
- package/dist/shared/assistant/writeReplySend.d.ts.map +1 -1
- package/dist/shared/assistant/writeReplySend.js +32 -29
- package/dist/shared/components/ContextConversationWidget.js +1 -1
- package/dist/shared/events/sinks/RybbitSink.d.ts.map +1 -1
- package/dist/shared/events/sinks/RybbitSink.js +66 -69
- package/dist/shared/hooks/index.d.ts +2 -0
- package/dist/shared/hooks/index.d.ts.map +1 -1
- package/dist/shared/navigation/unsavedChanges.d.ts +83 -0
- package/dist/shared/navigation/unsavedChanges.d.ts.map +1 -0
- package/dist/shared/navigation/unsavedChanges.js +46 -0
- package/dist/shared/providers/AppShellProvider.d.ts +17 -0
- package/dist/shared/providers/AppShellProvider.d.ts.map +1 -1
- package/dist/shared/providers/AppShellProvider.js +188 -180
- package/dist/shared/providers/shell/I18nProvider.d.ts +92 -4
- package/dist/shared/providers/shell/I18nProvider.d.ts.map +1 -1
- package/dist/shared/providers/shell/I18nProvider.js +187 -79
- package/dist/shared/providers/shell/ProfileI18nBridge.d.ts +18 -2
- package/dist/shared/providers/shell/ProfileI18nBridge.d.ts.map +1 -1
- package/dist/shared/providers/shell/ProfileI18nBridge.js +55 -41
- package/dist/shared/providers/shell/directionMode.d.ts +25 -0
- package/dist/shared/providers/shell/directionMode.d.ts.map +1 -0
- package/dist/shared/providers/shell/directionMode.js +34 -0
- package/dist/shared/providers/shell/index.d.ts +4 -2
- package/dist/shared/providers/shell/index.d.ts.map +1 -1
- package/dist/shared/providers/shell/translationLayers.d.ts +30 -0
- package/dist/shared/providers/shell/translationLayers.d.ts.map +1 -0
- package/dist/shared/providers/shell/translationLayers.js +35 -0
- package/dist/shared/providers/shell/translationStore.d.ts +55 -0
- package/dist/shared/providers/shell/translationStore.d.ts.map +1 -0
- package/dist/shared/providers/shell/translationStore.js +100 -0
- package/dist/shared/providers/shell/useShellLabel.d.ts +13 -1
- package/dist/shared/providers/shell/useShellLabel.d.ts.map +1 -1
- package/dist/shared/providers/shell/useShellLabel.js +10 -9
- package/dist/shared-assistant.js +244 -237
- package/dist/shared-hooks.js +10 -9
- package/dist/shared-providers-shell.js +20 -19
- package/dist/shared.js +20 -19
- package/dist/ui/boff-ui2.d.ts.map +1 -1
- package/dist/ui/cta-overflow-menu.d.ts.map +1 -1
- package/dist/ui/cta-overflow-menu.js +20 -18
- package/dist/ui/guidance.d.ts +1 -1
- package/dist/ui/guidance.d.ts.map +1 -1
- package/dist/ui/guidance.js +53 -52
- package/package.json +3 -2
|
@@ -1,23 +1,76 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { TranslationPersistence } from './translationStore';
|
|
2
3
|
export type Locale = 'en' | 'es' | 'fr' | 'de' | 'ja' | 'zh' | 'ta' | 'hi' | 'ar';
|
|
4
|
+
export type TextDirection = 'ltr' | 'rtl';
|
|
5
|
+
/**
|
|
6
|
+
* How the provider decides the document's text direction (BOFF-8060, F6).
|
|
7
|
+
*
|
|
8
|
+
* - `off` (the default): the provider never touches `dir`; every locale renders
|
|
9
|
+
* LTR, exactly as before. Existing component CSS across fe-libs and the
|
|
10
|
+
* microfrontends still uses physical Tailwind utilities (`ml-`, `left-`,
|
|
11
|
+
* `text-left`, `translate-x`), which mirror wrongly under `dir="rtl"`:
|
|
12
|
+
* sidebars and icon gaps on the wrong side, drawers sliding from the wrong
|
|
13
|
+
* edge, chevrons pointing backwards. Arabic stays LTR until that sweep lands.
|
|
14
|
+
* - `locale`: `dir` follows `LOCALE_DIRECTION` (Arabic RTL). For products whose
|
|
15
|
+
* UI has been swept to logical utilities.
|
|
16
|
+
* - `rtl`: force RTL whatever the locale. A QA preview (`?dir=rtl`) for
|
|
17
|
+
* checking a sweep in production before any user sees RTL.
|
|
18
|
+
*/
|
|
19
|
+
export type DirectionMode = 'off' | 'locale' | 'rtl';
|
|
20
|
+
/** Script direction of each supported locale. */
|
|
21
|
+
export declare const LOCALE_DIRECTION: Readonly<Record<Locale, TextDirection>>;
|
|
22
|
+
/** Direction of a locale code (`ar`, `ar-EG`); unknown codes are LTR. */
|
|
23
|
+
export declare function localeDirection(code: string): TextDirection;
|
|
24
|
+
/** The direction the document renders in under a mode. */
|
|
25
|
+
export declare function directionFor(mode: DirectionMode, locale: string): TextDirection;
|
|
3
26
|
export interface TranslationDictionary {
|
|
4
27
|
[key: string]: string | TranslationDictionary;
|
|
5
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Where one locale's dictionary stands (BOFF-8823).
|
|
31
|
+
*
|
|
32
|
+
* - `loading`: a fetch for it is in flight. A persisted copy (F3) may already be
|
|
33
|
+
* on screen meanwhile, but it can predate a newly seeded key, so a consumer
|
|
34
|
+
* waiting for a word in this locale keeps waiting until the download settles.
|
|
35
|
+
* - `ready`: the download settled with a dictionary applied (the fresh one, or
|
|
36
|
+
* the cached copy when the revalidation came back partial or failed), or this
|
|
37
|
+
* session already holds a complete one.
|
|
38
|
+
* - `failed`: the fetch settled with nothing; the static fallback is in force.
|
|
39
|
+
*/
|
|
40
|
+
export type LocaleLoadStatus = 'loading' | 'ready' | 'failed';
|
|
6
41
|
export interface I18nContextValue {
|
|
7
42
|
locale: Locale;
|
|
8
43
|
translations: TranslationDictionary;
|
|
9
44
|
setLocale: (locale: Locale) => void;
|
|
10
45
|
t: (key: string, fallbackOrParams?: string | Record<string, string | number>, params?: Record<string, string | number>) => string;
|
|
11
|
-
/** Whether translations are
|
|
46
|
+
/** Whether ANY locale's translations are being fetched. */
|
|
12
47
|
isLoading: boolean;
|
|
13
48
|
/** Error message if translation fetch failed */
|
|
14
49
|
error: string | null;
|
|
50
|
+
/**
|
|
51
|
+
* Per-locale readiness. Wait on the locale you need, not on `isLoading`: a
|
|
52
|
+
* fetch for another locale settling says nothing about yours.
|
|
53
|
+
*/
|
|
54
|
+
localeStatus: Readonly<Partial<Record<Locale, LocaleLoadStatus>>>;
|
|
55
|
+
/** Whether the dictionary for `code` (`hi`, `hi-IN`) is still being fetched. */
|
|
56
|
+
isLocaleLoading: (code: string) => boolean;
|
|
57
|
+
/** The document's text direction under the provider's direction mode. */
|
|
58
|
+
dir: TextDirection;
|
|
15
59
|
}
|
|
16
60
|
/**
|
|
17
61
|
* Function to fetch translations for a specific locale.
|
|
18
62
|
* Used when dynamic API-based translations are enabled.
|
|
19
63
|
*/
|
|
20
64
|
export type FetchTranslationsFn = (locale: Locale) => Promise<TranslationDictionary>;
|
|
65
|
+
/**
|
|
66
|
+
* A fetch that can say whether what it returns is the whole dictionary.
|
|
67
|
+
* An incomplete result is shown but never cached as the session's answer.
|
|
68
|
+
*/
|
|
69
|
+
export interface TranslationLoadResult {
|
|
70
|
+
translations: TranslationDictionary;
|
|
71
|
+
complete: boolean;
|
|
72
|
+
}
|
|
73
|
+
export type LoadTranslationsFn = (locale: Locale) => Promise<TranslationLoadResult>;
|
|
21
74
|
export interface I18nProviderProps {
|
|
22
75
|
children: ReactNode;
|
|
23
76
|
defaultLocale?: Locale;
|
|
@@ -36,8 +89,33 @@ export interface I18nProviderProps {
|
|
|
36
89
|
* Optional function to fetch translations dynamically from an API.
|
|
37
90
|
* When provided, translations will be fetched on mount and locale change.
|
|
38
91
|
* Static translations prop is used as fallback during loading or on error.
|
|
92
|
+
* A non-empty result counts as complete.
|
|
39
93
|
*/
|
|
40
94
|
fetchTranslations?: FetchTranslationsFn;
|
|
95
|
+
/**
|
|
96
|
+
* Like `fetchTranslations`, but reports whether the result is complete.
|
|
97
|
+
* Takes precedence when both are given.
|
|
98
|
+
*/
|
|
99
|
+
loadTranslations?: LoadTranslationsFn;
|
|
100
|
+
/**
|
|
101
|
+
* Names the dictionary being fetched (e.g. `healthybowl+workspaces`). The
|
|
102
|
+
* in-memory and persistent caches are keyed by scope AND locale, so two
|
|
103
|
+
* providers fetching different dictionaries never serve each other's.
|
|
104
|
+
*/
|
|
105
|
+
cacheScope?: string;
|
|
106
|
+
/**
|
|
107
|
+
* A persistent cache: the last complete dictionary is applied at once on the
|
|
108
|
+
* next load and revalidated in the background. Default: none.
|
|
109
|
+
*/
|
|
110
|
+
persistence?: TranslationPersistence | null;
|
|
111
|
+
/**
|
|
112
|
+
* For a non-English locale with `persistence`, hold the FIRST paint up to
|
|
113
|
+
* this long for the cached dictionary, so the page does not flash English
|
|
114
|
+
* before it. 0 (the default) never holds.
|
|
115
|
+
*/
|
|
116
|
+
firstPaintHoldMs?: number;
|
|
117
|
+
/** Text direction handling. Default `off`: the document stays LTR. */
|
|
118
|
+
directionMode?: DirectionMode;
|
|
41
119
|
/**
|
|
42
120
|
* Whether to show children during initial translation fetch.
|
|
43
121
|
* Default: true (show children with fallback translations while loading)
|
|
@@ -59,8 +137,18 @@ export interface I18nProviderProps {
|
|
|
59
137
|
* drop static keys for the same locale.
|
|
60
138
|
*/
|
|
61
139
|
export declare function mergeTranslationDictionaries(base: TranslationDictionary | undefined, override: TranslationDictionary | undefined): TranslationDictionary;
|
|
62
|
-
|
|
140
|
+
/** Whether `code`'s locale is `loading` in a status map (primary-tag match). */
|
|
141
|
+
export declare function isLocaleLoadingIn(status: Readonly<Partial<Record<Locale, LocaleLoadStatus>>>, code: string): boolean;
|
|
142
|
+
export declare function I18nProvider({ children, defaultLocale, translations: staticTranslations, storageKey, profileId, fetchTranslations, loadTranslations, cacheScope, persistence, firstPaintHoldMs, directionMode, showChildrenWhileLoading, loadingComponent, }: I18nProviderProps): import('react/jsx-runtime').JSX.Element;
|
|
63
143
|
export declare function useI18n(): I18nContextValue;
|
|
144
|
+
/**
|
|
145
|
+
* The i18n context, or null outside an `I18nProvider`.
|
|
146
|
+
*
|
|
147
|
+
* For presentation components that must also render standalone (a host or a
|
|
148
|
+
* test without the shell): they fall back to their English copy instead of
|
|
149
|
+
* throwing.
|
|
150
|
+
*/
|
|
151
|
+
export declare function useOptionalI18n(): I18nContextValue | null;
|
|
64
152
|
/**
|
|
65
153
|
* Clear the global translation cache.
|
|
66
154
|
* Call this to force a refetch of translations on the next component mount.
|
|
@@ -68,8 +156,8 @@ export declare function useI18n(): I18nContextValue;
|
|
|
68
156
|
*/
|
|
69
157
|
export declare function clearTranslationCache(): void;
|
|
70
158
|
/**
|
|
71
|
-
* Check
|
|
159
|
+
* Check whether a complete dictionary is cached for a locale (in a scope).
|
|
72
160
|
* Useful for debugging.
|
|
73
161
|
*/
|
|
74
|
-
export declare function isTranslationAttempted(locale: Locale): boolean;
|
|
162
|
+
export declare function isTranslationAttempted(locale: Locale, scope?: string): boolean;
|
|
75
163
|
//# sourceMappingURL=I18nProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18nProvider.d.ts","sourceRoot":"","sources":["../../../../src/shared/providers/shell/I18nProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"I18nProvider.d.ts","sourceRoot":"","sources":["../../../../src/shared/providers/shell/I18nProvider.tsx"],"names":[],"mappings":"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"}
|
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
import { interpolate as e } from "./interpolate.js";
|
|
2
2
|
import { resolveTranslationValue as t } from "./resolveTranslation.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { hashTranslations as n } from "./translationStore.js";
|
|
4
|
+
import { createContext as r, use as i, useCallback as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
|
|
5
|
+
import { Fragment as u, jsx as d } from "react/jsx-runtime";
|
|
5
6
|
//#region src/shared/providers/shell/I18nProvider.tsx
|
|
6
|
-
var
|
|
7
|
+
var f = Object.freeze({
|
|
8
|
+
en: "ltr",
|
|
9
|
+
es: "ltr",
|
|
10
|
+
fr: "ltr",
|
|
11
|
+
de: "ltr",
|
|
12
|
+
ja: "ltr",
|
|
13
|
+
zh: "ltr",
|
|
14
|
+
ta: "ltr",
|
|
15
|
+
hi: "ltr",
|
|
16
|
+
ar: "rtl"
|
|
17
|
+
}), p = (e) => e.trim().toLowerCase().split(/[-_]/)[0] ?? "";
|
|
18
|
+
function m(e) {
|
|
19
|
+
let t = p(e);
|
|
20
|
+
return t in f ? f[t] : "ltr";
|
|
21
|
+
}
|
|
22
|
+
function h(e, t) {
|
|
23
|
+
return e === "rtl" ? "rtl" : e === "locale" ? m(t) : "ltr";
|
|
24
|
+
}
|
|
25
|
+
var g = r(null), ee = {
|
|
7
26
|
en: {},
|
|
8
27
|
es: {},
|
|
9
28
|
fr: {},
|
|
@@ -13,15 +32,21 @@ var d = n(null), f = {
|
|
|
13
32
|
ta: {},
|
|
14
33
|
hi: {},
|
|
15
34
|
ar: {}
|
|
16
|
-
},
|
|
35
|
+
}, _ = {
|
|
17
36
|
attempted: /* @__PURE__ */ new Set(),
|
|
18
|
-
translations:
|
|
37
|
+
translations: /* @__PURE__ */ new Map(),
|
|
19
38
|
version: 0,
|
|
20
39
|
clear() {
|
|
21
|
-
this.attempted.clear(), this.translations
|
|
40
|
+
this.attempted.clear(), this.translations.clear(), this.version++;
|
|
22
41
|
}
|
|
23
42
|
};
|
|
24
|
-
function
|
|
43
|
+
function v(e, t) {
|
|
44
|
+
return e ? `${e}::${t}` : t;
|
|
45
|
+
}
|
|
46
|
+
function y(e) {
|
|
47
|
+
return !!e && Object.keys(e).length > 0;
|
|
48
|
+
}
|
|
49
|
+
function b(e, t, n) {
|
|
25
50
|
if (typeof window > "u") return n;
|
|
26
51
|
if (e) {
|
|
27
52
|
let t = localStorage.getItem(`bf-p-${e}-locale`);
|
|
@@ -29,10 +54,10 @@ function m(e, t, n) {
|
|
|
29
54
|
}
|
|
30
55
|
return localStorage.getItem(t) || n;
|
|
31
56
|
}
|
|
32
|
-
function
|
|
57
|
+
function x(e) {
|
|
33
58
|
return typeof e == "object" && !!e;
|
|
34
59
|
}
|
|
35
|
-
function
|
|
60
|
+
function S(e, t) {
|
|
36
61
|
if (!e && !t) return {};
|
|
37
62
|
if (!e) return { ...t ?? {} };
|
|
38
63
|
if (!t) return { ...e };
|
|
@@ -43,103 +68,186 @@ function g(e, t) {
|
|
|
43
68
|
n[e] = r;
|
|
44
69
|
continue;
|
|
45
70
|
}
|
|
46
|
-
n[e] =
|
|
71
|
+
n[e] = S(x(t) ? t : void 0, r);
|
|
47
72
|
}
|
|
48
73
|
return n;
|
|
49
74
|
}
|
|
50
|
-
function
|
|
51
|
-
let
|
|
52
|
-
|
|
53
|
-
|
|
75
|
+
function C(e, t) {
|
|
76
|
+
let n = p(t);
|
|
77
|
+
return Object.entries(e).some(([e, t]) => t === "loading" && p(e) === n);
|
|
78
|
+
}
|
|
79
|
+
function w({ children: r, defaultLocale: i = "en", translations: f = ee, storageKey: m = "burdenoff-locale", profileId: x, fetchTranslations: w, loadTranslations: T, cacheScope: E = "", persistence: D = null, firstPaintHoldMs: O = 0, directionMode: k = "off", showChildrenWhileLoading: A = !0, loadingComponent: j }) {
|
|
80
|
+
let [M, N] = l(() => b(x, m, i)), P = s(() => {
|
|
81
|
+
if (T) return T;
|
|
82
|
+
if (w) return async (e) => {
|
|
83
|
+
let t = await w(e);
|
|
84
|
+
return {
|
|
85
|
+
translations: t ?? {},
|
|
86
|
+
complete: y(t)
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
}, [T, w]), [F, I] = l(() => {
|
|
90
|
+
let e = _.translations.get(v(E, M));
|
|
91
|
+
return e ? { [M]: e.translations } : {};
|
|
92
|
+
}), [L, te] = l(() => {
|
|
93
|
+
if (!P) return {};
|
|
94
|
+
let e = _.translations.has(v(E, M));
|
|
95
|
+
return { [M]: e ? "ready" : "loading" };
|
|
96
|
+
}), [R, z] = l(null), [B, V] = l(() => typeof window < "u" && !!P && !!D && O > 0 && p(M) !== "en" && !_.translations.has(v(E, M)));
|
|
97
|
+
o(() => {
|
|
98
|
+
if (!B) return;
|
|
99
|
+
let e = setTimeout(() => V(!1), O);
|
|
100
|
+
return () => clearTimeout(e);
|
|
101
|
+
}, [B, O]);
|
|
102
|
+
let H = c(/* @__PURE__ */ new Map()), U = c(/* @__PURE__ */ new Set()), W = c(_.version), G = a((e, t) => {
|
|
103
|
+
te((n) => n[e] === t ? n : {
|
|
104
|
+
...n,
|
|
105
|
+
[e]: t
|
|
106
|
+
});
|
|
107
|
+
}, []), K = a((e, t, n) => {
|
|
108
|
+
H.current.set(e, n), I((n) => n[e] === t ? n : {
|
|
109
|
+
...n,
|
|
110
|
+
[e]: t
|
|
111
|
+
});
|
|
112
|
+
}, []), q = s(() => {
|
|
113
|
+
let e = { ...f };
|
|
114
|
+
for (let [t, n] of Object.entries(F)) if (n && Object.keys(n).length > 0) {
|
|
54
115
|
let r = t;
|
|
55
|
-
e[r] =
|
|
116
|
+
e[r] = S(f[r], n);
|
|
56
117
|
}
|
|
57
118
|
return e;
|
|
58
|
-
}, [
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
119
|
+
}, [f, F]), J = a(async (e) => {
|
|
120
|
+
if (!P) return;
|
|
121
|
+
W.current !== _.version && (U.current.clear(), H.current.clear(), W.current = _.version);
|
|
122
|
+
let t = v(E, e), r = _.translations.get(t);
|
|
123
|
+
if (r) {
|
|
124
|
+
H.current.get(e) !== r.hash && K(e, r.translations, r.hash), G(e, "ready"), V(!1);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (U.current.has(t)) return;
|
|
128
|
+
U.current.add(t), G(e, "loading"), z(null);
|
|
129
|
+
let i = !1, a = !1, o = !1, s = D ? D.read(E, e).catch(() => null) : Promise.resolve(null);
|
|
130
|
+
s.then((t) => {
|
|
131
|
+
if (i || !t || !y(t.translations)) {
|
|
132
|
+
V(!1);
|
|
66
133
|
return;
|
|
67
134
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
135
|
+
o = !0, K(e, t.translations, t.hash), a && G(e, "ready"), V(!1);
|
|
136
|
+
});
|
|
137
|
+
try {
|
|
138
|
+
let r = await P(e);
|
|
139
|
+
if (a = !0, r.complete && y(r.translations)) {
|
|
140
|
+
let a = n(r.translations);
|
|
141
|
+
if (_.attempted.add(t), _.translations.set(t, {
|
|
142
|
+
translations: r.translations,
|
|
143
|
+
hash: a
|
|
144
|
+
}), i = !0, H.current.get(e) !== a && K(e, r.translations, a), G(e, "ready"), D) {
|
|
145
|
+
let t = await s;
|
|
146
|
+
(!t || t.hash !== a) && D.write(E, e, {
|
|
147
|
+
translations: r.translations,
|
|
148
|
+
hash: a
|
|
149
|
+
});
|
|
80
150
|
}
|
|
81
|
-
}
|
|
151
|
+
} else o ? G(e, "ready") : y(r.translations) ? (K(e, r.translations, n(r.translations)), G(e, "ready")) : G(e, "failed");
|
|
152
|
+
} catch (t) {
|
|
153
|
+
a = !0, console.error(`[I18nProvider] Failed to fetch translations for ${e}:`, t), z(t instanceof Error ? t.message : "Failed to fetch translations"), G(e, o ? "ready" : "failed");
|
|
154
|
+
} finally {
|
|
155
|
+
U.current.delete(t), V(!1);
|
|
82
156
|
}
|
|
83
|
-
}, [y]);
|
|
84
|
-
a(() => {
|
|
85
|
-
y && (p.attempted.has(S) && p.translations[S] && Object.keys(p.translations[S]).length > 0 || N(S));
|
|
86
157
|
}, [
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
158
|
+
K,
|
|
159
|
+
E,
|
|
160
|
+
P,
|
|
161
|
+
G,
|
|
162
|
+
D
|
|
163
|
+
]);
|
|
164
|
+
o(() => {
|
|
165
|
+
P && J(M);
|
|
166
|
+
}, [
|
|
167
|
+
P,
|
|
168
|
+
M,
|
|
169
|
+
J
|
|
170
|
+
]), o(() => {
|
|
171
|
+
let e = b(x, m, i);
|
|
172
|
+
N(e), document.documentElement.setAttribute("lang", e);
|
|
93
173
|
}, [
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
174
|
+
x,
|
|
175
|
+
m,
|
|
176
|
+
i
|
|
97
177
|
]);
|
|
98
|
-
let
|
|
99
|
-
|
|
100
|
-
|
|
178
|
+
let Y = a((e) => {
|
|
179
|
+
if (N(e), P) {
|
|
180
|
+
let t = _.translations.get(v(E, e));
|
|
181
|
+
t ? (H.current.get(e) !== t.hash && K(e, t.translations, t.hash), G(e, "ready")) : G(e, "loading");
|
|
182
|
+
}
|
|
183
|
+
localStorage.setItem(m, e), x && localStorage.setItem(`bf-p-${x}-locale`, e), document.documentElement.setAttribute("lang", e);
|
|
184
|
+
}, [
|
|
185
|
+
K,
|
|
186
|
+
E,
|
|
187
|
+
P,
|
|
188
|
+
G,
|
|
189
|
+
m,
|
|
190
|
+
x
|
|
191
|
+
]), X = h(k, M);
|
|
192
|
+
o(() => {
|
|
193
|
+
if (k === "off" || typeof document > "u") return;
|
|
194
|
+
let e = document.documentElement, t = e.getAttribute("dir");
|
|
195
|
+
return e.setAttribute("dir", X), () => {
|
|
196
|
+
t === null ? e.removeAttribute("dir") : e.setAttribute("dir", t);
|
|
197
|
+
};
|
|
198
|
+
}, [k, X]);
|
|
199
|
+
let Z = a((n, r, a) => {
|
|
101
200
|
let o, s;
|
|
102
|
-
if (typeof
|
|
103
|
-
else if (
|
|
104
|
-
let { defaultValue: e, ...t } =
|
|
201
|
+
if (typeof r == "string") o = r, s = a;
|
|
202
|
+
else if (r && typeof r == "object") {
|
|
203
|
+
let { defaultValue: e, ...t } = r;
|
|
105
204
|
typeof e == "string" ? o = e : typeof e == "number" && (o = String(e)), s = t;
|
|
106
205
|
}
|
|
107
|
-
let c = t(M
|
|
206
|
+
let c = t(q[M], n) ?? (M === i ? void 0 : t(q[i], n)) ?? (i === "en" ? void 0 : t(q.en, n)) ?? o ?? n;
|
|
108
207
|
return s ? e(c, s) : c;
|
|
109
208
|
}, [
|
|
110
|
-
S,
|
|
111
209
|
M,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
210
|
+
q,
|
|
211
|
+
i
|
|
212
|
+
]), Q = Object.values(L).includes("loading"), $ = a((e) => C(L, e), [L]), ne = s(() => ({
|
|
213
|
+
locale: M,
|
|
214
|
+
translations: q[M] || {},
|
|
215
|
+
setLocale: Y,
|
|
216
|
+
t: Z,
|
|
217
|
+
isLoading: Q,
|
|
218
|
+
error: R,
|
|
219
|
+
localeStatus: L,
|
|
220
|
+
isLocaleLoading: $,
|
|
221
|
+
dir: X
|
|
120
222
|
}), [
|
|
121
|
-
S,
|
|
122
223
|
M,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
224
|
+
q,
|
|
225
|
+
Y,
|
|
226
|
+
Z,
|
|
227
|
+
Q,
|
|
228
|
+
R,
|
|
229
|
+
L,
|
|
230
|
+
$,
|
|
231
|
+
X
|
|
127
232
|
]);
|
|
128
|
-
return
|
|
129
|
-
value:
|
|
130
|
-
children:
|
|
233
|
+
return B ? /* @__PURE__ */ d(u, { children: j ?? null }) : Q && !A && j && !y(F[M]) ? /* @__PURE__ */ d(u, { children: j }) : /* @__PURE__ */ d(g.Provider, {
|
|
234
|
+
value: ne,
|
|
235
|
+
children: r
|
|
131
236
|
});
|
|
132
237
|
}
|
|
133
|
-
function
|
|
134
|
-
let e =
|
|
238
|
+
function T() {
|
|
239
|
+
let e = i(g);
|
|
135
240
|
if (!e) throw Error("useI18n must be used within an I18nProvider");
|
|
136
241
|
return e;
|
|
137
242
|
}
|
|
138
|
-
function
|
|
139
|
-
|
|
243
|
+
function E() {
|
|
244
|
+
return i(g);
|
|
245
|
+
}
|
|
246
|
+
function D() {
|
|
247
|
+
_.clear();
|
|
140
248
|
}
|
|
141
|
-
function
|
|
142
|
-
return
|
|
249
|
+
function O(e, t = "") {
|
|
250
|
+
return _.attempted.has(v(t, e));
|
|
143
251
|
}
|
|
144
252
|
//#endregion
|
|
145
|
-
export {
|
|
253
|
+
export { w as I18nProvider, f as LOCALE_DIRECTION, D as clearTranslationCache, O as isTranslationAttempted, m as localeDirection, S as mergeTranslationDictionaries, T as useI18n, E as useOptionalI18n };
|
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { Locale, TranslationDictionary } from './I18nProvider';
|
|
2
|
+
import { DirectionMode, Locale, TranslationDictionary } from './I18nProvider';
|
|
3
|
+
/** How long a returning non-English visitor's first paint waits for the cached dictionary. */
|
|
4
|
+
export declare const FIRST_PAINT_HOLD_MS = 150;
|
|
3
5
|
export interface ProfileI18nBridgeProps {
|
|
4
6
|
children: ReactNode;
|
|
5
7
|
/** Product ID for translations in the i18n service (created during DB seeding) */
|
|
6
8
|
i18nProductId: string;
|
|
9
|
+
/**
|
|
10
|
+
* The platform dictionary layered UNDER the product's (BOFF-8060, F2):
|
|
11
|
+
* fallback < platform < product. Default `workspaces`, the home of the
|
|
12
|
+
* platform screens' and shared chrome's keys. `null` opts out. Ignored when
|
|
13
|
+
* it equals `i18nProductId` (the Workspaces app loads one dictionary).
|
|
14
|
+
*/
|
|
15
|
+
platformI18nProductId?: string | null;
|
|
7
16
|
/** Default locale (default: "en") */
|
|
8
17
|
defaultLocale?: Locale;
|
|
9
18
|
/** Static fallback translations */
|
|
10
19
|
fallbackTranslations?: Record<string, TranslationDictionary>;
|
|
11
20
|
/** Disable live translation fetches and rely on static fallbacks only */
|
|
12
21
|
disableDynamicFetch?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Keep the last complete dictionary in IndexedDB and apply it at once on the
|
|
24
|
+
* next load while revalidating (BOFF-8060, F3). Default true.
|
|
25
|
+
*/
|
|
26
|
+
persistTranslations?: boolean;
|
|
27
|
+
/** Text direction handling (BOFF-8060, F6). Default `off`: always LTR. */
|
|
28
|
+
directionMode?: DirectionMode;
|
|
13
29
|
}
|
|
14
|
-
export declare function ProfileI18nBridge({ children, i18nProductId, defaultLocale, fallbackTranslations, disableDynamicFetch, }: ProfileI18nBridgeProps): import('react/jsx-runtime').JSX.Element;
|
|
30
|
+
export declare function ProfileI18nBridge({ children, i18nProductId, platformI18nProductId, defaultLocale, fallbackTranslations, disableDynamicFetch, persistTranslations, directionMode, }: ProfileI18nBridgeProps): import('react/jsx-runtime').JSX.Element;
|
|
15
31
|
//# sourceMappingURL=ProfileI18nBridge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProfileI18nBridge.d.ts","sourceRoot":"","sources":["../../../../src/shared/providers/shell/ProfileI18nBridge.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ProfileI18nBridge.d.ts","sourceRoot":"","sources":["../../../../src/shared/providers/shell/ProfileI18nBridge.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG7D,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,KAAK,qBAAqB,EAC3B,MAAM,gBAAgB,CAAC;AAmBxB,8FAA8F;AAC9F,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAgDvC,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,SAAS,CAAC;IACpB,kFAAkF;IAClF,aAAa,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,qCAAqC;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mCAAmC;IACnC,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IAC7D,yEAAyE;IACzE,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,0EAA0E;IAC1E,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAYD,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,aAAa,EACb,qBAAwD,EACxD,aAAoB,EACpB,oBAAoB,EACpB,mBAA2B,EAC3B,mBAA0B,EAC1B,aAAqB,GACtB,EAAE,sBAAsB,2CAmExB"}
|
|
@@ -1,44 +1,54 @@
|
|
|
1
1
|
import { graphqlFetch as e } from "../../graphql/fetch.js";
|
|
2
2
|
import "../../../shared-graphql.js";
|
|
3
3
|
import { useAuth as t } from "./AuthProvider.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { getDefaultTranslationPersistence as n } from "./translationStore.js";
|
|
5
|
+
import { I18nProvider as r, useI18n as i } from "./I18nProvider.js";
|
|
6
|
+
import { DEFAULT_PLATFORM_I18N_PRODUCT_ID as a, createLayeredTranslationLoader as o, effectivePlatformId as s, translationCacheScope as c } from "./translationLayers.js";
|
|
7
|
+
import { useCallback as l, useMemo as u } from "react";
|
|
8
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
9
|
+
import { DirectionProvider as f } from "@radix-ui/react-direction";
|
|
7
10
|
//#region src/shared/providers/shell/ProfileI18nBridge.tsx
|
|
8
|
-
var
|
|
9
|
-
function
|
|
10
|
-
let
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
extraHeaders: {
|
|
24
|
-
"x-actor-id": "system-i18n",
|
|
25
|
-
"x-actor-type": "service"
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
if (i.errors?.length || !i.data?.exportTranslations?.url) return {};
|
|
29
|
-
let a = i.data.exportTranslations.url, o = decodeURIComponent(a.replace("data:application/json;charset=utf-8,", ""));
|
|
30
|
-
return r(n, JSON.parse(o));
|
|
31
|
-
} catch {
|
|
32
|
-
return {};
|
|
11
|
+
var p = "\n query ExportTranslations($productId: String!, $languageCode: String!, $format: ImportJobFormat!) {\n exportTranslations(productId: $productId, languageCode: $languageCode, format: $format) {\n format\n url\n }\n }\n";
|
|
12
|
+
async function m(t, n) {
|
|
13
|
+
let r = await e({
|
|
14
|
+
gateway: "global",
|
|
15
|
+
query: p,
|
|
16
|
+
operationName: "ExportTranslations",
|
|
17
|
+
variables: {
|
|
18
|
+
productId: t,
|
|
19
|
+
languageCode: n,
|
|
20
|
+
format: "JSON"
|
|
21
|
+
},
|
|
22
|
+
extraHeaders: {
|
|
23
|
+
"x-actor-id": "system-i18n",
|
|
24
|
+
"x-actor-type": "service"
|
|
33
25
|
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
});
|
|
27
|
+
if (r.errors?.length || !r.data?.exportTranslations?.url) return null;
|
|
28
|
+
let i = r.data.exportTranslations.url, a = decodeURIComponent(i.replace("data:application/json;charset=utf-8,", ""));
|
|
29
|
+
return JSON.parse(a);
|
|
30
|
+
}
|
|
31
|
+
function h({ children: e }) {
|
|
32
|
+
let { dir: t } = i();
|
|
33
|
+
return /* @__PURE__ */ d(f, {
|
|
34
|
+
dir: t,
|
|
35
|
+
children: e
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function g({ children: e, i18nProductId: i, platformI18nProductId: f = a, defaultLocale: p = "en", fallbackTranslations: g, disableDynamicFetch: _ = !1, persistTranslations: v = !0, directionMode: y = "off" }) {
|
|
39
|
+
let { user: b } = t(), x = b?.id ?? null, S = !_, C = s(i, f), w = l((e) => g?.[e] ?? {}, [g]), T = u(() => o({
|
|
40
|
+
productId: i,
|
|
41
|
+
platformId: C,
|
|
42
|
+
fallback: w,
|
|
43
|
+
fetchDictionary: m
|
|
44
|
+
}), [
|
|
45
|
+
w,
|
|
46
|
+
i,
|
|
47
|
+
C
|
|
48
|
+
]), E = u(() => S && v ? n() : null, [v, S]);
|
|
49
|
+
return /* @__PURE__ */ d(r, {
|
|
50
|
+
defaultLocale: p,
|
|
51
|
+
translations: u(() => g ?? {
|
|
42
52
|
en: {},
|
|
43
53
|
es: {},
|
|
44
54
|
fr: {},
|
|
@@ -48,12 +58,16 @@ function c({ children: c, i18nProductId: l, defaultLocale: u = "en", fallbackTra
|
|
|
48
58
|
ta: {},
|
|
49
59
|
hi: {},
|
|
50
60
|
ar: {}
|
|
51
|
-
}, [
|
|
52
|
-
|
|
53
|
-
|
|
61
|
+
}, [g]),
|
|
62
|
+
loadTranslations: S ? T : void 0,
|
|
63
|
+
cacheScope: c(i, C),
|
|
64
|
+
persistence: E,
|
|
65
|
+
firstPaintHoldMs: E ? 150 : 0,
|
|
66
|
+
directionMode: y,
|
|
67
|
+
profileId: x,
|
|
54
68
|
showChildrenWhileLoading: !0,
|
|
55
|
-
children:
|
|
69
|
+
children: /* @__PURE__ */ d(h, { children: e })
|
|
56
70
|
});
|
|
57
71
|
}
|
|
58
72
|
//#endregion
|
|
59
|
-
export {
|
|
73
|
+
export { g as ProfileI18nBridge };
|