{"version":3,"file":"getLocaleDirection.mjs","names":[],"sources":["../../src/request/getLocaleDirection.ts"],"sourcesContent":["import { getI18nConfig } from 'gt-i18n/internal';\nimport { getLocale, useLocale } from './getLocale';\n\n/**\n * Retrieves the text direction ('ltr' or 'rtl') for the current or specified locale.\n *\n * If no locale is provided, the direction for the current user's locale is returned asynchronously.\n *\n * @param locale Optional locale code (e.g., 'ar', 'en-US'). If omitted, uses the current locale.\n * @returns If locale is omitted: Promise<'ltr' | 'rtl'>.\n *          If locale is provided: 'ltr' | 'rtl' directly.\n *\n * @example\n * const dir = await getLocaleDirection(); // Promise<'ltr' | 'rtl'>\n * const arabicDir = getLocaleDirection('ar'); // 'rtl'\n */\nexport function getLocaleDirection(locale: string): 'ltr' | 'rtl';\nexport function getLocaleDirection(): Promise<'ltr' | 'rtl'>;\n// Implementation\nexport function getLocaleDirection(locale?: string) {\n  const gtInstance = getI18nConfig().getGTClass();\n  if (typeof locale === 'string') {\n    // Synchronous result when locale is given\n    return gtInstance.getLocaleDirection(locale) as 'ltr' | 'rtl';\n  }\n  // Asynchronous result when locale is not given\n  return getLocale().then((resolvedLocale) =>\n    gtInstance.getLocaleDirection(resolvedLocale)\n  ) as Promise<'ltr' | 'rtl'>;\n}\n\n/**\n * Retrieves the text direction ('ltr' or 'rtl') for the current or specified locale from the `<GTProvider>` context.\n *\n * If no locale is provided, the direction for the current user's locale is returned.\n *\n * @param {string} [locale] - Optional locale code (e.g., 'ar', 'en-US'). If omitted, uses the current locale from context.\n * @returns {'ltr' | 'rtl'} The text direction for the locale: 'rtl' for right-to-left languages, otherwise 'ltr'.\n *\n * @example\n * const dir = useLocaleDirection(); // e.g., 'ltr'\n * const arabicDir = useLocaleDirection('ar'); // 'rtl'\n */\nexport function useLocaleDirection(locale?: string): 'ltr' | 'rtl' {\n  locale = locale || useLocale();\n  return getI18nConfig().getGTClass().getLocaleDirection(locale);\n}\n"],"mappings":";;;AAmBA,SAAgB,mBAAmB,QAAiB;CAClD,MAAM,aAAa,eAAe,CAAC,YAAY;AAC/C,KAAI,OAAO,WAAW,SAEpB,QAAO,WAAW,mBAAmB,OAAO;AAG9C,QAAO,WAAW,CAAC,MAAM,mBACvB,WAAW,mBAAmB,eAAe,CAC9C;;;;;;;;;;;;;;AAeH,SAAgB,mBAAmB,QAAgC;AACjE,UAAS,UAAU,WAAW;AAC9B,QAAO,eAAe,CAAC,YAAY,CAAC,mBAAmB,OAAO"}