{"version":3,"sources":["../../src/core/constants.ts","../../src/react-native/DirhamSymbol.tsx","../../src/core/format.ts","../../src/react-native/DirhamPrice.tsx"],"names":["jsx","Svg","Path","memo","useMemo","Text","View","jsxs","Fragment"],"mappings":";;;;;;;;;;AAgBO,IAAM,cAAA,GAAiB,QAAA;AASvB,IAAM,oBAAA,GAAuB,KAAA;AAsD7B,IAAM,iBAAA,GAAkD;AAAA,EAC9D,IAAA,EAAM,CAAA;AAAA,EACN,UAAA,EAAY,CAAA;AAAA,EACZ,KAAA,EAAO,CAAA;AAAA,EACP,OAAA,EAAS,CAAA;AAAA,EACT,MAAA,EAAQ,CAAA;AAAA,EACR,QAAA,EAAU,EAAA;AAAA,EACV,IAAA,EAAM,EAAA;AAAA,EACN,SAAA,EAAW,EAAA;AAAA,EACX,KAAA,EAAO;AACR,CAAA;ACrFA,IAAM,QAAA,GACL,25EAAA;AAyCD,SAAS,gBAAA,CAAiB;AAAA,EACzB,IAAA,GAAO,EAAA;AAAA,EACP,KAAA,GAAQ,MAAA;AAAA,EACR,kBAAA,GAAqB,YAAA;AAAA,EACrB,MAAA,GAAS;AACV,CAAA,EAAsB;AACrB,EAAA,MAAM,WAAA,GAAc,kBAAkB,MAAM,CAAA;AAE5C,EAAA,uBACCA,cAAA;AAAA,IAACC,kBAAA;AAAA,IAAA;AAAA,MACA,OAAA,EAAQ,cAAA;AAAA,MACR,KAAA,EAAO,IAAA;AAAA,MACP,MAAA,EAAQ,IAAA;AAAA,MACR,IAAA,EAAM,KAAA;AAAA,MACN,kBAAA;AAAA,MACA,iBAAA,EAAkB,OAAA;AAAA,MAElB,QAAA,kBAAAD,cAAA;AAAA,QAACE,mBAAA;AAAA,QAAA;AAAA,UACA,CAAA,EAAG,QAAA;AAAA,UACF,GAAI,cAAc,CAAA,IAAK;AAAA,YACvB,MAAA,EAAQ,KAAA;AAAA,YACR,WAAA;AAAA,YACA,cAAA,EAAgB,OAAA;AAAA,YAChB,UAAA,EAAY;AAAA;AACb;AAA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,EAAQ,MAAA,EAAQ,QAAA,EAAU,QAAQ,CAAC,CAAA;AAEvC,EAAA,MAAM,KAAA,GACL,kBAAA,IACA,YAAA,CAAa,MAAA,EAAQ,EAAE,QAAQ,QAAA,EAAU,OAAA,EAAS,IAAA,EAAM,QAAA,EAAU,CAAA;AAEnE,EAAA,MAAM,SAAS,OAAA,mBACdJ,eAACK,gBAAA,EAAA,EAAK,KAAA,EAAO,EAAE,KAAA,EAAO,QAAA,EAAS,EAAG,QAAA,EAAA,KAAA,EAAG,oBAErCL,cAAAA,CAAC,gBAAa,IAAA,EAAM,UAAA,EAAY,OAAc,MAAA,EAAgB,CAAA;AAG/D,EAAA,uBACCA,cAAAA;AAAA,IAACM,gBAAA;AAAA,IAAA;AAAA,MACA,KAAA,EAAO;AAAA,QACN,aAAA,EAAe,QAAQ,aAAA,GAAgB,KAAA;AAAA,QACvC,UAAA,EAAY;AAAA,OACb;AAAA,MACA,kBAAA,EAAoB,KAAA;AAAA,MACpB,iBAAA,EAAkB,MAAA;AAAA,MAEjB,wCACAC,eAAA,CAAAC,mBAAA,EAAA,EACE,QAAA,EAAA;AAAA,QAAA,MAAA;AAAA,wCACAH,gBAAA,EAAA,EAAK,KAAA,EAAO,EAAE,KAAA,EAAO,UAAS,EAC7B,QAAA,EAAA;AAAA,UAAA,MAAA;AAAA,UACA;AAAA,SAAA,EACF;AAAA,OAAA,EACD,oBAEAE,eAAA,CAAAC,mBAAA,EAAA,EACC,QAAA,EAAA;AAAA,wBAAAD,eAAA,CAACF,gBAAA,EAAA,EAAK,KAAA,EAAO,EAAE,KAAA,EAAO,UAAS,EAC7B,QAAA,EAAA;AAAA,UAAA,SAAA;AAAA,UACA;AAAA,SAAA,EACF,CAAA;AAAA,QACC;AAAA,OAAA,EACF;AAAA;AAAA,GAEF;AAEF;AAEO,IAAM,WAAA,GAAcF,WAAK,eAAe","file":"index.cjs","sourcesContent":["/**\n * UAE Dirham currency symbol constants.\n *\n * This package maps the Dirham glyph to the official Unicode codepoint U+20C3\n * (UAE DIRHAM SIGN) via a custom web font. The codepoint was accepted by the\n * Unicode Technical Committee for Unicode 18.0 (expected September 2026).\n *\n * Until system fonts ship native U+20C3 glyphs, the bundled web font provides\n * the rendering. When OS/font support lands, the web font becomes optional;\n * zero migration required.\n *\n * @module dirham\n * @see https://www.unicode.org/alloc/Pipeline.html\n */\n\n/** Unicode character for the Dirham symbol (U+20C3, requires Dirham web font until system fonts support it) */\nexport const DIRHAM_UNICODE = \"\\u20C3\";\n\n/** HTML entity for the Dirham symbol */\nexport const DIRHAM_HTML_ENTITY = \"&#x20C3;\";\n\n/** CSS content value for use in `::before` / `::after` pseudo-elements */\nexport const DIRHAM_CSS_CONTENT = \"\\\\20C3\";\n\n/** ISO 4217 currency code for UAE Dirham */\nexport const DIRHAM_CURRENCY_CODE = \"AED\";\n\n/** Arabic text representation of the Dirham symbol (د.إ) */\nexport const DIRHAM_SYMBOL_TEXT = \"د.إ\";\n\n/** The font family name used for the Dirham web font */\nexport const DIRHAM_FONT_FAMILY = \"Dirham\";\n\n/** CSS class name for the Dirham icon */\nexport const DIRHAM_CSS_CLASS = \"dirham-symbol\";\n\n/** Unicode codepoint as a number (0x20C3) */\nexport const DIRHAM_CODEPOINT = 0x20c3;\n\n// ── Font weight mapping ─────────────────────────────────────────────────\n\n/**\n * Supported visual weights for the Dirham symbol SVG component.\n *\n * Because the Dirham symbol is not yet in standard fonts (until Unicode 18.0),\n * weight simulation is applied via SVG stroke to match surrounding text weight,\n * similar to how $, €, £ adapt to their font's weight.\n */\nexport type DirhamWeight =\n\t| \"thin\"\n\t| \"extralight\"\n\t| \"light\"\n\t| \"regular\"\n\t| \"medium\"\n\t| \"semibold\"\n\t| \"bold\"\n\t| \"extrabold\"\n\t| \"black\";\n\n/**\n * Map from weight name to CSS `font-weight` numeric value.\n * Used for matching the symbol weight to surrounding text.\n */\nexport const DIRHAM_WEIGHT_MAP: Record<DirhamWeight, number> = {\n\tthin: 100,\n\textralight: 200,\n\tlight: 300,\n\tregular: 400,\n\tmedium: 500,\n\tsemibold: 600,\n\tbold: 700,\n\textrabold: 800,\n\tblack: 900,\n};\n\n/**\n * SVG stroke-width values that simulate font weight.\n * Applied with `paint-order: stroke` so stroke renders behind fill.\n */\nexport const DIRHAM_STROKE_MAP: Record<DirhamWeight, number> = {\n\tthin: 0,\n\textralight: 0,\n\tlight: 0,\n\tregular: 0,\n\tmedium: 8,\n\tsemibold: 16,\n\tbold: 24,\n\textrabold: 36,\n\tblack: 48,\n};\n","import { memo } from \"react\";\nimport { Path, Svg } from \"react-native-svg\";\nimport { DIRHAM_STROKE_MAP, type DirhamWeight } from \"../core/constants\";\n\nconst SVG_PATH =\n\t\"m88.3 1c0.4 0.6 2.6 3.3 4.7 5.9 15.3 18.2 26.8 47.8 33 85.1 4.1 24.5 4.3 32.2 4.3 125.6v87h-41.8c-38.2 0-42.6-0.2-50.1-1.7-11.8-2.5-24-9.2-32.2-17.8-6.5-6.9-6.3-7.3-5.9 13.6 0.5 17.3 0.7 19.2 3.2 28.6 4 14.9 9.5 26 17.8 35.9 11.3 13.6 22.8 21.2 39.2 26.3 3.5 1 10.9 1.4 37.1 1.6l32.7 0.5v43.3 43.4l-46.1-0.3-46.3-0.3-8-3.2c-9.5-3.8-13.8-6.6-23.1-14.9l-6.8-6.1 0.4 19.1c0.5 17.7 0.6 19.7 3.1 28.7 8.7 31.8 29.7 54.5 57.4 61.9 6.9 1.9 9.6 2 38.5 2.4l30.9 0.4v89.6c0 54.1-0.3 94-0.8 100.8-0.5 6.2-2.1 17.8-3.5 25.9-6.5 37.3-18.2 65.4-35 83.6l-3.4 3.7h169.1c101.1 0 176.7-0.4 187.8-0.9 19.5-1 63-5.3 72.8-7.4 3.1-0.6 8.9-1.5 12.7-2.1 8.1-1.2 21.5-4 40.8-8.9 27.2-6.8 52-15.3 76.3-26.1 7.6-3.4 29.4-14.5 35.2-18 3.1-1.8 6.8-4 8.2-4.7 3.9-2.1 10.4-6.3 19.9-13.1 4.7-3.4 9.4-6.7 10.4-7.4 4.2-2.8 18.7-14.9 25.3-21 25.1-23.1 46.1-48.8 62.4-76.3 2.3-4 5.3-9 6.6-11.1 3.3-5.6 16.9-33.6 18.2-37.8 0.6-1.9 1.4-3.9 1.8-4.3 2.6-3.4 17.6-50.6 19.4-60.9 0.6-3.3 0.9-3.8 3.4-4.3 1.6-0.3 24.9-0.3 51.8-0.1 53.8 0.4 53.8 0.4 65.7 5.9 6.7 3.1 8.7 4.5 16.1 11.2 9.7 8.7 8.8 10.1 8.2-11.7-0.4-12.8-0.9-20.7-1.8-23.9-3.4-12.3-4.2-14.9-7.2-21.1-9.8-21.4-26.2-36.7-47.2-44l-8.2-3-33.4-0.4-33.3-0.5 0.4-11.7c0.4-15.4 0.4-45.9-0.1-61.6l-0.4-12.6 44.6-0.2c38.2-0.2 45.3 0 49.5 1.1 12.6 3.5 21.1 8.3 31.5 17.8l5.8 5.4v-14.8c0-17.6-0.9-25.4-4.5-37-7.1-23.5-21.1-41-41.1-51.8-13-7-13.8-7.2-58.5-7.5-26.2-0.2-39.9-0.6-40.6-1.2-0.6-0.6-1.1-1.6-1.1-2.4 0-0.8-1.5-7.1-3.5-13.9-23.4-82.7-67.1-148.4-131-197.1-8.7-6.7-30-20.8-38.6-25.6-3.3-1.9-6.9-3.9-7.8-4.5-4.2-2.3-28.3-14.1-34.3-16.6-3.6-1.6-8.3-3.6-10.4-4.4-35.3-15.3-94.5-29.8-139.7-34.3-7.4-0.7-17.2-1.8-21.7-2.2-20.4-2.3-48.7-2.6-209.4-2.6-135.8 0-169.9 0.3-169.4 1zm330.7 43.3c33.8 2 54.6 4.6 78.9 10.5 74.2 17.6 126.4 54.8 164.3 117 3.5 5.8 18.3 36 20.5 42.1 10.5 28.3 15.6 45.1 20.1 67.3 1.1 5.4 2.6 12.6 3.3 16 0.7 3.3 1 6.4 0.7 6.7-0.5 0.4-100.9 0.6-223.3 0.5l-222.5-0.2-0.3-128.5c-0.1-70.6 0-129.3 0.3-130.4l0.4-1.9h71.1c39 0 78 0.4 86.5 0.9zm297.5 350.3c0.7 4.3 0.7 77.3 0 80.9l-0.6 2.7-227.5-0.2-227.4-0.3-0.2-42.4c-0.2-23.3 0-42.7 0.2-43.1 0.3-0.5 97.2-0.8 227.7-0.8h227.2zm-10.2 171.7c0.5 1.5-1.9 13.8-6.8 33.8-5.6 22.5-13.2 45.2-20.9 62-3.8 8.6-13.3 27.2-15.6 30.7-1.1 1.6-4.3 6.7-7.1 11.2-18 28.2-43.7 53.9-73 72.9-10.7 6.8-32.7 18.4-38.6 20.2-1.2 0.3-2.5 0.9-3 1.3-0.7 0.6-9.8 4-20.4 7.8-19.5 6.9-56.6 14.4-86.4 17.5-19.3 1.9-22.4 2-96.7 2h-76.9v-129.7-129.8l220.9-0.4c121.5-0.2 221.6-0.5 222.4-0.7 0.9-0.1 1.8 0.5 2.1 1.2z\";\n\nexport interface DirhamSymbolProps {\n\t/**\n\t * Size in logical pixels.\n\t * @default 24\n\t */\n\tsize?: number;\n\n\t/**\n\t * Color of the symbol.\n\t * @default \"currentColor\" (falls back to #000)\n\t */\n\tcolor?: string;\n\n\t/**\n\t * Accessible label for screen readers.\n\t * @default \"UAE Dirham\"\n\t */\n\taccessibilityLabel?: string;\n\n\t/**\n\t * Visual weight of the symbol.\n\t * @default \"regular\"\n\t */\n\tweight?: DirhamWeight;\n}\n\n/**\n * React Native SVG-based UAE Dirham symbol.\n *\n * Requires `react-native-svg` as a peer dependency.\n *\n * @example\n * ```tsx\n * import { DirhamSymbol } from \"dirham/react-native\";\n *\n * <DirhamSymbol size={24} />\n * <DirhamSymbol size={32} color=\"#00A86B\" weight=\"bold\" />\n * ```\n */\nfunction DirhamSymbolBase({\n\tsize = 24,\n\tcolor = \"#000\",\n\taccessibilityLabel = \"UAE Dirham\",\n\tweight = \"regular\",\n}: DirhamSymbolProps) {\n\tconst strokeWidth = DIRHAM_STROKE_MAP[weight];\n\n\treturn (\n\t\t<Svg\n\t\t\tviewBox=\"0 0 1000 870\"\n\t\t\twidth={size}\n\t\t\theight={size}\n\t\t\tfill={color}\n\t\t\taccessibilityLabel={accessibilityLabel}\n\t\t\taccessibilityRole=\"image\"\n\t\t>\n\t\t\t<Path\n\t\t\t\td={SVG_PATH}\n\t\t\t\t{...(strokeWidth > 0 && {\n\t\t\t\t\tstroke: color,\n\t\t\t\t\tstrokeWidth,\n\t\t\t\t\tstrokeLinejoin: \"round\",\n\t\t\t\t\tpaintOrder: \"stroke\",\n\t\t\t\t})}\n\t\t\t/>\n\t\t</Svg>\n\t);\n}\n\nexport const DirhamSymbol = memo(DirhamSymbolBase);\n","import {\n\tDIRHAM_CURRENCY_CODE,\n\tDIRHAM_SYMBOL_TEXT,\n\tDIRHAM_UNICODE,\n} from \"./constants\";\n\n// ─── Intl.NumberFormat cache ─────────────────────────────────────────────────\n// Constructing Intl.NumberFormat is expensive (~µs). Cache instances keyed on\n// \"locale:decimals\" so repeated calls (e.g., rendering a price list) reuse\n// the same formatter instead of allocating a new object each time.\nconst _fmtCache = new Map<string, Intl.NumberFormat>();\n\nfunction getFormatter(\n\tlocale: string,\n\tdecimals: number,\n\tnotation: \"standard\" | \"compact\" = \"standard\",\n): Intl.NumberFormat {\n\tconst key = `${locale}:${decimals}:${notation}`;\n\tlet fmt = _fmtCache.get(key);\n\tif (!fmt) {\n\t\tfmt = new Intl.NumberFormat(locale, {\n\t\t\tminimumFractionDigits: notation === \"compact\" ? 0 : decimals,\n\t\t\tmaximumFractionDigits: decimals,\n\t\t\t...(notation === \"compact\" && {\n\t\t\t\tnotation: \"compact\",\n\t\t\t\tcompactDisplay: \"short\",\n\t\t\t}),\n\t\t});\n\t\t_fmtCache.set(key, fmt);\n\t}\n\treturn fmt;\n}\n\n/**\n * Options for formatting a Dirham amount.\n */\nexport interface FormatDirhamOptions {\n\t/**\n\t * Locale string for number formatting.\n\t * @default \"en-AE\"\n\t */\n\tlocale?: string;\n\n\t/**\n\t * Number of decimal places.\n\t * @default 2\n\t */\n\tdecimals?: number;\n\n\t/**\n\t * Whether to place the symbol before the amount.\n\t * When `undefined`, determined by locale:\n\t * - Arabic locales (ar-*): symbol after amount\n\t * - Other locales: symbol before amount\n\t */\n\tsymbolFirst?: boolean;\n\n\t/**\n\t * Use ISO currency code (AED) instead of the symbol.\n\t * @default false\n\t */\n\tuseCode?: boolean;\n\n\t/**\n\t * Separator between symbol and amount.\n\t * @default \" \" (non-breaking space)\n\t */\n\tseparator?: string;\n\n\t/**\n\t * Number notation style.\n\t * - `\"standard\"` — full digits (e.g. 1,500,000.00)\n\t * - `\"compact\"` — abbreviated (e.g. 1.5M)\n\t * @default \"standard\"\n\t */\n\tnotation?: \"standard\" | \"compact\";\n}\n\n/**\n * Format a number as a Dirham currency string.\n *\n * @example\n * ```ts\n * formatDirham(100);          // \"\\u20C3 100.00\"\n * formatDirham(1234.5);       // \"\\u20C3 1,234.50\"\n * formatDirham(100, { locale: \"ar-AE\" }); // \"100.00 \\u20C3\"\n * formatDirham(100, { useCode: true });   // \"AED 100.00\"\n * formatDirham(1500000, { notation: \"compact\" }); // \"\\u20C3 1.5M\"\n * ```\n */\nexport function formatDirham(\n\tamount: number,\n\toptions: FormatDirhamOptions = {},\n): string {\n\tif (!Number.isFinite(amount)) {\n\t\tthrow new RangeError(\n\t\t\t`formatDirham: amount must be a finite number, got ${amount}`,\n\t\t);\n\t}\n\n\tconst {\n\t\tlocale = \"en-AE\",\n\t\tdecimals = 2,\n\t\tuseCode = false,\n\t\tseparator = \"\\u00A0\", // non-breaking space\n\t\tnotation = \"standard\",\n\t} = options;\n\n\tconst symbol = useCode ? DIRHAM_CURRENCY_CODE : DIRHAM_UNICODE;\n\n\t// Determine symbol placement\n\tlet symbolFirst: boolean;\n\tif (options.symbolFirst !== undefined) {\n\t\tsymbolFirst = options.symbolFirst;\n\t} else {\n\t\t// Arabic locales place symbol after amount\n\t\tsymbolFirst = !locale.startsWith(\"ar\");\n\t}\n\n\t// Format the number (use cached formatter)\n\tconst formatted = getFormatter(locale, decimals, notation).format(amount);\n\n\treturn symbolFirst\n\t\t? `${symbol}${separator}${formatted}`\n\t\t: `${formatted}${separator}${symbol}`;\n}\n\n/**\n * Options for parsing a Dirham-formatted string.\n */\nexport interface ParseDirhamOptions {\n\t/**\n\t * Normalize Arabic-Indic digits (٠١٢٣٤٥٦٧٨٩ / U+0660–U+0669) to ASCII\n\t * digits before parsing. Enables round-tripping strings produced by\n\t * `formatDirham` with Arabic locales (e.g. `\"ar-AE\"`).\n\t * @default true\n\t */\n\tnormalizeArabicNumerals?: boolean;\n}\n\n/**\n * Parse a Dirham-formatted string back to a number.\n * Strips currency symbols, codes, and formatting characters.\n * By default also normalizes Arabic-Indic digits so strings produced by\n * `formatDirham({ locale: \"ar-AE\" })` round-trip correctly.\n *\n * @example\n * ```ts\n * parseDirham(\"\\u20C3 1,234.50\");                  // 1234.5\n * parseDirham(\"AED 100.00\");                        // 100\n * parseDirham(\"١٬٢٣٤٫٥٠ \\u20C3\");                  // 1234.5\n * parseDirham(\"١٠٠٫٠٠ \\u20C3\", { normalizeArabicNumerals: false }); // throws\n * ```\n */\nexport function parseDirham(\n\tvalue: string,\n\toptions: ParseDirhamOptions = {},\n): number {\n\tconst { normalizeArabicNumerals = true } = options;\n\n\tlet cleaned = value\n\t\t.replaceAll(DIRHAM_UNICODE, \"\")\n\t\t.replaceAll(DIRHAM_SYMBOL_TEXT, \"\")\n\t\t.replaceAll(DIRHAM_CURRENCY_CODE, \"\")\n\t\t.replace(/[,\\s\\u00A0\\u066C]/g, \"\") // ASCII comma, whitespace, NBSP, Arabic thousands sep\n\t\t.trim();\n\n\tif (normalizeArabicNumerals) {\n\t\t// Arabic-Indic digits U+0660–U+0669 → ASCII 0–9\n\t\tcleaned = cleaned.replace(/[\\u0660-\\u0669]/g, (d) =>\n\t\t\tString(d.charCodeAt(0) - 0x0660),\n\t\t);\n\t\t// Arabic decimal separator (U+066B) → '.'\n\t\tcleaned = cleaned.replace(/\\u066B/g, \".\");\n\t}\n\n\tconst result = Number.parseFloat(cleaned);\n\tif (Number.isNaN(result)) {\n\t\tthrow new Error(`Cannot parse \"${value}\" as a Dirham amount`);\n\t}\n\treturn result;\n}\n","import { memo, useMemo } from \"react\";\nimport { Text, View } from \"react-native\";\nimport type { DirhamWeight } from \"../core/constants\";\nimport { formatDirham } from \"../core/format\";\nimport { DirhamSymbol } from \"./DirhamSymbol\";\n\nexport interface DirhamPriceProps {\n\t/**\n\t * Numeric amount to display.\n\t */\n\tamount: number;\n\n\t/**\n\t * Locale string for number formatting.\n\t * @default \"en-AE\"\n\t */\n\tlocale?: string;\n\n\t/**\n\t * Number of decimal places.\n\t * @default 2\n\t */\n\tdecimals?: number;\n\n\t/**\n\t * Use ISO currency code (AED) instead of the symbol.\n\t * @default false\n\t */\n\tuseCode?: boolean;\n\n\t/**\n\t * Number notation style.\n\t * @default \"standard\"\n\t */\n\tnotation?: \"standard\" | \"compact\";\n\n\t/**\n\t * Size of the Dirham symbol.\n\t * @default 16\n\t */\n\tsymbolSize?: number;\n\n\t/**\n\t * Visual weight of the SVG symbol.\n\t * @default \"regular\"\n\t */\n\tweight?: DirhamWeight;\n\n\t/**\n\t * Text color.\n\t * @default \"#000\"\n\t */\n\tcolor?: string;\n\n\t/**\n\t * Font size for the amount text.\n\t * @default 16\n\t */\n\tfontSize?: number;\n\n\t/**\n\t * Accessible label for screen readers.\n\t */\n\taccessibilityLabel?: string;\n}\n\n/**\n * React Native component for displaying formatted Dirham prices.\n *\n * @example\n * ```tsx\n * import { DirhamPrice } from \"dirham/react-native\";\n *\n * <DirhamPrice amount={1250} />\n * <DirhamPrice amount={500} locale=\"ar-AE\" />\n * ```\n */\nfunction DirhamPriceBase({\n\tamount,\n\tlocale = \"en-AE\",\n\tdecimals = 2,\n\tuseCode = false,\n\tnotation = \"standard\",\n\tsymbolSize = 16,\n\tweight = \"regular\",\n\tcolor = \"#000\",\n\tfontSize = 16,\n\taccessibilityLabel,\n}: DirhamPriceProps) {\n\tconst symbolFirst = !locale.startsWith(\"ar\");\n\tconst isRTL = locale.startsWith(\"ar\");\n\n\tconst formatted = useMemo(() => {\n\t\tif (!Number.isFinite(amount)) return \"—\";\n\t\treturn formatDirham(amount, {\n\t\t\tlocale,\n\t\t\tdecimals,\n\t\t\tuseCode: true,\n\t\t\tnotation,\n\t\t})\n\t\t\t.replace(\"AED\", \"\")\n\t\t\t.trim();\n\t}, [amount, locale, decimals, notation]);\n\n\tconst label =\n\t\taccessibilityLabel ??\n\t\tformatDirham(amount, { locale, decimals, useCode: true, notation });\n\n\tconst symbol = useCode ? (\n\t\t<Text style={{ color, fontSize }}>AED</Text>\n\t) : (\n\t\t<DirhamSymbol size={symbolSize} color={color} weight={weight} />\n\t);\n\n\treturn (\n\t\t<View\n\t\t\tstyle={{\n\t\t\t\tflexDirection: isRTL ? \"row-reverse\" : \"row\",\n\t\t\t\talignItems: \"center\",\n\t\t\t}}\n\t\t\taccessibilityLabel={label}\n\t\t\taccessibilityRole=\"text\"\n\t\t>\n\t\t\t{symbolFirst ? (\n\t\t\t\t<>\n\t\t\t\t\t{symbol}\n\t\t\t\t\t<Text style={{ color, fontSize }}>\n\t\t\t\t\t\t{\"\\u00A0\"}\n\t\t\t\t\t\t{formatted}\n\t\t\t\t\t</Text>\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<Text style={{ color, fontSize }}>\n\t\t\t\t\t\t{formatted}\n\t\t\t\t\t\t{\"\\u00A0\"}\n\t\t\t\t\t</Text>\n\t\t\t\t\t{symbol}\n\t\t\t\t</>\n\t\t\t)}\n\t\t</View>\n\t);\n}\n\nexport const DirhamPrice = memo(DirhamPriceBase);\n"]}