@vritti/quantum-ui 0.6.9 → 0.6.11

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.
Files changed (200) hide show
  1. package/dist/Avatar.js +5 -5
  2. package/dist/Badge2.js +86 -11
  3. package/dist/Badge2.js.map +1 -1
  4. package/dist/ChartFrame.js +4 -1
  5. package/dist/ChartFrame.js.map +1 -1
  6. package/dist/Checkbox2.js +5 -5
  7. package/dist/CurrencyFieldFilter.js +60 -34
  8. package/dist/CurrencyFieldFilter.js.map +1 -1
  9. package/dist/Dialog.js +1 -1
  10. package/dist/DropdownMenu.js +6 -1
  11. package/dist/DropdownMenu.js.map +1 -1
  12. package/dist/IconSelect.js +2302 -2324
  13. package/dist/IconSelect.js.map +1 -1
  14. package/dist/Input.js +1 -1
  15. package/dist/Input.js.map +1 -1
  16. package/dist/Label.js +1 -1
  17. package/dist/OTPField.js +2 -2
  18. package/dist/OTPField.js.map +1 -1
  19. package/dist/PhoneField.js +2 -2
  20. package/dist/PhoneField.js.map +1 -1
  21. package/dist/Progress.js +2 -2
  22. package/dist/QuantityField.js +437 -105
  23. package/dist/QuantityField.js.map +1 -1
  24. package/dist/RadioGroup.js +7 -7
  25. package/dist/Select.js +92 -4
  26. package/dist/Select.js.map +1 -1
  27. package/dist/Sidebar.js +1 -1
  28. package/dist/SingleSelect.js +1 -1
  29. package/dist/SingleSelect.js.map +1 -1
  30. package/dist/Sonner.js +1 -1
  31. package/dist/Spinner.js +8 -2
  32. package/dist/Spinner.js.map +1 -1
  33. package/dist/Switch.js +5 -5
  34. package/dist/TabsSkeleton.js +2 -2
  35. package/dist/TextArea.js +1 -1
  36. package/dist/TextArea.js.map +1 -1
  37. package/dist/TextField.js +29 -27
  38. package/dist/TextField.js.map +1 -1
  39. package/dist/Toggle.js +1 -1
  40. package/dist/assets/quantum-ui.css +473 -171
  41. package/dist/bindFilters.js +14 -1
  42. package/dist/bindFilters.js.map +1 -1
  43. package/dist/components/ContextBar.js.map +1 -1
  44. package/dist/components/QuantityField.js +1 -1
  45. package/dist/components/RichTextEditor.js +1 -1
  46. package/dist/components/TreeView.js +4 -4
  47. package/dist/currencyCode.js +1520 -0
  48. package/dist/currencyCode.js.map +1 -0
  49. package/dist/dropdown-menu.js +9 -9
  50. package/dist/image-component.js +1 -1
  51. package/dist/index.js +2 -2
  52. package/dist/index10.js +37 -1499
  53. package/dist/index10.js.map +1 -1
  54. package/dist/index11.js +503 -28
  55. package/dist/index11.js.map +1 -1
  56. package/dist/index12.js +230 -454
  57. package/dist/index12.js.map +1 -1
  58. package/dist/index13.js +1073 -213
  59. package/dist/index13.js.map +1 -1
  60. package/dist/index14.js +20 -1139
  61. package/dist/index14.js.map +1 -1
  62. package/dist/index15.js +14 -20
  63. package/dist/index15.js.map +1 -1
  64. package/dist/index16.js +173 -19
  65. package/dist/index16.js.map +1 -1
  66. package/dist/index17.js +173 -168
  67. package/dist/index17.js.map +1 -1
  68. package/dist/index18.js +201 -171
  69. package/dist/index18.js.map +1 -1
  70. package/dist/index19.js +190 -186
  71. package/dist/index19.js.map +1 -1
  72. package/dist/index20.js +204 -202
  73. package/dist/index20.js.map +1 -1
  74. package/dist/index21.js +68 -209
  75. package/dist/index21.js.map +1 -1
  76. package/dist/index22.js +1128 -70
  77. package/dist/index22.js.map +1 -1
  78. package/dist/index23.js +4 -1133
  79. package/dist/index23.js.map +1 -1
  80. package/dist/index24.js +232 -4
  81. package/dist/index24.js.map +1 -1
  82. package/dist/index25.js +1100 -207
  83. package/dist/index25.js.map +1 -1
  84. package/dist/index26.js +2469 -1023
  85. package/dist/index26.js.map +1 -1
  86. package/dist/index27.js +35 -2569
  87. package/dist/index27.js.map +1 -1
  88. package/dist/index28.js +308 -36
  89. package/dist/index28.js.map +1 -1
  90. package/dist/index29.js +7 -307
  91. package/dist/index29.js.map +1 -1
  92. package/dist/index30.js +30 -8
  93. package/dist/index30.js.map +1 -1
  94. package/dist/index31.js +59 -29
  95. package/dist/index31.js.map +1 -1
  96. package/dist/index32.js +10 -59
  97. package/dist/index32.js.map +1 -1
  98. package/dist/index33.js +35347 -9
  99. package/dist/index33.js.map +1 -1
  100. package/dist/index34.js +72 -35342
  101. package/dist/index34.js.map +1 -1
  102. package/dist/index35.js +187 -72
  103. package/dist/index35.js.map +1 -1
  104. package/dist/index5.js +4 -4
  105. package/dist/index9.js +1 -1
  106. package/dist/lib/components/ContextBar/useContextState.d.ts +7 -1
  107. package/dist/lib/components/ContextBar/useContextState.d.ts.map +1 -1
  108. package/dist/lib/components/CurrencyField/CurrencyField.d.ts +8 -4
  109. package/dist/lib/components/CurrencyField/CurrencyField.d.ts.map +1 -1
  110. package/dist/lib/components/CurrencyField/CurrencyFieldFilter.d.ts +3 -2
  111. package/dist/lib/components/CurrencyField/CurrencyFieldFilter.d.ts.map +1 -1
  112. package/dist/lib/components/DataTable/DataTable.d.ts.map +1 -1
  113. package/dist/lib/components/DataTable/components/DataTablePagination.d.ts.map +1 -1
  114. package/dist/lib/components/DataTable/components/DataTableSelectionBar.d.ts +3 -2
  115. package/dist/lib/components/DataTable/components/DataTableSelectionBar.d.ts.map +1 -1
  116. package/dist/lib/components/DataTable/hooks/useDataTable.d.ts +4 -1
  117. package/dist/lib/components/DataTable/hooks/useDataTable.d.ts.map +1 -1
  118. package/dist/lib/components/DataTable/index.d.ts +1 -1
  119. package/dist/lib/components/DataTable/index.d.ts.map +1 -1
  120. package/dist/lib/components/DataTable/types.d.ts +13 -1
  121. package/dist/lib/components/DataTable/types.d.ts.map +1 -1
  122. package/dist/lib/components/DataTable/utils.d.ts +2 -2
  123. package/dist/lib/components/DataTable/utils.d.ts.map +1 -1
  124. package/dist/lib/components/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  125. package/dist/lib/components/DropdownMenu/types.d.ts +2 -0
  126. package/dist/lib/components/DropdownMenu/types.d.ts.map +1 -1
  127. package/dist/lib/components/Field/numberConstraints.d.ts +19 -0
  128. package/dist/lib/components/Field/numberConstraints.d.ts.map +1 -0
  129. package/dist/lib/components/PhoneField/PhoneField.d.ts.map +1 -1
  130. package/dist/lib/components/QuantityField/QuantityField.d.ts +11 -1
  131. package/dist/lib/components/QuantityField/QuantityField.d.ts.map +1 -1
  132. package/dist/lib/components/QuantityField/index.d.ts +1 -1
  133. package/dist/lib/components/QuantityField/index.d.ts.map +1 -1
  134. package/dist/lib/components/QuantityField/quantity.d.ts +14 -0
  135. package/dist/lib/components/QuantityField/quantity.d.ts.map +1 -1
  136. package/dist/lib/components/Select/Select.d.ts +3 -0
  137. package/dist/lib/components/Select/Select.d.ts.map +1 -1
  138. package/dist/lib/components/Select/hooks/useSelect.d.ts +2 -0
  139. package/dist/lib/components/Select/hooks/useSelect.d.ts.map +1 -1
  140. package/dist/lib/components/TextField/TextField.d.ts.map +1 -1
  141. package/dist/lib/hooks/useWorkspaceCurrency.d.ts +2 -1
  142. package/dist/lib/hooks/useWorkspaceCurrency.d.ts.map +1 -1
  143. package/dist/lib/types/conditions.d.ts +2 -1
  144. package/dist/lib/types/conditions.d.ts.map +1 -1
  145. package/dist/lib/{components/DataTable/components → utils}/bindFilters.d.ts +2 -1
  146. package/dist/lib/utils/bindFilters.d.ts.map +1 -0
  147. package/dist/lib/utils/currency.d.ts +7 -5
  148. package/dist/lib/utils/currency.d.ts.map +1 -1
  149. package/dist/lib/utils/currencyCode.d.ts +14 -0
  150. package/dist/lib/utils/currencyCode.d.ts.map +1 -0
  151. package/dist/lib/utils/format.d.ts +7 -5
  152. package/dist/lib/utils/format.d.ts.map +1 -1
  153. package/dist/lib/utils/money.d.ts +5 -4
  154. package/dist/lib/utils/money.d.ts.map +1 -1
  155. package/dist/lib/utils/store.d.ts +3 -0
  156. package/dist/lib/utils/store.d.ts.map +1 -0
  157. package/dist/lib/utils/zod.d.ts +3 -1
  158. package/dist/lib/utils/zod.d.ts.map +1 -1
  159. package/dist/numberConstraints.js +68 -0
  160. package/dist/numberConstraints.js.map +1 -0
  161. package/dist/popover.js +5 -2
  162. package/dist/popover.js.map +1 -1
  163. package/dist/react.js +45 -0
  164. package/dist/react.js.map +1 -0
  165. package/dist/ruler.js +27 -0
  166. package/dist/ruler.js.map +1 -0
  167. package/dist/select2.js +2 -2
  168. package/dist/select2.js.map +1 -1
  169. package/dist/separator2.js +1 -1
  170. package/dist/shadcn/shadcnBadge/Badge.d.ts +5 -2
  171. package/dist/shadcn/shadcnBadge/Badge.d.ts.map +1 -1
  172. package/dist/shadcn/shadcnChart/Chart.d.ts.map +1 -1
  173. package/dist/shadcn/shadcnPopover/index.d.ts +1 -1
  174. package/dist/shadcn/shadcnPopover/index.d.ts.map +1 -1
  175. package/dist/shadcn/shadcnPopover/popover.d.ts +2 -1
  176. package/dist/shadcn/shadcnPopover/popover.d.ts.map +1 -1
  177. package/dist/tooltip2.js +1 -1
  178. package/dist/useContextState.js +39 -6
  179. package/dist/useContextState.js.map +1 -1
  180. package/dist/useDataTable.js +148 -64
  181. package/dist/useDataTable.js.map +1 -1
  182. package/dist/useWorkspaceCurrency.js.map +1 -1
  183. package/dist/utils/currency.js +3 -14
  184. package/dist/utils/currency.js.map +1 -1
  185. package/dist/utils/format.js +14 -6
  186. package/dist/utils/format.js.map +1 -1
  187. package/dist/utils/money.js +5 -3
  188. package/dist/utils/money.js.map +1 -1
  189. package/dist/utils/motion.js +2 -2
  190. package/dist/utils/store.js +67 -0
  191. package/dist/utils/store.js.map +1 -0
  192. package/dist/utils/zod.js +10 -7
  193. package/dist/utils/zod.js.map +1 -1
  194. package/dist/value.js +1 -1
  195. package/package.json +5 -1
  196. package/dist/Spinner2.js +0 -10
  197. package/dist/Spinner2.js.map +0 -1
  198. package/dist/index36.js +0 -199
  199. package/dist/index36.js.map +0 -1
  200. package/dist/lib/components/DataTable/components/bindFilters.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useWorkspaceCurrency.js","sources":["../lib/hooks/useBarcodeScanner.ts","../lib/hooks/useCategoricalColors.ts","../lib/hooks/useOrgCountryCode.ts","../lib/hooks/useSlugParams.ts","../lib/hooks/useSSE.ts","../lib/hooks/useTimer.ts","../lib/hooks/useWorkspaceCurrency.ts"],"sourcesContent":["import type { UseMutationResult } from '@tanstack/react-query';\nimport { useEffect, useRef, useState } from 'react';\nimport { useHotkeys } from '../utils/hotkeys';\n\nconst DEFAULT_MIN_LENGTH = 3;\nconst DEFAULT_MAX_INTERVAL_MS = 50;\nconst MAX_SCAN_DURATION_MS = 500;\n\nexport interface UseBarcodeScannerOptions<TData, TError, TVariables> {\n mutation: UseMutationResult<TData, TError, TVariables>;\n toVariables: (code: string) => TVariables;\n enabled?: boolean;\n toggleShortcut?: string;\n exitShortcut?: string;\n minLength?: number;\n maxIntervalMs?: number;\n}\n\nexport interface UseBarcodeScannerResult {\n isActive: boolean;\n isPending: boolean;\n enable: () => void;\n disable: () => void;\n toggle: () => void;\n toggleShortcut: string;\n exitShortcut: string;\n}\n\nexport function useBarcodeScanner<TData, TError, TVariables>({\n mutation,\n toVariables,\n enabled = true,\n toggleShortcut = 'alt+s',\n exitShortcut = 'escape',\n minLength = DEFAULT_MIN_LENGTH,\n maxIntervalMs = DEFAULT_MAX_INTERVAL_MS,\n}: UseBarcodeScannerOptions<TData, TError, TVariables>): UseBarcodeScannerResult {\n const [isActive, setIsActive] = useState(false);\n\n const enable = () => setIsActive(true);\n const disable = () => setIsActive(false);\n const toggle = () => setIsActive((v) => !v);\n\n // Auto-disable when the gating condition turns false\n useEffect(() => {\n if (!enabled) setIsActive(false);\n }, [enabled]);\n\n // Cross-platform toggle shortcut\n useHotkeys(toggleShortcut, toggle, { enabled: enabled });\n // Escape exits only when active\n useHotkeys(exitShortcut, disable, { enabled: isActive });\n\n // Keyboard-wedge burst detector\n const bufferRef = useRef('');\n const lastKeyTimeRef = useRef(0);\n const scanStartTimeRef = useRef(0);\n const mutateRef = useRef(mutation.mutate);\n mutateRef.current = mutation.mutate;\n const toVariablesRef = useRef(toVariables);\n toVariablesRef.current = toVariables;\n\n useEffect(() => {\n if (!isActive || !enabled) return;\n\n const handleKeyDown = (event: KeyboardEvent) => {\n const target = event.target as Element | null;\n if (\n target instanceof HTMLInputElement ||\n target instanceof HTMLTextAreaElement ||\n target?.hasAttribute('contenteditable')\n )\n return;\n\n const now = Date.now();\n const gap = now - lastKeyTimeRef.current;\n\n if (event.key === 'Enter') {\n const elapsed = now - scanStartTimeRef.current;\n const code = bufferRef.current;\n bufferRef.current = '';\n lastKeyTimeRef.current = 0;\n scanStartTimeRef.current = 0;\n if (code.length >= minLength && elapsed <= MAX_SCAN_DURATION_MS) {\n event.preventDefault();\n mutateRef.current(toVariablesRef.current(code));\n }\n return;\n }\n\n if (event.key.length !== 1) return;\n\n if (gap > maxIntervalMs && bufferRef.current.length > 0) {\n bufferRef.current = '';\n scanStartTimeRef.current = 0;\n }\n\n if (bufferRef.current.length === 0) scanStartTimeRef.current = now;\n\n bufferRef.current += event.key;\n lastKeyTimeRef.current = now;\n };\n\n window.addEventListener('keydown', handleKeyDown);\n return () => {\n window.removeEventListener('keydown', handleKeyDown);\n bufferRef.current = '';\n lastKeyTimeRef.current = 0;\n scanStartTimeRef.current = 0;\n };\n }, [isActive, enabled, minLength, maxIntervalMs]);\n\n return {\n isActive,\n isPending: mutation.isPending,\n enable,\n disable,\n toggle,\n toggleShortcut,\n exitShortcut,\n };\n}\n","import { useContext, useMemo, useSyncExternalStore } from 'react';\nimport { ThemeContext, type ThemeMode } from '../context/ThemeContext';\nimport { type CategoricalColor, generateCategoricalColors } from '../utils/colors';\n\nfunction subscribeToRootClass(onChange: () => void) {\n const observer = new MutationObserver(onChange);\n observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] });\n return () => observer.disconnect();\n}\n\nconst getRootMode = (): ThemeMode => (document.documentElement.classList.contains('dark') ? 'dark' : 'light');\nconst getServerMode = (): ThemeMode => 'light';\n\n/**\n * Returns `count` generated categorical colors for the active theme (prefix-stable, so growing `count` never\n * repaints existing slots). Reads the mode from `ThemeProvider`; outside a provider it tracks the `.dark` class\n * on `<html>`, which is what drives quantum-ui's theme tokens.\n */\nexport function useCategoricalColors(count: number): CategoricalColor[] {\n const context = useContext(ThemeContext);\n const rootMode = useSyncExternalStore(subscribeToRootClass, getRootMode, getServerMode);\n const mode = context?.theme ?? rootMode;\n return useMemo(() => generateCategoricalColors(count, mode), [count, mode]);\n}\n","import { getOrgCountryCode } from '../utils/country';\n\n// Returns the organization's ISO 3166-1 alpha-2 country as the host recorded it. Throws when the host recorded none: it\n// must record the country with setOrgCountryCode before it renders an organization screen.\nexport function useOrgCountryCode(): string {\n const countryCode = getOrgCountryCode();\n if (!countryCode) {\n throw new Error('No organization country; record it with setOrgCountryCode before rendering');\n }\n return countryCode;\n}\n","import { useParams } from 'react-router-dom';\nimport { parseSlug, unslugify } from '../utils/slug';\n\nexport interface SlugParam {\n slug: string;\n name: string;\n id: string;\n}\n\ntype SlugParamMap<T extends string[]> = { [K in T[number]]: SlugParam };\n\nfunction parseParam(value: string | undefined): SlugParam {\n const v = value ?? '';\n const parsed = parseSlug(v);\n return { slug: v, name: unslugify(parsed?.slug ?? ''), id: parsed?.id ?? v };\n}\n\n// Single param — returns SlugParam directly for clean destructuring\nexport function useSlugParams<T extends string>(param: T): SlugParam;\n// Multiple params — returns { paramA: SlugParam; paramB: SlugParam }\nexport function useSlugParams<T extends string[]>(...params: T): SlugParamMap<T>;\nexport function useSlugParams(...params: string[]): SlugParam | SlugParamMap<string[]> {\n const routeParams = useParams();\n\n if (params.length === 1) {\n return parseParam(routeParams[params[0]]);\n }\n\n const result: Record<string, SlugParam> = {};\n for (const param of params) {\n result[param] = parseParam(routeParams[param]);\n }\n return result;\n}\n","import { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { getConfig } from '../config';\n\nexport interface UseSSEOptions<EventMap extends Record<string, unknown> = Record<string, unknown>> {\n path: string;\n events: (keyof EventMap & string)[];\n enabled?: boolean;\n autoReconnect?: boolean;\n withCredentials?: boolean;\n onError?: (event: Event) => void;\n onOpen?: () => void;\n}\n\nexport interface UseSSEReturn<EventMap extends Record<string, unknown>> {\n eventType: keyof EventMap | null;\n data: EventMap[keyof EventMap] | null;\n eventTypes: { [K in keyof EventMap as Uppercase<K & string>]: K };\n isConnected: boolean;\n error: string | null;\n disconnect: () => void;\n}\n\n// Generic Server-Sent Events hook that returns the last event as `eventType` + `data`.\nexport function useSSE<EventMap extends Record<string, unknown> = Record<string, unknown>>(\n options: UseSSEOptions<EventMap>,\n): UseSSEReturn<EventMap> {\n const { path, events: eventNames = [], enabled = true, withCredentials = true } = options;\n\n const eventSourceRef = useRef<EventSource | null>(null);\n const [eventType, setEventType] = useState<keyof EventMap | null>(null);\n const [data, setData] = useState<EventMap[keyof EventMap] | null>(null);\n const [isConnected, setIsConnected] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n // Store options in a ref for stable access inside event handlers\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n // Stable serialized key for the events array\n const eventsKey = eventNames.join(',');\n\n const disconnect = useCallback(() => {\n if (eventSourceRef.current) {\n eventSourceRef.current.close();\n eventSourceRef.current = null;\n setIsConnected(false);\n }\n }, []);\n\n useEffect(() => {\n if (!enabled) {\n disconnect();\n setEventType(null);\n setData(null);\n return;\n }\n\n // Build full URL from quantum-ui config, letting the app attach whatever an axios request would carry\n // in a header — EventSource cannot set headers, so that context has to ride the query string.\n const config = getConfig();\n const baseUrl = `${config.axios.baseURL}${path}`;\n const sseUrl = config.sse.onRequest?.(baseUrl) ?? baseUrl;\n\n const eventSource = new EventSource(sseUrl, { withCredentials });\n eventSourceRef.current = eventSource;\n\n eventSource.onopen = () => {\n setIsConnected(true);\n setError(null);\n optionsRef.current.onOpen?.();\n };\n\n eventSource.onerror = (event) => {\n setIsConnected(false);\n\n // When autoReconnect is false, close on any error to prevent browser reconnect\n if (!optionsRef.current.autoReconnect && optionsRef.current.autoReconnect !== undefined) {\n eventSource.close();\n eventSourceRef.current = null;\n return;\n }\n\n if (eventSource.readyState === EventSource.CLOSED) {\n setError('Connection lost.');\n optionsRef.current.onError?.(event);\n }\n };\n\n // Register one addEventListener per event name\n const handlers: { name: string; handler: EventListener }[] = [];\n const names = eventsKey.split(',').filter(Boolean);\n\n for (const name of names) {\n const handler = (event: Event) => {\n try {\n const parsed = JSON.parse((event as MessageEvent).data as string);\n setEventType(name as keyof EventMap);\n setData(parsed);\n } catch (e) {\n console.error(`Failed to parse SSE event '${name}':`, e);\n }\n };\n\n eventSource.addEventListener(name, handler);\n handlers.push({ name, handler });\n }\n\n return () => {\n for (const { name, handler } of handlers) {\n eventSource.removeEventListener(name, handler);\n }\n disconnect();\n };\n }, [enabled, path, eventsKey, withCredentials, disconnect]);\n\n // Build UPPER_CASE enum from event names: { INITIATED: 'initiated', VERIFIED: 'verified', ... }\n type EventTypesMap = { [K in keyof EventMap as Uppercase<K & string>]: K };\n const eventTypes = useMemo(() => {\n const map = {} as EventTypesMap;\n for (const name of eventsKey.split(',').filter(Boolean)) {\n (map as Record<string, string>)[name.toUpperCase()] = name;\n }\n return map;\n }, [eventsKey]);\n\n return { eventType, data, eventTypes, isConnected, error, disconnect };\n}\n","import { useEffect, useState } from 'react';\n\nexport interface TimerHandle {\n timer: number;\n startTimer: (seconds?: number) => void;\n}\n\n// Generic countdown timer — decrements every second until 0\nexport function useTimer(initial = 0): TimerHandle {\n const [timer, setTimer] = useState(initial);\n\n useEffect(() => {\n if (timer > 0) {\n const t = setTimeout(() => setTimer(timer - 1), 1000);\n return () => clearTimeout(t);\n }\n }, [timer]);\n\n return { timer, startTimer: (seconds = 45) => setTimer(seconds) };\n}\n","import { useLocation } from 'react-router-dom';\nimport { resolveCurrency } from '../utils/currency';\n\n// Returns the ISO 4217 currency of the active workspace as the host resolves it, re-resolving when the route changes.\n// Pass `siteId` on a screen about one site to ask the host for that site's currency instead. Throws when the host\n// resolves none: it must know every workspace's and site's currency before it renders a workspace screen.\nexport function useWorkspaceCurrency(siteId?: string | null): string {\n useLocation();\n const currency = resolveCurrency(siteId);\n if (!currency) {\n throw new Error(\n siteId\n ? `No currency for site ${siteId}; record it with setWorkspaceCurrency before rendering`\n : 'No currency for the active workspace; record it with setWorkspaceCurrency before rendering',\n );\n }\n return currency;\n}\n"],"names":["useHotkeys"],"mappings":";;;;;;;;;;AAIA,MAAM,kBAAA,GAAqB,CAAA;AAC3B,MAAM,uBAAA,GAA0B,EAAA;AAChC,MAAM,oBAAA,GAAuB,GAAA;AAsBtB,SAAS,iBAAA,CAA6C;AAAA,EAC3D,QAAA;AAAA,EACA,WAAA;AAAA,EACA,OAAA,GAAU,IAAA;AAAA,EACV,cAAA,GAAiB,OAAA;AAAA,EACjB,YAAA,GAAe,QAAA;AAAA,EACf,SAAA,GAAY,kBAAA;AAAA,EACZ,aAAA,GAAgB;AAClB,CAAA,EAAiF;AAC/E,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,SAAS,KAAK,CAAA;AAE9C,EAAA,MAAM,MAAA,GAAS,MAAM,WAAA,CAAY,IAAI,CAAA;AACrC,EAAA,MAAM,OAAA,GAAU,MAAM,WAAA,CAAY,KAAK,CAAA;AACvC,EAAA,MAAM,SAAS,MAAM,WAAA,CAAY,CAAC,CAAA,KAAM,CAAC,CAAC,CAAA;AAG1C,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,OAAA,EAAS,WAAA,CAAY,KAAK,CAAA;AAAA,EACjC,CAAA,EAAG,CAAC,OAAO,CAAC,CAAA;AAGZ,EAAAA,EAAA,CAAW,cAAA,EAAgB,MAAA,EAAQ,EAAE,OAAA,EAAkB,CAAA;AAEvD,EAAAA,EAAA,CAAW,YAAA,EAAc,OAAA,EAAS,EAAE,OAAA,EAAS,UAAU,CAAA;AAGvD,EAAA,MAAM,SAAA,GAAY,OAAO,EAAE,CAAA;AAC3B,EAAA,MAAM,cAAA,GAAiB,OAAO,CAAC,CAAA;AAC/B,EAAA,MAAM,gBAAA,GAAmB,OAAO,CAAC,CAAA;AACjC,EAAA,MAAM,SAAA,GAAY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AA,EAAG;AACb,MAAA,MAAM,IAAI,UAAA,CAAW,MAAM,SAAS,KAAA,GAAQ,CAAC,GAAG,GAAI,CAAA;AACpD,MAAA,OAAO,MAAM,aAAa,CAAC,CAAA;AAAA,IAC7B;AAAA,EACF,CAAA,EAAG,CAAC,KAAK,CAAC,CAAA;AAEV,EAAA,OAAO,EAAE,OAAO,UAAA,EAAY,CAAC,UAAU,EAAA,KAAO,QAAA,CAAS,OAAO,CAAA,EAAE;AAClE;;ACbO,SAAS,qBAAqB,MAAA,EAAgC;AACnE,EAAA,WAAA,EAAY;AACZ,EAAA,MAAM,QAAA,GAAW,gBAAgB,MAAM,CAAA;AACvC,EAAA,IAAI,CAAC,QAAA,EAAU;AACb,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,MAAA,GACI,CAAA,qBAAA,EAAwB,MAAM,CAAA,sDAAA,CAAA,GAC9B;AAAA,KACN;AAAA,EACF;AACA,EAAA,OAAO,QAAA;AACT;;;;"}
1
+ {"version":3,"file":"useWorkspaceCurrency.js","sources":["../lib/hooks/useBarcodeScanner.ts","../lib/hooks/useCategoricalColors.ts","../lib/hooks/useOrgCountryCode.ts","../lib/hooks/useSlugParams.ts","../lib/hooks/useSSE.ts","../lib/hooks/useTimer.ts","../lib/hooks/useWorkspaceCurrency.ts"],"sourcesContent":["import type { UseMutationResult } from '@tanstack/react-query';\nimport { useEffect, useRef, useState } from 'react';\nimport { useHotkeys } from '../utils/hotkeys';\n\nconst DEFAULT_MIN_LENGTH = 3;\nconst DEFAULT_MAX_INTERVAL_MS = 50;\nconst MAX_SCAN_DURATION_MS = 500;\n\nexport interface UseBarcodeScannerOptions<TData, TError, TVariables> {\n mutation: UseMutationResult<TData, TError, TVariables>;\n toVariables: (code: string) => TVariables;\n enabled?: boolean;\n toggleShortcut?: string;\n exitShortcut?: string;\n minLength?: number;\n maxIntervalMs?: number;\n}\n\nexport interface UseBarcodeScannerResult {\n isActive: boolean;\n isPending: boolean;\n enable: () => void;\n disable: () => void;\n toggle: () => void;\n toggleShortcut: string;\n exitShortcut: string;\n}\n\nexport function useBarcodeScanner<TData, TError, TVariables>({\n mutation,\n toVariables,\n enabled = true,\n toggleShortcut = 'alt+s',\n exitShortcut = 'escape',\n minLength = DEFAULT_MIN_LENGTH,\n maxIntervalMs = DEFAULT_MAX_INTERVAL_MS,\n}: UseBarcodeScannerOptions<TData, TError, TVariables>): UseBarcodeScannerResult {\n const [isActive, setIsActive] = useState(false);\n\n const enable = () => setIsActive(true);\n const disable = () => setIsActive(false);\n const toggle = () => setIsActive((v) => !v);\n\n // Auto-disable when the gating condition turns false\n useEffect(() => {\n if (!enabled) setIsActive(false);\n }, [enabled]);\n\n // Cross-platform toggle shortcut\n useHotkeys(toggleShortcut, toggle, { enabled: enabled });\n // Escape exits only when active\n useHotkeys(exitShortcut, disable, { enabled: isActive });\n\n // Keyboard-wedge burst detector\n const bufferRef = useRef('');\n const lastKeyTimeRef = useRef(0);\n const scanStartTimeRef = useRef(0);\n const mutateRef = useRef(mutation.mutate);\n mutateRef.current = mutation.mutate;\n const toVariablesRef = useRef(toVariables);\n toVariablesRef.current = toVariables;\n\n useEffect(() => {\n if (!isActive || !enabled) return;\n\n const handleKeyDown = (event: KeyboardEvent) => {\n const target = event.target as Element | null;\n if (\n target instanceof HTMLInputElement ||\n target instanceof HTMLTextAreaElement ||\n target?.hasAttribute('contenteditable')\n )\n return;\n\n const now = Date.now();\n const gap = now - lastKeyTimeRef.current;\n\n if (event.key === 'Enter') {\n const elapsed = now - scanStartTimeRef.current;\n const code = bufferRef.current;\n bufferRef.current = '';\n lastKeyTimeRef.current = 0;\n scanStartTimeRef.current = 0;\n if (code.length >= minLength && elapsed <= MAX_SCAN_DURATION_MS) {\n event.preventDefault();\n mutateRef.current(toVariablesRef.current(code));\n }\n return;\n }\n\n if (event.key.length !== 1) return;\n\n if (gap > maxIntervalMs && bufferRef.current.length > 0) {\n bufferRef.current = '';\n scanStartTimeRef.current = 0;\n }\n\n if (bufferRef.current.length === 0) scanStartTimeRef.current = now;\n\n bufferRef.current += event.key;\n lastKeyTimeRef.current = now;\n };\n\n window.addEventListener('keydown', handleKeyDown);\n return () => {\n window.removeEventListener('keydown', handleKeyDown);\n bufferRef.current = '';\n lastKeyTimeRef.current = 0;\n scanStartTimeRef.current = 0;\n };\n }, [isActive, enabled, minLength, maxIntervalMs]);\n\n return {\n isActive,\n isPending: mutation.isPending,\n enable,\n disable,\n toggle,\n toggleShortcut,\n exitShortcut,\n };\n}\n","import { useContext, useMemo, useSyncExternalStore } from 'react';\nimport { ThemeContext, type ThemeMode } from '../context/ThemeContext';\nimport { type CategoricalColor, generateCategoricalColors } from '../utils/colors';\n\nfunction subscribeToRootClass(onChange: () => void) {\n const observer = new MutationObserver(onChange);\n observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] });\n return () => observer.disconnect();\n}\n\nconst getRootMode = (): ThemeMode => (document.documentElement.classList.contains('dark') ? 'dark' : 'light');\nconst getServerMode = (): ThemeMode => 'light';\n\n/**\n * Returns `count` generated categorical colors for the active theme (prefix-stable, so growing `count` never\n * repaints existing slots). Reads the mode from `ThemeProvider`; outside a provider it tracks the `.dark` class\n * on `<html>`, which is what drives quantum-ui's theme tokens.\n */\nexport function useCategoricalColors(count: number): CategoricalColor[] {\n const context = useContext(ThemeContext);\n const rootMode = useSyncExternalStore(subscribeToRootClass, getRootMode, getServerMode);\n const mode = context?.theme ?? rootMode;\n return useMemo(() => generateCategoricalColors(count, mode), [count, mode]);\n}\n","import { getOrgCountryCode } from '../utils/country';\n\n// Returns the organization's ISO 3166-1 alpha-2 country as the host recorded it. Throws when the host recorded none: it\n// must record the country with setOrgCountryCode before it renders an organization screen.\nexport function useOrgCountryCode(): string {\n const countryCode = getOrgCountryCode();\n if (!countryCode) {\n throw new Error('No organization country; record it with setOrgCountryCode before rendering');\n }\n return countryCode;\n}\n","import { useParams } from 'react-router-dom';\nimport { parseSlug, unslugify } from '../utils/slug';\n\nexport interface SlugParam {\n slug: string;\n name: string;\n id: string;\n}\n\ntype SlugParamMap<T extends string[]> = { [K in T[number]]: SlugParam };\n\nfunction parseParam(value: string | undefined): SlugParam {\n const v = value ?? '';\n const parsed = parseSlug(v);\n return { slug: v, name: unslugify(parsed?.slug ?? ''), id: parsed?.id ?? v };\n}\n\n// Single param — returns SlugParam directly for clean destructuring\nexport function useSlugParams<T extends string>(param: T): SlugParam;\n// Multiple params — returns { paramA: SlugParam; paramB: SlugParam }\nexport function useSlugParams<T extends string[]>(...params: T): SlugParamMap<T>;\nexport function useSlugParams(...params: string[]): SlugParam | SlugParamMap<string[]> {\n const routeParams = useParams();\n\n if (params.length === 1) {\n return parseParam(routeParams[params[0]]);\n }\n\n const result: Record<string, SlugParam> = {};\n for (const param of params) {\n result[param] = parseParam(routeParams[param]);\n }\n return result;\n}\n","import { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { getConfig } from '../config';\n\nexport interface UseSSEOptions<EventMap extends Record<string, unknown> = Record<string, unknown>> {\n path: string;\n events: (keyof EventMap & string)[];\n enabled?: boolean;\n autoReconnect?: boolean;\n withCredentials?: boolean;\n onError?: (event: Event) => void;\n onOpen?: () => void;\n}\n\nexport interface UseSSEReturn<EventMap extends Record<string, unknown>> {\n eventType: keyof EventMap | null;\n data: EventMap[keyof EventMap] | null;\n eventTypes: { [K in keyof EventMap as Uppercase<K & string>]: K };\n isConnected: boolean;\n error: string | null;\n disconnect: () => void;\n}\n\n// Generic Server-Sent Events hook that returns the last event as `eventType` + `data`.\nexport function useSSE<EventMap extends Record<string, unknown> = Record<string, unknown>>(\n options: UseSSEOptions<EventMap>,\n): UseSSEReturn<EventMap> {\n const { path, events: eventNames = [], enabled = true, withCredentials = true } = options;\n\n const eventSourceRef = useRef<EventSource | null>(null);\n const [eventType, setEventType] = useState<keyof EventMap | null>(null);\n const [data, setData] = useState<EventMap[keyof EventMap] | null>(null);\n const [isConnected, setIsConnected] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n // Store options in a ref for stable access inside event handlers\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n // Stable serialized key for the events array\n const eventsKey = eventNames.join(',');\n\n const disconnect = useCallback(() => {\n if (eventSourceRef.current) {\n eventSourceRef.current.close();\n eventSourceRef.current = null;\n setIsConnected(false);\n }\n }, []);\n\n useEffect(() => {\n if (!enabled) {\n disconnect();\n setEventType(null);\n setData(null);\n return;\n }\n\n // Build full URL from quantum-ui config, letting the app attach whatever an axios request would carry\n // in a header — EventSource cannot set headers, so that context has to ride the query string.\n const config = getConfig();\n const baseUrl = `${config.axios.baseURL}${path}`;\n const sseUrl = config.sse.onRequest?.(baseUrl) ?? baseUrl;\n\n const eventSource = new EventSource(sseUrl, { withCredentials });\n eventSourceRef.current = eventSource;\n\n eventSource.onopen = () => {\n setIsConnected(true);\n setError(null);\n optionsRef.current.onOpen?.();\n };\n\n eventSource.onerror = (event) => {\n setIsConnected(false);\n\n // When autoReconnect is false, close on any error to prevent browser reconnect\n if (!optionsRef.current.autoReconnect && optionsRef.current.autoReconnect !== undefined) {\n eventSource.close();\n eventSourceRef.current = null;\n return;\n }\n\n if (eventSource.readyState === EventSource.CLOSED) {\n setError('Connection lost.');\n optionsRef.current.onError?.(event);\n }\n };\n\n // Register one addEventListener per event name\n const handlers: { name: string; handler: EventListener }[] = [];\n const names = eventsKey.split(',').filter(Boolean);\n\n for (const name of names) {\n const handler = (event: Event) => {\n try {\n const parsed = JSON.parse((event as MessageEvent).data as string);\n setEventType(name as keyof EventMap);\n setData(parsed);\n } catch (e) {\n console.error(`Failed to parse SSE event '${name}':`, e);\n }\n };\n\n eventSource.addEventListener(name, handler);\n handlers.push({ name, handler });\n }\n\n return () => {\n for (const { name, handler } of handlers) {\n eventSource.removeEventListener(name, handler);\n }\n disconnect();\n };\n }, [enabled, path, eventsKey, withCredentials, disconnect]);\n\n // Build UPPER_CASE enum from event names: { INITIATED: 'initiated', VERIFIED: 'verified', ... }\n type EventTypesMap = { [K in keyof EventMap as Uppercase<K & string>]: K };\n const eventTypes = useMemo(() => {\n const map = {} as EventTypesMap;\n for (const name of eventsKey.split(',').filter(Boolean)) {\n (map as Record<string, string>)[name.toUpperCase()] = name;\n }\n return map;\n }, [eventsKey]);\n\n return { eventType, data, eventTypes, isConnected, error, disconnect };\n}\n","import { useEffect, useState } from 'react';\n\nexport interface TimerHandle {\n timer: number;\n startTimer: (seconds?: number) => void;\n}\n\n// Generic countdown timer — decrements every second until 0\nexport function useTimer(initial = 0): TimerHandle {\n const [timer, setTimer] = useState(initial);\n\n useEffect(() => {\n if (timer > 0) {\n const t = setTimeout(() => setTimer(timer - 1), 1000);\n return () => clearTimeout(t);\n }\n }, [timer]);\n\n return { timer, startTimer: (seconds = 45) => setTimer(seconds) };\n}\n","import { useLocation } from 'react-router-dom';\nimport { type CurrencyCode, resolveCurrency } from '../utils/currency';\n\n// Returns the ISO 4217 currency of the active workspace as the host resolves it, re-resolving when the route changes.\n// Pass `siteId` on a screen about one site to ask the host for that site's currency instead. Throws when the host\n// resolves none: it must know every workspace's and site's currency before it renders a workspace screen.\nexport function useWorkspaceCurrency(siteId?: string | null): CurrencyCode {\n useLocation();\n const currency = resolveCurrency(siteId);\n if (!currency) {\n throw new Error(\n siteId\n ? `No currency for site ${siteId}; record it with setWorkspaceCurrency before rendering`\n : 'No currency for the active workspace; record it with setWorkspaceCurrency before rendering',\n );\n }\n return currency;\n}\n"],"names":["useHotkeys"],"mappings":";;;;;;;;;;AAIA,MAAM,kBAAA,GAAqB,CAAA;AAC3B,MAAM,uBAAA,GAA0B,EAAA;AAChC,MAAM,oBAAA,GAAuB,GAAA;AAsBtB,SAAS,iBAAA,CAA6C;AAAA,EAC3D,QAAA;AAAA,EACA,WAAA;AAAA,EACA,OAAA,GAAU,IAAA;AAAA,EACV,cAAA,GAAiB,OAAA;AAAA,EACjB,YAAA,GAAe,QAAA;AAAA,EACf,SAAA,GAAY,kBAAA;AAAA,EACZ,aAAA,GAAgB;AAClB,CAAA,EAAiF;AAC/E,EAAA,M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AAA,qBAAA,EAAwB,MAAM,CAAA,sDAAA,CAAA,GAC9B;AAAA,KACN;AAAA,EACF;AACA,EAAA,OAAO,QAAA;AACT;;;;"}
@@ -1,16 +1,6 @@
1
- import { c as currencies } from '../index10.js';
1
+ import { C as CUSTOM_CURRENCY_EXPONENTS, c as currencies, i as isCurrencyCode } from '../currencyCode.js';
2
2
  import { g as getConfig } from '../index6.js';
3
3
 
4
- const CUSTOM_CURRENCY_EXPONENTS = {
5
- ANG: 2,
6
- HRK: 2,
7
- XAG: 0,
8
- XAU: 0,
9
- XDR: 0,
10
- XPD: 0,
11
- XPT: 0,
12
- ZWL: 2
13
- };
14
4
  function getCurrencyExponent(code) {
15
5
  const custom = CUSTOM_CURRENCY_EXPONENTS[code];
16
6
  if (custom !== void 0) return custom;
@@ -23,8 +13,7 @@ const WORKSPACE_CURRENCY_PREFIX = "vritti_";
23
13
  const canUseStorage = () => typeof window !== "undefined";
24
14
  const normalizeCurrencyCode = (code) => {
25
15
  const trimmed = code?.trim().toUpperCase();
26
- if (!trimmed) return null;
27
- return /^[A-Z]{3}$/.test(trimmed) ? trimmed : null;
16
+ return isCurrencyCode(trimmed) ? trimmed : null;
28
17
  };
29
18
  const getWorkspaceCurrencyStorageKey = (workspaceId) => `${WORKSPACE_CURRENCY_PREFIX}${workspaceId}${WORKSPACE_CURRENCY_SUFFIX}`;
30
19
  function setWorkspaceCurrency(workspaceId, code) {
@@ -44,5 +33,5 @@ function resolveCurrency(siteId) {
44
33
  return normalizeCurrencyCode(getConfig().currency.resolveCurrency?.(siteId));
45
34
  }
46
35
 
47
- export { getCurrencyExponent, getWorkspaceCurrency, resolveCurrency, setWorkspaceCurrency };
36
+ export { getCurrencyExponent, getWorkspaceCurrency, isCurrencyCode, resolveCurrency, setWorkspaceCurrency };
48
37
  //# sourceMappingURL=currency.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"currency.js","sources":["../../lib/utils/currency.ts"],"sourcesContent":["import * as currencies from 'dinero.js/bigint/currencies';\nimport { getConfig } from '../config';\n\nexport type CurrencyValue = { currency: string; value: string };\n\nconst CUSTOM_CURRENCY_EXPONENTS: Record<string, number> = {\n ANG: 2,\n HRK: 2,\n XAG: 0,\n XAU: 0,\n XDR: 0,\n XPD: 0,\n XPT: 0,\n ZWL: 2,\n};\n\nexport function getCurrencyExponent(code: string): number {\n const custom = CUSTOM_CURRENCY_EXPONENTS[code];\n if (custom !== undefined) return custom;\n const currency = (currencies as Record<string, { exponent: bigint | number } | undefined>)[code];\n if (!currency) return 2;\n return Number(currency.exponent);\n}\n\nconst WORKSPACE_CURRENCY_SUFFIX = '_currency';\nconst WORKSPACE_CURRENCY_PREFIX = 'vritti_';\n\nconst canUseStorage = () => typeof window !== 'undefined';\n\nconst normalizeCurrencyCode = (code: string | null | undefined): string | null => {\n const trimmed = code?.trim().toUpperCase();\n if (!trimmed) return null;\n return /^[A-Z]{3}$/.test(trimmed) ? trimmed : null;\n};\n\nconst getWorkspaceCurrencyStorageKey = (workspaceId: string) =>\n `${WORKSPACE_CURRENCY_PREFIX}${workspaceId}${WORKSPACE_CURRENCY_SUFFIX}`;\n\n// Records the currency a workspace (org, site group, legal entity or site) prices in, keyed by its id\nexport function setWorkspaceCurrency(workspaceId: string, code: string): void {\n if (!canUseStorage()) return;\n const normalizedWorkspaceId = workspaceId.trim();\n const normalized = normalizeCurrencyCode(code);\n if (!normalizedWorkspaceId || !normalized) return;\n localStorage.setItem(getWorkspaceCurrencyStorageKey(normalizedWorkspaceId), normalized);\n}\n\nexport function getWorkspaceCurrency(workspaceId: string): string | null {\n if (!canUseStorage()) return null;\n const normalizedWorkspaceId = workspaceId.trim();\n if (!normalizedWorkspaceId) return null;\n return normalizeCurrencyCode(localStorage.getItem(getWorkspaceCurrencyStorageKey(normalizedWorkspaceId)));\n}\n\n// The active workspace's currency, or one site's when `siteId` is given, as the host resolves it; null when it has none\nexport function resolveCurrency(siteId?: string | null): string | null {\n return normalizeCurrencyCode(getConfig().currency.resolveCurrency?.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IAAI,CAAA;AAC7C,EAAA,IAAI,CAAC,qBAAA,IAAyB,CAAC,UAAA,EAAY;AAC3C,EAAA,YAAA,CAAa,OAAA,CAAQ,8BAAA,CAA+B,qBAAqB,CAAA,EAAG,UAAU,CAAA;AACxF;AAEO,SAAS,qBAAqB,WAAA,EAAoC;AACvE,EAAA,IAAI,CAAC,aAAA,EAAc,EAAG,OAAO,IAAA;AAC7B,EAAA,MAAM,qBAAA,GAAwB,YAAY,IAAA,EAAK;AAC/C,EAAA,IAAI,CAAC,uBAAuB,OAAO,IAAA;AACnC,EAAA,OAAO,sBAAsB,YAAA,CAAa,OAAA,CAAQ,8BAAA,CAA+B,qBAAqB,CAAC,CAAC,CAAA;AAC1G;AAGO,SAAS,gBAAgB,MAAA,EAAuC;AACrE,EAAA,OAAO,sBAAsB,SAAA,EAAU,CAAE,QAAA,CAAS,eAAA,GAAkB,MAAM,CAAC,CAAA;AAC7E;;;;"}
1
+ {"version":3,"file":"currency.js","sources":["../../lib/utils/currency.ts"],"sourcesContent":["import * as currencies from 'dinero.js/bigint/currencies';\nimport { getConfig } from '../config';\nimport { CUSTOM_CURRENCY_EXPONENTS, type CurrencyCode, isCurrencyCode } from './currencyCode';\n\nexport { type CurrencyCode, isCurrencyCode } from './currencyCode';\n\n// A money amount: its currency and a major-unit amount string\nexport type CurrencyValue = { currency: CurrencyCode; value: string };\n\nexport function getCurrencyExponent(code: CurrencyCode): number {\n const custom = (CUSTOM_CURRENCY_EXPONENTS as Record<string, number | undefined>)[code];\n if (custom !== undefined) return custom;\n const currency = (currencies as Record<string, { exponent: bigint | number } | undefined>)[code];\n if (!currency) return 2;\n return Number(currency.exponent);\n}\n\nconst WORKSPACE_CURRENCY_SUFFIX = '_currency';\nconst WORKSPACE_CURRENCY_PREFIX = 'vritti_';\n\nconst canUseStorage = () => typeof window !== 'undefined';\n\nconst normalizeCurrencyCode = (code: string | null | undefined): CurrencyCode | null => {\n const trimmed = code?.trim().toUpperCase();\n return isCurrencyCode(trimmed) ? trimmed : null;\n};\n\nconst getWorkspaceCurrencyStorageKey = (workspaceId: string) =>\n `${WORKSPACE_CURRENCY_PREFIX}${workspaceId}${WORKSPACE_CURRENCY_SUFFIX}`;\n\n// Records the currency a workspace (org, site group, legal entity or site) prices in, keyed by its id\nexport function setWorkspaceCurrency(workspaceId: string, code: CurrencyCode): void {\n if (!canUseStorage()) return;\n const normalizedWorkspaceId = workspaceId.trim();\n const normalized = normalizeCurrencyCode(code);\n if (!normalizedWorkspaceId || !normalized) return;\n localStorage.setItem(getWorkspaceCurrencyStorageKey(normalizedWorkspaceId), normalized);\n}\n\nexport function getWorkspaceCurrency(workspaceId: string): CurrencyCode | null {\n if (!canUseStorage()) return null;\n const normalizedWorkspaceId = workspaceId.trim();\n if (!normalizedWorkspaceId) return null;\n return normalizeCurrencyCode(localStorage.getItem(getWorkspaceCurrencyStorageKey(normalizedWorkspaceId)));\n}\n\n// The active workspace's currency, or one site's when `siteId` is given, as the host resolves it; null when it has none\nexport function resolveCurrency(siteId?: string | null): CurrencyCode | null {\n return normalizeCurrencyCode(getConfig().currency.resolveCurrency?.(siteId));\n}\n"],"names":[],"mappings":";;;AASO,SAAS,oBAAoB,IAAA,EAA4B;AAC9D,EAAA,MAAM,MAAA,GAAU,0BAAiE,IAAI,CAAA;AACrF,EAAA,IAAI,MAAA,KAAW,QAAW,OAAO,MAAA;AACjC,EAAA,MAAM,QAAA,GAAY,WAAyE,IAAI,CAAA;AAC/F,EAAA,IAAI,CAAC,UAAU,OAAO,CAAA;AACtB,EAAA,OAAO,MAAA,CAAO,SAAS,QAAQ,CAAA;AACjC;AAEA,MAAM,yBAAA,GAA4B,WAAA;AAClC,MAAM,yBAAA,GAA4B,SAAA;AAElC,MAAM,aAAA,GAAgB,MAAM,OAAO,MAAA,KAAW,WAAA;AAE9C,MAAM,qBAAA,GAAwB,CAAC,IAAA,KAAyD;AACtF,EAAA,MAAM,OAAA,GAAU,IAAA,EAAM,IAAA,EAAK,CAAE,WAAA,EAAY;AACzC,EAAA,OAAO,cAAA,CAAe,OAAO,CAAA,GAAI,OAAA,GAAU,IAAA;AAC7C,CAAA;AAEA,MAAM,8BAAA,GAAiC,CAAC,WAAA,KACtC,CAAA,EAAG,yBAAyB,CAAA,EAAG,WAAW,GAAG,yBAAyB,CAAA,CAAA;AAGjE,SAAS,oBAAA,CAAqB,aAAqB,IAAA,EAA0B;AAClF,EAAA,IAAI,CAAC,eAAc,EAAG;AACtB,EAAA,MAAM,qBAAA,GAAwB,YAAY,IAAA,EAAK;AAC/C,EAAA,MAAM,UAAA,GAAa,sBAAsB,IAAI,CAAA;AAC7C,EAAA,IAAI,CAAC,qBAAA,IAAyB,CAAC,UAAA,EAAY;AAC3C,EAAA,YAAA,CAAa,OAAA,CAAQ,8BAAA,CAA+B,qBAAqB,CAAA,EAAG,UAAU,CAAA;AACxF;AAEO,SAAS,qBAAqB,WAAA,EAA0C;AAC7E,EAAA,IAAI,CAAC,aAAA,EAAc,EAAG,OAAO,IAAA;AAC7B,EAAA,MAAM,qBAAA,GAAwB,YAAY,IAAA,EAAK;AAC/C,EAAA,IAAI,CAAC,uBAAuB,OAAO,IAAA;AACnC,EAAA,OAAO,sBAAsB,YAAA,CAAa,OAAA,CAAQ,8BAAA,CAA+B,qBAAqB,CAAC,CAAC,CAAA;AAC1G;AAGO,SAAS,gBAAgB,MAAA,EAA6C;AAC3E,EAAA,OAAO,sBAAsB,SAAA,EAAU,CAAE,QAAA,CAAS,eAAA,GAAkB,MAAM,CAAC,CAAA;AAC7E;;;;"}
@@ -51,12 +51,20 @@ const formatQuantity = (value, options) => {
51
51
  if (!value.isPack) {
52
52
  return { primary: `${number.format(value.displayUomQty)} ${value.displayUomSymbol}`, secondary: inPrimary };
53
53
  }
54
- if (value.wholeDisplayUomQty === 0) return { primary: inPrimary };
55
- const packs = `${number.format(value.wholeDisplayUomQty)} ${value.displayUomSymbol}`;
56
- if (value.remainderPrimaryUomQty === 0) return { primary: packs, secondary: inPrimary };
57
- const sign = value.remainderPrimaryUomQty < 0 ? "−" : "+";
58
- const remainder = `${number.format(Math.abs(value.remainderPrimaryUomQty))} ${value.primaryUomSymbol}`;
59
- return { primary: `${packs} ${sign} ${remainder}`, secondary: inPrimary };
54
+ const parts = value.breakdown?.length ? value.breakdown : [
55
+ { qty: value.wholeDisplayUomQty, symbol: value.displayUomSymbol },
56
+ { qty: value.remainderPrimaryUomQty, symbol: value.primaryUomSymbol }
57
+ ].filter((part) => part.qty !== 0);
58
+ if (parts.length === 0 || parts.length === 1 && parts[0].symbol === value.primaryUomSymbol) {
59
+ return { primary: inPrimary };
60
+ }
61
+ const sign = value.primaryUomQty < 0 ? "−" : "+";
62
+ const [first, ...rest] = parts;
63
+ const reading = [
64
+ `${number.format(first.qty)} ${first.symbol}`,
65
+ ...rest.map((part) => `${sign} ${number.format(Math.abs(part.qty))} ${part.symbol}`)
66
+ ].join(" ");
67
+ return { primary: reading, secondary: inPrimary };
60
68
  };
61
69
  const formatCurrency = (value, options = {}) => {
62
70
  if (value == null) return { primary: "—" };
@@ -1 +1 @@
1
- {"version":3,"file":"format.js","sources":["../../lib/utils/format.ts"],"sourcesContent":["// Pure value-formatting helpers (no hooks) returning { primary, secondary? } for DetailField, DataTable cells, etc.\nimport { tz } from '@date-fns/tz';\nimport type { Locale } from 'date-fns';\nimport { format, isValid, parseISO } from 'date-fns';\nimport type React from 'react';\nimport Decimal from './decimal';\nimport { formatCurrencyMajor } from './money';\nimport { getUserTimeZone } from './timezone';\n\nexport type CurrencyAmount = { currency: string; value: string };\n\nexport type FormattedValue = { primary: React.ReactNode; secondary?: string };\n\nconst DATE_ONLY_PATTERN = /^\\d{4}-\\d{2}-\\d{2}$/;\n\nconst formatWithTimeZone = (date: Date, dateFormat: string, timeZone: string, locale?: Locale) =>\n format(date, dateFormat, locale ? { in: tz(timeZone), locale } : { in: tz(timeZone) });\n\nconst parseDateOnly = (value: string): Date => parseISO(DATE_ONLY_PATTERN.test(value) ? `${value}T00:00:00Z` : value);\n\nexport const formatString = (value: React.ReactNode): FormattedValue => {\n if (value == null) return { primary: '—' };\n // Treat empty/whitespace strings as \"no value\", but let JSX/element values pass through untouched.\n if (typeof value === 'string' && value.trim() === '') return { primary: '—' };\n return { primary: value };\n};\n\n// One Intl.NumberFormat per locale and options, reused: building one costs far more than formatting with it, and a\n// table formats the same few shapes on every row\nconst numberFormatters = new Map<string, Intl.NumberFormat>();\nfunction numberFormatter(localeTag: string, options?: Intl.NumberFormatOptions): Intl.NumberFormat {\n const key = `${localeTag}|${JSON.stringify(options ?? {})}`;\n const cached = numberFormatters.get(key);\n if (cached) return cached;\n const formatter = new Intl.NumberFormat(localeTag, options);\n numberFormatters.set(key, formatter);\n return formatter;\n}\n\nexport interface FormatNumberOptions {\n localeTag: string;\n fractionDigits?: number;\n}\n\nexport const formatNumber = (\n value: number | string | null | undefined,\n options: FormatNumberOptions,\n): FormattedValue => {\n if (value == null) return { primary: '—' };\n const num = typeof value === 'number' ? value : Number(value);\n if (!Number.isFinite(num)) return { primary: '—' };\n const formatter = numberFormatter(\n options.localeTag,\n options.fractionDigits != null\n ? { minimumFractionDigits: options.fractionDigits, maximumFractionDigits: options.fractionDigits }\n : undefined,\n );\n return { primary: formatter.format(num) };\n};\n\nexport interface FormatPercentOptions {\n localeTag: string;\n maximumFractionDigits?: number;\n}\n\n// Formats a percentage given on a 0–100 scale (42.5 → \"42.5%\"), one decimal at most unless told otherwise\nexport const formatPercent = (\n value: number | string | null | undefined,\n options: FormatPercentOptions,\n): FormattedValue => {\n if (value == null) return { primary: '—' };\n const num = typeof value === 'number' ? value : Number(value);\n if (!Number.isFinite(num)) return { primary: '—' };\n const formatter = numberFormatter(options.localeTag, {\n style: 'percent',\n maximumFractionDigits: options.maximumFractionDigits ?? 1,\n });\n return { primary: formatter.format(new Decimal(num).div(100).toNumber()) };\n};\n\nexport type DisplayQuantity = {\n primaryUomQty: number;\n displayUomQty: number;\n wholeDisplayUomQty: number;\n remainderPrimaryUomQty: number;\n displayUomSymbol: string;\n primaryUomSymbol: string;\n isPack: boolean;\n};\n\nexport interface FormatQuantityOptions {\n localeTag: string;\n}\n\n// Formats an item quantity in its display unit: a pack unit as whole packs plus the primary units left over (\"234 strip\n// + 4 tab\"), any other unit as one figure (\"12.5 kg\"); the primary-unit total is the secondary whenever it differs\nexport const formatQuantity = (\n value: DisplayQuantity | null | undefined,\n options: FormatQuantityOptions,\n): FormattedValue => {\n if (value == null) return { primary: '—' };\n const number = numberFormatter(options.localeTag);\n const inPrimary = `${number.format(value.primaryUomQty)} ${value.primaryUomSymbol}`;\n if (value.displayUomSymbol === value.primaryUomSymbol) return { primary: inPrimary };\n // Nothing is nothing in either unit, so it reads in the display unit the item's other quantities use\n if (value.primaryUomQty === 0) return { primary: `${number.format(0)} ${value.displayUomSymbol}` };\n if (!value.isPack) {\n return { primary: `${number.format(value.displayUomQty)} ${value.displayUomSymbol}`, secondary: inPrimary };\n }\n if (value.wholeDisplayUomQty === 0) return { primary: inPrimary };\n const packs = `${number.format(value.wholeDisplayUomQty)} ${value.displayUomSymbol}`;\n if (value.remainderPrimaryUomQty === 0) return { primary: packs, secondary: inPrimary };\n const sign = value.remainderPrimaryUomQty < 0 ? '−' : '+';\n const remainder = `${number.format(Math.abs(value.remainderPrimaryUomQty))} ${value.primaryUomSymbol}`;\n return { primary: `${packs} ${sign} ${remainder}`, secondary: inPrimary };\n};\n\nexport interface FormatCurrencyOptions {\n workspaceCurrency?: string | null;\n exchangeRate?: number | null;\n}\n\nexport const formatCurrency = (\n value: CurrencyAmount | null | undefined,\n options: FormatCurrencyOptions = {},\n): FormattedValue => {\n if (value == null) return { primary: '—' };\n const { currency, value: amountStr } = value;\n const amount = Number(amountStr);\n if (!Number.isFinite(amount)) return { primary: '—' };\n const primary = formatCurrencyMajor(amount, currency);\n\n const { workspaceCurrency, exchangeRate } = options;\n if (exchangeRate != null && Number.isFinite(exchangeRate) && workspaceCurrency && workspaceCurrency !== currency) {\n const workspaceAmount = new Decimal(amountStr).times(exchangeRate).toNumber();\n if (Number.isFinite(workspaceAmount)) {\n return { primary, secondary: `(${formatCurrencyMajor(workspaceAmount, workspaceCurrency)})` };\n }\n }\n return { primary };\n};\n\nexport interface FormatDateOptions {\n locale?: Locale;\n}\n\nexport const formatDate = (value: string | null | undefined, options: FormatDateOptions = {}): FormattedValue => {\n if (value == null) return { primary: '—' };\n const parsed = DATE_ONLY_PATTERN.test(value) ? parseDateOnly(value) : parseISO(value);\n if (!isValid(parsed)) return { primary: '—' };\n // Render date-only values in UTC so the displayed day matches the stored YYYY-MM-DD.\n return { primary: formatWithTimeZone(parsed, 'P', 'UTC', options.locale) };\n};\n\nexport interface FormatDateTimeOptions {\n locale?: Locale;\n workspaceTimeZone?: string | null;\n timeZoneOverride?: string;\n}\n\nexport const formatDateTime = (\n value: string | null | undefined,\n options: FormatDateTimeOptions = {},\n): FormattedValue => {\n if (value == null) return { primary: '—' };\n const parsed = parseISO(value);\n if (!isValid(parsed)) return { primary: '—' };\n\n const primaryTz = options.timeZoneOverride ?? options.workspaceTimeZone ?? null;\n if (!primaryTz) {\n return { primary: format(parsed, 'Pp', options.locale ? { locale: options.locale } : undefined) };\n }\n const primary = `${formatWithTimeZone(parsed, 'Pp', primaryTz, options.locale)} (${primaryTz})`;\n const userTz = getUserTimeZone();\n if (!userTz || userTz === primaryTz) return { primary };\n return {\n primary,\n secondary: `Your time: ${formatWithTimeZone(parsed, 'Pp', userTz, options.locale)} (${userTz})`,\n };\n};\n"],"names":[],"mappings":";;;;;;;AAaA,MAAM,iBAAA,GAAoB,qBAAA;AAE1B,MAAM,kBAAA,GAAqB,CAAC,IAAA,EAAY,UAAA,EAAoB,UAAkB,MAAA,KAC5E,MAAA,CAAO,IAAA,EAAM,UAAA,EAAY,MAAA,GAAS,EAAE,IAAI,EAAA,CAAG,QAAQ,GAAG,MAAA,EAAO,GAAI,EAAE,EAAA,EAAI,EAAA,CAAG,QAAQ,CAAA,EAAG,CAAA;AAEvF,MAAM,aAAA,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../../lib/utils/format.ts"],"sourcesContent":["// Pure value-formatting helpers (no hooks) returning { primary, secondary? } for DetailField, DataTable cells, etc.\nimport { tz } from '@date-fns/tz';\nimport type { Locale } from 'date-fns';\nimport { format, isValid, parseISO } from 'date-fns';\nimport type React from 'react';\nimport type { CurrencyCode, CurrencyValue } from './currency';\nimport Decimal from './decimal';\nimport { formatCurrencyMajor } from './money';\nimport { getUserTimeZone } from './timezone';\n\nexport type CurrencyAmount = CurrencyValue;\n\nexport type FormattedValue = { primary: React.ReactNode; secondary?: string };\n\nconst DATE_ONLY_PATTERN = /^\\d{4}-\\d{2}-\\d{2}$/;\n\nconst formatWithTimeZone = (date: Date, dateFormat: string, timeZone: string, locale?: Locale) =>\n format(date, dateFormat, locale ? { in: tz(timeZone), locale } : { in: tz(timeZone) });\n\nconst parseDateOnly = (value: string): Date => parseISO(DATE_ONLY_PATTERN.test(value) ? `${value}T00:00:00Z` : value);\n\nexport const formatString = (value: React.ReactNode): FormattedValue => {\n if (value == null) return { primary: '—' };\n // Treat empty/whitespace strings as \"no value\", but let JSX/element values pass through untouched.\n if (typeof value === 'string' && value.trim() === '') return { primary: '—' };\n return { primary: value };\n};\n\n// One Intl.NumberFormat per locale and options, reused: building one costs far more than formatting with it, and a\n// table formats the same few shapes on every row\nconst numberFormatters = new Map<string, Intl.NumberFormat>();\nfunction numberFormatter(localeTag: string, options?: Intl.NumberFormatOptions): Intl.NumberFormat {\n const key = `${localeTag}|${JSON.stringify(options ?? {})}`;\n const cached = numberFormatters.get(key);\n if (cached) return cached;\n const formatter = new Intl.NumberFormat(localeTag, options);\n numberFormatters.set(key, formatter);\n return formatter;\n}\n\nexport interface FormatNumberOptions {\n localeTag: string;\n fractionDigits?: number;\n}\n\nexport const formatNumber = (\n value: number | string | null | undefined,\n options: FormatNumberOptions,\n): FormattedValue => {\n if (value == null) return { primary: '—' };\n const num = typeof value === 'number' ? value : Number(value);\n if (!Number.isFinite(num)) return { primary: '—' };\n const formatter = numberFormatter(\n options.localeTag,\n options.fractionDigits != null\n ? { minimumFractionDigits: options.fractionDigits, maximumFractionDigits: options.fractionDigits }\n : undefined,\n );\n return { primary: formatter.format(num) };\n};\n\nexport interface FormatPercentOptions {\n localeTag: string;\n maximumFractionDigits?: number;\n}\n\n// Formats a percentage given on a 0–100 scale (42.5 → \"42.5%\"), one decimal at most unless told otherwise\nexport const formatPercent = (\n value: number | string | null | undefined,\n options: FormatPercentOptions,\n): FormattedValue => {\n if (value == null) return { primary: '—' };\n const num = typeof value === 'number' ? value : Number(value);\n if (!Number.isFinite(num)) return { primary: '—' };\n const formatter = numberFormatter(options.localeTag, {\n style: 'percent',\n maximumFractionDigits: options.maximumFractionDigits ?? 1,\n });\n return { primary: formatter.format(new Decimal(num).div(100).toNumber()) };\n};\n\nexport type DisplayQuantity = {\n primaryUomQty: number;\n displayUomQty: number;\n wholeDisplayUomQty: number;\n remainderPrimaryUomQty: number;\n displayUomSymbol: string;\n primaryUomSymbol: string;\n isPack: boolean;\n // The quantity broken down by unit, largest first, zero shares left out — whole display packs, the item's smaller\n // packs when it cascades its units, then the primary units left over; absent, it is the whole packs and the leftover\n breakdown?: { qty: number; symbol: string }[];\n};\n\nexport interface FormatQuantityOptions {\n localeTag: string;\n}\n\n// Formats an item quantity in its display unit: a pack unit as its breakdown (\"234 strip + 4 tab\", or \"9 box + 5 strip +\n// 2 tab\" for an item that cascades its units), any other unit as one figure (\"12.5 kg\"); the primary-unit total is the\n// secondary whenever it differs\nexport const formatQuantity = (\n value: DisplayQuantity | null | undefined,\n options: FormatQuantityOptions,\n): FormattedValue => {\n if (value == null) return { primary: '—' };\n const number = numberFormatter(options.localeTag);\n const inPrimary = `${number.format(value.primaryUomQty)} ${value.primaryUomSymbol}`;\n if (value.displayUomSymbol === value.primaryUomSymbol) return { primary: inPrimary };\n // Nothing is nothing in either unit, so it reads in the display unit the item's other quantities use\n if (value.primaryUomQty === 0) return { primary: `${number.format(0)} ${value.displayUomSymbol}` };\n if (!value.isPack) {\n return { primary: `${number.format(value.displayUomQty)} ${value.displayUomSymbol}`, secondary: inPrimary };\n }\n const parts = value.breakdown?.length\n ? value.breakdown\n : [\n { qty: value.wholeDisplayUomQty, symbol: value.displayUomSymbol },\n { qty: value.remainderPrimaryUomQty, symbol: value.primaryUomSymbol },\n ].filter((part) => part.qty !== 0);\n // Less than one of the smallest pack reads in the primary unit alone, as does a sliver every share rounds away\n if (parts.length === 0 || (parts.length === 1 && parts[0].symbol === value.primaryUomSymbol)) {\n return { primary: inPrimary };\n }\n // A negative quantity splits toward zero, so every share after the first is taken off it\n const sign = value.primaryUomQty < 0 ? '−' : '+';\n const [first, ...rest] = parts;\n const reading = [\n `${number.format(first.qty)} ${first.symbol}`,\n ...rest.map((part) => `${sign} ${number.format(Math.abs(part.qty))} ${part.symbol}`),\n ].join(' ');\n return { primary: reading, secondary: inPrimary };\n};\n\nexport interface FormatCurrencyOptions {\n workspaceCurrency?: CurrencyCode | null;\n exchangeRate?: number | null;\n}\n\nexport const formatCurrency = (\n value: CurrencyAmount | null | undefined,\n options: FormatCurrencyOptions = {},\n): FormattedValue => {\n if (value == null) return { primary: '—' };\n const { currency, value: amountStr } = value;\n const amount = Number(amountStr);\n if (!Number.isFinite(amount)) return { primary: '—' };\n const primary = formatCurrencyMajor(amount, currency);\n\n const { workspaceCurrency, exchangeRate } = options;\n if (exchangeRate != null && Number.isFinite(exchangeRate) && workspaceCurrency && workspaceCurrency !== currency) {\n const workspaceAmount = new Decimal(amountStr).times(exchangeRate).toNumber();\n if (Number.isFinite(workspaceAmount)) {\n return { primary, secondary: `(${formatCurrencyMajor(workspaceAmount, workspaceCurrency)})` };\n }\n }\n return { primary };\n};\n\nexport interface FormatDateOptions {\n locale?: Locale;\n}\n\nexport const formatDate = (value: string | null | undefined, options: FormatDateOptions = {}): FormattedValue => {\n if (value == null) return { primary: '—' };\n const parsed = DATE_ONLY_PATTERN.test(value) ? parseDateOnly(value) : parseISO(value);\n if (!isValid(parsed)) return { primary: '—' };\n // Render date-only values in UTC so the displayed day matches the stored YYYY-MM-DD.\n return { primary: formatWithTimeZone(parsed, 'P', 'UTC', options.locale) };\n};\n\nexport interface FormatDateTimeOptions {\n locale?: Locale;\n workspaceTimeZone?: string | null;\n timeZoneOverride?: string;\n}\n\nexport const formatDateTime = (\n value: string | null | undefined,\n options: FormatDateTimeOptions = {},\n): FormattedValue => {\n if (value == null) return { primary: '—' };\n const parsed = parseISO(value);\n if (!isValid(parsed)) return { primary: '—' };\n\n const primaryTz = options.timeZoneOverride ?? options.workspaceTimeZone ?? null;\n if (!primaryTz) {\n return { primary: format(parsed, 'Pp', options.locale ? { locale: options.locale } : undefined) };\n }\n const primary = `${formatWithTimeZone(parsed, 'Pp', primaryTz, options.locale)} (${primaryTz})`;\n const userTz = getUserTimeZone();\n if (!userTz || userTz === primaryTz) return { primary };\n return {\n primary,\n secondary: `Your time: ${formatWithTimeZone(parsed, 'Pp', userTz, options.locale)} (${userTz})`,\n };\n};\n"],"names":[],"mappings":";;;;;;;AAcA,MAAM,iBAAA,GAAoB,qBAAA;AAE1B,MAAM,kBAAA,GAAqB,CAAC,IAAA,EAAY,UAAA,EAAoB,UAAkB,MAAA,KAC5E,MAAA,CAAO,IAAA,EAAM,UAAA,EAAY,MAAA,GAAS,EAAE,IAAI,EAAA,CAAG,QAAQ,GAAG,MAAA,EAAO,GAAI,EAAE,EAAA,EAAI,EAAA,CAAG,QAAQ,CAAA,EAAG,CAAA;AAEvF,MAAM,aAAA,GAAgB,CAAC,KAAA,KAAwB,QAAA,CAAS,iBAAA,CAAkB,IAAA,CAAK,KAAK,CAAA,GAAI,CAAA,EAAG,KAAK,CAAA,UAAA,CAAA,GAAe,KAAK,CAAA;AAE7G,MAAM,YAAA,GAAe,CAAC,KAAA,KAA2C;AACtE,EAAA,IAAI,KAAA,IAAS,IAAA,EAAM,OAAO,EAAE,SAAS,GAAA,EAAI;AAEzC,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,CAAM,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AQ,OAAA,CAAQ,MAAM,CAAC,CAAA,EAAA,EAAK,MAAM,CAAA,CAAA;AAAA,GAC9F;AACF;;;;"}
@@ -1,5 +1,5 @@
1
1
  import Decimal from './decimal.js';
2
- import { c as currencies } from '../index10.js';
2
+ import { c as currencies, C as CUSTOM_CURRENCY_EXPONENTS } from '../currencyCode.js';
3
3
  import { getLocale } from './locale.js';
4
4
 
5
5
  //#region src/core/checks/messages.ts
@@ -382,8 +382,10 @@ const dinero = createDinero({ calculator });
382
382
 
383
383
  function resolveCurrency(currencyCode) {
384
384
  const currency = currencies[currencyCode];
385
- if (!currency) throw new Error(`Unknown currency: ${currencyCode}`);
386
- return currency;
385
+ if (currency) return currency;
386
+ const exponent = CUSTOM_CURRENCY_EXPONENTS[currencyCode];
387
+ if (exponent === void 0) throw new Error(`Unknown currency: ${currencyCode}`);
388
+ return { code: currencyCode, base: 10n, exponent: BigInt(exponent) };
387
389
  }
388
390
  function minorToMajor(minor, currencyCode) {
389
391
  const currency = resolveCurrency(currencyCode);
@@ -1 +1 @@
1
- {"version":3,"file":"money.js","sources":["../../node_modules/.pnpm/dinero.js@2.0.2/node_modules/dinero.js/dist/esm/trimScale-C3-DjbPM.js","../../node_modules/.pnpm/dinero.js@2.0.2/node_modules/dinero.js/dist/esm/bigint/index.js","../../lib/utils/money.ts"],"sourcesContent":["//#region src/core/checks/messages.ts\nconst INVALID_AMOUNT_MESSAGE = \"Amount is invalid.\";\nconst INVALID_SCALE_MESSAGE = \"Scale is invalid.\";\nconst INVALID_RATIOS_MESSAGE = \"Ratios are invalid.\";\nconst UNEQUAL_CURRENCIES_MESSAGE = \"Objects must have the same currency.\";\nconst NON_DECIMAL_CURRENCY_MESSAGE = \"Currency is not decimal.\";\nconst MISMATCHED_BASES_MESSAGE = \"Objects must have the same currency base.\";\n\n//#endregion\n//#region src/core/helpers/assert.ts\n/**\n* Assert a condition.\n*\n* @param condition - The condition to verify.\n* @param message - The error message to throw.\n*\n* @throws If the condition isn't met.\n*/\nfunction assert(condition, message) {\n\tif (!condition) throw new Error(`[Dinero.js] ${message}`);\n}\n\n//#endregion\n//#region src/core/helpers/createDinero.ts\nfunction createDinero({ calculator, onCreate, formatter = {\n\ttoNumber: Number,\n\ttoString: String\n} }) {\n\treturn function dinero({ amount, currency: { code, base, exponent }, scale = exponent }) {\n\t\tconst currency = {\n\t\t\tcode,\n\t\t\tbase,\n\t\t\texponent\n\t\t};\n\t\tonCreate?.({\n\t\t\tamount,\n\t\t\tcurrency,\n\t\t\tscale\n\t\t});\n\t\treturn {\n\t\t\tcalculator,\n\t\t\tformatter,\n\t\t\tcreate: dinero,\n\t\t\ttoJSON() {\n\t\t\t\treturn {\n\t\t\t\t\tamount,\n\t\t\t\t\tcurrency,\n\t\t\t\t\tscale\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\t};\n}\n\n//#endregion\n//#region src/core/types/DineroCalculator.ts\nlet DineroComparisonOperator = /* @__PURE__ */ function(DineroComparisonOperator) {\n\tDineroComparisonOperator[DineroComparisonOperator[\"LT\"] = -1] = \"LT\";\n\tDineroComparisonOperator[DineroComparisonOperator[\"EQ\"] = 0] = \"EQ\";\n\tDineroComparisonOperator[DineroComparisonOperator[\"GT\"] = 1] = \"GT\";\n\treturn DineroComparisonOperator;\n}({});\n\n//#endregion\n//#region src/core/utils/equal.ts\n/**\n* Returns an equal function.\n*\n* @param calculator - The calculator to use.\n*\n* @returns The equal function.\n*/\nfunction equal$2(calculator) {\n\treturn (subject, comparator) => {\n\t\treturn calculator.compare(subject, comparator) === DineroComparisonOperator.EQ;\n\t};\n}\n\n//#endregion\n//#region src/core/utils/lessThan.ts\n/**\n* Returns a lessThan function.\n*\n* @param calculator - The calculator to use.\n*\n* @returns The lessThan function.\n*/\nfunction lessThan$1(calculator) {\n\treturn (subject, comparator) => {\n\t\treturn calculator.compare(subject, comparator) === DineroComparisonOperator.LT;\n\t};\n}\n\n//#endregion\n//#region src/core/utils/absolute.ts\nfunction absolute(calculator) {\n\tconst equalFn = equal$2(calculator);\n\tconst lessThanFn = lessThan$1(calculator);\n\tconst zero = calculator.zero();\n\treturn (input) => {\n\t\tif (equalFn(input, zero)) return zero;\n\t\tif (lessThanFn(input, zero)) {\n\t\t\tconst minusOne = calculator.decrement(zero);\n\t\t\treturn calculator.multiply(minusOne, input);\n\t\t}\n\t\treturn input;\n\t};\n}\n\n//#endregion\n//#region src/core/utils/compare.ts\n/**\n* Returns a compare function.\n*\n* @param calculator - The calculator to use.\n*\n* @returns The compare function.\n*/\nfunction compare$1(calculator) {\n\treturn (subject, comparator) => {\n\t\treturn calculator.compare(subject, comparator);\n\t};\n}\n\n//#endregion\n//#region src/core/utils/isArray.ts\nfunction isArray(maybeArray) {\n\treturn Array.isArray(maybeArray);\n}\n\n//#endregion\n//#region src/core/utils/computeBase.ts\nfunction computeBase(calculator) {\n\treturn (base) => {\n\t\tif (isArray(base)) return base.reduce((acc, curr) => calculator.multiply(acc, curr));\n\t\treturn base;\n\t};\n}\n\n//#endregion\n//#region src/core/utils/countTrailingZeros.ts\nfunction countTrailingZeros(calculator) {\n\tconst equalFn = equal$2(calculator);\n\treturn (input, base) => {\n\t\tconst zero = calculator.zero();\n\t\tif (equalFn(zero, input)) return calculator.zero();\n\t\tlet i = zero;\n\t\tlet temp = input;\n\t\twhile (equalFn(calculator.modulo(temp, base), zero)) {\n\t\t\ttemp = calculator.integerDivide(temp, base);\n\t\t\ti = calculator.increment(i);\n\t\t}\n\t\treturn i;\n\t};\n}\n\n//#endregion\n//#region src/core/utils/greaterThan.ts\n/**\n* Returns a greaterThan function.\n*\n* @param calculator - The calculator to use.\n*\n* @returns The greaterThan function.\n*/\nfunction greaterThan$1(calculator) {\n\treturn (subject, comparator) => {\n\t\treturn calculator.compare(subject, comparator) === DineroComparisonOperator.GT;\n\t};\n}\n\n//#endregion\n//#region src/core/utils/greaterThanOrEqual.ts\n/**\n* Returns a greaterThanOrEqual function.\n*\n* @param calculator - The calculator to use.\n*\n* @returns The greaterThanOrEqual function.\n*/\nfunction greaterThanOrEqual$1(calculator) {\n\treturn (subject, comparator) => {\n\t\treturn greaterThan$1(calculator)(subject, comparator) || equal$2(calculator)(subject, comparator);\n\t};\n}\n\n//#endregion\n//#region src/core/utils/distribute.ts\n/**\n* Returns a distribute function.\n*\n* @param calculator - The calculator to use.\n*\n* @returns The distribute function.\n*/\nfunction distribute(calculator) {\n\treturn (value, ratios) => {\n\t\tconst equalFn = equal$2(calculator);\n\t\tconst greaterThanFn = greaterThan$1(calculator);\n\t\tconst lessThanFn = lessThan$1(calculator);\n\t\tconst greaterThanOrEqualFn = greaterThanOrEqual$1(calculator);\n\t\tconst zero = calculator.zero();\n\t\tconst one = calculator.increment(zero);\n\t\tconst total = ratios.reduce((a, b) => calculator.add(a, b), zero);\n\t\tif (equalFn(total, zero)) return ratios;\n\t\tlet remainder = value;\n\t\tconst shares = ratios.map((ratio) => {\n\t\t\tconst share = calculator.integerDivide(calculator.multiply(value, ratio), total) || zero;\n\t\t\tremainder = calculator.subtract(remainder, share);\n\t\t\treturn share;\n\t\t});\n\t\tconst isPositive = greaterThanOrEqualFn(value, zero);\n\t\tconst compare = isPositive ? greaterThanFn : lessThanFn;\n\t\tconst amount = isPositive ? one : calculator.decrement(zero);\n\t\tconst sortedIndices = ratios.map((ratio, index) => ({\n\t\t\tratio,\n\t\t\tindex\n\t\t})).filter(({ ratio }) => !equalFn(ratio, zero)).sort((a, b) => greaterThanFn(a.ratio, b.ratio) ? -1 : 1).map(({ index }) => index);\n\t\tlet i = 0;\n\t\twhile (compare(remainder, zero)) {\n\t\t\tconst index = sortedIndices[i % sortedIndices.length];\n\t\t\tshares[index] = calculator.add(shares[index], amount);\n\t\t\tconst newRemainder = calculator.subtract(remainder, amount);\n\t\t\tif (equalFn(newRemainder, remainder)) break;\n\t\t\tremainder = newRemainder;\n\t\t\ti++;\n\t\t}\n\t\treturn shares;\n\t};\n}\n\n//#endregion\n//#region src/core/utils/isScaledAmount.ts\nfunction isScaledAmount(amount) {\n\treturn amount?.hasOwnProperty(\"amount\");\n}\n\n//#endregion\n//#region src/core/utils/getAmountAndScale.ts\nfunction getAmountAndScale(value, zero) {\n\tif (isScaledAmount(value)) return {\n\t\tamount: value.amount,\n\t\tscale: value?.scale ?? zero\n\t};\n\treturn {\n\t\tamount: value,\n\t\tscale: zero\n\t};\n}\n\n//#endregion\n//#region src/core/utils/getDivisors.ts\nfunction getDivisors(calculator) {\n\tconst { multiply } = calculator;\n\treturn (bases) => {\n\t\treturn bases.reduce((divisors, _, i) => {\n\t\t\tconst divisor = bases.slice(i).reduce((acc, curr) => multiply(acc, curr));\n\t\t\treturn [...divisors, divisor];\n\t\t}, []);\n\t};\n}\n\n//#endregion\n//#region src/core/utils/isEven.ts\nfunction isEven(calculator) {\n\tconst equalFn = equal$2(calculator);\n\tconst zero = calculator.zero();\n\tconst two = calculator.increment(calculator.increment(zero));\n\treturn (input) => {\n\t\treturn equalFn(calculator.modulo(input, two), zero);\n\t};\n}\n\n//#endregion\n//#region src/core/utils/isHalf.ts\nfunction isHalf(calculator) {\n\tconst equalFn = equal$2(calculator);\n\tconst absoluteFn = absolute(calculator);\n\treturn (input, total) => {\n\t\tconst remainder = absoluteFn(calculator.modulo(input, total));\n\t\treturn equalFn(calculator.subtract(total, remainder), remainder);\n\t};\n}\n\n//#endregion\n//#region src/core/utils/lessThanOrEqual.ts\n/**\n* Returns a lessThanOrEqual function.\n*\n* @param calculator - The calculator to use.\n*\n* @returns The lessThanOrEqual function.\n*/\nfunction lessThanOrEqual$1(calculator) {\n\treturn (subject, comparator) => {\n\t\treturn lessThan$1(calculator)(subject, comparator) || equal$2(calculator)(subject, comparator);\n\t};\n}\n\n//#endregion\n//#region src/core/utils/maximum.ts\n/**\n* Returns a maximum function.\n*\n* @param calculator - The calculator to use.\n*\n* @returns The maximum function.\n*/\nfunction maximum$1(calculator) {\n\tconst lessThanFn = lessThan$1(calculator);\n\treturn (values) => {\n\t\treturn values.reduce((acc, curr) => {\n\t\t\treturn lessThanFn(acc, curr) ? curr : acc;\n\t\t});\n\t};\n}\n\n//#endregion\n//#region src/core/utils/minimum.ts\n/**\n* Returns a minimum function.\n*\n* @param calculator - The calculator to use.\n*\n* @returns The minimum function.\n*/\nfunction minimum$1(calculator) {\n\tconst greaterThanFn = greaterThan$1(calculator);\n\treturn (values) => {\n\t\treturn values.reduce((acc, curr) => {\n\t\t\treturn greaterThanFn(acc, curr) ? curr : acc;\n\t\t});\n\t};\n}\n\n//#endregion\n//#region src/core/utils/sign.ts\nfunction sign(calculator) {\n\tconst equalFn = equal$2(calculator);\n\tconst lessThanFn = lessThan$1(calculator);\n\tconst zero = calculator.zero();\n\treturn (input) => {\n\t\tif (equalFn(input, zero)) return zero;\n\t\tconst one = calculator.increment(zero);\n\t\tconst minusOne = calculator.decrement(zero);\n\t\treturn lessThanFn(input, zero) ? minusOne : one;\n\t};\n}\n\n//#endregion\n//#region src/core/api/haveSameCurrency.ts\nfunction haveSameCurrency$1(dineroObjects) {\n\tconst [firstDinero, ...otherDineros] = dineroObjects;\n\tconst computeBaseFn = computeBase(firstDinero.calculator);\n\tconst { currency: comparator } = firstDinero.toJSON();\n\tconst equalFn = equal$2(firstDinero.calculator);\n\tconst comparatorBase = computeBaseFn(comparator.base);\n\treturn otherDineros.every((d) => {\n\t\tconst { currency: subject } = d.toJSON();\n\t\tconst subjectBase = computeBaseFn(subject.base);\n\t\treturn subject.code === comparator.code && equalFn(subjectBase, comparatorBase) && equalFn(subject.exponent, comparator.exponent);\n\t});\n}\n\n//#endregion\n//#region src/core/divide/down.ts\n/**\n* Divide and round down.\n*\n* Rounding down happens whenever the quotient is not an integer.\n*\n* @param amount - The amount to divide.\n* @param factor - The factor to divide by.\n* @param calculator - The calculator to use.\n*\n* @returns The rounded amount.\n*/\nconst down = (amount, factor, calculator) => {\n\tconst greaterThanFn = greaterThan$1(calculator);\n\tconst equalFn = equal$2(calculator);\n\tconst zero = calculator.zero();\n\tconst isPositive = greaterThanFn(amount, zero);\n\tconst quotient = calculator.integerDivide(amount, factor);\n\tconst isInteger = equalFn(calculator.modulo(amount, factor), zero);\n\tif (isPositive || isInteger) return quotient;\n\treturn calculator.decrement(quotient);\n};\n\n//#endregion\n//#region src/core/divide/halfAwayFromZero.ts\n/**\n* Divide and round towards \"nearest neighbor\" unless both neighbors are\n* equidistant, in which case round away from zero.\n*\n* @param amount - The amount to divide.\n* @param factor - The factor to divide by.\n* @param calculator - The calculator to use.\n*\n* @returns The rounded amount.\n*/\nconst halfAwayFromZero = (amount, factor, calculator) => {\n\tconst signFn = sign(calculator);\n\tconst isHalfFn = isHalf(calculator);\n\tconst absoluteFn = absolute(calculator);\n\tif (!isHalfFn(amount, factor)) return halfUp(amount, factor, calculator);\n\treturn calculator.multiply(signFn(amount), up(absoluteFn(amount), factor, calculator));\n};\n\n//#endregion\n//#region src/core/divide/halfDown.ts\n/**\n* Divide and round towards \"nearest neighbor\" unless both neighbors are\n* equidistant, in which case round down.\n*\n* Rounding down happens when:\n* - The quotient is half (e.g., -1.5, 1.5).\n* - The quotient is positive and less than half (e.g., 1.4).\n* - The quotient is negative and greater than half (e.g., -1.6).\n*\n* @param amount - The amount to divide.\n* @param factor - The factor to divide by.\n* @param calculator - The calculator to use.\n*\n* @returns The rounded amount.\n*/\nconst halfDown = (amount, factor, calculator) => {\n\tif (isHalf(calculator)(amount, factor)) return down(amount, factor, calculator);\n\treturn halfUp(amount, factor, calculator);\n};\n\n//#endregion\n//#region src/core/divide/halfEven.ts\n/**\n* Divide and round towards \"nearest neighbor\" unless both neighbors are\n* equidistant, in which case round to the nearest even integer.\n*\n* @param amount - The amount to divide.\n* @param factor - The factor to divide by.\n* @param calculator - The calculator to use.\n*\n* @returns The rounded amount.\n*/\nconst halfEven = (amount, factor, calculator) => {\n\tconst isEvenFn = isEven(calculator);\n\tconst isHalfFn = isHalf(calculator);\n\tconst rounded = halfUp(amount, factor, calculator);\n\tif (!isHalfFn(amount, factor)) return rounded;\n\treturn isEvenFn(rounded) ? rounded : calculator.decrement(rounded);\n};\n\n//#endregion\n//#region src/core/divide/halfOdd.ts\n/**\n* Divide and round towards \"nearest neighbor\" unless both neighbors are\n* equidistant, in which case round to the nearest odd integer.\n*\n* @param amount - The amount to divide.\n* @param factor - The factor to divide by.\n* @param calculator - The calculator to use.\n*\n* @returns The rounded amount.\n*/\nconst halfOdd = (amount, factor, calculator) => {\n\tconst isEvenFn = isEven(calculator);\n\tconst isHalfFn = isHalf(calculator);\n\tconst rounded = halfUp(amount, factor, calculator);\n\tif (!isHalfFn(amount, factor)) return rounded;\n\treturn isEvenFn(rounded) ? calculator.decrement(rounded) : rounded;\n};\n\n//#endregion\n//#region src/core/divide/halfTowardsZero.ts\n/**\n* Divide and round towards \"nearest neighbor\" unless both neighbors are\n* equidistant, in which case round towards zero.\n*\n* @param amount - The amount to divide.\n* @param factor - The factor to divide by.\n* @param calculator - The calculator to use.\n*\n* @returns The rounded amount.\n*/\nconst halfTowardsZero = (amount, factor, calculator) => {\n\tconst signFn = sign(calculator);\n\tconst isHalfFn = isHalf(calculator);\n\tconst absoluteFn = absolute(calculator);\n\tif (!isHalfFn(amount, factor)) return halfUp(amount, factor, calculator);\n\treturn calculator.multiply(signFn(amount), down(absoluteFn(amount), factor, calculator));\n};\n\n//#endregion\n//#region src/core/divide/halfUp.ts\n/**\n* Divide and round towards \"nearest neighbor\" unless both neighbors are\n* equidistant, in which case round up.\n*\n* Rounding up happens when:\n* - The quotient is half (e.g., -1.5, 1.5).\n* - The quotient is positive and greater than half (e.g., 1.6).\n* - The quotient is negative and less than half (e.g., -1.4).\n*\n* @param amount - The amount to divide.\n* @param factor - The factor to divide by.\n* @param calculator - The calculator to use.\n*\n* @returns The rounded amount.\n*/\nconst halfUp = (amount, factor, calculator) => {\n\tconst greaterThanFn = greaterThan$1(calculator);\n\tconst isHalfFn = isHalf(calculator);\n\tconst absoluteFn = absolute(calculator);\n\tconst zero = calculator.zero();\n\tconst remainder = absoluteFn(calculator.modulo(amount, factor));\n\tconst isLessThanHalf = greaterThanFn(calculator.subtract(factor, remainder), remainder);\n\tconst isPositive = greaterThanFn(amount, zero);\n\tif (isHalfFn(amount, factor) || isPositive && !isLessThanHalf || !isPositive && isLessThanHalf) return up(amount, factor, calculator);\n\treturn down(amount, factor, calculator);\n};\n\n//#endregion\n//#region src/core/divide/up.ts\n/**\n* Divide and round up.\n*\n* Rounding up happens whenever the quotient is not an integer.\n*\n* @param amount - The amount to divide.\n* @param factor - The factor to divide by.\n* @param calculator - The calculator to use.\n*\n* @returns The rounded amount.\n*/\nconst up = (amount, factor, calculator) => {\n\tconst greaterThanFn = greaterThan$1(calculator);\n\tconst equalFn = equal$2(calculator);\n\tconst zero = calculator.zero();\n\tconst isPositive = greaterThanFn(amount, zero);\n\tconst quotient = calculator.integerDivide(amount, factor);\n\tif (!equalFn(calculator.modulo(amount, factor), zero) && isPositive) return calculator.increment(quotient);\n\treturn quotient;\n};\n\n//#endregion\n//#region src/core/api/transformScale.ts\nfunction transformScale$1(calculator) {\n\tconst greaterThanFn = greaterThan$1(calculator);\n\tconst computeBaseFn = computeBase(calculator);\n\treturn function transformScaleFn(...[dineroObject, newScale, divide = down]) {\n\t\tconst { amount, currency, scale } = dineroObject.toJSON();\n\t\tconst isLarger = greaterThanFn(newScale, scale);\n\t\tconst operation = isLarger ? calculator.multiply : divide;\n\t\tconst [a, b] = isLarger ? [newScale, scale] : [scale, newScale];\n\t\tconst base = computeBaseFn(currency.base);\n\t\tconst factor = calculator.power(base, calculator.subtract(a, b));\n\t\treturn dineroObject.create({\n\t\t\tamount: operation(amount, factor, calculator),\n\t\t\tcurrency,\n\t\t\tscale: newScale\n\t\t});\n\t};\n}\n\n//#endregion\n//#region src/core/api/normalizeScale.ts\nfunction normalizeScale$1(calculator) {\n\tconst maximumFn = maximum$1(calculator);\n\tconst convertScaleFn = transformScale$1(calculator);\n\tconst equalFn = equal$2(calculator);\n\treturn function _normalizeScale(...[dineroObjects]) {\n\t\tconst highestScale = dineroObjects.reduce((highest, current) => {\n\t\t\tconst { scale } = current.toJSON();\n\t\t\treturn maximumFn([highest, scale]);\n\t\t}, calculator.zero());\n\t\treturn dineroObjects.map((d) => {\n\t\t\tconst { scale } = d.toJSON();\n\t\t\treturn !equalFn(scale, highestScale) ? convertScaleFn(d, highestScale) : d;\n\t\t});\n\t};\n}\n\n//#endregion\n//#region src/core/api/add.ts\nfunction unsafeAdd(calculator) {\n\treturn function add(...[augend, addend]) {\n\t\tconst { amount: augendAmount, currency, scale } = augend.toJSON();\n\t\tconst { amount: addendAmount } = addend.toJSON();\n\t\tconst amount = calculator.add(augendAmount, addendAmount);\n\t\treturn augend.create({\n\t\t\tamount,\n\t\t\tcurrency,\n\t\t\tscale\n\t\t});\n\t};\n}\nfunction safeAdd(calculator) {\n\tconst normalizeFn = normalizeScale$1(calculator);\n\tconst addFn = unsafeAdd(calculator);\n\treturn function add(...[augend, addend]) {\n\t\tassert(haveSameCurrency$1([augend, addend]), UNEQUAL_CURRENCIES_MESSAGE);\n\t\tconst [newAugend, newAddend] = normalizeFn([augend, addend]);\n\t\treturn addFn(newAugend, newAddend);\n\t};\n}\n\n//#endregion\n//#region src/core/api/allocate.ts\nfunction unsafeAllocate(calculator) {\n\treturn function allocate(...[dineroObject, ratios]) {\n\t\tconst { amount, currency, scale } = dineroObject.toJSON();\n\t\treturn distribute(calculator)(amount, ratios.map((ratio) => ratio.amount)).map((share) => {\n\t\t\treturn dineroObject.create({\n\t\t\t\tamount: share,\n\t\t\t\tcurrency,\n\t\t\t\tscale\n\t\t\t});\n\t\t});\n\t};\n}\nfunction safeAllocate(calculator) {\n\tconst allocateFn = unsafeAllocate(calculator);\n\tconst greaterThanOrEqualFn = greaterThanOrEqual$1(calculator);\n\tconst greaterThanFn = greaterThan$1(calculator);\n\tconst convertScaleFn = transformScale$1(calculator);\n\tconst maximumFn = maximum$1(calculator);\n\tconst equalFn = equal$2(calculator);\n\tconst zero = calculator.zero();\n\tconst ten = new Array(10).fill(null).reduce(calculator.increment, zero);\n\treturn function allocate(...[dineroObject, ratios]) {\n\t\tconst hasRatios = ratios.length > 0;\n\t\tconst scaledRatios = ratios.map((ratio) => getAmountAndScale(ratio, zero));\n\t\tconst highestRatioScale = hasRatios ? maximumFn(scaledRatios.map(({ scale }) => scale)) : zero;\n\t\tconst normalizedRatios = scaledRatios.map(({ amount, scale }) => {\n\t\t\tconst factor = equalFn(scale, highestRatioScale) ? zero : calculator.subtract(highestRatioScale, scale);\n\t\t\treturn {\n\t\t\t\tamount: calculator.multiply(amount, calculator.power(ten, factor)),\n\t\t\t\tscale\n\t\t\t};\n\t\t});\n\t\tconst hasOnlyPositiveRatios = normalizedRatios.every(({ amount }) => greaterThanOrEqualFn(amount, zero));\n\t\tconst hasOneNonZeroRatio = normalizedRatios.some(({ amount }) => greaterThanFn(amount, zero));\n\t\tassert(hasRatios && hasOnlyPositiveRatios && hasOneNonZeroRatio, INVALID_RATIOS_MESSAGE);\n\t\tconst { scale } = dineroObject.toJSON();\n\t\treturn allocateFn(convertScaleFn(dineroObject, calculator.add(scale, highestRatioScale)), normalizedRatios);\n\t};\n}\n\n//#endregion\n//#region src/core/api/compare.ts\nfunction unsafeCompare(calculator) {\n\tconst compareFn = compare$1(calculator);\n\treturn function compare(...[dineroObject, comparator]) {\n\t\tconst [subjectAmount, comparatorAmount] = [dineroObject, comparator].map((d) => {\n\t\t\tconst { amount } = d.toJSON();\n\t\t\treturn amount;\n\t\t});\n\t\treturn compareFn(subjectAmount, comparatorAmount);\n\t};\n}\nfunction safeCompare(calculator) {\n\tconst normalizeFn = normalizeScale$1(calculator);\n\tconst compareFn = unsafeCompare(calculator);\n\treturn function compare(...[dineroObject, comparator]) {\n\t\tassert(haveSameCurrency$1([dineroObject, comparator]), UNEQUAL_CURRENCIES_MESSAGE);\n\t\tconst [subjectAmount, comparatorAmount] = normalizeFn([dineroObject, comparator]);\n\t\treturn compareFn(subjectAmount, comparatorAmount);\n\t};\n}\n\n//#endregion\n//#region src/core/api/convert.ts\nfunction convert$1(calculator) {\n\tconst convertScaleFn = transformScale$1(calculator);\n\tconst maximumFn = maximum$1(calculator);\n\tconst computeBaseFn = computeBase(calculator);\n\tconst equalFn = equal$2(calculator);\n\tconst zero = calculator.zero();\n\treturn function convertFn(...[dineroObject, newCurrency, rates]) {\n\t\tconst rate = rates[newCurrency.code];\n\t\tconst { amount, currency, scale } = dineroObject.toJSON();\n\t\tassert(equalFn(computeBaseFn(currency.base), computeBaseFn(newCurrency.base)), MISMATCHED_BASES_MESSAGE);\n\t\tconst { amount: rateAmount, scale: rateScale } = getAmountAndScale(rate, zero);\n\t\tconst newScale = calculator.add(scale, rateScale);\n\t\treturn convertScaleFn(dineroObject.create({\n\t\t\tamount: calculator.multiply(amount, rateAmount),\n\t\t\tcurrency: newCurrency,\n\t\t\tscale: newScale\n\t\t}), maximumFn([newScale, newCurrency.exponent]));\n\t};\n}\n\n//#endregion\n//#region src/core/api/haveSameAmount.ts\nfunction haveSameAmount$1(calculator) {\n\tconst normalizeFn = normalizeScale$1(calculator);\n\tconst equalFn = equal$2(calculator);\n\treturn function _haveSameAmount(...[dineroObjects]) {\n\t\tconst [firstDinero, ...otherDineros] = normalizeFn(dineroObjects);\n\t\tconst { amount: comparatorAmount } = firstDinero.toJSON();\n\t\treturn otherDineros.every((d) => {\n\t\t\tconst { amount: subjectAmount } = d.toJSON();\n\t\t\treturn equalFn(subjectAmount, comparatorAmount);\n\t\t});\n\t};\n}\n\n//#endregion\n//#region src/core/api/equal.ts\nfunction equal$1(calculator) {\n\treturn function _equal(...[dineroObject, comparator]) {\n\t\treturn haveSameAmount$1(calculator)([dineroObject, comparator]) && haveSameCurrency$1([dineroObject, comparator]);\n\t};\n}\n\n//#endregion\n//#region src/core/api/greaterThan.ts\nfunction unsafeGreaterThan(calculator) {\n\tconst greaterThanFn = greaterThan$1(calculator);\n\treturn function greaterThan(...[dineroObject, comparator]) {\n\t\tconst [subjectAmount, comparatorAmount] = [dineroObject, comparator].map((d) => {\n\t\t\tconst { amount } = d.toJSON();\n\t\t\treturn amount;\n\t\t});\n\t\treturn greaterThanFn(subjectAmount, comparatorAmount);\n\t};\n}\nfunction safeGreaterThan(calculator) {\n\tconst normalizeFn = normalizeScale$1(calculator);\n\tconst greaterThanFn = unsafeGreaterThan(calculator);\n\treturn function greaterThan(...[dineroObject, comparator]) {\n\t\tassert(haveSameCurrency$1([dineroObject, comparator]), UNEQUAL_CURRENCIES_MESSAGE);\n\t\tconst [subjectAmount, comparatorAmount] = normalizeFn([dineroObject, comparator]);\n\t\treturn greaterThanFn(subjectAmount, comparatorAmount);\n\t};\n}\n\n//#endregion\n//#region src/core/api/greaterThanOrEqual.ts\nfunction unsafeGreaterThanOrEqual(calculator) {\n\tconst greaterThanOrEqualFn = greaterThanOrEqual$1(calculator);\n\treturn function greaterThanOrEqual(...[dineroObject, comparator]) {\n\t\tconst [subjectAmount, comparatorAmount] = [dineroObject, comparator].map((d) => {\n\t\t\tconst { amount } = d.toJSON();\n\t\t\treturn amount;\n\t\t});\n\t\treturn greaterThanOrEqualFn(subjectAmount, comparatorAmount);\n\t};\n}\nfunction safeGreaterThanOrEqual(calculator) {\n\tconst normalizeFn = normalizeScale$1(calculator);\n\tconst greaterThanOrEqualFn = unsafeGreaterThanOrEqual(calculator);\n\treturn function greaterThanOrEqual(...[dineroObject, comparator]) {\n\t\tassert(haveSameCurrency$1([dineroObject, comparator]), UNEQUAL_CURRENCIES_MESSAGE);\n\t\tconst [subjectAmount, comparatorAmount] = normalizeFn([dineroObject, comparator]);\n\t\treturn greaterThanOrEqualFn(subjectAmount, comparatorAmount);\n\t};\n}\n\n//#endregion\n//#region src/core/api/hasSubUnits.ts\nfunction hasSubUnits$1(calculator) {\n\tconst equalFn = equal$2(calculator);\n\tconst computeBaseFn = computeBase(calculator);\n\treturn function _hasSubUnits(...[dineroObject]) {\n\t\tconst { amount, currency, scale } = dineroObject.toJSON();\n\t\tconst base = computeBaseFn(currency.base);\n\t\treturn !equalFn(calculator.modulo(amount, calculator.power(base, scale)), calculator.zero());\n\t};\n}\n\n//#endregion\n//#region src/core/api/isNegative.ts\nfunction isNegative$1(calculator) {\n\tconst lessThanFn = lessThan$1(calculator);\n\treturn function _isNegative(...[dineroObject]) {\n\t\tconst { amount } = dineroObject.toJSON();\n\t\treturn lessThanFn(amount, calculator.zero());\n\t};\n}\n\n//#endregion\n//#region src/core/api/isPositive.ts\nfunction isPositive$1(calculator) {\n\tconst greaterThanFn = greaterThan$1(calculator);\n\treturn function _isPositive(...[dineroObject]) {\n\t\tconst { amount } = dineroObject.toJSON();\n\t\treturn greaterThanFn(amount, calculator.zero());\n\t};\n}\n\n//#endregion\n//#region src/core/api/isZero.ts\nfunction isZero$1(calculator) {\n\tconst equalFn = equal$2(calculator);\n\treturn function _isZero(...[dineroObject]) {\n\t\tconst { amount } = dineroObject.toJSON();\n\t\treturn equalFn(amount, calculator.zero());\n\t};\n}\n\n//#endregion\n//#region src/core/api/lessThan.ts\nfunction unsafeLessThan(calculator) {\n\tconst lessThanFn = lessThan$1(calculator);\n\treturn function lessThan(...[dineroObject, comparator]) {\n\t\tconst [subjectAmount, comparatorAmount] = [dineroObject, comparator].map((d) => {\n\t\t\tconst { amount } = d.toJSON();\n\t\t\treturn amount;\n\t\t});\n\t\treturn lessThanFn(subjectAmount, comparatorAmount);\n\t};\n}\nfunction safeLessThan(calculator) {\n\tconst normalizeFn = normalizeScale$1(calculator);\n\tconst lessThanFn = unsafeLessThan(calculator);\n\treturn function lessThan(...[dineroObject, comparator]) {\n\t\tassert(haveSameCurrency$1([dineroObject, comparator]), UNEQUAL_CURRENCIES_MESSAGE);\n\t\tconst [subjectAmount, comparatorAmount] = normalizeFn([dineroObject, comparator]);\n\t\treturn lessThanFn(subjectAmount, comparatorAmount);\n\t};\n}\n\n//#endregion\n//#region src/core/api/lessThanOrEqual.ts\nfunction unsafeLessThanOrEqual(calculator) {\n\tconst lessThanOrEqualFn = lessThanOrEqual$1(calculator);\n\treturn function lessThanOrEqual(...[dineroObject, comparator]) {\n\t\tconst [subjectAmount, comparatorAmount] = [dineroObject, comparator].map((d) => {\n\t\t\tconst { amount } = d.toJSON();\n\t\t\treturn amount;\n\t\t});\n\t\treturn lessThanOrEqualFn(subjectAmount, comparatorAmount);\n\t};\n}\nfunction safeLessThanOrEqual(calculator) {\n\tconst normalizeFn = normalizeScale$1(calculator);\n\tconst lessThanOrEqualFn = unsafeLessThanOrEqual(calculator);\n\treturn function lessThanOrEqual(...[dineroObject, comparator]) {\n\t\tassert(haveSameCurrency$1([dineroObject, comparator]), UNEQUAL_CURRENCIES_MESSAGE);\n\t\tconst [subjectAmount, comparatorAmount] = normalizeFn([dineroObject, comparator]);\n\t\treturn lessThanOrEqualFn(subjectAmount, comparatorAmount);\n\t};\n}\n\n//#endregion\n//#region src/core/api/maximum.ts\nfunction unsafeMaximum(calculator) {\n\tconst maxFn = maximum$1(calculator);\n\treturn function maximum(dineroObjects) {\n\t\tconst [firstDinero] = dineroObjects;\n\t\tconst { currency, scale } = firstDinero.toJSON();\n\t\tconst amount = maxFn(dineroObjects.map((subject) => {\n\t\t\tconst { amount: subjectAmount } = subject.toJSON();\n\t\t\treturn subjectAmount;\n\t\t}));\n\t\treturn firstDinero.create({\n\t\t\tamount,\n\t\t\tcurrency,\n\t\t\tscale\n\t\t});\n\t};\n}\nfunction safeMaximum(calculator) {\n\tconst normalizeFn = normalizeScale$1(calculator);\n\tconst maxFn = unsafeMaximum(calculator);\n\treturn function maximum(...[dineroObjects]) {\n\t\tassert(haveSameCurrency$1(dineroObjects), UNEQUAL_CURRENCIES_MESSAGE);\n\t\treturn maxFn(normalizeFn([...dineroObjects]));\n\t};\n}\n\n//#endregion\n//#region src/core/api/minimum.ts\nfunction unsafeMinimum(calculator) {\n\tconst minFn = minimum$1(calculator);\n\treturn function minimum(dineroObjects) {\n\t\tconst [firstDinero] = dineroObjects;\n\t\tconst { currency, scale } = firstDinero.toJSON();\n\t\tconst amount = minFn(dineroObjects.map((subject) => {\n\t\t\tconst { amount: subjectAmount } = subject.toJSON();\n\t\t\treturn subjectAmount;\n\t\t}));\n\t\treturn firstDinero.create({\n\t\t\tamount,\n\t\t\tcurrency,\n\t\t\tscale\n\t\t});\n\t};\n}\nfunction safeMinimum(calculator) {\n\tconst normalizeFn = normalizeScale$1(calculator);\n\tconst minFn = unsafeMinimum(calculator);\n\treturn function minimum(...[dineroObjects]) {\n\t\tassert(haveSameCurrency$1(dineroObjects), UNEQUAL_CURRENCIES_MESSAGE);\n\t\treturn minFn(normalizeFn([...dineroObjects]));\n\t};\n}\n\n//#endregion\n//#region src/core/api/multiply.ts\nfunction multiply$1(calculator) {\n\tconst convertScaleFn = transformScale$1(calculator);\n\tconst zero = calculator.zero();\n\treturn function multiplyFn(...[multiplicand, multiplier]) {\n\t\tconst { amount, currency, scale } = multiplicand.toJSON();\n\t\tconst { amount: multiplierAmount, scale: multiplierScale } = getAmountAndScale(multiplier, zero);\n\t\tconst newScale = calculator.add(scale, multiplierScale);\n\t\treturn convertScaleFn(multiplicand.create({\n\t\t\tamount: calculator.multiply(amount, multiplierAmount),\n\t\t\tcurrency,\n\t\t\tscale: newScale\n\t\t}), newScale);\n\t};\n}\n\n//#endregion\n//#region src/core/api/subtract.ts\nfunction unsafeSubtract(calculator) {\n\treturn function subtract(...[minuend, subtrahend]) {\n\t\tconst { amount: minuendAmount, currency, scale } = minuend.toJSON();\n\t\tconst { amount: subtrahendAmount } = subtrahend.toJSON();\n\t\tconst amount = calculator.subtract(minuendAmount, subtrahendAmount);\n\t\treturn minuend.create({\n\t\t\tamount,\n\t\t\tcurrency,\n\t\t\tscale\n\t\t});\n\t};\n}\nfunction safeSubtract(calculator) {\n\tconst normalizeFn = normalizeScale$1(calculator);\n\tconst subtractFn = unsafeSubtract(calculator);\n\treturn function subtract(...[minuend, subtrahend]) {\n\t\tassert(haveSameCurrency$1([minuend, subtrahend]), UNEQUAL_CURRENCIES_MESSAGE);\n\t\tconst [newMinuend, newSubtrahend] = normalizeFn([minuend, subtrahend]);\n\t\treturn subtractFn(newMinuend, newSubtrahend);\n\t};\n}\n\n//#endregion\n//#region src/core/api/toUnits.ts\nfunction toUnits$1(calculator) {\n\tconst getDivisorsFn = getDivisors(calculator);\n\treturn function toUnitsFn(...[dineroObject, transformer]) {\n\t\tconst { amount, currency, scale } = dineroObject.toJSON();\n\t\tconst { power, integerDivide, modulo } = calculator;\n\t\tconst value = getDivisorsFn((isArray(currency.base) ? currency.base : [currency.base]).map((base) => power(base, scale))).reduce((amounts, divisor, index) => {\n\t\t\tconst amountLeft = amounts[index];\n\t\t\tconst quotient = integerDivide(amountLeft, divisor);\n\t\t\tconst remainder = modulo(amountLeft, divisor);\n\t\t\treturn [\n\t\t\t\t...amounts.filter((_, i) => i !== index),\n\t\t\t\tquotient,\n\t\t\t\tremainder\n\t\t\t];\n\t\t}, [amount]);\n\t\tif (!transformer) return value;\n\t\treturn transformer({\n\t\t\tvalue,\n\t\t\tcurrency\n\t\t});\n\t};\n}\n\n//#endregion\n//#region src/core/api/toDecimal.ts\nfunction toDecimal$1(calculator) {\n\tconst toUnitsFn = toUnits$1(calculator);\n\tconst computeBaseFn = computeBase(calculator);\n\tconst equalFn = equal$2(calculator);\n\treturn function toDecimalFn(...[dineroObject, transformer]) {\n\t\tconst { currency, scale } = dineroObject.toJSON();\n\t\tconst base = computeBaseFn(currency.base);\n\t\tconst zero = calculator.zero();\n\t\tconst ten = new Array(10).fill(null).reduce(calculator.increment, zero);\n\t\tconst isMultiBase = isArray(currency.base);\n\t\tconst isBaseTen = equalFn(calculator.modulo(base, ten), zero);\n\t\tassert(!isMultiBase && isBaseTen, NON_DECIMAL_CURRENCY_MESSAGE);\n\t\tconst units = toUnitsFn(dineroObject);\n\t\tconst value = getDecimal(calculator, dineroObject.formatter)(units, scale);\n\t\tif (!transformer) return value;\n\t\treturn transformer({\n\t\t\tvalue,\n\t\t\tcurrency\n\t\t});\n\t};\n}\nfunction getDecimal(calculator, formatter) {\n\tconst absoluteFn = absolute(calculator);\n\tconst equalFn = equal$2(calculator);\n\tconst lessThanFn = lessThan$1(calculator);\n\tconst zero = calculator.zero();\n\treturn (units, scale) => {\n\t\tconst whole = formatter.toString(units[0]);\n\t\tconst fractional = formatter.toString(absoluteFn(units[1]));\n\t\tconst scaleNumber = formatter.toNumber(scale);\n\t\tconst decimal = `${whole}${scaleNumber > 0 ? `.${fractional.padStart(scaleNumber, \"0\")}` : \"\"}`;\n\t\tconst leadsWithZero = equalFn(units[0], zero);\n\t\tconst isNegative = lessThanFn(units[1], zero);\n\t\treturn leadsWithZero && isNegative ? `-${decimal}` : decimal;\n\t};\n}\n\n//#endregion\n//#region src/core/api/toSnapshot.ts\nfunction toSnapshot$1(dineroObject) {\n\treturn dineroObject.toJSON();\n}\n\n//#endregion\n//#region src/core/api/trimScale.ts\nfunction trimScale$1(calculator) {\n\tconst countTrailingZerosFn = countTrailingZeros(calculator);\n\tconst equalFn = equal$2(calculator);\n\tconst maximumFn = maximum$1(calculator);\n\tconst transformScaleFn = transformScale$1(calculator);\n\tconst computeBaseFn = computeBase(calculator);\n\treturn function trimScaleFn(...[dineroObject]) {\n\t\tconst { amount, currency, scale } = dineroObject.toJSON();\n\t\tconst trailingZerosLength = countTrailingZerosFn(amount, computeBaseFn(currency.base));\n\t\tconst newScale = maximumFn([calculator.subtract(scale, trailingZerosLength), currency.exponent]);\n\t\tif (equalFn(newScale, scale)) return dineroObject;\n\t\treturn transformScaleFn(dineroObject, newScale);\n\t};\n}\n\n//#endregion\n//#region src/api/add.ts\n/**\n* Add up the passed Dinero objects.\n*\n* @param augend - The Dinero object to add to.\n* @param addend - The Dinero object to add.\n*\n* @returns A new Dinero object.\n*\n* @public\n*/\nfunction add(...[augend, addend]) {\n\tconst { calculator } = augend;\n\treturn safeAdd(calculator)(augend, addend);\n}\n\n//#endregion\n//#region src/api/allocate.ts\n/**\n* Distribute the amount of a Dinero object across a list of ratios.\n*\n* @param dineroObject - The Dinero object to allocate from.\n* @param ratios - The ratios to allocate the amount to.\n*\n* @returns A new Dinero object.\n*\n* @public\n*/\nfunction allocate(...[dineroObject, ratios]) {\n\tconst { calculator } = dineroObject;\n\treturn safeAllocate(calculator)(dineroObject, ratios);\n}\n\n//#endregion\n//#region src/api/compare.ts\n/**\n* Compare the value of a Dinero object relative to another.\n*\n* @param dineroObject - The Dinero object to compare.\n* @param comparator - The Dinero object to compare to.\n*\n* @returns One of -1, 0, or 1 depending on whether the first Dinero object is less than, equal to, or greater than the other.\n*\n* @public\n*/\nfunction compare(...[dineroObject, comparator]) {\n\tconst { calculator } = dineroObject;\n\treturn safeCompare(calculator)(dineroObject, comparator);\n}\n\n//#endregion\n//#region src/api/convert.ts\n/**\n* Convert a Dinero object to another currency.\n*\n* @param dineroObject - The Dinero object to format.\n* @param newCurrency - The currency to convert to.\n* @param rates - The rates to convert with.\n*\n* @returns A converted Dinero object.\n*\n* @public\n*/\nfunction convert(...[dineroObject, newCurrency, rates]) {\n\tconst { calculator } = dineroObject;\n\treturn convert$1(calculator)(dineroObject, newCurrency, rates);\n}\n\n//#endregion\n//#region src/api/equal.ts\n/**\n* Check whether the value of a Dinero object is equal to another.\n*\n* @param dineroObject - The first Dinero object to compare.\n* @param comparator - The second Dinero object to compare.\n*\n* @returns Whether the Dinero objects are equal.\n*\n* @public\n*/\nfunction equal(...[dineroObject, comparator]) {\n\tconst { calculator } = dineroObject;\n\treturn equal$1(calculator)(dineroObject, comparator);\n}\n\n//#endregion\n//#region src/api/greaterThan.ts\n/**\n* Check whether the value of a Dinero object is greater than another.\n*\n* @param dineroObject - The Dinero object to compare.\n* @param comparator - The Dinero object to compare to.\n*\n* @returns Whether the Dinero to compare is greater than the other.\n*\n* @public\n*/\nfunction greaterThan(...[dineroObject, comparator]) {\n\tconst { calculator } = dineroObject;\n\treturn safeGreaterThan(calculator)(dineroObject, comparator);\n}\n\n//#endregion\n//#region src/api/greaterThanOrEqual.ts\n/**\n* Check whether the value of a Dinero object is greater than or equal another.\n*\n* @param dineroObject - The Dinero object to compare.\n* @param comparator - The Dinero object to compare to.\n*\n* @returns Whether the Dinero to compare is greater than or equal the other.\n*\n* @public\n*/\nfunction greaterThanOrEqual(...[dineroObject, comparator]) {\n\tconst { calculator } = dineroObject;\n\treturn safeGreaterThanOrEqual(calculator)(dineroObject, comparator);\n}\n\n//#endregion\n//#region src/api/hasSubUnits.ts\n/**\n* Check whether a Dinero object has minor currency units.\n*\n* @param dineroObject - The Dinero object to check.\n*\n* @returns Whether the Dinero object has minor currency units.\n*\n* @public\n*/\nfunction hasSubUnits(...[dineroObject]) {\n\tconst { calculator } = dineroObject;\n\treturn hasSubUnits$1(calculator)(dineroObject);\n}\n\n//#endregion\n//#region src/api/haveSameAmount.ts\n/**\n* Check whether a set of Dinero objects have the same amount.\n*\n* @param dineroObjects - The Dinero objects to compare.\n*\n* @returns Whether the Dinero objects have the same amount.\n*\n* @public\n*/\nfunction haveSameAmount(...[dineroObjects]) {\n\tconst { calculator } = dineroObjects[0];\n\treturn haveSameAmount$1(calculator)(dineroObjects);\n}\n\n//#endregion\n//#region src/api/haveSameCurrency.ts\n/**\n* Check whether a set of Dinero objects have the same currency.\n*\n* @param dineroObjects - The Dinero objects to compare.\n*\n* @returns Whether the Dinero objects have the same currency.\n*\n* @public\n*/\nconst haveSameCurrency = haveSameCurrency$1;\n\n//#endregion\n//#region src/api/isNegative.ts\n/**\n* Check whether a Dinero object is negative.\n*\n* @param dineroObject - The Dinero object to check.\n*\n* @returns Whether the Dinero object is negative.\n*\n* @public\n*/\nfunction isNegative(...[dineroObject]) {\n\tconst { calculator } = dineroObject;\n\treturn isNegative$1(calculator)(dineroObject);\n}\n\n//#endregion\n//#region src/api/isPositive.ts\n/**\n* Check whether a Dinero object is positive.\n*\n* @param dineroObject - The Dinero object to check.\n*\n* @returns Whether the Dinero object is positive.\n*\n* @public\n*/\nfunction isPositive(...[dineroObject]) {\n\tconst { calculator } = dineroObject;\n\treturn isPositive$1(calculator)(dineroObject);\n}\n\n//#endregion\n//#region src/api/isZero.ts\n/**\n* Check whether the value of a Dinero object is zero.\n*\n* @param dineroObject - The Dinero object to check.\n*\n* @returns Whether the value of a Dinero object is zero.\n*\n* @public\n*/\nfunction isZero(...[dineroObject]) {\n\tconst { calculator } = dineroObject;\n\treturn isZero$1(calculator)(dineroObject);\n}\n\n//#endregion\n//#region src/api/lessThan.ts\n/**\n* Check whether the value of a Dinero object is lesser than another.\n*\n* @param dineroObject - The Dinero object to compare.\n* @param comparator - The Dinero object to compare to.\n*\n* @returns Whether the Dinero to compare is lesser than the other.\n*\n* @public\n*/\nfunction lessThan(...[dineroObject, comparator]) {\n\tconst { calculator } = dineroObject;\n\treturn safeLessThan(calculator)(dineroObject, comparator);\n}\n\n//#endregion\n//#region src/api/lessThanOrEqual.ts\n/**\n* Check whether the value of a Dinero object is lesser than or equal to another.\n*\n* @param dineroObject - The Dinero object to compare.\n* @param comparator - The Dinero object to compare to.\n*\n* @returns Whether the Dinero to compare is lesser than or equal to the other.\n*\n* @public\n*/\nfunction lessThanOrEqual(...[dineroObject, comparator]) {\n\tconst { calculator } = dineroObject;\n\treturn safeLessThanOrEqual(calculator)(dineroObject, comparator);\n}\n\n//#endregion\n//#region src/api/maximum.ts\n/**\n* Get the greatest of the passed Dinero objects.\n*\n* @param dineroObjects - The Dinero objects to maximum.\n*\n* @returns A new Dinero object.\n*\n* @public\n*/\nfunction maximum(...[dineroObjects]) {\n\tconst { calculator } = dineroObjects[0];\n\treturn safeMaximum(calculator)(dineroObjects);\n}\n\n//#endregion\n//#region src/api/minimum.ts\n/**\n* Get the lowest of the passed Dinero objects.\n*\n* @param dineroObjects - The Dinero objects to minimum.\n*\n* @returns A new Dinero object.\n*\n* @public\n*/\nfunction minimum(...[dineroObjects]) {\n\tconst { calculator } = dineroObjects[0];\n\treturn safeMinimum(calculator)(dineroObjects);\n}\n\n//#endregion\n//#region src/api/multiply.ts\n/**\n* Multiply the passed Dinero object.\n*\n* @param multiplicand - The Dinero object to multiply.\n* @param multiplier - The number to multiply with.\n*\n* @returns A new Dinero object.\n*\n* @public\n*/\nfunction multiply(...[multiplicand, multiplier]) {\n\tconst { calculator } = multiplicand;\n\treturn multiply$1(calculator)(multiplicand, multiplier);\n}\n\n//#endregion\n//#region src/api/normalizeScale.ts\n/**\n* Normalize a set of Dinero objects to the highest scale of the set.\n*\n* @param dineroObjects - The Dinero objects to normalize.\n*\n* @returns A new set of Dinero objects.\n*\n* @public\n*/\nfunction normalizeScale(...[dineroObjects]) {\n\tconst { calculator } = dineroObjects[0];\n\treturn normalizeScale$1(calculator)(dineroObjects);\n}\n\n//#endregion\n//#region src/api/subtract.ts\n/**\n* Subtract the passed Dinero objects.\n*\n* @param minuend - The Dinero object to subtract from.\n* @param subtrahend - The Dinero object to subtract.\n*\n* @returns A new Dinero object.\n*\n* @public\n*/\nfunction subtract(...[minuend, subtrahend]) {\n\tconst { calculator } = minuend;\n\treturn safeSubtract(calculator)(minuend, subtrahend);\n}\n\n//#endregion\n//#region src/api/toDecimal.ts\n/**\n* Get the amount of a Dinero object in decimal form.\n*\n* @param dineroObject - The Dinero object to format.\n* @param transformer - A transformer function.\n*\n* @returns The amount in decimal form.\n*\n* @public\n*/\nfunction toDecimal(...[dineroObject, transformer]) {\n\tconst { calculator } = dineroObject;\n\treturn toDecimal$1(calculator)(dineroObject, transformer);\n}\n\n//#endregion\n//#region src/api/toSnapshot.ts\n/**\n* Get a snapshot of a Dinero object.\n*\n* @param dineroObject - The Dinero object to format.\n* @param transformer - A transformer function.\n*\n* @returns A snapshot of the object.\n*\n* @public\n*/\nconst toSnapshot = toSnapshot$1;\n\n//#endregion\n//#region src/api/toUnits.ts\n/**\n* Get the amount of a Dinero object in units.\n*\n* @param dineroObject - The Dinero object to format.\n* @param transformer - A transformer function.\n*\n* @returns The amount in units.\n*\n* @public\n*/\nfunction toUnits(...[dineroObject, transformer]) {\n\tconst { calculator } = dineroObject;\n\treturn toUnits$1(calculator)(dineroObject, transformer);\n}\n\n//#endregion\n//#region src/api/transformScale.ts\n/**\n* Transform a Dinero object to a new scale.\n*\n* @param dineroObject - The Dinero object to transform.\n* @param newScale - The new scale.\n* @param divide - A custom divide function.\n*\n* @returns A new Dinero object.\n*\n* @public\n*/\nfunction transformScale(...[dineroObject, newScale, divide]) {\n\tconst { calculator } = dineroObject;\n\treturn transformScale$1(calculator)(dineroObject, newScale, divide);\n}\n\n//#endregion\n//#region src/api/trimScale.ts\n/**\n* Trim a Dinero object's scale as much as possible, down to the currency exponent.\n*\n* @param dineroObject - The Dinero object which scale to trim.\n*\n* @returns A new Dinero object.\n*\n* @public\n*/\nfunction trimScale(...[dineroObject]) {\n\tconst { calculator } = dineroObject;\n\treturn trimScale$1(calculator)(dineroObject);\n}\n\n//#endregion\nexport { halfEven as A, compare as C, halfUp as D, up as E, createDinero as F, assert as I, INVALID_AMOUNT_MESSAGE as L, halfAwayFromZero as M, down as N, halfTowardsZero as O, DineroComparisonOperator as P, INVALID_SCALE_MESSAGE as R, convert as S, add as T, haveSameAmount as _, toDecimal as a, greaterThan as b, multiply as c, lessThanOrEqual as d, lessThan as f, haveSameCurrency as g, isNegative as h, toSnapshot as i, halfDown as j, halfOdd as k, minimum as l, isPositive as m, transformScale as n, subtract as o, isZero as p, toUnits as r, normalizeScale as s, trimScale as t, maximum as u, hasSubUnits as v, allocate as w, equal as x, greaterThanOrEqual as y };","import { A as halfEven, C as compare, D as halfUp, E as up, F as createDinero, M as halfAwayFromZero, N as down, O as halfTowardsZero, P as DineroComparisonOperator, S as convert, T as add, _ as haveSameAmount, a as toDecimal, b as greaterThan, c as multiply, d as lessThanOrEqual, f as lessThan, g as haveSameCurrency, h as isNegative, i as toSnapshot, j as halfDown, k as halfOdd, l as minimum, m as isPositive, n as transformScale, o as subtract, p as isZero, r as toUnits, s as normalizeScale, t as trimScale, u as maximum, v as hasSubUnits, w as allocate, x as equal, y as greaterThanOrEqual } from \"../trimScale-C3-DjbPM.js\";\nimport { AED, AFN, ALL, AMD, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BOV, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHE, CHF, CHW, CLF, CLP, CNY, COP, COU, CRC, CUP, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JMD, JOD, JPY, KES, KGS, KHR, KMF, KPW, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MXV, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLE, SOS, SRD, SSP, STN, SVC, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USN, UYI, UYU, UYW, UZS, VED, VES, VND, VUV, WST, XAD, XAF, XCD, XCG, XOF, XPF, YER, ZAR, ZMW, ZWG } from \"./currencies/index.js\";\n\n//#region src/calculator/bigint/api/add.ts\n/**\n* Returns the sum of two bigints.\n*\n* @param augend - The bigint to add to.\n* @param addend - The bigint to add.\n*\n* @returns The sum of the two bigints.\n*/\nconst add$1 = (augend, addend) => {\n\treturn augend + addend;\n};\n\n//#endregion\n//#region src/calculator/bigint/api/compare.ts\n/**\n* Compare two bigints.\n*\n* @param a - The first bigint to compare.\n* @param b - The second bigint to compare.\n*\n* @returns Whether the two bigints are equal, or whether the first one is greater or less than the other.\n*/\nconst compare$1 = (a, b) => {\n\tif (a < b) return DineroComparisonOperator.LT;\n\tif (a > b) return DineroComparisonOperator.GT;\n\treturn DineroComparisonOperator.EQ;\n};\n\n//#endregion\n//#region src/calculator/bigint/api/decrement.ts\n/**\n* Returns an decremented bigint.\n*\n* @param value - The bigint to decrement.\n*\n* @returns The decremented bigint.\n*/\nconst decrement = (value) => {\n\treturn value - 1n;\n};\n\n//#endregion\n//#region src/calculator/bigint/api/increment.ts\n/**\n* Returns an incremented bigint.\n*\n* @param value - The bigint to increment.\n*\n* @returns The incremented bigint.\n*/\nconst increment = (value) => {\n\treturn value + 1n;\n};\n\n//#endregion\n//#region src/calculator/bigint/api/integerDivide.ts\n/**\n* Returns the quotient of two bigints with no fractional part.\n*\n* @param dividend - The bigint to divide.\n* @param divisor - The bigint to divide with.\n*\n* @returns The quotient of the two bigints.\n*/\nconst integerDivide = (dividend, divisor) => {\n\treturn dividend / divisor;\n};\n\n//#endregion\n//#region src/calculator/bigint/api/modulo.ts\n/**\n* Returns the remainder of two bigints.\n*\n* @param dividend - The bigint to divide.\n* @param divisor - The bigint to divide with.\n*\n* @returns The remainder of the two bigints.\n*/\nconst modulo = (dividend, divisor) => {\n\treturn dividend % divisor;\n};\n\n//#endregion\n//#region src/calculator/bigint/api/multiply.ts\n/**\n* Returns the product of two bigints.\n*\n* @param multiplicand - The bigint to multiply.\n* @param multiplier - The bigint to multiply with.\n*\n* @returns The product of the two bigints.\n*/\nconst multiply$1 = (multiplicand, multiplier) => {\n\treturn multiplicand * multiplier;\n};\n\n//#endregion\n//#region src/calculator/bigint/api/power.ts\n/**\n* Returns an bigint to the power of an exponent.\n*\n* @param base - The base bigint.\n* @param exponent - The exponent to raise the base to.\n*\n* @returns The base to the power of the exponent.\n*/\nconst power = (base, exponent) => {\n\treturn base ** exponent;\n};\n\n//#endregion\n//#region src/calculator/bigint/api/subtract.ts\n/**\n* Returns the difference between two bigints.\n*\n* @param minuend - The bigint to subtract from.\n* @param subtrahend - The bigint to subtract.\n*\n* @returns The difference of the two bigints.\n*/\nconst subtract$1 = (minuend, subtrahend) => {\n\treturn minuend - subtrahend;\n};\n\n//#endregion\n//#region src/calculator/bigint/api/zero.ts\n/**\n* Return zero as a bigint.\n*\n* @returns Zero as a bigint.\n*/\nfunction zero() {\n\treturn 0n;\n}\n\n//#endregion\n//#region src/calculator/bigint/calculator.ts\nconst calculator = {\n\tadd: add$1,\n\tcompare: compare$1,\n\tdecrement,\n\tincrement,\n\tintegerDivide,\n\tmodulo,\n\tmultiply: multiply$1,\n\tpower,\n\tsubtract: subtract$1,\n\tzero\n};\n\n//#endregion\n//#region src/bigint/dinero.ts\n/**\n* Create a Dinero object with bigint amounts.\n*\n* @param options.amount - The amount in minor currency units as a bigint.\n* @param options.currency - The currency.\n* @param options.scale - The number of decimal places to represent.\n*\n* @returns The created Dinero object.\n*\n* @public\n*/\nconst dinero = createDinero({ calculator });\n\n//#endregion\nexport { AED, AFN, ALL, AMD, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BOV, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHE, CHF, CHW, CLF, CLP, CNY, COP, COU, CRC, CUP, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JMD, JOD, JPY, KES, KGS, KHR, KMF, KPW, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MXV, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLE, SOS, SRD, SSP, STN, SVC, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USN, UYI, UYU, UYW, UZS, VED, VES, VND, VUV, WST, XAD, XAF, XCD, XCG, XOF, XPF, YER, ZAR, ZMW, ZWG, add, allocate, calculator, compare, convert, createDinero, dinero, down, equal, greaterThan, greaterThanOrEqual, halfAwayFromZero, halfDown, halfEven, halfOdd, halfTowardsZero, halfUp, hasSubUnits, haveSameAmount, haveSameCurrency, isNegative, isPositive, isZero, lessThan, lessThanOrEqual, maximum, minimum, multiply, normalizeScale, subtract, toDecimal, toSnapshot, toUnits, transformScale, trimScale, up };","import Decimal from 'decimal.js';\nimport type { DineroCurrency } from 'dinero.js/bigint';\nimport { dinero, toDecimal } from 'dinero.js/bigint';\nimport * as currencies from 'dinero.js/bigint/currencies';\nimport { getLocale } from './locale';\n\nfunction resolveCurrency(currencyCode: string): DineroCurrency<bigint> {\n const currency = (currencies as Record<string, DineroCurrency<bigint> | undefined>)[currencyCode];\n if (!currency) throw new Error(`Unknown currency: ${currencyCode}`);\n return currency;\n}\n\nexport function minorToMajor(minor: string, currencyCode: string): string {\n const currency = resolveCurrency(currencyCode);\n return toDecimal(dinero({ amount: BigInt(minor), currency }));\n}\n\nexport function majorToMinor(major: string, currencyCode: string): string {\n const currency = resolveCurrency(currencyCode);\n const factor = new Decimal(10).pow(Number(currency.exponent));\n return new Decimal(major).mul(factor).toFixed(0);\n}\n\nexport function formatCurrencyMajor(major: number, currencyCode: string): string {\n return new Intl.NumberFormat(getLocale() ?? 'en-US', {\n style: 'currency',\n currency: currencyCode,\n }).format(major);\n}\n\nexport function formatCurrency(minor: string, currencyCode: string): string {\n return formatCurrencyMajor(Number(minorToMajor(minor, currencyCode)), currencyCode);\n}\n"],"names":[],"mappings":";;;;AAAA;AAKA,MAAM,4BAA4B,GAAG,0BAA0B;;AAG/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE;AACpC,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,IAAI,KAAK,CAAC,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC;AAC1D;;AAEA;AACA;AACA,SAAS,YAAY,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,GA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;AACrE,EAAA,MAAM,QAAA,GAAY,WAAkE,YAAY,CAAA;AAChG,EAAA,IAAI,CAAC,QAAA,EAAU,MAAM,IAAI,KAAA,CAAM,CAAA,kBAAA,EAAqB,YAAY,CAAA,CAAE,CAAA;AAClE,EAAA,OAAO,QAAA;AACT;AAEO,SAAS,YAAA,CAAa,OAAe,YAAA,EAA8B;AACxE,EAAA,MAAM,QAAA,GAAW,gBAAgB,YAAY,CAAA;AAC7C,EAAA,OAAO,SAAA,CAAU,OAAO,EAAE,MAAA,EAAQ,OAAO,KAAK,CAAA,EAAG,QAAA,EAAU,CAAC,CAAA;AAC9D;AAEO,SAAS,YAAA,CAAa,OAAe,YAAA,EAA8B;AACxE,EAAA,MAAM,QAAA,GAAW,gBAAgB,YAAY,CAAA;AAC7C,EAAA,MAAM,MAAA,GAAS,IAAI,OAAA,CAAQ,EAAE,EAAE,GAAA,CAAI,MAAA,CAAO,QAAA,CAAS,QAAQ,CAAC,CAAA;AAC5D,EAAA,OAAO,IAAI,QAAQ,KAAK,CAAA,CAAE,IAAI,MAAM,CAAA,CAAE,QAAQ,CAAC,CAAA;AACjD;AAEO,SAAS,mBAAA,CAAoB,OAAe,YAAA,EAA8B;AAC/E,EAAA,OAAO,IAAI,IAAA,CAAK,YAAA,CAAa,SAAA,MAAe,OAAA,EAAS;AAAA,IACnD,KAAA,EAAO,UAAA;AAAA,IACP,QAAA,EAAU;AAAA,GACX,CAAA,CAAE,MAAA,CAAO,KAAK,CAAA;AACjB;AAEO,SAAS,cAAA,CAAe,OAAe,YAAA,EAA8B;AAC1E,EAAA,OAAO,oBAAoB,MAAA,CAAO,YAAA,CAAa,OAAO,YAAY,CAAC,GAAG,YAAY,CAAA;AACpF;;;;","x_google_ignoreList":[0,1]}
1
+ {"version":3,"file":"money.js","sources":["../../node_modules/.pnpm/dinero.js@2.0.2/node_modules/dinero.js/dist/esm/trimScale-C3-DjbPM.js","../../node_modules/.pnpm/dinero.js@2.0.2/node_modules/dinero.js/dist/esm/bigint/index.js","../../lib/utils/money.ts"],"sourcesContent":["//#region src/core/checks/messages.ts\nconst INVALID_AMOUNT_MESSAGE = \"Amount is invalid.\";\nconst INVALID_SCALE_MESSAGE = \"Scale is invalid.\";\nconst INVALID_RATIOS_MESSAGE = \"Ratios are invalid.\";\nconst UNEQUAL_CURRENCIES_MESSAGE = \"Objects must have the same currency.\";\nconst NON_DECIMAL_CURRENCY_MESSAGE = \"Currency is not decimal.\";\nconst MISMATCHED_BASES_MESSAGE = \"Objects must have the same currency base.\";\n\n//#endregion\n//#region src/core/helpers/assert.ts\n/**\n* Assert a condition.\n*\n* @param condition - The condition to verify.\n* @param message - The error message to throw.\n*\n* @throws If the condition isn't met.\n*/\nfunction assert(condition, message) {\n\tif (!condition) throw new Error(`[Dinero.js] ${message}`);\n}\n\n//#endregion\n//#region src/core/helpers/createDinero.ts\nfunction createDinero({ calculator, onCreate, formatter = {\n\ttoNumber: Number,\n\ttoString: String\n} }) {\n\treturn function dinero({ amount, currency: { code, base, exponent }, scale = exponent }) {\n\t\tconst currency = {\n\t\t\tcode,\n\t\t\tbase,\n\t\t\texponent\n\t\t};\n\t\tonCreate?.({\n\t\t\tamount,\n\t\t\tcurrency,\n\t\t\tscale\n\t\t});\n\t\treturn {\n\t\t\tcalculator,\n\t\t\tformatter,\n\t\t\tcreate: dinero,\n\t\t\ttoJSON() {\n\t\t\t\treturn {\n\t\t\t\t\tamount,\n\t\t\t\t\tcurrency,\n\t\t\t\t\tscale\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\t};\n}\n\n//#endregion\n//#region src/core/types/DineroCalculator.ts\nlet DineroComparisonOperator = /* @__PURE__ */ function(DineroComparisonOperator) {\n\tDineroComparisonOperator[DineroComparisonOperator[\"LT\"] = -1] = \"LT\";\n\tDineroComparisonOperator[DineroComparisonOperator[\"EQ\"] = 0] = \"EQ\";\n\tDineroComparisonOperator[DineroComparisonOperator[\"GT\"] = 1] = \"GT\";\n\treturn DineroComparisonOperator;\n}({});\n\n//#endregion\n//#region src/core/utils/equal.ts\n/**\n* Returns an equal function.\n*\n* @param calculator - The calculator to use.\n*\n* @returns The equal function.\n*/\nfunction equal$2(calculator) {\n\treturn (subject, comparator) => {\n\t\treturn calculator.compare(subject, comparator) === DineroComparisonOperator.EQ;\n\t};\n}\n\n//#endregion\n//#region src/core/utils/lessThan.ts\n/**\n* Returns a lessThan function.\n*\n* @param calculator - The calculator to use.\n*\n* @returns The lessThan function.\n*/\nfunction lessThan$1(calculator) {\n\treturn (subject, comparator) => {\n\t\treturn calculator.compare(subject, comparator) === DineroComparisonOperator.LT;\n\t};\n}\n\n//#endregion\n//#region src/core/utils/absolute.ts\nfunction absolute(calculator) {\n\tconst equalFn = equal$2(calculator);\n\tconst lessThanFn = lessThan$1(calculator);\n\tconst zero = calculator.zero();\n\treturn (input) => {\n\t\tif (equalFn(input, zero)) return zero;\n\t\tif (lessThanFn(input, zero)) {\n\t\t\tconst minusOne = calculator.decrement(zero);\n\t\t\treturn calculator.multiply(minusOne, input);\n\t\t}\n\t\treturn input;\n\t};\n}\n\n//#endregion\n//#region src/core/utils/compare.ts\n/**\n* Returns a compare function.\n*\n* @param calculator - The calculator to use.\n*\n* @returns The compare function.\n*/\nfunction compare$1(calculator) {\n\treturn (subject, comparator) => {\n\t\treturn calculator.compare(subject, comparator);\n\t};\n}\n\n//#endregion\n//#region src/core/utils/isArray.ts\nfunction isArray(maybeArray) {\n\treturn Array.isArray(maybeArray);\n}\n\n//#endregion\n//#region src/core/utils/computeBase.ts\nfunction computeBase(calculator) {\n\treturn (base) => {\n\t\tif (isArray(base)) return base.reduce((acc, curr) => calculator.multiply(acc, curr));\n\t\treturn base;\n\t};\n}\n\n//#endregion\n//#region src/core/utils/countTrailingZeros.ts\nfunction countTrailingZeros(calculator) {\n\tconst equalFn = equal$2(calculator);\n\treturn (input, base) => {\n\t\tconst zero = calculator.zero();\n\t\tif (equalFn(zero, input)) return calculator.zero();\n\t\tlet i = zero;\n\t\tlet temp = input;\n\t\twhile (equalFn(calculator.modulo(temp, base), zero)) {\n\t\t\ttemp = calculator.integerDivide(temp, base);\n\t\t\ti = calculator.increment(i);\n\t\t}\n\t\treturn i;\n\t};\n}\n\n//#endregion\n//#region src/core/utils/greaterThan.ts\n/**\n* Returns a greaterThan function.\n*\n* @param calculator - The calculator to use.\n*\n* @returns The greaterThan function.\n*/\nfunction greaterThan$1(calculator) {\n\treturn (subject, comparator) => {\n\t\treturn calculator.compare(subject, comparator) === DineroComparisonOperator.GT;\n\t};\n}\n\n//#endregion\n//#region src/core/utils/greaterThanOrEqual.ts\n/**\n* Returns a greaterThanOrEqual function.\n*\n* @param calculator - The calculator to use.\n*\n* @returns The greaterThanOrEqual function.\n*/\nfunction greaterThanOrEqual$1(calculator) {\n\treturn (subject, comparator) => {\n\t\treturn greaterThan$1(calculator)(subject, comparator) || equal$2(calculator)(subject, comparator);\n\t};\n}\n\n//#endregion\n//#region src/core/utils/distribute.ts\n/**\n* Returns a distribute function.\n*\n* @param calculator - The calculator to use.\n*\n* @returns The distribute function.\n*/\nfunction distribute(calculator) {\n\treturn (value, ratios) => {\n\t\tconst equalFn = equal$2(calculator);\n\t\tconst greaterThanFn = greaterThan$1(calculator);\n\t\tconst lessThanFn = lessThan$1(calculator);\n\t\tconst greaterThanOrEqualFn = greaterThanOrEqual$1(calculator);\n\t\tconst zero = calculator.zero();\n\t\tconst one = calculator.increment(zero);\n\t\tconst total = ratios.reduce((a, b) => calculator.add(a, b), zero);\n\t\tif (equalFn(total, zero)) return ratios;\n\t\tlet remainder = value;\n\t\tconst shares = ratios.map((ratio) => {\n\t\t\tconst share = calculator.integerDivide(calculator.multiply(value, ratio), total) || zero;\n\t\t\tremainder = calculator.subtract(remainder, share);\n\t\t\treturn share;\n\t\t});\n\t\tconst isPositive = greaterThanOrEqualFn(value, zero);\n\t\tconst compare = isPositive ? greaterThanFn : lessThanFn;\n\t\tconst amount = isPositive ? one : calculator.decrement(zero);\n\t\tconst sortedIndices = ratios.map((ratio, index) => ({\n\t\t\tratio,\n\t\t\tindex\n\t\t})).filter(({ ratio }) => !equalFn(ratio, zero)).sort((a, b) => greaterThanFn(a.ratio, b.ratio) ? -1 : 1).map(({ index }) => index);\n\t\tlet i = 0;\n\t\twhile (compare(remainder, zero)) {\n\t\t\tconst index = sortedIndices[i % sortedIndices.length];\n\t\t\tshares[index] = calculator.add(shares[index], amount);\n\t\t\tconst newRemainder = calculator.subtract(remainder, amount);\n\t\t\tif (equalFn(newRemainder, remainder)) break;\n\t\t\tremainder = newRemainder;\n\t\t\ti++;\n\t\t}\n\t\treturn shares;\n\t};\n}\n\n//#endregion\n//#region src/core/utils/isScaledAmount.ts\nfunction isScaledAmount(amount) {\n\treturn amount?.hasOwnProperty(\"amount\");\n}\n\n//#endregion\n//#region src/core/utils/getAmountAndScale.ts\nfunction getAmountAndScale(value, zero) {\n\tif (isScaledAmount(value)) return {\n\t\tamount: value.amount,\n\t\tscale: value?.scale ?? zero\n\t};\n\treturn {\n\t\tamount: value,\n\t\tscale: zero\n\t};\n}\n\n//#endregion\n//#region src/core/utils/getDivisors.ts\nfunction getDivisors(calculator) {\n\tconst { multiply } = calculator;\n\treturn (bases) => {\n\t\treturn bases.reduce((divisors, _, i) => {\n\t\t\tconst divisor = bases.slice(i).reduce((acc, curr) => multiply(acc, curr));\n\t\t\treturn [...divisors, divisor];\n\t\t}, []);\n\t};\n}\n\n//#endregion\n//#region src/core/utils/isEven.ts\nfunction isEven(calculator) {\n\tconst equalFn = equal$2(calculator);\n\tconst zero = calculator.zero();\n\tconst two = calculator.increment(calculator.increment(zero));\n\treturn (input) => {\n\t\treturn equalFn(calculator.modulo(input, two), zero);\n\t};\n}\n\n//#endregion\n//#region src/core/utils/isHalf.ts\nfunction isHalf(calculator) {\n\tconst equalFn = equal$2(calculator);\n\tconst absoluteFn = absolute(calculator);\n\treturn (input, total) => {\n\t\tconst remainder = absoluteFn(calculator.modulo(input, total));\n\t\treturn equalFn(calculator.subtract(total, remainder), remainder);\n\t};\n}\n\n//#endregion\n//#region src/core/utils/lessThanOrEqual.ts\n/**\n* Returns a lessThanOrEqual function.\n*\n* @param calculator - The calculator to use.\n*\n* @returns The lessThanOrEqual function.\n*/\nfunction lessThanOrEqual$1(calculator) {\n\treturn (subject, comparator) => {\n\t\treturn lessThan$1(calculator)(subject, comparator) || equal$2(calculator)(subject, comparator);\n\t};\n}\n\n//#endregion\n//#region src/core/utils/maximum.ts\n/**\n* Returns a maximum function.\n*\n* @param calculator - The calculator to use.\n*\n* @returns The maximum function.\n*/\nfunction maximum$1(calculator) {\n\tconst lessThanFn = lessThan$1(calculator);\n\treturn (values) => {\n\t\treturn values.reduce((acc, curr) => {\n\t\t\treturn lessThanFn(acc, curr) ? curr : acc;\n\t\t});\n\t};\n}\n\n//#endregion\n//#region src/core/utils/minimum.ts\n/**\n* Returns a minimum function.\n*\n* @param calculator - The calculator to use.\n*\n* @returns The minimum function.\n*/\nfunction minimum$1(calculator) {\n\tconst greaterThanFn = greaterThan$1(calculator);\n\treturn (values) => {\n\t\treturn values.reduce((acc, curr) => {\n\t\t\treturn greaterThanFn(acc, curr) ? curr : acc;\n\t\t});\n\t};\n}\n\n//#endregion\n//#region src/core/utils/sign.ts\nfunction sign(calculator) {\n\tconst equalFn = equal$2(calculator);\n\tconst lessThanFn = lessThan$1(calculator);\n\tconst zero = calculator.zero();\n\treturn (input) => {\n\t\tif (equalFn(input, zero)) return zero;\n\t\tconst one = calculator.increment(zero);\n\t\tconst minusOne = calculator.decrement(zero);\n\t\treturn lessThanFn(input, zero) ? minusOne : one;\n\t};\n}\n\n//#endregion\n//#region src/core/api/haveSameCurrency.ts\nfunction haveSameCurrency$1(dineroObjects) {\n\tconst [firstDinero, ...otherDineros] = dineroObjects;\n\tconst computeBaseFn = computeBase(firstDinero.calculator);\n\tconst { currency: comparator } = firstDinero.toJSON();\n\tconst equalFn = equal$2(firstDinero.calculator);\n\tconst comparatorBase = computeBaseFn(comparator.base);\n\treturn otherDineros.every((d) => {\n\t\tconst { currency: subject } = d.toJSON();\n\t\tconst subjectBase = computeBaseFn(subject.base);\n\t\treturn subject.code === comparator.code && equalFn(subjectBase, comparatorBase) && equalFn(subject.exponent, comparator.exponent);\n\t});\n}\n\n//#endregion\n//#region src/core/divide/down.ts\n/**\n* Divide and round down.\n*\n* Rounding down happens whenever the quotient is not an integer.\n*\n* @param amount - The amount to divide.\n* @param factor - The factor to divide by.\n* @param calculator - The calculator to use.\n*\n* @returns The rounded amount.\n*/\nconst down = (amount, factor, calculator) => {\n\tconst greaterThanFn = greaterThan$1(calculator);\n\tconst equalFn = equal$2(calculator);\n\tconst zero = calculator.zero();\n\tconst isPositive = greaterThanFn(amount, zero);\n\tconst quotient = calculator.integerDivide(amount, factor);\n\tconst isInteger = equalFn(calculator.modulo(amount, factor), zero);\n\tif (isPositive || isInteger) return quotient;\n\treturn calculator.decrement(quotient);\n};\n\n//#endregion\n//#region src/core/divide/halfAwayFromZero.ts\n/**\n* Divide and round towards \"nearest neighbor\" unless both neighbors are\n* equidistant, in which case round away from zero.\n*\n* @param amount - The amount to divide.\n* @param factor - The factor to divide by.\n* @param calculator - The calculator to use.\n*\n* @returns The rounded amount.\n*/\nconst halfAwayFromZero = (amount, factor, calculator) => {\n\tconst signFn = sign(calculator);\n\tconst isHalfFn = isHalf(calculator);\n\tconst absoluteFn = absolute(calculator);\n\tif (!isHalfFn(amount, factor)) return halfUp(amount, factor, calculator);\n\treturn calculator.multiply(signFn(amount), up(absoluteFn(amount), factor, calculator));\n};\n\n//#endregion\n//#region src/core/divide/halfDown.ts\n/**\n* Divide and round towards \"nearest neighbor\" unless both neighbors are\n* equidistant, in which case round down.\n*\n* Rounding down happens when:\n* - The quotient is half (e.g., -1.5, 1.5).\n* - The quotient is positive and less than half (e.g., 1.4).\n* - The quotient is negative and greater than half (e.g., -1.6).\n*\n* @param amount - The amount to divide.\n* @param factor - The factor to divide by.\n* @param calculator - The calculator to use.\n*\n* @returns The rounded amount.\n*/\nconst halfDown = (amount, factor, calculator) => {\n\tif (isHalf(calculator)(amount, factor)) return down(amount, factor, calculator);\n\treturn halfUp(amount, factor, calculator);\n};\n\n//#endregion\n//#region src/core/divide/halfEven.ts\n/**\n* Divide and round towards \"nearest neighbor\" unless both neighbors are\n* equidistant, in which case round to the nearest even integer.\n*\n* @param amount - The amount to divide.\n* @param factor - The factor to divide by.\n* @param calculator - The calculator to use.\n*\n* @returns The rounded amount.\n*/\nconst halfEven = (amount, factor, calculator) => {\n\tconst isEvenFn = isEven(calculator);\n\tconst isHalfFn = isHalf(calculator);\n\tconst rounded = halfUp(amount, factor, calculator);\n\tif (!isHalfFn(amount, factor)) return rounded;\n\treturn isEvenFn(rounded) ? rounded : calculator.decrement(rounded);\n};\n\n//#endregion\n//#region src/core/divide/halfOdd.ts\n/**\n* Divide and round towards \"nearest neighbor\" unless both neighbors are\n* equidistant, in which case round to the nearest odd integer.\n*\n* @param amount - The amount to divide.\n* @param factor - The factor to divide by.\n* @param calculator - The calculator to use.\n*\n* @returns The rounded amount.\n*/\nconst halfOdd = (amount, factor, calculator) => {\n\tconst isEvenFn = isEven(calculator);\n\tconst isHalfFn = isHalf(calculator);\n\tconst rounded = halfUp(amount, factor, calculator);\n\tif (!isHalfFn(amount, factor)) return rounded;\n\treturn isEvenFn(rounded) ? calculator.decrement(rounded) : rounded;\n};\n\n//#endregion\n//#region src/core/divide/halfTowardsZero.ts\n/**\n* Divide and round towards \"nearest neighbor\" unless both neighbors are\n* equidistant, in which case round towards zero.\n*\n* @param amount - The amount to divide.\n* @param factor - The factor to divide by.\n* @param calculator - The calculator to use.\n*\n* @returns The rounded amount.\n*/\nconst halfTowardsZero = (amount, factor, calculator) => {\n\tconst signFn = sign(calculator);\n\tconst isHalfFn = isHalf(calculator);\n\tconst absoluteFn = absolute(calculator);\n\tif (!isHalfFn(amount, factor)) return halfUp(amount, factor, calculator);\n\treturn calculator.multiply(signFn(amount), down(absoluteFn(amount), factor, calculator));\n};\n\n//#endregion\n//#region src/core/divide/halfUp.ts\n/**\n* Divide and round towards \"nearest neighbor\" unless both neighbors are\n* equidistant, in which case round up.\n*\n* Rounding up happens when:\n* - The quotient is half (e.g., -1.5, 1.5).\n* - The quotient is positive and greater than half (e.g., 1.6).\n* - The quotient is negative and less than half (e.g., -1.4).\n*\n* @param amount - The amount to divide.\n* @param factor - The factor to divide by.\n* @param calculator - The calculator to use.\n*\n* @returns The rounded amount.\n*/\nconst halfUp = (amount, factor, calculator) => {\n\tconst greaterThanFn = greaterThan$1(calculator);\n\tconst isHalfFn = isHalf(calculator);\n\tconst absoluteFn = absolute(calculator);\n\tconst zero = calculator.zero();\n\tconst remainder = absoluteFn(calculator.modulo(amount, factor));\n\tconst isLessThanHalf = greaterThanFn(calculator.subtract(factor, remainder), remainder);\n\tconst isPositive = greaterThanFn(amount, zero);\n\tif (isHalfFn(amount, factor) || isPositive && !isLessThanHalf || !isPositive && isLessThanHalf) return up(amount, factor, calculator);\n\treturn down(amount, factor, calculator);\n};\n\n//#endregion\n//#region src/core/divide/up.ts\n/**\n* Divide and round up.\n*\n* Rounding up happens whenever the quotient is not an integer.\n*\n* @param amount - The amount to divide.\n* @param factor - The factor to divide by.\n* @param calculator - The calculator to use.\n*\n* @returns The rounded amount.\n*/\nconst up = (amount, factor, calculator) => {\n\tconst greaterThanFn = greaterThan$1(calculator);\n\tconst equalFn = equal$2(calculator);\n\tconst zero = calculator.zero();\n\tconst isPositive = greaterThanFn(amount, zero);\n\tconst quotient = calculator.integerDivide(amount, factor);\n\tif (!equalFn(calculator.modulo(amount, factor), zero) && isPositive) return calculator.increment(quotient);\n\treturn quotient;\n};\n\n//#endregion\n//#region src/core/api/transformScale.ts\nfunction transformScale$1(calculator) {\n\tconst greaterThanFn = greaterThan$1(calculator);\n\tconst computeBaseFn = computeBase(calculator);\n\treturn function transformScaleFn(...[dineroObject, newScale, divide = down]) {\n\t\tconst { amount, currency, scale } = dineroObject.toJSON();\n\t\tconst isLarger = greaterThanFn(newScale, scale);\n\t\tconst operation = isLarger ? calculator.multiply : divide;\n\t\tconst [a, b] = isLarger ? [newScale, scale] : [scale, newScale];\n\t\tconst base = computeBaseFn(currency.base);\n\t\tconst factor = calculator.power(base, calculator.subtract(a, b));\n\t\treturn dineroObject.create({\n\t\t\tamount: operation(amount, factor, calculator),\n\t\t\tcurrency,\n\t\t\tscale: newScale\n\t\t});\n\t};\n}\n\n//#endregion\n//#region src/core/api/normalizeScale.ts\nfunction normalizeScale$1(calculator) {\n\tconst maximumFn = maximum$1(calculator);\n\tconst convertScaleFn = transformScale$1(calculator);\n\tconst equalFn = equal$2(calculator);\n\treturn function _normalizeScale(...[dineroObjects]) {\n\t\tconst highestScale = dineroObjects.reduce((highest, current) => {\n\t\t\tconst { scale } = current.toJSON();\n\t\t\treturn maximumFn([highest, scale]);\n\t\t}, calculator.zero());\n\t\treturn dineroObjects.map((d) => {\n\t\t\tconst { scale } = d.toJSON();\n\t\t\treturn !equalFn(scale, highestScale) ? convertScaleFn(d, highestScale) : d;\n\t\t});\n\t};\n}\n\n//#endregion\n//#region src/core/api/add.ts\nfunction unsafeAdd(calculator) {\n\treturn function add(...[augend, addend]) {\n\t\tconst { amount: augendAmount, currency, scale } = augend.toJSON();\n\t\tconst { amount: addendAmount } = addend.toJSON();\n\t\tconst amount = calculator.add(augendAmount, addendAmount);\n\t\treturn augend.create({\n\t\t\tamount,\n\t\t\tcurrency,\n\t\t\tscale\n\t\t});\n\t};\n}\nfunction safeAdd(calculator) {\n\tconst normalizeFn = normalizeScale$1(calculator);\n\tconst addFn = unsafeAdd(calculator);\n\treturn function add(...[augend, addend]) {\n\t\tassert(haveSameCurrency$1([augend, addend]), UNEQUAL_CURRENCIES_MESSAGE);\n\t\tconst [newAugend, newAddend] = normalizeFn([augend, addend]);\n\t\treturn addFn(newAugend, newAddend);\n\t};\n}\n\n//#endregion\n//#region src/core/api/allocate.ts\nfunction unsafeAllocate(calculator) {\n\treturn function allocate(...[dineroObject, ratios]) {\n\t\tconst { amount, currency, scale } = dineroObject.toJSON();\n\t\treturn distribute(calculator)(amount, ratios.map((ratio) => ratio.amount)).map((share) => {\n\t\t\treturn dineroObject.create({\n\t\t\t\tamount: share,\n\t\t\t\tcurrency,\n\t\t\t\tscale\n\t\t\t});\n\t\t});\n\t};\n}\nfunction safeAllocate(calculator) {\n\tconst allocateFn = unsafeAllocate(calculator);\n\tconst greaterThanOrEqualFn = greaterThanOrEqual$1(calculator);\n\tconst greaterThanFn = greaterThan$1(calculator);\n\tconst convertScaleFn = transformScale$1(calculator);\n\tconst maximumFn = maximum$1(calculator);\n\tconst equalFn = equal$2(calculator);\n\tconst zero = calculator.zero();\n\tconst ten = new Array(10).fill(null).reduce(calculator.increment, zero);\n\treturn function allocate(...[dineroObject, ratios]) {\n\t\tconst hasRatios = ratios.length > 0;\n\t\tconst scaledRatios = ratios.map((ratio) => getAmountAndScale(ratio, zero));\n\t\tconst highestRatioScale = hasRatios ? maximumFn(scaledRatios.map(({ scale }) => scale)) : zero;\n\t\tconst normalizedRatios = scaledRatios.map(({ amount, scale }) => {\n\t\t\tconst factor = equalFn(scale, highestRatioScale) ? zero : calculator.subtract(highestRatioScale, scale);\n\t\t\treturn {\n\t\t\t\tamount: calculator.multiply(amount, calculator.power(ten, factor)),\n\t\t\t\tscale\n\t\t\t};\n\t\t});\n\t\tconst hasOnlyPositiveRatios = normalizedRatios.every(({ amount }) => greaterThanOrEqualFn(amount, zero));\n\t\tconst hasOneNonZeroRatio = normalizedRatios.some(({ amount }) => greaterThanFn(amount, zero));\n\t\tassert(hasRatios && hasOnlyPositiveRatios && hasOneNonZeroRatio, INVALID_RATIOS_MESSAGE);\n\t\tconst { scale } = dineroObject.toJSON();\n\t\treturn allocateFn(convertScaleFn(dineroObject, calculator.add(scale, highestRatioScale)), normalizedRatios);\n\t};\n}\n\n//#endregion\n//#region src/core/api/compare.ts\nfunction unsafeCompare(calculator) {\n\tconst compareFn = compare$1(calculator);\n\treturn function compare(...[dineroObject, comparator]) {\n\t\tconst [subjectAmount, comparatorAmount] = [dineroObject, comparator].map((d) => {\n\t\t\tconst { amount } = d.toJSON();\n\t\t\treturn amount;\n\t\t});\n\t\treturn compareFn(subjectAmount, comparatorAmount);\n\t};\n}\nfunction safeCompare(calculator) {\n\tconst normalizeFn = normalizeScale$1(calculator);\n\tconst compareFn = unsafeCompare(calculator);\n\treturn function compare(...[dineroObject, comparator]) {\n\t\tassert(haveSameCurrency$1([dineroObject, comparator]), UNEQUAL_CURRENCIES_MESSAGE);\n\t\tconst [subjectAmount, comparatorAmount] = normalizeFn([dineroObject, comparator]);\n\t\treturn compareFn(subjectAmount, comparatorAmount);\n\t};\n}\n\n//#endregion\n//#region src/core/api/convert.ts\nfunction convert$1(calculator) {\n\tconst convertScaleFn = transformScale$1(calculator);\n\tconst maximumFn = maximum$1(calculator);\n\tconst computeBaseFn = computeBase(calculator);\n\tconst equalFn = equal$2(calculator);\n\tconst zero = calculator.zero();\n\treturn function convertFn(...[dineroObject, newCurrency, rates]) {\n\t\tconst rate = rates[newCurrency.code];\n\t\tconst { amount, currency, scale } = dineroObject.toJSON();\n\t\tassert(equalFn(computeBaseFn(currency.base), computeBaseFn(newCurrency.base)), MISMATCHED_BASES_MESSAGE);\n\t\tconst { amount: rateAmount, scale: rateScale } = getAmountAndScale(rate, zero);\n\t\tconst newScale = calculator.add(scale, rateScale);\n\t\treturn convertScaleFn(dineroObject.create({\n\t\t\tamount: calculator.multiply(amount, rateAmount),\n\t\t\tcurrency: newCurrency,\n\t\t\tscale: newScale\n\t\t}), maximumFn([newScale, newCurrency.exponent]));\n\t};\n}\n\n//#endregion\n//#region src/core/api/haveSameAmount.ts\nfunction haveSameAmount$1(calculator) {\n\tconst normalizeFn = normalizeScale$1(calculator);\n\tconst equalFn = equal$2(calculator);\n\treturn function _haveSameAmount(...[dineroObjects]) {\n\t\tconst [firstDinero, ...otherDineros] = normalizeFn(dineroObjects);\n\t\tconst { amount: comparatorAmount } = firstDinero.toJSON();\n\t\treturn otherDineros.every((d) => {\n\t\t\tconst { amount: subjectAmount } = d.toJSON();\n\t\t\treturn equalFn(subjectAmount, comparatorAmount);\n\t\t});\n\t};\n}\n\n//#endregion\n//#region src/core/api/equal.ts\nfunction equal$1(calculator) {\n\treturn function _equal(...[dineroObject, comparator]) {\n\t\treturn haveSameAmount$1(calculator)([dineroObject, comparator]) && haveSameCurrency$1([dineroObject, comparator]);\n\t};\n}\n\n//#endregion\n//#region src/core/api/greaterThan.ts\nfunction unsafeGreaterThan(calculator) {\n\tconst greaterThanFn = greaterThan$1(calculator);\n\treturn function greaterThan(...[dineroObject, comparator]) {\n\t\tconst [subjectAmount, comparatorAmount] = [dineroObject, comparator].map((d) => {\n\t\t\tconst { amount } = d.toJSON();\n\t\t\treturn amount;\n\t\t});\n\t\treturn greaterThanFn(subjectAmount, comparatorAmount);\n\t};\n}\nfunction safeGreaterThan(calculator) {\n\tconst normalizeFn = normalizeScale$1(calculator);\n\tconst greaterThanFn = unsafeGreaterThan(calculator);\n\treturn function greaterThan(...[dineroObject, comparator]) {\n\t\tassert(haveSameCurrency$1([dineroObject, comparator]), UNEQUAL_CURRENCIES_MESSAGE);\n\t\tconst [subjectAmount, comparatorAmount] = normalizeFn([dineroObject, comparator]);\n\t\treturn greaterThanFn(subjectAmount, comparatorAmount);\n\t};\n}\n\n//#endregion\n//#region src/core/api/greaterThanOrEqual.ts\nfunction unsafeGreaterThanOrEqual(calculator) {\n\tconst greaterThanOrEqualFn = greaterThanOrEqual$1(calculator);\n\treturn function greaterThanOrEqual(...[dineroObject, comparator]) {\n\t\tconst [subjectAmount, comparatorAmount] = [dineroObject, comparator].map((d) => {\n\t\t\tconst { amount } = d.toJSON();\n\t\t\treturn amount;\n\t\t});\n\t\treturn greaterThanOrEqualFn(subjectAmount, comparatorAmount);\n\t};\n}\nfunction safeGreaterThanOrEqual(calculator) {\n\tconst normalizeFn = normalizeScale$1(calculator);\n\tconst greaterThanOrEqualFn = unsafeGreaterThanOrEqual(calculator);\n\treturn function greaterThanOrEqual(...[dineroObject, comparator]) {\n\t\tassert(haveSameCurrency$1([dineroObject, comparator]), UNEQUAL_CURRENCIES_MESSAGE);\n\t\tconst [subjectAmount, comparatorAmount] = normalizeFn([dineroObject, comparator]);\n\t\treturn greaterThanOrEqualFn(subjectAmount, comparatorAmount);\n\t};\n}\n\n//#endregion\n//#region src/core/api/hasSubUnits.ts\nfunction hasSubUnits$1(calculator) {\n\tconst equalFn = equal$2(calculator);\n\tconst computeBaseFn = computeBase(calculator);\n\treturn function _hasSubUnits(...[dineroObject]) {\n\t\tconst { amount, currency, scale } = dineroObject.toJSON();\n\t\tconst base = computeBaseFn(currency.base);\n\t\treturn !equalFn(calculator.modulo(amount, calculator.power(base, scale)), calculator.zero());\n\t};\n}\n\n//#endregion\n//#region src/core/api/isNegative.ts\nfunction isNegative$1(calculator) {\n\tconst lessThanFn = lessThan$1(calculator);\n\treturn function _isNegative(...[dineroObject]) {\n\t\tconst { amount } = dineroObject.toJSON();\n\t\treturn lessThanFn(amount, calculator.zero());\n\t};\n}\n\n//#endregion\n//#region src/core/api/isPositive.ts\nfunction isPositive$1(calculator) {\n\tconst greaterThanFn = greaterThan$1(calculator);\n\treturn function _isPositive(...[dineroObject]) {\n\t\tconst { amount } = dineroObject.toJSON();\n\t\treturn greaterThanFn(amount, calculator.zero());\n\t};\n}\n\n//#endregion\n//#region src/core/api/isZero.ts\nfunction isZero$1(calculator) {\n\tconst equalFn = equal$2(calculator);\n\treturn function _isZero(...[dineroObject]) {\n\t\tconst { amount } = dineroObject.toJSON();\n\t\treturn equalFn(amount, calculator.zero());\n\t};\n}\n\n//#endregion\n//#region src/core/api/lessThan.ts\nfunction unsafeLessThan(calculator) {\n\tconst lessThanFn = lessThan$1(calculator);\n\treturn function lessThan(...[dineroObject, comparator]) {\n\t\tconst [subjectAmount, comparatorAmount] = [dineroObject, comparator].map((d) => {\n\t\t\tconst { amount } = d.toJSON();\n\t\t\treturn amount;\n\t\t});\n\t\treturn lessThanFn(subjectAmount, comparatorAmount);\n\t};\n}\nfunction safeLessThan(calculator) {\n\tconst normalizeFn = normalizeScale$1(calculator);\n\tconst lessThanFn = unsafeLessThan(calculator);\n\treturn function lessThan(...[dineroObject, comparator]) {\n\t\tassert(haveSameCurrency$1([dineroObject, comparator]), UNEQUAL_CURRENCIES_MESSAGE);\n\t\tconst [subjectAmount, comparatorAmount] = normalizeFn([dineroObject, comparator]);\n\t\treturn lessThanFn(subjectAmount, comparatorAmount);\n\t};\n}\n\n//#endregion\n//#region src/core/api/lessThanOrEqual.ts\nfunction unsafeLessThanOrEqual(calculator) {\n\tconst lessThanOrEqualFn = lessThanOrEqual$1(calculator);\n\treturn function lessThanOrEqual(...[dineroObject, comparator]) {\n\t\tconst [subjectAmount, comparatorAmount] = [dineroObject, comparator].map((d) => {\n\t\t\tconst { amount } = d.toJSON();\n\t\t\treturn amount;\n\t\t});\n\t\treturn lessThanOrEqualFn(subjectAmount, comparatorAmount);\n\t};\n}\nfunction safeLessThanOrEqual(calculator) {\n\tconst normalizeFn = normalizeScale$1(calculator);\n\tconst lessThanOrEqualFn = unsafeLessThanOrEqual(calculator);\n\treturn function lessThanOrEqual(...[dineroObject, comparator]) {\n\t\tassert(haveSameCurrency$1([dineroObject, comparator]), UNEQUAL_CURRENCIES_MESSAGE);\n\t\tconst [subjectAmount, comparatorAmount] = normalizeFn([dineroObject, comparator]);\n\t\treturn lessThanOrEqualFn(subjectAmount, comparatorAmount);\n\t};\n}\n\n//#endregion\n//#region src/core/api/maximum.ts\nfunction unsafeMaximum(calculator) {\n\tconst maxFn = maximum$1(calculator);\n\treturn function maximum(dineroObjects) {\n\t\tconst [firstDinero] = dineroObjects;\n\t\tconst { currency, scale } = firstDinero.toJSON();\n\t\tconst amount = maxFn(dineroObjects.map((subject) => {\n\t\t\tconst { amount: subjectAmount } = subject.toJSON();\n\t\t\treturn subjectAmount;\n\t\t}));\n\t\treturn firstDinero.create({\n\t\t\tamount,\n\t\t\tcurrency,\n\t\t\tscale\n\t\t});\n\t};\n}\nfunction safeMaximum(calculator) {\n\tconst normalizeFn = normalizeScale$1(calculator);\n\tconst maxFn = unsafeMaximum(calculator);\n\treturn function maximum(...[dineroObjects]) {\n\t\tassert(haveSameCurrency$1(dineroObjects), UNEQUAL_CURRENCIES_MESSAGE);\n\t\treturn maxFn(normalizeFn([...dineroObjects]));\n\t};\n}\n\n//#endregion\n//#region src/core/api/minimum.ts\nfunction unsafeMinimum(calculator) {\n\tconst minFn = minimum$1(calculator);\n\treturn function minimum(dineroObjects) {\n\t\tconst [firstDinero] = dineroObjects;\n\t\tconst { currency, scale } = firstDinero.toJSON();\n\t\tconst amount = minFn(dineroObjects.map((subject) => {\n\t\t\tconst { amount: subjectAmount } = subject.toJSON();\n\t\t\treturn subjectAmount;\n\t\t}));\n\t\treturn firstDinero.create({\n\t\t\tamount,\n\t\t\tcurrency,\n\t\t\tscale\n\t\t});\n\t};\n}\nfunction safeMinimum(calculator) {\n\tconst normalizeFn = normalizeScale$1(calculator);\n\tconst minFn = unsafeMinimum(calculator);\n\treturn function minimum(...[dineroObjects]) {\n\t\tassert(haveSameCurrency$1(dineroObjects), UNEQUAL_CURRENCIES_MESSAGE);\n\t\treturn minFn(normalizeFn([...dineroObjects]));\n\t};\n}\n\n//#endregion\n//#region src/core/api/multiply.ts\nfunction multiply$1(calculator) {\n\tconst convertScaleFn = transformScale$1(calculator);\n\tconst zero = calculator.zero();\n\treturn function multiplyFn(...[multiplicand, multiplier]) {\n\t\tconst { amount, currency, scale } = multiplicand.toJSON();\n\t\tconst { amount: multiplierAmount, scale: multiplierScale } = getAmountAndScale(multiplier, zero);\n\t\tconst newScale = calculator.add(scale, multiplierScale);\n\t\treturn convertScaleFn(multiplicand.create({\n\t\t\tamount: calculator.multiply(amount, multiplierAmount),\n\t\t\tcurrency,\n\t\t\tscale: newScale\n\t\t}), newScale);\n\t};\n}\n\n//#endregion\n//#region src/core/api/subtract.ts\nfunction unsafeSubtract(calculator) {\n\treturn function subtract(...[minuend, subtrahend]) {\n\t\tconst { amount: minuendAmount, currency, scale } = minuend.toJSON();\n\t\tconst { amount: subtrahendAmount } = subtrahend.toJSON();\n\t\tconst amount = calculator.subtract(minuendAmount, subtrahendAmount);\n\t\treturn minuend.create({\n\t\t\tamount,\n\t\t\tcurrency,\n\t\t\tscale\n\t\t});\n\t};\n}\nfunction safeSubtract(calculator) {\n\tconst normalizeFn = normalizeScale$1(calculator);\n\tconst subtractFn = unsafeSubtract(calculator);\n\treturn function subtract(...[minuend, subtrahend]) {\n\t\tassert(haveSameCurrency$1([minuend, subtrahend]), UNEQUAL_CURRENCIES_MESSAGE);\n\t\tconst [newMinuend, newSubtrahend] = normalizeFn([minuend, subtrahend]);\n\t\treturn subtractFn(newMinuend, newSubtrahend);\n\t};\n}\n\n//#endregion\n//#region src/core/api/toUnits.ts\nfunction toUnits$1(calculator) {\n\tconst getDivisorsFn = getDivisors(calculator);\n\treturn function toUnitsFn(...[dineroObject, transformer]) {\n\t\tconst { amount, currency, scale } = dineroObject.toJSON();\n\t\tconst { power, integerDivide, modulo } = calculator;\n\t\tconst value = getDivisorsFn((isArray(currency.base) ? currency.base : [currency.base]).map((base) => power(base, scale))).reduce((amounts, divisor, index) => {\n\t\t\tconst amountLeft = amounts[index];\n\t\t\tconst quotient = integerDivide(amountLeft, divisor);\n\t\t\tconst remainder = modulo(amountLeft, divisor);\n\t\t\treturn [\n\t\t\t\t...amounts.filter((_, i) => i !== index),\n\t\t\t\tquotient,\n\t\t\t\tremainder\n\t\t\t];\n\t\t}, [amount]);\n\t\tif (!transformer) return value;\n\t\treturn transformer({\n\t\t\tvalue,\n\t\t\tcurrency\n\t\t});\n\t};\n}\n\n//#endregion\n//#region src/core/api/toDecimal.ts\nfunction toDecimal$1(calculator) {\n\tconst toUnitsFn = toUnits$1(calculator);\n\tconst computeBaseFn = computeBase(calculator);\n\tconst equalFn = equal$2(calculator);\n\treturn function toDecimalFn(...[dineroObject, transformer]) {\n\t\tconst { currency, scale } = dineroObject.toJSON();\n\t\tconst base = computeBaseFn(currency.base);\n\t\tconst zero = calculator.zero();\n\t\tconst ten = new Array(10).fill(null).reduce(calculator.increment, zero);\n\t\tconst isMultiBase = isArray(currency.base);\n\t\tconst isBaseTen = equalFn(calculator.modulo(base, ten), zero);\n\t\tassert(!isMultiBase && isBaseTen, NON_DECIMAL_CURRENCY_MESSAGE);\n\t\tconst units = toUnitsFn(dineroObject);\n\t\tconst value = getDecimal(calculator, dineroObject.formatter)(units, scale);\n\t\tif (!transformer) return value;\n\t\treturn transformer({\n\t\t\tvalue,\n\t\t\tcurrency\n\t\t});\n\t};\n}\nfunction getDecimal(calculator, formatter) {\n\tconst absoluteFn = absolute(calculator);\n\tconst equalFn = equal$2(calculator);\n\tconst lessThanFn = lessThan$1(calculator);\n\tconst zero = calculator.zero();\n\treturn (units, scale) => {\n\t\tconst whole = formatter.toString(units[0]);\n\t\tconst fractional = formatter.toString(absoluteFn(units[1]));\n\t\tconst scaleNumber = formatter.toNumber(scale);\n\t\tconst decimal = `${whole}${scaleNumber > 0 ? `.${fractional.padStart(scaleNumber, \"0\")}` : \"\"}`;\n\t\tconst leadsWithZero = equalFn(units[0], zero);\n\t\tconst isNegative = lessThanFn(units[1], zero);\n\t\treturn leadsWithZero && isNegative ? `-${decimal}` : decimal;\n\t};\n}\n\n//#endregion\n//#region src/core/api/toSnapshot.ts\nfunction toSnapshot$1(dineroObject) {\n\treturn dineroObject.toJSON();\n}\n\n//#endregion\n//#region src/core/api/trimScale.ts\nfunction trimScale$1(calculator) {\n\tconst countTrailingZerosFn = countTrailingZeros(calculator);\n\tconst equalFn = equal$2(calculator);\n\tconst maximumFn = maximum$1(calculator);\n\tconst transformScaleFn = transformScale$1(calculator);\n\tconst computeBaseFn = computeBase(calculator);\n\treturn function trimScaleFn(...[dineroObject]) {\n\t\tconst { amount, currency, scale } = dineroObject.toJSON();\n\t\tconst trailingZerosLength = countTrailingZerosFn(amount, computeBaseFn(currency.base));\n\t\tconst newScale = maximumFn([calculator.subtract(scale, trailingZerosLength), currency.exponent]);\n\t\tif (equalFn(newScale, scale)) return dineroObject;\n\t\treturn transformScaleFn(dineroObject, newScale);\n\t};\n}\n\n//#endregion\n//#region src/api/add.ts\n/**\n* Add up the passed Dinero objects.\n*\n* @param augend - The Dinero object to add to.\n* @param addend - The Dinero object to add.\n*\n* @returns A new Dinero object.\n*\n* @public\n*/\nfunction add(...[augend, addend]) {\n\tconst { calculator } = augend;\n\treturn safeAdd(calculator)(augend, addend);\n}\n\n//#endregion\n//#region src/api/allocate.ts\n/**\n* Distribute the amount of a Dinero object across a list of ratios.\n*\n* @param dineroObject - The Dinero object to allocate from.\n* @param ratios - The ratios to allocate the amount to.\n*\n* @returns A new Dinero object.\n*\n* @public\n*/\nfunction allocate(...[dineroObject, ratios]) {\n\tconst { calculator } = dineroObject;\n\treturn safeAllocate(calculator)(dineroObject, ratios);\n}\n\n//#endregion\n//#region src/api/compare.ts\n/**\n* Compare the value of a Dinero object relative to another.\n*\n* @param dineroObject - The Dinero object to compare.\n* @param comparator - The Dinero object to compare to.\n*\n* @returns One of -1, 0, or 1 depending on whether the first Dinero object is less than, equal to, or greater than the other.\n*\n* @public\n*/\nfunction compare(...[dineroObject, comparator]) {\n\tconst { calculator } = dineroObject;\n\treturn safeCompare(calculator)(dineroObject, comparator);\n}\n\n//#endregion\n//#region src/api/convert.ts\n/**\n* Convert a Dinero object to another currency.\n*\n* @param dineroObject - The Dinero object to format.\n* @param newCurrency - The currency to convert to.\n* @param rates - The rates to convert with.\n*\n* @returns A converted Dinero object.\n*\n* @public\n*/\nfunction convert(...[dineroObject, newCurrency, rates]) {\n\tconst { calculator } = dineroObject;\n\treturn convert$1(calculator)(dineroObject, newCurrency, rates);\n}\n\n//#endregion\n//#region src/api/equal.ts\n/**\n* Check whether the value of a Dinero object is equal to another.\n*\n* @param dineroObject - The first Dinero object to compare.\n* @param comparator - The second Dinero object to compare.\n*\n* @returns Whether the Dinero objects are equal.\n*\n* @public\n*/\nfunction equal(...[dineroObject, comparator]) {\n\tconst { calculator } = dineroObject;\n\treturn equal$1(calculator)(dineroObject, comparator);\n}\n\n//#endregion\n//#region src/api/greaterThan.ts\n/**\n* Check whether the value of a Dinero object is greater than another.\n*\n* @param dineroObject - The Dinero object to compare.\n* @param comparator - The Dinero object to compare to.\n*\n* @returns Whether the Dinero to compare is greater than the other.\n*\n* @public\n*/\nfunction greaterThan(...[dineroObject, comparator]) {\n\tconst { calculator } = dineroObject;\n\treturn safeGreaterThan(calculator)(dineroObject, comparator);\n}\n\n//#endregion\n//#region src/api/greaterThanOrEqual.ts\n/**\n* Check whether the value of a Dinero object is greater than or equal another.\n*\n* @param dineroObject - The Dinero object to compare.\n* @param comparator - The Dinero object to compare to.\n*\n* @returns Whether the Dinero to compare is greater than or equal the other.\n*\n* @public\n*/\nfunction greaterThanOrEqual(...[dineroObject, comparator]) {\n\tconst { calculator } = dineroObject;\n\treturn safeGreaterThanOrEqual(calculator)(dineroObject, comparator);\n}\n\n//#endregion\n//#region src/api/hasSubUnits.ts\n/**\n* Check whether a Dinero object has minor currency units.\n*\n* @param dineroObject - The Dinero object to check.\n*\n* @returns Whether the Dinero object has minor currency units.\n*\n* @public\n*/\nfunction hasSubUnits(...[dineroObject]) {\n\tconst { calculator } = dineroObject;\n\treturn hasSubUnits$1(calculator)(dineroObject);\n}\n\n//#endregion\n//#region src/api/haveSameAmount.ts\n/**\n* Check whether a set of Dinero objects have the same amount.\n*\n* @param dineroObjects - The Dinero objects to compare.\n*\n* @returns Whether the Dinero objects have the same amount.\n*\n* @public\n*/\nfunction haveSameAmount(...[dineroObjects]) {\n\tconst { calculator } = dineroObjects[0];\n\treturn haveSameAmount$1(calculator)(dineroObjects);\n}\n\n//#endregion\n//#region src/api/haveSameCurrency.ts\n/**\n* Check whether a set of Dinero objects have the same currency.\n*\n* @param dineroObjects - The Dinero objects to compare.\n*\n* @returns Whether the Dinero objects have the same currency.\n*\n* @public\n*/\nconst haveSameCurrency = haveSameCurrency$1;\n\n//#endregion\n//#region src/api/isNegative.ts\n/**\n* Check whether a Dinero object is negative.\n*\n* @param dineroObject - The Dinero object to check.\n*\n* @returns Whether the Dinero object is negative.\n*\n* @public\n*/\nfunction isNegative(...[dineroObject]) {\n\tconst { calculator } = dineroObject;\n\treturn isNegative$1(calculator)(dineroObject);\n}\n\n//#endregion\n//#region src/api/isPositive.ts\n/**\n* Check whether a Dinero object is positive.\n*\n* @param dineroObject - The Dinero object to check.\n*\n* @returns Whether the Dinero object is positive.\n*\n* @public\n*/\nfunction isPositive(...[dineroObject]) {\n\tconst { calculator } = dineroObject;\n\treturn isPositive$1(calculator)(dineroObject);\n}\n\n//#endregion\n//#region src/api/isZero.ts\n/**\n* Check whether the value of a Dinero object is zero.\n*\n* @param dineroObject - The Dinero object to check.\n*\n* @returns Whether the value of a Dinero object is zero.\n*\n* @public\n*/\nfunction isZero(...[dineroObject]) {\n\tconst { calculator } = dineroObject;\n\treturn isZero$1(calculator)(dineroObject);\n}\n\n//#endregion\n//#region src/api/lessThan.ts\n/**\n* Check whether the value of a Dinero object is lesser than another.\n*\n* @param dineroObject - The Dinero object to compare.\n* @param comparator - The Dinero object to compare to.\n*\n* @returns Whether the Dinero to compare is lesser than the other.\n*\n* @public\n*/\nfunction lessThan(...[dineroObject, comparator]) {\n\tconst { calculator } = dineroObject;\n\treturn safeLessThan(calculator)(dineroObject, comparator);\n}\n\n//#endregion\n//#region src/api/lessThanOrEqual.ts\n/**\n* Check whether the value of a Dinero object is lesser than or equal to another.\n*\n* @param dineroObject - The Dinero object to compare.\n* @param comparator - The Dinero object to compare to.\n*\n* @returns Whether the Dinero to compare is lesser than or equal to the other.\n*\n* @public\n*/\nfunction lessThanOrEqual(...[dineroObject, comparator]) {\n\tconst { calculator } = dineroObject;\n\treturn safeLessThanOrEqual(calculator)(dineroObject, comparator);\n}\n\n//#endregion\n//#region src/api/maximum.ts\n/**\n* Get the greatest of the passed Dinero objects.\n*\n* @param dineroObjects - The Dinero objects to maximum.\n*\n* @returns A new Dinero object.\n*\n* @public\n*/\nfunction maximum(...[dineroObjects]) {\n\tconst { calculator } = dineroObjects[0];\n\treturn safeMaximum(calculator)(dineroObjects);\n}\n\n//#endregion\n//#region src/api/minimum.ts\n/**\n* Get the lowest of the passed Dinero objects.\n*\n* @param dineroObjects - The Dinero objects to minimum.\n*\n* @returns A new Dinero object.\n*\n* @public\n*/\nfunction minimum(...[dineroObjects]) {\n\tconst { calculator } = dineroObjects[0];\n\treturn safeMinimum(calculator)(dineroObjects);\n}\n\n//#endregion\n//#region src/api/multiply.ts\n/**\n* Multiply the passed Dinero object.\n*\n* @param multiplicand - The Dinero object to multiply.\n* @param multiplier - The number to multiply with.\n*\n* @returns A new Dinero object.\n*\n* @public\n*/\nfunction multiply(...[multiplicand, multiplier]) {\n\tconst { calculator } = multiplicand;\n\treturn multiply$1(calculator)(multiplicand, multiplier);\n}\n\n//#endregion\n//#region src/api/normalizeScale.ts\n/**\n* Normalize a set of Dinero objects to the highest scale of the set.\n*\n* @param dineroObjects - The Dinero objects to normalize.\n*\n* @returns A new set of Dinero objects.\n*\n* @public\n*/\nfunction normalizeScale(...[dineroObjects]) {\n\tconst { calculator } = dineroObjects[0];\n\treturn normalizeScale$1(calculator)(dineroObjects);\n}\n\n//#endregion\n//#region src/api/subtract.ts\n/**\n* Subtract the passed Dinero objects.\n*\n* @param minuend - The Dinero object to subtract from.\n* @param subtrahend - The Dinero object to subtract.\n*\n* @returns A new Dinero object.\n*\n* @public\n*/\nfunction subtract(...[minuend, subtrahend]) {\n\tconst { calculator } = minuend;\n\treturn safeSubtract(calculator)(minuend, subtrahend);\n}\n\n//#endregion\n//#region src/api/toDecimal.ts\n/**\n* Get the amount of a Dinero object in decimal form.\n*\n* @param dineroObject - The Dinero object to format.\n* @param transformer - A transformer function.\n*\n* @returns The amount in decimal form.\n*\n* @public\n*/\nfunction toDecimal(...[dineroObject, transformer]) {\n\tconst { calculator } = dineroObject;\n\treturn toDecimal$1(calculator)(dineroObject, transformer);\n}\n\n//#endregion\n//#region src/api/toSnapshot.ts\n/**\n* Get a snapshot of a Dinero object.\n*\n* @param dineroObject - The Dinero object to format.\n* @param transformer - A transformer function.\n*\n* @returns A snapshot of the object.\n*\n* @public\n*/\nconst toSnapshot = toSnapshot$1;\n\n//#endregion\n//#region src/api/toUnits.ts\n/**\n* Get the amount of a Dinero object in units.\n*\n* @param dineroObject - The Dinero object to format.\n* @param transformer - A transformer function.\n*\n* @returns The amount in units.\n*\n* @public\n*/\nfunction toUnits(...[dineroObject, transformer]) {\n\tconst { calculator } = dineroObject;\n\treturn toUnits$1(calculator)(dineroObject, transformer);\n}\n\n//#endregion\n//#region src/api/transformScale.ts\n/**\n* Transform a Dinero object to a new scale.\n*\n* @param dineroObject - The Dinero object to transform.\n* @param newScale - The new scale.\n* @param divide - A custom divide function.\n*\n* @returns A new Dinero object.\n*\n* @public\n*/\nfunction transformScale(...[dineroObject, newScale, divide]) {\n\tconst { calculator } = dineroObject;\n\treturn transformScale$1(calculator)(dineroObject, newScale, divide);\n}\n\n//#endregion\n//#region src/api/trimScale.ts\n/**\n* Trim a Dinero object's scale as much as possible, down to the currency exponent.\n*\n* @param dineroObject - The Dinero object which scale to trim.\n*\n* @returns A new Dinero object.\n*\n* @public\n*/\nfunction trimScale(...[dineroObject]) {\n\tconst { calculator } = dineroObject;\n\treturn trimScale$1(calculator)(dineroObject);\n}\n\n//#endregion\nexport { halfEven as A, compare as C, halfUp as D, up as E, createDinero as F, assert as I, INVALID_AMOUNT_MESSAGE as L, halfAwayFromZero as M, down as N, halfTowardsZero as O, DineroComparisonOperator as P, INVALID_SCALE_MESSAGE as R, convert as S, add as T, haveSameAmount as _, toDecimal as a, greaterThan as b, multiply as c, lessThanOrEqual as d, lessThan as f, haveSameCurrency as g, isNegative as h, toSnapshot as i, halfDown as j, halfOdd as k, minimum as l, isPositive as m, transformScale as n, subtract as o, isZero as p, toUnits as r, normalizeScale as s, trimScale as t, maximum as u, hasSubUnits as v, allocate as w, equal as x, greaterThanOrEqual as y };","import { A as halfEven, C as compare, D as halfUp, E as up, F as createDinero, M as halfAwayFromZero, N as down, O as halfTowardsZero, P as DineroComparisonOperator, S as convert, T as add, _ as haveSameAmount, a as toDecimal, b as greaterThan, c as multiply, d as lessThanOrEqual, f as lessThan, g as haveSameCurrency, h as isNegative, i as toSnapshot, j as halfDown, k as halfOdd, l as minimum, m as isPositive, n as transformScale, o as subtract, p as isZero, r as toUnits, s as normalizeScale, t as trimScale, u as maximum, v as hasSubUnits, w as allocate, x as equal, y as greaterThanOrEqual } from \"../trimScale-C3-DjbPM.js\";\nimport { AED, AFN, ALL, AMD, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BOV, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHE, CHF, CHW, CLF, CLP, CNY, COP, COU, CRC, CUP, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JMD, JOD, JPY, KES, KGS, KHR, KMF, KPW, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MXV, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLE, SOS, SRD, SSP, STN, SVC, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USN, UYI, UYU, UYW, UZS, VED, VES, VND, VUV, WST, XAD, XAF, XCD, XCG, XOF, XPF, YER, ZAR, ZMW, ZWG } from \"./currencies/index.js\";\n\n//#region src/calculator/bigint/api/add.ts\n/**\n* Returns the sum of two bigints.\n*\n* @param augend - The bigint to add to.\n* @param addend - The bigint to add.\n*\n* @returns The sum of the two bigints.\n*/\nconst add$1 = (augend, addend) => {\n\treturn augend + addend;\n};\n\n//#endregion\n//#region src/calculator/bigint/api/compare.ts\n/**\n* Compare two bigints.\n*\n* @param a - The first bigint to compare.\n* @param b - The second bigint to compare.\n*\n* @returns Whether the two bigints are equal, or whether the first one is greater or less than the other.\n*/\nconst compare$1 = (a, b) => {\n\tif (a < b) return DineroComparisonOperator.LT;\n\tif (a > b) return DineroComparisonOperator.GT;\n\treturn DineroComparisonOperator.EQ;\n};\n\n//#endregion\n//#region src/calculator/bigint/api/decrement.ts\n/**\n* Returns an decremented bigint.\n*\n* @param value - The bigint to decrement.\n*\n* @returns The decremented bigint.\n*/\nconst decrement = (value) => {\n\treturn value - 1n;\n};\n\n//#endregion\n//#region src/calculator/bigint/api/increment.ts\n/**\n* Returns an incremented bigint.\n*\n* @param value - The bigint to increment.\n*\n* @returns The incremented bigint.\n*/\nconst increment = (value) => {\n\treturn value + 1n;\n};\n\n//#endregion\n//#region src/calculator/bigint/api/integerDivide.ts\n/**\n* Returns the quotient of two bigints with no fractional part.\n*\n* @param dividend - The bigint to divide.\n* @param divisor - The bigint to divide with.\n*\n* @returns The quotient of the two bigints.\n*/\nconst integerDivide = (dividend, divisor) => {\n\treturn dividend / divisor;\n};\n\n//#endregion\n//#region src/calculator/bigint/api/modulo.ts\n/**\n* Returns the remainder of two bigints.\n*\n* @param dividend - The bigint to divide.\n* @param divisor - The bigint to divide with.\n*\n* @returns The remainder of the two bigints.\n*/\nconst modulo = (dividend, divisor) => {\n\treturn dividend % divisor;\n};\n\n//#endregion\n//#region src/calculator/bigint/api/multiply.ts\n/**\n* Returns the product of two bigints.\n*\n* @param multiplicand - The bigint to multiply.\n* @param multiplier - The bigint to multiply with.\n*\n* @returns The product of the two bigints.\n*/\nconst multiply$1 = (multiplicand, multiplier) => {\n\treturn multiplicand * multiplier;\n};\n\n//#endregion\n//#region src/calculator/bigint/api/power.ts\n/**\n* Returns an bigint to the power of an exponent.\n*\n* @param base - The base bigint.\n* @param exponent - The exponent to raise the base to.\n*\n* @returns The base to the power of the exponent.\n*/\nconst power = (base, exponent) => {\n\treturn base ** exponent;\n};\n\n//#endregion\n//#region src/calculator/bigint/api/subtract.ts\n/**\n* Returns the difference between two bigints.\n*\n* @param minuend - The bigint to subtract from.\n* @param subtrahend - The bigint to subtract.\n*\n* @returns The difference of the two bigints.\n*/\nconst subtract$1 = (minuend, subtrahend) => {\n\treturn minuend - subtrahend;\n};\n\n//#endregion\n//#region src/calculator/bigint/api/zero.ts\n/**\n* Return zero as a bigint.\n*\n* @returns Zero as a bigint.\n*/\nfunction zero() {\n\treturn 0n;\n}\n\n//#endregion\n//#region src/calculator/bigint/calculator.ts\nconst calculator = {\n\tadd: add$1,\n\tcompare: compare$1,\n\tdecrement,\n\tincrement,\n\tintegerDivide,\n\tmodulo,\n\tmultiply: multiply$1,\n\tpower,\n\tsubtract: subtract$1,\n\tzero\n};\n\n//#endregion\n//#region src/bigint/dinero.ts\n/**\n* Create a Dinero object with bigint amounts.\n*\n* @param options.amount - The amount in minor currency units as a bigint.\n* @param options.currency - The currency.\n* @param options.scale - The number of decimal places to represent.\n*\n* @returns The created Dinero object.\n*\n* @public\n*/\nconst dinero = createDinero({ calculator });\n\n//#endregion\nexport { AED, AFN, ALL, AMD, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BOV, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHE, CHF, CHW, CLF, CLP, CNY, COP, COU, CRC, CUP, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JMD, JOD, JPY, KES, KGS, KHR, KMF, KPW, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MXV, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLE, SOS, SRD, SSP, STN, SVC, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USN, UYI, UYU, UYW, UZS, VED, VES, VND, VUV, WST, XAD, XAF, XCD, XCG, XOF, XPF, YER, ZAR, ZMW, ZWG, add, allocate, calculator, compare, convert, createDinero, dinero, down, equal, greaterThan, greaterThanOrEqual, halfAwayFromZero, halfDown, halfEven, halfOdd, halfTowardsZero, halfUp, hasSubUnits, haveSameAmount, haveSameCurrency, isNegative, isPositive, isZero, lessThan, lessThanOrEqual, maximum, minimum, multiply, normalizeScale, subtract, toDecimal, toSnapshot, toUnits, transformScale, trimScale, up };","import Decimal from 'decimal.js';\nimport type { DineroCurrency } from 'dinero.js/bigint';\nimport { dinero, toDecimal } from 'dinero.js/bigint';\nimport * as currencies from 'dinero.js/bigint/currencies';\nimport { CUSTOM_CURRENCY_EXPONENTS, type CurrencyCode } from './currencyCode';\nimport { getLocale } from './locale';\n\n// The dinero currency for a code, built from its exponent for the few currencies dinero does not carry\nfunction resolveCurrency(currencyCode: CurrencyCode): DineroCurrency<bigint> {\n const currency = (currencies as Record<string, DineroCurrency<bigint> | undefined>)[currencyCode];\n if (currency) return currency;\n const exponent = (CUSTOM_CURRENCY_EXPONENTS as Record<string, number | undefined>)[currencyCode];\n if (exponent === undefined) throw new Error(`Unknown currency: ${currencyCode}`);\n return { code: currencyCode, base: 10n, exponent: BigInt(exponent) };\n}\n\nexport function minorToMajor(minor: string, currencyCode: CurrencyCode): string {\n const currency = resolveCurrency(currencyCode);\n return toDecimal(dinero({ amount: BigInt(minor), currency }));\n}\n\nexport function majorToMinor(major: string, currencyCode: CurrencyCode): string {\n const currency = resolveCurrency(currencyCode);\n const factor = new Decimal(10).pow(Number(currency.exponent));\n return new Decimal(major).mul(factor).toFixed(0);\n}\n\nexport function formatCurrencyMajor(major: number, currencyCode: CurrencyCode): string {\n return new Intl.NumberFormat(getLocale() ?? 'en-US', {\n style: 'currency',\n currency: currencyCode,\n }).format(major);\n}\n\nexport function formatCurrency(minor: string, currencyCode: CurrencyCode): string {\n return formatCurrencyMajor(Number(minorToMajor(minor, currencyCode)), currencyCode);\n}\n"],"names":[],"mappings":";;;;AAAA;AAKA,MAAM,4BAA4B,GAAG,0BAA0B;;AAG/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE;AACpC,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,IAAI,KAAK,CAAC,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC;AAC1D;;AAEA;AACA;AACA,SAAS,YAAY,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,GAAG;AAC1D,CAAC,QAAQ,EAAE,MAAM;AACjB,CAAC,QAAQ,EAAE;AACX,CAAC,EAAE,EAAE;AACL,CAAC,OAAO,SAAS,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,KAAK,GAAG,QAAQ,EAAE,EAAE;AAC1F,EAAE,MAAM,QAAQ,GAAG;AACnB,GAAG,IAAI;AACP,GAAG,IAAI;AACP,GAAG;AACH,GAAG;AACH,EAAE,QAAQ,GAAG;AACb,GAAG,MAAM;AACT,GAAG,QAAQ;AACX,GAAG;AACH,GAAG,CAAC;AACJ,EAAE,OAAO;AACT,GAAG,UAAU;AACb,GAAG,SAAS;AACZ,GAAG,MAAM,EAAE,MAAM;AACjB,GAAG,MAAM,GAAG;AACZ,IAAI,OAAO;AACX,KAAK,MAAM;AACX,KAAK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