{"version":3,"file":"utils.cjs","names":["useLocale","useEnableI18n","getFormatLocales"],"sources":["../../src/hooks/utils.ts"],"sourcesContent":["import type { LocaleProperties } from '@generaltranslation/format/types';\nimport { useMemo } from 'react';\nimport { useEnableI18n, useLocale } from './condition-store';\nimport { getFormatLocales } from './utils/getFormatLocales';\nimport { getI18nConfig } from 'gt-i18n/internal';\n\nconst EMPTY_LOCALES_PROP: string[] = [];\n\nexport { getFormatLocales };\n\nexport function useFormatLocales(\n  localesProp: string[] = EMPTY_LOCALES_PROP\n): string[] {\n  const locale = useLocale();\n  const enableI18n = useEnableI18n();\n  return useMemo(\n    () =>\n      getFormatLocales({\n        locale,\n        enableI18n,\n        localesProp,\n      }),\n    [locale, enableI18n, localesProp]\n  );\n}\n\nexport function useShouldTranslate(): boolean {\n  const enableI18n = useEnableI18n();\n  const locale = useLocale();\n  return enableI18n && getI18nConfig().requiresTranslation(locale);\n}\n\n/**\n * Resolves the condition values shared by translation hooks once per render.\n */\nexport function useTranslationConditions(): {\n  locale: string;\n  shouldTranslate: boolean;\n} {\n  const locale = useLocale();\n  const enableI18n = useEnableI18n();\n  return {\n    locale,\n    shouldTranslate: enableI18n && getI18nConfig().requiresTranslation(locale),\n  };\n}\n\nexport function useLocaleProperties(locale: string): LocaleProperties {\n  return useMemo(\n    () => getI18nConfig().getGTClass().getLocaleProperties(locale),\n    [locale]\n  );\n}\n\nexport function useLocaleDirection(locale?: string): 'ltr' | 'rtl' {\n  const currentLocale = useLocale();\n  const resolvedLocale = locale ?? currentLocale;\n  return useMemo(\n    () => getI18nConfig().getGTClass().getLocaleDirection(resolvedLocale),\n    [resolvedLocale]\n  );\n}\n"],"mappings":"qLAMA,MAAM,EAA+B,EAAE,CAIvC,SAAgB,EACd,EAAwB,EACd,CACV,IAAM,EAASA,EAAAA,WAAW,CACpB,EAAaC,EAAAA,eAAe,CAClC,OAAA,EAAA,EAAA,aAEIC,EAAAA,iBAAiB,CACf,SACA,aACA,cACD,CAAC,CACJ,CAAC,EAAQ,EAAY,EAAY,CAClC,CAGH,SAAgB,GAA8B,CAC5C,IAAM,EAAaD,EAAAA,eAAe,CAC5B,EAASD,EAAAA,WAAW,CAC1B,OAAO,IAAA,EAAA,EAAA,gBAA6B,CAAC,oBAAoB,EAAO,CAMlE,SAAgB,GAGd,CACA,IAAM,EAASA,EAAAA,WAAW,CAE1B,MAAO,CACL,SACA,gBAHiBC,EAAAA,eAGU,GAAA,EAAA,EAAA,gBAAmB,CAAC,oBAAoB,EAAO,CAC3E,CAGH,SAAgB,EAAoB,EAAkC,CACpE,OAAA,EAAA,EAAA,cAAA,EAAA,EAAA,gBACuB,CAAC,YAAY,CAAC,oBAAoB,EAAO,CAC9D,CAAC,EAAO,CACT,CAGH,SAAgB,EAAmB,EAAgC,CACjE,IAAM,EAAgBD,EAAAA,WAAW,CAC3B,EAAiB,GAAU,EACjC,OAAA,EAAA,EAAA,cAAA,EAAA,EAAA,gBACuB,CAAC,YAAY,CAAC,mBAAmB,EAAe,CACrE,CAAC,EAAe,CACjB"}