| 1 | /** Shared helpers for system-authored letters (CE, bank, bounty, …). */ |
| 2 | |
| 3 | export const CENTRAL_EXCHANGE_ORG = "Central Exchange"; |
| 4 | export const BANK_LETTER_AUTHOR = "The Bank"; |
| 5 | export const BOUNTY_OFFICE_AUTHOR = "Bounty Office"; |
| 6 | export { |
| 7 | QUESTWARD_GIFT_AUTHOR, |
| 8 | QUESTWARD_GIFT_ORG, |
| 9 | formatGiftLetterBody, |
| 10 | formatGiftItemBullet |
| 11 | } from "./giftLetters.js"; |
| 12 | export { giftItemOrigin } from "./giftOrigin.js"; |
| 13 | |
| 14 | export function isCentralExchangeLetter (instance) |
| 15 | { |
| 16 | if (instance?.kind !== "letter") |
| 17 | { return false; } |
| 18 | if (instance.centralExchange === true) |
| 19 | { return true; } |
| 20 | return instance.authorOrganization === CENTRAL_EXCHANGE_ORG; |
| 21 | } |
| 22 | |
| 23 | export function isBankRestNoticeLetter (instance) |
| 24 | { |
| 25 | return instance?.kind === "letter" && instance.bankRestNotice === true; |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Format the UI "Signed:" block. Optional organization is a second line under the name. |
| 30 | * @param {{ authorDisplayName?: string, authorOrganization?: string|null }} instance |
| 31 | * @param {string} [fallbackName] |
| 32 | */ |
| 33 | export function formatLetterSignature (instance, fallbackName = "Unknown") |
| 34 | { |
| 35 | const name = String(instance?.authorDisplayName ?? "").trim() || fallbackName; |
| 36 | const org = String(instance?.authorOrganization ?? "").trim(); |
| 37 | return org ? `Signed:\n${name}\n${org}` : `Signed:\n${name}`; |
| 38 | } |