@forgeroute/ui 0.5.31 → 0.5.33
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.
- package/fesm2022/forgeroute-ui-address-input.mjs +10 -2
- package/fesm2022/forgeroute-ui-address-input.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-conversations.mjs +1 -0
- package/fesm2022/forgeroute-ui-conversations.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-core.mjs +22 -2
- package/fesm2022/forgeroute-ui-core.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-data-table-core.mjs +21 -7
- package/fesm2022/forgeroute-ui-data-table-core.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-editor.mjs +1 -0
- package/fesm2022/forgeroute-ui-editor.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-form-row.mjs +54 -18
- package/fesm2022/forgeroute-ui-form-row.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-form-section.mjs +32 -4
- package/fesm2022/forgeroute-ui-form-section.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-kpi-card.mjs +20 -4
- package/fesm2022/forgeroute-ui-kpi-card.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-list-item.mjs +2 -2
- package/fesm2022/forgeroute-ui-list-item.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-map.mjs +10 -2
- package/fesm2022/forgeroute-ui-map.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-messaging.mjs +31 -6
- package/fesm2022/forgeroute-ui-messaging.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-notification-bell.mjs +1 -0
- package/fesm2022/forgeroute-ui-notification-bell.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-offline.mjs +1 -0
- package/fesm2022/forgeroute-ui-offline.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-payments.mjs +29 -5
- package/fesm2022/forgeroute-ui-payments.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-phone-number-picker.mjs +1 -0
- package/fesm2022/forgeroute-ui-phone-number-picker.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-quickbooks.mjs +11 -2
- package/fesm2022/forgeroute-ui-quickbooks.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-share-menu.mjs +46 -15
- package/fesm2022/forgeroute-ui-share-menu.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-square.mjs +1 -0
- package/fesm2022/forgeroute-ui-square.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-stripe.mjs +22 -4
- package/fesm2022/forgeroute-ui-stripe.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-table-types.mjs.map +1 -1
- package/package.json +1 -1
- package/types/forgeroute-ui-core.d.ts +9 -2
- package/types/forgeroute-ui-data-table-core.d.ts +5 -0
- package/types/forgeroute-ui-form-row.d.ts +14 -0
- package/types/forgeroute-ui-form-section.d.ts +8 -1
- package/types/forgeroute-ui-kpi-card.d.ts +7 -0
- package/types/forgeroute-ui-list-item.d.ts +1 -1
- package/types/forgeroute-ui-share-menu.d.ts +20 -11
- package/types/forgeroute-ui-table-types.d.ts +7 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forgeroute-ui-square.mjs","names":[],"sources":["../../../projects/forgeroute-ui/square/src/square-loader/square-loader.ts","../../../projects/forgeroute-ui/square/src/errors/square-errors.ts","../../../projects/forgeroute-ui/square/src/square-payment/square-outcomes.ts","../../../projects/forgeroute-ui/square/src/square-payment/square-style.ts","../../../projects/forgeroute-ui/square/src/square-payment/square-payment.component.ts","../../../projects/forgeroute-ui/square/src/square-connect/square-connect.flow.ts","../../../projects/forgeroute-ui/square/src/square-connect/square-connect.component.ts","../../../projects/forgeroute-ui/square/src/square-terminal/square-terminal.models.ts","../../../projects/forgeroute-ui/square/src/square-terminal/square-terminal.flow.ts","../../../projects/forgeroute-ui/square/src/square-terminal/square-terminal-status.component.ts","../../../projects/forgeroute-ui/square/src/square-terminal/square-terminal-payment.component.ts","../../../projects/forgeroute-ui/square/src/payment-square-method/payment-square-method.models.ts","../../../projects/forgeroute-ui/square/src/payment-square-method/payment-square-body.component.ts","../../../projects/forgeroute-ui/square/src/square-terminal/square-terminal-banner.component.ts","../../../projects/forgeroute-ui/square/src/payment-square-method/payment-square-method.component.ts","../../../projects/forgeroute-ui/square/src/square-terminal/square-terminal-pairing.component.ts"],"sourcesContent":["import { InjectionToken, type Provider } from '@angular/core';\nimport type { SquareConnectionConfig, SquareEnvironment, SquarePaymentsLike } from './square-types';\n\n/** The only addresses the SDK script is ever loaded from (Square's own CDN; never an address an answer or an input made up). */\nexport const SQUARE_SDK_URL = 'https://web.squarecdn.com/v1/square.js';\nexport const SQUARE_SANDBOX_SDK_URL = 'https://sandbox.web.squarecdn.com/v1/square.js';\n\n/** How long a script that is already in the page may take to define `window.Square` before the load is reported as failed. */\nexport const SQUARE_SCRIPT_WAIT_MS = 15_000;\n\n/** How long a script this loader inserted (or a form's `card()` / `attach()` / `ach()`) may stay silent before the load is reported as failed: a hung CDN must not leave a skeleton forever. */\nexport const SQUARE_LOAD_TIMEOUT_MS = 20_000;\n/**\n * Races a step of the form (`loader`, `card()`, `attach()`, `ach()`) against {@link SQUARE_LOAD_TIMEOUT_MS}: a promise that never settles becomes the error `makeError()` builds, so the\n * form shows its load error instead of a skeleton forever. The timer is always cleared (nothing is left pending).\n */\nexport function withSquareTimeout<T>(step: Promise<T> | T, makeError: () => Error): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n const timer = setTimeout(() => reject(makeError()), SQUARE_LOAD_TIMEOUT_MS);\n Promise.resolve(step).then(value => { clearTimeout(timer); resolve(value); }, error => { clearTimeout(timer); reject(error); });\n });\n}\n\n/** Marks the script tags THIS loader inserted, so a tag whose `window.Square` is gone (the host deleted it) is replaced instead of waited for. */\nconst OWN_SCRIPT_MARK = 'data-forgeroute-square';\n\n/** Why the SDK could not be loaded; `code` is `'script_failed'` (the script did not load or never defined `window.Square`) or `'sdk_missing'`. */\nexport class SquareLoadError extends Error {\n constructor(readonly code: 'script_failed' | 'sdk_missing') {\n super(code);\n this.name = 'SquareLoadError';\n }\n}\n\n/** Loads the Web Payments SDK and resolves the payments object: `loader({ applicationId, locationId, environment })`. */\nexport type SquareLoaderFn = (config: SquareConnectionConfig) => Promise<SquarePaymentsLike>;\n\ninterface SquareGlobal { payments(applicationId: string, locationId: string): SquarePaymentsLike | Promise<SquarePaymentsLike> }\nconst squareGlobal = (): SquareGlobal | undefined => (window as unknown as { Square?: SquareGlobal }).Square;\n\n/**\n * The script tag handling, behind an object so a spec can watch it (internal: not part of the public API).\n *\n * The sandbox and the production SDK are two different scripts that BOTH define `window.Square`, so `window.Square` alone says nothing about which one it is. `active` remembers\n * the address of the script whose `window.Square` is current: when a payment form asks for the OTHER environment, the old object is set aside, the other script is loaded fresh and\n * its `window.Square` wins (a form that already has its payments object keeps working: it holds its own reference). A `window.Square` this loader did not load (`active` is `null`)\n * is trusted as it is. One page normally uses one environment; switching is supported but not a hot path.\n */\nexport const squareScript = {\n /** One load per address at a time; a failed load is forgotten so the next call retries with a fresh script. */\n pending: new Map<string, Promise<void>>(),\n /** The address of the script whose `window.Square` is current; `null` = unknown (nothing loaded yet, or the SDK came from the host page). */\n active: null as string | null,\n /** The load that currently OWNS an address: a callback of any other load (an older one, a timer that fires late) never touches `pending`, `active` or `window.Square`. */\n owners: new Map<string, object>(),\n load(url: string): Promise<void> {\n const switching = squareScript.active !== null && squareScript.active !== url;\n if (squareGlobal() && !switching) return Promise.resolve();\n // Two environments are never loaded at the same moment (both define window.Square): the second waits for the first to finish, then switches.\n for (const [other, inFlight] of squareScript.pending) if (other !== url) return inFlight.catch(() => undefined).then(() => squareScript.load(url));\n // A load of THIS address that is already running (also one that is doing the switch) is shared: never a second script, never a second download.\n const running = squareScript.pending.get(url);\n if (running) return running;\n const owner = {};\n squareScript.owners.set(url, owner);\n const promise = new Promise<void>((resolve, reject) => {\n const windowWithSquare = window as unknown as { Square?: SquareGlobal };\n const previous = switching ? windowWithSquare.Square : undefined;\n const current = () => squareScript.owners.get(url) === owner;\n let settled = false;\n let loadTimer: ReturnType<typeof setTimeout> | null = null;\n let script: HTMLScriptElement | null = null;\n const finish = (): boolean => {\n if (settled) return false;\n settled = true;\n if (loadTimer) { clearTimeout(loadTimer); loadTimer = null; }\n if (script) { script.onload = null; script.onerror = null; }\n return true;\n };\n const fail = () => {\n if (!finish()) return;\n if (current()) {\n squareScript.pending.delete(url);\n squareScript.owners.delete(url);\n if (switching && previous && !windowWithSquare.Square) windowWithSquare.Square = previous; // the other environment keeps working\n }\n reject(new SquareLoadError('script_failed'));\n };\n // A finished load is forgotten at once (only an IN-FLIGHT load is shared): nothing is retained, and coming back to this address later loads it again.\n const done = () => {\n if (!finish()) return;\n if (current()) { squareScript.active = url; squareScript.pending.delete(url); squareScript.owners.delete(url); }\n resolve();\n };\n const tags = Array.from(document.querySelectorAll('script')).filter(s => s.getAttribute('src') === url);\n let foreign = tags.filter(t => !t.hasAttribute(OWN_SCRIPT_MARK));\n if (switching) {\n // The other environment's SDK is current: run THIS address again (a script that stays in the page does not run twice) and let its `window.Square` replace the old one.\n tags.forEach(t => t.remove());\n foreign = [];\n delete windowWithSquare.Square;\n } else {\n // Our own tag is still in the page but `window.Square` is gone (the host deleted it): insert the script again instead of waiting for something that will not come.\n tags.filter(t => t.hasAttribute(OWN_SCRIPT_MARK)).forEach(t => t.remove());\n }\n if (!switching && foreign.length) {\n // Somebody else inserted the script: wait for `window.Square` instead of adding a second one.\n const started = Date.now();\n const timer = setInterval(() => {\n if (settled) { clearInterval(timer); return; }\n if (squareGlobal()) { clearInterval(timer); done(); }\n else if (Date.now() - started > SQUARE_SCRIPT_WAIT_MS) { clearInterval(timer); fail(); }\n }, 50);\n return;\n }\n const own = document.createElement('script');\n script = own;\n own.src = url;\n own.async = true;\n own.setAttribute(OWN_SCRIPT_MARK, '');\n loadTimer = setTimeout(() => { own.remove(); fail(); }, SQUARE_LOAD_TIMEOUT_MS); // onload / onerror never fired: the load is reported as failed\n own.onload = () => { if (squareGlobal()) done(); else { own.remove(); fail(); } };\n own.onerror = () => { own.remove(); fail(); };\n document.head.appendChild(own);\n });\n squareScript.pending.set(url, promise);\n return promise;\n },\n};\n\nexport const squareSdkUrl = (environment: SquareEnvironment): string => (environment === 'production' ? SQUARE_SDK_URL : SQUARE_SANDBOX_SDK_URL);\n\n/**\n * The default loader: adds the SDK script from Square's CDN (production or sandbox host by `environment`) once, then calls `Square.payments(applicationId, locationId)`.\n * Nothing is fetched until a payment form is shown.\n */\nexport const defaultSquareLoader: SquareLoaderFn = async (config) => {\n await squareScript.load(squareSdkUrl(config.environment));\n const square = squareGlobal();\n if (!square) throw new SquareLoadError('sdk_missing');\n return square.payments(config.applicationId, config.locationId);\n};\n\n/** How the Web Payments SDK is loaded. Provide your own to fake Square in tests or to load it differently. Defaults to `defaultSquareLoader`. */\nexport const SQUARE_LOADER = new InjectionToken<SquareLoaderFn>('SQUARE_LOADER', { providedIn: 'root', factory: () => defaultSquareLoader });\n\n/** App-wide defaults for every Square component, set once with `provideSquarePayment`. A value on the component always wins. */\nexport interface SquarePaymentDefaults {\n /** The Square application id (`sq0idp-...` / `sandbox-sq0idb-...`). */\n applicationId?: string;\n /** The seller's Square location id. */\n locationId?: string;\n /** `'production'` or `'sandbox'` (default `'sandbox'`: a forgotten setting never charges real cards). */\n environment?: SquareEnvironment;\n}\n\nexport const SQUARE_PAYMENT_DEFAULTS = new InjectionToken<SquarePaymentDefaults>('SQUARE_PAYMENT_DEFAULTS', { providedIn: 'root', factory: () => ({}) });\n\nexport interface ProvideSquarePaymentOptions extends SquarePaymentDefaults {\n /** Replaces how the SDK is loaded (tests, a self-hosted loader). */\n loader?: SquareLoaderFn;\n}\n\n/**\n * Global defaults for the Square components:\n *\n * providers: [provideSquarePayment({ applicationId: env.squareApplicationId, locationId: env.squareLocationId, environment: 'production' })]\n */\nexport function provideSquarePayment(options: ProvideSquarePaymentOptions = {}): Provider[] {\n const { loader, ...defaults } = options;\n const providers: Provider[] = [{ provide: SQUARE_PAYMENT_DEFAULTS, useValue: defaults }];\n if (loader) providers.push({ provide: SQUARE_LOADER, useValue: loader });\n return providers;\n}\n","import { UiLabelKey, uiText } from '@forgeroute/ui/core';\nimport type { SquareTokenError } from '../square-loader/square-types';\n\n/**\n * Plain-language text for the codes Square's Payments API answers when a payment is refused (https://developer.squareup.com/reference/square/objects/Error).\n * The Web Payments SDK never sees these (it only tokenizes); they come back from the host's backend after it created the payment, which is why the table is\n * public: `getSquarePaymentErrorMessage(code)` words them in the app's active language. Values are label keys; the English text lives in the dictionary.\n */\nexport const SQUARE_PAYMENT_ERROR_KEYS: Readonly<Record<string, UiLabelKey>> = {\n GENERIC_DECLINE: 'squareErrors.code.GENERIC_DECLINE',\n CARD_DECLINED: 'squareErrors.code.CARD_DECLINED',\n CARD_DECLINED_CALL_ISSUER: 'squareErrors.code.CARD_DECLINED_CALL_ISSUER',\n CARD_DECLINED_VERIFICATION_REQUIRED: 'squareErrors.code.CARD_DECLINED_VERIFICATION_REQUIRED',\n INSUFFICIENT_FUNDS: 'squareErrors.code.INSUFFICIENT_FUNDS',\n CVV_FAILURE: 'squareErrors.code.CVV_FAILURE',\n VERIFY_CVV_FAILURE: 'squareErrors.code.CVV_FAILURE',\n ADDRESS_VERIFICATION_FAILURE: 'squareErrors.code.ADDRESS_VERIFICATION_FAILURE',\n VERIFY_AVS_FAILURE: 'squareErrors.code.ADDRESS_VERIFICATION_FAILURE',\n INVALID_EXPIRATION: 'squareErrors.code.INVALID_EXPIRATION',\n BAD_EXPIRATION: 'squareErrors.code.INVALID_EXPIRATION',\n CARD_EXPIRED: 'squareErrors.code.CARD_EXPIRED',\n INVALID_CARD: 'squareErrors.code.INVALID_CARD',\n PAN_FAILURE: 'squareErrors.code.INVALID_CARD',\n CARD_NOT_SUPPORTED: 'squareErrors.code.CARD_NOT_SUPPORTED',\n INVALID_ACCOUNT: 'squareErrors.code.INVALID_ACCOUNT',\n PAYMENT_LIMIT_EXCEEDED: 'squareErrors.code.PAYMENT_LIMIT_EXCEEDED',\n TRANSACTION_LIMIT: 'squareErrors.code.PAYMENT_LIMIT_EXCEEDED',\n BUYER_REFUSED_PAYMENT: 'squareErrors.code.BUYER_REFUSED_PAYMENT',\n CARDHOLDER_INSUFFICIENT_PERMISSIONS: 'squareErrors.code.CARDHOLDER_INSUFFICIENT_PERMISSIONS',\n IDEMPOTENCY_KEY_REUSED: 'squareErrors.code.IDEMPOTENCY_KEY_REUSED',\n RATE_LIMITED: 'squareErrors.code.RATE_LIMITED',\n UNAUTHORIZED: 'squareErrors.code.UNAUTHORIZED',\n ACCESS_TOKEN_EXPIRED: 'squareErrors.code.UNAUTHORIZED',\n ACCESS_TOKEN_REVOKED: 'squareErrors.code.UNAUTHORIZED',\n};\n\n/** The card fields the SDK names in a validation error. */\nexport const SQUARE_FIELD_ERROR_KEYS: Readonly<Record<string, UiLabelKey>> = {\n cardNumber: 'squareErrors.field.cardNumber',\n expirationDate: 'squareErrors.field.expirationDate',\n cvv: 'squareErrors.field.cvv',\n postalCode: 'squareErrors.field.postalCode',\n};\n\n/** The SDK's own error types. */\nexport const SQUARE_TYPE_ERROR_KEYS: Readonly<Record<string, UiLabelKey>> = {\n UNSUPPORTED_CARD_BRAND: 'squareErrors.type.UNSUPPORTED_CARD_BRAND',\n INVALID_APPLICATION_ID: 'squareErrors.type.CONFIGURATION',\n INVALID_LOCATION_ID: 'squareErrors.type.CONFIGURATION',\n PAYMENT_METHOD_NOT_SUPPORTED: 'squareErrors.type.PAYMENT_METHOD_NOT_SUPPORTED',\n};\n\n/**\n * `'friendly'` (default): the code table (`overrides` first), then the validation field, then the SDK error type, then Square's own text for a validation error\n * (customer-facing), then the fallback. `'square'`: Square's own `message` untouched, the fallback when there is none.\n */\nexport type SquareErrorDisplay = 'friendly' | 'square';\n\nexport interface SquareErrorMessageOptions {\n display?: SquareErrorDisplay;\n /** Text for single codes (a payment code, an SDK error type, a card field name); wins over the tables. */\n overrides?: Readonly<Record<string, string>> | null;\n /** Shown when there is nothing better. */\n fallback?: string;\n}\n\n/** The text for a payment error code the host's backend got back from Square (`'GENERIC_DECLINE'`, ...), in the app's active language. */\nexport function getSquarePaymentErrorMessage(code: string | null | undefined, options: Pick<SquareErrorMessageOptions, 'overrides' | 'fallback'> = {}): string {\n const fallback = options.fallback ?? uiText('squareErrors.defaultMessage');\n const key = (code ?? '').toUpperCase();\n const override = key ? options.overrides?.[code as string] ?? options.overrides?.[key] : undefined;\n if (override) return override;\n const table = SQUARE_PAYMENT_ERROR_KEYS[key];\n return table ? uiText(table) : fallback;\n}\n\n/** The text to show the customer for an error of the Web Payments SDK (`result.errors[n]`). */\nexport function getSquareErrorMessage(error: SquareTokenError | null | undefined, options: SquareErrorMessageOptions = {}): string {\n const fallback = options.fallback ?? uiText('squareErrors.defaultMessage');\n if (!error) return fallback;\n if (options.display === 'square') return error.message || fallback;\n const overrides = options.overrides ?? {};\n for (const name of [error.code, error.type, error.field]) {\n if (name && overrides[name]) return overrides[name];\n }\n if (error.code && SQUARE_PAYMENT_ERROR_KEYS[error.code.toUpperCase()]) return uiText(SQUARE_PAYMENT_ERROR_KEYS[error.code.toUpperCase()]);\n if (error.field && SQUARE_FIELD_ERROR_KEYS[error.field]) return uiText(SQUARE_FIELD_ERROR_KEYS[error.field]);\n const type = (error.type ?? '').toUpperCase();\n if (SQUARE_TYPE_ERROR_KEYS[type]) return uiText(SQUARE_TYPE_ERROR_KEYS[type]);\n if (type === 'VALIDATION_ERROR' && error.message) return error.message;\n return fallback;\n}\n","import { UiLabelKey, uiText } from '@forgeroute/ui/core';\nimport { getSquareErrorMessage, type SquareErrorMessageOptions } from '../errors/square-errors';\nimport type { SquareTokenDetailsLike, SquareTokenError, SquareTokenResultLike } from '../square-loader/square-types';\n\n/** `'card'` = the Web Payments SDK card form, `'ach'` = Square's bank-account authorization window. */\nexport type SquareMethod = 'card' | 'ach';\n/** `'payment'` takes a payment (single-use token), `'setup'` saves the method on file (the token is used to create a card / bank account on file). */\nexport type SquareIntentKind = 'payment' | 'setup';\n\nexport type SquareCardType = 'CREDIT' | 'DEBIT' | 'UNKNOWN';\nexport type SquarePrepaidType = 'PREPAID' | 'NOT_PREPAID' | 'UNKNOWN';\n\n/**\n * What the SDK told about the tokenized method. Every field is `null` when the SDK did not send it. `cardType` / `prepaidType` (the funding of the card) are\n * only filled when the SDK returns them in `details.card`, which it usually does NOT at tokenization time: Square's own `card_type` / `prepaid_type` are\n * read on the server after the card exists (a card on file, or the payment), so a backend that needs the funding must read it there.\n */\nexport interface SquareTokenDetails {\n brand: string | null;\n last4: string | null;\n expMonth: number | null;\n expYear: number | null;\n cardType: SquareCardType | null;\n prepaidType: SquarePrepaidType | null;\n bankName: string | null;\n accountType: string | null;\n}\n\n/** A successful tokenization. The component NEVER talks to your backend: send `token` (single use) to it, together with `attemptKey` (never the deprecated per-token `idempotencyKey`). */\nexport interface SquareTokenizedEvent {\n /** The single-use source id (`cnon:...` for a card, `bnon:...` for a bank account). */\n token: string;\n method: SquareMethod;\n kind: SquareIntentKind;\n details: SquareTokenDetails;\n /** The buyer-verification (SCA / 3-D Secure) token, when `payments.verifyBuyer` ran (card, `amount` + `billingContact` given); `null` otherwise. */\n verificationToken: string | null;\n /**\n * @deprecated A new id per tokenization: do NOT use it as the charge's idempotency key (a retry with a new token would then be a second payment). Derive Square's `idempotency_key` from\n * `attemptKey`, and look the attempt up by `attemptKey` before calling Square.\n */\n idempotencyKey: string;\n /**\n * The key of this PAYMENT ATTEMPT (stable across retries after a timeout, a reload and a second tab; renewed only after a definitive failure or success): send it to your backend with the\n * charge, which derives the processor's idempotency key from it. `idempotencyKey` above is new per tokenization; the attempt key is the one that prevents a duplicate charge.\n */\n attemptKey: string;\n /** The amount the attempt STARTED with (pinned when the click began; the buyer verification asked for exactly this). `null` for a saved card or when the form has no `amount`. */\n amount: number | null;\n /** The payable the attempt started for (the form's `payableRef` at the click): send it with the charge; the backend allows ONE open or succeeded attempt per payable and answers 409 `payment_in_flight` to a second key. */\n payableRef: string | null;\n}\n\nexport type SquareFailureStage = 'load' | 'validate' | 'tokenize' | 'verify';\n\n/** A failure: `message` is what to show the customer; `squareMessage` is Square's own text. */\nexport interface SquareFailure {\n code: string;\n message: string;\n squareMessage: string;\n stage: SquareFailureStage;\n /** The SDK's `status` (`'Cancel'`, `'Invalid'`, ...) for a tokenization failure. */\n status?: string;\n /** The card field a validation error is about. */\n field?: string;\n /** The SDK errors as returned. */\n errors?: SquareTokenError[];\n}\n\nexport function squareFailure(code: string, message: string, stage: SquareFailureStage, squareMessage = ''): SquareFailure {\n return { code, message, squareMessage, stage };\n}\n\n/** An error thrown by the SDK, the loader or a host callback: its own `error.error.message` (HTTP body), `message`, else the fallback. */\nexport function messageOfThrown(err: unknown, fallback: string): string {\n const e = err as { error?: { message?: unknown }; message?: unknown } | null | undefined;\n if (typeof e?.error?.message === 'string' && e.error.message) return e.error.message;\n if (typeof e?.message === 'string' && e.message) return e.message;\n return fallback;\n}\n\nconst upper = (v: unknown): string => (typeof v === 'string' ? v.toUpperCase() : '');\nconst text = (v: unknown): string | null => (typeof v === 'string' && v.trim() ? v : null);\n\n/** `details` of a token result as the fixed shape (see {@link SquareTokenDetails}); an unreadable field is `null`. */\nexport function normalizeSquareDetails(details: SquareTokenDetailsLike | null | undefined): SquareTokenDetails {\n const card = details?.card;\n const cardType = upper(card?.cardType);\n const prepaid = upper(card?.prepaidType);\n return {\n brand: text(card?.brand),\n last4: text(card?.last4) ?? text(details?.lastFour) ?? text(details?.ach?.lastFour),\n expMonth: typeof card?.expMonth === 'number' ? card.expMonth : null,\n expYear: typeof card?.expYear === 'number' ? card.expYear : null,\n cardType: cardType === 'CREDIT' || cardType === 'DEBIT' || cardType === 'UNKNOWN' ? cardType : null,\n prepaidType: prepaid === 'PREPAID' || prepaid === 'NOT_PREPAID' || prepaid === 'UNKNOWN' ? prepaid : null,\n bankName: text(details?.bankName) ?? text(details?.ach?.bankName),\n accountType: text(details?.accountType) ?? text(details?.ach?.accountType),\n };\n}\n\n/** The failure of a `tokenize()` that did not answer `status: 'OK'` with a token. The text is chosen by `options` (see `getSquareErrorMessage`). */\nexport function failureFromTokenResult(result: SquareTokenResultLike, method: SquareMethod, options: SquareErrorMessageOptions = {}): SquareFailure {\n const errors = (result.errors ?? []).filter(e => !!e);\n const first = errors[0];\n const base = { status: result.status, ...(errors.length ? { errors } : {}) };\n if (!first) {\n const cancelled = result.status === 'Cancel';\n const key: UiLabelKey = cancelled ? 'squarePayment.msg.cancelled' : method === 'ach' ? 'squarePayment.msg.achFailed' : 'squarePayment.msg.tokenizeFailed';\n return { ...squareFailure(cancelled ? 'cancelled' : method === 'ach' ? 'ach_failed' : 'tokenize_failed', uiText(key), 'tokenize'), ...base };\n }\n const fallback = options.fallback ?? uiText(method === 'ach' ? 'squarePayment.msg.achFailed' : 'squarePayment.msg.tokenizeFailed');\n return {\n ...squareFailure(first.code || first.type || 'tokenize_failed', getSquareErrorMessage(first, { ...options, fallback }), 'tokenize', first.message ?? ''),\n ...base,\n ...(first.field ? { field: first.field } : {}),\n };\n}\n\n/** A new idempotency key (a UUID, with a time + random fallback for a browser without `crypto.randomUUID`). */\nexport function newIdempotencyKey(): string {\n const c = typeof crypto !== 'undefined' ? crypto : undefined;\n return c && 'randomUUID' in c ? c.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`;\n}\n","import { isDarkPage } from '@forgeroute/ui/utils';\n\n/**\n * The `style` option of `payments.card({ style })`: the card form's look read from CSS custom properties at runtime, so one set of tokens styles the page and\n * the Square form, in light and dark.\n *\n * :root { --ui-square-color-primary: #0d9488; --ui-square-border-radius: 8px; }\n *\n * Tokens read (all optional; a missing one is left out so Square's default stays): `--ui-square-color-primary` (the focused field's border),\n * `--ui-square-color-text`, `--ui-square-color-background`, `--ui-square-color-border`, `--ui-square-color-danger`, `--ui-square-font-family`,\n * `--ui-square-border-radius`, `--ui-square-font-size-base`. On a dark page (`data-theme=\"dark\"`, or a dark system whose root is not forced to `light`) the text and\n * background fall back to a light-on-dark pair so a form without tokens stays readable.\n */\nexport type SquareCardStyle = Record<string, Record<string, string>>;\n\nconst DARK_TEXT = '#e2e8f0';\nconst DARK_BACKGROUND = '#0f172a';\nconst DARK_BORDER = '#64748b'; // 3.76:1 on the dark background (WCAG 1.4.11 non-text contrast; #475569 was ~2.35:1)\n\n/** Builds the card style from the tokens in effect on `element` (default: the document root). */\nexport function readSquareCardStyle(doc: Document, element: Element = doc.documentElement): SquareCardStyle {\n const view = doc.defaultView;\n const token = (name: string): string => (view ? view.getComputedStyle(element).getPropertyValue(name).trim() : '');\n const dark = isDarkPage(doc);\n const primary = token('--ui-square-color-primary');\n const text = token('--ui-square-color-text') || (dark ? DARK_TEXT : '');\n const background = token('--ui-square-color-background') || (dark ? DARK_BACKGROUND : '');\n const border = token('--ui-square-color-border') || (dark ? DARK_BORDER : '');\n const danger = token('--ui-square-color-danger');\n const font = token('--ui-square-font-family');\n const radius = token('--ui-square-border-radius');\n const size = token('--ui-square-font-size-base');\n const style: SquareCardStyle = {};\n const put = (selector: string, props: Record<string, string | undefined>): void => {\n const filled = Object.fromEntries(Object.entries(props).filter(([, v]) => !!v)) as Record<string, string>;\n if (Object.keys(filled).length) style[selector] = filled;\n };\n put('.input-container', { borderColor: border, borderRadius: radius });\n put('.input-container.is-focus', { borderColor: primary });\n put('.input-container.is-error', { borderColor: danger });\n put('.message-text', { color: text });\n put('.message-icon', { color: text });\n put('.message-text.is-error', { color: danger });\n put('input', { backgroundColor: background, color: text, fontFamily: font, fontSize: size });\n put('input::placeholder', { color: dark ? '#94a3b8' : '' });\n return style;\n}\n\n/** The app's theme tokens for {@link squareCardStyleFromTheme}. Every field is optional: a missing one is left out so the SDK's default stays. */\nexport interface SquareThemeTokens {\n /** The focused field's border. */\n primary?: string;\n background?: string;\n text?: string;\n danger?: string;\n border?: string;\n fontFamily?: string;\n radius?: string;\n fontSize?: string;\n /** The page is dark: text / background / border fall back to a readable light-on-dark pair when not given. Default false. */\n dark?: boolean;\n}\n\n/**\n * Neutral card-style helper for apps: turns the app's own theme tokens into the `style` option of the card form (pass it to `[cardStyle]`), so the form matches the page in light and dark\n * without the app knowing the SDK's selectors. Pure (no DOM). Same result as {@link readSquareCardStyle} would give for the same values.\n */\nexport function squareCardStyleFromTheme(tokens: SquareThemeTokens): SquareCardStyle {\n const dark = !!tokens.dark;\n const text = tokens.text || (dark ? DARK_TEXT : '');\n const background = tokens.background || (dark ? DARK_BACKGROUND : '');\n const border = tokens.border || (dark ? DARK_BORDER : '');\n const style: SquareCardStyle = {};\n const put = (selector: string, props: Record<string, string | undefined>): void => {\n const filled = Object.fromEntries(Object.entries(props).filter(([, v]) => !!v)) as Record<string, string>;\n if (Object.keys(filled).length) style[selector] = filled;\n };\n put('.input-container', { borderColor: border, borderRadius: tokens.radius });\n put('.input-container.is-focus', { borderColor: tokens.primary });\n put('.input-container.is-error', { borderColor: tokens.danger });\n put('.message-text', { color: text });\n put('.message-icon', { color: text });\n put('.message-text.is-error', { color: tokens.danger });\n put('input', { backgroundColor: background, color: text, fontFamily: tokens.fontFamily, fontSize: tokens.fontSize });\n put('input::placeholder', { color: dark ? '#94a3b8' : '' });\n return style;\n}\n","import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, Injector, PLATFORM_ID, afterNextRender, computed, effect, inject, input, model, output, signal, untracked, viewChild, ViewEncapsulation } from '@angular/core';\nimport { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport { FormsModule } from '@angular/forms';\nimport { AlertComponent } from '@forgeroute/ui/alert';\nimport { ButtonComponent, UiLabelsService, uiText } from '@forgeroute/ui/core';\nimport { CheckboxComponent } from '@forgeroute/ui/checkbox';\nimport { LiveRegionComponent } from '@forgeroute/ui/live-region';\nimport { PAYMENT_READINESS_EVERY_MS, PAYMENT_READINESS_TIMEOUT_MS, PAYMENT_STATUS_CHECK_TIMEOUT_MS, PAYMENT_STATUS_FAIL_GRACE_MS, PAYMENT_HOST_SILENCE_MS, PAYMENT_STATUS_POLL_MAX_MS, PAYMENT_STATUS_POLL_MS, PaymentAttemptStatusComponent, createPaymentProtection, type CheckPaymentStatusFn, type PaymentAttempt, type PaymentAttemptOutcome, type PaymentReadiness, type PaymentReadinessResult, type ReadinessCheckFn } from '@forgeroute/ui/payments';\nimport { PillTabsComponent, type PillTab } from '@forgeroute/ui/pill-tabs';\nimport { SkeletonComponent } from '@forgeroute/ui/skeleton';\nimport { TextComponent } from '@forgeroute/ui/text';\nimport { TextInputComponent } from '@forgeroute/ui/text-input';\nimport { SQUARE_LOADER, SQUARE_PAYMENT_DEFAULTS, SquareLoadError, withSquareTimeout } from '../square-loader/square-loader';\nimport type { SquareAchLike, SquareBillingContact, SquareCardLike, SquareConnectionConfig, SquarePaymentsLike, SquareVerifyBuyerDetails } from '../square-loader/square-types';\nimport type { SquareErrorDisplay, SquareErrorMessageOptions } from '../errors/square-errors';\nimport {\n failureFromTokenResult, messageOfThrown, newIdempotencyKey, normalizeSquareDetails, squareFailure,\n type SquareFailure, type SquareIntentKind, type SquareMethod, type SquareTokenizedEvent,\n} from './square-outcomes';\nimport { readSquareCardStyle, type SquareCardStyle } from './square-style';\n\n/** The texts of the screen-reader status region. */\nexport interface SquareA11yMessages {\n loading: string;\n processing: string;\n tokenized: string;\n}\n\n/** The screen-reader messages of the payment form; read on every access, so they follow the app's active language. */\nexport const SQUARE_A11Y_MESSAGES: Readonly<SquareA11yMessages> = {\n get loading() { return uiText('squarePayment.a11y.loading'); },\n get processing() { return uiText('squarePayment.a11y.processing'); },\n get tokenized() { return uiText('squarePayment.a11y.tokenized'); },\n};\n\n/**\n * The live Square objects of a form, handed to the host by `(squareReady)`: the host's own code can call `card.tokenize()`, `ach.tokenize({ accountHolderName })`,\n * `payments.verifyBuyer(...)` and anything else the SDK offers. `card` is set for the card form, `ach` for the bank-account form (the other one is `null`).\n */\nexport interface SquareReadyEvent {\n payments: SquarePaymentsLike;\n card: SquareCardLike | null;\n ach: SquareAchLike | null;\n}\n\n/** The SDK card events that mean the payer changed what is typed (not focus / blur, not a validation that just failed). */\nconst SQUARE_EDIT_EVENTS = ['cardBrandChanged', 'postalCodeChanged', 'errorClassRemoved'] as const;\n\nlet nextId = 0;\nconst jsonEqual = (a: unknown, b: unknown): boolean => JSON.stringify(a) === JSON.stringify(b);\n/**\n * Structural equality for option objects that may hold functions (`cardOptions`): plain values and nested objects / arrays / Maps / Sets are compared by content (a Set's members\n * structurally and without regard to order), a Date by time, a RegExp by source and flags, a class instance by prototype AND own keys, a FUNCTION by reference, so a new callback\n * rebuilds the card form (JSON.stringify would drop functions and `undefined` and call two different callbacks equal). A cycle never loops: a pair of objects that is already being\n * compared (further up the same comparison) counts as equal while it is in progress.\n */\nexport function structuralEqual(a: unknown, b: unknown, inProgress: WeakMap<object, WeakSet<object>> = new WeakMap()): boolean {\n if (Object.is(a, b)) return true;\n if (typeof a !== 'object' || typeof b !== 'object' || !a || !b) return false;\n if (inProgress.get(a)?.has(b)) return true;\n if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false;\n if (a instanceof Date) return b instanceof Date && a.getTime() === b.getTime();\n if (a instanceof RegExp) return b instanceof RegExp && a.source === b.source && a.flags === b.flags;\n const pairs = inProgress.get(a) ?? new WeakSet<object>();\n pairs.add(b);\n inProgress.set(a, pairs);\n try {\n if (a instanceof Map) {\n const other = b as Map<unknown, unknown>;\n return a.size === other.size && [...a].every(([k, v]) => other.has(k) && structuralEqual(v, other.get(k), inProgress));\n }\n if (a instanceof Set) {\n const other = b as Set<unknown>;\n if (a.size !== other.size) return false;\n const rest = [...other];\n for (const member of a) {\n const at = rest.findIndex(candidate => structuralEqual(member, candidate, inProgress));\n if (at < 0) return false;\n rest.splice(at, 1);\n }\n return true;\n }\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n return keysA.length === keysB.length && keysA.every(k => k in b && structuralEqual((a as Record<string, unknown>)[k], (b as Record<string, unknown>)[k], inProgress));\n } finally {\n pairs.delete(b);\n }\n}\n\n/**\n * Square Web Payments SDK form: a card form or Square's bank-account (ACH) authorization, as a payment (`mode=\"payment\"`) or to keep the method on file\n * (`mode=\"setup\"`).\n *\n * The component NEVER talks to your backend. It tokenizes in the browser and emits `(tokenized)` with the single-use token (plus the brand / last four /\n * bank name Square returned, an optional buyer-verification token and an idempotency key); your app sends that to its backend, which creates the payment or the\n * card on file. A failure is `(failed)` with a friendly message. The SDK script is loaded lazily from Square's CDN (nothing is fetched until a form is shown).\n *\n * <ui-square-payment [applicationId]=\"app\" [locationId]=\"loc\" environment=\"production\" [amount]=\"total\" [billingContact]=\"billing\"\n * (tokenized)=\"onToken($event)\" (failed)=\"onFailed($event)\" />\n *\n * Every behaviour of the CRM apps' Square forms is reproduced; see docs/square.md (\"Parity with the existing app implementations\").\n */\n@Component({\n selector: 'ui-square-payment',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n imports: [AlertComponent, ButtonComponent, CheckboxComponent, FormsModule, LiveRegionComponent, PaymentAttemptStatusComponent, PillTabsComponent, SkeletonComponent, TextComponent, TextInputComponent],\n host: { '[attr.aria-busy]': '!mountOnly() && (loading() || submitting()) ? \"true\" : null' },\n template: `\n <div class=\"sqp\">\n @if (!mountOnly() || a11yMessages()) {\n <ui-live-region data-testid=\"square-status\" [message]=\"statusText()\" />\n }\n @if (!mountOnly() && tabs().length > 1) {\n <div class=\"sqp-block\"><ui-pill-tabs [ariaLabel]=\"labels.t('squarePayment.method.group')\" [tabs]=\"tabs()\" [activeKey]=\"method()\" (tabChange)=\"onTab($event)\" /></div>\n }\n @if (!mountOnly() && showStatus()) {\n <ui-payment-attempt-status [attempt]=\"attempt\" [readiness]=\"readiness\" [allowStartOver]=\"allowStartOver()\" [showPaid]=\"showPaid()\" (retryLoad)=\"retryLoad()\" />\n }\n @if (!mountOnly() && (loading() || pending())) {\n <div class=\"sqp-skeleton\" data-testid=\"square-skeleton\" aria-hidden=\"true\">\n <ui-skeleton [height]=\"44\" [mb]=\"10\" />\n <ui-skeleton [height]=\"44\" width=\"60%\" />\n </div>\n }\n @if (!mountOnly() && loadErrorText(); as text) {\n <div class=\"sqp-block\" data-testid=\"square-load-error\"><ui-alert variant=\"danger\">{{ text }}</ui-alert></div>\n }\n @if (!mountOnly() && required()) {\n <div class=\"sqp-label\" data-testid=\"square-required-label\">{{ label() }}<span class=\"sqp-required\" aria-hidden=\"true\">*</span></div>\n }\n @if (method() === 'card') {\n <div #mount class=\"sqp-mount\" [attr.id]=\"mountId() || null\" [class]=\"mountClass()\" [class.sqp-mount--hidden]=\"mountHidden()\" [class.sqp-mount--locked]=\"mountLocked()\"\n [attr.aria-hidden]=\"mountHidden() ? 'true' : null\" [attr.aria-disabled]=\"mountLocked() ? 'true' : null\" [attr.inert]=\"mountHidden() || mountLocked() ? '' : null\"\n [attr.role]=\"mountOnly() ? null : 'group'\" [attr.aria-label]=\"mountOnly() ? null : label()\" [attr.data-testid]=\"mountTestId()\"></div>\n } @else if (!mountOnly()) {\n <div class=\"sqp-ach\" data-testid=\"square-ach\">\n <ui-text data-testid=\"square-ach-info\" size=\"sm\" tone=\"muted\" [text]=\"labels.t('squarePayment.achInfo')\" />\n <ui-text-input [label]=\"labels.t('squarePayment.holderLabel')\" [placeholder]=\"labels.t('squarePayment.holderPlaceholder')\" [inputTestId]=\"holderTestId()\" autocomplete=\"name\"\n [required]=\"true\" [maxlength]=\"255\" [error]=\"holderError()\" [showErrors]=\"attempted()\" [disabled]=\"locked()\"\n [ngModel]=\"holder()\" (ngModelChange)=\"holder.set($event ?? ''); edited()\" />\n @if (requireAchConsent()) {\n <ui-checkbox testId=\"square-consent\" [label]=\"achConsent()\" [required]=\"true\" [requiredMessage]=\"labels.t('squarePayment.consentRequired')\" [showErrors]=\"attempted()\"\n [disabled]=\"locked()\" [ngModel]=\"consent()\" (ngModelChange)=\"consent.set(!!$event); edited()\" />\n }\n </div>\n }\n @if (!mountOnly() && errorText(); as text) {\n <div class=\"sqp-block\" [id]=\"errorId\" [attr.data-testid]=\"errorTestId()\"><ui-alert variant=\"danger\">{{ text }}</ui-alert></div>\n }\n @if (!mountOnly() && showSubmit()) {\n <div class=\"sqp-actions\">\n <ui-button variant=\"primary\" type=\"button\" [fullWidth]=\"true\" [loading]=\"submitting()\" [disabled]=\"submitDisabled()\" [ariaDescribedBy]=\"errorText() ? errorId : undefined\"\n data-testid=\"square-submit\" (click)=\"tokenize()\">{{ effectiveSubmitLabel() }}</ui-button>\n </div>\n }\n </div>\n `,\n styles: [`\n ui-square-payment { display: block; min-width: 0; }\n ui-square-payment .sqp { position: relative; }\n ui-square-payment .sqp-block { margin-top: 12px; }\n ui-square-payment .sqp-label { font-size: 0.875rem; font-weight: 500; color: var(--ui-text, #1e293b); margin-bottom: 6px; }\n ui-square-payment .sqp-required { color: var(--ui-danger, #dc2626); margin-left: 2px; }\n ui-square-payment .sqp-mount { min-height: 44px; margin-top: 12px; }\n ui-square-payment .sqp-ach { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }\n /* The submit button fills the row on every screen: a flex column stretches the (inline-flex) ui-button host, and [fullWidth] stretches its button. */\n ui-square-payment .sqp-actions { margin-top: 16px; display: flex; flex-direction: column; align-items: stretch; }\n /* While loading the card form is kept laid out (the SDK measures its container) but invisible and untouchable. */\n ui-square-payment .sqp-mount--hidden { position: absolute; top: 0; left: 0; right: 0; opacity: 0; pointer-events: none; }\n /* Disabled or tokenizing: the card form cannot be typed into. the inert attribute does it where it is supported; pointer-events (mouse / touch) and a dimmed look cover an older Safari. */\n ui-square-payment .sqp-mount--locked { pointer-events: none; opacity: 0.6; }\n `],\n})\nexport class SquarePaymentComponent {\n protected readonly labels = inject(UiLabelsService);\n private readonly loader = inject(SQUARE_LOADER);\n private readonly defaults = inject(SQUARE_PAYMENT_DEFAULTS);\n private readonly doc = inject(DOCUMENT);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly injector = inject(Injector);\n\n // ── Inputs ─────────────────────────────────────────────────────────────\n /**\n * Mount-only mode: the component only creates the Square objects and mounts the card form (or creates the bank-account object). No submit button, skeleton, status text (unless\n * `a11yMessages` is set), switcher, holder / consent fields or alerts: load failures go to `(loadError)` only. The host keeps its own tokenization code and calls the SDK with the\n * objects from `(squareReady)`. `mountId` / `mountClass` / `mountTestId` still apply, `(ready)` still emits, and `tokenize()` stays available (the holder name then comes from\n * `accountHolderName`, since the holder field is not drawn).\n */\n readonly mountOnly = input(false);\n /** `'payment'` takes a payment, `'setup'` keeps the method on file (changes the default button text and the buyer-verification intent). */\n readonly mode = input<SquareIntentKind>('payment');\n /** The method shown: `'card'` (the SDK card form) or `'ach'` (the bank-account authorization). Two-way. */\n readonly method = model<SquareMethod>('card');\n /** The methods the customer may pick between (a switcher is shown for two or more); `null` = only the `method` above, no switcher. */\n readonly methods = input<readonly SquareMethod[] | null>(null);\n /** The Square application id. Falls back to `provideSquarePayment({ applicationId })`. */\n readonly applicationId = input<string | null>(null);\n readonly locationId = input<string | null>(null);\n /** `'production'` or `'sandbox'` (default: the provider's, else `'sandbox'`). Decides which Square host the SDK script comes from. */\n readonly environment = input<'production' | 'sandbox' | null>(null);\n /** The amount in major units (12.5 = $12.50), for buyer verification (SCA / 3-D Secure) of a card payment. */\n readonly amount = input<number | null>(null);\n readonly currency = input('USD');\n /** The buyer's billing contact, for buyer verification. */\n readonly billingContact = input<SquareBillingContact | null>(null);\n /** Run `payments.verifyBuyer` after a card token. `null` (default) = automatic: for a payment when `amount` and `billingContact` are both given, for a setup when `billingContact` is given. */\n readonly verifyBuyer = input<boolean | null>(null);\n /** The account holder name of the bank account (ACH); the customer can edit it. */\n readonly accountHolderName = input('');\n /** ACH: an unticked authorization checkbox blocks the tokenization (default TRUE: a bank debit needs the holder's authorization; the wording follows `mode`: one-time payment vs agreed-upon payments for a saved account). Not applied in `mountOnly` (no checkbox is drawn: the host owns the consent). */\n readonly requireAchConsent = input(true);\n readonly achConsentTextInput = input<string | null>(null, { alias: 'achConsentText' });\n readonly achConsent = computed(() => this.achConsentTextInput() ?? this.labels.t(this.mode() === 'setup' ? 'squarePayment.achConsentSetup' : 'squarePayment.achConsent'));\n /** `payments.ach({ redirectURI })`: where the bank sends the customer back after a redirect-based authorization. Passed only when set. */\n readonly achRedirectUri = input<string | null>(null);\n /** `payments.ach({ transactionId })`. Passed only when set. */\n readonly achTransactionId = input<string | null>(null);\n /** Extra options of `payments.card(options)`, merged over `cardStyle`. */\n readonly cardOptions = input<Record<string, unknown> | null>(null);\n /** The card form's CSS-like `style` (see Square's docs). */\n readonly cardStyle = input<SquareCardStyle | null>(null);\n /** Build the card `style` from the `--ui-square-*` CSS tokens (light / dark) when no `cardStyle` is given. */\n readonly styleFromTokens = input(false);\n /** The language of the SDK's own texts (`payments.setLocale`): `'es-ES'`, `'en-US'`, ... Default: the app's active language (`UiLabelsService`: Spanish -> `es-ES`, English -> `en-US`). `false` = never call `setLocale` (the SDK picks from the browser). */\n readonly sdkLocale = input<string | false | null>(null);\n /** Show the SDK's visible field labels (`includeInputLabels`, helps screen readers and the 320px layout). Default false = unchanged. */\n readonly includeInputLabels = input(false);\n /** The card form's postal code field: `null` (default) = the SDK decides, a string pre-fills it, `false` hides it (only when your backend does not need AVS). */\n readonly postalCode = input<string | false | null>(null);\n /** Hide the SDK's inline validation message and icon under the fields (`.message-text` / `.message-icon`): the form's own alert (`role=\"alert\"`) is then the only place a failure is shown. Best effort: applied only where the SDK accepts the style. Default false. */\n readonly hideInlineMessages = input(false);\n\n /** Show the built-in attempt / readiness status block (a payment plugin that embeds this form shows its own and turns this off). */\n readonly showStatus = input(true);\n /** Show the paid state of the attempt status (default true). A form whose host shows its own success notice sets it off while that notice is up. */\n readonly showPaid = input(true);\n\n // ── Duplicate-payment protection and readiness gate (docs: \"Duplicate-payment protection\", \"Readiness gate\") ──\n /**\n * The payable this is for (an invoice, a balance, a payment link). While an attempt is undecided its opaque marker (key, amount, method) is stored under it in `localStorage`, so a RELOAD or a\n * SECOND TAB of the same payable starts locked (unknown) with the same attempt key. Without it the protection covers this page instance only. Nothing else is stored.\n */\n readonly payableRef = input<string | null>(null);\n /** A key the host supplies for the charge; empty = the component generates one per payment attempt session (see `attemptKeyChange`). */\n readonly attemptKey = input<string | null>(null);\n /** The host's status check by attempt key: resolves an UNKNOWN outcome (`'succeeded' | 'failed' | 'checking' | 'in_flight' | 'awaiting_verification'` (`'unknown'` = the old name of `'checking'`, still accepted)). */\n readonly checkStatus = input<CheckPaymentStatusFn | null>(null);\n /** The payable is paid (host re-render, back navigation): the form shows the paid state and ignores every submit for good. */\n readonly paid = input(false);\n /** The host reports an ambiguous result of ITS charge call (its own timeout): the form goes to \"Checking your payment...\" while true. */\n readonly hostPending = input(false);\n readonly statusPollMs = input(PAYMENT_STATUS_POLL_MS);\n readonly statusPollMaxMs = input(PAYMENT_STATUS_POLL_MAX_MS);\n /** A status check slower than this counts as unknown (ms). */\n readonly statusCheckTimeoutMs = input(PAYMENT_STATUS_CHECK_TIMEOUT_MS);\n /** While the attempt's own request is unsettled, a status answer `failed` is ignored for this long (ms). */\n readonly statusFailGraceMs = input(PAYMENT_STATUS_FAIL_GRACE_MS);\n /** Offer \"Start over\" after the status polling window (a new attempt with a NEW key). Turn it on ONLY when your backend allows ONE open or succeeded attempt per payable and answers 409 `payment_in_flight` to a second key: that rule is what makes it safe. */\n readonly allowStartOver = input(false);\n /** Managed environments where `navigator.onLine === false` is a false negative (captive portal, VPN): do not refuse a payment because of the browser's offline flag (default false). */\n readonly offlineOverride = input(false);\n /** A token-only form whose host never reports (markSucceeded / markFailed / markUnknown / markNotCharged) becomes unknown after this long (ms), so the status check and \"Check again\" engage. */\n readonly hostSilenceMs = input(PAYMENT_HOST_SILENCE_MS);\n /** The host's readiness endpoint (`GET /api/payments/ready`): `{ ready, reasons[] }`. */\n readonly readinessCheck = input<ReadinessCheckFn | null>(null);\n readonly readinessTimeoutMs = input(PAYMENT_READINESS_TIMEOUT_MS);\n readonly readinessEveryMs = input(PAYMENT_READINESS_EVERY_MS);\n\n\n // Presentation\n readonly submitLabel = input('');\n /** Show the built-in submit button; turn off to use your own and call `tokenize()`. */\n readonly showSubmit = input(true);\n readonly disabled = input(false);\n /** The host is still preparing the form (e.g. it fetches the amount): show the loading skeleton. */\n readonly pending = input(false);\n /** Accessible name of the payment form. */\n readonly labelInput = input<string | null>(null, { alias: 'label' });\n readonly label = computed(() => this.labelInput() ?? this.labels.t('squarePayment.label'));\n /** The payment details are required (a required wizard step): a visible heading with a red asterisk is shown above the form. Not shown in `mountOnly` mode. */\n readonly required = input(false);\n /** The `id` of the card container (an app's e2e selector). */\n readonly mountId = input('');\n readonly mountClass = input('');\n /** `data-testid` of the card container (default `square-card-form`, the id the mfh forms had). */\n readonly mountTestId = input('square-card-form');\n readonly errorTestId = input('square-error');\n readonly holderTestId = input('square-holder');\n /** Show failures in the built-in alert. Turn off when the host shows `(failed)` itself. */\n readonly showErrors = input(true);\n /** `'friendly'` (default) or `'square'` (Square's own message). See `getSquareErrorMessage`. */\n readonly errorDisplay = input<SquareErrorDisplay>('friendly');\n /** Replacement texts by code: Square error codes / types / card fields AND the library's own codes (`not_ready`, `holder_required`, `consent_required`, `cancelled`, `verification_failed`, ...). */\n readonly errorMessages = input<Record<string, string> | null>(null);\n /** The text when Square sends an error with no usable text. */\n readonly errorFallback = input('');\n readonly loadErrorMessageInput = input<string | null>(null, { alias: 'loadErrorMessage' });\n readonly loadErrorMessage = computed(() => this.loadErrorMessageInput() ?? this.labels.t('squarePayment.loadErrorMessage'));\n /** Texts of the screen-reader status region (translate them); missing keys keep the defaults. */\n readonly a11yMessages = input<Partial<SquareA11yMessages> | null>(null);\n\n // ── Outputs ────────────────────────────────────────────────────────────\n /**\n * The live Square objects, emitted once each time the form is created: right after the card form was attached (or the bank-account object created), before `(ready)`.\n * `null` is emitted when they go away (the form is re-created for new inputs, `reset()` or `destroyForm()`): drop your references. Destroying the component itself emits nothing\n * (the host owns that moment).\n */\n readonly squareReady = output<SquareReadyEvent | null>();\n /** The card form / bank authorization is ready. */\n readonly ready = output<void>();\n /** A step of an attempt started / ended (the synchronous lock). */\n readonly inFlightChange = output<boolean>();\n /** Unified outcome of a payment attempt: `succeeded`, `failed`, `unknown`, `refused` (with `reason`), `pending`. */\n readonly outcome = output<PaymentAttemptOutcome>();\n /** The attempt key in effect (also on `tokenized`): send it to your backend with the charge. */\n readonly attemptKeyChange = output<string>();\n /** The readiness gate changed: `{ ready, reasons }`. */\n readonly readinessChange = output<PaymentReadinessResult>();\n /** The customer's details were tokenized: send `token` to your backend. */\n readonly tokenized = output<SquareTokenizedEvent>();\n /** A step failed (validation, tokenization, buyer verification). `message` is ready to show. */\n readonly failed = output<SquareFailure>();\n /**\n * The payer edited the details: the card number / postal code changed or a field error cleared (the SDK's `cardBrandChanged` / `postalCodeChanged` / `errorClassRemoved`), or the bank form's holder name / authorization changed.\n * The built-in error alert clears itself at the same moment; a host that shows its own decline banner clears it here, so a stale \"card declined\" never stays next to details the payer is already correcting.\n * Not emitted for changes the form makes itself (building the form, a tab switch).\n */\n readonly detailsChange = output<void>();\n /** The SDK could not be loaded or the form could not be created. */\n readonly loadError = output<SquareFailure>();\n\n // ── State ──────────────────────────────────────────────────────────────\n readonly loading = signal(false);\n readonly isReady = signal(false);\n readonly submitting = signal(false);\n readonly errorText = signal('');\n readonly loadErrorText = signal('');\n protected readonly holder = signal('');\n protected readonly consent = signal(false);\n protected readonly attempted = signal(false);\n private readonly announcement = signal('');\n private readonly resetTick = signal(0);\n\n protected readonly errorId = `ui-square-error-${nextId++}`;\n private readonly mountRef = viewChild<ElementRef<HTMLElement>>('mount');\n\n protected readonly tabs = computed((): PillTab[] => {\n const methods = this.methods();\n if (!methods || methods.length < 2) return [];\n return methods.map(m => ({ key: m, label: this.labels.t(m === 'card' ? 'squarePayment.method.card' : 'squarePayment.method.ach') }));\n });\n protected readonly locked = computed(() => this.disabled() || this.submitting() || this.attempt.locked());\n protected readonly mountHidden = computed(() => !this.mountOnly() && (this.loading() || this.pending() || !!this.loadErrorText()));\n /** The card form is not usable while the form is disabled or a tokenization runs (not in `mountOnly`: there the host owns the interaction). */\n protected readonly mountLocked = computed(() => !this.mountOnly() && this.locked());\n protected readonly holderError = computed(() => (this.attempted() && !this.holder().trim() ? this.labels.t('squarePayment.holderRequired') : ''));\n protected readonly effectiveSubmitLabel = computed(() => {\n const given = this.submitLabel();\n if (given) return given;\n const setup = this.mode() === 'setup';\n return this.labels.t(this.method() === 'ach' ? (setup ? 'squarePayment.submit.saveBank' : 'squarePayment.submit.payBank') : (setup ? 'squarePayment.submit.saveCard' : 'squarePayment.submit.pay'));\n });\n protected readonly submitDisabled = computed(() => this.disabled() || this.loading() || this.pending() || !this.isReady() || !!this.loadErrorText() || this.attempt.locked() || !this.readiness.ready());\n private readonly messages = computed((): SquareA11yMessages => {\n const given = Object.fromEntries(Object.entries(this.a11yMessages() ?? {}).filter(([, text]) => typeof text === 'string')) as Partial<SquareA11yMessages>;\n return { ...SQUARE_A11Y_MESSAGES, ...given };\n });\n protected readonly statusText = computed(() => {\n if (this.loading()) return this.messages().loading;\n if (this.submitting()) return this.messages().processing;\n return this.announcement();\n });\n\n private readonly connection = computed((): SquareConnectionConfig => ({\n applicationId: this.applicationId() || this.defaults.applicationId || '',\n locationId: this.locationId() || this.defaults.locationId || '',\n environment: this.environment() ?? this.defaults.environment ?? 'sandbox',\n }), { equal: jsonEqual });\n\n /** The options of `payments.card()`: `cardOptions` merged over the style; `null` = call `card()` with no argument (the SDK default look). */\n private readonly cardConfig = computed((): Record<string, unknown> | null => {\n const hidden: SquareCardStyle | null = this.hideInlineMessages() ? { '.message-text': { display: 'none' }, '.message-icon': { display: 'none' } } : null;\n const style = hidden ? { ...(this.cardStyle() ?? {}), ...hidden } : this.cardStyle();\n const options = this.cardOptions();\n const own: Record<string, unknown> = {\n ...(this.includeInputLabels() ? { includeInputLabels: true } : {}),\n ...(this.postalCode() === false ? { postalCode: false } : this.postalCode() ? { postalCode: this.postalCode() } : {}),\n };\n if (!style && !options && !Object.keys(own).length) return null;\n return { ...own, ...(style ? { style } : {}), ...(options ?? {}) };\n }, { equal: structuralEqual });\n\n private payments: SquarePaymentsLike | null = null;\n private card: SquareCardLike | null = null;\n private ach: SquareAchLike | null = null;\n private generation = 0;\n private destroyed = false;\n /** `(squareReady)` emitted an object set that has not been withdrawn (`null`) yet. */\n private announced = false;\n\n /** The duplicate-payment protection of this form: the synchronous lock, the attempt key, the unknown state. Public so a host can read `attempt.key()` / `attempt.unknown()`. */\n readonly attempt: PaymentAttempt;\n /** The readiness gate: `readiness.ready()` / `readiness.reasons()`. */\n readonly readiness: PaymentReadiness;\n\n constructor() {\n const protection = createPaymentProtection(this, {\n amount: () => this.amount(),\n method: () => this.method(),\n sdk: () => (this.loadErrorText() ? 'blocked' : this.loading() ? 'loading' : 'ok'),\n offlineMidFlight: false, // this form only TOKENIZES: the token call answers or fails by itself, no charge is in flight here\n onOutcome: o => this.outcome.emit(o),\n onInFlightChange: v => this.inFlightChange.emit(v),\n onKeyChange: k => this.attemptKeyChange.emit(k),\n onReadinessChange: r => this.readinessChange.emit(r),\n });\n this.attempt = protection.attempt;\n this.readiness = protection.readiness;\n effect(() => {\n const method = this.method();\n const mount = method === 'card' ? this.mountRef() : null;\n const connection = this.connection();\n const card = this.cardConfig();\n const ach = { redirectUri: this.achRedirectUri(), transactionId: this.achTransactionId() };\n this.resetTick();\n this.styleFromTokens(); // the token style is read when the form is built: switching it on / off rebuilds the form\n if (method === 'card' && !mount) return;\n untracked(() => { void this.init(mount?.nativeElement ?? null, method, connection, card, ach); });\n });\n effect(() => { const name = this.accountHolderName(); untracked(() => this.holder.set(name)); });\n inject(DestroyRef).onDestroy(() => { this.destroyed = true; this.generation++; this.disposeInstances(); this.payments = null; });\n }\n\n // ── Public methods ─────────────────────────────────────────────────────\n\n /**\n * Tokenizes the entered card / bank account (the same as the built-in button). Resolves the event (also emitted as `tokenized`), or `null` after a failure (emitted\n * as `failed`) or when nothing was started (already running, disabled, not ready). Never rejects: anything the SDK throws becomes a `failed` event.\n *\n * ACH opens the bank window: call this method directly from the click handler (no `await` before it), or the browser blocks the window.\n */\n async tokenize(): Promise<SquareTokenizedEvent | null> {\n if (this.submitting() || this.disabled() || this.pending()) return null;\n if (this.refusedByProtection()) return null;\n const method = this.method();\n const card = this.card;\n const ach = this.ach;\n if (!this.isReady() || (method === 'card' ? !card : !ach)) { this.fail(squareFailure('not_ready', this.labels.t('squarePayment.msg.notReady'), 'tokenize')); return null; }\n this.attempted.set(true);\n const holder = this.holder().trim();\n if (method === 'ach') {\n if (!holder) { this.fail(squareFailure('holder_required', this.labels.t('squarePayment.holderRequired'), 'validate')); this.focusInput('holder'); return null; }\n if (this.requireAchConsent() && !this.mountOnly() && !this.consent()) { this.fail(squareFailure('consent_required', this.labels.t('squarePayment.consentRequired'), 'validate')); this.focusInput('consent'); return null; }\n }\n const generation = this.generation;\n const kind = this.mode();\n const begun = this.attempt.begin(); // SYNCHRONOUS lock: the same tick as the click, before any await\n if (!begun.ok) return null;\n const attemptKey = begun.key;\n const payableRef = this.attempt.pinnedRef();\n const amount = this.attempt.pinnedAmount(); // PINNED at begin: a fee re-estimate while the card is verified never changes what was asked for\n let handedToHost = false;\n this.submitting.set(true);\n this.errorText.set('');\n this.announcement.set('');\n try {\n const result = method === 'card' ? await card!.tokenize() : await ach!.tokenize({ accountHolderName: holder });\n if (this.destroyed || generation !== this.generation) return null;\n if (result.status !== 'OK' || !result.token) { this.fail(failureFromTokenResult(result, method, this.errorOptions())); return null; }\n let verificationToken: string | null = null;\n if (method === 'card' && this.shouldVerify(kind, amount)) {\n const verified = await this.verify(result.token, kind, amount);\n if (this.destroyed || generation !== this.generation) return null;\n if ('code' in verified) { this.fail(verified); return null; }\n verificationToken = verified.token;\n }\n const event: SquareTokenizedEvent = {\n token: result.token, method, kind, details: normalizeSquareDetails(result.details), verificationToken, idempotencyKey: newIdempotencyKey(), attemptKey, amount, payableRef,\n };\n this.announcement.set(this.messages().tokenized);\n // A PAYMENT keeps its lock after the token: the host charges now, and until it reports markSucceeded / markFailed / markUnknown / markNotCharged (or the status check decides) a second\n // tokenization or charge is refused. A saved card (mode 'setup') charges nothing, so it unlocks.\n if (kind === 'payment') { handedToHost = true; this.attempt.markPending('token'); }\n this.tokenized.emit(event);\n return event;\n } catch (err) {\n if (this.destroyed || generation !== this.generation) return null;\n this.fail({ ...squareFailure('tokenize_failed', this.errorFallback() || this.labels.t(method === 'ach' ? 'squarePayment.msg.achFailed' : 'squarePayment.msg.tokenizeFailed'), 'tokenize', messageOfThrown(err, '')) });\n return null;\n } finally {\n this.submitting.set(false);\n if (!handedToHost) this.attempt.release(); // the attempt ended before any charge request (validation, tokenization, verification): unlock, the key is kept\n }\n }\n\n /** The host reports that ITS charge call timed out or is ambiguous: the form shows \"Checking your payment...\" and stays locked (see `checkStatus`). */\n markUnknown(): void { this.attempt.markUnknown('host'); }\n\n /** The host reports that the charge succeeded: the form locks for this payable (a success does NOT move the epoch: the same key replays the original payment; the paid lock lasts 24 hours, see `resetPaid()`). */\n markSucceeded(): void { this.attempt.succeed('host'); }\n\n /** The host reports a DEFINITIVE failure of the charge (declined): the form unlocks with a NEW attempt key. */\n markFailed(): void { this.attempt.fail('host'); }\n\n /** The host did not use the token and nothing reached the processor (its call never left, the offline layer refused it): the form unlocks and the attempt key is KEPT. */\n markNotCharged(): void { this.attempt.markNotCharged(); }\n /** The host starts a deliberate SECOND payment of this payable (an explicit \"pay again\" flow): forgets the paid state this form saw, removes the succeeded record and moves the epoch so the next attempt has a NEW key. Does nothing against the host's own `paid` input. */\n resetPaid(): void { this.attempt.resetPaid(); }\n\n /** Builds the form again (clears the typed card; a token is single use, so call this after the host has used one). */\n reset(): void { this.resetTick.update(n => n + 1); }\n\n /** Removes the card form (host teardown). The component re-creates it when its inputs change. */\n destroyForm(): void { this.generation++; this.disposeInstances(); this.isReady.set(false); this.loading.set(false); }\n\n // ── Internals ──────────────────────────────────────────────────────────\n\n /** The gate before ANYTHING starts: a paid or unknown payable, offline, or a failed readiness check refuses (nothing is sent, the reason is reported). */\n private refusedByProtection(): boolean {\n if (!this.readiness.passSync()) {\n const reason = this.readiness.reasons()[0] ?? 'checking';\n this.outcome.emit({ kind: 'refused', attemptKey: this.attempt.key(), reason });\n this.fail(squareFailure(reason, this.labels.t(this.readiness.labelKeyFor(reason)), 'validate'));\n return true;\n }\n if (this.attempt.inFlight()) return true; // the host is charging the token of the earlier click: nothing may start (silent, like a double click)\n if (this.attempt.paidLocked() || this.attempt.unknown()) { this.attempt.begin(); return true; } // refuses and reports `refused`\n return false;\n }\n\n /** \"Retry loading\" of a blocked payment SDK: builds the form again (the loader asks Square's CDN again). */\n protected retryLoad(): void { this.reset(); }\n\n /** After a refused submit the focus goes to the bank field the message is about (the holder name or the authorization), once the view is up to date. */\n private focusInput(which: 'holder' | 'consent'): void {\n if (this.mountOnly()) return;\n const id = which === 'holder' ? this.holderTestId() : 'square-consent';\n afterNextRender(() => this.host.nativeElement.querySelector<HTMLElement>(`input[data-testid=\"${id}\"]`)?.focus(), { injector: this.injector });\n }\n\n private errorOptions(): SquareErrorMessageOptions {\n return { display: this.errorDisplay(), overrides: this.errorMessages(), ...(this.errorFallback() ? { fallback: this.errorFallback() } : {}) };\n }\n\n private shouldVerify(kind: SquareIntentKind, amount: number | null): boolean {\n const forced = this.verifyBuyer();\n if (forced !== null) return forced;\n return kind === 'payment' ? amount !== null && !!this.billingContact() : !!this.billingContact();\n }\n\n private async verify(token: string, kind: SquareIntentKind, amount: number | null): Promise<{ token: string } | SquareFailure> {\n const failure = (squareMessage = '') => squareFailure('verification_failed', this.labels.t('squarePayment.msg.verifyFailed'), 'verify', squareMessage);\n const verifyBuyer = this.payments?.verifyBuyer?.bind(this.payments);\n if (!verifyBuyer || (kind === 'payment' && amount === null)) return failure();\n const billing = this.billingContact();\n const details: SquareVerifyBuyerDetails = {\n intent: kind === 'setup' ? 'STORE' : 'CHARGE',\n ...(kind === 'payment' ? { amount: (Math.round((amount as number) * 100) / 100).toFixed(2), currencyCode: this.currency().toUpperCase() } : {}),\n ...(billing ? { billingContact: billing } : {}),\n customerInitiated: true,\n sellerKeyedIn: false,\n };\n try {\n const result = await verifyBuyer(token, details);\n return result?.token ? { token: result.token } : failure();\n } catch (err) {\n return failure(messageOfThrown(err, ''));\n }\n }\n\n private fail(f: SquareFailure): void {\n const override = this.errorMessages()?.[f.code];\n if (override) f = { ...f, message: override };\n if (this.destroyed) return;\n if (this.showErrors()) this.errorText.set(f.message);\n this.announcement.set('');\n this.failed.emit(f);\n }\n\n /** A `card()` / `ach()` that answers AFTER the form gave up on it (timeout, or the inputs changed): the late object is destroyed, never leaked. A rejection is ignored. */\n private discardLate(pending: Promise<{ destroy?(): Promise<void> | void }>): void {\n void pending.then(late => { try { void Promise.resolve(late.destroy?.()).catch(() => undefined); } catch { /* already gone */ } }, () => undefined);\n }\n\n private disposeInstances(): void {\n const card = this.card;\n const ach = this.ach;\n this.card = null;\n this.ach = null;\n if (this.announced) { this.announced = false; if (!this.destroyed) this.squareReady.emit(null); }\n for (const instance of [card, ach]) {\n if (!instance?.destroy) continue;\n try { void Promise.resolve(instance.destroy()).catch(() => undefined); } catch { /* the SDK may already have removed it */ }\n }\n }\n\n private loadFailed(code: string, message: string, squareMessage: string): void {\n this.loading.set(false);\n this.isReady.set(false);\n this.loadErrorText.set(this.loadErrorMessage());\n this.loadError.emit(squareFailure(code, message, 'load', squareMessage));\n }\n\n private async init(\n container: HTMLElement | null,\n method: SquareMethod,\n connection: SquareConnectionConfig,\n cardConfig: Record<string, unknown> | null,\n ach: { redirectUri: string | null; transactionId: string | null },\n ): Promise<void> {\n const generation = ++this.generation;\n this.disposeInstances();\n this.isReady.set(false);\n this.errorText.set('');\n this.loadErrorText.set('');\n this.announcement.set('');\n if (!this.isBrowser) { this.loading.set(false); return; }\n if (!connection.applicationId || !connection.locationId) { this.loadFailed('config_missing', this.labels.t('squarePayment.msg.configMissing'), ''); return; }\n this.loading.set(true);\n try {\n // No cache: every build of the form asks the loader again (the loader itself adds the SDK script once per page); the object is only this form's live handle.\n this.payments = null;\n const payments = await withSquareTimeout(this.loader(connection), () => new SquareLoadError('script_failed'));\n if (generation !== this.generation) return;\n this.payments = payments;\n const code = this.sdkLocaleCode();\n if (code && payments.setLocale) { try { await withSquareTimeout(Promise.resolve(payments.setLocale(code)), () => new Error('timeout')); } catch { /* an unsupported locale keeps the SDK default: never a load failure */ } if (generation !== this.generation) return; }\n } catch (err) {\n if (generation !== this.generation) return;\n this.loadFailed(err instanceof SquareLoadError ? err.code : 'load_error', this.labels.t('squarePayment.msg.loadFailed'), messageOfThrown(err, ''));\n return;\n }\n try {\n const payments = this.payments as SquarePaymentsLike;\n if (method === 'card') {\n // The token style is the base when no explicit style is given; `cardOptions` (and an explicit `cardStyle`) are spread over it, so options alone never switch `styleFromTokens` off.\n const tokenStyle = this.styleFromTokens() && cardConfig?.['style'] === undefined ? { style: readSquareCardStyle(this.doc, this.host.nativeElement) } : null;\n const options = tokenStyle || cardConfig ? { ...(tokenStyle ?? {}), ...(cardConfig ?? {}) } : null;\n const pendingCard = options ? payments.card(options) : payments.card();\n const card = await withSquareTimeout(pendingCard, () => new Error('timeout')).catch(err => { this.discardLate(pendingCard); throw err; });\n if (generation !== this.generation) { try { void Promise.resolve(card.destroy()).catch(() => undefined); } catch { /* gone */ } return; }\n this.card = card;\n for (const event of SQUARE_EDIT_EVENTS) card.addEventListener?.(event, () => { if (generation === this.generation && !this.submitting()) this.edited(); });\n try { await withSquareTimeout(card.attach(container as HTMLElement), () => new Error('timeout')); } catch (err) {\n if (generation !== this.generation) return;\n this.disposeInstances();\n this.loadFailed('mount_failed', this.labels.t('squarePayment.msg.cardFormFailed'), messageOfThrown(err, ''));\n return;\n }\n } else {\n const options: Record<string, unknown> = { ...(ach.redirectUri ? { redirectURI: ach.redirectUri } : {}), ...(ach.transactionId ? { transactionId: ach.transactionId } : {}) };\n const pendingAch = Object.keys(options).length ? payments.ach(options) : payments.ach();\n const instance = await withSquareTimeout(pendingAch, () => new Error('timeout')).catch(err => { this.discardLate(pendingAch); throw err; });\n if (generation !== this.generation) { try { void Promise.resolve(instance.destroy?.()).catch(() => undefined); } catch { /* gone */ } return; }\n this.ach = instance;\n }\n if (generation !== this.generation) return;\n this.loading.set(false);\n this.isReady.set(true);\n this.announced = true;\n this.squareReady.emit({ payments, card: this.card, ach: this.ach });\n this.ready.emit();\n } catch (err) {\n if (generation !== this.generation) return;\n this.disposeInstances();\n this.loadFailed('init_failed', this.labels.t(method === 'card' ? 'squarePayment.msg.cardFormFailed' : 'squarePayment.msg.achInitFailed'), messageOfThrown(err, ''));\n }\n }\n\n /** The payer edited something: clears the form's own error alert and tells the host. */\n protected edited(): void {\n if (this.errorText()) this.errorText.set('');\n this.detailsChange.emit();\n }\n\n /** The language the SDK should speak: the host's `sdkLocale`, else the app's active language. `null` = do not call `setLocale`. */\n private readonly sdkLocaleCode = computed((): string | null => {\n const given = this.sdkLocale();\n if (given === false) return null;\n if (given) return given;\n const language = (this.labels.locale() || '').toLowerCase().split('-')[0];\n return language === 'es' ? 'es-ES' : 'en-US';\n });\n\n protected onTab(key: string): void {\n if (this.submitting() || this.disabled() || this.attempt.locked() || (key !== 'card' && key !== 'ach')) return;\n this.method.set(key);\n this.errorText.set('');\n }\n}\n","import type { DestroyRef, WritableSignal } from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport type { Observable } from 'rxjs';\n\n/** The state of the seller's Square connection (the shape of contractor's `GET /integrations/square/status`, with the optional names a service may add). */\nexport interface SquareConnectStatus {\n connected: boolean;\n /** The integration is switched on for this account (informational). */\n enabled?: boolean;\n merchantId?: string | null;\n merchantName?: string | null;\n locationId?: string | null;\n locationName?: string | null;\n /** ISO date-time the connection was made. */\n connectedAt?: string | null;\n /** The access token was revoked or expired for good: the seller has to authorize again. */\n needsReconnect?: boolean;\n}\n\n/** What the start call answers: the address of Square's authorization page (`authUrl`, or `url`). */\nexport interface SquareConnectStart { authUrl?: string; url?: string }\n\n/**\n * What happened after the user pressed a button or the page asked for the state. The flow never shows toasts itself (each app has its own): the host words each outcome.\n *\n * - `connected`: the connection is live. `source: 'check'` = after \"Check Status\"; `'return'` = the state was read again when the user came back to this tab (`refreshOnReturn`).\n * - `needs-reconnect`: Square no longer accepts the saved authorization.\n * - `not-connected`: \"Check Status\" found no connection (the authorization was not finished).\n * - `disconnected`: the connection was removed.\n * - `link-unavailable`: the answer had no https Square address; nothing was opened.\n * - `failed`: a call failed (`action` says which); `error` is what it threw.\n */\nexport type SquareConnectOutcome =\n | { kind: 'connected'; source: 'check' | 'return' }\n | { kind: 'needs-reconnect'; source: 'check' | 'return' }\n | { kind: 'not-connected' }\n | { kind: 'disconnected' }\n | { kind: 'link-unavailable' }\n | { kind: 'failed'; action: 'start' | 'check' | 'disconnect'; error: unknown };\n\n/** The state the flow reads and writes: signals owned by the host (or by the card's two-way models). */\nexport interface SquareConnectState {\n status: WritableSignal<SquareConnectStatus | null>;\n loading: WritableSignal<boolean>;\n}\n\nexport interface SquareConnectFlowOptions {\n /** Read at call time, so a host can swap the call. Null = no call yet (`start()` does nothing). */\n start: () => (() => Observable<SquareConnectStart>) | null;\n getStatus: () => (() => Observable<SquareConnectStatus>) | null;\n disconnect: () => (() => Observable<unknown>) | null;\n state: SquareConnectState;\n /** Where outcomes go. */\n emit: (outcome: SquareConnectOutcome) => void;\n /** The buttons and methods do nothing while this says true (a read-only user). */\n disabled?: () => boolean;\n /** How THIS tab is sent to Square when the browser refused the new tab (default `window.location.href = url`). */\n navigate?: (url: string) => void;\n /** Called when Square's page was opened in a new tab (the card then offers \"Check Status\"). */\n onOpened?: () => void;\n destroyRef: DestroyRef;\n}\n\n/** Only an https address on Square's own domains (`squareup.com`, `squareupsandbox.com`, `square.com`, or a real subdomain): never `evilsquareup.com`, `http:` or `javascript:`. */\nexport function isSquareUrl(url: string | undefined | null): url is string {\n if (!url) return false;\n try {\n const u = new URL(url);\n return u.protocol === 'https:' && ['squareup.com', 'squareupsandbox.com', 'square.com'].some(d => u.hostname === d || u.hostname.endsWith(`.${d}`));\n } catch { return false; }\n}\n\n/**\n * The Square OAuth connection as a plain class: start (authorization page in a new tab), \"Check Status\", disconnect, and the \"back from Square\" read.\n * `ui-square-connect` runs it behind its card; a host that has to start the flow from code creates its own instance over the same state signals.\n * Square's page always opens in a NEW tab opened inside the click (a tab opened after the request is blocked by popup blockers); only an https Square address is\n * opened; a failed call closes the empty tab.\n */\nexport class SquareConnectFlow {\n /** A Square tab was opened: the card reads the state again when the user comes back (`refreshOnReturn`). */\n tabOpened = false;\n\n constructor(private readonly o: SquareConnectFlowOptions) {}\n\n private get blocked(): boolean { return this.o.state.loading() || !!this.o.disabled?.(); }\n\n /** Asks for the authorization address and opens Square's page in a new tab. */\n startConnect(): void {\n const start = this.o.start();\n if (!start || this.blocked) return;\n this.o.state.loading.set(true);\n const tab = this.openBlankTab();\n start().pipe(takeUntilDestroyed(this.o.destroyRef)).subscribe({\n next: result => {\n this.o.state.loading.set(false);\n this.openSquare(tab, result?.authUrl ?? result?.url);\n },\n error: error => {\n this.closeTab(tab);\n this.o.state.loading.set(false);\n this.o.emit({ kind: 'failed', action: 'start', error });\n },\n });\n }\n\n /** \"Check Status\": reads the state and reports it. */\n check(): void {\n const status = this.o.getStatus();\n if (!status || this.blocked) return;\n this.o.state.loading.set(true);\n status().pipe(takeUntilDestroyed(this.o.destroyRef)).subscribe({\n next: s => {\n this.o.state.status.set(s);\n this.o.state.loading.set(false);\n if (s.connected && s.needsReconnect) this.o.emit({ kind: 'needs-reconnect', source: 'check' });\n else if (s.connected) this.o.emit({ kind: 'connected', source: 'check' });\n else this.o.emit({ kind: 'not-connected' });\n },\n error: error => { this.o.state.loading.set(false); this.o.emit({ kind: 'failed', action: 'check', error }); },\n });\n }\n\n /** Removes the connection. The state becomes \"not connected\" only after the call succeeded. */\n disconnect(): void {\n const disconnect = this.o.disconnect();\n if (!disconnect || this.blocked) return;\n this.o.state.loading.set(true);\n disconnect().pipe(takeUntilDestroyed(this.o.destroyRef)).subscribe({\n next: () => {\n this.o.state.status.set({ connected: false });\n this.o.state.loading.set(false);\n this.o.emit({ kind: 'disconnected' });\n },\n error: error => { this.o.state.loading.set(false); this.o.emit({ kind: 'failed', action: 'disconnect', error }); },\n });\n }\n\n /** The state read when the user came back to this tab: silent unless a connection is live or needs to be redone. */\n readStatusOnReturn(): void {\n const status = this.o.getStatus();\n if (!status) return;\n status().pipe(takeUntilDestroyed(this.o.destroyRef)).subscribe({\n next: s => {\n this.o.state.status.set(s);\n if (s.connected && s.needsReconnect) this.o.emit({ kind: 'needs-reconnect', source: 'return' });\n else if (s.connected) this.o.emit({ kind: 'connected', source: 'return' });\n },\n error: () => { /* the user can press Check Status; a failed background read says nothing */ },\n });\n }\n\n private openSquare(tab: Window | null, url: string | undefined): void {\n // A blank tab the user already closed (before the answer arrived) cannot take the address: this tab is sent instead, like a refused tab.\n if (isSquareUrl(url) && tab && !tab.closed) {\n tab.location.href = url;\n this.tabOpened = true;\n this.o.onOpened?.();\n } else if (isSquareUrl(url)) {\n this.navigateCurrentTab(url);\n } else {\n // not an https Square address: never navigate to it, close the empty tab and say so\n this.closeTab(tab);\n this.o.emit({ kind: 'link-unavailable' });\n }\n }\n\n /** The empty tab, opened inside the click and cut from this page (`opener`); null when the browser refused. */\n openBlankTab(): Window | null {\n const tab = window.open('about:blank', '_blank');\n if (tab) { try { tab.opener = null; } catch { /* cannot be changed: harmless */ } }\n return tab;\n }\n\n /** The browser refused the new tab: Square opens in this one. */\n private navigateCurrentTab(url: string): void {\n if (this.o.navigate) this.o.navigate(url);\n else window.location.href = url;\n }\n\n private closeTab(tab: Window | null): void {\n try { tab?.close(); } catch { /* already closed */ }\n }\n}\n","import { NgTemplateOutlet } from '@angular/common';\nimport { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, Injector, ViewEncapsulation, afterNextRender, computed, effect, inject, input, model, output, signal } from '@angular/core';\nimport type { Observable } from 'rxjs';\nimport { SquareConnectFlow } from './square-connect.flow';\nimport type { SquareConnectOutcome, SquareConnectStart, SquareConnectStatus } from './square-connect.flow';\nexport type { SquareConnectOutcome, SquareConnectStart, SquareConnectStatus } from './square-connect.flow';\nexport { SquareConnectFlow, isSquareUrl } from './square-connect.flow';\nimport { BadgeComponent } from '@forgeroute/ui/badge';\nimport { ButtonComponent, ModalComponent, UiLabelsService, uiText } from '@forgeroute/ui/core';\nimport { DetailCardComponent } from '@forgeroute/ui/detail-card';\nimport { LiveRegionComponent } from '@forgeroute/ui/live-region';\nimport { StackComponent } from '@forgeroute/ui/stack';\nimport { TextComponent } from '@forgeroute/ui/text';\n\n/**\n * The default wording of an outcome, for apps that just want a toast: `{ variant, message }`, or null when nothing should be said.\n */\nexport function squareConnectNotice(outcome: SquareConnectOutcome): { variant: 'success' | 'info' | 'error'; message: string } | null {\n switch (outcome.kind) {\n case 'connected': return { variant: 'success', message: uiText('squareConnect.noticeConnected') };\n case 'needs-reconnect': return { variant: 'error', message: uiText('squareConnect.noticeReconnect') };\n case 'not-connected': return { variant: 'info', message: uiText('squareConnect.noticeNotConnected') };\n case 'disconnected': return { variant: 'success', message: uiText('squareConnect.noticeDisconnected') };\n case 'link-unavailable': return { variant: 'error', message: uiText('squareConnect.noticeLinkUnavailable') };\n case 'failed': return { variant: 'error', message: uiText(outcome.action === 'start' ? 'squareConnect.failedStart' : outcome.action === 'check' ? 'squareConnect.failedCheck' : 'squareConnect.failedDisconnect') };\n }\n}\n\nlet nextConnectId = 0;\n\n/**\n * \"Square account\": the card where a business connects the Square account it collects payments into (Square OAuth). The host owns the data (its three calls and the\n * status value); the component owns the screen and the flow:\n *\n * - not connected: \"Connect Square\" (opens Square's authorization page in a NEW tab, then offers \"Check Status\");\n * - connected: success with the merchant, the location and the date, \"Check Status\" and \"Disconnect\" (asks to confirm first);\n * - needs reconnect: warning with \"Reconnect\".\n *\n * The page opens in a NEW tab opened inside the click (a tab opened after the request is blocked by popup blockers) and receives the address when it arrives; with the\n * tab refused the address opens in the current tab. Only an https Square address is ever opened. A failed call closes the empty tab and is reported, never toasted.\n *\n * <ui-square-connect [(status)]=\"status\" [startConnect]=\"start\" [getStatus]=\"getStatus\" [disconnect]=\"disconnect\" [refreshOnReturn]=\"true\" (outcome)=\"onOutcome($event)\" />\n *\n * where `start = () => http.get<SquareConnectStart>('/integrations/square/connect')`, `getStatus = () => http.get<SquareConnectStatus>('/integrations/square/status')` and\n * `disconnect = () => http.delete('/integrations/square/disconnect')`.\n */\n@Component({\n selector: 'ui-square-connect',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [NgTemplateOutlet, BadgeComponent, ButtonComponent, DetailCardComponent, ModalComponent, LiveRegionComponent, StackComponent, TextComponent],\n template: `\n <!-- Persistent live region: present before the state changes, so every new state is announced (and \"Loading\" while a request runs). -->\n <ui-live-region data-testid=\"square-connect-live\" [message]=\"liveText()\" />\n @if (bare()) {\n <ng-container *ngTemplateOutlet=\"body\" />\n } @else {\n <ui-detail-card [collapsible]=\"false\" [title]=\"title()\" [headingLevel]=\"3\" data-testid=\"square-connect-card\">\n <ng-container *ngTemplateOutlet=\"body\" />\n </ui-detail-card>\n }\n\n <ng-template #body>\n @if (state() === 'none') {\n <ui-stack gap=\"sm\" class=\"sqc-state\" tabindex=\"-1\" data-testid=\"square-connect-status-none\" [attr.aria-busy]=\"loading() ? 'true' : null\">\n <ui-text size=\"lg\" weight=\"semibold\" [text]=\"startTitle()\" />\n <ui-text size=\"sm\" [text]=\"startText()\" />\n <ui-stack direction=\"horizontal\">\n <ui-button variant=\"primary\" size=\"sm\" data-testid=\"square-connect-start-button\" [disabled]=\"disabled()\" (click)=\"start()\">@if (loading()) {<span aria-hidden=\"true\">{{ labels.t('common.loadingellipsis') }}</span><span class=\"sqc-sr\">{{ labels.t('squareConnect.opensInNewTabBusy', { label: startLabel() }) }}</span>} @else { {{ startLabel() }}<span class=\"sqc-sr\">{{ labels.t('squareConnect.opensInNewTabSr') }}</span>}</ui-button>\n @if (awaiting()) {\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"square-connect-check-status-button\" [disabled]=\"disabled() || loading()\" (click)=\"check()\">{{ labels.t(loading() ? 'squareConnect.checking' : 'squareConnect.checkStatus') }}</ui-button>\n }\n </ui-stack>\n </ui-stack>\n } @else if (state() === 'reconnect') {\n <ui-stack gap=\"sm\" class=\"sqc-state\" tabindex=\"-1\" data-testid=\"square-connect-status-reconnect\" [attr.aria-busy]=\"loading() ? 'true' : null\">\n <span class=\"sqc-badge\"><ui-badge [label]=\"labels.t('squareConnect.needsReconnect')\" variant=\"red\" data-testid=\"square-connect-reconnect-badge\" /></span>\n <ui-text size=\"sm\" [text]=\"labels.t('squareConnect.reconnectText')\" />\n <ui-stack direction=\"horizontal\">\n <ui-button variant=\"primary\" size=\"sm\" data-testid=\"square-connect-reconnect-button\" [disabled]=\"disabled()\" (click)=\"start()\">@if (loading()) {<span aria-hidden=\"true\">{{ labels.t('common.loadingellipsis') }}</span><span class=\"sqc-sr\">{{ labels.t('squareConnect.opensInNewTabBusy', { label: labels.t('squareConnect.reconnect') }) }}</span>} @else { {{ labels.t('squareConnect.reconnect') }}<span class=\"sqc-sr\">{{ labels.t('squareConnect.opensInNewTabSr') }}</span>}</ui-button>\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"square-connect-disconnect-button\" [disabled]=\"disabled() || loading()\" (click)=\"askDisconnect()\">{{ labels.t('squareConnect.disconnect') }}</ui-button>\n </ui-stack>\n </ui-stack>\n } @else {\n <ui-stack gap=\"sm\" class=\"sqc-state\" tabindex=\"-1\" data-testid=\"square-connect-status-connected\" [attr.aria-busy]=\"loading() ? 'true' : null\">\n <ui-text size=\"lg\" weight=\"semibold\" [text]=\"labels.t('squareConnect.connected')\" />\n @if (merchant(); as merchant) { <ui-text size=\"sm\" tone=\"muted\" data-testid=\"square-connect-merchant\" [text]=\"labels.t('squareConnect.merchantLine', { merchant })\" /> }\n @if (location(); as location) { <ui-text size=\"sm\" tone=\"muted\" data-testid=\"square-connect-location\" [text]=\"labels.t('squareConnect.locationLine', { location })\" /> }\n @if (connectedOn(); as date) { <ui-text size=\"sm\" tone=\"muted\" data-testid=\"square-connect-date\" [text]=\"labels.t('squareConnect.connectedOn', { date })\" /> }\n <ui-stack direction=\"horizontal\">\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"square-connect-check-status-button\" [disabled]=\"disabled() || loading()\" (click)=\"check()\">{{ labels.t(loading() ? 'squareConnect.checking' : 'squareConnect.checkStatus') }}</ui-button>\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"square-connect-disconnect-button\" [disabled]=\"disabled() || loading()\" (click)=\"askDisconnect()\">{{ labels.t('squareConnect.disconnect') }}</ui-button>\n </ui-stack>\n </ui-stack>\n }\n </ng-template>\n\n <ui-modal [open]=\"confirming()\" [title]=\"labels.t('squareConnect.disconnectTitle')\" maxWidth=\"440px\" [describedBy]=\"confirmMessageId\" [busy]=\"loading()\" dialogTestId=\"square-connect-confirm\" (close)=\"cancelDisconnect()\">\n <p [id]=\"confirmMessageId\" class=\"sqc-confirm\" data-testid=\"square-connect-confirm-message\">{{ labels.t('squareConnect.disconnectMessage') }}</p>\n <ui-button modal-footer-left variant=\"secondary\" size=\"sm\" data-testid=\"square-connect-confirm-cancel\" [disabled]=\"loading()\" (click)=\"cancelDisconnect()\">{{ labels.t('common.cancel') }}</ui-button>\n <ui-button modal-footer-right variant=\"danger\" size=\"sm\" data-testid=\"square-connect-confirm-accept\" [loading]=\"loading()\" (click)=\"doDisconnect()\">{{ labels.t('squareConnect.disconnect') }}</ui-button>\n </ui-modal>\n `,\n styles: [`ui-square-connect { display: block; min-width: 0; } ui-square-connect .sqc-badge { display: flex; } ui-square-connect .sqc-confirm { margin: 0; font-size: 0.9375rem; line-height: 1.5; } ui-square-connect .sqc-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }`],\n encapsulation: ViewEncapsulation.None,\n})\nexport class SquareConnectComponent {\n /** Unique per instance: two connect cards on one page must not share the id the dialog's description points at. */\n protected readonly confirmMessageId = `sqc-disconnect-msg-${nextConnectId++}`;\n protected readonly labels = inject(UiLabelsService);\n private readonly destroyRef = inject(DestroyRef);\n private readonly injector = inject(Injector);\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /** The call that answers Square's authorization address (`{ authUrl }`). Needed for `start()`. */\n readonly startConnect = input<(() => Observable<SquareConnectStart>) | null>(null);\n /** The call that reads the connection's state. Needed for `check()` and `refreshOnReturn`. */\n readonly getStatus = input<(() => Observable<SquareConnectStatus>) | null>(null);\n /** The call that removes the connection. Needed for \"Disconnect\". */\n readonly disconnect = input<(() => Observable<unknown>) | null>(null);\n\n /** The connection state (null = not read yet = shown as not connected). Two-way: the component sets it after \"Check Status\" and \"Disconnect\". */\n readonly status = model<SquareConnectStatus | null>(null);\n\n readonly titleInput = input<string | null>(null, { alias: 'title' });\n readonly title = computed(() => this.titleInput() ?? this.labels.t('squareConnect.title'));\n /** No card around the content: the text and the buttons sit directly in the host's own card (a setup wizard step). `title` is not shown then. */\n readonly bare = input(false);\n readonly startTitleInput = input<string | null>(null, { alias: 'startTitle' });\n readonly startTitle = computed(() => this.startTitleInput() ?? this.labels.t('squareConnect.startTitle'));\n readonly startTextInput = input<string | null>(null, { alias: 'startText' });\n readonly startText = computed(() => this.startTextInput() ?? this.labels.t('squareConnect.startText'));\n readonly startLabelInput = input<string | null>(null, { alias: 'startLabel' });\n readonly startLabel = computed(() => this.startLabelInput() ?? this.labels.t('squareConnect.startLabel'));\n /** The buttons cannot be pressed (a read-only user). */\n readonly disabled = input(false);\n /** Ask before disconnecting (default true). */\n readonly confirmDisconnect = input(true);\n /** After a Square tab was opened, the state is read again when this tab becomes visible again (the user came back): `(outcome)` then reports `connected` / `needs-reconnect` with source `return`. */\n readonly refreshOnReturn = input(false);\n /** How the current tab is sent to Square when the browser refused the new tab (default: `window.location.href = url`). */\n readonly navigateTab = input<((url: string) => void) | null>(null);\n\n /** What happened (see {@link SquareConnectOutcome}); the host words it. */\n readonly outcome = output<SquareConnectOutcome>();\n\n /** A request is running: the buttons show \"Loading...\" / \"Checking...\" and cannot be pressed again. Two-way, so a host can read it. */\n readonly loading = model(false);\n\n protected readonly awaiting = signal(false);\n protected readonly confirming = signal(false);\n protected readonly state = computed((): 'none' | 'connected' | 'reconnect' => {\n const s = this.status();\n return !s?.connected ? 'none' : s.needsReconnect ? 'reconnect' : 'connected';\n });\n protected readonly merchant = computed(() => this.status()?.merchantName || this.status()?.merchantId || '');\n protected readonly location = computed(() => this.status()?.locationName || this.status()?.locationId || '');\n protected readonly connectedOn = computed(() => this.labels.formatDate(this.status()?.connectedAt ?? null, 'mediumDate'));\n /** What the persistent status region says: the current state, plus \"Loading.\" while a request runs. */\n protected readonly liveText = computed(() => {\n const text = this.labels.t(({ none: 'squareConnect.live.none', connected: 'squareConnect.live.connected', reconnect: 'squareConnect.live.reconnect' } as const)[this.state()]);\n return this.loading() ? this.labels.t('squareConnect.live.loading', { text }) : text;\n });\n /** The user pressed a button that started a request: when the screen then changes, focus moves to the new screen (the pressed button is gone). */\n private acted = false;\n private lastState = this.state();\n private readonly flow = new SquareConnectFlow({\n start: () => this.startConnect(),\n getStatus: () => this.getStatus(),\n disconnect: () => this.disconnect(),\n state: { status: this.status, loading: this.loading },\n emit: outcome => this.outcome.emit(outcome),\n disabled: () => this.disabled(),\n navigate: url => this.navigateCurrentTab(url),\n onOpened: () => this.awaiting.set(true),\n destroyRef: this.destroyRef,\n });\n\n constructor() {\n effect(() => {\n const state = this.state();\n if (this.loading()) return;\n const changed = state !== this.lastState;\n this.lastState = state;\n const focusIt = changed && this.acted;\n this.acted = false;\n if (state === 'connected') this.awaiting.set(false);\n if (focusIt) afterNextRender(() => this.host.nativeElement.querySelector<HTMLElement>('.sqc-state')?.focus(), { injector: this.injector });\n });\n if (typeof document !== 'undefined') {\n const onVisible = () => {\n if (document.visibilityState !== 'visible' || !this.flow.tabOpened || !this.refreshOnReturn() || this.loading()) return;\n this.flow.tabOpened = false;\n this.flow.readStatusOnReturn();\n };\n document.addEventListener('visibilitychange', onVisible);\n this.destroyRef.onDestroy(() => document.removeEventListener('visibilitychange', onVisible));\n }\n }\n\n /** Asks for the authorization address and opens Square's page in a new tab. */\n start(): void { const run = this.canRun(this.startConnect()); this.flow.startConnect(); this.acted ||= run; }\n\n /** \"Check Status\": reads the state; the card updates and the outcome is reported. */\n check(): void { const run = this.canRun(this.getStatus()); this.flow.check(); this.acted ||= run; }\n\n /** \"Disconnect\": asks for confirmation first (`confirmDisconnect`, default), then removes the connection. */\n askDisconnect(): void {\n if (this.disabled() || this.loading() || !this.disconnect()) return;\n if (this.confirmDisconnect()) this.confirming.set(true);\n else this.doDisconnect();\n }\n\n protected cancelDisconnect(): void { if (!this.loading()) this.confirming.set(false); }\n\n /** Removes the connection (what the confirm's button calls). */\n doDisconnect(): void {\n const run = this.canRun(this.disconnect());\n this.flow.disconnect();\n this.acted ||= run;\n this.confirming.set(false);\n }\n\n /** The flow will really send a request (the host gave the call, nothing is running, the card is not read-only). */\n private canRun(call: unknown): boolean { return !!call && !this.loading() && !this.disabled(); }\n\n /** The browser refused the new tab: Square opens in this one (through the host's `navigateTab` when it gave one). */\n protected navigateCurrentTab(url: string): void {\n const navigate = this.navigateTab();\n if (navigate) navigate(url);\n else window.location.href = url;\n }\n}\n","import type { HostResult, PaymentAllocation } from '@forgeroute/ui/payments';\nimport type { UiLabelKey } from '@forgeroute/ui/core';\nimport type { SquareFees } from '../payment-square-method/payment-square-method.models';\n\n/**\n * Card-reader (Square Terminal) types of the library. They mirror the answers of the payments service (`GET /v1/terminal/readiness`,\n * `GET /v1/terminal/readers/:id/ready`, the `terminal` object of a card-present payment; see forgeroute-payments `docs/API.md` section 16.3 and\n * `host-kit/contract/terminal-readiness.json`). The BROWSER never calls the service: every call below is a function the HOST supplies (it calls its own backend,\n * which calls the service), exactly like `ui-square-connect`.\n */\n\n/**\n * The ONE state of the reader setup, chosen by the service with this fixed precedence (first match wins). `checking` = the read was slow or failed (nothing is guessed). `unknown` is the OLD name of `checking`: it is still\n * ACCEPTED in an answer a host passes in (and read as `checking`), but the library never produces it: {@link normalizeReadiness} returns `checking`, no screen shows the word and no event carries it.\n */\nexport type SquareTerminalReadinessState = 'merchant_not_ready' | 'no_reader' | 'unsupported_only' | 'reader_ready' | 'reader_busy' | 'reader_pairing' | 'reader_offline' | 'checking' | 'unknown';\n\n/** The precedence of the service, first match wins (documentation and tests; the service already sends the winning state). */\nexport const SQUARE_TERMINAL_STATE_PRECEDENCE: readonly Exclude<SquareTerminalReadinessState, 'checking' | 'unknown'>[] = [\n 'merchant_not_ready', 'no_reader', 'unsupported_only', 'reader_ready', 'reader_busy', 'reader_pairing', 'reader_offline',\n];\n\nexport type SquareTerminalDeviceStatus = 'online' | 'offline' | 'registering';\n\n/** A reader as the service answers it (register / list / get / rename). */\nexport interface SquareTerminal {\n id: string;\n label?: string | null;\n status: SquareTerminalDeviceStatus | string;\n locationId?: string | null;\n deviceType?: string | null;\n serialNumber?: string | null;\n pairingCode?: string | null;\n action?: 'idle' | 'in_progress' | 'failed' | null;\n actionIntentId?: string | null;\n /** One of the supported smart readers (S700, S710, WisePOS E). Anything else cannot take a payment. */\n supported: boolean;\n /** Human model name, e.g. `Square Terminal`. */\n model?: string | null;\n /** A payment of this merchant waits on the reader, or the processor says it works on an action. */\n busy: boolean;\n /** Only names a payment of THIS merchant. */\n busyPaymentId?: string | null;\n}\n\n/** `GET /v1/terminal/readiness`. */\nexport interface SquareTerminalReadiness {\n state: SquareTerminalReadinessState;\n readers: SquareTerminal[];\n /** The single ready reader, else the most recently used ready reader, else null (the user picks). */\n defaultReaderId: string | null;\n checkedAt?: string;\n /** The processor read was slow or failed: nothing was guessed. */\n stale?: boolean;\n /**\n * Why the answer is what it is. With `merchant_not_ready`: `reconnect_required` (offers \"Reconnect payments\"), `sandbox`, `service_disabled` or `processor_unsupported` (see {@link SquareTerminalBannerReason}: the banner words these\n * with no button), anything else = payments are not set up yet (\"Set up payments\"). With `no_reader` / `unsupported_only`: the same three no-button reasons, otherwise the usual \"get a reader\" message.\n */\n reason?: SquareTerminalBannerReason | string;\n merchantStatus?: string;\n /** Why the processor read failed (`stale`): see {@link SquareTerminalTerminal.degradedReason}. */\n degradedReason?: SquareTerminalDegradedReason | string;\n}\n\n/** `GET /v1/terminal/readers/:id/ready` (the optional check right before a payment). */\nexport interface SquareTerminalReady {\n ready: boolean;\n reason: 'ok' | 'offline' | 'busy' | 'unsupported' | 'merchant_not_ready' | 'reconnect_required' | 'unknown' | string;\n reader?: SquareTerminal | null;\n checkedAt?: string;\n stale?: boolean;\n degradedReason?: SquareTerminalDegradedReason | string;\n}\n\n/**\n * Why the service could not read the processor (`terminal.degradedReason`): `processor_unreachable` / `processor_timeout` are transient (try again), `reconnect_required` (the processor refused our credentials) and\n * `processor_refused` (it refused the read) will NOT fix themselves: the payment account needs attention.\n */\nexport type SquareTerminalDegradedReason = 'processor_unreachable' | 'processor_timeout' | 'reconnect_required' | 'processor_refused';\n\n/**\n * `checking` = the processor could not be read in time (the stored payment is answered); `stale` is the same thing named after the `stale` flag. `unknown` is the OLD name: still ACCEPTED in the service's answer (read as\n * `checking`), never produced by the library; the screen words all three as \"still checking\" and never shows the word.\n */\nexport type SquareTerminalTerminalState = 'waiting' | 'declined' | 'failed' | 'succeeded' | 'canceled' | 'checking' | 'stale' | 'unknown';\n\n/** True for a terminal state that means \"the processor could not be read\": `checking`, `stale` and the old `unknown`. */\nexport function isTerminalChecking(state: SquareTerminalTerminalState | string | null | undefined): boolean {\n return state === 'checking' || state === 'stale' || state === 'unknown';\n}\n\n/**\n * The reasons a host may put in `SquareTerminalReadiness.reason` for the \"no usable reader\" banner. Each maps to its own plain message with NO action button:\n * - `sandbox`: the company is a sandbox account (\"Card readers are not available in a sandbox account.\"); apps map `merchant_not_ready` + this reason.\n * - `service_disabled`: the payments service is switched off (\"Card readers are turned off for this account.\").\n * - `processor_unsupported`: the company's processor can never use readers, e.g. QuickBooks (\"Card readers are not available with this payment processor.\").\n * Any other reason (including `reconnect_required`) or none keeps the usual messages and buttons. The table is `SQUARE_TERMINAL_BANNER_REASONS`.\n */\nexport type SquareTerminalBannerReason = 'sandbox' | 'service_disabled' | 'processor_unsupported';\n\n/** Reason -> label key of the no-button banner message. Exported for documentation and tests. */\nexport const SQUARE_TERMINAL_BANNER_REASONS: Readonly<Record<SquareTerminalBannerReason, UiLabelKey>> = {\n sandbox: 'stripeReaderBanner.sandbox',\n service_disabled: 'stripeReaderBanner.serviceDisabled',\n processor_unsupported: 'stripeReaderBanner.processorUnsupported',\n};\n\n/** The no-button label key for a readiness reason, or null when the reason has no special wording. */\nexport function readerBannerReasonKey(reason: string | null | undefined): UiLabelKey | null {\n return reason && Object.prototype.hasOwnProperty.call(SQUARE_TERMINAL_BANNER_REASONS, reason) ? SQUARE_TERMINAL_BANNER_REASONS[reason as SquareTerminalBannerReason] : null;\n}\n\n/** The `terminal` object of a card-present payment (also carried by a 409 `payment_in_flight`). */\nexport interface SquareTerminalTerminal {\n readerId: string;\n state: SquareTerminalTerminalState;\n declineCode?: string;\n message?: string;\n /** `false` with the state `waiting` = the reader dropped its connection while the payment waits. */\n readerOnline?: boolean;\n /** `unknown` + `stale`: the processor could not be read in time; the stored payment is answered. */\n stale?: boolean;\n checkedAt?: string;\n /** With `stale`: why the processor could not be read (transient or needs attention). */\n degradedReason?: SquareTerminalDegradedReason | string;\n /** From the 3rd consecutive stale read: how many stale reads in a row. */\n staleReads?: number;\n /** From the 3rd consecutive stale read: ISO time of the first stale read of the run (\"we cannot reach the processor since 10:42\"). */\n staleSince?: string;\n}\n\n/** What a card reader payment looks like (the service's payment view plus `terminal`). Only the fields the library reads are typed. */\nexport interface SquareTerminalPayment {\n id: string;\n status?: string;\n amountCents?: number;\n baseCents?: number;\n feeCents?: number;\n platformFeeCents?: number;\n brand?: string | null;\n last4?: string | null;\n attemptKey?: string;\n terminal?: SquareTerminalTerminal | null;\n /** `POST .../retry`: a second retry while the reader already waits is a replay. */\n replayed?: boolean;\n [key: string]: unknown;\n}\n\n/** What `startPayment` receives (the host maps it to `POST /v1/terminal/payments`). The amount is in major units. */\nexport interface SquareTerminalStartContext {\n readerId: string;\n /** The amount the customer owes before fees, major units (12.5 = $12.50). */\n amount: number;\n /** Stable per click and REUSED when the answer is lost; send it as the service's `attemptKey`. */\n attemptKey: string;\n payableRef: string | null;\n /** Always `'CARD_PRESENT'`. */\n paymentMethod: 'CARD_PRESENT';\n /**\n * The TOTAL in cents the payer saw (`Math.round(quote.totalAmount * 100)` of the CARD_PRESENT quote). Send it as the service's `expectedAmountCents`: a changed quote is refused with 409 `quote_changed` before the\n * reader is touched. Absent when the screen showed no quote.\n */\n expectedAmountCents?: number;\n /** Set only by the payment-panel integration: what the panel's other fields say. */\n receivedDate?: string;\n notes?: string | null;\n allocation?: PaymentAllocation;\n}\n\n/** What `estimateFees` receives for a reader payment. The quote is the CARD_PRESENT one and differs from the online card quote. */\nexport interface SquareTerminalFeeContext { amount: number; paymentMethod: 'CARD_PRESENT'; paymentMethodType: 'card_present' }\n\n/** `getPayment`: which payment to read. `paymentId` is known after the start answered; before that only the attempt key is. */\nexport interface SquareTerminalPaymentRef { paymentId: string | null; attemptKey: string }\n\nexport type SquareTerminalGetReadinessFn = () => HostResult<SquareTerminalReadiness>;\nexport type SquareTerminalStartFn = (ctx: SquareTerminalStartContext) => HostResult<SquareTerminalPayment>;\n/** Reads one payment with its `terminal` object. Answer `null` (or reject with 404) when no payment exists for the attempt key. */\nexport type SquareTerminalGetPaymentFn = (ref: SquareTerminalPaymentRef) => HostResult<SquareTerminalPayment | null>;\nexport type SquareTerminalRetryFn = (paymentId: string) => HostResult<SquareTerminalPayment>;\nexport type SquareTerminalCancelFn = (paymentId: string) => HostResult<unknown>;\nexport type SquareTerminalFeesFn = (ctx: SquareTerminalFeeContext) => HostResult<SquareFees>;\n\n/** The one bundle of host callbacks that turns card-reader mode on in `ui-square-payment-method` (`[reader]`). */\nexport interface SquareTerminalConfig {\n getReadiness: SquareTerminalGetReadinessFn;\n startPayment: SquareTerminalStartFn;\n getPayment: SquareTerminalGetPaymentFn;\n retryPayment: SquareTerminalRetryFn;\n cancelPayment: SquareTerminalCancelFn;\n /** The CARD_PRESENT fee quote. REQUIRED: a reader payment shows the breakdown (and sends `expectedAmountCents`) before the tap. */\n estimateFees: SquareTerminalFeesFn;\n /** The address of the receipt of a paid payment (host-built; only https or in-app `/paths` are linked). */\n receiptUrl?: (payment: SquareTerminalPayment) => string | null | undefined;\n /**\n * How often (ms) the waiting payment's status is read while the payer taps (default 2000). Clamped to {@link SQUARE_TERMINAL_POLL_MIN_MS}..{@link SQUARE_TERMINAL_POLL_MAX_MS}. The `[readerPollMs]` input of\n * `ui-square-payment-method`, when set, wins over this value.\n */\n pollMs?: number;\n}\n\n/** The fastest and the slowest status poll of a waiting reader payment (ms): a faster one would hammer the host's backend, a slower one would leave the payer staring at a stale screen. */\nexport const SQUARE_TERMINAL_POLL_MIN_MS = 500;\nexport const SQUARE_TERMINAL_POLL_MAX_MS = 30_000;\nconst SQUARE_TERMINAL_POLL_DEFAULT_MS = 2000;\n\n/** A poll cadence the library will actually use: not a finite number > 0 = the default (2000 ms); otherwise rounded and clamped to 500..30 000 ms. */\nexport function clampReaderPollMs(value: number | null | undefined): number {\n if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0) return SQUARE_TERMINAL_POLL_DEFAULT_MS;\n return Math.min(SQUARE_TERMINAL_POLL_MAX_MS, Math.max(SQUARE_TERMINAL_POLL_MIN_MS, Math.round(value)));\n}\n\n/** A refusal of `startPayment` / `retryPayment` the library words itself. */\nexport interface SquareTerminalRefusal {\n code: string;\n /** The service's own text, shown only for a code the library has no wording for. */\n message: string;\n paymentId: string | null;\n terminal: SquareTerminalTerminal | null;\n /** `reader_not_paired`: the pairing code the staff still has to enter on the Terminal, when the service sent it. */\n pairingCode?: string | null;\n /** `quote_changed`: the new total / fees in cents, as the service answered them. */\n amountCents?: number | null;\n feeCents?: number | null;\n platformFeeCents?: number | null;\n}\n\n/** Reads the flat `code`, status, `paymentId` and `terminal` of a failed host call (the error itself or its `error` body). */\nexport function readerErrorInfo(error: unknown): SquareTerminalRefusal & { status: number | null } {\n type Body = { code?: unknown; message?: unknown; paymentId?: unknown; pairingCode?: unknown; terminal?: unknown; amountCents?: unknown; feeCents?: unknown; platformFeeCents?: unknown };\n const e = error as (Body & { status?: unknown; response?: { status?: unknown } | null; error?: Body | null }) | null | undefined;\n const pick = <T>(guard: (v: unknown) => v is T, ...values: unknown[]): T | null => { for (const v of values) if (guard(v)) return v; return null; };\n const isString = (v: unknown): v is string => typeof v === 'string' && v.length > 0;\n const isCents = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v) && v >= 0;\n const isObject = (v: unknown): v is SquareTerminalTerminal => !!v && typeof v === 'object' && typeof (v as { state?: unknown }).state === 'string';\n const status = typeof e?.status === 'number' ? e.status : typeof e?.response?.status === 'number' ? e.response.status : null;\n const body = (e?.error && typeof e.error === 'object' ? e.error : null) as Body | null;\n // the quote_changed amounts are present only when the service sent them (a refusal without them has no such keys)\n const cents = (key: 'amountCents' | 'feeCents' | 'platformFeeCents'): Partial<Record<typeof key, number>> => { const v = pick(isCents, e?.[key], body?.[key]); return v === null ? {} : ({ [key]: v } as Partial<Record<typeof key, number>>); };\n return {\n code: (pick(isString, e?.code, body?.code) ?? '').toLowerCase(),\n message: pick(isString, body?.message, e?.message) ?? '',\n paymentId: pick(isString, e?.paymentId, body?.paymentId),\n terminal: pick(isObject, e?.terminal, body?.terminal),\n ...(safePairingCode(pick(isString, e?.pairingCode, body?.pairingCode)) ? { pairingCode: safePairingCode(pick(isString, e?.pairingCode, body?.pairingCode)) } : {}),\n ...cents('amountCents'), ...cents('feeCents'), ...cents('platformFeeCents'),\n status,\n };\n}\n\n/** A refusal without the HTTP status (the refusal the screen keeps is the same shape whatever the transport said). */\nexport function toRefusal(info: SquareTerminalRefusal & { status?: number | null }): SquareTerminalRefusal {\n const { status: _status, ...rest } = info;\n void _status;\n return rest;\n}\n\n/** What a payment was STARTED for (before fees, major units): `baseCents`, else the total minus the fees, else the total; `null` when the service gave no amount. Never 0 for a missing amount. */\nexport function paymentBaseAmount(payment: SquareTerminalPayment | null | undefined): number | null {\n if (!payment) return null;\n if (typeof payment.baseCents === 'number' && payment.baseCents > 0) return payment.baseCents / 100;\n if (typeof payment.amountCents === 'number' && payment.amountCents > 0) {\n const fees = (typeof payment.feeCents === 'number' ? payment.feeCents : 0) + (typeof payment.platformFeeCents === 'number' ? payment.platformFeeCents : 0);\n return Math.max(0, payment.amountCents - fees) / 100 || payment.amountCents / 100;\n }\n return null;\n}\n\n/** How the screen words a terminal the service could not read (`checking` / `stale`). */\nexport type SquareTerminalDegraded = { kind: 'transient' } | { kind: 'since'; since: string } | { kind: 'attention' };\n\n/**\n * `null` when the terminal was read normally. Otherwise: `attention` for a reason that will not fix itself (`reconnect_required`, `processor_refused`: \"the payment account needs attention\"), `since` from the 3rd\n * consecutive stale read (\"cannot reach the processor since 10:42\") and `transient` for the rest (`processor_unreachable`, `processor_timeout`, none given). Never a resubmit in any of them.\n */\nexport function readerDegraded(terminal: Pick<SquareTerminalTerminal, 'state' | 'stale' | 'degradedReason' | 'staleReads' | 'staleSince'> | null | undefined, locale?: string): SquareTerminalDegraded | null {\n if (!terminal || !(isTerminalChecking(terminal.state) || terminal.stale === true)) return null;\n if (terminal.degradedReason === 'reconnect_required' || terminal.degradedReason === 'processor_refused') return { kind: 'attention' };\n if (typeof terminal.staleReads === 'number' && terminal.staleReads >= 3 && terminal.staleSince) {\n const at = new Date(terminal.staleSince);\n if (!Number.isNaN(at.getTime())) {\n try { return { kind: 'since', since: new Intl.DateTimeFormat(locale, { hour: 'numeric', minute: '2-digit' }).format(at) }; } catch { /* fall through to transient */ }\n }\n }\n return { kind: 'transient' };\n}\n\n/** The TOTAL a payment charged (major units), from the service's `amountCents`; `null` when absent. */\nexport function paymentChargedAmount(payment: SquareTerminalPayment | null | undefined): number | null {\n return payment && typeof payment.amountCents === 'number' && payment.amountCents > 0 ? payment.amountCents / 100 : null;\n}\n\n/** The label key of the wording of a reader refusal code, or null for a code the library does not know (the service's message is shown). */\nexport function readerRefusalLabelKey(code: string): UiLabelKey | null {\n switch (code) {\n case 'reader_busy': return 'stripeReader.refusal.reader_busy';\n case 'reader_offline': return 'stripeReader.refusal.reader_offline';\n case 'reader_not_supported': return 'stripeReader.refusal.reader_not_supported';\n case 'reader_unreachable': return 'squareTerminal.refusal.reader_unreachable';\n // 400 on a start: the device code was registered but not entered on the Terminal yet (or it expired): nothing was created. `squareTerminal.refusal.reader_not_paired` carries the code when the answer had one.\n case 'reader_not_paired': return 'squareTerminal.refusal.reader_not_paired';\n case 'terminal_not_retryable': return 'stripeReader.refusal.terminal_not_retryable';\n case 'payment_in_flight': return 'stripeReader.refusal.payment_in_flight';\n case 'merchant_not_ready': return 'stripeReader.refusal.merchant_not_ready';\n case 'reconnect_required': return 'stripeReader.refusal.reconnect_required';\n case 'not_supported_by_processor': return 'stripeReader.refusal.not_supported_by_processor';\n case 'exceeds_amount_due': return 'stripeReader.refusal.exceeds_amount_due';\n case 'duplicate_suspected': return 'stripeReader.refusal.duplicate_suspected';\n case 'quote_changed': return 'stripeReader.refusal.quote_changed';\n case 'attempt_failed_use_new_key': return 'stripeReader.refusal.attempt_failed_use_new_key';\n case 'payment_being_sent': return 'stripeReader.refusal.payment_being_sent';\n // raised by the library itself (the attempt machine refused the click, a start / retry could not be settled, or the service answered 429)\n case 'paid': return 'stripeReader.refusal.paid';\n case 'offline': return 'stripeReader.refusal.offline';\n case 'outcome_checking':\n case 'outcome_unknown': return 'stripeReader.refusal.outcome_checking'; // `outcome_unknown` = the old code, still worded; the library raises `outcome_checking`\n case 'queued_offline': return 'stripeReader.refusal.queued_offline';\n case 'start_not_received': return 'stripeReader.refusal.start_not_received';\n case 'retry_unreachable': return 'stripeReader.refusal.retry_unreachable';\n case 'rate_limited': return 'stripeReader.refusal.rate_limited';\n default: return null;\n }\n}\n\n/** Codes that prove NOTHING was created or charged: the attempt is released (key kept) and the payer may start again. */\nexport const SQUARE_TERMINAL_NOT_CREATED_CODES: readonly string[] = [\n 'reader_busy', 'reader_offline', 'reader_not_supported', 'reader_not_paired', 'merchant_not_ready', 'reconnect_required', 'not_supported_by_processor', 'exceeds_amount_due', 'quote_changed',\n];\n\n/** The supported device: the Square Terminal (the service refuses anything else with 400 `reader_not_supported`). */\nexport const SQUARE_TERMINAL_MODELS: readonly { deviceType: string; model: string }[] = [\n { deviceType: 'square_terminal', model: 'Square Terminal' },\n];\n\nconst KNOWN_STATES: readonly SquareTerminalReadinessState[] = ['merchant_not_ready', 'no_reader', 'unsupported_only', 'reader_ready', 'reader_busy', 'reader_pairing', 'reader_offline', 'checking', 'unknown'];\n\n/** A defensive copy of an answer: an unrecognised state (or the old `unknown`) becomes `checking`, a missing list `[]` (nothing is ever guessed ready). The result's state is never `unknown`. */\nexport function normalizeReadiness(raw: unknown): SquareTerminalReadiness {\n const r = raw as Partial<SquareTerminalReadiness> | null | undefined;\n const readers = Array.isArray(r?.readers) ? r!.readers!.filter(x => !!x && typeof x.id === 'string') : [];\n let state = KNOWN_STATES.includes(r?.state as SquareTerminalReadinessState) ? (r!.state as SquareTerminalReadinessState) : 'checking';\n if (state === 'unknown') state = 'checking';\n // `reader_ready` with no reader that is supported, online and free can take no payment: nothing is guessed ready.\n if (state === 'reader_ready' && !readers.some(isReaderFree)) state = 'checking';\n return {\n state, readers, defaultReaderId: typeof r?.defaultReaderId === 'string' ? r.defaultReaderId : null,\n ...(r?.checkedAt ? { checkedAt: r.checkedAt } : {}), ...(r?.stale ? { stale: true } : {}), ...(r?.reason ? { reason: r.reason } : {}), ...(r?.merchantStatus ? { merchantStatus: r.merchantStatus } : {}),\n ...(r?.degradedReason ? { degradedReason: r.degradedReason } : {}),\n };\n}\n\n/**\n * \"10:42 AM\" of a moment, in the user's language (explicit locale, the user's own time zone). `''` for a missing / unreadable value. Library source 2026-11-21 (used by `ui-square-terminal-banner`: \"last confirmed at ...\").\n */\nexport function formatReaderTime(value: Date | string | number | null | undefined, locale?: string): string {\n if (value == null || value === '') return '';\n const at = value instanceof Date ? value : new Date(value);\n if (Number.isNaN(at.getTime())) return '';\n try { return new Intl.DateTimeFormat(locale, { hour: 'numeric', minute: '2-digit' }).format(at); } catch { return ''; }\n}\n\n/** The name a reader is shown under: its label, else its model, else its id. */\nexport function readerDisplayName(reader: Pick<SquareTerminal, 'id' | 'label' | 'model' | 'deviceType'> | null | undefined): string {\n if (!reader) return '';\n return reader.label?.trim() || reader.model?.trim() || SQUARE_TERMINAL_MODELS.find(m => m.deviceType === reader.deviceType)?.model || reader.id;\n}\n\n/** Can this reader take a payment right now (supported, online, free)? */\nexport function isReaderFree(reader: SquareTerminal): boolean { return reader.supported && reader.status === 'online' && !reader.busy; }\n\n/** Only an https address or an in-app `/path` is ever linked or opened (never `javascript:`, `data:`, `//host`). */\nexport function isSafeReceiptUrl(url: string | null | undefined): url is string {\n if (!url || /[\\u0000-\\u001f\\\\]/.test(url)) return false;\n if (url.startsWith('/') && !url.startsWith('//')) return true;\n try { return new URL(url).protocol === 'https:'; } catch { return false; }\n}\n\n/**\n * A device pairing code as it may be SHOWN: the code Square makes is a short run of letters and digits. The answer of the host is untrusted, so anything else (control characters, spaces, markup, a very long text) is not a code and\n * is never shown or announced: the screen then says to get a new code. Returns the trimmed code or `null`.\n */\nexport function safePairingCode(value: unknown): string | null {\n if (typeof value !== 'string') return null;\n const code = value.trim();\n return /^[A-Za-z0-9-]{3,32}$/.test(code) ? code : null;\n}\n\n/** `m:ss` of an elapsed time in ms (never negative). */\nexport function formatElapsed(ms: number): string {\n const total = Math.max(0, Math.floor((Number.isFinite(ms) ? ms : 0) / 1000));\n const m = Math.floor(total / 60);\n const s = total % 60;\n return `${m}:${s < 10 ? '0' : ''}${s}`;\n}\n\n// ── Square Terminal pairing ──\n\n/** What `registerTerminal` receives (the host maps it to `POST /v1/terminal/readers`: `label`, the Square `locationId`; Square ignores a registration code). */\nexport interface SquareTerminalRegisterContext { label: string; locationId?: string }\n\n/** What the host answers: the reader as the service returns it. Its `pairingCode` is the device code the staff enter on the Terminal (`null` once paired). */\nexport type SquareTerminalRegisterFn = (ctx: SquareTerminalRegisterContext) => HostResult<SquareTerminal>;\n\n/** True for a Square Terminal (`deviceType: 'square_terminal'`). */\nexport function isSquareTerminal(reader: Pick<SquareTerminal, 'deviceType'> | null | undefined): boolean { return reader?.deviceType === 'square_terminal'; }\n\n/** Dictionary keys of the card reader screens that read differently for a Square Terminal (looked up for keys built at run time: `stripeReader.status.<state>.title|text`, `stripeReader.wait.<phase>.text`). Any other key is the shared reader wording. */\nexport const SQUARE_TERMINAL_LABEL_KEYS: Readonly<Record<string, UiLabelKey>> = {\n 'stripeReader.status.no_reader.title': 'squareTerminal.status.no_reader.title',\n 'stripeReader.status.no_reader.text': 'squareTerminal.status.no_reader.text',\n 'stripeReader.status.unsupported_only.title': 'squareTerminal.status.unsupported_only.title',\n 'stripeReader.status.unsupported_only.text': 'squareTerminal.status.unsupported_only.text',\n 'stripeReader.status.reader_offline.title': 'squareTerminal.status.reader_offline.title',\n 'stripeReader.status.reader_offline.text': 'squareTerminal.status.reader_offline.text',\n 'stripeReader.status.reader_pairing.title': 'squareTerminal.status.reader_pairing.title',\n 'stripeReader.status.reader_pairing.text': 'squareTerminal.status.reader_pairing.text',\n 'stripeReader.wait.waiting.text': 'squareTerminal.wait.waiting.text',\n};\n\n/** The Square wording of a run-time built reader key, else the key itself. */\nexport function terminalLabelKey(key: UiLabelKey): UiLabelKey {\n return Object.prototype.hasOwnProperty.call(SQUARE_TERMINAL_LABEL_KEYS, key) ? SQUARE_TERMINAL_LABEL_KEYS[key] : key;\n}\n\n/**\n * What `ui-square-payment-method (readerLeftPending)` reports: the body went away (panel closed, method changed, plugin removed) or the reader screen was removed while a Terminal payment was open. The payment MAY STILL EXIST at the processor:\n * no `readerBusyChange(false)` is sent for it (the host keeps its other pay actions blocked and reads the server's own hold).\n */\nexport interface SquareTerminalLeftPending {\n reason: 'destroyed' | 'unmounted';\n /** The attempt key of the open Terminal payment, when known. */\n paymentAttemptKey?: string;\n}\n","import { computed, signal } from '@angular/core';\nimport { PAYMENT_REQUEST_TIMEOUT_MS, callHost, wasQueuedOffline, type HostResult } from '@forgeroute/ui/payments';\nimport {\n SQUARE_TERMINAL_NOT_CREATED_CODES, isTerminalChecking, paymentBaseAmount, readerErrorInfo, toRefusal,\n type SquareTerminalCancelFn, type SquareTerminalGetPaymentFn, type SquareTerminalPayment, type SquareTerminalRefusal, type SquareTerminalRetryFn,\n type SquareTerminalStartContext, type SquareTerminalStartFn, type SquareTerminalTerminal,\n} from './square-terminal.models';\n\n/**\n * Where a card reader payment is. One value, always:\n * - `idle`: nothing started (or an earlier payment ended: canceled / failed / refused);\n * - `starting`: the click was accepted and the payment is on its way to the service (the answer is not here yet);\n * - `recovering`: the answer of `starting` was lost (timeout, connection): the attempt key is looked up until the payment is found (or, after the grace period, the service still has none: then `recoveryExpired` is set and\n * the payer is asked to check again; only a second \"none\" answer, asked by the payer, releases the attempt). NEVER a second start;\n * - `waiting`: the reader waits for the customer to tap, insert or swipe;\n * - `declined`: the card was declined; the payment stays open (retry the SAME payment or cancel it);\n * - `stopped`: the reader stopped waiting without a decline; the payment stays open (retry or cancel);\n * - `retrying`: the same payment is being sent to the reader again;\n * - `cancelling`: a cancel is running (the payment is canceled ONLY when the service confirms);\n * - `succeeded`, `canceled`, `failed`: final.\n */\nexport type SquareTerminalPhase = 'idle' | 'starting' | 'recovering' | 'waiting' | 'declined' | 'stopped' | 'retrying' | 'cancelling' | 'succeeded' | 'canceled' | 'failed';\n\n/** What the flow needs of the payment-attempt machine (`PaymentAttempt` of `@forgeroute/ui/payments` fits it; specs use a fake). */\nexport interface SquareTerminalAttemptPort {\n begin(): { ok: true; key: string } | { ok: false; reason: 'locked' | 'paid' | 'unknown' | 'offline' };\n /** The key of the attempt in effect. */\n key(): string;\n /** The payment succeeded: locks the payable as paid. */\n succeed(reason?: string): void;\n /** A DEFINITIVE end without money (canceled, failed): unlocks with a NEW key. */\n fail(reason?: string): void;\n /** Nothing was created at the service: unlock, KEEP the key. */\n markNotCharged(): void;\n /** The answer of the start was lost: lock (key kept) until the payment is found. */\n markUnknown(reason: string): void;\n}\n\nexport type SquareTerminalFlowEvent =\n | { kind: 'started'; payment: SquareTerminalPayment; attemptKey: string }\n | { kind: 'declined'; payment: SquareTerminalPayment }\n | { kind: 'succeeded'; payment: SquareTerminalPayment; attemptKey: string }\n | { kind: 'canceled'; payment: SquareTerminalPayment | null }\n | { kind: 'failed'; payment: SquareTerminalPayment | null }\n | { kind: 'refused'; refusal: SquareTerminalRefusal }\n | { kind: 'connection-lost' }\n | { kind: 'connection-restored' };\n\nexport interface SquareTerminalFlowOptions {\n attempt: SquareTerminalAttemptPort;\n /** The calls are read at call time (a host may swap them); null = not provided (the action does nothing). */\n start: () => SquareTerminalStartFn | null;\n getPayment: () => SquareTerminalGetPaymentFn | null;\n retry: () => SquareTerminalRetryFn | null;\n cancel: () => SquareTerminalCancelFn | null;\n /** How often the open payment is read (default 2000 ms). */\n pollMs?: () => number;\n /** A poll slower than this counts as a lost connection (default 8000 ms). */\n pollTimeoutMs?: () => number;\n /** One start / retry / cancel call slower than this is treated as unreachable: a start becomes a lost answer (looked up by its attempt key, never re-sent), a retry / cancel leaves the payment as it was (default 60 000 ms). */\n requestTimeoutMs?: () => number;\n /** After a lost start answer (or an adopted attempt), \"no payment for this attempt key\" is believed only after this long, MEASURED FROM THE MOMENT RECOVERY STARTS (default 360 000 ms: the service may take up to 5 minutes to create the payment\n * of a request whose answer the browser gave up on, API.md 16.3, plus 1 minute of margin). */\n lostAnswerGraceMs?: () => number;\n now?: () => number;\n onEvent?: (event: SquareTerminalFlowEvent) => void;\n}\n\n/** What the screen passes to `start()`. */\nexport interface SquareTerminalStartInput {\n readerId: string;\n /** Major units. */\n amount: number;\n payableRef: string | null;\n /** The total in cents the payer saw (the CARD_PRESENT quote); sent as `expectedAmountCents`. */\n expectedAmountCents?: number;\n extras?: Pick<SquareTerminalStartContext, 'receivedDate' | 'notes' | 'allocation'>;\n}\n\nexport const SQUARE_TERMINAL_POLL_MS = 2000;\nexport const SQUARE_TERMINAL_POLL_TIMEOUT_MS = 8000;\n/** The service's create window (5 minutes) plus a minute of margin: \"no payment for this key\" earlier than this may only mean the payment is not created yet. */\nexport const SQUARE_TERMINAL_LOST_ANSWER_GRACE_MS = 6 * 60_000;\n/** A start / retry / cancel call that has not answered by then is unreachable (the library's request timeout). */\nexport const SQUARE_TERMINAL_REQUEST_TIMEOUT_MS = PAYMENT_REQUEST_TIMEOUT_MS;\n\n/** The service's definitive refusals of a start that prove nothing was created and that are NOT worded as \"not charged\" retries: the existing payment is shown. */\nconst DEFINITIVE_START_CODES: readonly string[] = ['duplicate_suspected'];\n\nconst OPEN: readonly SquareTerminalPhase[] = ['starting', 'recovering', 'waiting', 'declined', 'stopped', 'retrying', 'cancelling'];\nconst FINAL: readonly SquareTerminalPhase[] = ['succeeded', 'canceled', 'failed'];\n\n/**\n * The card reader payment flow as a plain class (no view): readiness is the screen's job, this starts ONE payment on a reader, follows it by polling the service through the host's calls, and lets the payer retry\n * (the SAME payment, never a new charge) or cancel it. `ui-square-terminal-payment` runs it; specs drive it with fake calls and a fake clock.\n *\n * Money rules it enforces:\n * - ONE payment at a time: `start()` is synchronous up to the attempt's `begin()` (a double click / second tab is refused) and every state in {@link OPEN} refuses another start;\n * - the attempt key is the one the attempt machine pinned at the click and is REUSED when the answer is lost (the service answers the same attempt key with the same payment, one intent, one reader action);\n * - a lost answer is never \"failed\": it is `recovering` (polling by attempt key) until the payment shows up, or the grace period has passed with the service still saying \"no payment for this key\";\n * - a cancel never claims success unless the service confirmed it (`reader_unreachable` leaves the payment open and says so);\n * - a poll that fails (connection lost) never changes the payment's state: it is reported and polling continues; the state shown on reconnect is the service's truth;\n * - the service's `terminal.state` `unknown` / `stale` is \"still checking\" (never an error, never a resubmit).\n */\nexport class SquareTerminalFlow {\n readonly phase = signal<SquareTerminalPhase>('idle');\n readonly payment = signal<SquareTerminalPayment | null>(null);\n readonly terminal = computed((): SquareTerminalTerminal | null => this.payment()?.terminal ?? null);\n /** The service could not read the processor (`terminal.state` `unknown` or `stale`): \"still checking\". */\n readonly checking = signal(false);\n /** The browser could not reach the host while a payment is open: the reader may still take the payment. */\n readonly connectionLost = signal(false);\n /** `recovering` only: the grace period is over and the service still has no payment for the attempt key. Polling stops; the payer is asked to \"Check again\" (`recheck()`), and only another \"none\" releases the attempt. */\n readonly recoveryExpired = signal(false);\n /** `recheck()` is running. */\n readonly rechecking = signal(false);\n /** The reader dropped its connection while the payment waits (`terminal.readerOnline === false`). */\n readonly readerOffline = signal(false);\n /** The last refusal of a start / retry (worded by the screen); cleared by the next start. */\n readonly refusal = signal<SquareTerminalRefusal | null>(null);\n /** A cancel could not be confirmed (the reader or the processor was unreachable): the payment is STILL open. */\n readonly cancelUnreachable = signal(false);\n /**\n * Square only: a cancel was REQUESTED while the payer was already paying on the Terminal (409 `reader_cancel_pending`, Square `CANCEL_REQUESTED`). The payment is STILL OPEN (the payer may still pay), the Terminal stays held and\n * nothing else may start: the screen says \"stopping the Terminal\", the payment is read until Square reports CANCELED (then `canceled`) or COMPLETED (then `succeeded`), and the payer may repeat the cancel. Never \"canceled\" on this alone.\n */\n readonly cancelPending = signal(false);\n readonly elapsedMs = signal(0);\n /** What the last start (or the adopted payment) is for, before fees (major units); `null` until known. */\n readonly baseAmount = computed((): number | null => paymentBaseAmount(this.payment()) ?? this.startInput()?.amount ?? null);\n /** The input of the last start (a signal, so the screen follows it). */\n readonly startInput = signal<SquareTerminalStartInput | null>(null);\n /** The attempt key of the payment being started / followed. */\n readonly attemptKey = signal<string | null>(null);\n /** No other payment may be started and the payer must not leave. */\n readonly locked = computed(() => OPEN.includes(this.phase()));\n /** A payment exists at the service and is not decided (cancel is possible). */\n readonly cancellable = computed(() => ['waiting', 'declined', 'stopped'].includes(this.phase()) && !!this.payment()?.id);\n readonly retryable = computed(() => ['declined', 'stopped'].includes(this.phase()) && !!this.payment()?.id);\n\n private disposed = false;\n private pollTimer: ReturnType<typeof setTimeout> | null = null;\n private tickTimer: ReturnType<typeof setInterval> | null = null;\n private pollGen = 0;\n private polling = false;\n private startedAt = 0;\n /** When recovery began (a lost start answer, or an adopted attempt): the grace is counted from here, never from the click. */\n private recoverStartedAt = 0;\n private explicitCheck = false;\n /** The payment id the service named in a 409 `request_in_progress` (the same attempt key is being created): used to read the payment while the answer of the start is lost. Never used to cancel. */\n private adoptedPaymentId: string | null = null;\n private cancelRun: Promise<boolean> | null = null;\n /** The phase to go back to when a retry or a cancel did not change anything. */\n private before: SquareTerminalPhase = 'waiting';\n\n constructor(private readonly o: SquareTerminalFlowOptions) {}\n\n private now(): number { return this.o.now ? this.o.now() : Date.now(); }\n private emit(event: SquareTerminalFlowEvent): void { if (!this.disposed) this.o.onEvent?.(event); }\n\n /** Starts ONE payment on a reader. Synchronous up to the attempt's `begin()`: a second click in the same tick is refused. */\n async start(input: SquareTerminalStartInput): Promise<void> {\n if (this.disposed || this.locked() || this.phase() === 'succeeded') return;\n const start = this.o.start();\n if (!start) return;\n const begun = this.o.attempt.begin();\n if (!begun.ok) {\n if (begun.reason !== 'locked') this.refuse({ code: begun.reason === 'unknown' ? 'outcome_checking' : begun.reason, message: '', paymentId: null, terminal: null });\n return;\n }\n this.phase.set('starting');\n this.startInput.set(input);\n this.attemptKey.set(begun.key);\n this.startedAt = this.now();\n this.elapsedMs.set(0);\n this.refusal.set(null);\n this.cancelUnreachable.set(false);\n this.cancelPending.set(false);\n this.connectionLost.set(false);\n this.checking.set(false);\n this.recoveryExpired.set(false);\n this.payment.set(null);\n this.adoptedPaymentId = null;\n this.startTick();\n const ctx: SquareTerminalStartContext = {\n readerId: input.readerId, amount: input.amount, attemptKey: begun.key, payableRef: input.payableRef, paymentMethod: 'CARD_PRESENT',\n ...(input.expectedAmountCents !== undefined && Number.isFinite(input.expectedAmountCents) && input.expectedAmountCents >= 1 ? { expectedAmountCents: Math.round(input.expectedAmountCents) } : {}),\n ...(input.extras ?? {}),\n };\n let answer: SquareTerminalPayment | null | undefined;\n try { answer = await this.call(() => start(ctx)); } catch (error) { this.onStartError(error); return; }\n if (this.disposed) return;\n if (wasQueuedOffline(answer)) {\n // The offline layer queued the request (a synthetic 202): nothing reached the service. Payments are never queued.\n this.o.attempt.markNotCharged();\n this.endNotCreated({ code: 'queued_offline', message: '', paymentId: null, terminal: null });\n return;\n }\n if (!answer || typeof answer.id !== 'string' || !answer.id) { this.lostAnswer(); return; }\n this.emit({ kind: 'started', payment: answer, attemptKey: begun.key });\n this.apply(answer);\n this.schedulePoll();\n }\n\n private onStartError(error: unknown): void {\n if (this.disposed) return;\n const info = readerErrorInfo(error);\n // The key can never complete (a failed payment superseded by a newer one, returned by the bank...): a DEFINITIVE end of this key, the attempt starts again with a NEW key. Never a lost answer.\n if (info.code === 'attempt_failed_use_new_key') {\n this.o.attempt.fail('replay');\n this.endNotCreated(toRefusal(info));\n return;\n }\n // The same attempt key is being created right now (`request_in_progress`, whatever the status): the payment may exist, so NEVER a second start and never idle. It is looked up by its attempt key (and by the payment id when the service names it).\n if (info.code === 'request_in_progress') {\n if (info.paymentId) this.adoptedPaymentId = info.paymentId;\n this.lostAnswer();\n return;\n }\n // Another payment of this reference holds the reader: when it IS a card reader payment (`terminal` is answered) it is followed, so staff can cancel / retry / watch the open payment instead of being stuck.\n if (info.code === 'payment_in_flight' && info.paymentId && info.terminal) {\n // The marker is KEPT (unknown) while the open payment is followed: a reload or a second tab must not find a free screen while a payment waits on the reader. It ends with the followed payment (succeeded / canceled / failed).\n this.o.attempt.markUnknown('payment_in_flight');\n this.follow({ id: info.paymentId, status: 'CREATED', terminal: info.terminal }, toRefusal(info));\n return;\n }\n // The reader holds another payment, or this reference has an open payment of another attempt (or a suspected duplicate): nothing was created by THIS click.\n if (info.code === 'payment_in_flight' || DEFINITIVE_START_CODES.includes(info.code) || SQUARE_TERMINAL_NOT_CREATED_CODES.includes(info.code)) {\n this.o.attempt.markNotCharged();\n this.endNotCreated(toRefusal(info));\n return;\n }\n // 429 (a risk block or a rate limit): the service creates NOTHING (API.md), so it is a definitive \"not created\". The same attempt key is idempotent at the service, so the payer may simply try again.\n if (info.status === 429) {\n this.o.attempt.markNotCharged();\n this.endNotCreated({ ...toRefusal(info), code: 'rate_limited' });\n return;\n }\n // A definitive refusal of the request itself (a 4xx the service answered, no code we know): nothing was created either. 408 (gateway timeout), 409 and 425 (too early) can follow a request the service already took: those are a lost answer.\n if (info.status !== null && info.status >= 400 && info.status < 500 && info.status !== 408 && info.status !== 409 && info.status !== 425) {\n this.o.attempt.markNotCharged();\n this.endNotCreated(toRefusal(info));\n return;\n }\n // Timeout, connection, 5xx, 408/409/425 without a known code: the payment may exist.\n this.lostAnswer();\n }\n\n /** Follows an open reader payment of another attempt (the service said so with `payment_in_flight` + `terminal`): the screen shows it like its own, with its refusal text above. */\n private follow(payment: SquareTerminalPayment, refusal: SquareTerminalRefusal): void {\n this.stopTick();\n this.startTick();\n this.payment.set(payment);\n this.phase.set('waiting');\n this.apply(payment);\n this.refuse(refusal);\n if (!FINAL.includes(this.phase())) this.schedulePoll();\n }\n\n /**\n * A reload or a second tab found an UNDECIDED attempt of this payable (the attempt machine is `unknown`): the payment may be waiting on a reader right now. The attempt key is looked up (never a new start)\n * until the payment shows up (then it is followed like any other) or, after the grace period, the service still has none.\n */\n adopt(): void {\n if (this.disposed || this.locked() || FINAL.includes(this.phase())) return;\n this.attemptKey.set(this.o.attempt.key());\n this.adoptedPaymentId = null;\n this.startedAt = this.now();\n this.recoverStartedAt = this.now();\n this.recoveryExpired.set(false);\n this.elapsedMs.set(0);\n this.refusal.set(null);\n this.startTick();\n this.phase.set('recovering');\n this.schedulePoll();\n }\n\n private endNotCreated(refusal: SquareTerminalRefusal): void {\n this.recoveryExpired.set(false);\n this.stopTick();\n this.stopPolling();\n this.phase.set('idle');\n this.refuse(refusal);\n }\n\n private refuse(refusal: SquareTerminalRefusal): void {\n this.refusal.set(refusal);\n this.emit({ kind: 'refused', refusal });\n }\n\n /** The answer of the start is lost: lock with the key kept and look the attempt key up until the payment shows up. */\n private lostAnswer(): void {\n this.o.attempt.markUnknown('timeout');\n this.recoverStartedAt = this.now();\n this.recoveryExpired.set(false);\n this.phase.set('recovering');\n this.schedulePoll();\n }\n\n // ── Polling ──────────────────────────────────────────────────────────────\n\n /** Reads the payment now (also after the browser says it is back online). */\n pollNow(): void {\n if (this.disposed || !this.shouldPoll()) return;\n this.stopPolling();\n void this.pollOnce(this.pollGen);\n }\n\n /** The browser reports offline / online. Offline only marks the loss; the next successful poll restores. */\n markConnection(online: boolean): void {\n if (this.disposed || !this.shouldPoll()) return;\n if (!online) this.setConnectionLost(true);\n else this.pollNow();\n }\n\n private shouldPoll(): boolean { return ['recovering', 'waiting', 'declined', 'stopped', 'retrying'].includes(this.phase()); }\n\n private schedulePoll(): void {\n this.stopPolling();\n if (this.disposed || !this.shouldPoll() || this.recoveryExpired()) return;\n const gen = this.pollGen;\n const every = Math.max(1, this.o.pollMs?.() ?? SQUARE_TERMINAL_POLL_MS);\n this.pollTimer = setTimeout(() => { this.pollTimer = null; void this.pollOnce(gen); }, every);\n }\n\n private stopPolling(): void {\n this.pollGen++;\n if (this.pollTimer) { clearTimeout(this.pollTimer); this.pollTimer = null; }\n }\n\n private async pollOnce(gen: number): Promise<void> {\n const read = this.o.getPayment();\n if (!read || this.polling || gen !== this.pollGen || !this.shouldPoll()) { if (gen === this.pollGen) this.schedulePoll(); return; }\n this.polling = true;\n const phaseAtStart = this.phase();\n const explicit = this.explicitCheck;\n let answer: SquareTerminalPayment | null | 'failed' = 'failed';\n let notFound = false;\n let timer: ReturnType<typeof setTimeout> | null = null;\n try {\n const timeout = new Promise<'timeout'>(resolve => { timer = setTimeout(() => resolve('timeout'), this.o.pollTimeoutMs?.() ?? SQUARE_TERMINAL_POLL_TIMEOUT_MS); });\n const result = await Promise.race([callHost(() => read({ paymentId: this.payment()?.id ?? this.adoptedPaymentId, attemptKey: this.attemptKey() ?? this.o.attempt.key() })), timeout]);\n if (result === 'timeout') answer = 'failed';\n else if (result && typeof result === 'object' && typeof result.id === 'string') answer = result;\n else { answer = null; notFound = true; }\n } catch (error) {\n const info = readerErrorInfo(error);\n if (info.status === 404 && !this.payment() && !this.adoptedPaymentId) { answer = null; notFound = true; } else answer = 'failed';\n } finally { if (timer) clearTimeout(timer); this.polling = false; }\n if (this.disposed || gen !== this.pollGen) return;\n if (answer === 'failed') {\n this.setConnectionLost(true);\n } else if (answer) {\n this.setConnectionLost(false);\n if (phaseAtStart === 'recovering' && this.phase() === 'recovering') this.emit({ kind: 'started', payment: answer, attemptKey: this.attemptKey() ?? '' });\n this.apply(answer);\n } else if (notFound) {\n this.setConnectionLost(false);\n if (this.phase() === 'recovering' && this.now() - this.recoverStartedAt >= Math.max(0, this.o.lostAnswerGraceMs?.() ?? SQUARE_TERMINAL_LOST_ANSWER_GRACE_MS)) {\n if (explicit && this.recoveryExpired()) {\n // The payer asked again AFTER the grace (longer than the service needs to create a payment) and the service still has none for this key: nothing was created. The marker is released (key kept: the service answers the same key with the same payment).\n this.o.attempt.markNotCharged();\n this.endNotCreated({ code: 'start_not_received', message: '', paymentId: null, terminal: null });\n return;\n }\n // The grace is over and the service still says \"none\": never claim \"nothing was charged\" on this alone. Polling stops, the marker stays, the payer is asked to check again.\n this.recoveryExpired.set(true);\n this.stopPolling();\n return;\n }\n }\n this.schedulePoll();\n }\n\n /**\n * \"Check again\" of an unconfirmed payment (`recoveryExpired`): reads the attempt key once more. Found: followed like any payment. Still none (the grace is over): the attempt is released and the payer may start again (the same key is\n * idempotent at the service). A failed read changes nothing (connection lost) and the payer can check again.\n */\n async recheck(): Promise<void> {\n if (this.disposed || this.phase() !== 'recovering' || !this.recoveryExpired() || this.polling || this.rechecking()) return;\n this.explicitCheck = true;\n this.rechecking.set(true);\n this.stopPolling();\n try { await this.pollOnce(this.pollGen); } finally { this.explicitCheck = false; this.rechecking.set(false); }\n }\n\n private setConnectionLost(lost: boolean): void {\n if (this.connectionLost() === lost) return;\n this.connectionLost.set(lost);\n this.emit({ kind: lost ? 'connection-lost' : 'connection-restored' });\n }\n\n // ── Applying what the service says ──────────────────────────────────────\n\n /** Applies a payment answer (a start / read / retry answer). Only an OPEN phase follows it: a late answer after a final state changes nothing. */\n private apply(payment: SquareTerminalPayment): void {\n if (this.disposed || FINAL.includes(this.phase())) return;\n this.payment.set(payment);\n const status = String(payment.status ?? '').toUpperCase();\n const t = payment.terminal ?? null;\n if (status === 'SUCCEEDED' || t?.state === 'succeeded') { this.settle('succeeded'); return; }\n if (status === 'CANCELED' || t?.state === 'canceled') { this.settle('canceled'); return; }\n if (status === 'FAILED') { this.settle('failed'); return; }\n this.recoveryExpired.set(false);\n this.checking.set(!!t && (isTerminalChecking(t.state) || t.stale === true));\n this.readerOffline.set(!!t && t.readerOnline === false);\n // While a cancel or a retry runs, a poll answer never moves the phase (a decline read meanwhile would show \"Try again\" while the retry request is still in flight); a final state (succeeded / canceled / failed) still settles above.\n const busyOp = this.phase() === 'cancelling' || this.phase() === 'retrying';\n if (t?.state === 'declined') { if (!busyOp) { const was = this.phase(); this.phase.set('declined'); if (was !== 'declined') this.emit({ kind: 'declined', payment }); } return; }\n if (t?.state === 'failed') { if (!busyOp) this.phase.set('stopped'); return; }\n // waiting, unknown (still checking) or no terminal object: the reader waits\n if (!busyOp) this.phase.set('waiting');\n }\n\n private settle(phase: 'succeeded' | 'canceled' | 'failed'): void {\n const payment = this.payment();\n this.stopPolling();\n this.stopTick();\n this.checking.set(false);\n this.connectionLost.set(false);\n this.readerOffline.set(false);\n this.cancelUnreachable.set(false);\n this.cancelPending.set(false);\n this.recoveryExpired.set(false);\n this.phase.set(phase);\n if (phase === 'succeeded') {\n const key = this.attemptKey() ?? this.o.attempt.key();\n this.o.attempt.succeed('reader');\n if (payment) this.emit({ kind: 'succeeded', payment, attemptKey: key });\n } else {\n this.o.attempt.fail(phase);\n this.emit({ kind: phase, payment });\n }\n }\n\n // ── Retry and cancel ────────────────────────────────────────────────────\n\n /** After a decline (or a stop): sends the SAME payment to the reader again. Never creates a payment. */\n async retry(): Promise<void> {\n const retry = this.o.retry();\n const id = this.payment()?.id;\n if (this.disposed || !retry || !id || !this.retryable()) return;\n this.before = this.phase();\n this.phase.set('retrying');\n this.refusal.set(null);\n this.stopPolling();\n try {\n const answer = await this.call(() => retry(id));\n if (this.disposed) return;\n if (answer && typeof answer.id === 'string') { this.phase.set(this.before); this.apply(answer); } else { this.phase.set(this.before); }\n this.schedulePoll();\n } catch (error) {\n if (this.disposed) return;\n const info = readerErrorInfo(error);\n this.phase.set(this.before);\n // The payment is not open any more (a tap or a cancel happened meanwhile): read it, show its real state.\n if (info.code === 'terminal_not_retryable') { this.refuse(toRefusal(info)); this.pollNow(); return; }\n this.refuse(toRefusal(info.code ? info : { ...info, code: 'retry_unreachable' }));\n this.schedulePoll();\n }\n }\n\n /**\n * Cancels the payment at the service. Resolves true only when the service confirmed the cancel (or already reports the payment canceled). While it runs the payment is `cancelling`; when the\n * service cannot reach the reader or the processor (503 `reader_unreachable`, a lost connection) the payment STAYS open, `cancelUnreachable` is set and the payer may cancel again.\n */\n cancel(): Promise<boolean> {\n if (this.cancelRun) return this.cancelRun;\n const cancel = this.o.cancel();\n const id = this.payment()?.id;\n if (this.disposed || !cancel || !id || !(this.cancellable() || (this.phase() === 'cancelling'))) return Promise.resolve(this.phase() === 'canceled');\n this.cancelRun = this.runCancel(cancel, id).finally(() => { this.cancelRun = null; });\n return this.cancelRun;\n }\n\n private async runCancel(cancel: SquareTerminalCancelFn, id: string): Promise<boolean> {\n this.before = this.phase() === 'cancelling' ? this.before : this.phase();\n this.phase.set('cancelling');\n this.cancelUnreachable.set(false);\n this.cancelPending.set(false);\n this.refusal.set(null);\n this.stopPolling();\n try {\n await this.call(() => cancel(id));\n if (this.disposed) return false;\n this.settle('canceled');\n return true;\n } catch (error) {\n if (this.disposed) return false;\n const info = readerErrorInfo(error);\n this.phase.set(this.before);\n if (info.code === 'payment_being_sent') {\n // The payment is still being sent to the reader: nothing could be canceled yet. Say so (\"wait a moment, then cancel again\"); the poll keeps following it. The service's instruction is `replay_attempt_key`, but a\n // second start is never sent from here: the payment is already known, and the poll (by attempt key) shows its real state. The id of the payment being cancelled is the one already known (a different id in the body is ignored).\n this.refuse(toRefusal(info));\n this.schedulePoll();\n return false;\n }\n if (info.code === 'reader_cancel_pending') {\n // Square CANCEL_REQUESTED: the cancel is not done and the payer may still pay. The payment stays open and the Terminal held (never released, never \"canceled\"); it is read until Square settles it.\n this.cancelPending.set(true);\n this.pollNow();\n return false;\n }\n if (info.status === 409 && info.code !== 'reader_unreachable') {\n // A tap that already happened (or races the cancel) is recorded as the payment: read the truth now.\n this.pollNow();\n return false;\n }\n this.cancelUnreachable.set(true);\n this.schedulePoll();\n return false;\n }\n }\n\n /** Runs one host call raced against the request timeout: a call that never answers cannot lock the flow forever. A late answer after the timeout is ignored (the next poll reads the truth). */\n private async call<T>(thunk: () => HostResult<T>): Promise<T> {\n let timer: ReturnType<typeof setTimeout> | null = null;\n try {\n const timeout = new Promise<never>((_, reject) => {\n timer = setTimeout(() => reject(Object.assign(new Error('request timeout'), { status: null, code: '' })), Math.max(1, this.o.requestTimeoutMs?.() ?? SQUARE_TERMINAL_REQUEST_TIMEOUT_MS));\n });\n return await Promise.race([callHost(thunk), timeout]);\n } finally { if (timer) clearTimeout(timer); }\n }\n\n /** From `canceled` / `failed`: back to a fresh start (a NEW key, the attempt machine already renewed it). */\n reset(): void {\n if (this.disposed || !(['canceled', 'failed'] as SquareTerminalPhase[]).includes(this.phase())) return;\n this.phase.set('idle');\n this.payment.set(null);\n this.refusal.set(null);\n this.attemptKey.set(null);\n this.elapsedMs.set(0);\n }\n\n /** The input of the last start (the screen re-sends it after \"Start again\"). */\n lastStartInput(): SquareTerminalStartInput | null { return this.startInput(); }\n\n // ── Elapsed time ────────────────────────────────────────────────────────\n\n private startTick(): void {\n this.stopTick();\n this.tickTimer = setInterval(() => this.elapsedMs.set(Math.max(0, this.now() - this.startedAt)), 1000);\n }\n\n private stopTick(): void {\n if (this.tickTimer) { clearInterval(this.tickTimer); this.tickTimer = null; }\n }\n\n /** The screen is gone: timers stop. Nothing is cancelled here (the screen decides; a payment that is open stays open at the service and is found again by its attempt key). */\n dispose(): void {\n this.disposed = true;\n this.stopPolling();\n this.stopTick();\n }\n}\n","import { ChangeDetectionStrategy, Component, ViewEncapsulation, computed, inject, input, output } from '@angular/core';\nimport { AlertComponent } from '@forgeroute/ui/alert';\nimport { ButtonComponent, UiLabelsService, type UiLabelKey } from '@forgeroute/ui/core';\nimport { LiveRegionComponent } from '@forgeroute/ui/live-region';\nimport { SkeletonComponent } from '@forgeroute/ui/skeleton';\nimport { readerDegraded, readerDisplayName, terminalLabelKey, type SquareTerminalReadiness, type SquareTerminalReadinessState } from './square-terminal.models';\n\n/**\n * The state the banner shows: the service's single readiness state, `loading` while a first read runs, `checking` when there is no usable answer (the read failed, was slow, or the service could not tell), and `attention` when the service says the payment account\n * needs attention. The component NEVER produces a state named `unknown` (the type keeps the member only because the readiness INPUT may carry it).\n */\nexport type SquareTerminalBannerState = SquareTerminalReadinessState | 'loading' | 'checking' | 'attention';\n\n/**\n * The ONE card-reader banner. It is rendered from the service's single readiness `state` (never from several flags), so a payment screen can never show two reader messages at once:\n *\n * - `merchant_not_ready`: payments are not set up (action: open payment setup); with the reason `reconnect_required` the payment account must be reconnected (\"Reconnect payments\", the same `openSetup` output: the host opens the place where the account is set up / reconnected);\n * - `no_reader` / `unsupported_only`: \"No Square Terminal set up\" with the ONE action \"How to get one\" (the host opens an info card);\n * - `reader_pairing` (Square Terminal only): a device code was created but not entered on the Terminal yet: \"Square Terminal waiting for its code\" with \"Connect Your Terminal\" (a new code) and \"Check again\";\n * - `reader_busy`: \"A payment is waiting on <reader>\" (+ \"Cancel that payment\" when the payment is this screen's own);\n * - `reader_offline`: \"Card reader not connected\" + \"Connect Your Terminal\" + \"Check again\";\n * - `checking`: there is no usable answer (the check failed, was too slow, or the service could not tell; nothing is guessed): \"Checking the card reader\" + \"Check again\"; when the service says WHY and it will not fix itself (`degradedReason` `reconnect_required` / `processor_refused`) the state is `attention`: the payment account needs attention (+ \"Reconnect payments\"). There is no state named `unknown`;\n * - `reader_ready`: no banner (a polite announcement only).\n *\n * The component has no HTTP: the host reads the readiness (see `ui-square-terminal-payment` / `ui-square-terminals`) and passes it in; the buttons are outputs.\n *\n * <ui-square-terminal-status [readiness]=\"readiness()\" [loading]=\"loading()\" (connectReader)=\"openPairing()\" (getReader)=\"openOrder()\" (recheck)=\"reload()\" />\n */\n@Component({\n selector: 'ui-square-terminal-status',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n imports: [AlertComponent, ButtonComponent, LiveRegionComponent, SkeletonComponent],\n template: `\n <ui-live-region data-testid=\"reader-status-live\" [message]=\"liveText()\" />\n @switch (state()) {\n @case ('loading') {\n <div class=\"srs-loading\" data-testid=\"reader-status-loading\" [attr.aria-busy]=\"'true'\">\n <ui-skeleton [height]=\"44\" [ariaLabel]=\"labels.t('stripeReader.status.loading')\" />\n </div>\n }\n @case ('reader_ready') { }\n @default {\n <ui-alert [variant]=\"variant()\" [title]=\"title()\" [quiet]=\"true\" class=\"srs-alert\" data-testid=\"reader-status\" [attr.data-state]=\"state()\">\n <p class=\"srs-text\" data-testid=\"reader-status-text\">{{ text() }}</p>\n <div class=\"srs-actions\">\n @if (state() === 'no_reader' || state() === 'unsupported_only') {\n <!-- no Terminal yet: the ONLY action is how to get one -->\n <ui-button variant=\"primary\" size=\"sm\" data-testid=\"reader-status-get\" (click)=\"getReader.emit()\">{{ labels.t('squareTerminal.status.getInfo') }}</ui-button>\n }\n @if (state() === 'merchant_not_ready' || attention()) {\n <ui-button variant=\"primary\" size=\"sm\" data-testid=\"reader-status-setup\" (click)=\"openSetup.emit()\">{{ labels.t(reconnect() || attention() ? 'stripeReader.status.reconnect' : 'stripeReader.status.setup') }}</ui-button>\n }\n @if ((state() === 'reader_pairing' || state() === 'reader_offline') && !hideConnect()) {\n <!-- a Terminal exists but is not connected (its code expired or was lost, or it is offline): connecting again gives a new code (the service answers the same code for a repeat inside 60 seconds) -->\n <ui-button variant=\"primary\" size=\"sm\" data-testid=\"reader-status-connect\" (click)=\"connectReader.emit()\">{{ labels.t('squareTerminal.status.connectYours') }}</ui-button>\n }\n @if (state() === 'reader_offline' || state() === 'reader_pairing' || state() === 'checking' || state() === 'attention') {\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"reader-status-recheck\" (click)=\"recheck.emit()\">{{ labels.t('stripeReader.status.recheck') }}</ui-button>\n }\n @if (state() === 'reader_busy') {\n @if (ownBusyPaymentId()) {\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"reader-status-cancel\" [loading]=\"cancelling()\" [disabled]=\"cancelling()\" (click)=\"cancelBusy.emit(ownBusyPaymentId()!)\">{{ labels.t('stripeReader.status.cancelBusy') }}</ui-button>\n }\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"reader-status-recheck\" (click)=\"recheck.emit()\">{{ labels.t('stripeReader.status.recheck') }}</ui-button>\n }\n @if (showManual()) {\n <ui-button variant=\"ghost\" size=\"sm\" data-testid=\"reader-status-manual\" (click)=\"manual.emit()\">{{ labels.t('stripeReader.status.manual') }}</ui-button>\n }\n </div>\n </ui-alert>\n }\n }\n `,\n styles: [`\n ui-square-terminal-status { display: block; min-width: 0; }\n ui-square-terminal-status .srs-text { margin: 0 0 8px; }\n ui-square-terminal-status .srs-actions { display: flex; flex-wrap: wrap; gap: 8px; }\n `],\n})\nexport class SquareTerminalStatusComponent {\n protected readonly labels = inject(UiLabelsService);\n\n /** The service's last readiness answer (`null` = none yet or the read failed). */\n readonly readiness = input<SquareTerminalReadiness | null>(null);\n /** A read is running and there is no answer to show yet: a skeleton. */\n readonly loading = input(false);\n /** The id of a payment THIS screen started and that holds the reader: the banner then offers \"Cancel that payment\". */\n readonly ownBusyPaymentId = input<string | null>(null);\n /** That cancel is running. */\n readonly cancelling = input(false);\n /** Adds \"Take a manual payment instead\" (a payment screen that has a manual path). */\n readonly showManual = input(false);\n /** Hides \"Connect Your Terminal\" (the pairing screen itself shows the banner). */\n readonly hideConnect = input(false);\n /**\n * Kept for backward compatibility: Square sells no Terminal in the app, so the no-Terminal action is always \"How to get one\" (`getReader`, the host opens an info card) and this input changes nothing.\n */\n readonly hardwareShopAvailable = input(true);\n\n /** \"Connect Your Terminal\" (`reader_pairing`, `reader_offline`): the host opens its pairing panel (`ui-square-terminals`). */\n readonly connectReader = output<void>();\n /** \"Get a card reader\": the host opens its order flow. */\n readonly getReader = output<void>();\n /** \"Check again\". */\n readonly recheck = output<void>();\n /** \"Set up payments\": the host opens payment setup. */\n readonly openSetup = output<void>();\n /** \"Cancel that payment\" (the payment id). */\n readonly cancelBusy = output<string>();\n /** \"Take a manual payment instead\". */\n readonly manual = output<void>();\n\n /** Which banner: no answer and loading = `loading`; no answer and not loading = `checking`; a service `checking` (old name `unknown`) = `attention` (reason that will not fix itself) or `checking`; else the service's state. Never `unknown`. */\n readonly state = computed((): SquareTerminalBannerState => {\n const r = this.readiness();\n if (!r) return this.loading() ? 'loading' : 'checking';\n if (r.state === 'checking' || r.state === 'unknown') return readerDegraded({ state: 'checking', stale: true, degradedReason: r.degradedReason })?.kind === 'attention' ? 'attention' : 'checking'; // `unknown` = the old name, accepted\n return r.state;\n });\n\n protected readonly variant = computed(() => (this.state() === 'no_reader' || this.state() === 'unsupported_only' || this.state() === 'reader_busy' ? 'info' : 'warning'));\n\n private readonly busyName = computed(() => {\n const r = this.readiness();\n const reader = r?.readers.find(x => x.busy) ?? r?.readers.find(x => x.id === r.defaultReaderId) ?? null;\n return reader ? readerDisplayName(reader) : this.labels.t('squareTerminal.theReader');\n });\n\n /** `merchant_not_ready` because the payment account must be reconnected (the service's `reason`). Any other merchant status (onboarding, disconnected...) is \"not set up\". */\n protected readonly reconnect = computed(() => this.state() === 'merchant_not_ready' && this.readiness()?.reason === 'reconnect_required');\n /** The service could not read the processor for a reason that will not fix itself (`reconnect_required`, `processor_refused`): the account needs attention. Transient reasons (and none) stay \"checking, check again\". */\n protected readonly attention = computed(() => this.state() === 'attention');\n /** The label group of the banner: the state, or a more exact one for a reconnect / attention case. */\n private readonly textKey = computed(() => (this.reconnect() ? 'reconnect_required' : this.attention() ? 'stale_attention' : this.state()));\n\n protected readonly title = computed(() => this.labels.t(terminalLabelKey(`stripeReader.status.${this.textKey()}.title` as UiLabelKey)));\n protected readonly text = computed(() => this.labels.t(terminalLabelKey(`stripeReader.status.${this.textKey()}.text` as UiLabelKey), { reader: this.busyName() }));\n\n /** What the polite region says: the banner's title (a change of state is announced), \"ready\" for a ready reader, nothing while loading. */\n protected readonly liveText = computed(() => {\n const state = this.state();\n if (state === 'loading') return '';\n if (state === 'reader_ready') {\n const r = this.readiness();\n const reader = r?.readers.find(x => x.id === r.defaultReaderId) ?? r?.readers.find(x => x.supported && x.status === 'online' && !x.busy);\n return this.labels.t('stripeReader.status.reader_ready.live', { reader: reader ? readerDisplayName(reader) : this.labels.t('squareTerminal.theReader') });\n }\n return `${this.title()}. ${this.text()}`;\n });\n}\n","import { NgTemplateOutlet } from '@angular/common';\nimport { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, Injector, ViewEncapsulation, afterNextRender, computed, effect, inject, input, isDevMode, output, signal, untracked } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { AlertComponent } from '@forgeroute/ui/alert';\nimport { ButtonComponent, UiLabelsService, type UiLabelKey } from '@forgeroute/ui/core';\nimport { IconComponent } from '@forgeroute/ui/icon';\nimport { LiveRegionComponent } from '@forgeroute/ui/live-region';\nimport { SelectComponent } from '@forgeroute/ui/select';\nimport { SkeletonComponent } from '@forgeroute/ui/skeleton';\nimport { PAYMENT_ATTEMPT_STORAGE, PaymentAttempt, builtInReadinessReasons, callHost, type PaymentAllocation } from '@forgeroute/ui/payments';\nimport { formatCurrency } from '@forgeroute/ui/utils';\nimport type { SquareFees } from '../payment-square-method/payment-square-method.models';\nimport { SQUARE_TERMINAL_LOST_ANSWER_GRACE_MS, SQUARE_TERMINAL_REQUEST_TIMEOUT_MS, SquareTerminalFlow, type SquareTerminalFlowEvent } from './square-terminal.flow';\nimport { SquareTerminalStatusComponent } from './square-terminal-status.component';\nimport {\n clampReaderPollMs, formatElapsed, isReaderFree, isSafeReceiptUrl, normalizeReadiness, paymentChargedAmount, readerDegraded, readerDisplayName, readerErrorInfo, readerRefusalLabelKey, terminalLabelKey,\n type SquareTerminalCancelFn, type SquareTerminalFeesFn, type SquareTerminalGetPaymentFn, type SquareTerminalGetReadinessFn, type SquareTerminalPayment, type SquareTerminalReadiness,\n type SquareTerminalReadinessState, type SquareTerminalRetryFn, type SquareTerminalStartFn,\n} from './square-terminal.models';\n\n/** The readiness states the panel's top banner speaks for: no usable Terminal, or a Terminal that is not connected (offline / waiting for its pairing code). */\nconst SQUARE_TERMINAL_NO_READER_STATES: readonly SquareTerminalReadinessState[] = ['no_reader', 'unsupported_only', 'merchant_not_ready', 'reader_offline', 'reader_pairing'];\n\n/** What `(succeeded)` reports. */\nexport interface SquareTerminalSucceededEvent {\n payment: SquareTerminalPayment;\n attemptKey: string;\n /** The amount the payment was STARTED with (major units, before fees). */\n amount: number;\n readerId: string;\n}\n\n/** What `(outcome)` reports, for a host that wants to word a toast or log (the component never toasts). */\nexport type SquareTerminalOutcome =\n | { kind: 'started'; payment: SquareTerminalPayment }\n | { kind: 'declined'; payment: SquareTerminalPayment }\n | { kind: 'canceled' }\n | { kind: 'failed' }\n | { kind: 'refused'; code: string }\n | { kind: 'connection-lost' }\n | { kind: 'connection-restored' }\n /** The panel was closed while the answer of the start was still on its way / lost: the payment is looked up again when the screen opens. The host may word it (\"We are still confirming your payment\"). */\n | { kind: 'left-pending' };\n\n/**\n * Takes a card payment on a Square Terminal: the card reader flow of the payment screen. The HOST owns the calls (it calls its own backend, which calls the\n * payments service; the browser never talks to the service), the component owns the screen and the flow ({@link SquareTerminalFlow}):\n *\n * 1. it reads the readiness (ONE state, see `ui-square-terminal-status`) now and every `readinessEveryMs`, and shows the ONE banner when the reader cannot be used;\n * 2. with `reader_ready` it shows the reader, the amount and the card-reader FEE quote (`estimateFees`, method CARD_PRESENT: cleared at once when the amount changes, \"Send to the reader\"\n * stays off until the quote for the current amount is here), and \"Send to the Terminal\" (a card taken on a Square Terminal is never kept: there is no \"Save this card\");\n * 3. while a payment waits: \"Waiting for the customer to tap, insert or swipe their card on <reader>\", the amount, the fees, the elapsed time and ONLY \"Cancel payment\";\n * 4. a decline shows \"Card declined\" with \"Try again\" (the SAME payment) / \"Cancel payment\" / \"Take a manual payment instead\" (a Square Terminal declines ON the device, so this state is rare); a cancel that Square only REQUESTED (`reader_cancel_pending`) keeps the payment open with \"stopping the Terminal\"; a success shows the receipt link.\n *\n * Nothing else can start a payment while one is open (every start button is off, a double click and a second tab are refused by the attempt machine), the attempt key is stable per click and\n * REUSED when the answer is lost, and a lost connection never changes the state shown: the payment is read again by its attempt key when the connection is back. Offline / slow connections\n * block \"Send to the reader\" before it starts (payments are never queued). A manual payment is always one click away (`(manual)`).\n *\n * <ui-square-terminal-payment [amount]=\"amount()\" payableRef=\"unit:42\" [getReadiness]=\"readiness\" [startPayment]=\"start\" [getPayment]=\"read\" [retryPayment]=\"retry\" [cancelPayment]=\"cancel\"\n * [estimateFees]=\"fees\" (manual)=\"useManual()\" (connectReader)=\"openPairing()\" (getReader)=\"openOrder()\" (succeeded)=\"onPaid($event)\" />\n */\n@Component({\n selector: 'ui-square-terminal-payment',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n imports: [FormsModule, NgTemplateOutlet, AlertComponent, ButtonComponent, IconComponent, LiveRegionComponent, SelectComponent, SkeletonComponent, SquareTerminalStatusComponent],\n template: `\n <ui-live-region data-testid=\"reader-live\" [message]=\"announcement()\" />\n @if (blockReason(); as reason) {\n @if (showBlocked()) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-blocked\" [attr.data-reason]=\"reason\">{{ blockText() }}</ui-alert>\n }\n } @else if (showReadiness()) {\n <ui-square-terminal-status [readiness]=\"shownReadiness()\" [loading]=\"readinessLoading() && !readiness()\" [ownBusyPaymentId]=\"busyOwnPaymentId()\" [cancelling]=\"cancellingBusy()\"\n [hideConnect]=\"false\"\n (connectReader)=\"connectReader.emit()\" (getReader)=\"getReader.emit()\" (recheck)=\"loadReadiness()\" (openSetup)=\"openSetup.emit()\" (cancelBusy)=\"cancelBusy($event)\" />\n }\n\n @if (active()) {\n @if (closeBlocked() && flow.locked()) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-close-blocked\">{{ labels.t('stripeReader.closeBlocked') }}</ui-alert>\n }\n\n @switch (flow.phase()) {\n @case ('starting') {\n <section class=\"srp-box srp-focus\" data-testid=\"reader-starting\" tabindex=\"-1\" [attr.aria-busy]=\"'true'\">\n <ui-skeleton [height]=\"44\" [ariaLabel]=\"labels.t('squareTerminal.starting')\" />\n <p class=\"srp-text\">{{ labels.t('squareTerminal.startingText') }}</p>\n @if (waitAmount(); as shown) { <p class=\"srp-text\" data-testid=\"reader-wait-amount\">{{ shown }}</p> }\n <p class=\"srp-elapsed\" data-testid=\"reader-leave-hint\">{{ labels.t('stripeReader.leaveHint') }}</p>\n </section>\n }\n @case ('succeeded') {\n <ui-alert variant=\"success\" [title]=\"labels.t('stripeReader.done.title')\" data-testid=\"reader-succeeded\" tabindex=\"-1\" class=\"srp-focus\">\n <p class=\"srp-text\" data-testid=\"reader-succeeded-text\">{{ succeededText() }}</p>\n @if (cardLine(); as card) { <p class=\"srp-text\" data-testid=\"reader-succeeded-card\">{{ card }}</p> }\n @if (receiptHref(); as href) {\n <p class=\"srp-text\"><a [href]=\"href\" target=\"_blank\" rel=\"noopener noreferrer\" data-testid=\"reader-receipt\">{{ labels.t('stripeReader.receipt') }}<span class=\"srp-sr\">{{ labels.t('squareConnect.opensInNewTabSr') }}</span></a></p>\n }\n </ui-alert>\n @if (feeRows().length) { <ng-container [ngTemplateOutlet]=\"feeTable\" /> }\n }\n @case ('canceled') {\n <ui-alert variant=\"info\" [title]=\"labels.t('stripeReader.canceled.title')\" data-testid=\"reader-canceled\" tabindex=\"-1\" class=\"srp-focus\">\n <p class=\"srp-text\">{{ labels.t('squareTerminal.canceled.text') }}</p>\n <div class=\"srp-actions\">\n @if (manualAvailable()) { <ui-button variant=\"primary\" size=\"sm\" data-testid=\"reader-take-manual\" (click)=\"manual.emit()\">{{ labels.t('stripeReader.takeManual') }}</ui-button> }\n <ui-button [variant]=\"manualAvailable() ? 'secondary' : 'primary'\" size=\"sm\" data-testid=\"reader-start-again\" (click)=\"startAgain()\">{{ labels.t('stripeReader.startAgain') }}</ui-button>\n </div>\n </ui-alert>\n }\n @case ('failed') {\n <ui-alert variant=\"danger\" [title]=\"labels.t('stripeReader.failed.title')\" data-testid=\"reader-failed\" tabindex=\"-1\" class=\"srp-focus\">\n <p class=\"srp-text\">{{ labels.t('stripeReader.failed.text') }}</p>\n <div class=\"srp-actions\">\n @if (manualAvailable()) { <ui-button variant=\"primary\" size=\"sm\" data-testid=\"reader-take-manual\" (click)=\"manual.emit()\">{{ labels.t('stripeReader.takeManual') }}</ui-button> }\n <ui-button [variant]=\"manualAvailable() ? 'secondary' : 'primary'\" size=\"sm\" data-testid=\"reader-start-again\" (click)=\"startAgain()\">{{ labels.t('stripeReader.startAgain') }}</ui-button>\n </div>\n </ui-alert>\n }\n @case ('idle') {\n <section class=\"srp-box\" data-testid=\"reader-ready-section\">\n @switch (idleNotice()) {\n @case ('paid') {\n <ui-alert variant=\"info\" [quiet]=\"true\" data-testid=\"reader-paid\">{{ labels.t('stripeReader.refusal.paid') }}</ui-alert>\n }\n @case ('pending-other') {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-pending-other\">{{ labels.t('stripeReader.refusal.outcome_checking') }}</ui-alert>\n }\n @case ('cancel-timeout') {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-cancel-busy-timeout\">{{ labels.t('stripeReader.cancelBusy.timeout') }}\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"reader-cancel-busy-recheck\" (click)=\"dismissCancelTimeout()\">{{ labels.t('stripeReader.status.recheck') }}</ui-button>\n </ui-alert>\n }\n @case ('quote-changed') {\n @if (flow.refusal(); as refusal) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-refusal\" [attr.data-code]=\"refusal.code\">{{ refusalText() }}</ui-alert>\n }\n <div class=\"srp-actions\" role=\"group\" data-testid=\"reader-quote-changed\">\n <ui-button variant=\"primary\" size=\"sm\" data-testid=\"reader-confirm-total\" [disabled]=\"quoting()\" (click)=\"confirmNewTotal()\">{{ labels.t('stripeReader.confirmTotal', { amount: confirmTotalText() }) }}</ui-button>\n </div>\n }\n @case ('refusal') {\n @if (flow.refusal(); as refusal) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-refusal\" [attr.data-code]=\"refusal.code\">{{ refusalText() }}\n @if (refusal.code === 'reader_not_paired') {\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"reader-refusal-connect\" (click)=\"connectReader.emit()\">{{ labels.t('squareTerminal.status.connect') }}</ui-button>\n }\n @if (existingPaymentHref(); as href) {\n <a [href]=\"href\" target=\"_blank\" rel=\"noopener noreferrer\" data-testid=\"reader-existing-payment\">{{ labels.t('stripeReader.refusal.viewExisting') }}<span class=\"srp-sr\">{{ labels.t('squareConnect.opensInNewTabSr') }}</span></a>\n }\n </ui-alert>\n }\n }\n }\n @if (ready() && !blockReason()) {\n @if (freeReaders().length > 1) {\n <ui-select [label]=\"labels.t('stripeReader.selectReader')\" [options]=\"readerOptions()\" [ngModel]=\"readerId()\" (ngModelChange)=\"selectedReaderId.set($event ?? '')\" data-testid=\"reader-select\" />\n } @else {\n <p class=\"srp-text\" data-testid=\"reader-name\">{{ labels.t('squareTerminal.readerLine', { reader: readerName() }) }}</p>\n }\n @if (amount() == null) {\n <p class=\"srp-text\" data-testid=\"reader-amount-needed\">{{ labels.t('squarePaymentMethod.amountNeeded') }}</p>\n }\n @if (feesMissing()) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-fees-unavailable\">{{ labels.t('stripeReader.fees.unavailable') }}</ui-alert>\n } @else if (quoteFailed()) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-fees-failed\">{{ labels.t('stripeReader.fees.failed') }}\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"reader-fees-retry\" (click)=\"retryQuote()\">{{ labels.t('common.tryAgain') }}</ui-button>\n </ui-alert>\n } @else if (quoting()) {\n <p class=\"srp-text\" data-testid=\"reader-fees-loading\" role=\"status\">{{ labels.t('stripeReader.fees.loading') }}</p>\n }\n @if (feeRows().length) { <ng-container [ngTemplateOutlet]=\"feeTable\" /> }\n <div class=\"srp-actions\">\n <ui-button variant=\"primary\" data-testid=\"reader-start\" [disabled]=\"!canStart()\" (click)=\"start()\">{{ startLabel() }}</ui-button>\n </div>\n }\n @if (manualAvailable()) {\n <div class=\"srp-actions\">\n <ui-button variant=\"link\" data-testid=\"reader-manual\" (click)=\"manual.emit()\">{{ labels.t('stripeReader.manualInstead') }}</ui-button>\n </div>\n }\n </section>\n }\n @default {\n <!-- Focus lands on this box when it appears; it has NO role and NO accessible name on purpose: the polite live region announces the title and the text, a labelled group would read them a second time. -->\n <section class=\"srp-wait\" data-testid=\"reader-waiting\" [attr.data-phase]=\"flow.phase()\" tabindex=\"-1\">\n <div class=\"srp-wait-head\">\n <span class=\"srp-pulse\" aria-hidden=\"true\" data-testid=\"reader-indicator\"><ui-icon name=\"card\" [size]=\"22\" [interactive]=\"false\" /></span>\n <h3 class=\"srp-title\" data-testid=\"reader-wait-title\">{{ waitTitle() }}</h3>\n </div>\n <p class=\"srp-text\" data-testid=\"reader-wait-text\">{{ waitText() }}</p>\n @if (waitAmount(); as shown) { <p class=\"srp-text\" data-testid=\"reader-wait-amount\">{{ shown }}</p> }\n @if (flow.phase() === 'recovering') { <p class=\"srp-elapsed\" data-testid=\"reader-leave-hint\">{{ labels.t('stripeReader.leaveHint') }}</p> }\n\n @if (flow.connectionLost()) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-connection-lost\">{{ labels.t('stripeReader.connectionLost') }}</ui-alert>\n }\n @if (flow.readerOffline() && !flow.connectionLost()) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-disconnected\">{{ labels.t('squareTerminal.readerDisconnected') }}</ui-alert>\n }\n @if (flow.checking() && !flow.connectionLost()) {\n <ui-alert [variant]=\"degraded()?.kind === 'transient' ? 'info' : 'warning'\" [quiet]=\"true\" data-testid=\"reader-still-checking\" [attr.data-kind]=\"degraded()?.kind ?? 'transient'\">{{ checkingText() }}</ui-alert>\n }\n @if (flow.cancelPending()) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-cancel-pending\">{{ labels.t('squareTerminal.cancelPending') }}</ui-alert>\n }\n @if (flow.cancelUnreachable()) {\n <ui-alert variant=\"danger\" [quiet]=\"true\" data-testid=\"reader-cancel-unreachable\">{{ labels.t('squareTerminal.cancelUnreachable') }}</ui-alert>\n }\n @if (flow.refusal(); as refusal) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-refusal\" [attr.data-code]=\"refusal.code\">{{ refusalText() }}</ui-alert>\n }\n @if (feeRows().length) { <ng-container [ngTemplateOutlet]=\"feeTable\" /> }\n <p class=\"srp-elapsed\" data-testid=\"reader-elapsed\">{{ labels.t('stripeReader.elapsed', { time: elapsedText() }) }}</p>\n <div class=\"srp-actions\">\n @if (flow.phase() === 'recovering' && flow.recoveryExpired()) {\n <ui-button variant=\"primary\" data-testid=\"reader-recheck\" [loading]=\"flow.rechecking()\" [disabled]=\"flow.rechecking()\" (click)=\"recheck()\">{{ labels.t('stripeReader.status.recheck') }}</ui-button>\n }\n @if (flow.retryable()) {\n <ui-button variant=\"primary\" data-testid=\"reader-retry\" (click)=\"retry()\">{{ labels.t('common.tryAgain') }}</ui-button>\n }\n @if (flow.cancellable() || flow.phase() === 'cancelling') {\n <ui-button [variant]=\"flow.retryable() ? 'secondary' : 'danger'\" data-testid=\"reader-cancel\" [loading]=\"flow.phase() === 'cancelling'\" [disabled]=\"flow.phase() === 'cancelling'\" (click)=\"cancelPayment()\">{{ labels.t('squareTerminal.cancel') }}</ui-button>\n }\n @if (flow.retryable() && manualAvailable()) {\n <ui-button variant=\"ghost\" data-testid=\"reader-use-manual\" (click)=\"switchToManual()\">{{ labels.t('stripeReader.takeManual') }}</ui-button>\n }\n </div>\n </section>\n }\n }\n }\n\n <ng-template #feeTable>\n <dl class=\"srp-fees\" data-testid=\"reader-fees\" [attr.aria-label]=\"labels.t('squarePaymentMethod.paymentTotal')\">\n @for (row of feeRows(); track row.key) {\n <div class=\"srp-fee\" [attr.data-testid]=\"'reader-fee-' + row.key\"><dt>{{ row.label }}</dt><dd>{{ row.value }}</dd></div>\n }\n </dl>\n </ng-template>\n `,\n styles: [`\n ui-square-terminal-payment { display: block; min-width: 0; }\n ui-square-terminal-payment .srp-box, ui-square-terminal-payment .srp-wait { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; min-width: 0; }\n ui-square-terminal-payment .srp-wait { padding: 16px; border: 2px solid var(--ui-psp-border, #cbd5e1); border-radius: 12px; background: var(--ui-psp-sunken, #f8fafc); }\n ui-square-terminal-payment .srp-wait[data-phase='declined'], ui-square-terminal-payment .srp-wait[data-phase='stopped'] { border-color: var(--ui-psp-danger, #b91c1c); }\n ui-square-terminal-payment .srp-wait:focus { outline: none; }\n ui-square-terminal-payment .srp-wait-head { display: flex; align-items: center; gap: 12px; }\n ui-square-terminal-payment .srp-title { margin: 0; font-size: 1.0625rem; font-weight: 700; color: var(--ui-psp-text, #1e293b); }\n ui-square-terminal-payment .srp-text, ui-square-terminal-payment .srp-elapsed { margin: 0; font-size: 0.9375rem; color: var(--ui-psp-text, #1e293b); }\n ui-square-terminal-payment .srp-elapsed { font-size: 0.8125rem; color: var(--ui-psp-muted, #475569); font-variant-numeric: tabular-nums; }\n ui-square-terminal-payment .srp-actions { display: flex; flex-wrap: wrap; gap: 8px; }\n ui-square-terminal-payment .srp-focus:focus { outline: none; }\n ui-square-terminal-payment .srp-pulse { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; color: var(--ui-psp-text, #1e293b); border: 2px solid currentColor; animation: srp-pulse 1.6s ease-in-out infinite; }\n ui-square-terminal-payment .srp-fees { margin: 0; padding: 12px 14px; border: 1px solid var(--ui-psp-border, #e2e8f0); border-radius: 10px; font-size: 0.8125rem; }\n ui-square-terminal-payment .srp-fee { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; color: var(--ui-psp-muted, #475569); }\n ui-square-terminal-payment .srp-fee dt, ui-square-terminal-payment .srp-fee dd { margin: 0; }\n ui-square-terminal-payment .srp-fee:last-child { font-weight: 700; color: var(--ui-psp-text, #1e293b); }\n ui-square-terminal-payment .srp-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }\n @keyframes srp-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.55; transform: scale(0.94); } }\n @media (prefers-reduced-motion: reduce) { ui-square-terminal-payment .srp-pulse { animation: none; } }\n @media (forced-colors: active) { ui-square-terminal-payment .srp-wait, ui-square-terminal-payment .srp-fees { border-color: CanvasText; } }\n `],\n})\nexport class SquareTerminalPaymentComponent {\n protected readonly labels = inject(UiLabelsService);\n private readonly destroyRef = inject(DestroyRef);\n private readonly injector = inject(Injector);\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly storage = inject(PAYMENT_ATTEMPT_STORAGE);\n\n // ── Inputs: what is paid ─────────────────────────────────────────────────\n /** The amount the customer owes before fees, major units. `null` = nothing to take yet. */\n readonly amount = input<number | null>(null);\n readonly currency = input('USD');\n /** The payable (an invoice, a balance): the attempt marker is stored under it, so a reload or a second tab finds an open payment instead of starting another. */\n readonly payableRef = input<string | null>(null);\n /** A key the host supplies; empty = derived from the payable / generated by the attempt machine. */\n readonly attemptKey = input<string | null>(null);\n /** The payable is paid (host re-render): no payment can start. */\n readonly paid = input(false);\n /** Extra fields the host's backend wants with the start (the payment panel passes its date, note and allocation). */\n readonly startExtras = input<{ receivedDate?: string; notes?: string | null; allocation?: PaymentAllocation } | null>(null);\n\n // ── Inputs: the host's calls (see docs/card-readers.md) ─────────────────\n readonly getReadiness = input<SquareTerminalGetReadinessFn | null>(null);\n readonly startPayment = input<SquareTerminalStartFn | null>(null);\n readonly getPayment = input<SquareTerminalGetPaymentFn | null>(null);\n readonly retryPayment = input<SquareTerminalRetryFn | null>(null);\n readonly cancelPaymentFn = input<SquareTerminalCancelFn | null>(null, { alias: 'cancelPayment' });\n /** The CARD_PRESENT fee quote. REQUIRED: a reader payment always shows the card reader fee breakdown before the tap, so without it \"Send to the reader\" stays off and says the fees are not available. */\n readonly estimateFees = input<SquareTerminalFeesFn | null>(null);\n readonly receiptUrl = input<((payment: SquareTerminalPayment) => string | null | undefined) | null>(null);\n /** The id of an open reader payment THIS user owns (from the host's records): with it the \"reader busy\" banner offers \"Cancel that payment\". */\n readonly ownPaymentId = input<string | null>(null);\n\n // ── Inputs: behaviour ───────────────────────────────────────────────────\n /** `true` = the full reader screen; `false` = only the banner (the payment screen is in manual mode but still tells that a reader could be used). */\n readonly active = input(true);\n /** A manual payment path exists: \"Enter the card manually instead\" / \"Take a manual payment instead\" show and the offline text says a manual payment can still be recorded. */\n readonly manualAvailable = input(true);\n /** The buttons that start something do nothing (a read-only user). Cancel stays possible. */\n readonly disabled = input(false);\n /**\n * Library 2026-11-21 (additive; NOT set by the payment panel's Square body, so nothing in the library uses it): `true` draws NO \"checking\" placeholder while there is no usable answer (a usable answer, or a payment, is still drawn here).\n * It is for a host that shows its own checking text elsewhere. NOTE: `ui-square-terminal-banner` (the payment panel's top banner) shows NOTHING while the read is pending, failed or `checking`, so with `hideChecking` nobody speaks for that state.\n * Default `false`: the screen shows its own checking state with \"Check again\" (also inside the payment panel).\n */\n readonly hideChecking = input(false);\n /**\n * Library 2026-11-21 (additive): the payment panel's top banner (`ctx.readerBanner`) is ALWAYS on screen and shows the \"get a card reader\" message when the organization has NO usable reader. With this input this screen draws no readiness banner for\n * those states (`no_reader`, `unsupported_only`, `merchant_not_ready`, and `reader_offline` / `reader_pairing`: \"not connected\" + \"Connect Your Terminal\") so the message never shows twice, and keeps everything else: its own \"checking\", busy (with \"Cancel that payment\"), connection notices, the reader choice, fees, \"Send to the reader\" and the\n * payment boxes. A standalone host that keeps `ui-square-terminal-banner` above its tab bar passes it too. Default `false`.\n */\n readonly hideBanner = input(false);\n /** Asked right before \"Send to the reader\" starts anything; `false` = do not start (the payment panel validates its own fields here and shows their messages). */\n readonly beforeStart = input<(() => boolean) | null>(null);\n readonly readinessEveryMs = input(15_000);\n readonly readinessTimeoutMs = input(4000);\n /** How often the waiting payment's status is read (ms; default 2000). Clamped to 500..30 000 ms. */\n readonly pollMs = input(2000);\n readonly pollTimeoutMs = input(8000);\n /** After a lost start answer (or an adopted attempt) the service's \"no payment for this attempt key\" is believed only after this long, counted from the moment recovery starts. Default 6 minutes: the service's 5-minute create window plus a minute (ms). */\n readonly lostAnswerGraceMs = input(SQUARE_TERMINAL_LOST_ANSWER_GRACE_MS);\n /** A start / retry / cancel call slower than this is unreachable (ms): a start is looked up by its attempt key, a retry / cancel leaves the payment as it was. */\n readonly requestTimeoutMs = input(SQUARE_TERMINAL_REQUEST_TIMEOUT_MS);\n /** A quote slower than this: \"Try again\" is offered and Send stays off (ms). */\n readonly feeTimeoutMs = input(10_000);\n /** Managed environments where `navigator.onLine === false` is a false negative: the browser's offline flag does not block (default false). */\n readonly offlineOverride = input(false);\n\n // ── Outputs ─────────────────────────────────────────────────────────────\n /** The user wants to enter the card manually (the host switches its method). Emitted only when nothing is waiting on the reader. */\n readonly manual = output<void>();\n /** \"Connect Your Terminal\": the host opens its pairing panel. */\n readonly connectReader = output<void>();\n /** \"Get a card reader\": the host opens its order flow. */\n readonly getReader = output<void>();\n /** \"Set up payments\": the host opens payment setup. */\n readonly openSetup = output<void>();\n /** The payment succeeded. */\n readonly succeeded = output<SquareTerminalSucceededEvent>();\n /** Everything else that happened, for the host to word. */\n readonly outcome = output<SquareTerminalOutcome>();\n /** A readiness read finished: its state (`null` = no answer / the read failed). The payment panel's FIRST answer decides whether the reader is the default. */\n readonly readinessChange = output<SquareTerminalReadinessState | null>();\n /** A payment is open on the reader (starting, waiting, declined, cancelling...): the host locks everything else. */\n readonly busyChange = output<boolean>();\n\n // ── State ───────────────────────────────────────────────────────────────\n readonly readiness = signal<SquareTerminalReadiness | null>(null);\n protected readonly readinessLoading = signal(false);\n readonly selectedReaderId = signal('');\n /** `quote_changed`: the total shown is not the total any more; Send stays off until the payer confirms the new one. */\n protected readonly quoteChanged = signal<{ total: number | null } | null>(null);\n readonly closeBlocked = signal(false);\n protected readonly cancellingBusy = signal(false);\n /** The \"Cancel that payment\" call did not answer in time: the payment may still be open (a notice with \"Check again\" shows instead of the banner). */\n protected readonly cancelTimedOut = signal(false);\n protected readonly quote = signal<SquareFees | null>(null);\n /** The amount the quote was asked for (a quote is shown only while it matches the amount on screen). */\n private readonly quotedFor = signal<number | null>(null);\n protected readonly quoting = signal(false);\n protected readonly quoteFailed = signal(false);\n private readonly quoteTick = signal(0);\n private quoteRun = 0;\n /** What the held quote was asked for: a phase change alone (a refusal, a canceled payment) keeps a held quote of the same amount; the service still checks the total (`quote_changed`). */\n private heldEstimate: unknown = null;\n private heldAmount: number | null | undefined = undefined;\n private heldTick = -1;\n private readonly builtIns = signal<string[]>([]);\n\n readonly attempt = new PaymentAttempt({\n destroyRef: this.destroyRef,\n payableRef: () => this.payableRef(),\n amount: () => this.amount(),\n method: () => 'CARD_PRESENT',\n attemptKey: () => this.attemptKey(),\n checkStatus: () => null,\n paid: () => this.paid(),\n offlineMidFlight: false,\n offlineOverride: () => this.offlineOverride(),\n storage: this.storage,\n });\n\n readonly flow = new SquareTerminalFlow({\n attempt: this.attempt,\n start: () => this.startPayment(),\n getPayment: () => this.getPayment(),\n retry: () => this.retryPayment(),\n cancel: () => this.cancelPaymentFn(),\n pollMs: () => clampReaderPollMs(this.pollMs()),\n pollTimeoutMs: () => this.pollTimeoutMs(),\n lostAnswerGraceMs: () => this.lostAnswerGraceMs(),\n requestTimeoutMs: () => this.requestTimeoutMs(),\n onEvent: event => this.onFlowEvent(event),\n });\n\n /** The user pressed a button that changes the screen: when the phase changes, focus moves to the new box (the pressed button is gone). */\n private acted = false;\n private lastPhase = this.flow.phase();\n private destroyed = false;\n private readRun = 0;\n private readTimer: ReturnType<typeof setTimeout> | null = null;\n\n protected readonly ready = computed(() => this.readiness()?.state === 'reader_ready');\n protected readonly freeReaders = computed(() => (this.readiness()?.readers ?? []).filter(isReaderFree));\n protected readonly readerId = computed(() => {\n const free = this.freeReaders();\n const chosen = this.selectedReaderId();\n if (chosen && free.some(r => r.id === chosen)) return chosen;\n const def = this.readiness()?.defaultReaderId;\n if (def && free.some(r => r.id === def)) return def;\n return free[0]?.id ?? '';\n });\n protected readonly readerOptions = computed(() => this.freeReaders().map(r => ({ value: r.id, label: r.model && r.label ? `${readerDisplayName(r)} (${r.model})` : readerDisplayName(r) })));\n /** The name of the reader the payment is (or would be) on. */\n protected readonly readerName = computed(() => {\n const id = this.flow.terminal()?.readerId ?? this.readerId();\n const readers = this.readiness()?.readers ?? [];\n return readerDisplayName(readers.find(r => r.id === id) ?? null) || this.labels.t('squareTerminal.theReader');\n });\n /** Why a reader payment cannot be started before it starts: offline, a slow connection, a browser that cannot pay safely. Empty = none. */\n protected readonly blockReason = computed((): '' | 'offline' | 'slow_connection' | 'unsupported_browser' => {\n if (this.attempt.blockedOffline()) return 'offline';\n const reasons = this.builtIns();\n if (reasons.includes('slow_connection')) return 'slow_connection';\n if (reasons.includes('unsupported_browser')) return 'unsupported_browser';\n return '';\n });\n protected readonly blockText = computed(() => {\n switch (this.blockReason()) {\n case 'offline': return this.labels.t(this.manualAvailable() ? 'stripeReader.offline.withManual' : 'stripeReader.offline.noManual');\n case 'slow_connection': return this.labels.t('paymentReadiness.slow_connection');\n case 'unsupported_browser': return this.labels.t('paymentReadiness.unsupported_browser');\n default: return '';\n }\n });\n /** No fee quote call: a reader payment must always show the CARD_PRESENT breakdown before the tap, so nothing can be sent. */\n protected readonly feesMissing = computed(() => !this.estimateFees());\n /**\n * The ONE message block of the idle screen, by precedence: already paid > an earlier payment still being confirmed > a cancel that timed out > the total changed > a refusal of the last start. The readiness banner and\n * the \"blocked\" notice show only when none of these does (and never in the canceled / failed boxes).\n */\n protected readonly idleNotice = computed((): 'paid' | 'pending-other' | 'cancel-timeout' | 'quote-changed' | 'refusal' | null => {\n if (!this.active() || this.flow.phase() !== 'idle') return null;\n if (this.attempt.paidLocked()) return 'paid';\n if (this.foreignPending()) return 'pending-other';\n if (this.cancelTimedOut()) return 'cancel-timeout';\n if (this.quoteChanged()) return 'quote-changed';\n if (this.flow.refusal()) return 'refusal';\n return null;\n });\n protected readonly showBlocked = computed(() => this.active() && this.flow.phase() === 'idle' && !this.idleNotice());\n /**\n * Library source 2026-11-21: this screen is showing a card reader message of its own right now (the readiness banner, a connection notice, one of the idle notices, or a payment box), so a second reader banner elsewhere\n * on the page must step aside. `false` when it shows nothing about the reader (a ready reader and an idle screen). Mirrors the template exactly (with `hideBanner` the no-reader states are not drawn here, so they do not count).\n */\n readonly ownsReaderMessage = computed(() => {\n if (this.flow.phase() !== 'idle' || this.flow.locked()) return true;\n if (this.idleNotice()) return true;\n if (this.blockReason()) return this.showBlocked();\n return this.showReadiness() && this.shownReadiness()?.state !== 'reader_ready';\n });\n /**\n * The readiness the banner is drawn from: a usable answer only. No answer (loading, failed, slow) and a service `checking` (old name `unknown`) that does not need the account's attention are NOT shown as a state of their own (there is no \"unknown\" banner): `null`, and the status component's \"Checking the card reader\" placeholder speaks (unless the host set `hideChecking`; the top banner never speaks for that state).\n */\n protected readonly shownReadiness = computed((): SquareTerminalReadiness | null => {\n const r = this.readiness();\n if (!r) return null;\n if ((r.state === 'checking' || r.state === 'unknown') && readerDegraded({ state: 'checking', stale: true, degradedReason: r.degradedReason })?.kind !== 'attention') return null;\n return r;\n });\n protected readonly showReadiness = computed(() => {\n if (this.flow.locked() || this.flow.phase() === 'succeeded') return false;\n if (!this.shownReadiness() && this.hideChecking()) return false; // no usable answer: the panel's top banner speaks, nothing of our own\n if (this.hideBanner() && SQUARE_TERMINAL_NO_READER_STATES.includes(this.shownReadiness()?.state as SquareTerminalReadinessState)) return false; // the top banner speaks for these states (get a Terminal / connect your Terminal)\n return this.active() ? this.flow.phase() === 'idle' && !this.idleNotice() : true;\n });\n /** The own payment that holds a reader, when the host knows it. */\n protected readonly busyOwnPaymentId = computed(() => {\n const id = this.ownPaymentId();\n return id && (this.readiness()?.readers ?? []).some(r => r.busyPaymentId === id) ? id : null;\n });\n private readonly amountValid = computed(() => { const a = this.amount(); return a != null && Number.isFinite(a) && a > 0; });\n /** The quote of the amount on screen (a quote for another amount is never shown). */\n protected readonly currentQuote = computed(() => (this.quotedFor() === this.amount() ? this.quote() : null));\n protected readonly feeRows = computed(() => {\n const fees = this.currentQuote();\n const amount = this.flow.locked() || this.flow.phase() === 'succeeded' ? (this.flow.baseAmount() ?? this.amount()) : this.amount();\n if (!fees || amount == null || (fees.processingFee === undefined && fees.platformFee === undefined && fees.totalAmount === undefined)) return [];\n const money = (n: number) => formatCurrency(n, { currency: this.currency() });\n const rows: { key: string; label: string; value: string }[] = [{ key: 'amount', label: this.labels.t('squarePaymentMethod.paymentAmount'), value: money(amount) }];\n if (fees.processingFee !== undefined) rows.push({ key: 'processing', label: `${this.labels.t('squarePaymentMethod.processingFee')}${fees.processingFeeLabel ? ` (${fees.processingFeeLabel})` : ''}`, value: money(fees.processingFee) });\n if (fees.platformFee !== undefined) rows.push({ key: 'platform', label: `${this.labels.t('squarePaymentMethod.platformFee')}${fees.platformFeeLabel ? ` (${fees.platformFeeLabel})` : ''}`, value: money(fees.platformFee) });\n if (fees.totalAmount !== undefined) rows.push({ key: 'total', label: this.labels.t('squarePaymentMethod.totalCharged'), value: money(fees.totalAmount) });\n return rows;\n });\n /** Everything that must be true before \"Send to the reader\" works. */\n readonly canStart = computed(() =>\n this.active() && this.ready() && !this.blockReason() && !!this.readerId() && this.amountValid() && !this.disabled() && !this.paid() && !this.flow.locked()\n && this.flow.phase() !== 'succeeded' && !this.attempt.locked() && !this.quoting() && !this.quoteFailed() && !this.feesMissing() && !!this.currentQuote() && !this.quoteChanged());\n protected readonly startLabel = computed(() => (this.amount() != null && this.amountValid()\n ? this.labels.t('squareTerminal.start', { amount: formatCurrency(this.currentQuote()?.totalAmount ?? this.amount(), { currency: this.currency() }) })\n : this.labels.t('squareTerminal.startNoAmount')));\n /** A reload / second tab found an undecided attempt of ANOTHER method (a manual card): it is never followed as a reader payment, only worded. */\n protected readonly foreignPending = computed(() => this.attempt.unknown() && !this.flow.locked() && this.flow.phase() === 'idle' && this.attempt.pinnedMethod() !== 'CARD_PRESENT');\n protected readonly degraded = computed(() => readerDegraded(this.flow.terminal()));\n protected readonly checkingText = computed(() => {\n const d = this.degraded();\n if (d?.kind === 'attention') return this.labels.t('stripeReader.degraded.attention');\n if (d?.kind === 'since') return this.labels.t('stripeReader.degraded.since', { time: d.since });\n return this.labels.t('stripeReader.stillChecking');\n });\n /** What was actually charged (the service's `amountCents`), else the quote total of the open payment; `null` when neither is known. */\n private readonly chargedTotal = computed((): number | null => paymentChargedAmount(this.flow.payment()) ?? (this.flow.locked() || this.flow.phase() === 'succeeded' ? this.currentQuote()?.totalAmount ?? null : null));\n /** The amount line of the waiting screen: the total when known, else the base amount (fees may be added). Always present once an amount is known, quote or not (also after a reload that adopted the payment). */\n protected readonly waitAmount = computed(() => {\n const money = (n: number) => formatCurrency(n, { currency: this.currency() });\n const total = this.chargedTotal();\n if (total != null) return this.labels.t('stripeReader.wait.amount', { amount: money(total) });\n const base = this.flow.baseAmount();\n return base != null ? this.labels.t('stripeReader.wait.amountBase', { amount: money(base) }) : '';\n });\n protected readonly confirmTotalText = computed(() => { const total = this.currentQuote()?.totalAmount ?? this.quoteChanged()?.total ?? null; return total == null ? '' : formatCurrency(total, { currency: this.currency() }); });\n protected readonly existingPaymentHref = computed(() => {\n const refusal = this.flow.refusal();\n if (refusal?.code !== 'duplicate_suspected' || !refusal.paymentId) return null;\n const url = this.receiptUrl()?.({ id: refusal.paymentId });\n return isSafeReceiptUrl(url) ? url : null;\n });\n protected readonly elapsedText = computed(() => formatElapsed(this.flow.elapsedMs()));\n protected readonly waitTitle = computed(() => this.labels.t(`stripeReader.wait.${this.waitKey()}.title` as UiLabelKey));\n protected readonly waitText = computed(() => {\n const t = this.flow.terminal();\n if (this.waitKey() === 'declined' && t?.message) return t.message;\n return this.labels.t(terminalLabelKey(`stripeReader.wait.${this.waitKey()}.text` as UiLabelKey), { reader: this.readerName() });\n });\n private readonly waitKey = computed((): 'waiting' | 'declined' | 'stopped' | 'retrying' | 'cancelling' | 'recovering' | 'unconfirmed' => {\n const p = this.flow.phase();\n if (p === 'recovering' && this.flow.recoveryExpired()) return 'unconfirmed';\n return p === 'declined' || p === 'stopped' || p === 'retrying' || p === 'cancelling' || p === 'recovering' ? p : 'waiting';\n });\n protected readonly refusalText = computed(() => {\n const refusal = this.flow.refusal();\n if (!refusal) return '';\n if (refusal.code === 'quote_changed') {\n return typeof refusal.amountCents === 'number'\n ? this.labels.t('stripeReader.refusal.quote_changed', { amount: formatCurrency(refusal.amountCents / 100, { currency: this.currency() }) })\n : this.labels.t('stripeReader.refusal.quote_changedNoAmount');\n }\n if (refusal.code === 'reader_not_paired') return refusal.pairingCode ? this.labels.t('squareTerminal.refusal.reader_not_paired', { code: refusal.pairingCode }) : this.labels.t('squareTerminal.refusal.reader_not_paired_nocode');\n const key = readerRefusalLabelKey(refusal.code);\n return key ? this.labels.t(key) : refusal.message || this.labels.t('stripeReader.refusal.generic');\n });\n protected readonly succeededText = computed(() => {\n // What was actually charged (the service's own total), else the quote the payer saw, else the base amount; never a made-up 0.\n const amount = this.chargedTotal() ?? this.flow.baseAmount() ?? this.amount();\n return amount == null\n ? this.labels.t('stripeReader.done.textNoAmount', { reader: this.readerName() })\n : this.labels.t('stripeReader.done.text', { amount: formatCurrency(amount, { currency: this.currency() }), reader: this.readerName() });\n });\n protected readonly cardLine = computed(() => {\n const p = this.flow.payment();\n return p?.last4 ? this.labels.t('stripeReader.done.card', { brand: p.brand ? String(p.brand).replace(/^./, c => c.toUpperCase()) : this.labels.t('stripeReader.done.cardWord'), last4: p.last4 }) : '';\n });\n protected readonly receiptHref = computed(() => {\n const payment = this.flow.payment();\n const url = payment ? this.receiptUrl()?.(payment) : null;\n return isSafeReceiptUrl(url) ? url : null;\n });\n /** What the polite region says: one text, the most important thing first, changing with every state. */\n protected readonly announcement = computed(() => {\n const phase = this.flow.phase();\n if (!this.active()) return ''; // manual mode: the reader is only a banner, the manual form speaks for the page\n if (this.blockReason() && !this.flow.locked() && phase !== 'succeeded') return this.blockText();\n if (this.closeBlocked() && this.flow.locked()) return this.labels.t('stripeReader.closeBlocked');\n if (phase === 'idle') return this.foreignPending() ? this.labels.t('stripeReader.refusal.outcome_checking') : '';\n if (phase === 'starting') return this.labels.t('squareTerminal.startingText');\n if (phase === 'succeeded') return ''; // the success alert is the announcement (a second one here would say it twice, and with another amount)\n if (phase === 'canceled') return `${this.labels.t('stripeReader.canceled.title')}. ${this.labels.t('squareTerminal.canceled.text')}`;\n if (phase === 'failed') return `${this.labels.t('stripeReader.failed.title')}. ${this.labels.t('stripeReader.failed.text')}`;\n if (this.flow.cancelPending()) return this.labels.t('squareTerminal.cancelPending');\n if (this.flow.cancelUnreachable()) return this.labels.t('squareTerminal.cancelUnreachable');\n if (this.flow.connectionLost()) return this.labels.t('stripeReader.connectionLost');\n if (this.flow.readerOffline()) return this.labels.t('squareTerminal.readerDisconnected');\n if (this.flow.checking()) return this.checkingText();\n return `${this.waitTitle()}. ${this.waitText()}`;\n });\n\n constructor() {\n this.refreshBuiltIns();\n if (typeof window !== 'undefined') {\n const refresh = (): void => this.refreshBuiltIns();\n window.addEventListener('online', refresh);\n window.addEventListener('offline', refresh);\n this.destroyRef.onDestroy(() => { window.removeEventListener('online', refresh); window.removeEventListener('offline', refresh); });\n }\n this.destroyRef.onDestroy(() => { this.destroyed = true; this.flow.dispose(); if (this.readTimer) clearTimeout(this.readTimer); this.quoteRun++; });\n // The readiness is read as soon as the host gave the call, then every `readinessEveryMs` (and again after a payment ends).\n effect(() => { const read = this.getReadiness(); untracked(() => { if (read) void this.loadReadiness(); }); });\n effect(() => { const locked = this.flow.locked(); untracked(() => { this.busyChange.emit(locked); if (!locked) this.closeBlocked.set(false); }); });\n effect(() => {\n const phase = this.flow.phase();\n untracked(() => {\n const changed = phase !== this.lastPhase;\n this.lastPhase = phase;\n if (changed && this.acted && phase !== 'idle') { this.acted = false; afterNextRender(() => this.host.nativeElement.querySelector<HTMLElement>('[data-testid=\"reader-starting\"], [data-testid=\"reader-waiting\"], [data-testid=\"reader-succeeded\"], [data-testid=\"reader-canceled\"], [data-testid=\"reader-failed\"]')?.focus(), { injector: this.injector }); }\n });\n });\n effect(() => { const phase = this.flow.phase(); untracked(() => { if (phase === 'canceled' || phase === 'failed' || phase === 'succeeded') void this.loadReadiness(); }); });\n // A reload / a second tab found an open attempt of this payable: look its payment up (never start another). The marker is per PAYABLE, not per method: only a card READER attempt is followed on the terminal\n // channel; a manual card attempt is worded (\"still confirming an earlier payment\") and keeps Send off, but is never polled as a reader payment.\n effect(() => {\n const unknown = this.attempt.unknown();\n const method = this.attempt.pinnedMethod();\n untracked(() => { if (unknown && method === 'CARD_PRESENT' && !this.flow.locked() && this.flow.phase() === 'idle') this.flow.adopt(); });\n });\n // `quote_changed`: the total shown is stale. The quote is asked again at once and Send stays off until the payer confirms the new total. `reader_not_paired`: the device is not a Terminal yet, so the readiness is read again (it then says `reader_pairing`).\n effect(() => {\n const refusal = this.flow.refusal();\n untracked(() => {\n if (refusal?.code === 'quote_changed') { this.quoteChanged.set({ total: typeof refusal.amountCents === 'number' ? refusal.amountCents / 100 : null }); this.quoteTick.update(n => n + 1); }\n if (refusal?.code === 'reader_not_paired') void this.loadReadiness();\n });\n });\n // Another amount is another quote: the \"confirm the new total\" step is over.\n effect(() => { this.amount(); untracked(() => this.quoteChanged.set(null)); });\n // Without a payable reference the reload / second-tab protection cannot work (the marker is stored under it).\n effect(() => { const ref = this.payableRef(); untracked(() => { if (isDevMode() && ref == null) console.warn('[ui-square-terminal-payment] payableRef is not set: a reload or a second tab cannot find an open reader payment, so the duplicate protection only covers this page instance.'); }); });\n effect(() => { const estimate = this.estimateFees(); untracked(() => { if (isDevMode() && !estimate) console.warn('[ui-square-terminal-payment] estimateFees is not set: a reader payment must show the card reader fee breakdown before the tap.'); }); });\n // The browser's own offline / online events while a payment is open.\n effect(() => { const offline = this.attempt.offline(); untracked(() => { if (this.flow.locked()) this.flow.markConnection(!offline); }); });\n // The fee quote: cleared AT ONCE when the amount changes (a quote for another amount is never shown), asked again after a short pause, and Send stays off until the quote of the current amount arrives.\n effect(onCleanup => {\n const estimate = this.estimateFees();\n const amount = this.amount();\n const tick = this.quoteTick();\n const phase = this.flow.phase();\n const active = this.active();\n if (phase !== 'idle' && phase !== 'canceled' && phase !== 'failed') return; // while a payment is open (or done) the quote on screen belongs to it\n if (!active) { this.heldTick = -1; untracked(() => { this.quote.set(null); this.quotedFor.set(null); this.quoteFailed.set(false); this.quoting.set(false); }); return; } // the reader is only a banner (manual mode): no card-present quote is asked\n // Only the phase moved (a refusal or a canceled payment brought the screen back): the quote held for this very amount is still the one to show. Anything else (another amount, another call, \"Try again\", a changed total) asks again.\n const unchanged = estimate === this.heldEstimate && amount === this.heldAmount && tick === this.heldTick;\n if (unchanged && untracked(() => !!this.quote() && this.quotedFor() === amount)) return;\n this.heldEstimate = estimate; this.heldAmount = amount; this.heldTick = tick;\n const run = ++this.quoteRun;\n untracked(() => { this.quote.set(null); this.quotedFor.set(null); this.quoteFailed.set(false); this.quoting.set(false); });\n if (!estimate || amount == null || !Number.isFinite(amount) || amount <= 0) return;\n untracked(() => this.quoting.set(true));\n let hung: ReturnType<typeof setTimeout> | null = null;\n const timer = setTimeout(async () => {\n hung = setTimeout(() => { if (run === this.quoteRun) { this.quoting.set(false); this.quoteFailed.set(true); } }, Math.max(1, this.feeTimeoutMs()));\n let fees: SquareFees | null = null;\n try { fees = (await callHost(() => estimate({ amount, paymentMethod: 'CARD_PRESENT', paymentMethodType: 'card_present' }))) ?? null; } catch { fees = null; }\n if (hung) { clearTimeout(hung); hung = null; }\n if (this.destroyed || run !== this.quoteRun) return;\n this.quoting.set(false);\n if (fees) { this.quote.set(fees); this.quotedFor.set(amount); this.quoteFailed.set(false); } else { this.quote.set(null); this.quotedFor.set(null); this.quoteFailed.set(true); }\n }, 300);\n onCleanup(() => { clearTimeout(timer); if (hung) clearTimeout(hung); });\n });\n }\n\n private refreshBuiltIns(): void { this.builtIns.set(builtInReadinessReasons(this.offlineOverride())); }\n\n // ── Readiness ───────────────────────────────────────────────────────────\n\n /** Reads the readiness now (\"Check again\"). A slow (over `readinessTimeoutMs`) or failed read leaves NO answer: the banner says it could not be checked and nothing is started. */\n async loadReadiness(): Promise<void> {\n const read = this.getReadiness();\n if (!read || this.destroyed) return;\n if (this.readTimer) { clearTimeout(this.readTimer); this.readTimer = null; }\n const run = ++this.readRun;\n this.readinessLoading.set(true);\n let result: SquareTerminalReadiness | null = null;\n let timer: ReturnType<typeof setTimeout> | null = null;\n try {\n const timeout = new Promise<'timeout'>(resolve => { timer = setTimeout(() => resolve('timeout'), this.readinessTimeoutMs()); });\n const raw = await Promise.race([callHost(() => read()), timeout]);\n result = raw === 'timeout' ? null : normalizeReadiness(raw);\n } catch { result = null; } finally { if (timer) clearTimeout(timer); }\n if (this.destroyed || run !== this.readRun) return;\n this.readinessLoading.set(false);\n this.readiness.set(result);\n // \"Not paired yet\" is over once the readiness says a Terminal is ready: the old refusal must not stay above \"Send\".\n if (result?.state === 'reader_ready' && this.flow.refusal()?.code === 'reader_not_paired' && !this.flow.locked()) this.flow.refusal.set(null);\n this.readinessChange.emit(result?.state ?? null);\n this.scheduleReadiness();\n }\n\n private scheduleReadiness(): void {\n if (this.destroyed) return;\n if (this.readTimer) clearTimeout(this.readTimer);\n this.readTimer = setTimeout(() => { this.readTimer = null; if (this.flow.locked()) this.scheduleReadiness(); else void this.loadReadiness(); }, Math.max(1, this.readinessEveryMs()));\n }\n\n // ── Actions ─────────────────────────────────────────────────────────────\n\n /** \"Send to the reader\". Synchronous up to the attempt lock: a double click sends ONE payment. */\n start(): void {\n this.refreshBuiltIns();\n if (!this.canStart()) return;\n const before = this.beforeStart();\n if (before && !before()) return;\n const amount = this.amount() as number;\n const total = this.currentQuote()?.totalAmount;\n this.closeBlocked.set(false);\n void this.flow.start({\n readerId: this.readerId(), amount, payableRef: this.payableRef(), extras: this.startExtras() ?? undefined,\n ...(total !== undefined && Number.isFinite(total) ? { expectedAmountCents: Math.round(total * 100) } : {}),\n });\n this.acted = true;\n }\n\n /** \"Confirm the new total\": the payer saw the new total, Send is available again. */\n protected confirmNewTotal(): void { this.quoteChanged.set(null); }\n\n protected retry(): void { this.acted = true; void this.flow.retry(); }\n\n /** \"Check again\" of an unconfirmed payment: reads the attempt key once more (found: followed; still none after the grace: released, \"Start again\"). */\n protected recheck(): void { void this.flow.recheck(); }\n\n protected dismissCancelTimeout(): void { this.cancelTimedOut.set(false); void this.loadReadiness(); }\n\n protected cancelPayment(): void { this.acted = true; void this.flow.cancel(); }\n\n protected startAgain(): void { this.flow.reset(); }\n\n protected retryQuote(): void { this.quoteTick.update(n => n + 1); }\n\n /** \"Take a manual payment instead\" while a payment is open: the payment is canceled FIRST; the host is told only when the service confirmed it. */\n protected async switchToManual(): Promise<void> {\n if (await this.cancelAndWait()) this.manual.emit();\n }\n\n /** Cancels an open reader payment and resolves true when nothing is open any more (nothing was waiting, or the service confirmed the cancel). False = the payment is STILL open. */\n async cancelAndWait(): Promise<boolean> {\n if (!this.flow.locked()) return true;\n if (this.flow.phase() === 'starting' || this.flow.phase() === 'recovering' || this.flow.phase() === 'retrying') return false;\n return this.flow.cancel();\n }\n\n /** Is a reader payment open (starting, waiting, declined, cancelling...)? */\n isLocked(): boolean { return this.flow.locked(); }\n\n /** The panel wants to close: allowed (true) only when nothing is open. Otherwise the warning shows and focus goes to \"Cancel payment\". */\n requestClose(): boolean {\n if (!this.flow.locked()) return true;\n // Nothing is waiting on the reader yet (the answer of the start is on its way or lost): there is nothing to cancel. The panel may close; the attempt marker is kept, so reopening it\n // finds the payment by its attempt key (\"Checking the payment\" with the same hint) and NEVER starts another.\n const phase = this.flow.phase();\n if (phase === 'starting' || phase === 'recovering') { this.outcome.emit({ kind: 'left-pending' }); return true; }\n this.closeBlocked.set(true);\n afterNextRender(() => this.host.nativeElement.querySelector<HTMLElement>('[data-testid=\"reader-cancel\"] button, [data-testid=\"reader-waiting\"]')?.focus(), { injector: this.injector });\n return false;\n }\n\n /** Fire-and-forget cancel of an open payment (the host closed the panel anyway). Never claims the payment is canceled. */\n cancelBestEffort(): void {\n const cancel = this.cancelPaymentFn();\n const id = this.flow.payment()?.id;\n if (!cancel || !id || !this.flow.cancellable()) return;\n callHost(() => cancel(id)).catch(() => { /* the service keeps the payment open and the reconciler settles it */ });\n }\n\n /** \"Cancel that payment\" of the busy banner: cancels the user's own payment that holds the reader, then reads the readiness again. */\n protected async cancelBusy(id: string): Promise<void> {\n const cancel = this.cancelPaymentFn();\n if (!cancel || this.cancellingBusy()) return;\n this.cancellingBusy.set(true);\n this.cancelTimedOut.set(false);\n let timer: ReturnType<typeof setTimeout> | null = null;\n try {\n // Raced against the request timeout: a call that never answers cannot leave \"Cancel that payment\" busy forever. A timed-out cancel may have gone through: the readiness is read again at once.\n const timeout = new Promise<never>((_, reject) => { timer = setTimeout(() => reject(Object.assign(new Error('request timeout'), { status: null, code: 'request_timeout' })), Math.max(1, this.requestTimeoutMs())); });\n await Promise.race([callHost(() => cancel(id)), timeout]);\n } catch (error) {\n const code = readerErrorInfo(error).code;\n if (code === 'request_timeout') this.cancelTimedOut.set(!this.destroyed);\n this.outcome.emit({ kind: 'refused', code: code || 'reader_unreachable' });\n } finally { if (timer) clearTimeout(timer); }\n if (this.destroyed) return;\n this.cancellingBusy.set(false);\n void this.loadReadiness();\n }\n\n private onFlowEvent(event: SquareTerminalFlowEvent): void {\n switch (event.kind) {\n case 'started': this.outcome.emit({ kind: 'started', payment: event.payment }); break;\n case 'declined': this.outcome.emit({ kind: 'declined', payment: event.payment }); break;\n case 'succeeded':\n // The amount of THIS payment: the service's base amount (also after a reload that adopted it), else what this screen started with; never a made-up 0.\n this.succeeded.emit({ payment: event.payment, attemptKey: event.attemptKey, amount: this.flow.baseAmount() ?? this.amount() ?? paymentChargedAmount(event.payment) ?? 0, readerId: event.payment.terminal?.readerId ?? this.flow.lastStartInput()?.readerId ?? '' });\n break;\n case 'canceled': this.outcome.emit({ kind: 'canceled' }); break;\n case 'failed': this.outcome.emit({ kind: 'failed' }); break;\n case 'refused': this.outcome.emit({ kind: 'refused', code: event.refusal.code }); break;\n case 'connection-lost': this.outcome.emit({ kind: 'connection-lost' }); break;\n case 'connection-restored': this.outcome.emit({ kind: 'connection-restored' }); break;\n }\n }\n}\n","import type { PaymentAllocation } from '@forgeroute/ui/payments';\nimport { uiText } from '@forgeroute/ui/core';\nimport type { SquareCardType, SquareMethod, SquareTokenDetails } from '../square-payment/square-outcomes';\n\n/** What the host's `createPayment` receives: the entered payment, how it is applied to charges, and the single-use token Square gave for the customer's card / bank account. */\nexport interface SquarePaymentContext extends PaymentAllocation {\n /** The amount the payer owes (before processing fees), in major units (12.5 = $12.50). */\n amount: number;\n /** The method value that was selected (`'CARD'` / `'ACH'`). */\n paymentMethod: string;\n /** Square's side of it: `'card'` or `'ach'`. */\n method: SquareMethod;\n receivedDate: string;\n notes: string | null;\n /** The single-use source id: send it to your backend (which sends it to the payments service). */\n token: string;\n /** Brand, last four, bank name ... as far as the SDK sent them. */\n details: SquareTokenDetails;\n /** The card funding when the SDK already told it at tokenization (`null` otherwise: a backend that needs it reads `card_type` from Square once the card exists). */\n funding: SquareCardType | null;\n /** The buyer-verification (SCA) token, when the form ran `verifyBuyer`. */\n verificationToken: string | null;\n /**\n * @deprecated A new id per tokenization: do NOT use it as the Square `idempotency_key` (a retry with a new token would then be a second payment). Send `token` and `attemptKey` instead, and derive\n * the idempotency key from `attemptKey`.\n */\n idempotencyKey: string;\n /**\n * The key of this PAYMENT ATTEMPT: stable across retries after a timeout / offline loss, a reload and a second tab (with a `payableRef` it is derived from payable, amount and method, so every tab holds\n * the SAME key); renewed only after a definitive failure or success. Send it to your backend with the charge (it looks the attempt up by it FIRST and derives the processor's idempotency key from it) and\n * answer `checkStatus(attemptKey)` with it.\n */\n attemptKey: string;\n /** The payable of this attempt (the plugin's `payableRef` at the click): the backend allows ONE open or succeeded attempt per payable and answers 409 `payment_in_flight` to a second key. */\n payableRef: string | null;\n}\n\n/**\n * What the host's `createPayment` answers. `status` is Square's payment status: `COMPLETED` = paid (a payment the host created with autocomplete answers `COMPLETED`), `APPROVED` (authorized, NOT captured yet)\n * and `PENDING` (and any other non-final value) = submitted and settling (a bank debit takes days), `FAILED` / `CANCELED` = not paid (the panel shows `failureMessage` / a default text and the payer can try again). Fees are optional;\n * when given they are shown as rows under the form.\n */\nexport interface SquarePaymentResult {\n paymentId?: string | null;\n status?: string;\n failureMessage?: string;\n processingFee?: number;\n platformFee?: number;\n totalAmount?: number;\n processingFeeLabel?: string;\n platformFeeLabel?: string;\n}\n\n/** The fees of a payment, shown before the payer pays (the host's `estimateFees`) or after the payment exists. */\nexport interface SquareFees {\n processingFee?: number;\n platformFee?: number;\n /** What the payer is charged (amount + fees), shown as \"Total charged\". Display only: Square's form is not created for an amount. */\n totalAmount?: number;\n processingFeeLabel?: string;\n platformFeeLabel?: string;\n}\n\nexport interface SquareFeeContext {\n amount: number;\n paymentMethod: string;\n method: SquareMethod;\n /**\n * The card funding. Square's SDK does not know it before the customer pays, so this is `null` in the estimate; a credit-only fee schedule shows the credit fee\n * (or the highest) here and corrects the rows from the `createPayment` answer.\n */\n funding: SquareCardType | null;\n}\n\nexport type SquareOutcomeKind = 'paid' | 'processing' | 'failed';\n\n// `APPROVED` is an authorization that is not captured yet: the money has not moved, so it is NOT paid (it is `processing`, like any other non-final status).\nconst PAID = new Set(['COMPLETED', 'PAID']);\nconst FAILED = new Set(['FAILED', 'CANCELED', 'CANCELLED']);\n\n/**\n * Square's payment `status` as one outcome. A non-final status (`PENDING`, `APPROVED` = authorized but not captured, anything unknown) counts as `'processing'`: the payment exists, so the payer is told it was submitted,\n * never \"failed\". No status at all (a host that answers nothing after it created the payment) is `'paid'` for a card and `'processing'` for a bank account, which never settles at once.\n */\nexport function squareOutcomeOf(status: string | null | undefined, method: SquareMethod = 'card'): SquareOutcomeKind {\n const value = (status ?? '').trim().toUpperCase();\n if (!value) return method === 'ach' ? 'processing' : 'paid';\n if (PAID.has(value)) return 'paid';\n if (FAILED.has(value)) return 'failed';\n return 'processing';\n}\n\n/** The method values the plugin takes over by default. */\nexport const SQUARE_PAYMENT_METHOD_VALUES = ['CARD', 'ACH'] as const;\n\n/** The name of a method in the app's active language (an unknown value is shown as it is). */\nexport const squareMethodLabel = (value: string): string =>\n value === 'CARD' ? uiText('squarePaymentMethod.methodCard') : value === 'ACH' ? uiText('squarePaymentMethod.methodAch') : value;\n\nexport const squareMethodOf = (method: string): SquareMethod => (method === 'ACH' ? 'ach' : 'card');\n\n/** The texts of the Square payment method; read on every access, so they follow the app's active language. */\nexport const SQUARE_METHOD_TEXTS = {\n get amountNeeded() { return uiText('squarePaymentMethod.amountNeeded'); },\n get notCompleted() { return uiText('squarePaymentMethod.notCompleted'); },\n get achTitle() { return uiText('squarePaymentMethod.achTitle'); },\n achMessage: (amount: string) => uiText('squarePaymentMethod.achMessage', { amount }),\n get pendingTitle() { return uiText('squarePaymentMethod.pendingTitle'); },\n pendingMessage: (amount: string) => uiText('squarePaymentMethod.pendingMessage', { amount }),\n get receiptNote() { return uiText('squarePaymentMethod.receiptNote'); },\n};\n","import { FormsModule } from '@angular/forms';\nimport { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, Injector, ViewEncapsulation, afterNextRender, computed, effect, inject, input, signal, untracked, viewChild } from '@angular/core';\nimport { AlertComponent } from '@forgeroute/ui/alert';\nimport { ButtonComponent, UiLabelsService } from '@forgeroute/ui/core';\nimport { HintComponent } from '@forgeroute/ui/hint';\nimport { KpiCardComponent } from '@forgeroute/ui/kpi-card';\nimport { RadioGroupComponent } from '@forgeroute/ui/radio';\nimport { PaymentAttemptStatusComponent, callHost, classifyHostError, isAwaitingVerificationError, isFinalPaymentRefusal, paymentErrorLabelKey, wasQueuedOffline, warnQueuedPayment, createPaymentProtection, hostErrorMessage, type PaymentAttempt, type PaymentAttemptControls, type PaymentAttemptOutcome, type PaymentMethodContext, type PaymentProtectionInputs, type PaymentReadiness } from '@forgeroute/ui/payments';\nimport { formatCurrency } from '@forgeroute/ui/utils';\nimport { SquarePaymentComponent } from '../square-payment/square-payment.component';\nimport { SquareTerminalPaymentComponent, type SquareTerminalSucceededEvent } from '../square-terminal/square-terminal-payment.component';\nimport { SQUARE_TERMINAL_POLL_MS } from '../square-terminal/square-terminal.flow';\nimport { paymentBaseAmount, type SquareTerminalReadinessState } from '../square-terminal/square-terminal.models';\nimport type { SquareFailure } from '../square-payment/square-outcomes';\nimport type { SquarePaymentMethodComponent } from './payment-square-method.component';\nimport { SQUARE_METHOD_TEXTS, squareMethodOf, squareOutcomeOf, type SquareFees, type SquarePaymentContext, type SquarePaymentResult } from './payment-square-method.models';\n\n/** The body `ui-square-payment-method` hands to the panel: the Square form, the fee rows and the whole flow (tokenize, host callback, outcome), talking to the panel through `ctx`. */\n@Component({\n selector: 'ui-payment-square-body',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n imports: [FormsModule, AlertComponent, ButtonComponent, HintComponent, KpiCardComponent, PaymentAttemptStatusComponent, RadioGroupComponent, SquarePaymentComponent, SquareTerminalPaymentComponent],\n template: `\n <div class=\"psq\">\n @if (confirmation(); as notice) {\n <ui-alert variant=\"success\" [title]=\"notice.title\" tabindex=\"-1\" class=\"psq-notice\" data-testid=\"square-method-confirmation\">\n <p>{{ notice.message }}</p>\n <p>{{ receiptNote() }}</p>\n </ui-alert>\n } @else {\n <!-- the region stays in the DOM (only its content toggles) so a screen reader announces the reason when it appears -->\n <div role=\"status\" aria-live=\"polite\" class=\"psq-blocked\" data-testid=\"square-method-blocked-status\">\n @if (blockedMessage(); as reason) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"square-method-blocked\">{{ reason }}</ui-alert>\n }\n </div>\n @if (readerEnabled()) {\n @if (!readerPaid()) {\n <!-- a refused switch re-creates the group (new epoch) so the radio shows the mode that is really in effect -->\n @for (epoch of [modeEpoch()]; track epoch) {\n <ui-radio-group class=\"psq-mode\" [label]=\"labels.t('stripeReader.mode.label')\" [options]=\"modeOptions()\" orientation=\"horizontal\" [ngModel]=\"modeShown()\" (ngModelChange)=\"chooseMode($event)\"\n [disabled]=\"modeLocked()\" data-testid=\"square-reader-mode\" />\n }\n @if (modeBlocked()) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" class=\"psq-mode-blocked\" data-testid=\"square-reader-mode-blocked\">{{ labels.t(modeBlockedWhy() === 'manual-pending' ? 'stripeReader.mode.blockedManual' : 'stripeReader.mode.blocked') }}</ui-alert>\n }\n }\n <ui-square-terminal-payment [active]=\"mode() === 'reader'\" [amount]=\"ctx().amount\" [currency]=\"ctx().currency\" [payableRef]=\"config().payableRef()\" [paid]=\"config().paid()\"\n [startExtras]=\"readerExtras()\" [getReadiness]=\"reader()!.getReadiness\" [startPayment]=\"reader()!.startPayment\" [getPayment]=\"reader()!.getPayment\" [retryPayment]=\"reader()!.retryPayment\"\n [cancelPayment]=\"reader()!.cancelPayment\" [estimateFees]=\"reader()!.estimateFees\" [receiptUrl]=\"reader()!.receiptUrl ?? null\"\n [offlineOverride]=\"config().offlineOverride()\" [beforeStart]=\"beforeReaderStart\" [manualAvailable]=\"true\" [disabled]=\"isBlocked()\" [hideBanner]=\"!!ctx().readerBanner\" [pollMs]=\"readerPollMs()\"\n (manual)=\"onReaderManual()\" (connectReader)=\"config().readerConnect.emit()\" (getReader)=\"config().readerOrder.emit()\" (openSetup)=\"config().readerSetup.emit()\"\n (succeeded)=\"onReaderPaid($event)\" (readinessChange)=\"onReaderReadiness($event)\" (busyChange)=\"onReaderBusy($event)\" />\n @if (readerPaid()) {\n <ui-kpi-card class=\"psq-total\" data-testid=\"square-reader-paid-total\" [label]=\"labels.t('squarePaymentMethod.paymentAmount')\" [value]=\"readerPaidAmountText()\" icon=\"dollar\" color=\"blue\" valueColor=\"blue\" />\n }\n }\n @if (showManual()) {\n <ui-payment-attempt-status [attempt]=\"attempt\" [readiness]=\"readiness\" [allowStartOver]=\"config().allowStartOver()\" [showPaid]=\"!confirmation() && !done()\" (retryLoad)=\"payment()?.reset()\" />\n @if (ctx().amount == null) {\n <ui-hint data-testid=\"square-method-amount-needed\">{{ texts.amountNeeded }}</ui-hint>\n }\n @if (estimateError()) {\n <div class=\"psq-error\">\n <ui-alert variant=\"warning\" data-testid=\"square-method-estimate-error\">{{ estimateError() }}\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"square-method-estimate-retry\" (click)=\"retryEstimate()\">{{ labels.t('common.tryAgain') }}</ui-button>\n </ui-alert>\n </div>\n }\n @if (lastAmount() != null) {\n <ui-square-payment #payment mode=\"payment\" [method]=\"squareMethod()\" [applicationId]=\"config().applicationId()\" [locationId]=\"config().locationId()\" [environment]=\"config().environment()\"\n [amount]=\"chargedAmount()\" [currency]=\"ctx().currency\" [billingContact]=\"config().billingContact()\" [accountHolderName]=\"config().accountHolderName()\"\n [requireAchConsent]=\"config().requireAchConsent()\" [cardStyle]=\"config().cardStyle()\" [styleFromTokens]=\"true\" [showSubmit]=\"false\" [showErrors]=\"false\"\n [showStatus]=\"false\" [offlineOverride]=\"config().offlineOverride()\" [disabled]=\"processing() || done() || attempt.unknown() || attempt.paidLocked()\" [label]=\"labels.t('squarePaymentMethod.paymentDetails')\" (ready)=\"onReady()\" (failed)=\"onFailed($event)\" (loadError)=\"onFailed($event)\" />\n @if (totalCard(); as card) {\n <ui-kpi-card class=\"psq-total\" data-testid=\"square-method-total\" [label]=\"labels.t('squarePaymentMethod.totalCharged')\" [value]=\"card.value\" [subtitle]=\"card.subtitle\" icon=\"dollar\" color=\"blue\" valueColor=\"blue\" />\n }\n @if (feeRows().length) {\n <dl class=\"psq-fees\" data-testid=\"square-method-fees\" [attr.aria-label]=\"labels.t('squarePaymentMethod.paymentTotal')\">\n @for (row of feeRows(); track row.key) {\n <div class=\"psq-fee\" [attr.data-testid]=\"'square-fee-' + row.key\"><dt>{{ row.label }}</dt><dd>{{ row.value }}</dd></div>\n }\n </dl>\n }\n @if (error()) { <div class=\"psq-error\"><ui-alert variant=\"danger\" data-testid=\"square-method-error\">{{ error() }}</ui-alert></div> }\n }\n }\n }\n </div>\n `,\n styles: [`\n ui-payment-square-body { display: block; min-width: 0; }\n ui-payment-square-body .psq-error { margin-top: 12px; }\n ui-payment-square-body .psq-mode, ui-payment-square-body .psq-mode-blocked, ui-payment-square-body .psq-blocked { display: block; margin-bottom: 12px; }\n ui-payment-square-body .psq-blocked:empty { display: none; }\n ui-payment-square-body .psq-total { display: block; margin-top: 16px; }\n ui-payment-square-body .psq-fees { margin: 16px 0 0; padding: 14px 16px; border: 1px solid var(--ui-psp-border, #e2e8f0); border-radius: 10px; font-size: 0.8125rem; }\n ui-payment-square-body .psq-fee { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; color: var(--ui-psp-muted, #475569); }\n ui-payment-square-body .psq-fee dt, ui-payment-square-body .psq-fee dd { margin: 0; }\n ui-payment-square-body .psq-notice:focus { outline: none; }\n ui-payment-square-body .psq-notice p { margin: 0 0 6px; }\n `],\n})\nexport class PaymentSquareBodyComponent {\n protected readonly labels = inject(UiLabelsService);\n private readonly injector = inject(Injector);\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n readonly ctx = input.required<PaymentMethodContext>();\n readonly config = input.required<SquarePaymentMethodComponent>();\n private readonly payment = viewChild(SquarePaymentComponent);\n private readonly readerView = viewChild(SquareTerminalPaymentComponent);\n\n // ── Square Terminal (card reader) mode (opt-in: only with `[reader]` on the plugin and the method Card) ──\n protected readonly reader = computed(() => this.config().reader());\n protected readonly readerEnabled = computed(() => !!this.reader() && this.ctx().method === 'CARD');\n /** The last readiness state the reader screen reported (`null` = no answer / failed). */\n readonly readerState = signal<SquareTerminalReadinessState | null>(null);\n private readerAnswered = false;\n /** The payer's choice. `null` until the FIRST readiness answer: then the Terminal when it is ready (and `readerFirst`), else manual. Never changes by itself after that. */\n readonly choice = signal<'reader' | 'manual' | null>(null);\n protected readonly modeShown = signal<string>('manual');\n /** The Terminal payment that was taken (the success box and \"Done\" show). */\n readonly readerPaid = signal<SquareTerminalSucceededEvent | null>(null);\n private readerBusy = false;\n private readerAttemptKey: string | undefined;\n readonly mode = computed((): 'reader' | 'manual' => (this.readerEnabled() ? (this.choice() ?? 'manual') : 'manual'));\n /** The Square form shows (manual card): no Terminal, or manual chosen after the first readiness answer. */\n protected readonly showManual = computed(() => !this.readerEnabled() || (this.choice() === 'manual'));\n protected readonly readerActive = computed(() => this.readerEnabled() && this.mode() === 'reader');\n protected readonly modeOptions = computed(() => [\n { value: 'reader', label: this.labels.t('stripeReader.mode.reader'), testId: 'square-reader-mode-reader' },\n { value: 'manual', label: this.labels.t('stripeReader.mode.manual'), testId: 'square-reader-mode-manual' },\n ]);\n protected readonly modeLocked = computed(() => this.processing() || this.done() || this.switching() || this.isBlocked());\n protected readonly readerPollMs = computed(() => this.config().readerPollMs() ?? this.reader()?.pollMs ?? SQUARE_TERMINAL_POLL_MS);\n /** Blocked by the plugin's own `[blocked]` or by the panel's (`ctx.blocked`). */\n protected readonly isBlocked = computed(() => this.config().blocked() || !!this.ctx().blocked);\n protected readonly blockedMessage = computed(() => (this.config().blocked() && !this.ctx().blocked && !this.done() && !this.readerPaid() && !this.confirmation()\n ? (this.config().blockedReason().trim() || this.labels.t('paymentBlocked.default')) : ''));\n private readonly switching = signal(false);\n protected readonly modeBlocked = signal(false);\n protected readonly modeBlockedWhy = signal<'reader-open' | 'manual-pending'>('reader-open');\n protected readonly modeEpoch = signal(0);\n protected readonly readerExtras = computed(() => { const c = this.ctx(); return { receivedDate: c.receivedDate, notes: c.note || null, allocation: c.allocation }; });\n /** Called by the Terminal screen's Send button: the panel's fields must be valid (and show their messages). */\n protected readonly beforeReaderStart = (): boolean => this.ctx().validate();\n protected readonly readerPaidAmountText = computed(() => { const e = this.readerPaid(); return e ? formatCurrency(e.amount, { currency: this.ctx().currency }) : ''; });\n\n protected readonly texts = SQUARE_METHOD_TEXTS;\n\n readonly ready = signal(false);\n readonly processing = signal(false);\n /** The payment was accepted (the panel was told, or the notice is up): Pay stays off even if the host keeps the panel open. */\n readonly done = signal(false);\n readonly error = signal('');\n /** The service gave an answer a retry cannot change (see `isFinalPaymentRefusal`), for THIS method, payable and amount: the text stays and Pay stays off until one of them changes (then the refusal and its text are cleared for good; it comes back only if the service answers it again). */\n readonly finalRefusal = signal<{ method: string; ref: string | null; amount: number } | null>(null);\n /** Fees from the host's estimate (before the payer pays). */\n readonly estimate = signal<SquareFees | null>(null);\n private readonly estimating = signal(false);\n protected readonly estimateError = signal('');\n private readonly estimateTick = signal(0);\n /** Fees the host answered when it created the payment. */\n private readonly resultFees = signal<SquareFees | null>(null);\n protected readonly confirmation = signal<{ title: string; message: string } | null>(null);\n /** The last valid amount: the form stays mounted (and keeps the typed card data) while the amount is briefly empty or invalid. */\n protected readonly lastAmount = signal<number | null>(null);\n /** What the attempt was STARTED with (pinned at the click; a later amount edit or method change never changes what is recorded). */\n private payAmount: number | null = null;\n private payMethod: string | null = null;\n /** What the payment that was RECORDED (or accepted) was made with: a late answer of an older attempt is recorded with ITS OWN amount and method, never the newest click's. */\n private doneAmount: number | null = null;\n private doneMethod: string | null = null;\n private estimateRun = 0;\n\n private readonly amountValue = computed(() => this.ctx().amount);\n private readonly methodValue = computed(() => this.ctx().method);\n protected readonly squareMethod = computed(() => squareMethodOf(this.ctx().method));\n private readonly total = computed(() => this.resultFees()?.totalAmount ?? this.estimate()?.totalAmount ?? this.lastAmount() ?? 0);\n /** What the card is actually charged (amount + fees the host showed): the amount Square's buyer verification must be asked for. Falls back to the entered amount. */\n protected readonly chargedAmount = computed(() => this.estimate()?.totalAmount ?? this.resultFees()?.totalAmount ?? this.lastAmount());\n protected readonly receiptNote = computed(() => this.config().receiptNote());\n protected readonly feeRows = computed(() => {\n const fees = this.resultFees() ?? this.estimate();\n const amount = this.lastAmount();\n if (!fees || amount == null || (fees.processingFee === undefined && fees.platformFee === undefined)) return [];\n const money = (n: number) => formatCurrency(n, { currency: this.ctx().currency });\n const rows: { key: string; label: string; value: string }[] = [{ key: 'amount', label: this.labels.t('squarePaymentMethod.paymentAmount'), value: money(amount) }];\n if (fees.processingFee !== undefined) rows.push({ key: 'processing', label: `${this.labels.t('squarePaymentMethod.processingFee')}${fees.processingFeeLabel ? ` (${fees.processingFeeLabel})` : ''}`, value: money(fees.processingFee) });\n if (fees.platformFee !== undefined) rows.push({ key: 'platform', label: `${this.labels.t('squarePaymentMethod.platformFee')}${fees.platformFeeLabel ? ` (${fees.platformFeeLabel})` : ''}`, value: money(fees.platformFee) });\n return rows;\n });\n /** The headline figure: what the payer is charged, once fees are known. */\n protected readonly totalCard = computed(() => {\n const fees = this.resultFees() ?? this.estimate();\n if (!fees || this.lastAmount() == null || fees.totalAmount === undefined) return null;\n return { value: formatCurrency(fees.totalAmount, { currency: this.ctx().currency }), subtitle: this.labels.t('squarePaymentMethod.amountPlusFees') };\n });\n\n /** The duplicate-payment protection of this payment (lock, attempt key, unknown state) and its readiness gate, driven by the plugin's inputs. */\n readonly attempt: PaymentAttempt;\n readonly readiness: PaymentReadiness;\n private gone = false;\n\n constructor() {\n // offlineOverride is read once while the readiness gate is constructed, before the inputs are bound: an unset required input counts as \"no override\" until the config arrives.\n const configured = <T>(read: (config: SquarePaymentMethodComponent) => T) => computed(() => read(this.config()));\n const inputs: PaymentProtectionInputs = {\n payableRef: configured(c => c.payableRef()), attemptKey: configured(c => c.attemptKey()), checkStatus: configured(c => c.checkStatus()), paid: configured(c => c.paid()), hostPending: configured(c => c.hostPending()),\n statusPollMs: configured(c => c.statusPollMs()), statusPollMaxMs: configured(c => c.statusPollMaxMs()),\n statusCheckTimeoutMs: configured(c => c.statusCheckTimeoutMs()), statusFailGraceMs: configured(c => c.statusFailGraceMs()), authTimeoutMs: configured(c => c.authTimeoutMs()), readinessCheck: configured(c => c.readinessCheck()),\n readinessTimeoutMs: configured(c => c.readinessTimeoutMs()), readinessEveryMs: configured(c => c.readinessEveryMs()), offlineOverride: computed(() => { try { return this.config().offlineOverride(); } catch { return false; } }),\n };\n const protection = createPaymentProtection(inputs, {\n amount: () => this.ctx().amount,\n method: () => this.ctx().method,\n sdk: () => (this.payment()?.loadErrorText() ? 'blocked' : 'ok'),\n onOutcome: o => this.onAttemptOutcome(o),\n });\n this.attempt = protection.attempt;\n this.readiness = protection.readiness;\n inject(DestroyRef).onDestroy(() => { this.gone = true; });\n // The host resolves an undecided attempt through the plugin component (markSucceeded / markFailed / markNotCharged / markUnknown), without a status check.\n const controls: PaymentAttemptControls = {\n markUnknown: () => this.attempt.markUnknown('host'),\n markSucceeded: () => this.attempt.succeed('host'),\n markFailed: () => this.attempt.fail('host'),\n resetPaid: () => { this.attempt.resetPaid(); this.readerView()?.attempt.resetPaid(); this.readerPaid.set(null); this.done.set(false); this.confirmation.set(null); this.error.set(''); this.ctx().setExclusive(false); },\n markNotCharged: () => { this.attempt.markNotCharged(); this.payment()?.markNotCharged(); this.processing.set(false); this.ctx().setBusy(false); this.ctx().flowOver?.(); },\n };\n // The controls are handed to the plugin that is bound NOW and taken back from that same one when the binding changes or the body is destroyed. (Reading `this.config()` in a destroy callback threw NG0950 when the body\n // was destroyed before its required config input was ever bound, which aborted the rest of the view's cleanups.)\n effect(onCleanup => {\n const config = this.config();\n untracked(() => config.attachControls(controls));\n onCleanup(() => config.detachControls(controls));\n });\n effect(() => { const amount = this.amountValue(); if (amount != null) untracked(() => this.lastAmount.set(amount)); });\n // A final refusal belongs to the method, payable and amount it was raised for: when one of them changes the refusal and its text are cleared (and stay cleared unless the service answers it again).\n effect(() => {\n const scope = this.finalRefusal();\n if (!scope) return;\n const ctx = this.ctx();\n if (ctx.method !== scope.method || ctx.amount !== scope.amount || this.config().payableRef() !== scope.ref) untracked(() => { this.finalRefusal.set(null); this.error.set(''); });\n });\n // The panel's footer button for this method.\n effect(() => {\n const ctx = this.ctx();\n const processing = this.processing();\n const notice = this.confirmation();\n const ready = this.ready();\n const estimating = this.estimating();\n const done = this.done();\n const estimateFailed = !!this.estimateError();\n const unknown = this.attempt.unknown();\n const paidLocked = this.attempt.paidLocked();\n const finalRefusal = !!this.finalRefusal();\n const gateReady = this.readiness.ready();\n const readerActive = this.readerActive();\n const readerPaid = this.readerPaid();\n const blocked = this.isBlocked();\n const label = notice ? this.labels.t('common.done') : ctx.amount != null ? `${this.labels.t('squarePaymentMethod.pay')} ${formatCurrency(this.total(), { currency: ctx.currency })}` : this.labels.t('squarePaymentMethod.pay');\n // Terminal mode: the Terminal screen has its own buttons (Send / Cancel); after a Terminal payment only \"Done\" shows.\n if (readerPaid) { untracked(() => ctx.setPrimary({ label: this.labels.t('common.done'), disabled: done, onClick: () => this.finish() })); return; }\n if (readerActive) { untracked(() => ctx.setPrimary(null)); return; }\n untracked(() => ctx.setPrimary({\n label, loading: processing && !notice,\n disabled: notice ? done : !ready || processing || estimating || estimateFailed || ctx.amount == null || done || unknown || paidLocked || finalRefusal || !gateReady || blocked,\n onClick: () => (notice ? this.finish() : void this.pay()),\n }));\n });\n // Estimated fees, debounced (display only: Square's form is not created for an amount).\n effect((onCleanup) => {\n const estimate = this.config().estimateFees();\n const amount = this.amountValue();\n const method = this.methodValue();\n const readerActive = this.readerActive();\n // Before the FIRST readiness answer nothing is estimated (the ONLINE quote would be asked for a payer who may pay on the Terminal).\n const modePending = this.readerEnabled() && this.choice() === null;\n this.estimateTick();\n const run = ++this.estimateRun; // any change makes an answer that is still on its way stale\n untracked(() => { this.estimate.set(null); this.resultFees.set(null); this.estimateError.set(''); });\n if (!estimate || amount == null || readerActive || modePending) { untracked(() => this.estimating.set(false)); return; }\n untracked(() => this.estimating.set(true));\n let hung: ReturnType<typeof setTimeout> | null = null;\n const failure = this.labels.t('squarePaymentMethod.feesFailed');\n const timer = setTimeout(async () => {\n // A hung estimate must not block the user forever: after the timeout \"Try again\" is offered (and Pay stays off when fees are required). A late answer still recovers.\n hung = setTimeout(() => {\n if (run !== this.estimateRun) return;\n this.estimating.set(false);\n if (this.feesMustBeKnown()) this.estimateError.set(failure);\n }, Math.max(1, this.config().estimateTimeoutMs()));\n let fees: SquareFees | null = null;\n try { fees = (await callHost(() => estimate({ amount, paymentMethod: method, method: squareMethodOf(method), funding: null }))) ?? null; } catch { fees = null; }\n if (hung) { clearTimeout(hung); hung = null; }\n if (run !== this.estimateRun) return;\n this.estimating.set(false);\n if (fees) { this.estimate.set(fees); this.estimateError.set(''); }\n else { this.estimate.set(null); this.estimateError.set(this.feesMustBeKnown() ? failure : ''); }\n }, 300);\n onCleanup(() => { clearTimeout(timer); if (hung) clearTimeout(hung); });\n });\n // A new form is built for another method, or for another application / location / environment: it is not ready until Square says so (Pay stays off meanwhile).\n effect(() => {\n this.methodValue();\n const config = this.config();\n config.applicationId(); config.locationId(); config.environment();\n untracked(() => { this.ready.set(false); this.error.set(''); });\n });\n // A new method starts the Terminal choice again (the first readiness answer decides the default).\n effect(() => { this.methodValue(); untracked(() => { this.choice.set(null); this.readerState.set(null); this.readerAnswered = false; }); });\n // The panel tells us when it is closing or the method changes before this body is removed: an accepted payment whose notice is still up is reported as recorded.\n effect(() => { const ctx = this.ctx(); untracked(() => ctx.onCancel(() => {\n // The panel clears the close guard when it runs this hook: the guard is registered again, or a panel that stays open (a reset) would let the payment be abandoned.\n this.registerCloseGuard(ctx);\n if (this.readerPaid()) { this.finish(); return; }\n const view = this.readerView();\n if (view?.isLocked()) { view.cancelBestEffort(); return; }\n if (this.confirmation()) this.finish();\n })); });\n // The panel asks before it closes: a payment that waits on a Terminal must be canceled first.\n effect(() => { const ctx = this.ctx(); untracked(() => this.registerCloseGuard(ctx)); });\n // The panel's top banner (`ctx.readerBanner`) never steps aside; this screen draws no reader banner of its own then (`hideBanner`), so exactly ONE banner per state.\n effect(() => { const mode = this.mode(); const pending = this.readerEnabled() && this.choice() === null; untracked(() => { this.modeShown.set(pending ? '' : mode); }); });\n inject(DestroyRef).onDestroy(() => { this.estimateRun++; });\n // The body is going away: a Terminal payment that was open MAY STILL EXIST at the processor, so the host hears `readerLeftPending` (never \"idle\").\n inject(DestroyRef).onDestroy(() => this.leaveReaderPending('destroyed'));\n // The Terminal screen is removed while a payment is open on it (the reader was switched off, or the method left Card): the same rule applies.\n effect(() => { const enabled = this.readerEnabled(); untracked(() => { if (!enabled && this.readerBusy) this.leaveReaderPending('unmounted'); }); });\n }\n\n // ── Terminal handlers ──\n\n private registerCloseGuard(ctx: PaymentMethodContext): void {\n ctx.setCloseGuard?.(() => {\n const view = this.readerView();\n const wasOpen = !!view?.isLocked();\n const allowed = view?.requestClose() ?? true;\n // The panel may close while the start answer is still on its way (starting / recovering): the payment is not canceled, so the host hears which attempt is left open.\n if (allowed && wasOpen) ctx.report('reader-left-pending', { ...(this.readerAttemptKey ? { attemptKey: this.readerAttemptKey } : {}) });\n return allowed;\n });\n }\n\n /** A Terminal payment that MAY STILL EXIST is let go of: never reported idle. The host hears `readerLeftPending` (and a panel hears `ctx.leavePending`). Once per busy period. */\n private leaveReaderPending(reason: 'destroyed' | 'unmounted'): void {\n if (!this.readerBusy) return;\n this.readerBusy = false;\n const paymentAttemptKey = this.readerAttemptKey;\n try { this.config().readerLeftPending.emit({ reason, ...(paymentAttemptKey ? { paymentAttemptKey } : {}) }); } catch { /* the plugin is already gone */ }\n if (reason === 'unmounted') { try { this.ctx().leavePending?.({ reason: 'unmounted', ...(paymentAttemptKey ? { paymentAttemptKey } : {}) }); } catch { /* the panel is already gone */ } }\n }\n\n /** The Terminal screen read the readiness. The FIRST answer decides the default: the Terminal when it is ready, else manual. */\n protected onReaderReadiness(state: SquareTerminalReadinessState | null): void {\n const previous = this.readerState();\n const answeredBefore = this.readerAnswered;\n this.readerAnswered = true;\n this.readerState.set(state);\n // The panel's top banner is the only reader banner on screen: when this screen's own read sees the state CHANGE the top banner reads again.\n if (answeredBefore && state !== null && previous !== state && this.ctx().readerBanner) { try { this.ctx().refreshReaderBanner?.(); } catch { /* the panel is already gone */ } }\n if (this.choice() === null) this.choice.set(state === 'reader_ready' && this.config().readerFirst() ? 'reader' : 'manual');\n }\n\n /** A Terminal payment is open: everything else is locked (fields, method, the manual form). */\n protected onReaderBusy(locked: boolean): void {\n if (locked === this.readerBusy) return;\n this.readerBusy = locked;\n if (locked) {\n try { this.readerAttemptKey = this.readerView()?.attempt.key() || undefined; } catch { this.readerAttemptKey = undefined; }\n this.config().rememberAttempt(this.readerAttemptKey, 'reader', this.ctx().amount ?? undefined);\n }\n this.config().readerBusyChange.emit(locked);\n if (!locked) this.modeBlocked.set(false);\n // A Terminal payment is open (started here, or found again after a reload / in a second tab): its screen is the one to show, never the manual form behind it.\n else if (this.choice() !== 'reader') this.choice.set('reader');\n this.ctx().setBusy(locked);\n if (!locked) this.ctx().flowOver?.();\n }\n\n /** The payer picks Terminal or manual. Leaving the Terminal while a payment waits first cancels it THROUGH THE HOST; only when the service confirmed it does the manual form open. */\n protected async chooseMode(next: string | null): Promise<void> {\n const target = next === 'reader' ? 'reader' : 'manual';\n if (this.switching() || (target === this.mode() && this.choice() !== null)) return;\n this.modeBlocked.set(false);\n if (target === 'manual') {\n const view = this.readerView();\n if (view?.isLocked()) {\n this.switching.set(true);\n let canceled = false;\n try { canceled = await view.cancelAndWait(); } finally { this.switching.set(false); }\n if (!canceled) { this.refuseSwitch('reader-open'); return; }\n this.ctx().flowOver?.();\n }\n } else if (this.processing() || this.attempt.unknown()) { this.refuseSwitch('manual-pending'); return; }\n this.choice.set(target);\n }\n\n private refuseSwitch(why: 'reader-open' | 'manual-pending'): void {\n this.modeBlockedWhy.set(why);\n this.modeBlocked.set(true);\n this.modeEpoch.update(n => n + 1);\n this.modeShown.set(this.mode());\n afterNextRender(() => this.host.nativeElement.querySelector<HTMLElement>('[data-testid=\"square-reader-mode\"] input:checked')?.focus(), { injector: this.injector });\n }\n\n /** The Terminal screen asked for the manual form (its payment is already canceled or never started). */\n protected onReaderManual(): void { this.choice.set('manual'); this.ctx().flowOver?.(); }\n\n /** The Terminal took the payment: reported like any live payment; \"Done\" completes the panel. */\n protected onReaderPaid(event: SquareTerminalSucceededEvent): void {\n if (this.done() || this.readerPaid()) return;\n const ctx = this.ctx();\n // Never reported as 0 while any amount is known: the event's, else the payment's own base amount, else what the panel says now, else the last amount it said.\n const amount = event.amount > 0 ? event.amount : (paymentBaseAmount(event.payment) ?? ctx.amount ?? this.lastAmount() ?? event.amount);\n this.readerPaid.set({ ...event, amount });\n this.doneAmount = amount;\n this.doneMethod = ctx.method;\n ctx.report('paid', { result: { type: 'stripe', paymentMethod: ctx.method, amount, processor: 'square' } });\n ctx.setExclusive(true);\n ctx.setBusy(false);\n if (this.readerBusy) { this.readerBusy = false; this.config().readerBusyChange.emit(false); }\n }\n\n /**\n * Pay stays off while an estimate that was asked for failed when the payer covers fees (`feesRequired`) OR when buyer verification is on (`billingContact`): the verification is\n * done for the charged total, so a failed estimate would verify the base amount while the host may still add fees (Square then declines with a verification error).\n */\n private feesMustBeKnown(): boolean { return this.config().feesRequired() || !!this.config().billingContact(); }\n\n protected retryEstimate(): void { this.estimateTick.update(n => n + 1); }\n\n protected onReady(): void {\n this.ready.set(true);\n this.ctx().announce(this.labels.t('squarePaymentMethod.announceReady'));\n }\n\n protected onFailed(failure: SquareFailure): void {\n // A failed buyer verification (3-D Secure) happened BEFORE any charge: the payer can try again, for the SAME total the Pay button shows.\n const message = failure.stage === 'verify' ? `${failure.message} ${this.labels.t('paymentAttempt.verifyRetry', { amount: formatCurrency(this.total(), { currency: this.ctx().currency }) })}` : failure.message;\n failure = { ...failure, message };\n this.error.set(failure.message); // shown in a role=alert ui-alert: that is the announcement\n this.processing.set(false);\n this.ctx().report('failed', { message: failure.message });\n }\n\n /**\n * Pays: the gate (paid / unknown / not ready / offline: nothing is sent), validates the panel, then ONE attempt under the synchronous lock: tokenizes the Square form and creates the\n * payment through the host with the attempt key. A timeout, going offline or an ambiguous host error makes the outcome UNKNOWN (locked, \"Checking your payment...\", status check by\n * key); only a definitive refusal unlocks with a new key. The component never retries a charge itself.\n */\n async pay(): Promise<void> {\n const ctx = this.ctx();\n const payment = this.payment();\n if (this.processing() || this.estimating() || this.done() || !payment || this.isBlocked()) return;\n if (this.refused(ctx)) return;\n if (!ctx.validate() || ctx.amount == null) return;\n this.payAmount = ctx.amount;\n this.payMethod = ctx.method;\n const attemptAmount: number = ctx.amount; // captured for THIS attempt: a late answer must not read the fields a newer click overwrote\n const attemptMethod: string = ctx.method;\n const create = this.config().createPayment();\n if (!create) { this.onFailed({ code: 'not_configured', message: this.labels.t('squarePaymentMethod.unavailable'), squareMessage: '', stage: 'tokenize' }); return; }\n this.error.set('');\n this.processing.set(true);\n ctx.setBusy(true);\n ctx.announce(this.labels.t('squarePaymentMethod.announceProcessing'));\n let finished = false;\n const run = await this.attempt.run<SquarePaymentResult | null>(async key => {\n // A LATE answer (the attempt moved on while this call was still running) must not touch the newer attempt's screen, error text, busy state or inner form: every side effect below asks `live()` first.\n const live = (): boolean => this.attempt.isLive(key);\n try {\n // The tokenization starts synchronously from the click (the bank window of an ACH payment needs the user gesture).\n if (squareMethodOf(attemptMethod) === 'ach') this.attempt.markPending('bank_window'); // the bank window may stay open for minutes: the request timeout is replaced by authTimeoutMs meanwhile\n const event = await payment.tokenize();\n if (!event) return { kind: 'released' }; // the form reported the failure (onFailed): nothing was charged\n if (this.gone) return { kind: 'released', reason: 'destroyed' }; // destroyed before the host call: NOTHING was sent, the marker must not outlive the page\n const request: SquarePaymentContext = {\n amount: attemptAmount, paymentMethod: attemptMethod, method: event.method, receivedDate: ctx.receivedDate, notes: ctx.note || null, ...ctx.allocation,\n token: event.token, details: event.details, funding: event.details.cardType, verificationToken: event.verificationToken, idempotencyKey: event.idempotencyKey, attemptKey: key, payableRef: this.attempt.pinnedRef(),\n };\n let result: SquarePaymentResult | null | undefined;\n try { result = await callHost(() => create(request)); } catch (err) { // after the panel closed (`this.gone`) the classification still decides and the core writes the records: there is no screen left to touch\n const kind = classifyHostError(err);\n if (kind === 'unknown') return { kind: 'unknown', reason: isAwaitingVerificationError(err) ? 'microdeposits' : 'host_error' }; // the open payment waits for the payer's bank verification: say so, never \"already processed\"\n // The reference / payment-link codes are worded in OUR (translated) words; a final one (the balance changed, the link was paid / ended, the processor cannot do it) keeps the text and turns Pay off instead of looping.\n const labelKey = paymentErrorLabelKey(err);\n const message = labelKey ? this.labels.t(labelKey) : hostErrorMessage(err, this.labels.t('squarePaymentMethod.paymentFailed'));\n if (live() && isFinalPaymentRefusal(err)) this.finalRefusal.set({ method: attemptMethod, ref: this.config().payableRef(), amount: attemptAmount });\n if (kind === 'not_sent') { // the request never left (offline layer): nothing was charged, the key is KEPT and the payer may try again\n if (live()) { this.error.set(message); ctx.report('refused', { message }); }\n return { kind: 'released', reason: 'not_sent' };\n }\n if (live()) { this.error.set(message); ctx.report('failed', { message }); }\n return { kind: 'failure', reason: 'host_refused' };\n }\n if (wasQueuedOffline(result)) { // the offline layer QUEUED the request instead of sending it (a synthetic 202): no payment exists, the key is KEPT\n warnQueuedPayment();\n const message = this.labels.t('paymentAttempt.queuedOffline');\n if (live()) { this.error.set(message); ctx.report('refused', { message }); }\n return { kind: 'released', reason: 'not_sent' };\n }\n if (this.gone) return { kind: squareOutcomeOf(result?.status, squareMethodOf(attemptMethod)) === 'failed' ? 'failure' : 'success', value: result ?? null, reason: 'created' }; // the panel closed meanwhile: the answer is still the payment's outcome (the core records it for the next form of the payable)\n finished = this.afterCreate(result ?? null, ctx, live(), attemptAmount, attemptMethod);\n return { kind: squareOutcomeOf(result?.status, squareMethodOf(attemptMethod)) === 'failed' ? 'failure' : 'success', value: result ?? null, reason: 'created' };\n } finally { if (live()) payment.markNotCharged(); } // the token was handed to the host: the INNER form's own lock ends with this attempt (never the lock of a NEWER attempt)\n }, { timeoutMs: this.config().paymentTimeoutMs() });\n this.processing.set(false);\n if ('refused' in run && run.refused) { ctx.setBusy(false); return; }\n if (run.kind === 'unknown') return; // stays locked (busy) until the status check, the host or a late answer resolves it\n if (!finished) ctx.setBusy(false);\n }\n\n /** Refuses to start (nothing is sent): a paid payable, an unknown earlier outcome, a failed readiness gate or being offline. Returns true when refused. */\n private refused(ctx: PaymentMethodContext): boolean {\n if (!this.readiness.passSync()) {\n const reason = this.readiness.reasons()[0] ?? 'checking';\n const message = this.labels.t(this.readiness.labelKeyFor(reason));\n this.error.set(message);\n ctx.report('refused', { message });\n ctx.announce(message);\n return true;\n }\n if (this.attempt.paidLocked() || this.attempt.unknown()) { this.attempt.begin(); return true; } // refuses and reports `refused`\n return false;\n }\n\n /** The attempt resolved OUTSIDE the click (a status check, the host's `markSucceeded` / `markFailed`, a late answer) or became unknown. */\n private onAttemptOutcome(outcome: PaymentAttemptOutcome): void {\n const ctx = this.ctx();\n if (outcome.kind === 'unknown' && outcome.reason === 'duplicate_suspected') {\n // A SECOND payment of a payable that is already paid: nothing about the lock, the amount or the method changes; the host is told (with the key of the second payment) so it can resolve it.\n const message = this.labels.t('paymentAttempt.duplicate');\n this.error.set(message);\n ctx.report('duplicate_suspected', { message, attemptKey: outcome.attemptKey });\n ctx.announce(message);\n } else if (outcome.kind === 'unknown') {\n this.payAmount = this.attempt.pinnedAmount() ?? this.payAmount; // the amount and method of the attempt that is UNKNOWN (an adopted one included), never a stale earlier one\n this.payMethod = this.attempt.pinnedMethod() ?? this.payMethod;\n const message = this.labels.t(outcome.reason === 'offline' ? 'paymentAttempt.offlineInFlight' : outcome.reason === 'timeout' ? 'paymentAttempt.timeout' : outcome.reason === 'microdeposits' || this.attempt.awaitingVerification() ? 'paymentAttempt.awaitingVerification' : 'paymentAttempt.checking'); // a reload / another tab that adopted a bank verification wait says so too\n ctx.report('unknown', { message });\n ctx.announce(message);\n } else if (outcome.kind === 'refused') {\n const refusedReason = outcome.reason ?? '';\n // `unknown` while a bank verification wait is on is the verification text, never \"Checking your payment...\"\n const refusedKey = refusedReason === 'unknown' && this.attempt.awaitingVerification() ? 'paymentAttempt.awaitingVerification' : this.readiness.labelKeyFor(refusedReason);\n ctx.report('refused', { message: this.labels.t(refusedKey) });\n } else if (outcome.kind === 'succeeded' && outcome.reason === 'other_tab') {\n // Another tab / page load paid this payable: this form only shows the paid lock. Nothing is recorded here (no `paid`, no `complete`): no money moved through THIS form and the amount typed here is not what was paid.\n // A host that wants to reconcile reads the paid attempt's key, amount and method from the report (and from the form's own `(outcome)`).\n ctx.report('paid_elsewhere', { message: this.labels.t('paymentAttempt.paid'), attemptKey: outcome.attemptKey, ...(outcome.method !== undefined ? { paid: { amount: outcome.amount ?? null, method: outcome.method } } : {}) });\n } else if (outcome.kind === 'succeeded' && (outcome.reason === 'status_check' || outcome.reason === 'host') && !this.done()) {\n const paid = { type: 'stripe' as const, paymentMethod: outcome.method ?? this.payMethod ?? ctx.method, amount: outcome.amount ?? this.payAmount ?? ctx.amount ?? this.lastAmount() ?? 0, processor: 'square' };\n this.doneAmount = paid.amount;\n this.doneMethod = paid.paymentMethod;\n ctx.report('paid', { result: paid });\n this.done.set(true);\n ctx.setBusy(false);\n ctx.complete(paid);\n } else if (outcome.kind === 'failed') {\n if (outcome.reason === 'status_check' || outcome.reason === 'host') {\n const message = this.labels.t('paymentAttempt.failedAfterCheck');\n this.error.set(message);\n ctx.report('failed', { message });\n }\n this.payment()?.markNotCharged(); // the attempt is decided: the INNER form's lock (kept while the host charged) ends with it, so a NEW attempt can tokenize even when the old request never answers\n ctx.setBusy(false); // also a LATE definitive refusal (the answer came after a timeout): the panel is free again\n }\n }\n\n private afterCreate(result: SquarePaymentResult | null, ctx: PaymentMethodContext, live: boolean, amount: number, method: string): boolean {\n if (this.done() || this.confirmation()) return true; // a status check or the host already recorded this payment: report it exactly once\n const money = formatCurrency(amount, { currency: ctx.currency });\n const outcome = squareOutcomeOf(result?.status, squareMethodOf(method));\n if (outcome === 'failed') {\n if (live) { // a late decline of an OLDER attempt says nothing on the newer attempt's screen\n const message = result?.failureMessage || this.texts.notCompleted;\n this.error.set(message);\n ctx.report('failed', { message });\n }\n return false;\n }\n if (live && result && (result.processingFee !== undefined || result.platformFee !== undefined || result.totalAmount !== undefined)) {\n this.resultFees.set({ processingFee: result.processingFee, platformFee: result.platformFee, totalAmount: result.totalAmount, processingFeeLabel: result.processingFeeLabel, platformFeeLabel: result.platformFeeLabel });\n }\n const paid = { type: 'stripe' as const, paymentMethod: method, amount, processor: 'square' };\n this.doneAmount = amount;\n this.doneMethod = method;\n if (outcome === 'paid') {\n ctx.report('paid', { result: paid });\n this.done.set(true);\n ctx.complete(paid);\n return true;\n }\n ctx.report('processing', { result: paid });\n this.confirmation.set(squareMethodOf(method) === 'ach'\n ? { title: this.texts.achTitle, message: this.texts.achMessage(money) }\n : { title: this.texts.pendingTitle, message: this.texts.pendingMessage(money) });\n ctx.setExclusive(true);\n ctx.setBusy(false);\n afterNextRender(() => this.host.nativeElement.querySelector<HTMLElement>('.psq-notice')?.focus(), { injector: this.injector });\n return true;\n }\n\n /** \"Done\" on the submitted notice, or closing the panel while the notice is up: the accepted payment is reported as recorded (once). */\n private finish(): void {\n const ctx = this.ctx();\n if (this.done()) return;\n this.done.set(true);\n ctx.complete({ type: 'stripe', paymentMethod: this.doneMethod ?? this.payMethod ?? ctx.method, amount: this.doneAmount ?? this.payAmount ?? ctx.amount ?? this.lastAmount() ?? 0, processor: 'square' });\n }\n}\n","import { ChangeDetectionStrategy, Component, DestroyRef, ViewEncapsulation, computed, effect, inject, input, output, signal, untracked } from '@angular/core';\nimport { AlertComponent } from '@forgeroute/ui/alert';\nimport { ButtonComponent, UiLabelsService } from '@forgeroute/ui/core';\nimport { builtInReadinessReasons, callHost, type PaymentReaderBannerConfig, type PaymentReaderState } from '@forgeroute/ui/payments';\nimport { normalizeReadiness, readerBannerReasonKey, type SquareTerminalGetReadinessFn, type SquareTerminalReadiness } from './square-terminal.models';\n\n/**\n * Gives a host without `ui-square-payment-method` in its panel the `[readerBanner]` config of `ui-payment-side-panel` (merchant not ready, collection off, no payable version: no plugin is rendered, but the banner must show).\n * With the plugin rendered a plain `{ getReadiness }` object is enough (the plugin supplies the component).\n *\n * readonly banner = computed(() => squareTerminalBannerConfig({ getReadiness: this.readiness, refreshKey: this.readersVersion() }));\n */\nexport function squareTerminalBannerConfig(config: Omit<PaymentReaderBannerConfig, 'component'>): PaymentReaderBannerConfig {\n return { ...config, component: SquareTerminalBannerComponent };\n}\n\n/**\n * The service states the banner shows: the organization has NO usable Terminal (`no_reader`, `unsupported_only`, `merchant_not_ready`) or HAS one that is not connected (`reader_offline`, `reader_pairing`: a pairing code was issued but not entered on the Terminal).\n * Busy, ready, checking and a failed read show nothing (busy means in use, never \"not connected\").\n */\nexport const SQUARE_TERMINAL_BANNER_STATES: readonly SquareTerminalReadiness['state'][] = ['no_reader', 'unsupported_only', 'merchant_not_ready', 'reader_offline', 'reader_pairing'];\n\n/** The banner states in which a Terminal exists but is not connected: the message \"Your Square Terminal is not connected.\" with the one action \"Connect Your Terminal\". */\nexport const SQUARE_TERMINAL_NOT_CONNECTED_STATES: readonly SquareTerminalReadiness['state'][] = ['reader_offline', 'reader_pairing'];\n\n/**\n * The Square Terminal banner: a SMALL `ui-alert` (info, one line, ONE action) for a STAFF place where a customer payment can be taken. Two situations show it:\n * - NO Terminal (`no_reader`, `unsupported_only`): \"Get a Square Terminal to take in-person card payments.\" with ONLY \"How to get one\" (`order`);\n * - a Terminal that is NOT CONNECTED (`reader_offline`, `reader_pairing`): \"Your Square Terminal is not connected.\" with ONLY \"Connect Your Terminal\" (`connect`);\n * - `merchant_not_ready`: payments must be set up first (`setup`).\n * It renders NOTHING in every other state (reader ready, busy = in use, still checking, a failed read, an offline browser): those belong to the reader screen the payment plugin shows when Card is chosen. `ui-payment-side-panel [readerBanner]` renders it as the first element of the panel. Never use it in a payer-facing component.\n *\n * <ui-square-terminal-banner [getReadiness]=\"readiness\" [refreshKey]=\"readersVersion()\" [hardwareShopAvailable]=\"canOrder()\" (connect)=\"openPairing()\" (order)=\"openOrder()\" (setup)=\"openSetup()\" />\n *\n * A readiness `reason` of `sandbox`, `service_disabled` or `processor_unsupported` (in any state the banner shows) gives its own plain message and NO button (see `SQUARE_TERMINAL_BANNER_REASONS`: \"Card readers are not available in a sandbox account.\", \"Card readers are turned off for this account.\", \"Card readers are not available with this payment processor.\"; Spanish in the dictionary); the banner still appears only in its listed states (no_reader, unsupported_only, merchant_not_ready, reader_offline, reader_pairing).\n * `hardwareShopAvailable` is ignored (always \"How to get one\"); `merchant_not_ready` says payments must be\n * set up first and offers \"Set up payments\" (\"Reconnect payments\" when the account must be reconnected; `setup`). The container is always in the DOM (it mounts when the panel opens, the host never gates anything on the read); the alert appears when the answer\n * arrives. The readiness is read FRESH on every start and every `refreshKey` change (and `refresh()`), never cached or polled; a failed or slow read (over `readinessTimeoutMs`) or an offline browser shows nothing and asks nothing more. No HTTP: the host's `getReadiness` calls its own backend.\n */\n@Component({\n selector: 'ui-square-terminal-banner',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n // the host is `hidden` (display: none) while the banner shows nothing, so a flex / gap parent (the payment panel) leaves no empty gap\n host: { '[hidden]': '!shown()' },\n imports: [AlertComponent, ButtonComponent],\n template: `\n <div class=\"srb\" data-testid=\"reader-banner\" [attr.data-state]=\"shownState()\">\n @if (shown(); as r) {\n <ui-alert variant=\"info\" [quiet]=\"true\" data-testid=\"reader-banner-message\">\n <span class=\"srb-line\">{{ message() }}</span>\n @if (!reasonKey()) {\n <!-- a sandbox / service-off / unsupported-processor reason has no action: only the message -->\n <span class=\"srb-actions\">\n @if (r.state === 'merchant_not_ready') {\n <ui-button variant=\"link\" size=\"sm\" data-testid=\"reader-banner-setup\" (click)=\"setup.emit()\">{{ labels.t(r.reason === 'reconnect_required' ? 'stripeReader.status.reconnect' : 'stripeReader.status.setup') }}</ui-button>\n } @else if (notConnected()) {\n <!-- a Terminal exists but is not connected (offline, or its pairing code was not entered yet): the ONLY action is to connect it -->\n <ui-button variant=\"link\" size=\"sm\" data-testid=\"reader-banner-connect\" (click)=\"connect.emit()\">{{ labels.t('squareTerminal.status.connectYours') }}</ui-button>\n } @else {\n <!-- no Terminal yet: the ONLY action is how to get one (pairing a Terminal the seller already owns lives in the host's Terminals screen, never in this banner) -->\n <ui-button variant=\"link\" size=\"sm\" data-testid=\"reader-banner-get\" (click)=\"order.emit()\">{{ labels.t('squareTerminal.status.getInfo') }}</ui-button>\n }\n </span>\n }\n </ui-alert>\n }\n </div>\n `,\n styles: [`\n ui-square-terminal-banner { display: block; min-width: 0; }\n ui-square-terminal-banner[hidden] { display: none; }\n ui-square-terminal-banner .srb-line { margin-right: 8px; }\n ui-square-terminal-banner .srb-actions { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; }\n `],\n})\nexport class SquareTerminalBannerComponent {\n protected readonly labels = inject(UiLabelsService);\n private readonly destroyRef = inject(DestroyRef);\n\n /** The host's readiness call (`GET /v1/terminal/readiness`, through its own backend). Called FRESH every time. */\n readonly getReadiness = input<SquareTerminalGetReadinessFn | null>(null);\n /** Any value that changes when the host knows the readers changed (a reader was connected, an order was placed): every change reads the readiness again. */\n readonly refreshKey = input<unknown>(null);\n /** Kept for backward compatibility: Square sells no Terminal in the app, so the action is always \"How to get one\" (`order`, the host opens an info card) and this input changes nothing. */\n readonly hardwareShopAvailable = input(true);\n /** Kept for backward compatibility: there is no connected line any more, so it changes nothing. */\n readonly hideReady = input(false);\n /** A read slower than this shows nothing (ms). */\n readonly readinessTimeoutMs = input(4000);\n /** Managed environments where `navigator.onLine === false` is a false negative: do not treat the browser's offline flag as offline (default false). */\n readonly offlineOverride = input(false);\n /** `true` while the banner is kept but not shown (the panel hides it after a payment was taken): it asks the host nothing; shown again it reads once only if a read was asked for meanwhile. */\n readonly paused = input(false);\n\n /** \"Connect Your Terminal\" (a Terminal that is not connected): the host opens its pairing screen. */\n readonly connect = output<void>();\n /** \"Get a card reader\" / \"How to get a card reader\": the host opens its order flow or an info card. */\n readonly order = output<void>();\n /** \"Set up payments\" / \"Reconnect payments\": the host opens payment setup. */\n readonly setup = output<void>();\n /** The banner's readiness state whenever it changes (`{ state, stale, at, ready }`; `state` is `checking` when the last read failed; never `unknown`). `ui-payment-side-panel` re-emits it as `(readerState)`. */\n readonly stateChange = output<PaymentReaderState>();\n\n private readonly confirmed = signal<{ readiness: SquareTerminalReadiness; at: Date } | null>(null);\n private readonly failed = signal(false);\n private readonly offline = signal(false);\n private run = 0;\n private destroyed = false;\n private readWhenShown = false;\n\n /** The answer on screen: only a CONFIRMED, latest answer in which the organization has no usable reader. */\n protected readonly shown = computed((): SquareTerminalReadiness | null => {\n const c = this.confirmed();\n return c && !this.failed() && !this.offline() && SQUARE_TERMINAL_BANNER_STATES.includes(c.readiness.state) ? c.readiness : null;\n });\n readonly shownState = computed(() => this.shown()?.state ?? 'none');\n /** A Terminal exists but is not connected (`reader_offline`, `reader_pairing`). */\n protected readonly notConnected = computed(() => SQUARE_TERMINAL_NOT_CONNECTED_STATES.includes(this.shown()?.state as SquareTerminalReadiness['state']));\n /** The label key of a reason with its own no-button wording (`sandbox`, `service_disabled`, `processor_unsupported`), else null. Never for a not-connected Terminal (its message is about the Terminal). */\n protected readonly reasonKey = computed(() => (this.notConnected() ? null : readerBannerReasonKey(this.shown()?.reason)));\n protected readonly message = computed(() => this.labels.t(this.reasonKey() ?? (this.notConnected() ? 'squareTerminal.banner.notConnected' : this.shown()?.state === 'merchant_not_ready' ? 'squareTerminal.banner.setupFirst' : 'squareTerminal.banner.getReader')));\n\n constructor() {\n this.destroyRef.onDestroy(() => { this.destroyed = true; });\n const syncOffline = (): void => { this.offline.set(builtInReadinessReasons(this.offlineOverride()).includes('offline')); };\n if (typeof window !== 'undefined') {\n const update = (): void => { syncOffline(); untracked(() => { if (!this.offline()) void this.refresh(); }); };\n window.addEventListener('online', update);\n window.addEventListener('offline', update);\n this.destroyRef.onDestroy(() => { window.removeEventListener('online', update); window.removeEventListener('offline', update); });\n }\n effect(() => {\n const read = this.getReadiness();\n this.refreshKey();\n this.offlineOverride();\n untracked(() => { syncOffline(); if (read) void this.refresh(); });\n });\n effect(() => {\n const paused = this.paused();\n untracked(() => { if (!paused && this.readWhenShown) { this.readWhenShown = false; void this.refresh(); } });\n });\n effect(() => {\n const c = this.confirmed();\n const failed = this.failed();\n const next: PaymentReaderState | null = c && !failed ? { state: c.readiness.state, stale: false, at: c.at, ready: c.readiness.state === 'reader_ready' } : failed ? { state: 'checking', stale: true, at: null, ready: false } : null;\n untracked(() => { if (next) this.stateChange.emit(next); });\n });\n }\n\n /** Reads the readiness NOW. Never cached. A failed, slow or `checking` answer shows nothing; offline asks nothing. */\n async refresh(): Promise<void> {\n const read = this.getReadiness();\n if (!read || this.destroyed || this.offline()) return;\n if (untracked(() => this.paused())) { this.readWhenShown = true; return; }\n const run = ++this.run;\n let result: SquareTerminalReadiness | null = null;\n let timer: ReturnType<typeof setTimeout> | null = null;\n try {\n const timeout = new Promise<'timeout'>(resolve => { timer = setTimeout(() => resolve('timeout'), Math.max(1, this.readinessTimeoutMs())); });\n const raw = await Promise.race([callHost(() => read()), timeout]);\n result = raw === 'timeout' ? null : normalizeReadiness(raw);\n } catch { result = null; } finally { if (timer) clearTimeout(timer); }\n if (this.destroyed || run !== this.run) return;\n if (result && result.state !== 'checking') {\n const at = result.checkedAt ? new Date(result.checkedAt) : new Date();\n this.confirmed.set({ readiness: result, at: Number.isNaN(at.getTime()) ? new Date() : at });\n this.failed.set(false);\n } else {\n this.failed.set(true);\n }\n }\n}\n","import { ChangeDetectionStrategy, Component, TemplateRef, forwardRef, input, output, viewChild, computed, signal } from '@angular/core';\nimport { callHost, PAYMENT_METHOD_PLUGIN, PAYMENT_READINESS_EVERY_MS, PAYMENT_READINESS_TIMEOUT_MS, PAYMENT_REQUEST_TIMEOUT_MS, PAYMENT_STATUS_CHECK_TIMEOUT_MS, PAYMENT_STATUS_FAIL_GRACE_MS, PAYMENT_AUTH_TIMEOUT_MS, PAYMENT_STATUS_POLL_MAX_MS, PAYMENT_STATUS_POLL_MS, PaymentMethodPlugin, type PaymentPendingCheckInfo, type PaymentPendingCheckResult, type CheckPaymentStatusFn, type PaymentAttemptControls, type HostResult, type PaymentMethodBodyContext, type PaymentPluginMethod, type ReadinessCheckFn } from '@forgeroute/ui/payments';\nimport type { SquareBillingContact } from '../square-loader/square-types';\nimport type { SquareCardStyle } from '../square-payment/square-style';\nimport { PaymentSquareBodyComponent } from './payment-square-body.component';\nimport { SquareTerminalBannerComponent } from '../square-terminal/square-terminal-banner.component';\nimport { SQUARE_TERMINAL_LOST_ANSWER_GRACE_MS } from '../square-terminal/square-terminal.flow';\nimport { paymentBaseAmount, readerErrorInfo, type SquareTerminalConfig, type SquareTerminalLeftPending, type SquareTerminalPayment } from '../square-terminal/square-terminal.models';\nimport { SQUARE_PAYMENT_METHOD_VALUES, SQUARE_METHOD_TEXTS, squareMethodLabel, type SquareFeeContext, type SquareFees, type SquarePaymentContext, type SquarePaymentResult } from './payment-square-method.models';\n\n/**\n * Adds LIVE Card and ACH (Square) to `ui-payment-side-panel`. Put it inside the panel only for customers who use Square: its presence replaces the record-only\n * Card / ACH (last 4 digits) with the Square card form / bank authorization; remove it and the panel is record-only again.\n *\n * <ui-payment-side-panel ...>\n * @if (squareEnabled()) {\n * <ui-square-payment-method [applicationId]=\"app\" [locationId]=\"loc\" environment=\"production\" [createPayment]=\"createPayment\" />\n * }\n * </ui-payment-side-panel>\n *\n * The host owns the HTTP: `createPayment(ctx)` receives the single-use token (and the entered amount, date, notes, allocation) and answers the payment result\n * (`{ status, fees... }`). Outcomes arrive as the panel's `outcome` events with kind `'plugin'` and codes `paid`, `processing` and `failed`.\n */\n@Component({\n selector: 'ui-square-payment-method',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [PaymentSquareBodyComponent],\n providers: [{ provide: PAYMENT_METHOD_PLUGIN, useExisting: forwardRef(() => SquarePaymentMethodComponent) }],\n host: { style: 'display: none' },\n template: `<ng-template #body let-ctx><ui-payment-square-body [ctx]=\"ctx\" [config]=\"self\" /></ng-template>`,\n})\nexport class SquarePaymentMethodComponent extends PaymentMethodPlugin {\n protected readonly self = this;\n /** Creates the payment on the host's backend from the token (called when the payer presses Pay, after Square tokenized). */\n readonly createPayment = input<((ctx: SquarePaymentContext) => HostResult<SquarePaymentResult>) | null>(null);\n /** Optional fee preview before paying (display only). */\n readonly estimateFees = input<((ctx: SquareFeeContext) => HostResult<SquareFees>) | null>(null);\n readonly applicationId = input<string | null>(null);\n readonly locationId = input<string | null>(null);\n readonly environment = input<'production' | 'sandbox' | null>(null);\n /** The buyer's billing contact: with it the card form runs buyer verification (SCA / 3-D Secure) before the token reaches your backend. */\n readonly billingContact = input<SquareBillingContact | null>(null);\n /** The account holder name offered for the bank account. */\n readonly accountHolderName = input('');\n /** ACH: the authorization checkbox must be ticked before the bank window opens. */\n readonly requireAchConsent = input(true);\n readonly cardStyle = input<SquareCardStyle | null>(null);\n /** The methods this plugin takes over (default: Card and ACH / Bank Transfer). Pass `[{ value: 'CARD', label: 'Card' }]` for cards only. */\n readonly methodListInput = input<readonly PaymentPluginMethod[] | null>(null, { alias: 'methodList' });\n readonly methodList = computed((): readonly PaymentPluginMethod[] => this.methodListInput() ?? SQUARE_PAYMENT_METHOD_VALUES.map(value => ({ value, label: squareMethodLabel(value) })));\n /** How long a fee estimate may take before Pay is released and \"Try again\" is offered (ms). */\n readonly estimateTimeoutMs = input(10000);\n // ── Duplicate-payment protection and readiness gate (docs: \"Duplicate-payment protection\", \"Readiness gate\") ──\n /**\n * The payable this is for (an invoice, a balance, a payment link). While an attempt is undecided its opaque marker (key, amount, method) is stored under it in `localStorage`, so a RELOAD or a\n * SECOND TAB of the same payable starts locked (unknown) with the same attempt key. Without it the protection covers this page instance only. Nothing else is stored.\n */\n readonly payableRef = input<string | null>(null);\n /** A key the host supplies for the charge; empty = the plugin generates one per payment attempt session (it arrives in `createPayment(ctx).attemptKey`). */\n readonly attemptKey = input<string | null>(null);\n /** The host's status check by attempt key: resolves an UNKNOWN outcome (timeout, offline mid-flight). */\n readonly checkStatus = input<CheckPaymentStatusFn | null>(null);\n /** The payable is paid (host re-render, back navigation): Pay stays locked for good. */\n readonly paid = input(false);\n /** The host reports an ambiguous result of ITS charge call: the plugin goes to \"Checking your payment...\" while true. */\n readonly hostPending = input(false);\n readonly statusPollMs = input(PAYMENT_STATUS_POLL_MS);\n readonly statusPollMaxMs = input(PAYMENT_STATUS_POLL_MAX_MS);\n /** A status check slower than this counts as unknown (ms). */\n readonly statusCheckTimeoutMs = input(PAYMENT_STATUS_CHECK_TIMEOUT_MS);\n /** While the attempt's own request is unsettled, a status answer `failed` is ignored for this long (ms). */\n readonly statusFailGraceMs = input(PAYMENT_STATUS_FAIL_GRACE_MS);\n /** Offer \"Start over\" after the status polling window (a new attempt with a NEW key). Turn it on ONLY when your backend allows ONE open or succeeded attempt per payable and answers 409 `payment_in_flight` to a second key: that rule is what makes it safe. */\n readonly allowStartOver = input(false);\n /** Managed environments where `navigator.onLine === false` is a false negative (captive portal, VPN): do not refuse a payment because of the browser's offline flag (default false). */\n readonly offlineOverride = input(false);\n /** The request timeout is replaced by this while a 3-D Secure challenge or the bank window is open (ms). */\n readonly authTimeoutMs = input(PAYMENT_AUTH_TIMEOUT_MS);\n /** How long ONE `createPayment` (tokenize + charge) may take before the outcome counts as unknown (ms). */\n readonly paymentTimeoutMs = input(PAYMENT_REQUEST_TIMEOUT_MS);\n /** The host's readiness endpoint (`GET /api/payments/ready`): `{ ready, reasons[] }`. */\n readonly readinessCheck = input<ReadinessCheckFn | null>(null);\n readonly readinessTimeoutMs = input(PAYMENT_READINESS_TIMEOUT_MS);\n readonly readinessEveryMs = input(PAYMENT_READINESS_EVERY_MS);\n /** The payer covers fees: a rejected or empty estimate keeps Pay off (with \"Try again\") instead of paying without the fee preview. */\n readonly feesRequired = input(false);\n readonly receiptNoteInput = input<string | null>(null, { alias: 'receiptNote' });\n readonly receiptNote = computed((): string => this.receiptNoteInput() ?? SQUARE_METHOD_TEXTS.receiptNote);\n\n // ── Square Terminal (card reader) mode (opt-in: with no `[reader]` nothing changes) ──\n /**\n * The Square Terminal calls. With it, the method Card gets a choice \"Card reader | Enter card manually\" above the form and the Terminal is the default as soon as the first readiness answer says `reader_ready` (`[readerFirst]`);\n * otherwise manual stays the default and the panel's one reader banner explains why. Switching away while a Terminal payment waits first cancels it through `reader.cancelPayment`. See docs/card-readers.md.\n */\n readonly reader = input<SquareTerminalConfig | null>(null);\n /** The Terminal is the default when it is ready (default true). */\n readonly readerFirst = input(true);\n /** \"Connect Your Terminal\" (banner, a Terminal that is not connected): the host opens its pairing screen (`ui-square-terminal-pairing`). */\n readonly readerConnect = output<void>();\n /** \"Get a Square Terminal\" / \"How to get one\": the host opens its order flow or an info card. */\n readonly readerOrder = output<void>();\n /** \"Set up payments\". */\n readonly readerSetup = output<void>();\n /** How often (ms) the waiting payment's status is read (default 2000; clamped to 500..30 000). Wins over `reader.pollMs`. */\n readonly readerPollMs = input<number | null>(null);\n /** `true` while a Terminal payment is open; emitted only on change. NEVER sent as `false` for a payment that may still exist at the processor (see `readerLeftPending`). */\n readonly readerBusyChange = output<boolean>();\n /** The body went away or the reader screen was removed while a Terminal payment was open: the payment MAY STILL EXIST. */\n readonly readerLeftPending = output<SquareTerminalLeftPending>();\n /** While `true` Pay, \"Send to the Terminal\" and the Reader | Manual choice do nothing (a payment already open keeps Cancel); `blockedReason` is shown as a status message. Inside `ui-payment-side-panel` use the panel's own `[blocked]`. */\n readonly blocked = input(false);\n readonly blockedReason = input('');\n\n private readonly body = viewChild<TemplateRef<PaymentMethodBodyContext>>('body');\n\n // ── The host resolves an undecided attempt itself (without a status check): the body registers its controls here ──\n private readonly controls = signal<PaymentAttemptControls | null>(null);\n /** @internal The body registers itself. */\n attachControls(controls: PaymentAttemptControls): void { this.controls.set(controls); }\n /** @internal The body leaves. */\n detachControls(controls: PaymentAttemptControls): void { if (this.controls() === controls) this.controls.set(null); }\n /** The host's charge of this payment is ambiguous (its call timed out): the plugin shows \"Checking your payment...\" and stays locked (see `checkStatus`). */\n markUnknown(): void { this.controls()?.markUnknown(); }\n /** The host's charge succeeded: the plugin records it (paid + complete) and locks the payable. */\n markSucceeded(): void { this.controls()?.markSucceeded(); }\n /** The host's charge was DEFINITIVELY refused: the plugin unlocks with a NEW attempt key. */\n markFailed(): void { this.controls()?.markFailed(); }\n /** NOTHING was sent to the processor: the plugin unlocks and the attempt key is KEPT (the backend must still answer the state of an attempt it already holds for that key). */\n markNotCharged(): void { this.controls()?.markNotCharged(); }\n /** The host starts a deliberate SECOND payment of this payable (an explicit \"pay again\" flow): forgets the paid state this form saw, removes the succeeded record and moves the epoch so the next attempt has a NEW key. Does nothing against the host's own `paid` input. */\n resetPaid(): void { this.controls()?.resetPaid(); }\n\n\n /** The attempt this plugin last started (a Terminal payment or a manual card confirmation), kept here because the body is gone when the panel closes: what the panel's \"Check again\" reads. */\n private remembered: { key: string; kind: 'reader' | 'manual'; amount?: number } | null = null;\n /** @internal The body names the attempt it just started. */\n rememberAttempt(key: string | undefined, kind: 'reader' | 'manual', amount?: number): void { if (key) this.remembered = { key, kind, ...(amount !== undefined ? { amount } : {}) }; }\n\n /**\n * The truth of the payment the panel is holding, read by ATTEMPT KEY. A Terminal payment is read with `reader.getPayment`, a manual card with `checkStatus`. `over` only when the answer proves nothing is open (\"never seen\" only once the\n * hold is older than the processing window); `succeeded` when paid; `open` while it runs; `checking` when it cannot be told.\n */\n override async checkPending(info: PaymentPendingCheckInfo): Promise<PaymentPendingCheckResult> {\n const key = info.paymentAttemptKey ?? this.remembered?.key;\n if (!key) return { state: 'checking' };\n const known = this.remembered && this.remembered.key === key ? this.remembered : null;\n const kind = known?.kind ?? (this.reader() ? 'reader' : 'manual');\n if (kind === 'reader') {\n const reader = this.reader();\n if (!reader) return { state: 'checking' };\n let payment: SquareTerminalPayment | null = null;\n try { payment = (await callHost(() => reader.getPayment({ paymentId: null, attemptKey: key }))) ?? null; } catch (error) {\n if (readerErrorInfo(error).status !== 404) return { state: 'checking' };\n payment = null;\n }\n if (!payment || typeof payment !== 'object' || typeof payment.id !== 'string') return { state: info.ageMs >= SQUARE_TERMINAL_LOST_ANSWER_GRACE_MS ? 'over' : 'checking' };\n const status = String(payment.status ?? '').toUpperCase();\n const terminal = payment.terminal?.state;\n if (status === 'SUCCEEDED' || terminal === 'succeeded') {\n const amount = paymentBaseAmount(payment) ?? known?.amount;\n return { state: 'succeeded', result: { type: 'stripe', paymentMethod: info.method, processor: 'square', ...(amount !== undefined && amount !== null ? { amount } : {}) } };\n }\n if (status === 'CANCELED' || status === 'FAILED' || terminal === 'canceled') return { state: 'over' };\n return { state: 'open' };\n }\n const check = this.checkStatus();\n if (!check) return { state: 'checking' };\n let answer: string;\n try { answer = String(await callHost(() => check(key))); } catch { return { state: 'checking' }; }\n switch (answer) {\n case 'succeeded': return { state: 'succeeded', result: { type: 'stripe', paymentMethod: info.method, processor: 'square', ...(known?.amount !== undefined ? { amount: known.amount } : {}) } };\n case 'failed': return { state: 'over' };\n case 'not_found': return { state: info.ageMs >= this.paymentTimeoutMs() + this.statusFailGraceMs() ? 'over' : 'checking' };\n case 'in_flight':\n case 'awaiting_verification': return { state: 'open' };\n default: return { state: 'checking' };\n }\n }\n\n readonly methods = this.methodList;\n readonly template = this.body;\n /** The Square Terminal banner the panel's `[readerBanner]` renders: rendering this plugin in the panel is all a host needs for it (the host gives the panel `[readerBanner]=\"{ getReadiness }\"`, or `squareTerminalBannerConfig({ getReadiness })`). */\n override readonly readerBannerComponent = SquareTerminalBannerComponent;\n}\n","import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, Injector, ViewEncapsulation, afterNextRender, computed, effect, inject, input, output, signal, untracked, viewChildren } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { AlertComponent } from '@forgeroute/ui/alert';\nimport { ButtonComponent, UiFieldValidity, UiLabelsService } from '@forgeroute/ui/core';\nimport { LiveRegionComponent } from '@forgeroute/ui/live-region';\nimport { TextInputComponent } from '@forgeroute/ui/text-input';\nimport { callHost, type HostResult } from '@forgeroute/ui/payments';\nimport { SQUARE_TERMINAL_REQUEST_TIMEOUT_MS } from './square-terminal.flow';\nimport {\n formatElapsed, isSquareTerminal, normalizeReadiness, readerDisplayName, safePairingCode,\n type SquareTerminalRegisterFn, type SquareTerminal, type SquareTerminalGetReadinessFn,\n} from './square-terminal.models';\n\n/** The fastest and the slowest poll of the pairing wait (ms). */\nexport const SQUARE_PAIRING_POLL_MIN_MS = 1000;\nexport const SQUARE_PAIRING_POLL_MAX_MS = 30_000;\n/** Square device codes expire after 5 minutes; the wait never lasts longer than the host's `timeoutMs` (clamped to this range). */\nexport const SQUARE_PAIRING_TIMEOUT_MIN_MS = 10_000;\nexport const SQUARE_PAIRING_TIMEOUT_MAX_MS = 900_000;\n\n/** A pairing poll cadence the library will actually use: not a finite number > 0 = 3000 ms; otherwise rounded and clamped to 1000..30 000 ms. */\nexport function clampPairingPollMs(value: number | null | undefined): number {\n if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0) return 3000;\n return Math.min(SQUARE_PAIRING_POLL_MAX_MS, Math.max(SQUARE_PAIRING_POLL_MIN_MS, Math.round(value)));\n}\n\n/** A pairing wait the library will actually use: not a finite number > 0 = 300 000 ms (5 minutes); otherwise rounded and clamped to 10 000..900 000 ms. */\nexport function clampPairingTimeoutMs(value: number | null | undefined): number {\n if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0) return 300_000;\n return Math.min(SQUARE_PAIRING_TIMEOUT_MAX_MS, Math.max(SQUARE_PAIRING_TIMEOUT_MIN_MS, Math.round(value)));\n}\n\n/**\n * The reader the pairing is waiting for, found in the readers of a readiness read, or `null` while the Terminal has not connected yet:\n * - the registered reader is still listed (same id): paired when it no longer carries a `pairingCode` and its status is `online`;\n * - the registered id is gone from the list (the device code became the device): paired when exactly ONE Square Terminal with the same name is online without a `pairingCode`.\n * Nothing else counts (never a guess between two Terminals).\n */\nexport function findPairedTerminal(readers: readonly SquareTerminal[], registered: Pick<SquareTerminal, 'id' | 'label'>): SquareTerminal | null {\n const same = readers.find(r => r.id === registered.id);\n if (same) return !same.pairingCode && same.status === 'online' ? same : null;\n const name = (registered.label ?? '').trim().toLowerCase();\n const matches = readers.filter(r => isSquareTerminal(r) && !r.pairingCode && r.status === 'online' && (r.label ?? '').trim().toLowerCase() === name);\n return name && matches.length === 1 ? matches[0] : null;\n}\n\n/** What `(outcome)` reports (the component never toasts: the host words a toast if it wants one). */\nexport type SquareTerminalPairingOutcome =\n | { kind: 'code'; reader: SquareTerminal }\n | { kind: 'paired'; reader: SquareTerminal }\n | { kind: 'timeout' }\n | { kind: 'canceled' }\n | { kind: 'failed' };\n\ntype Phase = 'form' | 'registering' | 'waiting' | 'paired' | 'timeout';\n\n/**\n * \"Connect a Square Terminal\" (a Square Terminal has no connection token and no SDK: it is paired with a DEVICE CODE). The flow, with every call a HOST function (the browser never talks to the payments service):\n *\n * 1. staff name the Terminal and press \"Get a pairing code\": `registerTerminal({ label, locationId? })` (the host calls `POST /v1/terminal/readers`; the answer is the reader with its `pairingCode`);\n * 2. the code is shown with plain instructions (\"On the Terminal choose Sign in > Use a device code and enter <code>\") and announced politely;\n * 3. the component reads the readiness (`getReadiness`) every `pollMs` until that reader is paired (see {@link findPairedTerminal}): `(paired)` carries it, \"Terminal <name> connected.\" is shown;\n * 4. the wait is BOUNDED (`timeoutMs`, default 5 minutes, the life of a Square device code) and cancellable: at the end \"The code was not used in time\" with \"Get a new code\". A failed or slow poll never ends the wait by itself.\n *\n * A Square Terminal can only be renamed or removed in the Square dashboard (the screen says so): there is no rename / remove here. The reader list of the screen is the host's own (or the payment screen's reader choice).\n *\n * <ui-square-terminal-pairing [registerTerminal]=\"register\" [getReadiness]=\"readiness\" locationId=\"L123\" (paired)=\"onPaired($event)\" (canceled)=\"close()\" />\n */\n@Component({\n selector: 'ui-square-terminal-pairing',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n imports: [FormsModule, AlertComponent, ButtonComponent, LiveRegionComponent, TextInputComponent],\n template: `\n <ui-live-region data-testid=\"square-pairing-live\" [message]=\"announcement()\" />\n <section class=\"stp\" [attr.aria-labelledby]=\"ids + '-title'\" data-testid=\"square-pairing\" [attr.data-phase]=\"phase()\">\n <h3 class=\"stp-h\" [id]=\"ids + '-title'\">{{ labels.t('squareTerminal.pairing.title') }}</h3>\n @switch (phase()) {\n @case ('waiting') {\n <div class=\"stp-wait\" data-testid=\"square-pairing-waiting\" tabindex=\"-1\">\n <p class=\"stp-muted\">{{ labels.t('squareTerminal.pairing.code.label') }}</p>\n <strong class=\"stp-code\" data-testid=\"square-pairing-code\">{{ code() }}</strong>\n <p class=\"stp-text\" data-testid=\"square-pairing-steps\">{{ labels.t('squareTerminal.pairing.steps', { code: code() }) }}</p>\n <p class=\"stp-muted\" data-testid=\"square-pairing-countdown\">{{ labels.t('squareTerminal.pairing.waiting', { time: remainingText() }) }}</p>\n <div class=\"stp-actions\">\n <ui-button variant=\"secondary\" data-testid=\"square-pairing-cancel\" (click)=\"cancel()\">{{ labels.t('common.cancel') }}</ui-button>\n </div>\n </div>\n }\n @case ('paired') {\n <ui-alert variant=\"success\" [quiet]=\"true\" data-testid=\"square-pairing-paired\" tabindex=\"-1\" class=\"stp-focus\">{{ labels.t('squareTerminal.pairing.paired', { name: pairedName() }) }}</ui-alert>\n }\n @case ('timeout') {\n <ui-alert variant=\"warning\" [title]=\"labels.t('squareTerminal.pairing.timeout.title')\" data-testid=\"square-pairing-timeout\" tabindex=\"-1\" class=\"stp-focus\">\n <p class=\"stp-text\">{{ labels.t('squareTerminal.pairing.timeout.text') }}</p>\n <div class=\"stp-actions\">\n <ui-button variant=\"primary\" data-testid=\"square-pairing-new-code\" (click)=\"getCode()\">{{ labels.t('squareTerminal.pairing.newCode') }}</ui-button>\n <ui-button variant=\"secondary\" data-testid=\"square-pairing-cancel\" (click)=\"cancel()\">{{ labels.t('common.cancel') }}</ui-button>\n </div>\n </ui-alert>\n }\n @default {\n <p class=\"stp-text\" data-testid=\"square-pairing-intro\">{{ labels.t('squareTerminal.pairing.intro') }}</p>\n @if (error()) { <ui-alert variant=\"danger\" [quiet]=\"true\" data-testid=\"square-pairing-error\">{{ error() }}</ui-alert> }\n <ui-text-input [label]=\"labels.t('squareTerminal.pairing.name.label')\" [hint]=\"labels.t('squareTerminal.pairing.name.hint')\" [required]=\"true\" [maxlength]=\"100\"\n [ngModel]=\"label()\" (ngModelChange)=\"label.set($event ?? '')\" [showErrors]=\"touched()\" [disabled]=\"phase() === 'registering'\" inputTestId=\"square-pairing-name\" />\n <div class=\"stp-actions\">\n <ui-button variant=\"primary\" data-testid=\"square-pairing-start\" [loading]=\"phase() === 'registering'\" [disabled]=\"phase() === 'registering' || (touched() && hasInvalid())\" (click)=\"getCode()\">{{ labels.t(phase() === 'registering' ? 'squareTerminal.pairing.starting' : 'squareTerminal.pairing.start') }}</ui-button>\n </div>\n }\n }\n </section>\n `,\n styles: [`\n ui-square-terminal-pairing { display: block; min-width: 0; }\n ui-square-terminal-pairing .stp { display: flex; flex-direction: column; gap: 12px; min-width: 0; }\n ui-square-terminal-pairing .stp-h { margin: 0; font-size: 0.9375rem; font-weight: 700; color: var(--ui-psp-text, #1e293b); }\n ui-square-terminal-pairing .stp-text { margin: 0; font-size: 0.9375rem; color: var(--ui-psp-text, #1e293b); }\n ui-square-terminal-pairing .stp-muted { margin: 0; font-size: 0.8125rem; color: var(--ui-psp-muted, #475569); font-variant-numeric: tabular-nums; }\n ui-square-terminal-pairing .stp-wait { display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 2px solid var(--ui-psp-border, #cbd5e1); border-radius: 12px; background: var(--ui-psp-sunken, #f8fafc); }\n ui-square-terminal-pairing .stp-wait:focus, ui-square-terminal-pairing .stp-focus:focus { outline: none; }\n ui-square-terminal-pairing .stp-code { font-size: 1.75rem; line-height: 1.2; letter-spacing: 0.18em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; color: var(--ui-psp-text, #1e293b); }\n ui-square-terminal-pairing .stp-actions { display: flex; flex-wrap: wrap; gap: 8px; }\n @media (forced-colors: active) { ui-square-terminal-pairing .stp-wait { border-color: CanvasText; } }\n `],\n})\nexport class SquareTerminalPairingComponent {\n protected readonly labels = inject(UiLabelsService);\n private readonly destroyRef = inject(DestroyRef);\n private readonly injector = inject(Injector);\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private static seq = 0;\n /** Unique per instance: two screens on one page never share an id. */\n protected readonly ids = `stp-${++SquareTerminalPairingComponent.seq}`;\n\n /** Registers the Terminal (`POST /v1/terminal/readers`): answers the reader with its `pairingCode` (the device code). */\n readonly registerTerminal = input<SquareTerminalRegisterFn | null>(null);\n /** Reads `GET /v1/terminal/readiness` through the host; polled while the code waits. */\n readonly getReadiness = input<SquareTerminalGetReadinessFn | null>(null);\n /** The Square location the Terminal belongs to, when the host's backend does not choose it itself (sent as `locationId`). */\n readonly locationId = input<string | null>(null);\n /** The name the field starts with. */\n readonly defaultLabel = input('');\n /** How often the readiness is read while waiting (ms; default 3000; clamped to 1000..30 000). */\n readonly pollMs = input(3000);\n /** How long the code is waited for (ms; default 300 000 = 5 minutes, the life of a Square device code; clamped to 10 000..900 000). */\n readonly timeoutMs = input(300_000);\n /** A host call (register, read) slower than this is unreachable (ms). */\n readonly requestTimeoutMs = input(SQUARE_TERMINAL_REQUEST_TIMEOUT_MS);\n\n /** The Terminal connected: the host refreshes its readers (the payment screen then offers it). */\n readonly paired = output<SquareTerminal>();\n /** The user left the pairing (Cancel). The device code is left to expire at Square. */\n readonly canceled = output<void>();\n readonly outcome = output<SquareTerminalPairingOutcome>();\n\n protected readonly phase = signal<Phase>('form');\n protected readonly label = signal('');\n protected readonly touched = signal(false);\n protected readonly error = signal('');\n protected readonly code = signal('');\n protected readonly announcement = signal('');\n protected readonly pairedName = signal('');\n private readonly now = signal(Date.now());\n private deadline = 0;\n private registered: Pick<SquareTerminal, 'id' | 'label'> | null = null;\n private pollTimer: ReturnType<typeof setTimeout> | null = null;\n private tickTimer: ReturnType<typeof setInterval> | null = null;\n private busyRead = false;\n private run = 0;\n private destroyed = false;\n\n private readonly fields = viewChildren(UiFieldValidity);\n protected readonly hasInvalid = computed(() => this.fields().some(f => f.invalid()) || !this.label().trim());\n protected readonly remainingText = computed(() => formatElapsed(Math.max(0, this.deadline - this.now())));\n\n constructor() {\n effect(() => { const start = this.defaultLabel(); untracked(() => { if (!this.label()) this.label.set(start); }); });\n this.destroyRef.onDestroy(() => { this.destroyed = true; this.stopTimers(); });\n }\n\n private stopTimers(): void {\n if (this.pollTimer) { clearTimeout(this.pollTimer); this.pollTimer = null; }\n if (this.tickTimer) { clearInterval(this.tickTimer); this.tickTimer = null; }\n }\n\n private async call<T>(thunk: () => HostResult<T>): Promise<T> {\n let timer: ReturnType<typeof setTimeout> | null = null;\n try {\n const timeout = new Promise<never>((_, reject) => { timer = setTimeout(() => reject(Object.assign(new Error('request timeout'), { code: 'request_timeout' })), Math.max(1, this.requestTimeoutMs())); });\n return await Promise.race([callHost(thunk), timeout]);\n } finally { if (timer) clearTimeout(timer); }\n }\n\n private focus(testId: string): void {\n afterNextRender(() => this.host.nativeElement.querySelector<HTMLElement>(`[data-testid=\"${testId}\"]`)?.focus(), { injector: this.injector });\n }\n\n /** \"Get a pairing code\" / \"Get a new code\": registers the Terminal and starts the bounded wait. A second click while a registration runs does nothing. */\n async getCode(): Promise<void> {\n const register = this.registerTerminal();\n if (!register || this.phase() === 'registering' || this.phase() === 'waiting') return;\n this.touched.set(true);\n if (this.hasInvalid()) return;\n const label = this.label().trim();\n const location = this.locationId();\n const run = ++this.run;\n this.stopTimers();\n this.error.set('');\n this.phase.set('registering');\n try {\n const reader = await this.call(() => register({ label, ...(location ? { locationId: location } : {}) }));\n if (this.destroyed || run !== this.run) return;\n const code = safePairingCode(reader?.pairingCode) ?? '';\n if (!reader || typeof reader.id !== 'string' || !code) throw Object.assign(new Error('no pairing code'), { code: 'no_pairing_code' });\n this.registered = { id: reader.id, label: reader.label ?? label };\n this.code.set(code);\n this.touched.set(false);\n this.deadline = Date.now() + clampPairingTimeoutMs(this.timeoutMs());\n this.now.set(Date.now());\n this.phase.set('waiting');\n this.announcement.set(this.labels.t('squareTerminal.pairing.live', { code: code.split('').join(' ') }));\n this.outcome.emit({ kind: 'code', reader });\n this.focus('square-pairing-waiting');\n this.tickTimer = setInterval(() => this.tick(run), 1000);\n this.schedulePoll(run);\n } catch {\n if (this.destroyed || run !== this.run) return;\n this.phase.set('form');\n const text = this.labels.t('squareTerminal.pairing.failed');\n this.error.set(text);\n this.announcement.set(text);\n this.outcome.emit({ kind: 'failed' });\n }\n }\n\n private schedulePoll(run: number): void {\n if (this.pollTimer) clearTimeout(this.pollTimer);\n this.pollTimer = setTimeout(() => { this.pollTimer = null; void this.poll(run); }, clampPairingPollMs(this.pollMs()));\n }\n\n private tick(run: number): void {\n if (this.destroyed || run !== this.run || this.phase() !== 'waiting') return;\n this.now.set(Date.now());\n if (Date.now() >= this.deadline) void this.poll(run, true);\n }\n\n /** One read of the readiness: paired -> done; not paired -> keep waiting (or, at the end of the wait, \"The code was not used in time\"). A failed or slow read changes nothing. */\n private async poll(run: number, final = false): Promise<void> {\n const read = this.getReadiness();\n const registered = this.registered;\n if (this.destroyed || run !== this.run || this.phase() !== 'waiting' || !registered) return;\n if (this.busyRead) { if (!final) this.schedulePoll(run); return; }\n this.busyRead = true;\n let found: SquareTerminal | null = null;\n try {\n if (read) { const readiness = normalizeReadiness(await this.call(() => read())); found = findPairedTerminal(readiness.readers, registered); }\n } catch { found = null; } finally { this.busyRead = false; }\n if (this.destroyed || run !== this.run || this.phase() !== 'waiting') return;\n if (found) {\n this.stopTimers();\n this.pairedName.set(readerDisplayName(found));\n this.phase.set('paired');\n this.announcement.set(this.labels.t('squareTerminal.pairing.paired', { name: this.pairedName() }));\n this.outcome.emit({ kind: 'paired', reader: found });\n this.paired.emit(found);\n this.focus('square-pairing-paired');\n return;\n }\n if (final || Date.now() >= this.deadline) {\n this.stopTimers();\n this.phase.set('timeout');\n this.announcement.set(`${this.labels.t('squareTerminal.pairing.timeout.title')}. ${this.labels.t('squareTerminal.pairing.timeout.text')}`);\n this.outcome.emit({ kind: 'timeout' });\n this.focus('square-pairing-timeout');\n return;\n }\n this.schedulePoll(run);\n }\n\n /** Cancel: the wait ends, the device code is left to expire at Square, the host closes the screen. */\n cancel(): void {\n this.run++;\n this.stopTimers();\n this.busyRead = false;\n this.registered = null;\n this.code.set('');\n this.phase.set('form');\n this.outcome.emit({ kind: 'canceled' });\n this.canceled.emit();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAa,iBAAiB;A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;GAAA,CAAA;EAAA,CAAA;EAAA,YAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,cAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,QAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,WAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,kBAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,QAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,QAAA;EAAA,CAAA;EAAA,UAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,UAAA;EAAA,CAAA;EAAA,SAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,SAAA;EAAA,CAAA;EAAA,QAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,GAAA,iBAAA,eAAe,GAAA,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"forgeroute-ui-square.mjs","names":[],"sources":["../../../projects/forgeroute-ui/square/src/square-loader/square-loader.ts","../../../projects/forgeroute-ui/square/src/errors/square-errors.ts","../../../projects/forgeroute-ui/square/src/square-payment/square-outcomes.ts","../../../projects/forgeroute-ui/square/src/square-payment/square-style.ts","../../../projects/forgeroute-ui/square/src/square-payment/square-payment.component.ts","../../../projects/forgeroute-ui/square/src/square-connect/square-connect.flow.ts","../../../projects/forgeroute-ui/square/src/square-connect/square-connect.component.ts","../../../projects/forgeroute-ui/square/src/square-terminal/square-terminal.models.ts","../../../projects/forgeroute-ui/square/src/square-terminal/square-terminal.flow.ts","../../../projects/forgeroute-ui/square/src/square-terminal/square-terminal-status.component.ts","../../../projects/forgeroute-ui/square/src/square-terminal/square-terminal-payment.component.ts","../../../projects/forgeroute-ui/square/src/payment-square-method/payment-square-method.models.ts","../../../projects/forgeroute-ui/square/src/payment-square-method/payment-square-body.component.ts","../../../projects/forgeroute-ui/square/src/square-terminal/square-terminal-banner.component.ts","../../../projects/forgeroute-ui/square/src/payment-square-method/payment-square-method.component.ts","../../../projects/forgeroute-ui/square/src/square-terminal/square-terminal-pairing.component.ts"],"sourcesContent":["import { InjectionToken, type Provider } from '@angular/core';\nimport type { SquareConnectionConfig, SquareEnvironment, SquarePaymentsLike } from './square-types';\n\n/** The only addresses the SDK script is ever loaded from (Square's own CDN; never an address an answer or an input made up). */\nexport const SQUARE_SDK_URL = 'https://web.squarecdn.com/v1/square.js';\nexport const SQUARE_SANDBOX_SDK_URL = 'https://sandbox.web.squarecdn.com/v1/square.js';\n\n/** How long a script that is already in the page may take to define `window.Square` before the load is reported as failed. */\nexport const SQUARE_SCRIPT_WAIT_MS = 15_000;\n\n/** How long a script this loader inserted (or a form's `card()` / `attach()` / `ach()`) may stay silent before the load is reported as failed: a hung CDN must not leave a skeleton forever. */\nexport const SQUARE_LOAD_TIMEOUT_MS = 20_000;\n/**\n * Races a step of the form (`loader`, `card()`, `attach()`, `ach()`) against {@link SQUARE_LOAD_TIMEOUT_MS}: a promise that never settles becomes the error `makeError()` builds, so the\n * form shows its load error instead of a skeleton forever. The timer is always cleared (nothing is left pending).\n */\nexport function withSquareTimeout<T>(step: Promise<T> | T, makeError: () => Error): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n const timer = setTimeout(() => reject(makeError()), SQUARE_LOAD_TIMEOUT_MS);\n Promise.resolve(step).then(value => { clearTimeout(timer); resolve(value); }, error => { clearTimeout(timer); reject(error); });\n });\n}\n\n/** Marks the script tags THIS loader inserted, so a tag whose `window.Square` is gone (the host deleted it) is replaced instead of waited for. */\nconst OWN_SCRIPT_MARK = 'data-forgeroute-square';\n\n/** Why the SDK could not be loaded; `code` is `'script_failed'` (the script did not load or never defined `window.Square`) or `'sdk_missing'`. */\nexport class SquareLoadError extends Error {\n constructor(readonly code: 'script_failed' | 'sdk_missing') {\n super(code);\n this.name = 'SquareLoadError';\n }\n}\n\n/** Loads the Web Payments SDK and resolves the payments object: `loader({ applicationId, locationId, environment })`. */\nexport type SquareLoaderFn = (config: SquareConnectionConfig) => Promise<SquarePaymentsLike>;\n\ninterface SquareGlobal { payments(applicationId: string, locationId: string): SquarePaymentsLike | Promise<SquarePaymentsLike> }\nconst squareGlobal = (): SquareGlobal | undefined => (window as unknown as { Square?: SquareGlobal }).Square;\n\n/**\n * The script tag handling, behind an object so a spec can watch it (internal: not part of the public API).\n *\n * The sandbox and the production SDK are two different scripts that BOTH define `window.Square`, so `window.Square` alone says nothing about which one it is. `active` remembers\n * the address of the script whose `window.Square` is current: when a payment form asks for the OTHER environment, the old object is set aside, the other script is loaded fresh and\n * its `window.Square` wins (a form that already has its payments object keeps working: it holds its own reference). A `window.Square` this loader did not load (`active` is `null`)\n * is trusted as it is. One page normally uses one environment; switching is supported but not a hot path.\n */\nexport const squareScript = {\n /** One load per address at a time; a failed load is forgotten so the next call retries with a fresh script. */\n pending: new Map<string, Promise<void>>(),\n /** The address of the script whose `window.Square` is current; `null` = unknown (nothing loaded yet, or the SDK came from the host page). */\n active: null as string | null,\n /** The load that currently OWNS an address: a callback of any other load (an older one, a timer that fires late) never touches `pending`, `active` or `window.Square`. */\n owners: new Map<string, object>(),\n load(url: string): Promise<void> {\n const switching = squareScript.active !== null && squareScript.active !== url;\n if (squareGlobal() && !switching) return Promise.resolve();\n // Two environments are never loaded at the same moment (both define window.Square): the second waits for the first to finish, then switches.\n for (const [other, inFlight] of squareScript.pending) if (other !== url) return inFlight.catch(() => undefined).then(() => squareScript.load(url));\n // A load of THIS address that is already running (also one that is doing the switch) is shared: never a second script, never a second download.\n const running = squareScript.pending.get(url);\n if (running) return running;\n const owner = {};\n squareScript.owners.set(url, owner);\n const promise = new Promise<void>((resolve, reject) => {\n const windowWithSquare = window as unknown as { Square?: SquareGlobal };\n const previous = switching ? windowWithSquare.Square : undefined;\n const current = () => squareScript.owners.get(url) === owner;\n let settled = false;\n let loadTimer: ReturnType<typeof setTimeout> | null = null;\n let script: HTMLScriptElement | null = null;\n const finish = (): boolean => {\n if (settled) return false;\n settled = true;\n if (loadTimer) { clearTimeout(loadTimer); loadTimer = null; }\n if (script) { script.onload = null; script.onerror = null; }\n return true;\n };\n const fail = () => {\n if (!finish()) return;\n if (current()) {\n squareScript.pending.delete(url);\n squareScript.owners.delete(url);\n if (switching && previous && !windowWithSquare.Square) windowWithSquare.Square = previous; // the other environment keeps working\n }\n reject(new SquareLoadError('script_failed'));\n };\n // A finished load is forgotten at once (only an IN-FLIGHT load is shared): nothing is retained, and coming back to this address later loads it again.\n const done = () => {\n if (!finish()) return;\n if (current()) { squareScript.active = url; squareScript.pending.delete(url); squareScript.owners.delete(url); }\n resolve();\n };\n const tags = Array.from(document.querySelectorAll('script')).filter(s => s.getAttribute('src') === url);\n let foreign = tags.filter(t => !t.hasAttribute(OWN_SCRIPT_MARK));\n if (switching) {\n // The other environment's SDK is current: run THIS address again (a script that stays in the page does not run twice) and let its `window.Square` replace the old one.\n tags.forEach(t => t.remove());\n foreign = [];\n delete windowWithSquare.Square;\n } else {\n // Our own tag is still in the page but `window.Square` is gone (the host deleted it): insert the script again instead of waiting for something that will not come.\n tags.filter(t => t.hasAttribute(OWN_SCRIPT_MARK)).forEach(t => t.remove());\n }\n if (!switching && foreign.length) {\n // Somebody else inserted the script: wait for `window.Square` instead of adding a second one.\n const started = Date.now();\n const timer = setInterval(() => {\n if (settled) { clearInterval(timer); return; }\n if (squareGlobal()) { clearInterval(timer); done(); }\n else if (Date.now() - started > SQUARE_SCRIPT_WAIT_MS) { clearInterval(timer); fail(); }\n }, 50);\n return;\n }\n const own = document.createElement('script');\n script = own;\n own.src = url;\n own.async = true;\n own.setAttribute(OWN_SCRIPT_MARK, '');\n loadTimer = setTimeout(() => { own.remove(); fail(); }, SQUARE_LOAD_TIMEOUT_MS); // onload / onerror never fired: the load is reported as failed\n own.onload = () => { if (squareGlobal()) done(); else { own.remove(); fail(); } };\n own.onerror = () => { own.remove(); fail(); };\n document.head.appendChild(own);\n });\n squareScript.pending.set(url, promise);\n return promise;\n },\n};\n\nexport const squareSdkUrl = (environment: SquareEnvironment): string => (environment === 'production' ? SQUARE_SDK_URL : SQUARE_SANDBOX_SDK_URL);\n\n/**\n * The default loader: adds the SDK script from Square's CDN (production or sandbox host by `environment`) once, then calls `Square.payments(applicationId, locationId)`.\n * Nothing is fetched until a payment form is shown.\n */\nexport const defaultSquareLoader: SquareLoaderFn = async (config) => {\n await squareScript.load(squareSdkUrl(config.environment));\n const square = squareGlobal();\n if (!square) throw new SquareLoadError('sdk_missing');\n return square.payments(config.applicationId, config.locationId);\n};\n\n/** How the Web Payments SDK is loaded. Provide your own to fake Square in tests or to load it differently. Defaults to `defaultSquareLoader`. */\nexport const SQUARE_LOADER = new InjectionToken<SquareLoaderFn>('SQUARE_LOADER', { providedIn: 'root', factory: () => defaultSquareLoader });\n\n/** App-wide defaults for every Square component, set once with `provideSquarePayment`. A value on the component always wins. */\nexport interface SquarePaymentDefaults {\n /** The Square application id (`sq0idp-...` / `sandbox-sq0idb-...`). */\n applicationId?: string;\n /** The seller's Square location id. */\n locationId?: string;\n /** `'production'` or `'sandbox'` (default `'sandbox'`: a forgotten setting never charges real cards). */\n environment?: SquareEnvironment;\n}\n\nexport const SQUARE_PAYMENT_DEFAULTS = new InjectionToken<SquarePaymentDefaults>('SQUARE_PAYMENT_DEFAULTS', { providedIn: 'root', factory: () => ({}) });\n\nexport interface ProvideSquarePaymentOptions extends SquarePaymentDefaults {\n /** Replaces how the SDK is loaded (tests, a self-hosted loader). */\n loader?: SquareLoaderFn;\n}\n\n/**\n * Global defaults for the Square components:\n *\n * providers: [provideSquarePayment({ applicationId: env.squareApplicationId, locationId: env.squareLocationId, environment: 'production' })]\n */\nexport function provideSquarePayment(options: ProvideSquarePaymentOptions = {}): Provider[] {\n const { loader, ...defaults } = options;\n const providers: Provider[] = [{ provide: SQUARE_PAYMENT_DEFAULTS, useValue: defaults }];\n if (loader) providers.push({ provide: SQUARE_LOADER, useValue: loader });\n return providers;\n}\n","import { UiLabelKey, uiText } from '@forgeroute/ui/core';\nimport type { SquareTokenError } from '../square-loader/square-types';\n\n/**\n * Plain-language text for the codes Square's Payments API answers when a payment is refused (https://developer.squareup.com/reference/square/objects/Error).\n * The Web Payments SDK never sees these (it only tokenizes); they come back from the host's backend after it created the payment, which is why the table is\n * public: `getSquarePaymentErrorMessage(code)` words them in the app's active language. Values are label keys; the English text lives in the dictionary.\n */\nexport const SQUARE_PAYMENT_ERROR_KEYS: Readonly<Record<string, UiLabelKey>> = {\n GENERIC_DECLINE: 'squareErrors.code.GENERIC_DECLINE',\n CARD_DECLINED: 'squareErrors.code.CARD_DECLINED',\n CARD_DECLINED_CALL_ISSUER: 'squareErrors.code.CARD_DECLINED_CALL_ISSUER',\n CARD_DECLINED_VERIFICATION_REQUIRED: 'squareErrors.code.CARD_DECLINED_VERIFICATION_REQUIRED',\n INSUFFICIENT_FUNDS: 'squareErrors.code.INSUFFICIENT_FUNDS',\n CVV_FAILURE: 'squareErrors.code.CVV_FAILURE',\n VERIFY_CVV_FAILURE: 'squareErrors.code.CVV_FAILURE',\n ADDRESS_VERIFICATION_FAILURE: 'squareErrors.code.ADDRESS_VERIFICATION_FAILURE',\n VERIFY_AVS_FAILURE: 'squareErrors.code.ADDRESS_VERIFICATION_FAILURE',\n INVALID_EXPIRATION: 'squareErrors.code.INVALID_EXPIRATION',\n BAD_EXPIRATION: 'squareErrors.code.INVALID_EXPIRATION',\n CARD_EXPIRED: 'squareErrors.code.CARD_EXPIRED',\n INVALID_CARD: 'squareErrors.code.INVALID_CARD',\n PAN_FAILURE: 'squareErrors.code.INVALID_CARD',\n CARD_NOT_SUPPORTED: 'squareErrors.code.CARD_NOT_SUPPORTED',\n INVALID_ACCOUNT: 'squareErrors.code.INVALID_ACCOUNT',\n PAYMENT_LIMIT_EXCEEDED: 'squareErrors.code.PAYMENT_LIMIT_EXCEEDED',\n TRANSACTION_LIMIT: 'squareErrors.code.PAYMENT_LIMIT_EXCEEDED',\n BUYER_REFUSED_PAYMENT: 'squareErrors.code.BUYER_REFUSED_PAYMENT',\n CARDHOLDER_INSUFFICIENT_PERMISSIONS: 'squareErrors.code.CARDHOLDER_INSUFFICIENT_PERMISSIONS',\n IDEMPOTENCY_KEY_REUSED: 'squareErrors.code.IDEMPOTENCY_KEY_REUSED',\n RATE_LIMITED: 'squareErrors.code.RATE_LIMITED',\n UNAUTHORIZED: 'squareErrors.code.UNAUTHORIZED',\n ACCESS_TOKEN_EXPIRED: 'squareErrors.code.UNAUTHORIZED',\n ACCESS_TOKEN_REVOKED: 'squareErrors.code.UNAUTHORIZED',\n};\n\n/** The card fields the SDK names in a validation error. */\nexport const SQUARE_FIELD_ERROR_KEYS: Readonly<Record<string, UiLabelKey>> = {\n cardNumber: 'squareErrors.field.cardNumber',\n expirationDate: 'squareErrors.field.expirationDate',\n cvv: 'squareErrors.field.cvv',\n postalCode: 'squareErrors.field.postalCode',\n};\n\n/** The SDK's own error types. */\nexport const SQUARE_TYPE_ERROR_KEYS: Readonly<Record<string, UiLabelKey>> = {\n UNSUPPORTED_CARD_BRAND: 'squareErrors.type.UNSUPPORTED_CARD_BRAND',\n INVALID_APPLICATION_ID: 'squareErrors.type.CONFIGURATION',\n INVALID_LOCATION_ID: 'squareErrors.type.CONFIGURATION',\n PAYMENT_METHOD_NOT_SUPPORTED: 'squareErrors.type.PAYMENT_METHOD_NOT_SUPPORTED',\n};\n\n/**\n * `'friendly'` (default): the code table (`overrides` first), then the validation field, then the SDK error type, then Square's own text for a validation error\n * (customer-facing), then the fallback. `'square'`: Square's own `message` untouched, the fallback when there is none.\n */\nexport type SquareErrorDisplay = 'friendly' | 'square';\n\nexport interface SquareErrorMessageOptions {\n display?: SquareErrorDisplay;\n /** Text for single codes (a payment code, an SDK error type, a card field name); wins over the tables. */\n overrides?: Readonly<Record<string, string>> | null;\n /** Shown when there is nothing better. */\n fallback?: string;\n}\n\n/** The text for a payment error code the host's backend got back from Square (`'GENERIC_DECLINE'`, ...), in the app's active language. */\nexport function getSquarePaymentErrorMessage(code: string | null | undefined, options: Pick<SquareErrorMessageOptions, 'overrides' | 'fallback'> = {}): string {\n const fallback = options.fallback ?? uiText('squareErrors.defaultMessage');\n const key = (code ?? '').toUpperCase();\n const override = key ? options.overrides?.[code as string] ?? options.overrides?.[key] : undefined;\n if (override) return override;\n const table = SQUARE_PAYMENT_ERROR_KEYS[key];\n return table ? uiText(table) : fallback;\n}\n\n/** The text to show the customer for an error of the Web Payments SDK (`result.errors[n]`). */\nexport function getSquareErrorMessage(error: SquareTokenError | null | undefined, options: SquareErrorMessageOptions = {}): string {\n const fallback = options.fallback ?? uiText('squareErrors.defaultMessage');\n if (!error) return fallback;\n if (options.display === 'square') return error.message || fallback;\n const overrides = options.overrides ?? {};\n for (const name of [error.code, error.type, error.field]) {\n if (name && overrides[name]) return overrides[name];\n }\n if (error.code && SQUARE_PAYMENT_ERROR_KEYS[error.code.toUpperCase()]) return uiText(SQUARE_PAYMENT_ERROR_KEYS[error.code.toUpperCase()]);\n if (error.field && SQUARE_FIELD_ERROR_KEYS[error.field]) return uiText(SQUARE_FIELD_ERROR_KEYS[error.field]);\n const type = (error.type ?? '').toUpperCase();\n if (SQUARE_TYPE_ERROR_KEYS[type]) return uiText(SQUARE_TYPE_ERROR_KEYS[type]);\n if (type === 'VALIDATION_ERROR' && error.message) return error.message;\n return fallback;\n}\n","import { UiLabelKey, uiText } from '@forgeroute/ui/core';\nimport { getSquareErrorMessage, type SquareErrorMessageOptions } from '../errors/square-errors';\nimport type { SquareTokenDetailsLike, SquareTokenError, SquareTokenResultLike } from '../square-loader/square-types';\n\n/** `'card'` = the Web Payments SDK card form, `'ach'` = Square's bank-account authorization window. */\nexport type SquareMethod = 'card' | 'ach';\n/** `'payment'` takes a payment (single-use token), `'setup'` saves the method on file (the token is used to create a card / bank account on file). */\nexport type SquareIntentKind = 'payment' | 'setup';\n\nexport type SquareCardType = 'CREDIT' | 'DEBIT' | 'UNKNOWN';\nexport type SquarePrepaidType = 'PREPAID' | 'NOT_PREPAID' | 'UNKNOWN';\n\n/**\n * What the SDK told about the tokenized method. Every field is `null` when the SDK did not send it. `cardType` / `prepaidType` (the funding of the card) are\n * only filled when the SDK returns them in `details.card`, which it usually does NOT at tokenization time: Square's own `card_type` / `prepaid_type` are\n * read on the server after the card exists (a card on file, or the payment), so a backend that needs the funding must read it there.\n */\nexport interface SquareTokenDetails {\n brand: string | null;\n last4: string | null;\n expMonth: number | null;\n expYear: number | null;\n cardType: SquareCardType | null;\n prepaidType: SquarePrepaidType | null;\n bankName: string | null;\n accountType: string | null;\n}\n\n/** A successful tokenization. The component NEVER talks to your backend: send `token` (single use) to it, together with `attemptKey` (never the deprecated per-token `idempotencyKey`). */\nexport interface SquareTokenizedEvent {\n /** The single-use source id (`cnon:...` for a card, `bnon:...` for a bank account). */\n token: string;\n method: SquareMethod;\n kind: SquareIntentKind;\n details: SquareTokenDetails;\n /** The buyer-verification (SCA / 3-D Secure) token, when `payments.verifyBuyer` ran (card, `amount` + `billingContact` given); `null` otherwise. */\n verificationToken: string | null;\n /**\n * @deprecated A new id per tokenization: do NOT use it as the charge's idempotency key (a retry with a new token would then be a second payment). Derive Square's `idempotency_key` from\n * `attemptKey`, and look the attempt up by `attemptKey` before calling Square.\n */\n idempotencyKey: string;\n /**\n * The key of this PAYMENT ATTEMPT (stable across retries after a timeout, a reload and a second tab; renewed only after a definitive failure or success): send it to your backend with the\n * charge, which derives the processor's idempotency key from it. `idempotencyKey` above is new per tokenization; the attempt key is the one that prevents a duplicate charge.\n */\n attemptKey: string;\n /** The amount the attempt STARTED with (pinned when the click began; the buyer verification asked for exactly this). `null` for a saved card or when the form has no `amount`. */\n amount: number | null;\n /** The payable the attempt started for (the form's `payableRef` at the click): send it with the charge; the backend allows ONE open or succeeded attempt per payable and answers 409 `payment_in_flight` to a second key. */\n payableRef: string | null;\n}\n\nexport type SquareFailureStage = 'load' | 'validate' | 'tokenize' | 'verify';\n\n/** A failure: `message` is what to show the customer; `squareMessage` is Square's own text. */\nexport interface SquareFailure {\n code: string;\n message: string;\n squareMessage: string;\n stage: SquareFailureStage;\n /** The SDK's `status` (`'Cancel'`, `'Invalid'`, ...) for a tokenization failure. */\n status?: string;\n /** The card field a validation error is about. */\n field?: string;\n /** The SDK errors as returned. */\n errors?: SquareTokenError[];\n}\n\nexport function squareFailure(code: string, message: string, stage: SquareFailureStage, squareMessage = ''): SquareFailure {\n return { code, message, squareMessage, stage };\n}\n\n/** An error thrown by the SDK, the loader or a host callback: its own `error.error.message` (HTTP body), `message`, else the fallback. */\nexport function messageOfThrown(err: unknown, fallback: string): string {\n const e = err as { error?: { message?: unknown }; message?: unknown } | null | undefined;\n if (typeof e?.error?.message === 'string' && e.error.message) return e.error.message;\n if (typeof e?.message === 'string' && e.message) return e.message;\n return fallback;\n}\n\nconst upper = (v: unknown): string => (typeof v === 'string' ? v.toUpperCase() : '');\nconst text = (v: unknown): string | null => (typeof v === 'string' && v.trim() ? v : null);\n\n/** `details` of a token result as the fixed shape (see {@link SquareTokenDetails}); an unreadable field is `null`. */\nexport function normalizeSquareDetails(details: SquareTokenDetailsLike | null | undefined): SquareTokenDetails {\n const card = details?.card;\n const cardType = upper(card?.cardType);\n const prepaid = upper(card?.prepaidType);\n return {\n brand: text(card?.brand),\n last4: text(card?.last4) ?? text(details?.lastFour) ?? text(details?.ach?.lastFour),\n expMonth: typeof card?.expMonth === 'number' ? card.expMonth : null,\n expYear: typeof card?.expYear === 'number' ? card.expYear : null,\n cardType: cardType === 'CREDIT' || cardType === 'DEBIT' || cardType === 'UNKNOWN' ? cardType : null,\n prepaidType: prepaid === 'PREPAID' || prepaid === 'NOT_PREPAID' || prepaid === 'UNKNOWN' ? prepaid : null,\n bankName: text(details?.bankName) ?? text(details?.ach?.bankName),\n accountType: text(details?.accountType) ?? text(details?.ach?.accountType),\n };\n}\n\n/** The failure of a `tokenize()` that did not answer `status: 'OK'` with a token. The text is chosen by `options` (see `getSquareErrorMessage`). */\nexport function failureFromTokenResult(result: SquareTokenResultLike, method: SquareMethod, options: SquareErrorMessageOptions = {}): SquareFailure {\n const errors = (result.errors ?? []).filter(e => !!e);\n const first = errors[0];\n const base = { status: result.status, ...(errors.length ? { errors } : {}) };\n if (!first) {\n const cancelled = result.status === 'Cancel';\n const key: UiLabelKey = cancelled ? 'squarePayment.msg.cancelled' : method === 'ach' ? 'squarePayment.msg.achFailed' : 'squarePayment.msg.tokenizeFailed';\n return { ...squareFailure(cancelled ? 'cancelled' : method === 'ach' ? 'ach_failed' : 'tokenize_failed', uiText(key), 'tokenize'), ...base };\n }\n const fallback = options.fallback ?? uiText(method === 'ach' ? 'squarePayment.msg.achFailed' : 'squarePayment.msg.tokenizeFailed');\n return {\n ...squareFailure(first.code || first.type || 'tokenize_failed', getSquareErrorMessage(first, { ...options, fallback }), 'tokenize', first.message ?? ''),\n ...base,\n ...(first.field ? { field: first.field } : {}),\n };\n}\n\n/** A new idempotency key (a UUID, with a time + random fallback for a browser without `crypto.randomUUID`). */\nexport function newIdempotencyKey(): string {\n const c = typeof crypto !== 'undefined' ? crypto : undefined;\n return c && 'randomUUID' in c ? c.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`;\n}\n","import { isDarkPage } from '@forgeroute/ui/utils';\n\n/**\n * The `style` option of `payments.card({ style })`: the card form's look read from CSS custom properties at runtime, so one set of tokens styles the page and\n * the Square form, in light and dark.\n *\n * :root { --ui-square-color-primary: #0d9488; --ui-square-border-radius: 8px; }\n *\n * Tokens read (all optional; a missing one is left out so Square's default stays): `--ui-square-color-primary` (the focused field's border),\n * `--ui-square-color-text`, `--ui-square-color-background`, `--ui-square-color-border`, `--ui-square-color-danger`, `--ui-square-font-family`,\n * `--ui-square-border-radius`, `--ui-square-font-size-base`. On a dark page (`data-theme=\"dark\"`, or a dark system whose root is not forced to `light`) the text and\n * background fall back to a light-on-dark pair so a form without tokens stays readable.\n */\nexport type SquareCardStyle = Record<string, Record<string, string>>;\n\nconst DARK_TEXT = '#e2e8f0';\nconst DARK_BACKGROUND = '#0f172a';\nconst DARK_BORDER = '#64748b'; // 3.76:1 on the dark background (WCAG 1.4.11 non-text contrast; #475569 was ~2.35:1)\n\n/** Builds the card style from the tokens in effect on `element` (default: the document root). */\nexport function readSquareCardStyle(doc: Document, element: Element = doc.documentElement): SquareCardStyle {\n const view = doc.defaultView;\n const token = (name: string): string => (view ? view.getComputedStyle(element).getPropertyValue(name).trim() : '');\n const dark = isDarkPage(doc);\n const primary = token('--ui-square-color-primary');\n const text = token('--ui-square-color-text') || (dark ? DARK_TEXT : '');\n const background = token('--ui-square-color-background') || (dark ? DARK_BACKGROUND : '');\n const border = token('--ui-square-color-border') || (dark ? DARK_BORDER : '');\n const danger = token('--ui-square-color-danger');\n const font = token('--ui-square-font-family');\n const radius = token('--ui-square-border-radius');\n const size = token('--ui-square-font-size-base');\n const style: SquareCardStyle = {};\n const put = (selector: string, props: Record<string, string | undefined>): void => {\n const filled = Object.fromEntries(Object.entries(props).filter(([, v]) => !!v)) as Record<string, string>;\n if (Object.keys(filled).length) style[selector] = filled;\n };\n put('.input-container', { borderColor: border, borderRadius: radius });\n put('.input-container.is-focus', { borderColor: primary });\n put('.input-container.is-error', { borderColor: danger });\n put('.message-text', { color: text });\n put('.message-icon', { color: text });\n put('.message-text.is-error', { color: danger });\n put('input', { backgroundColor: background, color: text, fontFamily: font, fontSize: size });\n put('input::placeholder', { color: dark ? '#94a3b8' : '' });\n return style;\n}\n\n/** The app's theme tokens for {@link squareCardStyleFromTheme}. Every field is optional: a missing one is left out so the SDK's default stays. */\nexport interface SquareThemeTokens {\n /** The focused field's border. */\n primary?: string;\n background?: string;\n text?: string;\n danger?: string;\n border?: string;\n fontFamily?: string;\n radius?: string;\n fontSize?: string;\n /** The page is dark: text / background / border fall back to a readable light-on-dark pair when not given. Default false. */\n dark?: boolean;\n}\n\n/**\n * Neutral card-style helper for apps: turns the app's own theme tokens into the `style` option of the card form (pass it to `[cardStyle]`), so the form matches the page in light and dark\n * without the app knowing the SDK's selectors. Pure (no DOM). Same result as {@link readSquareCardStyle} would give for the same values.\n */\nexport function squareCardStyleFromTheme(tokens: SquareThemeTokens): SquareCardStyle {\n const dark = !!tokens.dark;\n const text = tokens.text || (dark ? DARK_TEXT : '');\n const background = tokens.background || (dark ? DARK_BACKGROUND : '');\n const border = tokens.border || (dark ? DARK_BORDER : '');\n const style: SquareCardStyle = {};\n const put = (selector: string, props: Record<string, string | undefined>): void => {\n const filled = Object.fromEntries(Object.entries(props).filter(([, v]) => !!v)) as Record<string, string>;\n if (Object.keys(filled).length) style[selector] = filled;\n };\n put('.input-container', { borderColor: border, borderRadius: tokens.radius });\n put('.input-container.is-focus', { borderColor: tokens.primary });\n put('.input-container.is-error', { borderColor: tokens.danger });\n put('.message-text', { color: text });\n put('.message-icon', { color: text });\n put('.message-text.is-error', { color: tokens.danger });\n put('input', { backgroundColor: background, color: text, fontFamily: tokens.fontFamily, fontSize: tokens.fontSize });\n put('input::placeholder', { color: dark ? '#94a3b8' : '' });\n return style;\n}\n","import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, Injector, PLATFORM_ID, afterNextRender, computed, effect, inject, input, model, output, signal, untracked, viewChild, ViewEncapsulation } from '@angular/core';\nimport { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport { FormsModule } from '@angular/forms';\nimport { AlertComponent } from '@forgeroute/ui/alert';\nimport { ButtonComponent, UiLabelsService, uiText } from '@forgeroute/ui/core';\nimport { CheckboxComponent } from '@forgeroute/ui/checkbox';\nimport { LiveRegionComponent } from '@forgeroute/ui/live-region';\nimport { PAYMENT_READINESS_EVERY_MS, PAYMENT_READINESS_TIMEOUT_MS, PAYMENT_STATUS_CHECK_TIMEOUT_MS, PAYMENT_STATUS_FAIL_GRACE_MS, PAYMENT_HOST_SILENCE_MS, PAYMENT_STATUS_POLL_MAX_MS, PAYMENT_STATUS_POLL_MS, PaymentAttemptStatusComponent, createPaymentProtection, type CheckPaymentStatusFn, type PaymentAttempt, type PaymentAttemptOutcome, type PaymentReadiness, type PaymentReadinessResult, type ReadinessCheckFn } from '@forgeroute/ui/payments';\nimport { PillTabsComponent, type PillTab } from '@forgeroute/ui/pill-tabs';\nimport { SkeletonComponent } from '@forgeroute/ui/skeleton';\nimport { TextComponent } from '@forgeroute/ui/text';\nimport { TextInputComponent } from '@forgeroute/ui/text-input';\nimport { SQUARE_LOADER, SQUARE_PAYMENT_DEFAULTS, SquareLoadError, withSquareTimeout } from '../square-loader/square-loader';\nimport type { SquareAchLike, SquareBillingContact, SquareCardLike, SquareConnectionConfig, SquarePaymentsLike, SquareVerifyBuyerDetails } from '../square-loader/square-types';\nimport type { SquareErrorDisplay, SquareErrorMessageOptions } from '../errors/square-errors';\nimport {\n failureFromTokenResult, messageOfThrown, newIdempotencyKey, normalizeSquareDetails, squareFailure,\n type SquareFailure, type SquareIntentKind, type SquareMethod, type SquareTokenizedEvent,\n} from './square-outcomes';\nimport { readSquareCardStyle, type SquareCardStyle } from './square-style';\n\n/** The texts of the screen-reader status region. */\nexport interface SquareA11yMessages {\n loading: string;\n processing: string;\n tokenized: string;\n}\n\n/** The screen-reader messages of the payment form; read on every access, so they follow the app's active language. */\nexport const SQUARE_A11Y_MESSAGES: Readonly<SquareA11yMessages> = {\n get loading() { return uiText('squarePayment.a11y.loading'); },\n get processing() { return uiText('squarePayment.a11y.processing'); },\n get tokenized() { return uiText('squarePayment.a11y.tokenized'); },\n};\n\n/**\n * The live Square objects of a form, handed to the host by `(squareReady)`: the host's own code can call `card.tokenize()`, `ach.tokenize({ accountHolderName })`,\n * `payments.verifyBuyer(...)` and anything else the SDK offers. `card` is set for the card form, `ach` for the bank-account form (the other one is `null`).\n */\nexport interface SquareReadyEvent {\n payments: SquarePaymentsLike;\n card: SquareCardLike | null;\n ach: SquareAchLike | null;\n}\n\n/** The SDK card events that mean the payer changed what is typed (not focus / blur, not a validation that just failed). */\nconst SQUARE_EDIT_EVENTS = ['cardBrandChanged', 'postalCodeChanged', 'errorClassRemoved'] as const;\n\nlet nextId = 0;\nconst jsonEqual = (a: unknown, b: unknown): boolean => JSON.stringify(a) === JSON.stringify(b);\n/**\n * Structural equality for option objects that may hold functions (`cardOptions`): plain values and nested objects / arrays / Maps / Sets are compared by content (a Set's members\n * structurally and without regard to order), a Date by time, a RegExp by source and flags, a class instance by prototype AND own keys, a FUNCTION by reference, so a new callback\n * rebuilds the card form (JSON.stringify would drop functions and `undefined` and call two different callbacks equal). A cycle never loops: a pair of objects that is already being\n * compared (further up the same comparison) counts as equal while it is in progress.\n */\nexport function structuralEqual(a: unknown, b: unknown, inProgress: WeakMap<object, WeakSet<object>> = new WeakMap()): boolean {\n if (Object.is(a, b)) return true;\n if (typeof a !== 'object' || typeof b !== 'object' || !a || !b) return false;\n if (inProgress.get(a)?.has(b)) return true;\n if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false;\n if (a instanceof Date) return b instanceof Date && a.getTime() === b.getTime();\n if (a instanceof RegExp) return b instanceof RegExp && a.source === b.source && a.flags === b.flags;\n const pairs = inProgress.get(a) ?? new WeakSet<object>();\n pairs.add(b);\n inProgress.set(a, pairs);\n try {\n if (a instanceof Map) {\n const other = b as Map<unknown, unknown>;\n return a.size === other.size && [...a].every(([k, v]) => other.has(k) && structuralEqual(v, other.get(k), inProgress));\n }\n if (a instanceof Set) {\n const other = b as Set<unknown>;\n if (a.size !== other.size) return false;\n const rest = [...other];\n for (const member of a) {\n const at = rest.findIndex(candidate => structuralEqual(member, candidate, inProgress));\n if (at < 0) return false;\n rest.splice(at, 1);\n }\n return true;\n }\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n return keysA.length === keysB.length && keysA.every(k => k in b && structuralEqual((a as Record<string, unknown>)[k], (b as Record<string, unknown>)[k], inProgress));\n } finally {\n pairs.delete(b);\n }\n}\n\n/**\n * Square Web Payments SDK form: a card form or Square's bank-account (ACH) authorization, as a payment (`mode=\"payment\"`) or to keep the method on file\n * (`mode=\"setup\"`).\n *\n * The component NEVER talks to your backend. It tokenizes in the browser and emits `(tokenized)` with the single-use token (plus the brand / last four /\n * bank name Square returned, an optional buyer-verification token and an idempotency key); your app sends that to its backend, which creates the payment or the\n * card on file. A failure is `(failed)` with a friendly message. The SDK script is loaded lazily from Square's CDN (nothing is fetched until a form is shown).\n *\n * <ui-square-payment [applicationId]=\"app\" [locationId]=\"loc\" environment=\"production\" [amount]=\"total\" [billingContact]=\"billing\"\n * (tokenized)=\"onToken($event)\" (failed)=\"onFailed($event)\" />\n *\n * Every behaviour of the CRM apps' Square forms is reproduced; see docs/square.md (\"Parity with the existing app implementations\").\n */\n@Component({\n selector: 'ui-square-payment',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n imports: [AlertComponent, ButtonComponent, CheckboxComponent, FormsModule, LiveRegionComponent, PaymentAttemptStatusComponent, PillTabsComponent, SkeletonComponent, TextComponent, TextInputComponent],\n host: { '[attr.aria-busy]': '!mountOnly() && (loading() || submitting()) ? \"true\" : null' },\n template: `\n <div class=\"sqp\">\n @if (!mountOnly() || a11yMessages()) {\n <ui-live-region data-testid=\"square-status\" [message]=\"statusText()\" />\n }\n @if (!mountOnly() && tabs().length > 1) {\n <div class=\"sqp-block\"><ui-pill-tabs [ariaLabel]=\"labels.t('squarePayment.method.group')\" [tabs]=\"tabs()\" [activeKey]=\"method()\" (tabChange)=\"onTab($event)\" /></div>\n }\n @if (!mountOnly() && showStatus()) {\n <ui-payment-attempt-status [attempt]=\"attempt\" [readiness]=\"readiness\" [allowStartOver]=\"allowStartOver()\" [showPaid]=\"showPaid()\" (retryLoad)=\"retryLoad()\" />\n }\n @if (!mountOnly() && (loading() || pending())) {\n <div class=\"sqp-skeleton\" data-testid=\"square-skeleton\" aria-hidden=\"true\">\n <ui-skeleton [height]=\"44\" [mb]=\"10\" />\n <ui-skeleton [height]=\"44\" width=\"60%\" />\n </div>\n }\n @if (!mountOnly() && loadErrorText(); as text) {\n <div class=\"sqp-block\" data-testid=\"square-load-error\"><ui-alert variant=\"danger\">{{ text }}</ui-alert></div>\n }\n @if (!mountOnly() && required()) {\n <div class=\"sqp-label\" data-testid=\"square-required-label\">{{ label() }}<span class=\"sqp-required\" aria-hidden=\"true\">*</span></div>\n }\n @if (method() === 'card') {\n <div #mount class=\"sqp-mount\" [attr.id]=\"mountId() || null\" [class]=\"mountClass()\" [class.sqp-mount--hidden]=\"mountHidden()\" [class.sqp-mount--locked]=\"mountLocked()\"\n [attr.aria-hidden]=\"mountHidden() ? 'true' : null\" [attr.aria-disabled]=\"mountLocked() ? 'true' : null\" [attr.inert]=\"mountHidden() || mountLocked() ? '' : null\"\n [attr.role]=\"mountOnly() ? null : 'group'\" [attr.aria-label]=\"mountOnly() ? null : label()\" [attr.data-testid]=\"mountTestId()\"></div>\n } @else if (!mountOnly()) {\n <div class=\"sqp-ach\" data-testid=\"square-ach\">\n <ui-text data-testid=\"square-ach-info\" size=\"sm\" tone=\"muted\" [text]=\"labels.t('squarePayment.achInfo')\" />\n <ui-text-input [label]=\"labels.t('squarePayment.holderLabel')\" [placeholder]=\"labels.t('squarePayment.holderPlaceholder')\" [inputTestId]=\"holderTestId()\" autocomplete=\"name\"\n [required]=\"true\" [maxlength]=\"255\" [error]=\"holderError()\" [showErrors]=\"attempted()\" [disabled]=\"locked()\"\n [ngModel]=\"holder()\" (ngModelChange)=\"holder.set($event ?? ''); edited()\" />\n @if (requireAchConsent()) {\n <ui-checkbox testId=\"square-consent\" [label]=\"achConsent()\" [required]=\"true\" [requiredMessage]=\"labels.t('squarePayment.consentRequired')\" [showErrors]=\"attempted()\"\n [disabled]=\"locked()\" [ngModel]=\"consent()\" (ngModelChange)=\"consent.set(!!$event); edited()\" />\n }\n </div>\n }\n @if (!mountOnly() && errorText(); as text) {\n <div class=\"sqp-block\" [id]=\"errorId\" [attr.data-testid]=\"errorTestId()\"><ui-alert variant=\"danger\">{{ text }}</ui-alert></div>\n }\n @if (!mountOnly() && showSubmit()) {\n <div class=\"sqp-actions\">\n <ui-button variant=\"primary\" type=\"button\" [fullWidth]=\"true\" [loading]=\"submitting()\" [disabled]=\"submitDisabled()\" [ariaDescribedBy]=\"errorText() ? errorId : undefined\"\n data-testid=\"square-submit\" (click)=\"tokenize()\">{{ effectiveSubmitLabel() }}</ui-button>\n </div>\n }\n </div>\n `,\n styles: [`\n ui-square-payment { display: block; min-width: 0; }\n ui-square-payment .sqp { position: relative; }\n ui-square-payment .sqp-block { margin-top: 12px; }\n ui-square-payment .sqp-label { font-size: 0.875rem; font-weight: 500; color: var(--ui-text, #1e293b); margin-bottom: 6px; }\n ui-square-payment .sqp-required { color: var(--ui-danger, #dc2626); margin-left: 2px; }\n ui-square-payment .sqp-mount { min-height: 44px; margin-top: 12px; }\n ui-square-payment .sqp-ach { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }\n /* The submit button fills the row on every screen: a flex column stretches the (inline-flex) ui-button host, and [fullWidth] stretches its button. */\n ui-square-payment .sqp-actions { margin-top: 16px; display: flex; flex-direction: column; align-items: stretch; }\n /* While loading the card form is kept laid out (the SDK measures its container) but invisible and untouchable. */\n ui-square-payment .sqp-mount--hidden { position: absolute; top: 0; left: 0; right: 0; opacity: 0; pointer-events: none; }\n /* Disabled or tokenizing: the card form cannot be typed into. the inert attribute does it where it is supported; pointer-events (mouse / touch) and a dimmed look cover an older Safari. */\n ui-square-payment .sqp-mount--locked { pointer-events: none; opacity: 0.6; }\n `],\n})\nexport class SquarePaymentComponent {\n protected readonly labels = inject(UiLabelsService);\n private readonly loader = inject(SQUARE_LOADER);\n private readonly defaults = inject(SQUARE_PAYMENT_DEFAULTS);\n private readonly doc = inject(DOCUMENT);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly injector = inject(Injector);\n\n // ── Inputs ─────────────────────────────────────────────────────────────\n /**\n * Mount-only mode: the component only creates the Square objects and mounts the card form (or creates the bank-account object). No submit button, skeleton, status text (unless\n * `a11yMessages` is set), switcher, holder / consent fields or alerts: load failures go to `(loadError)` only. The host keeps its own tokenization code and calls the SDK with the\n * objects from `(squareReady)`. `mountId` / `mountClass` / `mountTestId` still apply, `(ready)` still emits, and `tokenize()` stays available (the holder name then comes from\n * `accountHolderName`, since the holder field is not drawn).\n */\n readonly mountOnly = input(false);\n /** `'payment'` takes a payment, `'setup'` keeps the method on file (changes the default button text and the buyer-verification intent). */\n readonly mode = input<SquareIntentKind>('payment');\n /** The method shown: `'card'` (the SDK card form) or `'ach'` (the bank-account authorization). Two-way. */\n readonly method = model<SquareMethod>('card');\n /** The methods the customer may pick between (a switcher is shown for two or more); `null` = only the `method` above, no switcher. */\n readonly methods = input<readonly SquareMethod[] | null>(null);\n /** The Square application id. Falls back to `provideSquarePayment({ applicationId })`. */\n readonly applicationId = input<string | null>(null);\n readonly locationId = input<string | null>(null);\n /** `'production'` or `'sandbox'` (default: the provider's, else `'sandbox'`). Decides which Square host the SDK script comes from. */\n readonly environment = input<'production' | 'sandbox' | null>(null);\n /** The amount in major units (12.5 = $12.50), for buyer verification (SCA / 3-D Secure) of a card payment. */\n readonly amount = input<number | null>(null);\n readonly currency = input('USD');\n /** The buyer's billing contact, for buyer verification. */\n readonly billingContact = input<SquareBillingContact | null>(null);\n /** Run `payments.verifyBuyer` after a card token. `null` (default) = automatic: for a payment when `amount` and `billingContact` are both given, for a setup when `billingContact` is given. */\n readonly verifyBuyer = input<boolean | null>(null);\n /** The account holder name of the bank account (ACH); the customer can edit it. */\n readonly accountHolderName = input('');\n /** ACH: an unticked authorization checkbox blocks the tokenization (default TRUE: a bank debit needs the holder's authorization; the wording follows `mode`: one-time payment vs agreed-upon payments for a saved account). Not applied in `mountOnly` (no checkbox is drawn: the host owns the consent). */\n readonly requireAchConsent = input(true);\n readonly achConsentTextInput = input<string | null>(null, { alias: 'achConsentText' });\n readonly achConsent = computed(() => this.achConsentTextInput() ?? this.labels.t(this.mode() === 'setup' ? 'squarePayment.achConsentSetup' : 'squarePayment.achConsent'));\n /** `payments.ach({ redirectURI })`: where the bank sends the customer back after a redirect-based authorization. Passed only when set. */\n readonly achRedirectUri = input<string | null>(null);\n /** `payments.ach({ transactionId })`. Passed only when set. */\n readonly achTransactionId = input<string | null>(null);\n /** Extra options of `payments.card(options)`, merged over `cardStyle`. */\n readonly cardOptions = input<Record<string, unknown> | null>(null);\n /** The card form's CSS-like `style` (see Square's docs). */\n readonly cardStyle = input<SquareCardStyle | null>(null);\n /** Build the card `style` from the `--ui-square-*` CSS tokens (light / dark) when no `cardStyle` is given. */\n readonly styleFromTokens = input(false);\n /** The language of the SDK's own texts (`payments.setLocale`): `'es-ES'`, `'en-US'`, ... Default: the app's active language (`UiLabelsService`: Spanish -> `es-ES`, English -> `en-US`). `false` = never call `setLocale` (the SDK picks from the browser). */\n readonly sdkLocale = input<string | false | null>(null);\n /** Show the SDK's visible field labels (`includeInputLabels`, helps screen readers and the 320px layout). Default false = unchanged. */\n readonly includeInputLabels = input(false);\n /** The card form's postal code field: `null` (default) = the SDK decides, a string pre-fills it, `false` hides it (only when your backend does not need AVS). */\n readonly postalCode = input<string | false | null>(null);\n /** Hide the SDK's inline validation message and icon under the fields (`.message-text` / `.message-icon`): the form's own alert (`role=\"alert\"`) is then the only place a failure is shown. Best effort: applied only where the SDK accepts the style. Default false. */\n readonly hideInlineMessages = input(false);\n\n /** Show the built-in attempt / readiness status block (a payment plugin that embeds this form shows its own and turns this off). */\n readonly showStatus = input(true);\n /** Show the paid state of the attempt status (default true). A form whose host shows its own success notice sets it off while that notice is up. */\n readonly showPaid = input(true);\n\n // ── Duplicate-payment protection and readiness gate (docs: \"Duplicate-payment protection\", \"Readiness gate\") ──\n /**\n * The payable this is for (an invoice, a balance, a payment link). While an attempt is undecided its opaque marker (key, amount, method) is stored under it in `localStorage`, so a RELOAD or a\n * SECOND TAB of the same payable starts locked (unknown) with the same attempt key. Without it the protection covers this page instance only. Nothing else is stored.\n */\n readonly payableRef = input<string | null>(null);\n /** A key the host supplies for the charge; empty = the component generates one per payment attempt session (see `attemptKeyChange`). */\n readonly attemptKey = input<string | null>(null);\n /** The host's status check by attempt key: resolves an UNKNOWN outcome (`'succeeded' | 'failed' | 'checking' | 'in_flight' | 'awaiting_verification'` (`'unknown'` = the old name of `'checking'`, still accepted)). */\n readonly checkStatus = input<CheckPaymentStatusFn | null>(null);\n /** The payable is paid (host re-render, back navigation): the form shows the paid state and ignores every submit for good. */\n readonly paid = input(false);\n /** The host reports an ambiguous result of ITS charge call (its own timeout): the form goes to \"Checking your payment...\" while true. */\n readonly hostPending = input(false);\n readonly statusPollMs = input(PAYMENT_STATUS_POLL_MS);\n readonly statusPollMaxMs = input(PAYMENT_STATUS_POLL_MAX_MS);\n /** A status check slower than this counts as unknown (ms). */\n readonly statusCheckTimeoutMs = input(PAYMENT_STATUS_CHECK_TIMEOUT_MS);\n /** While the attempt's own request is unsettled, a status answer `failed` is ignored for this long (ms). */\n readonly statusFailGraceMs = input(PAYMENT_STATUS_FAIL_GRACE_MS);\n /** Offer \"Start over\" after the status polling window (a new attempt with a NEW key). Turn it on ONLY when your backend allows ONE open or succeeded attempt per payable and answers 409 `payment_in_flight` to a second key: that rule is what makes it safe. */\n readonly allowStartOver = input(false);\n /** Managed environments where `navigator.onLine === false` is a false negative (captive portal, VPN): do not refuse a payment because of the browser's offline flag (default false). */\n readonly offlineOverride = input(false);\n /** A token-only form whose host never reports (markSucceeded / markFailed / markUnknown / markNotCharged) becomes unknown after this long (ms), so the status check and \"Check again\" engage. */\n readonly hostSilenceMs = input(PAYMENT_HOST_SILENCE_MS);\n /** The host's readiness endpoint (`GET /api/payments/ready`): `{ ready, reasons[] }`. */\n readonly readinessCheck = input<ReadinessCheckFn | null>(null);\n readonly readinessTimeoutMs = input(PAYMENT_READINESS_TIMEOUT_MS);\n readonly readinessEveryMs = input(PAYMENT_READINESS_EVERY_MS);\n\n\n // Presentation\n readonly submitLabel = input('');\n /** Show the built-in submit button; turn off to use your own and call `tokenize()`. */\n readonly showSubmit = input(true);\n readonly disabled = input(false);\n /** The host is still preparing the form (e.g. it fetches the amount): show the loading skeleton. */\n readonly pending = input(false);\n /** Accessible name of the payment form. */\n readonly labelInput = input<string | null>(null, { alias: 'label' });\n readonly label = computed(() => this.labelInput() ?? this.labels.t('squarePayment.label'));\n /** The payment details are required (a required wizard step): a visible heading with a red asterisk is shown above the form. Not shown in `mountOnly` mode. */\n readonly required = input(false);\n /** The `id` of the card container (an app's e2e selector). */\n readonly mountId = input('');\n readonly mountClass = input('');\n /** `data-testid` of the card container (default `square-card-form`, the id the mfh forms had). */\n readonly mountTestId = input('square-card-form');\n readonly errorTestId = input('square-error');\n readonly holderTestId = input('square-holder');\n /** Show failures in the built-in alert. Turn off when the host shows `(failed)` itself. */\n readonly showErrors = input(true);\n /** `'friendly'` (default) or `'square'` (Square's own message). See `getSquareErrorMessage`. */\n readonly errorDisplay = input<SquareErrorDisplay>('friendly');\n /** Replacement texts by code: Square error codes / types / card fields AND the library's own codes (`not_ready`, `holder_required`, `consent_required`, `cancelled`, `verification_failed`, ...). */\n readonly errorMessages = input<Record<string, string> | null>(null);\n /** The text when Square sends an error with no usable text. */\n readonly errorFallback = input('');\n readonly loadErrorMessageInput = input<string | null>(null, { alias: 'loadErrorMessage' });\n readonly loadErrorMessage = computed(() => this.loadErrorMessageInput() ?? this.labels.t('squarePayment.loadErrorMessage'));\n /** Texts of the screen-reader status region (translate them); missing keys keep the defaults. */\n readonly a11yMessages = input<Partial<SquareA11yMessages> | null>(null);\n\n // ── Outputs ────────────────────────────────────────────────────────────\n /**\n * The live Square objects, emitted once each time the form is created: right after the card form was attached (or the bank-account object created), before `(ready)`.\n * `null` is emitted when they go away (the form is re-created for new inputs, `reset()` or `destroyForm()`): drop your references. Destroying the component itself emits nothing\n * (the host owns that moment).\n */\n readonly squareReady = output<SquareReadyEvent | null>();\n /** The card form / bank authorization is ready. */\n readonly ready = output<void>();\n /** A step of an attempt started / ended (the synchronous lock). */\n readonly inFlightChange = output<boolean>();\n /** Unified outcome of a payment attempt: `succeeded`, `failed`, `unknown`, `refused` (with `reason`), `pending`. */\n readonly outcome = output<PaymentAttemptOutcome>();\n /** The attempt key in effect (also on `tokenized`): send it to your backend with the charge. */\n readonly attemptKeyChange = output<string>();\n /** The readiness gate changed: `{ ready, reasons }`. */\n readonly readinessChange = output<PaymentReadinessResult>();\n /** The customer's details were tokenized: send `token` to your backend. */\n readonly tokenized = output<SquareTokenizedEvent>();\n /** A step failed (validation, tokenization, buyer verification). `message` is ready to show. */\n readonly failed = output<SquareFailure>();\n /**\n * The payer edited the details: the card number / postal code changed or a field error cleared (the SDK's `cardBrandChanged` / `postalCodeChanged` / `errorClassRemoved`), or the bank form's holder name / authorization changed.\n * The built-in error alert clears itself at the same moment; a host that shows its own decline banner clears it here, so a stale \"card declined\" never stays next to details the payer is already correcting.\n * Not emitted for changes the form makes itself (building the form, a tab switch).\n */\n readonly detailsChange = output<void>();\n /** The SDK could not be loaded or the form could not be created. */\n readonly loadError = output<SquareFailure>();\n\n // ── State ──────────────────────────────────────────────────────────────\n readonly loading = signal(false);\n readonly isReady = signal(false);\n readonly submitting = signal(false);\n readonly errorText = signal('');\n readonly loadErrorText = signal('');\n protected readonly holder = signal('');\n protected readonly consent = signal(false);\n protected readonly attempted = signal(false);\n private readonly announcement = signal('');\n private readonly resetTick = signal(0);\n\n protected readonly errorId = `ui-square-error-${nextId++}`;\n private readonly mountRef = viewChild<ElementRef<HTMLElement>>('mount');\n\n protected readonly tabs = computed((): PillTab[] => {\n const methods = this.methods();\n if (!methods || methods.length < 2) return [];\n return methods.map(m => ({ key: m, label: this.labels.t(m === 'card' ? 'squarePayment.method.card' : 'squarePayment.method.ach') }));\n });\n protected readonly locked = computed(() => this.disabled() || this.submitting() || this.attempt.locked());\n protected readonly mountHidden = computed(() => !this.mountOnly() && (this.loading() || this.pending() || !!this.loadErrorText()));\n /** The card form is not usable while the form is disabled or a tokenization runs (not in `mountOnly`: there the host owns the interaction). */\n protected readonly mountLocked = computed(() => !this.mountOnly() && this.locked());\n protected readonly holderError = computed(() => (this.attempted() && !this.holder().trim() ? this.labels.t('squarePayment.holderRequired') : ''));\n protected readonly effectiveSubmitLabel = computed(() => {\n const given = this.submitLabel();\n if (given) return given;\n const setup = this.mode() === 'setup';\n return this.labels.t(this.method() === 'ach' ? (setup ? 'squarePayment.submit.saveBank' : 'squarePayment.submit.payBank') : (setup ? 'squarePayment.submit.saveCard' : 'squarePayment.submit.pay'));\n });\n protected readonly submitDisabled = computed(() => this.disabled() || this.loading() || this.pending() || !this.isReady() || !!this.loadErrorText() || this.attempt.locked() || !this.readiness.ready());\n private readonly messages = computed((): SquareA11yMessages => {\n const given = Object.fromEntries(Object.entries(this.a11yMessages() ?? {}).filter(([, text]) => typeof text === 'string')) as Partial<SquareA11yMessages>;\n return { ...SQUARE_A11Y_MESSAGES, ...given };\n });\n protected readonly statusText = computed(() => {\n if (this.loading()) return this.messages().loading;\n if (this.submitting()) return this.messages().processing;\n return this.announcement();\n });\n\n private readonly connection = computed((): SquareConnectionConfig => ({\n applicationId: this.applicationId() || this.defaults.applicationId || '',\n locationId: this.locationId() || this.defaults.locationId || '',\n environment: this.environment() ?? this.defaults.environment ?? 'sandbox',\n }), { equal: jsonEqual });\n\n /** The options of `payments.card()`: `cardOptions` merged over the style; `null` = call `card()` with no argument (the SDK default look). */\n private readonly cardConfig = computed((): Record<string, unknown> | null => {\n const hidden: SquareCardStyle | null = this.hideInlineMessages() ? { '.message-text': { display: 'none' }, '.message-icon': { display: 'none' } } : null;\n const style = hidden ? { ...(this.cardStyle() ?? {}), ...hidden } : this.cardStyle();\n const options = this.cardOptions();\n const own: Record<string, unknown> = {\n ...(this.includeInputLabels() ? { includeInputLabels: true } : {}),\n ...(this.postalCode() === false ? { postalCode: false } : this.postalCode() ? { postalCode: this.postalCode() } : {}),\n };\n if (!style && !options && !Object.keys(own).length) return null;\n return { ...own, ...(style ? { style } : {}), ...(options ?? {}) };\n }, { equal: structuralEqual });\n\n private payments: SquarePaymentsLike | null = null;\n private card: SquareCardLike | null = null;\n private ach: SquareAchLike | null = null;\n private generation = 0;\n private destroyed = false;\n /** `(squareReady)` emitted an object set that has not been withdrawn (`null`) yet. */\n private announced = false;\n\n /** The duplicate-payment protection of this form: the synchronous lock, the attempt key, the unknown state. Public so a host can read `attempt.key()` / `attempt.unknown()`. */\n readonly attempt: PaymentAttempt;\n /** The readiness gate: `readiness.ready()` / `readiness.reasons()`. */\n readonly readiness: PaymentReadiness;\n\n constructor() {\n const protection = createPaymentProtection(this, {\n amount: () => this.amount(),\n method: () => this.method(),\n sdk: () => (this.loadErrorText() ? 'blocked' : this.loading() ? 'loading' : 'ok'),\n offlineMidFlight: false, // this form only TOKENIZES: the token call answers or fails by itself, no charge is in flight here\n onOutcome: o => this.outcome.emit(o),\n onInFlightChange: v => this.inFlightChange.emit(v),\n onKeyChange: k => this.attemptKeyChange.emit(k),\n onReadinessChange: r => this.readinessChange.emit(r),\n });\n this.attempt = protection.attempt;\n this.readiness = protection.readiness;\n effect(() => {\n const method = this.method();\n const mount = method === 'card' ? this.mountRef() : null;\n const connection = this.connection();\n const card = this.cardConfig();\n const ach = { redirectUri: this.achRedirectUri(), transactionId: this.achTransactionId() };\n this.resetTick();\n this.styleFromTokens(); // the token style is read when the form is built: switching it on / off rebuilds the form\n if (method === 'card' && !mount) return;\n untracked(() => { void this.init(mount?.nativeElement ?? null, method, connection, card, ach); });\n });\n effect(() => { const name = this.accountHolderName(); untracked(() => this.holder.set(name)); });\n inject(DestroyRef).onDestroy(() => { this.destroyed = true; this.generation++; this.disposeInstances(); this.payments = null; });\n }\n\n // ── Public methods ─────────────────────────────────────────────────────\n\n /**\n * Tokenizes the entered card / bank account (the same as the built-in button). Resolves the event (also emitted as `tokenized`), or `null` after a failure (emitted\n * as `failed`) or when nothing was started (already running, disabled, not ready). Never rejects: anything the SDK throws becomes a `failed` event.\n *\n * ACH opens the bank window: call this method directly from the click handler (no `await` before it), or the browser blocks the window.\n */\n async tokenize(): Promise<SquareTokenizedEvent | null> {\n if (this.submitting() || this.disabled() || this.pending()) return null;\n if (this.refusedByProtection()) return null;\n const method = this.method();\n const card = this.card;\n const ach = this.ach;\n if (!this.isReady() || (method === 'card' ? !card : !ach)) { this.fail(squareFailure('not_ready', this.labels.t('squarePayment.msg.notReady'), 'tokenize')); return null; }\n this.attempted.set(true);\n const holder = this.holder().trim();\n if (method === 'ach') {\n if (!holder) { this.fail(squareFailure('holder_required', this.labels.t('squarePayment.holderRequired'), 'validate')); this.focusInput('holder'); return null; }\n if (this.requireAchConsent() && !this.mountOnly() && !this.consent()) { this.fail(squareFailure('consent_required', this.labels.t('squarePayment.consentRequired'), 'validate')); this.focusInput('consent'); return null; }\n }\n const generation = this.generation;\n const kind = this.mode();\n const begun = this.attempt.begin(); // SYNCHRONOUS lock: the same tick as the click, before any await\n if (!begun.ok) return null;\n const attemptKey = begun.key;\n const payableRef = this.attempt.pinnedRef();\n const amount = this.attempt.pinnedAmount(); // PINNED at begin: a fee re-estimate while the card is verified never changes what was asked for\n let handedToHost = false;\n this.submitting.set(true);\n this.errorText.set('');\n this.announcement.set('');\n try {\n const result = method === 'card' ? await card!.tokenize() : await ach!.tokenize({ accountHolderName: holder });\n if (this.destroyed || generation !== this.generation) return null;\n if (result.status !== 'OK' || !result.token) { this.fail(failureFromTokenResult(result, method, this.errorOptions())); return null; }\n let verificationToken: string | null = null;\n if (method === 'card' && this.shouldVerify(kind, amount)) {\n const verified = await this.verify(result.token, kind, amount);\n if (this.destroyed || generation !== this.generation) return null;\n if ('code' in verified) { this.fail(verified); return null; }\n verificationToken = verified.token;\n }\n const event: SquareTokenizedEvent = {\n token: result.token, method, kind, details: normalizeSquareDetails(result.details), verificationToken, idempotencyKey: newIdempotencyKey(), attemptKey, amount, payableRef,\n };\n this.announcement.set(this.messages().tokenized);\n // A PAYMENT keeps its lock after the token: the host charges now, and until it reports markSucceeded / markFailed / markUnknown / markNotCharged (or the status check decides) a second\n // tokenization or charge is refused. A saved card (mode 'setup') charges nothing, so it unlocks.\n if (kind === 'payment') { handedToHost = true; this.attempt.markPending('token'); }\n this.tokenized.emit(event);\n return event;\n } catch (err) {\n if (this.destroyed || generation !== this.generation) return null;\n this.fail({ ...squareFailure('tokenize_failed', this.errorFallback() || this.labels.t(method === 'ach' ? 'squarePayment.msg.achFailed' : 'squarePayment.msg.tokenizeFailed'), 'tokenize', messageOfThrown(err, '')) });\n return null;\n } finally {\n this.submitting.set(false);\n if (!handedToHost) this.attempt.release(); // the attempt ended before any charge request (validation, tokenization, verification): unlock, the key is kept\n }\n }\n\n /** The host reports that ITS charge call timed out or is ambiguous: the form shows \"Checking your payment...\" and stays locked (see `checkStatus`). */\n markUnknown(): void { this.attempt.markUnknown('host'); }\n\n /** The host reports that the charge succeeded: the form locks for this payable (a success does NOT move the epoch: the same key replays the original payment; the paid lock lasts 24 hours, see `resetPaid()`). */\n markSucceeded(): void { this.attempt.succeed('host'); }\n\n /** The host reports a DEFINITIVE failure of the charge (declined): the form unlocks with a NEW attempt key. */\n markFailed(): void { this.attempt.fail('host'); }\n\n /** The host did not use the token and nothing reached the processor (its call never left, the offline layer refused it): the form unlocks and the attempt key is KEPT. */\n markNotCharged(): void { this.attempt.markNotCharged(); }\n /** The host starts a deliberate SECOND payment of this payable (an explicit \"pay again\" flow): forgets the paid state this form saw, removes the succeeded record and moves the epoch so the next attempt has a NEW key. Does nothing against the host's own `paid` input. */\n resetPaid(): void { this.attempt.resetPaid(); }\n\n /** Builds the form again (clears the typed card; a token is single use, so call this after the host has used one). */\n reset(): void { this.resetTick.update(n => n + 1); }\n\n /** Removes the card form (host teardown). The component re-creates it when its inputs change. */\n destroyForm(): void { this.generation++; this.disposeInstances(); this.isReady.set(false); this.loading.set(false); }\n\n // ── Internals ──────────────────────────────────────────────────────────\n\n /** The gate before ANYTHING starts: a paid or unknown payable, offline, or a failed readiness check refuses (nothing is sent, the reason is reported). */\n private refusedByProtection(): boolean {\n if (!this.readiness.passSync()) {\n const reason = this.readiness.reasons()[0] ?? 'checking';\n this.outcome.emit({ kind: 'refused', attemptKey: this.attempt.key(), reason });\n this.fail(squareFailure(reason, this.labels.t(this.readiness.labelKeyFor(reason)), 'validate'));\n return true;\n }\n if (this.attempt.inFlight()) return true; // the host is charging the token of the earlier click: nothing may start (silent, like a double click)\n if (this.attempt.paidLocked() || this.attempt.unknown()) { this.attempt.begin(); return true; } // refuses and reports `refused`\n return false;\n }\n\n /** \"Retry loading\" of a blocked payment SDK: builds the form again (the loader asks Square's CDN again). */\n protected retryLoad(): void { this.reset(); }\n\n /** After a refused submit the focus goes to the bank field the message is about (the holder name or the authorization), once the view is up to date. */\n private focusInput(which: 'holder' | 'consent'): void {\n if (this.mountOnly()) return;\n const id = which === 'holder' ? this.holderTestId() : 'square-consent';\n afterNextRender(() => this.host.nativeElement.querySelector<HTMLElement>(`input[data-testid=\"${id}\"]`)?.focus(), { injector: this.injector });\n }\n\n private errorOptions(): SquareErrorMessageOptions {\n return { display: this.errorDisplay(), overrides: this.errorMessages(), ...(this.errorFallback() ? { fallback: this.errorFallback() } : {}) };\n }\n\n private shouldVerify(kind: SquareIntentKind, amount: number | null): boolean {\n const forced = this.verifyBuyer();\n if (forced !== null) return forced;\n return kind === 'payment' ? amount !== null && !!this.billingContact() : !!this.billingContact();\n }\n\n private async verify(token: string, kind: SquareIntentKind, amount: number | null): Promise<{ token: string } | SquareFailure> {\n const failure = (squareMessage = '') => squareFailure('verification_failed', this.labels.t('squarePayment.msg.verifyFailed'), 'verify', squareMessage);\n const verifyBuyer = this.payments?.verifyBuyer?.bind(this.payments);\n if (!verifyBuyer || (kind === 'payment' && amount === null)) return failure();\n const billing = this.billingContact();\n const details: SquareVerifyBuyerDetails = {\n intent: kind === 'setup' ? 'STORE' : 'CHARGE',\n ...(kind === 'payment' ? { amount: (Math.round((amount as number) * 100) / 100).toFixed(2), currencyCode: this.currency().toUpperCase() } : {}),\n ...(billing ? { billingContact: billing } : {}),\n customerInitiated: true,\n sellerKeyedIn: false,\n };\n try {\n const result = await verifyBuyer(token, details);\n return result?.token ? { token: result.token } : failure();\n } catch (err) {\n return failure(messageOfThrown(err, ''));\n }\n }\n\n private fail(f: SquareFailure): void {\n const override = this.errorMessages()?.[f.code];\n if (override) f = { ...f, message: override };\n if (this.destroyed) return;\n if (this.showErrors()) this.errorText.set(f.message);\n this.announcement.set('');\n this.failed.emit(f);\n }\n\n /** A `card()` / `ach()` that answers AFTER the form gave up on it (timeout, or the inputs changed): the late object is destroyed, never leaked. A rejection is ignored. */\n private discardLate(pending: Promise<{ destroy?(): Promise<void> | void }>): void {\n void pending.then(late => { try { void Promise.resolve(late.destroy?.()).catch(() => undefined); } catch { /* already gone */ } }, () => undefined);\n }\n\n private disposeInstances(): void {\n const card = this.card;\n const ach = this.ach;\n this.card = null;\n this.ach = null;\n if (this.announced) { this.announced = false; if (!this.destroyed) this.squareReady.emit(null); }\n for (const instance of [card, ach]) {\n if (!instance?.destroy) continue;\n try { void Promise.resolve(instance.destroy()).catch(() => undefined); } catch { /* the SDK may already have removed it */ }\n }\n }\n\n private loadFailed(code: string, message: string, squareMessage: string): void {\n this.loading.set(false);\n this.isReady.set(false);\n this.loadErrorText.set(this.loadErrorMessage());\n this.loadError.emit(squareFailure(code, message, 'load', squareMessage));\n }\n\n private async init(\n container: HTMLElement | null,\n method: SquareMethod,\n connection: SquareConnectionConfig,\n cardConfig: Record<string, unknown> | null,\n ach: { redirectUri: string | null; transactionId: string | null },\n ): Promise<void> {\n const generation = ++this.generation;\n this.disposeInstances();\n this.isReady.set(false);\n this.errorText.set('');\n this.loadErrorText.set('');\n this.announcement.set('');\n if (!this.isBrowser) { this.loading.set(false); return; }\n if (!connection.applicationId || !connection.locationId) { this.loadFailed('config_missing', this.labels.t('squarePayment.msg.configMissing'), ''); return; }\n this.loading.set(true);\n try {\n // No cache: every build of the form asks the loader again (the loader itself adds the SDK script once per page); the object is only this form's live handle.\n this.payments = null;\n const payments = await withSquareTimeout(this.loader(connection), () => new SquareLoadError('script_failed'));\n if (generation !== this.generation) return;\n this.payments = payments;\n const code = this.sdkLocaleCode();\n if (code && payments.setLocale) { try { await withSquareTimeout(Promise.resolve(payments.setLocale(code)), () => new Error('timeout')); } catch { /* an unsupported locale keeps the SDK default: never a load failure */ } if (generation !== this.generation) return; }\n } catch (err) {\n if (generation !== this.generation) return;\n this.loadFailed(err instanceof SquareLoadError ? err.code : 'load_error', this.labels.t('squarePayment.msg.loadFailed'), messageOfThrown(err, ''));\n return;\n }\n try {\n const payments = this.payments as SquarePaymentsLike;\n if (method === 'card') {\n // The token style is the base when no explicit style is given; `cardOptions` (and an explicit `cardStyle`) are spread over it, so options alone never switch `styleFromTokens` off.\n const tokenStyle = this.styleFromTokens() && cardConfig?.['style'] === undefined ? { style: readSquareCardStyle(this.doc, this.host.nativeElement) } : null;\n const options = tokenStyle || cardConfig ? { ...(tokenStyle ?? {}), ...(cardConfig ?? {}) } : null;\n const pendingCard = options ? payments.card(options) : payments.card();\n const card = await withSquareTimeout(pendingCard, () => new Error('timeout')).catch(err => { this.discardLate(pendingCard); throw err; });\n if (generation !== this.generation) { try { void Promise.resolve(card.destroy()).catch(() => undefined); } catch { /* gone */ } return; }\n this.card = card;\n for (const event of SQUARE_EDIT_EVENTS) card.addEventListener?.(event, () => { if (generation === this.generation && !this.submitting()) this.edited(); });\n try { await withSquareTimeout(card.attach(container as HTMLElement), () => new Error('timeout')); } catch (err) {\n if (generation !== this.generation) return;\n this.disposeInstances();\n this.loadFailed('mount_failed', this.labels.t('squarePayment.msg.cardFormFailed'), messageOfThrown(err, ''));\n return;\n }\n } else {\n const options: Record<string, unknown> = { ...(ach.redirectUri ? { redirectURI: ach.redirectUri } : {}), ...(ach.transactionId ? { transactionId: ach.transactionId } : {}) };\n const pendingAch = Object.keys(options).length ? payments.ach(options) : payments.ach();\n const instance = await withSquareTimeout(pendingAch, () => new Error('timeout')).catch(err => { this.discardLate(pendingAch); throw err; });\n if (generation !== this.generation) { try { void Promise.resolve(instance.destroy?.()).catch(() => undefined); } catch { /* gone */ } return; }\n this.ach = instance;\n }\n if (generation !== this.generation) return;\n this.loading.set(false);\n this.isReady.set(true);\n this.announced = true;\n this.squareReady.emit({ payments, card: this.card, ach: this.ach });\n this.ready.emit();\n } catch (err) {\n if (generation !== this.generation) return;\n this.disposeInstances();\n this.loadFailed('init_failed', this.labels.t(method === 'card' ? 'squarePayment.msg.cardFormFailed' : 'squarePayment.msg.achInitFailed'), messageOfThrown(err, ''));\n }\n }\n\n /** The payer edited something: clears the form's own error alert and tells the host. */\n protected edited(): void {\n if (this.errorText()) this.errorText.set('');\n this.detailsChange.emit();\n }\n\n /** The language the SDK should speak: the host's `sdkLocale`, else the app's active language. `null` = do not call `setLocale`. */\n private readonly sdkLocaleCode = computed((): string | null => {\n const given = this.sdkLocale();\n if (given === false) return null;\n if (given) return given;\n const language = (this.labels.locale() || '').toLowerCase().split('-')[0];\n return language === 'es' ? 'es-ES' : 'en-US';\n });\n\n protected onTab(key: string): void {\n if (this.submitting() || this.disabled() || this.attempt.locked() || (key !== 'card' && key !== 'ach')) return;\n this.method.set(key);\n this.errorText.set('');\n }\n}\n","import type { DestroyRef, WritableSignal } from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport type { Observable } from 'rxjs';\n\n/** The state of the seller's Square connection (the shape of contractor's `GET /integrations/square/status`, with the optional names a service may add). */\nexport interface SquareConnectStatus {\n connected: boolean;\n /** The integration is switched on for this account (informational). */\n enabled?: boolean;\n merchantId?: string | null;\n merchantName?: string | null;\n locationId?: string | null;\n locationName?: string | null;\n /** ISO date-time the connection was made. */\n connectedAt?: string | null;\n /** The access token was revoked or expired for good: the seller has to authorize again. */\n needsReconnect?: boolean;\n}\n\n/** What the start call answers: the address of Square's authorization page (`authUrl`, or `url`). */\nexport interface SquareConnectStart { authUrl?: string; url?: string }\n\n/**\n * What happened after the user pressed a button or the page asked for the state. The flow never shows toasts itself (each app has its own): the host words each outcome.\n *\n * - `connected`: the connection is live. `source: 'check'` = after \"Check Status\"; `'return'` = the state was read again when the user came back to this tab (`refreshOnReturn`).\n * - `needs-reconnect`: Square no longer accepts the saved authorization.\n * - `not-connected`: \"Check Status\" found no connection (the authorization was not finished).\n * - `disconnected`: the connection was removed.\n * - `link-unavailable`: the answer had no https Square address; nothing was opened.\n * - `failed`: a call failed (`action` says which); `error` is what it threw.\n */\nexport type SquareConnectOutcome =\n | { kind: 'connected'; source: 'check' | 'return' }\n | { kind: 'needs-reconnect'; source: 'check' | 'return' }\n | { kind: 'not-connected' }\n | { kind: 'disconnected' }\n | { kind: 'link-unavailable' }\n | { kind: 'failed'; action: 'start' | 'check' | 'disconnect'; error: unknown };\n\n/** The state the flow reads and writes: signals owned by the host (or by the card's two-way models). */\nexport interface SquareConnectState {\n status: WritableSignal<SquareConnectStatus | null>;\n loading: WritableSignal<boolean>;\n}\n\nexport interface SquareConnectFlowOptions {\n /** Read at call time, so a host can swap the call. Null = no call yet (`start()` does nothing). */\n start: () => (() => Observable<SquareConnectStart>) | null;\n getStatus: () => (() => Observable<SquareConnectStatus>) | null;\n disconnect: () => (() => Observable<unknown>) | null;\n state: SquareConnectState;\n /** Where outcomes go. */\n emit: (outcome: SquareConnectOutcome) => void;\n /** The buttons and methods do nothing while this says true (a read-only user). */\n disabled?: () => boolean;\n /** How THIS tab is sent to Square when the browser refused the new tab (default `window.location.href = url`). */\n navigate?: (url: string) => void;\n /** Called when Square's page was opened in a new tab (the card then offers \"Check Status\"). */\n onOpened?: () => void;\n destroyRef: DestroyRef;\n}\n\n/** Only an https address on Square's own domains (`squareup.com`, `squareupsandbox.com`, `square.com`, or a real subdomain): never `evilsquareup.com`, `http:` or `javascript:`. */\nexport function isSquareUrl(url: string | undefined | null): url is string {\n if (!url) return false;\n try {\n const u = new URL(url);\n return u.protocol === 'https:' && ['squareup.com', 'squareupsandbox.com', 'square.com'].some(d => u.hostname === d || u.hostname.endsWith(`.${d}`));\n } catch { return false; }\n}\n\n/**\n * The Square OAuth connection as a plain class: start (authorization page in a new tab), \"Check Status\", disconnect, and the \"back from Square\" read.\n * `ui-square-connect` runs it behind its card; a host that has to start the flow from code creates its own instance over the same state signals.\n * Square's page always opens in a NEW tab opened inside the click (a tab opened after the request is blocked by popup blockers); only an https Square address is\n * opened; a failed call closes the empty tab.\n */\nexport class SquareConnectFlow {\n /** A Square tab was opened: the card reads the state again when the user comes back (`refreshOnReturn`). */\n tabOpened = false;\n\n constructor(private readonly o: SquareConnectFlowOptions) {}\n\n private get blocked(): boolean { return this.o.state.loading() || !!this.o.disabled?.(); }\n\n /** Asks for the authorization address and opens Square's page in a new tab. */\n startConnect(): void {\n const start = this.o.start();\n if (!start || this.blocked) return;\n this.o.state.loading.set(true);\n const tab = this.openBlankTab();\n start().pipe(takeUntilDestroyed(this.o.destroyRef)).subscribe({\n next: result => {\n this.o.state.loading.set(false);\n this.openSquare(tab, result?.authUrl ?? result?.url);\n },\n error: error => {\n this.closeTab(tab);\n this.o.state.loading.set(false);\n this.o.emit({ kind: 'failed', action: 'start', error });\n },\n });\n }\n\n /** \"Check Status\": reads the state and reports it. */\n check(): void {\n const status = this.o.getStatus();\n if (!status || this.blocked) return;\n this.o.state.loading.set(true);\n status().pipe(takeUntilDestroyed(this.o.destroyRef)).subscribe({\n next: s => {\n this.o.state.status.set(s);\n this.o.state.loading.set(false);\n if (s.connected && s.needsReconnect) this.o.emit({ kind: 'needs-reconnect', source: 'check' });\n else if (s.connected) this.o.emit({ kind: 'connected', source: 'check' });\n else this.o.emit({ kind: 'not-connected' });\n },\n error: error => { this.o.state.loading.set(false); this.o.emit({ kind: 'failed', action: 'check', error }); },\n });\n }\n\n /** Removes the connection. The state becomes \"not connected\" only after the call succeeded. */\n disconnect(): void {\n const disconnect = this.o.disconnect();\n if (!disconnect || this.blocked) return;\n this.o.state.loading.set(true);\n disconnect().pipe(takeUntilDestroyed(this.o.destroyRef)).subscribe({\n next: () => {\n this.o.state.status.set({ connected: false });\n this.o.state.loading.set(false);\n this.o.emit({ kind: 'disconnected' });\n },\n error: error => { this.o.state.loading.set(false); this.o.emit({ kind: 'failed', action: 'disconnect', error }); },\n });\n }\n\n /** The state read when the user came back to this tab: silent unless a connection is live or needs to be redone. */\n readStatusOnReturn(): void {\n const status = this.o.getStatus();\n if (!status) return;\n status().pipe(takeUntilDestroyed(this.o.destroyRef)).subscribe({\n next: s => {\n this.o.state.status.set(s);\n if (s.connected && s.needsReconnect) this.o.emit({ kind: 'needs-reconnect', source: 'return' });\n else if (s.connected) this.o.emit({ kind: 'connected', source: 'return' });\n },\n error: () => { /* the user can press Check Status; a failed background read says nothing */ },\n });\n }\n\n private openSquare(tab: Window | null, url: string | undefined): void {\n // A blank tab the user already closed (before the answer arrived) cannot take the address: this tab is sent instead, like a refused tab.\n if (isSquareUrl(url) && tab && !tab.closed) {\n tab.location.href = url;\n this.tabOpened = true;\n this.o.onOpened?.();\n } else if (isSquareUrl(url)) {\n this.navigateCurrentTab(url);\n } else {\n // not an https Square address: never navigate to it, close the empty tab and say so\n this.closeTab(tab);\n this.o.emit({ kind: 'link-unavailable' });\n }\n }\n\n /** The empty tab, opened inside the click and cut from this page (`opener`); null when the browser refused. */\n openBlankTab(): Window | null {\n const tab = window.open('about:blank', '_blank');\n if (tab) { try { tab.opener = null; } catch { /* cannot be changed: harmless */ } }\n return tab;\n }\n\n /** The browser refused the new tab: Square opens in this one. */\n private navigateCurrentTab(url: string): void {\n if (this.o.navigate) this.o.navigate(url);\n else window.location.href = url;\n }\n\n private closeTab(tab: Window | null): void {\n try { tab?.close(); } catch { /* already closed */ }\n }\n}\n","import { NgTemplateOutlet } from '@angular/common';\nimport { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, Injector, ViewEncapsulation, afterNextRender, computed, effect, inject, input, model, output, signal } from '@angular/core';\nimport type { Observable } from 'rxjs';\nimport { SquareConnectFlow } from './square-connect.flow';\nimport type { SquareConnectOutcome, SquareConnectStart, SquareConnectStatus } from './square-connect.flow';\nexport type { SquareConnectOutcome, SquareConnectStart, SquareConnectStatus } from './square-connect.flow';\nexport { SquareConnectFlow, isSquareUrl } from './square-connect.flow';\nimport { BadgeComponent } from '@forgeroute/ui/badge';\nimport { ButtonComponent, ModalComponent, UiLabelsService, uiText } from '@forgeroute/ui/core';\nimport { DetailCardComponent } from '@forgeroute/ui/detail-card';\nimport { LiveRegionComponent } from '@forgeroute/ui/live-region';\nimport { StackComponent } from '@forgeroute/ui/stack';\nimport { TextComponent } from '@forgeroute/ui/text';\n\n/**\n * The default wording of an outcome, for apps that just want a toast: `{ variant, message }`, or null when nothing should be said.\n */\nexport function squareConnectNotice(outcome: SquareConnectOutcome): { variant: 'success' | 'info' | 'error'; message: string } | null {\n switch (outcome.kind) {\n case 'connected': return { variant: 'success', message: uiText('squareConnect.noticeConnected') };\n case 'needs-reconnect': return { variant: 'error', message: uiText('squareConnect.noticeReconnect') };\n case 'not-connected': return { variant: 'info', message: uiText('squareConnect.noticeNotConnected') };\n case 'disconnected': return { variant: 'success', message: uiText('squareConnect.noticeDisconnected') };\n case 'link-unavailable': return { variant: 'error', message: uiText('squareConnect.noticeLinkUnavailable') };\n case 'failed': return { variant: 'error', message: uiText(outcome.action === 'start' ? 'squareConnect.failedStart' : outcome.action === 'check' ? 'squareConnect.failedCheck' : 'squareConnect.failedDisconnect') };\n }\n}\n\nlet nextConnectId = 0;\n\n/**\n * \"Square account\": the card where a business connects the Square account it collects payments into (Square OAuth). The host owns the data (its three calls and the\n * status value); the component owns the screen and the flow:\n *\n * - not connected: \"Connect Square\" (opens Square's authorization page in a NEW tab, then offers \"Check Status\");\n * - connected: success with the merchant, the location and the date, \"Check Status\" and \"Disconnect\" (asks to confirm first);\n * - needs reconnect: warning with \"Reconnect\".\n *\n * The page opens in a NEW tab opened inside the click (a tab opened after the request is blocked by popup blockers) and receives the address when it arrives; with the\n * tab refused the address opens in the current tab. Only an https Square address is ever opened. A failed call closes the empty tab and is reported, never toasted.\n *\n * <ui-square-connect [(status)]=\"status\" [startConnect]=\"start\" [getStatus]=\"getStatus\" [disconnect]=\"disconnect\" [refreshOnReturn]=\"true\" (outcome)=\"onOutcome($event)\" />\n *\n * where `start = () => http.get<SquareConnectStart>('/integrations/square/connect')`, `getStatus = () => http.get<SquareConnectStatus>('/integrations/square/status')` and\n * `disconnect = () => http.delete('/integrations/square/disconnect')`.\n */\n@Component({\n selector: 'ui-square-connect',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [NgTemplateOutlet, BadgeComponent, ButtonComponent, DetailCardComponent, ModalComponent, LiveRegionComponent, StackComponent, TextComponent],\n template: `\n <!-- Persistent live region: present before the state changes, so every new state is announced (and \"Loading\" while a request runs). -->\n <ui-live-region data-testid=\"square-connect-live\" [message]=\"liveText()\" />\n @if (bare()) {\n <ng-container *ngTemplateOutlet=\"body\" />\n } @else {\n <ui-detail-card [collapsible]=\"false\" [title]=\"title()\" [headingLevel]=\"3\" data-testid=\"square-connect-card\">\n <ng-container *ngTemplateOutlet=\"body\" />\n </ui-detail-card>\n }\n\n <ng-template #body>\n @if (state() === 'none') {\n <ui-stack gap=\"sm\" class=\"sqc-state\" tabindex=\"-1\" data-testid=\"square-connect-status-none\" [attr.aria-busy]=\"loading() ? 'true' : null\">\n <ui-text size=\"lg\" weight=\"semibold\" [text]=\"startTitle()\" />\n <ui-text size=\"sm\" [text]=\"startText()\" />\n <ui-stack direction=\"horizontal\">\n <ui-button variant=\"primary\" size=\"sm\" data-testid=\"square-connect-start-button\" [disabled]=\"disabled()\" (click)=\"start()\">@if (loading()) {<span aria-hidden=\"true\">{{ labels.t('common.loadingellipsis') }}</span><span class=\"sqc-sr\">{{ labels.t('squareConnect.opensInNewTabBusy', { label: startLabel() }) }}</span>} @else { {{ startLabel() }}<span class=\"sqc-sr\">{{ labels.t('squareConnect.opensInNewTabSr') }}</span>}</ui-button>\n @if (awaiting()) {\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"square-connect-check-status-button\" [disabled]=\"disabled() || loading()\" (click)=\"check()\">{{ labels.t(loading() ? 'squareConnect.checking' : 'squareConnect.checkStatus') }}</ui-button>\n }\n </ui-stack>\n </ui-stack>\n } @else if (state() === 'reconnect') {\n <ui-stack gap=\"sm\" class=\"sqc-state\" tabindex=\"-1\" data-testid=\"square-connect-status-reconnect\" [attr.aria-busy]=\"loading() ? 'true' : null\">\n <span class=\"sqc-badge\"><ui-badge [label]=\"labels.t('squareConnect.needsReconnect')\" variant=\"red\" data-testid=\"square-connect-reconnect-badge\" /></span>\n <ui-text size=\"sm\" [text]=\"labels.t('squareConnect.reconnectText')\" />\n <ui-stack direction=\"horizontal\">\n <ui-button variant=\"primary\" size=\"sm\" data-testid=\"square-connect-reconnect-button\" [disabled]=\"disabled()\" (click)=\"start()\">@if (loading()) {<span aria-hidden=\"true\">{{ labels.t('common.loadingellipsis') }}</span><span class=\"sqc-sr\">{{ labels.t('squareConnect.opensInNewTabBusy', { label: labels.t('squareConnect.reconnect') }) }}</span>} @else { {{ labels.t('squareConnect.reconnect') }}<span class=\"sqc-sr\">{{ labels.t('squareConnect.opensInNewTabSr') }}</span>}</ui-button>\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"square-connect-disconnect-button\" [disabled]=\"disabled() || loading()\" (click)=\"askDisconnect()\">{{ labels.t('squareConnect.disconnect') }}</ui-button>\n </ui-stack>\n </ui-stack>\n } @else {\n <ui-stack gap=\"sm\" class=\"sqc-state\" tabindex=\"-1\" data-testid=\"square-connect-status-connected\" [attr.aria-busy]=\"loading() ? 'true' : null\">\n <ui-text size=\"lg\" weight=\"semibold\" [text]=\"labels.t('squareConnect.connected')\" />\n @if (merchant(); as merchant) { <ui-text size=\"sm\" tone=\"muted\" data-testid=\"square-connect-merchant\" [text]=\"labels.t('squareConnect.merchantLine', { merchant })\" /> }\n @if (location(); as location) { <ui-text size=\"sm\" tone=\"muted\" data-testid=\"square-connect-location\" [text]=\"labels.t('squareConnect.locationLine', { location })\" /> }\n @if (connectedOn(); as date) { <ui-text size=\"sm\" tone=\"muted\" data-testid=\"square-connect-date\" [text]=\"labels.t('squareConnect.connectedOn', { date })\" /> }\n <ui-stack direction=\"horizontal\">\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"square-connect-check-status-button\" [disabled]=\"disabled() || loading()\" (click)=\"check()\">{{ labels.t(loading() ? 'squareConnect.checking' : 'squareConnect.checkStatus') }}</ui-button>\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"square-connect-disconnect-button\" [disabled]=\"disabled() || loading()\" (click)=\"askDisconnect()\">{{ labels.t('squareConnect.disconnect') }}</ui-button>\n </ui-stack>\n </ui-stack>\n }\n </ng-template>\n\n <ui-modal [open]=\"confirming()\" [title]=\"labels.t('squareConnect.disconnectTitle')\" maxWidth=\"440px\" [describedBy]=\"confirmMessageId\" [busy]=\"loading()\" dialogTestId=\"square-connect-confirm\" (close)=\"cancelDisconnect()\">\n <p [id]=\"confirmMessageId\" class=\"sqc-confirm\" data-testid=\"square-connect-confirm-message\">{{ labels.t('squareConnect.disconnectMessage') }}</p>\n <ui-button modal-footer-left variant=\"secondary\" size=\"sm\" data-testid=\"square-connect-confirm-cancel\" [disabled]=\"loading()\" (click)=\"cancelDisconnect()\">{{ labels.t('common.cancel') }}</ui-button>\n <ui-button modal-footer-right variant=\"danger\" size=\"sm\" data-testid=\"square-connect-confirm-accept\" [loading]=\"loading()\" (click)=\"doDisconnect()\">{{ labels.t('squareConnect.disconnect') }}</ui-button>\n </ui-modal>\n `,\n styles: [`ui-square-connect { display: block; min-width: 0; } ui-square-connect .sqc-badge { display: flex; } ui-square-connect .sqc-confirm { margin: 0; font-size: 0.9375rem; line-height: 1.5; } ui-square-connect .sqc-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }`],\n encapsulation: ViewEncapsulation.None,\n})\nexport class SquareConnectComponent {\n /** Unique per instance: two connect cards on one page must not share the id the dialog's description points at. */\n protected readonly confirmMessageId = `sqc-disconnect-msg-${nextConnectId++}`;\n protected readonly labels = inject(UiLabelsService);\n private readonly destroyRef = inject(DestroyRef);\n private readonly injector = inject(Injector);\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /** The call that answers Square's authorization address (`{ authUrl }`). Needed for `start()`. */\n readonly startConnect = input<(() => Observable<SquareConnectStart>) | null>(null);\n /** The call that reads the connection's state. Needed for `check()` and `refreshOnReturn`. */\n readonly getStatus = input<(() => Observable<SquareConnectStatus>) | null>(null);\n /** The call that removes the connection. Needed for \"Disconnect\". */\n readonly disconnect = input<(() => Observable<unknown>) | null>(null);\n\n /** The connection state (null = not read yet = shown as not connected). Two-way: the component sets it after \"Check Status\" and \"Disconnect\". */\n readonly status = model<SquareConnectStatus | null>(null);\n\n readonly titleInput = input<string | null>(null, { alias: 'title' });\n readonly title = computed(() => this.titleInput() ?? this.labels.t('squareConnect.title'));\n /** No card around the content: the text and the buttons sit directly in the host's own card (a setup wizard step). `title` is not shown then. */\n readonly bare = input(false);\n readonly startTitleInput = input<string | null>(null, { alias: 'startTitle' });\n readonly startTitle = computed(() => this.startTitleInput() ?? this.labels.t('squareConnect.startTitle'));\n readonly startTextInput = input<string | null>(null, { alias: 'startText' });\n readonly startText = computed(() => this.startTextInput() ?? this.labels.t('squareConnect.startText'));\n readonly startLabelInput = input<string | null>(null, { alias: 'startLabel' });\n readonly startLabel = computed(() => this.startLabelInput() ?? this.labels.t('squareConnect.startLabel'));\n /** The buttons cannot be pressed (a read-only user). */\n readonly disabled = input(false);\n /** Ask before disconnecting (default true). */\n readonly confirmDisconnect = input(true);\n /** After a Square tab was opened, the state is read again when this tab becomes visible again (the user came back): `(outcome)` then reports `connected` / `needs-reconnect` with source `return`. */\n readonly refreshOnReturn = input(false);\n /** How the current tab is sent to Square when the browser refused the new tab (default: `window.location.href = url`). */\n readonly navigateTab = input<((url: string) => void) | null>(null);\n\n /** What happened (see {@link SquareConnectOutcome}); the host words it. */\n readonly outcome = output<SquareConnectOutcome>();\n\n /** A request is running: the buttons show \"Loading...\" / \"Checking...\" and cannot be pressed again. Two-way, so a host can read it. */\n readonly loading = model(false);\n\n protected readonly awaiting = signal(false);\n protected readonly confirming = signal(false);\n protected readonly state = computed((): 'none' | 'connected' | 'reconnect' => {\n const s = this.status();\n return !s?.connected ? 'none' : s.needsReconnect ? 'reconnect' : 'connected';\n });\n protected readonly merchant = computed(() => this.status()?.merchantName || this.status()?.merchantId || '');\n protected readonly location = computed(() => this.status()?.locationName || this.status()?.locationId || '');\n protected readonly connectedOn = computed(() => this.labels.formatDate(this.status()?.connectedAt ?? null, 'mediumDate'));\n /** What the persistent status region says: the current state, plus \"Loading.\" while a request runs. */\n protected readonly liveText = computed(() => {\n const text = this.labels.t(({ none: 'squareConnect.live.none', connected: 'squareConnect.live.connected', reconnect: 'squareConnect.live.reconnect' } as const)[this.state()]);\n return this.loading() ? this.labels.t('squareConnect.live.loading', { text }) : text;\n });\n /** The user pressed a button that started a request: when the screen then changes, focus moves to the new screen (the pressed button is gone). */\n private acted = false;\n private lastState = this.state();\n private readonly flow = new SquareConnectFlow({\n start: () => this.startConnect(),\n getStatus: () => this.getStatus(),\n disconnect: () => this.disconnect(),\n state: { status: this.status, loading: this.loading },\n emit: outcome => this.outcome.emit(outcome),\n disabled: () => this.disabled(),\n navigate: url => this.navigateCurrentTab(url),\n onOpened: () => this.awaiting.set(true),\n destroyRef: this.destroyRef,\n });\n\n constructor() {\n effect(() => {\n const state = this.state();\n if (this.loading()) return;\n const changed = state !== this.lastState;\n this.lastState = state;\n const focusIt = changed && this.acted;\n this.acted = false;\n if (state === 'connected') this.awaiting.set(false);\n if (focusIt) afterNextRender(() => this.host.nativeElement.querySelector<HTMLElement>('.sqc-state')?.focus(), { injector: this.injector });\n });\n if (typeof document !== 'undefined') {\n const onVisible = () => {\n if (document.visibilityState !== 'visible' || !this.flow.tabOpened || !this.refreshOnReturn() || this.loading()) return;\n this.flow.tabOpened = false;\n this.flow.readStatusOnReturn();\n };\n document.addEventListener('visibilitychange', onVisible);\n this.destroyRef.onDestroy(() => document.removeEventListener('visibilitychange', onVisible));\n }\n }\n\n /** Asks for the authorization address and opens Square's page in a new tab. */\n start(): void { const run = this.canRun(this.startConnect()); this.flow.startConnect(); this.acted ||= run; }\n\n /** \"Check Status\": reads the state; the card updates and the outcome is reported. */\n check(): void { const run = this.canRun(this.getStatus()); this.flow.check(); this.acted ||= run; }\n\n /** \"Disconnect\": asks for confirmation first (`confirmDisconnect`, default), then removes the connection. */\n askDisconnect(): void {\n if (this.disabled() || this.loading() || !this.disconnect()) return;\n if (this.confirmDisconnect()) this.confirming.set(true);\n else this.doDisconnect();\n }\n\n protected cancelDisconnect(): void { if (!this.loading()) this.confirming.set(false); }\n\n /** Removes the connection (what the confirm's button calls). */\n doDisconnect(): void {\n const run = this.canRun(this.disconnect());\n this.flow.disconnect();\n this.acted ||= run;\n this.confirming.set(false);\n }\n\n /** The flow will really send a request (the host gave the call, nothing is running, the card is not read-only). */\n private canRun(call: unknown): boolean { return !!call && !this.loading() && !this.disabled(); }\n\n /** The browser refused the new tab: Square opens in this one (through the host's `navigateTab` when it gave one). */\n protected navigateCurrentTab(url: string): void {\n const navigate = this.navigateTab();\n if (navigate) navigate(url);\n else window.location.href = url;\n }\n}\n","import type { HostResult, PaymentAllocation } from '@forgeroute/ui/payments';\nimport type { UiLabelKey } from '@forgeroute/ui/core';\nimport type { SquareFees } from '../payment-square-method/payment-square-method.models';\n\n/**\n * Card-reader (Square Terminal) types of the library. They mirror the answers of the payments service (`GET /v1/terminal/readiness`,\n * `GET /v1/terminal/readers/:id/ready`, the `terminal` object of a card-present payment; see forgeroute-payments `docs/API.md` section 16.3 and\n * `host-kit/contract/terminal-readiness.json`). The BROWSER never calls the service: every call below is a function the HOST supplies (it calls its own backend,\n * which calls the service), exactly like `ui-square-connect`.\n */\n\n/**\n * The ONE state of the reader setup, chosen by the service with this fixed precedence (first match wins). `checking` = the read was slow or failed (nothing is guessed). `unknown` is the OLD name of `checking`: it is still\n * ACCEPTED in an answer a host passes in (and read as `checking`), but the library never produces it: {@link normalizeReadiness} returns `checking`, no screen shows the word and no event carries it.\n */\nexport type SquareTerminalReadinessState = 'merchant_not_ready' | 'no_reader' | 'unsupported_only' | 'reader_ready' | 'reader_busy' | 'reader_pairing' | 'reader_offline' | 'checking' | 'unknown';\n\n/** The precedence of the service, first match wins (documentation and tests; the service already sends the winning state). */\nexport const SQUARE_TERMINAL_STATE_PRECEDENCE: readonly Exclude<SquareTerminalReadinessState, 'checking' | 'unknown'>[] = [\n 'merchant_not_ready', 'no_reader', 'unsupported_only', 'reader_ready', 'reader_busy', 'reader_pairing', 'reader_offline',\n];\n\nexport type SquareTerminalDeviceStatus = 'online' | 'offline' | 'registering';\n\n/** A reader as the service answers it (register / list / get / rename). */\nexport interface SquareTerminal {\n id: string;\n label?: string | null;\n status: SquareTerminalDeviceStatus | string;\n locationId?: string | null;\n deviceType?: string | null;\n serialNumber?: string | null;\n pairingCode?: string | null;\n action?: 'idle' | 'in_progress' | 'failed' | null;\n actionIntentId?: string | null;\n /** One of the supported smart readers (S700, S710, WisePOS E). Anything else cannot take a payment. */\n supported: boolean;\n /** Human model name, e.g. `Square Terminal`. */\n model?: string | null;\n /** A payment of this merchant waits on the reader, or the processor says it works on an action. */\n busy: boolean;\n /** Only names a payment of THIS merchant. */\n busyPaymentId?: string | null;\n}\n\n/** `GET /v1/terminal/readiness`. */\nexport interface SquareTerminalReadiness {\n state: SquareTerminalReadinessState;\n readers: SquareTerminal[];\n /** The single ready reader, else the most recently used ready reader, else null (the user picks). */\n defaultReaderId: string | null;\n checkedAt?: string;\n /** The processor read was slow or failed: nothing was guessed. */\n stale?: boolean;\n /**\n * Why the answer is what it is. With `merchant_not_ready`: `reconnect_required` (offers \"Reconnect payments\"), `sandbox`, `service_disabled` or `processor_unsupported` (see {@link SquareTerminalBannerReason}: the banner words these\n * with no button), anything else = payments are not set up yet (\"Set up payments\"). With `no_reader` / `unsupported_only`: the same three no-button reasons, otherwise the usual \"get a reader\" message.\n */\n reason?: SquareTerminalBannerReason | string;\n merchantStatus?: string;\n /** Why the processor read failed (`stale`): see {@link SquareTerminalTerminal.degradedReason}. */\n degradedReason?: SquareTerminalDegradedReason | string;\n}\n\n/** `GET /v1/terminal/readers/:id/ready` (the optional check right before a payment). */\nexport interface SquareTerminalReady {\n ready: boolean;\n reason: 'ok' | 'offline' | 'busy' | 'unsupported' | 'merchant_not_ready' | 'reconnect_required' | 'unknown' | string;\n reader?: SquareTerminal | null;\n checkedAt?: string;\n stale?: boolean;\n degradedReason?: SquareTerminalDegradedReason | string;\n}\n\n/**\n * Why the service could not read the processor (`terminal.degradedReason`): `processor_unreachable` / `processor_timeout` are transient (try again), `reconnect_required` (the processor refused our credentials) and\n * `processor_refused` (it refused the read) will NOT fix themselves: the payment account needs attention.\n */\nexport type SquareTerminalDegradedReason = 'processor_unreachable' | 'processor_timeout' | 'reconnect_required' | 'processor_refused';\n\n/**\n * `checking` = the processor could not be read in time (the stored payment is answered); `stale` is the same thing named after the `stale` flag. `unknown` is the OLD name: still ACCEPTED in the service's answer (read as\n * `checking`), never produced by the library; the screen words all three as \"still checking\" and never shows the word.\n */\nexport type SquareTerminalTerminalState = 'waiting' | 'declined' | 'failed' | 'succeeded' | 'canceled' | 'checking' | 'stale' | 'unknown';\n\n/** True for a terminal state that means \"the processor could not be read\": `checking`, `stale` and the old `unknown`. */\nexport function isTerminalChecking(state: SquareTerminalTerminalState | string | null | undefined): boolean {\n return state === 'checking' || state === 'stale' || state === 'unknown';\n}\n\n/**\n * The reasons a host may put in `SquareTerminalReadiness.reason` for the \"no usable reader\" banner. Each maps to its own plain message with NO action button:\n * - `sandbox`: the company is a sandbox account (\"Card readers are not available in a sandbox account.\"); apps map `merchant_not_ready` + this reason.\n * - `service_disabled`: the payments service is switched off (\"Card readers are turned off for this account.\").\n * - `processor_unsupported`: the company's processor can never use readers, e.g. QuickBooks (\"Card readers are not available with this payment processor.\").\n * Any other reason (including `reconnect_required`) or none keeps the usual messages and buttons. The table is `SQUARE_TERMINAL_BANNER_REASONS`.\n */\nexport type SquareTerminalBannerReason = 'sandbox' | 'service_disabled' | 'processor_unsupported';\n\n/** Reason -> label key of the no-button banner message. Exported for documentation and tests. */\nexport const SQUARE_TERMINAL_BANNER_REASONS: Readonly<Record<SquareTerminalBannerReason, UiLabelKey>> = {\n sandbox: 'stripeReaderBanner.sandbox',\n service_disabled: 'stripeReaderBanner.serviceDisabled',\n processor_unsupported: 'stripeReaderBanner.processorUnsupported',\n};\n\n/** The no-button label key for a readiness reason, or null when the reason has no special wording. */\nexport function readerBannerReasonKey(reason: string | null | undefined): UiLabelKey | null {\n return reason && Object.prototype.hasOwnProperty.call(SQUARE_TERMINAL_BANNER_REASONS, reason) ? SQUARE_TERMINAL_BANNER_REASONS[reason as SquareTerminalBannerReason] : null;\n}\n\n/** The `terminal` object of a card-present payment (also carried by a 409 `payment_in_flight`). */\nexport interface SquareTerminalTerminal {\n readerId: string;\n state: SquareTerminalTerminalState;\n declineCode?: string;\n message?: string;\n /** `false` with the state `waiting` = the reader dropped its connection while the payment waits. */\n readerOnline?: boolean;\n /** `unknown` + `stale`: the processor could not be read in time; the stored payment is answered. */\n stale?: boolean;\n checkedAt?: string;\n /** With `stale`: why the processor could not be read (transient or needs attention). */\n degradedReason?: SquareTerminalDegradedReason | string;\n /** From the 3rd consecutive stale read: how many stale reads in a row. */\n staleReads?: number;\n /** From the 3rd consecutive stale read: ISO time of the first stale read of the run (\"we cannot reach the processor since 10:42\"). */\n staleSince?: string;\n}\n\n/** What a card reader payment looks like (the service's payment view plus `terminal`). Only the fields the library reads are typed. */\nexport interface SquareTerminalPayment {\n id: string;\n status?: string;\n amountCents?: number;\n baseCents?: number;\n feeCents?: number;\n platformFeeCents?: number;\n brand?: string | null;\n last4?: string | null;\n attemptKey?: string;\n terminal?: SquareTerminalTerminal | null;\n /** `POST .../retry`: a second retry while the reader already waits is a replay. */\n replayed?: boolean;\n [key: string]: unknown;\n}\n\n/** What `startPayment` receives (the host maps it to `POST /v1/terminal/payments`). The amount is in major units. */\nexport interface SquareTerminalStartContext {\n readerId: string;\n /** The amount the customer owes before fees, major units (12.5 = $12.50). */\n amount: number;\n /** Stable per click and REUSED when the answer is lost; send it as the service's `attemptKey`. */\n attemptKey: string;\n payableRef: string | null;\n /** Always `'CARD_PRESENT'`. */\n paymentMethod: 'CARD_PRESENT';\n /**\n * The TOTAL in cents the payer saw (`Math.round(quote.totalAmount * 100)` of the CARD_PRESENT quote). Send it as the service's `expectedAmountCents`: a changed quote is refused with 409 `quote_changed` before the\n * reader is touched. Absent when the screen showed no quote.\n */\n expectedAmountCents?: number;\n /** Set only by the payment-panel integration: what the panel's other fields say. */\n receivedDate?: string;\n notes?: string | null;\n allocation?: PaymentAllocation;\n}\n\n/** What `estimateFees` receives for a reader payment. The quote is the CARD_PRESENT one and differs from the online card quote. */\nexport interface SquareTerminalFeeContext { amount: number; paymentMethod: 'CARD_PRESENT'; paymentMethodType: 'card_present' }\n\n/** `getPayment`: which payment to read. `paymentId` is known after the start answered; before that only the attempt key is. */\nexport interface SquareTerminalPaymentRef { paymentId: string | null; attemptKey: string }\n\nexport type SquareTerminalGetReadinessFn = () => HostResult<SquareTerminalReadiness>;\nexport type SquareTerminalStartFn = (ctx: SquareTerminalStartContext) => HostResult<SquareTerminalPayment>;\n/** Reads one payment with its `terminal` object. Answer `null` (or reject with 404) when no payment exists for the attempt key. */\nexport type SquareTerminalGetPaymentFn = (ref: SquareTerminalPaymentRef) => HostResult<SquareTerminalPayment | null>;\nexport type SquareTerminalRetryFn = (paymentId: string) => HostResult<SquareTerminalPayment>;\nexport type SquareTerminalCancelFn = (paymentId: string) => HostResult<unknown>;\nexport type SquareTerminalFeesFn = (ctx: SquareTerminalFeeContext) => HostResult<SquareFees>;\n\n/** The one bundle of host callbacks that turns card-reader mode on in `ui-square-payment-method` (`[reader]`). */\nexport interface SquareTerminalConfig {\n getReadiness: SquareTerminalGetReadinessFn;\n startPayment: SquareTerminalStartFn;\n getPayment: SquareTerminalGetPaymentFn;\n retryPayment: SquareTerminalRetryFn;\n cancelPayment: SquareTerminalCancelFn;\n /** The CARD_PRESENT fee quote. REQUIRED: a reader payment shows the breakdown (and sends `expectedAmountCents`) before the tap. */\n estimateFees: SquareTerminalFeesFn;\n /** The address of the receipt of a paid payment (host-built; only https or in-app `/paths` are linked). */\n receiptUrl?: (payment: SquareTerminalPayment) => string | null | undefined;\n /**\n * How often (ms) the waiting payment's status is read while the payer taps (default 2000). Clamped to {@link SQUARE_TERMINAL_POLL_MIN_MS}..{@link SQUARE_TERMINAL_POLL_MAX_MS}. The `[readerPollMs]` input of\n * `ui-square-payment-method`, when set, wins over this value.\n */\n pollMs?: number;\n}\n\n/** The fastest and the slowest status poll of a waiting reader payment (ms): a faster one would hammer the host's backend, a slower one would leave the payer staring at a stale screen. */\nexport const SQUARE_TERMINAL_POLL_MIN_MS = 500;\nexport const SQUARE_TERMINAL_POLL_MAX_MS = 30_000;\nconst SQUARE_TERMINAL_POLL_DEFAULT_MS = 2000;\n\n/** A poll cadence the library will actually use: not a finite number > 0 = the default (2000 ms); otherwise rounded and clamped to 500..30 000 ms. */\nexport function clampReaderPollMs(value: number | null | undefined): number {\n if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0) return SQUARE_TERMINAL_POLL_DEFAULT_MS;\n return Math.min(SQUARE_TERMINAL_POLL_MAX_MS, Math.max(SQUARE_TERMINAL_POLL_MIN_MS, Math.round(value)));\n}\n\n/** A refusal of `startPayment` / `retryPayment` the library words itself. */\nexport interface SquareTerminalRefusal {\n code: string;\n /** The service's own text, shown only for a code the library has no wording for. */\n message: string;\n paymentId: string | null;\n terminal: SquareTerminalTerminal | null;\n /** `reader_not_paired`: the pairing code the staff still has to enter on the Terminal, when the service sent it. */\n pairingCode?: string | null;\n /** `quote_changed`: the new total / fees in cents, as the service answered them. */\n amountCents?: number | null;\n feeCents?: number | null;\n platformFeeCents?: number | null;\n}\n\n/** Reads the flat `code`, status, `paymentId` and `terminal` of a failed host call (the error itself or its `error` body). */\nexport function readerErrorInfo(error: unknown): SquareTerminalRefusal & { status: number | null } {\n type Body = { code?: unknown; message?: unknown; paymentId?: unknown; pairingCode?: unknown; terminal?: unknown; amountCents?: unknown; feeCents?: unknown; platformFeeCents?: unknown };\n const e = error as (Body & { status?: unknown; response?: { status?: unknown } | null; error?: Body | null }) | null | undefined;\n const pick = <T>(guard: (v: unknown) => v is T, ...values: unknown[]): T | null => { for (const v of values) if (guard(v)) return v; return null; };\n const isString = (v: unknown): v is string => typeof v === 'string' && v.length > 0;\n const isCents = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v) && v >= 0;\n const isObject = (v: unknown): v is SquareTerminalTerminal => !!v && typeof v === 'object' && typeof (v as { state?: unknown }).state === 'string';\n const status = typeof e?.status === 'number' ? e.status : typeof e?.response?.status === 'number' ? e.response.status : null;\n const body = (e?.error && typeof e.error === 'object' ? e.error : null) as Body | null;\n // the quote_changed amounts are present only when the service sent them (a refusal without them has no such keys)\n const cents = (key: 'amountCents' | 'feeCents' | 'platformFeeCents'): Partial<Record<typeof key, number>> => { const v = pick(isCents, e?.[key], body?.[key]); return v === null ? {} : ({ [key]: v } as Partial<Record<typeof key, number>>); };\n return {\n code: (pick(isString, e?.code, body?.code) ?? '').toLowerCase(),\n message: pick(isString, body?.message, e?.message) ?? '',\n paymentId: pick(isString, e?.paymentId, body?.paymentId),\n terminal: pick(isObject, e?.terminal, body?.terminal),\n ...(safePairingCode(pick(isString, e?.pairingCode, body?.pairingCode)) ? { pairingCode: safePairingCode(pick(isString, e?.pairingCode, body?.pairingCode)) } : {}),\n ...cents('amountCents'), ...cents('feeCents'), ...cents('platformFeeCents'),\n status,\n };\n}\n\n/** A refusal without the HTTP status (the refusal the screen keeps is the same shape whatever the transport said). */\nexport function toRefusal(info: SquareTerminalRefusal & { status?: number | null }): SquareTerminalRefusal {\n const { status: _status, ...rest } = info;\n void _status;\n return rest;\n}\n\n/** What a payment was STARTED for (before fees, major units): `baseCents`, else the total minus the fees, else the total; `null` when the service gave no amount. Never 0 for a missing amount. */\nexport function paymentBaseAmount(payment: SquareTerminalPayment | null | undefined): number | null {\n if (!payment) return null;\n if (typeof payment.baseCents === 'number' && payment.baseCents > 0) return payment.baseCents / 100;\n if (typeof payment.amountCents === 'number' && payment.amountCents > 0) {\n const fees = (typeof payment.feeCents === 'number' ? payment.feeCents : 0) + (typeof payment.platformFeeCents === 'number' ? payment.platformFeeCents : 0);\n return Math.max(0, payment.amountCents - fees) / 100 || payment.amountCents / 100;\n }\n return null;\n}\n\n/** How the screen words a terminal the service could not read (`checking` / `stale`). */\nexport type SquareTerminalDegraded = { kind: 'transient' } | { kind: 'since'; since: string } | { kind: 'attention' };\n\n/**\n * `null` when the terminal was read normally. Otherwise: `attention` for a reason that will not fix itself (`reconnect_required`, `processor_refused`: \"the payment account needs attention\"), `since` from the 3rd\n * consecutive stale read (\"cannot reach the processor since 10:42\") and `transient` for the rest (`processor_unreachable`, `processor_timeout`, none given). Never a resubmit in any of them.\n */\nexport function readerDegraded(terminal: Pick<SquareTerminalTerminal, 'state' | 'stale' | 'degradedReason' | 'staleReads' | 'staleSince'> | null | undefined, locale?: string): SquareTerminalDegraded | null {\n if (!terminal || !(isTerminalChecking(terminal.state) || terminal.stale === true)) return null;\n if (terminal.degradedReason === 'reconnect_required' || terminal.degradedReason === 'processor_refused') return { kind: 'attention' };\n if (typeof terminal.staleReads === 'number' && terminal.staleReads >= 3 && terminal.staleSince) {\n const at = new Date(terminal.staleSince);\n if (!Number.isNaN(at.getTime())) {\n try { return { kind: 'since', since: new Intl.DateTimeFormat(locale, { hour: 'numeric', minute: '2-digit' }).format(at) }; } catch { /* fall through to transient */ }\n }\n }\n return { kind: 'transient' };\n}\n\n/** The TOTAL a payment charged (major units), from the service's `amountCents`; `null` when absent. */\nexport function paymentChargedAmount(payment: SquareTerminalPayment | null | undefined): number | null {\n return payment && typeof payment.amountCents === 'number' && payment.amountCents > 0 ? payment.amountCents / 100 : null;\n}\n\n/** The label key of the wording of a reader refusal code, or null for a code the library does not know (the service's message is shown). */\nexport function readerRefusalLabelKey(code: string): UiLabelKey | null {\n switch (code) {\n case 'reader_busy': return 'stripeReader.refusal.reader_busy';\n case 'reader_offline': return 'stripeReader.refusal.reader_offline';\n case 'reader_not_supported': return 'stripeReader.refusal.reader_not_supported';\n case 'reader_unreachable': return 'squareTerminal.refusal.reader_unreachable';\n // 400 on a start: the device code was registered but not entered on the Terminal yet (or it expired): nothing was created. `squareTerminal.refusal.reader_not_paired` carries the code when the answer had one.\n case 'reader_not_paired': return 'squareTerminal.refusal.reader_not_paired';\n case 'terminal_not_retryable': return 'stripeReader.refusal.terminal_not_retryable';\n case 'payment_in_flight': return 'stripeReader.refusal.payment_in_flight';\n case 'merchant_not_ready': return 'stripeReader.refusal.merchant_not_ready';\n case 'reconnect_required': return 'stripeReader.refusal.reconnect_required';\n case 'not_supported_by_processor': return 'stripeReader.refusal.not_supported_by_processor';\n case 'exceeds_amount_due': return 'stripeReader.refusal.exceeds_amount_due';\n case 'duplicate_suspected': return 'stripeReader.refusal.duplicate_suspected';\n case 'quote_changed': return 'stripeReader.refusal.quote_changed';\n case 'attempt_failed_use_new_key': return 'stripeReader.refusal.attempt_failed_use_new_key';\n case 'payment_being_sent': return 'stripeReader.refusal.payment_being_sent';\n // raised by the library itself (the attempt machine refused the click, a start / retry could not be settled, or the service answered 429)\n case 'paid': return 'stripeReader.refusal.paid';\n case 'offline': return 'stripeReader.refusal.offline';\n case 'outcome_checking':\n case 'outcome_unknown': return 'stripeReader.refusal.outcome_checking'; // `outcome_unknown` = the old code, still worded; the library raises `outcome_checking`\n case 'queued_offline': return 'stripeReader.refusal.queued_offline';\n case 'start_not_received': return 'stripeReader.refusal.start_not_received';\n case 'retry_unreachable': return 'stripeReader.refusal.retry_unreachable';\n case 'rate_limited': return 'stripeReader.refusal.rate_limited';\n default: return null;\n }\n}\n\n/** Codes that prove NOTHING was created or charged: the attempt is released (key kept) and the payer may start again. */\nexport const SQUARE_TERMINAL_NOT_CREATED_CODES: readonly string[] = [\n 'reader_busy', 'reader_offline', 'reader_not_supported', 'reader_not_paired', 'merchant_not_ready', 'reconnect_required', 'not_supported_by_processor', 'exceeds_amount_due', 'quote_changed',\n];\n\n/** The supported device: the Square Terminal (the service refuses anything else with 400 `reader_not_supported`). */\nexport const SQUARE_TERMINAL_MODELS: readonly { deviceType: string; model: string }[] = [\n { deviceType: 'square_terminal', model: 'Square Terminal' },\n];\n\nconst KNOWN_STATES: readonly SquareTerminalReadinessState[] = ['merchant_not_ready', 'no_reader', 'unsupported_only', 'reader_ready', 'reader_busy', 'reader_pairing', 'reader_offline', 'checking', 'unknown'];\n\n/** A defensive copy of an answer: an unrecognised state (or the old `unknown`) becomes `checking`, a missing list `[]` (nothing is ever guessed ready). The result's state is never `unknown`. */\nexport function normalizeReadiness(raw: unknown): SquareTerminalReadiness {\n const r = raw as Partial<SquareTerminalReadiness> | null | undefined;\n const readers = Array.isArray(r?.readers) ? r!.readers!.filter(x => !!x && typeof x.id === 'string') : [];\n let state = KNOWN_STATES.includes(r?.state as SquareTerminalReadinessState) ? (r!.state as SquareTerminalReadinessState) : 'checking';\n if (state === 'unknown') state = 'checking';\n // `reader_ready` with no reader that is supported, online and free can take no payment: nothing is guessed ready.\n if (state === 'reader_ready' && !readers.some(isReaderFree)) state = 'checking';\n return {\n state, readers, defaultReaderId: typeof r?.defaultReaderId === 'string' ? r.defaultReaderId : null,\n ...(r?.checkedAt ? { checkedAt: r.checkedAt } : {}), ...(r?.stale ? { stale: true } : {}), ...(r?.reason ? { reason: r.reason } : {}), ...(r?.merchantStatus ? { merchantStatus: r.merchantStatus } : {}),\n ...(r?.degradedReason ? { degradedReason: r.degradedReason } : {}),\n };\n}\n\n/**\n * \"10:42 AM\" of a moment, in the user's language (explicit locale, the user's own time zone). `''` for a missing / unreadable value. Library source 2026-11-21 (used by `ui-square-terminal-banner`: \"last confirmed at ...\").\n */\nexport function formatReaderTime(value: Date | string | number | null | undefined, locale?: string): string {\n if (value == null || value === '') return '';\n const at = value instanceof Date ? value : new Date(value);\n if (Number.isNaN(at.getTime())) return '';\n try { return new Intl.DateTimeFormat(locale, { hour: 'numeric', minute: '2-digit' }).format(at); } catch { return ''; }\n}\n\n/** The name a reader is shown under: its label, else its model, else its id. */\nexport function readerDisplayName(reader: Pick<SquareTerminal, 'id' | 'label' | 'model' | 'deviceType'> | null | undefined): string {\n if (!reader) return '';\n return reader.label?.trim() || reader.model?.trim() || SQUARE_TERMINAL_MODELS.find(m => m.deviceType === reader.deviceType)?.model || reader.id;\n}\n\n/** Can this reader take a payment right now (supported, online, free)? */\nexport function isReaderFree(reader: SquareTerminal): boolean { return reader.supported && reader.status === 'online' && !reader.busy; }\n\n/** Only an https address or an in-app `/path` is ever linked or opened (never `javascript:`, `data:`, `//host`). */\nexport function isSafeReceiptUrl(url: string | null | undefined): url is string {\n if (!url || /[\\u0000-\\u001f\\\\]/.test(url)) return false;\n if (url.startsWith('/') && !url.startsWith('//')) return true;\n try { return new URL(url).protocol === 'https:'; } catch { return false; }\n}\n\n/**\n * A device pairing code as it may be SHOWN: the code Square makes is a short run of letters and digits. The answer of the host is untrusted, so anything else (control characters, spaces, markup, a very long text) is not a code and\n * is never shown or announced: the screen then says to get a new code. Returns the trimmed code or `null`.\n */\nexport function safePairingCode(value: unknown): string | null {\n if (typeof value !== 'string') return null;\n const code = value.trim();\n return /^[A-Za-z0-9-]{3,32}$/.test(code) ? code : null;\n}\n\n/** `m:ss` of an elapsed time in ms (never negative). */\nexport function formatElapsed(ms: number): string {\n const total = Math.max(0, Math.floor((Number.isFinite(ms) ? ms : 0) / 1000));\n const m = Math.floor(total / 60);\n const s = total % 60;\n return `${m}:${s < 10 ? '0' : ''}${s}`;\n}\n\n// ── Square Terminal pairing ──\n\n/** What `registerTerminal` receives (the host maps it to `POST /v1/terminal/readers`: `label`, the Square `locationId`; Square ignores a registration code). */\nexport interface SquareTerminalRegisterContext { label: string; locationId?: string }\n\n/** What the host answers: the reader as the service returns it. Its `pairingCode` is the device code the staff enter on the Terminal (`null` once paired). */\nexport type SquareTerminalRegisterFn = (ctx: SquareTerminalRegisterContext) => HostResult<SquareTerminal>;\n\n/** True for a Square Terminal (`deviceType: 'square_terminal'`). */\nexport function isSquareTerminal(reader: Pick<SquareTerminal, 'deviceType'> | null | undefined): boolean { return reader?.deviceType === 'square_terminal'; }\n\n/** Dictionary keys of the card reader screens that read differently for a Square Terminal (looked up for keys built at run time: `stripeReader.status.<state>.title|text`, `stripeReader.wait.<phase>.text`). Any other key is the shared reader wording. */\nexport const SQUARE_TERMINAL_LABEL_KEYS: Readonly<Record<string, UiLabelKey>> = {\n 'stripeReader.status.no_reader.title': 'squareTerminal.status.no_reader.title',\n 'stripeReader.status.no_reader.text': 'squareTerminal.status.no_reader.text',\n 'stripeReader.status.unsupported_only.title': 'squareTerminal.status.unsupported_only.title',\n 'stripeReader.status.unsupported_only.text': 'squareTerminal.status.unsupported_only.text',\n 'stripeReader.status.reader_offline.title': 'squareTerminal.status.reader_offline.title',\n 'stripeReader.status.reader_offline.text': 'squareTerminal.status.reader_offline.text',\n 'stripeReader.status.reader_pairing.title': 'squareTerminal.status.reader_pairing.title',\n 'stripeReader.status.reader_pairing.text': 'squareTerminal.status.reader_pairing.text',\n 'stripeReader.wait.waiting.text': 'squareTerminal.wait.waiting.text',\n};\n\n/** The Square wording of a run-time built reader key, else the key itself. */\nexport function terminalLabelKey(key: UiLabelKey): UiLabelKey {\n return Object.prototype.hasOwnProperty.call(SQUARE_TERMINAL_LABEL_KEYS, key) ? SQUARE_TERMINAL_LABEL_KEYS[key] : key;\n}\n\n/**\n * What `ui-square-payment-method (readerLeftPending)` reports: the body went away (panel closed, method changed, plugin removed) or the reader screen was removed while a Terminal payment was open. The payment MAY STILL EXIST at the processor:\n * no `readerBusyChange(false)` is sent for it (the host keeps its other pay actions blocked and reads the server's own hold).\n */\nexport interface SquareTerminalLeftPending {\n reason: 'destroyed' | 'unmounted';\n /** The attempt key of the open Terminal payment, when known. */\n paymentAttemptKey?: string;\n}\n","import { computed, signal } from '@angular/core';\nimport { PAYMENT_REQUEST_TIMEOUT_MS, callHost, wasQueuedOffline, type HostResult } from '@forgeroute/ui/payments';\nimport {\n SQUARE_TERMINAL_NOT_CREATED_CODES, isTerminalChecking, paymentBaseAmount, readerErrorInfo, toRefusal,\n type SquareTerminalCancelFn, type SquareTerminalGetPaymentFn, type SquareTerminalPayment, type SquareTerminalRefusal, type SquareTerminalRetryFn,\n type SquareTerminalStartContext, type SquareTerminalStartFn, type SquareTerminalTerminal,\n} from './square-terminal.models';\n\n/**\n * Where a card reader payment is. One value, always:\n * - `idle`: nothing started (or an earlier payment ended: canceled / failed / refused);\n * - `starting`: the click was accepted and the payment is on its way to the service (the answer is not here yet);\n * - `recovering`: the answer of `starting` was lost (timeout, connection): the attempt key is looked up until the payment is found (or, after the grace period, the service still has none: then `recoveryExpired` is set and\n * the payer is asked to check again; only a second \"none\" answer, asked by the payer, releases the attempt). NEVER a second start;\n * - `waiting`: the reader waits for the customer to tap, insert or swipe;\n * - `declined`: the card was declined; the payment stays open (retry the SAME payment or cancel it);\n * - `stopped`: the reader stopped waiting without a decline; the payment stays open (retry or cancel);\n * - `retrying`: the same payment is being sent to the reader again;\n * - `cancelling`: a cancel is running (the payment is canceled ONLY when the service confirms);\n * - `succeeded`, `canceled`, `failed`: final.\n */\nexport type SquareTerminalPhase = 'idle' | 'starting' | 'recovering' | 'waiting' | 'declined' | 'stopped' | 'retrying' | 'cancelling' | 'succeeded' | 'canceled' | 'failed';\n\n/** What the flow needs of the payment-attempt machine (`PaymentAttempt` of `@forgeroute/ui/payments` fits it; specs use a fake). */\nexport interface SquareTerminalAttemptPort {\n begin(): { ok: true; key: string } | { ok: false; reason: 'locked' | 'paid' | 'unknown' | 'offline' };\n /** The key of the attempt in effect. */\n key(): string;\n /** The payment succeeded: locks the payable as paid. */\n succeed(reason?: string): void;\n /** A DEFINITIVE end without money (canceled, failed): unlocks with a NEW key. */\n fail(reason?: string): void;\n /** Nothing was created at the service: unlock, KEEP the key. */\n markNotCharged(): void;\n /** The answer of the start was lost: lock (key kept) until the payment is found. */\n markUnknown(reason: string): void;\n}\n\nexport type SquareTerminalFlowEvent =\n | { kind: 'started'; payment: SquareTerminalPayment; attemptKey: string }\n | { kind: 'declined'; payment: SquareTerminalPayment }\n | { kind: 'succeeded'; payment: SquareTerminalPayment; attemptKey: string }\n | { kind: 'canceled'; payment: SquareTerminalPayment | null }\n | { kind: 'failed'; payment: SquareTerminalPayment | null }\n | { kind: 'refused'; refusal: SquareTerminalRefusal }\n | { kind: 'connection-lost' }\n | { kind: 'connection-restored' };\n\nexport interface SquareTerminalFlowOptions {\n attempt: SquareTerminalAttemptPort;\n /** The calls are read at call time (a host may swap them); null = not provided (the action does nothing). */\n start: () => SquareTerminalStartFn | null;\n getPayment: () => SquareTerminalGetPaymentFn | null;\n retry: () => SquareTerminalRetryFn | null;\n cancel: () => SquareTerminalCancelFn | null;\n /** How often the open payment is read (default 2000 ms). */\n pollMs?: () => number;\n /** A poll slower than this counts as a lost connection (default 8000 ms). */\n pollTimeoutMs?: () => number;\n /** One start / retry / cancel call slower than this is treated as unreachable: a start becomes a lost answer (looked up by its attempt key, never re-sent), a retry / cancel leaves the payment as it was (default 60 000 ms). */\n requestTimeoutMs?: () => number;\n /** After a lost start answer (or an adopted attempt), \"no payment for this attempt key\" is believed only after this long, MEASURED FROM THE MOMENT RECOVERY STARTS (default 360 000 ms: the service may take up to 5 minutes to create the payment\n * of a request whose answer the browser gave up on, API.md 16.3, plus 1 minute of margin). */\n lostAnswerGraceMs?: () => number;\n now?: () => number;\n onEvent?: (event: SquareTerminalFlowEvent) => void;\n}\n\n/** What the screen passes to `start()`. */\nexport interface SquareTerminalStartInput {\n readerId: string;\n /** Major units. */\n amount: number;\n payableRef: string | null;\n /** The total in cents the payer saw (the CARD_PRESENT quote); sent as `expectedAmountCents`. */\n expectedAmountCents?: number;\n extras?: Pick<SquareTerminalStartContext, 'receivedDate' | 'notes' | 'allocation'>;\n}\n\nexport const SQUARE_TERMINAL_POLL_MS = 2000;\nexport const SQUARE_TERMINAL_POLL_TIMEOUT_MS = 8000;\n/** The service's create window (5 minutes) plus a minute of margin: \"no payment for this key\" earlier than this may only mean the payment is not created yet. */\nexport const SQUARE_TERMINAL_LOST_ANSWER_GRACE_MS = 6 * 60_000;\n/** A start / retry / cancel call that has not answered by then is unreachable (the library's request timeout). */\nexport const SQUARE_TERMINAL_REQUEST_TIMEOUT_MS = PAYMENT_REQUEST_TIMEOUT_MS;\n\n/** The service's definitive refusals of a start that prove nothing was created and that are NOT worded as \"not charged\" retries: the existing payment is shown. */\nconst DEFINITIVE_START_CODES: readonly string[] = ['duplicate_suspected'];\n\nconst OPEN: readonly SquareTerminalPhase[] = ['starting', 'recovering', 'waiting', 'declined', 'stopped', 'retrying', 'cancelling'];\nconst FINAL: readonly SquareTerminalPhase[] = ['succeeded', 'canceled', 'failed'];\n\n/**\n * The card reader payment flow as a plain class (no view): readiness is the screen's job, this starts ONE payment on a reader, follows it by polling the service through the host's calls, and lets the payer retry\n * (the SAME payment, never a new charge) or cancel it. `ui-square-terminal-payment` runs it; specs drive it with fake calls and a fake clock.\n *\n * Money rules it enforces:\n * - ONE payment at a time: `start()` is synchronous up to the attempt's `begin()` (a double click / second tab is refused) and every state in {@link OPEN} refuses another start;\n * - the attempt key is the one the attempt machine pinned at the click and is REUSED when the answer is lost (the service answers the same attempt key with the same payment, one intent, one reader action);\n * - a lost answer is never \"failed\": it is `recovering` (polling by attempt key) until the payment shows up, or the grace period has passed with the service still saying \"no payment for this key\";\n * - a cancel never claims success unless the service confirmed it (`reader_unreachable` leaves the payment open and says so);\n * - a poll that fails (connection lost) never changes the payment's state: it is reported and polling continues; the state shown on reconnect is the service's truth;\n * - the service's `terminal.state` `unknown` / `stale` is \"still checking\" (never an error, never a resubmit).\n */\nexport class SquareTerminalFlow {\n readonly phase = signal<SquareTerminalPhase>('idle');\n readonly payment = signal<SquareTerminalPayment | null>(null);\n readonly terminal = computed((): SquareTerminalTerminal | null => this.payment()?.terminal ?? null);\n /** The service could not read the processor (`terminal.state` `unknown` or `stale`): \"still checking\". */\n readonly checking = signal(false);\n /** The browser could not reach the host while a payment is open: the reader may still take the payment. */\n readonly connectionLost = signal(false);\n /** `recovering` only: the grace period is over and the service still has no payment for the attempt key. Polling stops; the payer is asked to \"Check again\" (`recheck()`), and only another \"none\" releases the attempt. */\n readonly recoveryExpired = signal(false);\n /** `recheck()` is running. */\n readonly rechecking = signal(false);\n /** The reader dropped its connection while the payment waits (`terminal.readerOnline === false`). */\n readonly readerOffline = signal(false);\n /** The last refusal of a start / retry (worded by the screen); cleared by the next start. */\n readonly refusal = signal<SquareTerminalRefusal | null>(null);\n /** A cancel could not be confirmed (the reader or the processor was unreachable): the payment is STILL open. */\n readonly cancelUnreachable = signal(false);\n /**\n * Square only: a cancel was REQUESTED while the payer was already paying on the Terminal (409 `reader_cancel_pending`, Square `CANCEL_REQUESTED`). The payment is STILL OPEN (the payer may still pay), the Terminal stays held and\n * nothing else may start: the screen says \"stopping the Terminal\", the payment is read until Square reports CANCELED (then `canceled`) or COMPLETED (then `succeeded`), and the payer may repeat the cancel. Never \"canceled\" on this alone.\n */\n readonly cancelPending = signal(false);\n readonly elapsedMs = signal(0);\n /** What the last start (or the adopted payment) is for, before fees (major units); `null` until known. */\n readonly baseAmount = computed((): number | null => paymentBaseAmount(this.payment()) ?? this.startInput()?.amount ?? null);\n /** The input of the last start (a signal, so the screen follows it). */\n readonly startInput = signal<SquareTerminalStartInput | null>(null);\n /** The attempt key of the payment being started / followed. */\n readonly attemptKey = signal<string | null>(null);\n /** No other payment may be started and the payer must not leave. */\n readonly locked = computed(() => OPEN.includes(this.phase()));\n /** A payment exists at the service and is not decided (cancel is possible). */\n readonly cancellable = computed(() => ['waiting', 'declined', 'stopped'].includes(this.phase()) && !!this.payment()?.id);\n readonly retryable = computed(() => ['declined', 'stopped'].includes(this.phase()) && !!this.payment()?.id);\n\n private disposed = false;\n private pollTimer: ReturnType<typeof setTimeout> | null = null;\n private tickTimer: ReturnType<typeof setInterval> | null = null;\n private pollGen = 0;\n private polling = false;\n private startedAt = 0;\n /** When recovery began (a lost start answer, or an adopted attempt): the grace is counted from here, never from the click. */\n private recoverStartedAt = 0;\n private explicitCheck = false;\n /** The payment id the service named in a 409 `request_in_progress` (the same attempt key is being created): used to read the payment while the answer of the start is lost. Never used to cancel. */\n private adoptedPaymentId: string | null = null;\n private cancelRun: Promise<boolean> | null = null;\n /** The phase to go back to when a retry or a cancel did not change anything. */\n private before: SquareTerminalPhase = 'waiting';\n\n constructor(private readonly o: SquareTerminalFlowOptions) {}\n\n private now(): number { return this.o.now ? this.o.now() : Date.now(); }\n private emit(event: SquareTerminalFlowEvent): void { if (!this.disposed) this.o.onEvent?.(event); }\n\n /** Starts ONE payment on a reader. Synchronous up to the attempt's `begin()`: a second click in the same tick is refused. */\n async start(input: SquareTerminalStartInput): Promise<void> {\n if (this.disposed || this.locked() || this.phase() === 'succeeded') return;\n const start = this.o.start();\n if (!start) return;\n const begun = this.o.attempt.begin();\n if (!begun.ok) {\n if (begun.reason !== 'locked') this.refuse({ code: begun.reason === 'unknown' ? 'outcome_checking' : begun.reason, message: '', paymentId: null, terminal: null });\n return;\n }\n this.phase.set('starting');\n this.startInput.set(input);\n this.attemptKey.set(begun.key);\n this.startedAt = this.now();\n this.elapsedMs.set(0);\n this.refusal.set(null);\n this.cancelUnreachable.set(false);\n this.cancelPending.set(false);\n this.connectionLost.set(false);\n this.checking.set(false);\n this.recoveryExpired.set(false);\n this.payment.set(null);\n this.adoptedPaymentId = null;\n this.startTick();\n const ctx: SquareTerminalStartContext = {\n readerId: input.readerId, amount: input.amount, attemptKey: begun.key, payableRef: input.payableRef, paymentMethod: 'CARD_PRESENT',\n ...(input.expectedAmountCents !== undefined && Number.isFinite(input.expectedAmountCents) && input.expectedAmountCents >= 1 ? { expectedAmountCents: Math.round(input.expectedAmountCents) } : {}),\n ...(input.extras ?? {}),\n };\n let answer: SquareTerminalPayment | null | undefined;\n try { answer = await this.call(() => start(ctx)); } catch (error) { this.onStartError(error); return; }\n if (this.disposed) return;\n if (wasQueuedOffline(answer)) {\n // The offline layer queued the request (a synthetic 202): nothing reached the service. Payments are never queued.\n this.o.attempt.markNotCharged();\n this.endNotCreated({ code: 'queued_offline', message: '', paymentId: null, terminal: null });\n return;\n }\n if (!answer || typeof answer.id !== 'string' || !answer.id) { this.lostAnswer(); return; }\n this.emit({ kind: 'started', payment: answer, attemptKey: begun.key });\n this.apply(answer);\n this.schedulePoll();\n }\n\n private onStartError(error: unknown): void {\n if (this.disposed) return;\n const info = readerErrorInfo(error);\n // The key can never complete (a failed payment superseded by a newer one, returned by the bank...): a DEFINITIVE end of this key, the attempt starts again with a NEW key. Never a lost answer.\n if (info.code === 'attempt_failed_use_new_key') {\n this.o.attempt.fail('replay');\n this.endNotCreated(toRefusal(info));\n return;\n }\n // The same attempt key is being created right now (`request_in_progress`, whatever the status): the payment may exist, so NEVER a second start and never idle. It is looked up by its attempt key (and by the payment id when the service names it).\n if (info.code === 'request_in_progress') {\n if (info.paymentId) this.adoptedPaymentId = info.paymentId;\n this.lostAnswer();\n return;\n }\n // Another payment of this reference holds the reader: when it IS a card reader payment (`terminal` is answered) it is followed, so staff can cancel / retry / watch the open payment instead of being stuck.\n if (info.code === 'payment_in_flight' && info.paymentId && info.terminal) {\n // The marker is KEPT (unknown) while the open payment is followed: a reload or a second tab must not find a free screen while a payment waits on the reader. It ends with the followed payment (succeeded / canceled / failed).\n this.o.attempt.markUnknown('payment_in_flight');\n this.follow({ id: info.paymentId, status: 'CREATED', terminal: info.terminal }, toRefusal(info));\n return;\n }\n // The reader holds another payment, or this reference has an open payment of another attempt (or a suspected duplicate): nothing was created by THIS click.\n if (info.code === 'payment_in_flight' || DEFINITIVE_START_CODES.includes(info.code) || SQUARE_TERMINAL_NOT_CREATED_CODES.includes(info.code)) {\n this.o.attempt.markNotCharged();\n this.endNotCreated(toRefusal(info));\n return;\n }\n // 429 (a risk block or a rate limit): the service creates NOTHING (API.md), so it is a definitive \"not created\". The same attempt key is idempotent at the service, so the payer may simply try again.\n if (info.status === 429) {\n this.o.attempt.markNotCharged();\n this.endNotCreated({ ...toRefusal(info), code: 'rate_limited' });\n return;\n }\n // A definitive refusal of the request itself (a 4xx the service answered, no code we know): nothing was created either. 408 (gateway timeout), 409 and 425 (too early) can follow a request the service already took: those are a lost answer.\n if (info.status !== null && info.status >= 400 && info.status < 500 && info.status !== 408 && info.status !== 409 && info.status !== 425) {\n this.o.attempt.markNotCharged();\n this.endNotCreated(toRefusal(info));\n return;\n }\n // Timeout, connection, 5xx, 408/409/425 without a known code: the payment may exist.\n this.lostAnswer();\n }\n\n /** Follows an open reader payment of another attempt (the service said so with `payment_in_flight` + `terminal`): the screen shows it like its own, with its refusal text above. */\n private follow(payment: SquareTerminalPayment, refusal: SquareTerminalRefusal): void {\n this.stopTick();\n this.startTick();\n this.payment.set(payment);\n this.phase.set('waiting');\n this.apply(payment);\n this.refuse(refusal);\n if (!FINAL.includes(this.phase())) this.schedulePoll();\n }\n\n /**\n * A reload or a second tab found an UNDECIDED attempt of this payable (the attempt machine is `unknown`): the payment may be waiting on a reader right now. The attempt key is looked up (never a new start)\n * until the payment shows up (then it is followed like any other) or, after the grace period, the service still has none.\n */\n adopt(): void {\n if (this.disposed || this.locked() || FINAL.includes(this.phase())) return;\n this.attemptKey.set(this.o.attempt.key());\n this.adoptedPaymentId = null;\n this.startedAt = this.now();\n this.recoverStartedAt = this.now();\n this.recoveryExpired.set(false);\n this.elapsedMs.set(0);\n this.refusal.set(null);\n this.startTick();\n this.phase.set('recovering');\n this.schedulePoll();\n }\n\n private endNotCreated(refusal: SquareTerminalRefusal): void {\n this.recoveryExpired.set(false);\n this.stopTick();\n this.stopPolling();\n this.phase.set('idle');\n this.refuse(refusal);\n }\n\n private refuse(refusal: SquareTerminalRefusal): void {\n this.refusal.set(refusal);\n this.emit({ kind: 'refused', refusal });\n }\n\n /** The answer of the start is lost: lock with the key kept and look the attempt key up until the payment shows up. */\n private lostAnswer(): void {\n this.o.attempt.markUnknown('timeout');\n this.recoverStartedAt = this.now();\n this.recoveryExpired.set(false);\n this.phase.set('recovering');\n this.schedulePoll();\n }\n\n // ── Polling ──────────────────────────────────────────────────────────────\n\n /** Reads the payment now (also after the browser says it is back online). */\n pollNow(): void {\n if (this.disposed || !this.shouldPoll()) return;\n this.stopPolling();\n void this.pollOnce(this.pollGen);\n }\n\n /** The browser reports offline / online. Offline only marks the loss; the next successful poll restores. */\n markConnection(online: boolean): void {\n if (this.disposed || !this.shouldPoll()) return;\n if (!online) this.setConnectionLost(true);\n else this.pollNow();\n }\n\n private shouldPoll(): boolean { return ['recovering', 'waiting', 'declined', 'stopped', 'retrying'].includes(this.phase()); }\n\n private schedulePoll(): void {\n this.stopPolling();\n if (this.disposed || !this.shouldPoll() || this.recoveryExpired()) return;\n const gen = this.pollGen;\n const every = Math.max(1, this.o.pollMs?.() ?? SQUARE_TERMINAL_POLL_MS);\n this.pollTimer = setTimeout(() => { this.pollTimer = null; void this.pollOnce(gen); }, every);\n }\n\n private stopPolling(): void {\n this.pollGen++;\n if (this.pollTimer) { clearTimeout(this.pollTimer); this.pollTimer = null; }\n }\n\n private async pollOnce(gen: number): Promise<void> {\n const read = this.o.getPayment();\n if (!read || this.polling || gen !== this.pollGen || !this.shouldPoll()) { if (gen === this.pollGen) this.schedulePoll(); return; }\n this.polling = true;\n const phaseAtStart = this.phase();\n const explicit = this.explicitCheck;\n let answer: SquareTerminalPayment | null | 'failed' = 'failed';\n let notFound = false;\n let timer: ReturnType<typeof setTimeout> | null = null;\n try {\n const timeout = new Promise<'timeout'>(resolve => { timer = setTimeout(() => resolve('timeout'), this.o.pollTimeoutMs?.() ?? SQUARE_TERMINAL_POLL_TIMEOUT_MS); });\n const result = await Promise.race([callHost(() => read({ paymentId: this.payment()?.id ?? this.adoptedPaymentId, attemptKey: this.attemptKey() ?? this.o.attempt.key() })), timeout]);\n if (result === 'timeout') answer = 'failed';\n else if (result && typeof result === 'object' && typeof result.id === 'string') answer = result;\n else { answer = null; notFound = true; }\n } catch (error) {\n const info = readerErrorInfo(error);\n if (info.status === 404 && !this.payment() && !this.adoptedPaymentId) { answer = null; notFound = true; } else answer = 'failed';\n } finally { if (timer) clearTimeout(timer); this.polling = false; }\n if (this.disposed || gen !== this.pollGen) return;\n if (answer === 'failed') {\n this.setConnectionLost(true);\n } else if (answer) {\n this.setConnectionLost(false);\n if (phaseAtStart === 'recovering' && this.phase() === 'recovering') this.emit({ kind: 'started', payment: answer, attemptKey: this.attemptKey() ?? '' });\n this.apply(answer);\n } else if (notFound) {\n this.setConnectionLost(false);\n if (this.phase() === 'recovering' && this.now() - this.recoverStartedAt >= Math.max(0, this.o.lostAnswerGraceMs?.() ?? SQUARE_TERMINAL_LOST_ANSWER_GRACE_MS)) {\n if (explicit && this.recoveryExpired()) {\n // The payer asked again AFTER the grace (longer than the service needs to create a payment) and the service still has none for this key: nothing was created. The marker is released (key kept: the service answers the same key with the same payment).\n this.o.attempt.markNotCharged();\n this.endNotCreated({ code: 'start_not_received', message: '', paymentId: null, terminal: null });\n return;\n }\n // The grace is over and the service still says \"none\": never claim \"nothing was charged\" on this alone. Polling stops, the marker stays, the payer is asked to check again.\n this.recoveryExpired.set(true);\n this.stopPolling();\n return;\n }\n }\n this.schedulePoll();\n }\n\n /**\n * \"Check again\" of an unconfirmed payment (`recoveryExpired`): reads the attempt key once more. Found: followed like any payment. Still none (the grace is over): the attempt is released and the payer may start again (the same key is\n * idempotent at the service). A failed read changes nothing (connection lost) and the payer can check again.\n */\n async recheck(): Promise<void> {\n if (this.disposed || this.phase() !== 'recovering' || !this.recoveryExpired() || this.polling || this.rechecking()) return;\n this.explicitCheck = true;\n this.rechecking.set(true);\n this.stopPolling();\n try { await this.pollOnce(this.pollGen); } finally { this.explicitCheck = false; this.rechecking.set(false); }\n }\n\n private setConnectionLost(lost: boolean): void {\n if (this.connectionLost() === lost) return;\n this.connectionLost.set(lost);\n this.emit({ kind: lost ? 'connection-lost' : 'connection-restored' });\n }\n\n // ── Applying what the service says ──────────────────────────────────────\n\n /** Applies a payment answer (a start / read / retry answer). Only an OPEN phase follows it: a late answer after a final state changes nothing. */\n private apply(payment: SquareTerminalPayment): void {\n if (this.disposed || FINAL.includes(this.phase())) return;\n this.payment.set(payment);\n const status = String(payment.status ?? '').toUpperCase();\n const t = payment.terminal ?? null;\n if (status === 'SUCCEEDED' || t?.state === 'succeeded') { this.settle('succeeded'); return; }\n if (status === 'CANCELED' || t?.state === 'canceled') { this.settle('canceled'); return; }\n if (status === 'FAILED') { this.settle('failed'); return; }\n this.recoveryExpired.set(false);\n this.checking.set(!!t && (isTerminalChecking(t.state) || t.stale === true));\n this.readerOffline.set(!!t && t.readerOnline === false);\n // While a cancel or a retry runs, a poll answer never moves the phase (a decline read meanwhile would show \"Try again\" while the retry request is still in flight); a final state (succeeded / canceled / failed) still settles above.\n const busyOp = this.phase() === 'cancelling' || this.phase() === 'retrying';\n if (t?.state === 'declined') { if (!busyOp) { const was = this.phase(); this.phase.set('declined'); if (was !== 'declined') this.emit({ kind: 'declined', payment }); } return; }\n if (t?.state === 'failed') { if (!busyOp) this.phase.set('stopped'); return; }\n // waiting, unknown (still checking) or no terminal object: the reader waits\n if (!busyOp) this.phase.set('waiting');\n }\n\n private settle(phase: 'succeeded' | 'canceled' | 'failed'): void {\n const payment = this.payment();\n this.stopPolling();\n this.stopTick();\n this.checking.set(false);\n this.connectionLost.set(false);\n this.readerOffline.set(false);\n this.cancelUnreachable.set(false);\n this.cancelPending.set(false);\n this.recoveryExpired.set(false);\n this.phase.set(phase);\n if (phase === 'succeeded') {\n const key = this.attemptKey() ?? this.o.attempt.key();\n this.o.attempt.succeed('reader');\n if (payment) this.emit({ kind: 'succeeded', payment, attemptKey: key });\n } else {\n this.o.attempt.fail(phase);\n this.emit({ kind: phase, payment });\n }\n }\n\n // ── Retry and cancel ────────────────────────────────────────────────────\n\n /** After a decline (or a stop): sends the SAME payment to the reader again. Never creates a payment. */\n async retry(): Promise<void> {\n const retry = this.o.retry();\n const id = this.payment()?.id;\n if (this.disposed || !retry || !id || !this.retryable()) return;\n this.before = this.phase();\n this.phase.set('retrying');\n this.refusal.set(null);\n this.stopPolling();\n try {\n const answer = await this.call(() => retry(id));\n if (this.disposed) return;\n if (answer && typeof answer.id === 'string') { this.phase.set(this.before); this.apply(answer); } else { this.phase.set(this.before); }\n this.schedulePoll();\n } catch (error) {\n if (this.disposed) return;\n const info = readerErrorInfo(error);\n this.phase.set(this.before);\n // The payment is not open any more (a tap or a cancel happened meanwhile): read it, show its real state.\n if (info.code === 'terminal_not_retryable') { this.refuse(toRefusal(info)); this.pollNow(); return; }\n this.refuse(toRefusal(info.code ? info : { ...info, code: 'retry_unreachable' }));\n this.schedulePoll();\n }\n }\n\n /**\n * Cancels the payment at the service. Resolves true only when the service confirmed the cancel (or already reports the payment canceled). While it runs the payment is `cancelling`; when the\n * service cannot reach the reader or the processor (503 `reader_unreachable`, a lost connection) the payment STAYS open, `cancelUnreachable` is set and the payer may cancel again.\n */\n cancel(): Promise<boolean> {\n if (this.cancelRun) return this.cancelRun;\n const cancel = this.o.cancel();\n const id = this.payment()?.id;\n if (this.disposed || !cancel || !id || !(this.cancellable() || (this.phase() === 'cancelling'))) return Promise.resolve(this.phase() === 'canceled');\n this.cancelRun = this.runCancel(cancel, id).finally(() => { this.cancelRun = null; });\n return this.cancelRun;\n }\n\n private async runCancel(cancel: SquareTerminalCancelFn, id: string): Promise<boolean> {\n this.before = this.phase() === 'cancelling' ? this.before : this.phase();\n this.phase.set('cancelling');\n this.cancelUnreachable.set(false);\n this.cancelPending.set(false);\n this.refusal.set(null);\n this.stopPolling();\n try {\n await this.call(() => cancel(id));\n if (this.disposed) return false;\n this.settle('canceled');\n return true;\n } catch (error) {\n if (this.disposed) return false;\n const info = readerErrorInfo(error);\n this.phase.set(this.before);\n if (info.code === 'payment_being_sent') {\n // The payment is still being sent to the reader: nothing could be canceled yet. Say so (\"wait a moment, then cancel again\"); the poll keeps following it. The service's instruction is `replay_attempt_key`, but a\n // second start is never sent from here: the payment is already known, and the poll (by attempt key) shows its real state. The id of the payment being cancelled is the one already known (a different id in the body is ignored).\n this.refuse(toRefusal(info));\n this.schedulePoll();\n return false;\n }\n if (info.code === 'reader_cancel_pending') {\n // Square CANCEL_REQUESTED: the cancel is not done and the payer may still pay. The payment stays open and the Terminal held (never released, never \"canceled\"); it is read until Square settles it.\n this.cancelPending.set(true);\n this.pollNow();\n return false;\n }\n if (info.status === 409 && info.code !== 'reader_unreachable') {\n // A tap that already happened (or races the cancel) is recorded as the payment: read the truth now.\n this.pollNow();\n return false;\n }\n this.cancelUnreachable.set(true);\n this.schedulePoll();\n return false;\n }\n }\n\n /** Runs one host call raced against the request timeout: a call that never answers cannot lock the flow forever. A late answer after the timeout is ignored (the next poll reads the truth). */\n private async call<T>(thunk: () => HostResult<T>): Promise<T> {\n let timer: ReturnType<typeof setTimeout> | null = null;\n try {\n const timeout = new Promise<never>((_, reject) => {\n timer = setTimeout(() => reject(Object.assign(new Error('request timeout'), { status: null, code: '' })), Math.max(1, this.o.requestTimeoutMs?.() ?? SQUARE_TERMINAL_REQUEST_TIMEOUT_MS));\n });\n return await Promise.race([callHost(thunk), timeout]);\n } finally { if (timer) clearTimeout(timer); }\n }\n\n /** From `canceled` / `failed`: back to a fresh start (a NEW key, the attempt machine already renewed it). */\n reset(): void {\n if (this.disposed || !(['canceled', 'failed'] as SquareTerminalPhase[]).includes(this.phase())) return;\n this.phase.set('idle');\n this.payment.set(null);\n this.refusal.set(null);\n this.attemptKey.set(null);\n this.elapsedMs.set(0);\n }\n\n /** The input of the last start (the screen re-sends it after \"Start again\"). */\n lastStartInput(): SquareTerminalStartInput | null { return this.startInput(); }\n\n // ── Elapsed time ────────────────────────────────────────────────────────\n\n private startTick(): void {\n this.stopTick();\n this.tickTimer = setInterval(() => this.elapsedMs.set(Math.max(0, this.now() - this.startedAt)), 1000);\n }\n\n private stopTick(): void {\n if (this.tickTimer) { clearInterval(this.tickTimer); this.tickTimer = null; }\n }\n\n /** The screen is gone: timers stop. Nothing is cancelled here (the screen decides; a payment that is open stays open at the service and is found again by its attempt key). */\n dispose(): void {\n this.disposed = true;\n this.stopPolling();\n this.stopTick();\n }\n}\n","import { ChangeDetectionStrategy, Component, ViewEncapsulation, computed, inject, input, output } from '@angular/core';\nimport { AlertComponent } from '@forgeroute/ui/alert';\nimport { ButtonComponent, UiLabelsService, type UiLabelKey } from '@forgeroute/ui/core';\nimport { LiveRegionComponent } from '@forgeroute/ui/live-region';\nimport { SkeletonComponent } from '@forgeroute/ui/skeleton';\nimport { readerDegraded, readerDisplayName, terminalLabelKey, type SquareTerminalReadiness, type SquareTerminalReadinessState } from './square-terminal.models';\n\n/**\n * The state the banner shows: the service's single readiness state, `loading` while a first read runs, `checking` when there is no usable answer (the read failed, was slow, or the service could not tell), and `attention` when the service says the payment account\n * needs attention. The component NEVER produces a state named `unknown` (the type keeps the member only because the readiness INPUT may carry it).\n */\nexport type SquareTerminalBannerState = SquareTerminalReadinessState | 'loading' | 'checking' | 'attention';\n\n/**\n * The ONE card-reader banner. It is rendered from the service's single readiness `state` (never from several flags), so a payment screen can never show two reader messages at once:\n *\n * - `merchant_not_ready`: payments are not set up (action: open payment setup); with the reason `reconnect_required` the payment account must be reconnected (\"Reconnect payments\", the same `openSetup` output: the host opens the place where the account is set up / reconnected);\n * - `no_reader` / `unsupported_only`: \"No Square Terminal set up\" with the ONE action \"How to get one\" (the host opens an info card);\n * - `reader_pairing` (Square Terminal only): a device code was created but not entered on the Terminal yet: \"Square Terminal waiting for its code\" with \"Connect Your Terminal\" (a new code) and \"Check again\";\n * - `reader_busy`: \"A payment is waiting on <reader>\" (+ \"Cancel that payment\" when the payment is this screen's own);\n * - `reader_offline`: \"Card reader not connected\" + \"Connect Your Terminal\" + \"Check again\";\n * - `checking`: there is no usable answer (the check failed, was too slow, or the service could not tell; nothing is guessed): \"Checking the card reader\" + \"Check again\"; when the service says WHY and it will not fix itself (`degradedReason` `reconnect_required` / `processor_refused`) the state is `attention`: the payment account needs attention (+ \"Reconnect payments\"). There is no state named `unknown`;\n * - `reader_ready`: no banner (a polite announcement only).\n *\n * The component has no HTTP: the host reads the readiness (see `ui-square-terminal-payment` / `ui-square-terminals`) and passes it in; the buttons are outputs.\n *\n * <ui-square-terminal-status [readiness]=\"readiness()\" [loading]=\"loading()\" (connectReader)=\"openPairing()\" (getReader)=\"openOrder()\" (recheck)=\"reload()\" />\n */\n@Component({\n selector: 'ui-square-terminal-status',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n imports: [AlertComponent, ButtonComponent, LiveRegionComponent, SkeletonComponent],\n template: `\n <ui-live-region data-testid=\"reader-status-live\" [message]=\"liveText()\" />\n @switch (state()) {\n @case ('loading') {\n <div class=\"srs-loading\" data-testid=\"reader-status-loading\" [attr.aria-busy]=\"'true'\">\n <ui-skeleton [height]=\"44\" [ariaLabel]=\"labels.t('stripeReader.status.loading')\" />\n </div>\n }\n @case ('reader_ready') { }\n @default {\n <ui-alert [variant]=\"variant()\" [title]=\"title()\" [quiet]=\"true\" class=\"srs-alert\" data-testid=\"reader-status\" [attr.data-state]=\"state()\">\n <p class=\"srs-text\" data-testid=\"reader-status-text\">{{ text() }}</p>\n <div class=\"srs-actions\">\n @if (state() === 'no_reader' || state() === 'unsupported_only') {\n <!-- no Terminal yet: the ONLY action is how to get one -->\n <ui-button variant=\"primary\" size=\"sm\" data-testid=\"reader-status-get\" (click)=\"getReader.emit()\">{{ labels.t('squareTerminal.status.getInfo') }}</ui-button>\n }\n @if (state() === 'merchant_not_ready' || attention()) {\n <ui-button variant=\"primary\" size=\"sm\" data-testid=\"reader-status-setup\" (click)=\"openSetup.emit()\">{{ labels.t(reconnect() || attention() ? 'stripeReader.status.reconnect' : 'stripeReader.status.setup') }}</ui-button>\n }\n @if ((state() === 'reader_pairing' || state() === 'reader_offline') && !hideConnect()) {\n <!-- a Terminal exists but is not connected (its code expired or was lost, or it is offline): connecting again gives a new code (the service answers the same code for a repeat inside 60 seconds) -->\n <ui-button variant=\"primary\" size=\"sm\" data-testid=\"reader-status-connect\" (click)=\"connectReader.emit()\">{{ labels.t('squareTerminal.status.connectYours') }}</ui-button>\n }\n @if (state() === 'reader_offline' || state() === 'reader_pairing' || state() === 'checking' || state() === 'attention') {\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"reader-status-recheck\" (click)=\"recheck.emit()\">{{ labels.t('stripeReader.status.recheck') }}</ui-button>\n }\n @if (state() === 'reader_busy') {\n @if (ownBusyPaymentId()) {\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"reader-status-cancel\" [loading]=\"cancelling()\" [disabled]=\"cancelling()\" (click)=\"cancelBusy.emit(ownBusyPaymentId()!)\">{{ labels.t('stripeReader.status.cancelBusy') }}</ui-button>\n }\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"reader-status-recheck\" (click)=\"recheck.emit()\">{{ labels.t('stripeReader.status.recheck') }}</ui-button>\n }\n @if (showManual()) {\n <ui-button variant=\"ghost\" size=\"sm\" data-testid=\"reader-status-manual\" (click)=\"manual.emit()\">{{ labels.t('stripeReader.status.manual') }}</ui-button>\n }\n </div>\n </ui-alert>\n }\n }\n `,\n styles: [`\n ui-square-terminal-status { display: block; min-width: 0; }\n ui-square-terminal-status .srs-text { margin: 0 0 8px; }\n ui-square-terminal-status .srs-actions { display: flex; flex-wrap: wrap; gap: 8px; }\n `],\n})\nexport class SquareTerminalStatusComponent {\n protected readonly labels = inject(UiLabelsService);\n\n /** The service's last readiness answer (`null` = none yet or the read failed). */\n readonly readiness = input<SquareTerminalReadiness | null>(null);\n /** A read is running and there is no answer to show yet: a skeleton. */\n readonly loading = input(false);\n /** The id of a payment THIS screen started and that holds the reader: the banner then offers \"Cancel that payment\". */\n readonly ownBusyPaymentId = input<string | null>(null);\n /** That cancel is running. */\n readonly cancelling = input(false);\n /** Adds \"Take a manual payment instead\" (a payment screen that has a manual path). */\n readonly showManual = input(false);\n /** Hides \"Connect Your Terminal\" (the pairing screen itself shows the banner). */\n readonly hideConnect = input(false);\n /**\n * Kept for backward compatibility: Square sells no Terminal in the app, so the no-Terminal action is always \"How to get one\" (`getReader`, the host opens an info card) and this input changes nothing.\n */\n readonly hardwareShopAvailable = input(true);\n\n /** \"Connect Your Terminal\" (`reader_pairing`, `reader_offline`): the host opens its pairing panel (`ui-square-terminals`). */\n readonly connectReader = output<void>();\n /** \"Get a card reader\": the host opens its order flow. */\n readonly getReader = output<void>();\n /** \"Check again\". */\n readonly recheck = output<void>();\n /** \"Set up payments\": the host opens payment setup. */\n readonly openSetup = output<void>();\n /** \"Cancel that payment\" (the payment id). */\n readonly cancelBusy = output<string>();\n /** \"Take a manual payment instead\". */\n readonly manual = output<void>();\n\n /** Which banner: no answer and loading = `loading`; no answer and not loading = `checking`; a service `checking` (old name `unknown`) = `attention` (reason that will not fix itself) or `checking`; else the service's state. Never `unknown`. */\n readonly state = computed((): SquareTerminalBannerState => {\n const r = this.readiness();\n if (!r) return this.loading() ? 'loading' : 'checking';\n if (r.state === 'checking' || r.state === 'unknown') return readerDegraded({ state: 'checking', stale: true, degradedReason: r.degradedReason })?.kind === 'attention' ? 'attention' : 'checking'; // `unknown` = the old name, accepted\n return r.state;\n });\n\n protected readonly variant = computed(() => (this.state() === 'no_reader' || this.state() === 'unsupported_only' || this.state() === 'reader_busy' ? 'info' : 'warning'));\n\n private readonly busyName = computed(() => {\n const r = this.readiness();\n const reader = r?.readers.find(x => x.busy) ?? r?.readers.find(x => x.id === r.defaultReaderId) ?? null;\n return reader ? readerDisplayName(reader) : this.labels.t('squareTerminal.theReader');\n });\n\n /** `merchant_not_ready` because the payment account must be reconnected (the service's `reason`). Any other merchant status (onboarding, disconnected...) is \"not set up\". */\n protected readonly reconnect = computed(() => this.state() === 'merchant_not_ready' && this.readiness()?.reason === 'reconnect_required');\n /** The service could not read the processor for a reason that will not fix itself (`reconnect_required`, `processor_refused`): the account needs attention. Transient reasons (and none) stay \"checking, check again\". */\n protected readonly attention = computed(() => this.state() === 'attention');\n /** The label group of the banner: the state, or a more exact one for a reconnect / attention case. */\n private readonly textKey = computed(() => (this.reconnect() ? 'reconnect_required' : this.attention() ? 'stale_attention' : this.state()));\n\n protected readonly title = computed(() => this.labels.t(terminalLabelKey(`stripeReader.status.${this.textKey()}.title` as UiLabelKey)));\n protected readonly text = computed(() => this.labels.t(terminalLabelKey(`stripeReader.status.${this.textKey()}.text` as UiLabelKey), { reader: this.busyName() }));\n\n /** What the polite region says: the banner's title (a change of state is announced), \"ready\" for a ready reader, nothing while loading. */\n protected readonly liveText = computed(() => {\n const state = this.state();\n if (state === 'loading') return '';\n if (state === 'reader_ready') {\n const r = this.readiness();\n const reader = r?.readers.find(x => x.id === r.defaultReaderId) ?? r?.readers.find(x => x.supported && x.status === 'online' && !x.busy);\n return this.labels.t('stripeReader.status.reader_ready.live', { reader: reader ? readerDisplayName(reader) : this.labels.t('squareTerminal.theReader') });\n }\n return `${this.title()}. ${this.text()}`;\n });\n}\n","import { NgTemplateOutlet } from '@angular/common';\nimport { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, Injector, ViewEncapsulation, afterNextRender, computed, effect, inject, input, isDevMode, output, signal, untracked } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { AlertComponent } from '@forgeroute/ui/alert';\nimport { ButtonComponent, UiLabelsService, type UiLabelKey } from '@forgeroute/ui/core';\nimport { IconComponent } from '@forgeroute/ui/icon';\nimport { LiveRegionComponent } from '@forgeroute/ui/live-region';\nimport { SelectComponent } from '@forgeroute/ui/select';\nimport { SkeletonComponent } from '@forgeroute/ui/skeleton';\nimport { PAYMENT_ATTEMPT_STORAGE, PaymentAttempt, builtInReadinessReasons, callHost, type PaymentAllocation } from '@forgeroute/ui/payments';\nimport { formatCurrency } from '@forgeroute/ui/utils';\nimport type { SquareFees } from '../payment-square-method/payment-square-method.models';\nimport { SQUARE_TERMINAL_LOST_ANSWER_GRACE_MS, SQUARE_TERMINAL_REQUEST_TIMEOUT_MS, SquareTerminalFlow, type SquareTerminalFlowEvent } from './square-terminal.flow';\nimport { SquareTerminalStatusComponent } from './square-terminal-status.component';\nimport {\n clampReaderPollMs, formatElapsed, isReaderFree, isSafeReceiptUrl, normalizeReadiness, paymentChargedAmount, readerDegraded, readerDisplayName, readerErrorInfo, readerRefusalLabelKey, terminalLabelKey,\n type SquareTerminalCancelFn, type SquareTerminalFeesFn, type SquareTerminalGetPaymentFn, type SquareTerminalGetReadinessFn, type SquareTerminalPayment, type SquareTerminalReadiness,\n type SquareTerminalReadinessState, type SquareTerminalRetryFn, type SquareTerminalStartFn,\n} from './square-terminal.models';\n\n/** The readiness states the panel's top banner speaks for: no usable Terminal, or a Terminal that is not connected (offline / waiting for its pairing code). */\nconst SQUARE_TERMINAL_NO_READER_STATES: readonly SquareTerminalReadinessState[] = ['no_reader', 'unsupported_only', 'merchant_not_ready', 'reader_offline', 'reader_pairing'];\n\n/** What `(succeeded)` reports. */\nexport interface SquareTerminalSucceededEvent {\n payment: SquareTerminalPayment;\n attemptKey: string;\n /** The amount the payment was STARTED with (major units, before fees). */\n amount: number;\n readerId: string;\n}\n\n/** What `(outcome)` reports, for a host that wants to word a toast or log (the component never toasts). */\nexport type SquareTerminalOutcome =\n | { kind: 'started'; payment: SquareTerminalPayment }\n | { kind: 'declined'; payment: SquareTerminalPayment }\n | { kind: 'canceled' }\n | { kind: 'failed' }\n | { kind: 'refused'; code: string }\n | { kind: 'connection-lost' }\n | { kind: 'connection-restored' }\n /** The panel was closed while the answer of the start was still on its way / lost: the payment is looked up again when the screen opens. The host may word it (\"We are still confirming your payment\"). */\n | { kind: 'left-pending' };\n\n/**\n * Takes a card payment on a Square Terminal: the card reader flow of the payment screen. The HOST owns the calls (it calls its own backend, which calls the\n * payments service; the browser never talks to the service), the component owns the screen and the flow ({@link SquareTerminalFlow}):\n *\n * 1. it reads the readiness (ONE state, see `ui-square-terminal-status`) now and every `readinessEveryMs`, and shows the ONE banner when the reader cannot be used;\n * 2. with `reader_ready` it shows the reader, the amount and the card-reader FEE quote (`estimateFees`, method CARD_PRESENT: cleared at once when the amount changes, \"Send to the reader\"\n * stays off until the quote for the current amount is here), and \"Send to the Terminal\" (a card taken on a Square Terminal is never kept: there is no \"Save this card\");\n * 3. while a payment waits: \"Waiting for the customer to tap, insert or swipe their card on <reader>\", the amount, the fees, the elapsed time and ONLY \"Cancel payment\";\n * 4. a decline shows \"Card declined\" with \"Try again\" (the SAME payment) / \"Cancel payment\" / \"Take a manual payment instead\" (a Square Terminal declines ON the device, so this state is rare); a cancel that Square only REQUESTED (`reader_cancel_pending`) keeps the payment open with \"stopping the Terminal\"; a success shows the receipt link.\n *\n * Nothing else can start a payment while one is open (every start button is off, a double click and a second tab are refused by the attempt machine), the attempt key is stable per click and\n * REUSED when the answer is lost, and a lost connection never changes the state shown: the payment is read again by its attempt key when the connection is back. Offline / slow connections\n * block \"Send to the reader\" before it starts (payments are never queued). A manual payment is always one click away (`(manual)`).\n *\n * <ui-square-terminal-payment [amount]=\"amount()\" payableRef=\"unit:42\" [getReadiness]=\"readiness\" [startPayment]=\"start\" [getPayment]=\"read\" [retryPayment]=\"retry\" [cancelPayment]=\"cancel\"\n * [estimateFees]=\"fees\" (manual)=\"useManual()\" (connectReader)=\"openPairing()\" (getReader)=\"openOrder()\" (succeeded)=\"onPaid($event)\" />\n */\n@Component({\n selector: 'ui-square-terminal-payment',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n imports: [FormsModule, NgTemplateOutlet, AlertComponent, ButtonComponent, IconComponent, LiveRegionComponent, SelectComponent, SkeletonComponent, SquareTerminalStatusComponent],\n template: `\n <ui-live-region data-testid=\"reader-live\" [message]=\"announcement()\" />\n @if (blockReason(); as reason) {\n @if (showBlocked()) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-blocked\" [attr.data-reason]=\"reason\">{{ blockText() }}</ui-alert>\n }\n } @else if (showReadiness()) {\n <ui-square-terminal-status [readiness]=\"shownReadiness()\" [loading]=\"readinessLoading() && !readiness()\" [ownBusyPaymentId]=\"busyOwnPaymentId()\" [cancelling]=\"cancellingBusy()\"\n [hideConnect]=\"false\"\n (connectReader)=\"connectReader.emit()\" (getReader)=\"getReader.emit()\" (recheck)=\"loadReadiness()\" (openSetup)=\"openSetup.emit()\" (cancelBusy)=\"cancelBusy($event)\" />\n }\n\n @if (active()) {\n @if (closeBlocked() && flow.locked()) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-close-blocked\">{{ labels.t('stripeReader.closeBlocked') }}</ui-alert>\n }\n\n @switch (flow.phase()) {\n @case ('starting') {\n <section class=\"srp-box srp-focus\" data-testid=\"reader-starting\" tabindex=\"-1\" [attr.aria-busy]=\"'true'\">\n <ui-skeleton [height]=\"44\" [ariaLabel]=\"labels.t('squareTerminal.starting')\" />\n <p class=\"srp-text\">{{ labels.t('squareTerminal.startingText') }}</p>\n @if (waitAmount(); as shown) { <p class=\"srp-text\" data-testid=\"reader-wait-amount\">{{ shown }}</p> }\n <p class=\"srp-elapsed\" data-testid=\"reader-leave-hint\">{{ labels.t('stripeReader.leaveHint') }}</p>\n </section>\n }\n @case ('succeeded') {\n <ui-alert variant=\"success\" [title]=\"labels.t('stripeReader.done.title')\" data-testid=\"reader-succeeded\" tabindex=\"-1\" class=\"srp-focus\">\n <p class=\"srp-text\" data-testid=\"reader-succeeded-text\">{{ succeededText() }}</p>\n @if (cardLine(); as card) { <p class=\"srp-text\" data-testid=\"reader-succeeded-card\">{{ card }}</p> }\n @if (receiptHref(); as href) {\n <p class=\"srp-text\"><a [href]=\"href\" target=\"_blank\" rel=\"noopener noreferrer\" data-testid=\"reader-receipt\">{{ labels.t('stripeReader.receipt') }}<span class=\"srp-sr\">{{ labels.t('squareConnect.opensInNewTabSr') }}</span></a></p>\n }\n </ui-alert>\n @if (feeRows().length) { <ng-container [ngTemplateOutlet]=\"feeTable\" /> }\n }\n @case ('canceled') {\n <ui-alert variant=\"info\" [title]=\"labels.t('stripeReader.canceled.title')\" data-testid=\"reader-canceled\" tabindex=\"-1\" class=\"srp-focus\">\n <p class=\"srp-text\">{{ labels.t('squareTerminal.canceled.text') }}</p>\n <div class=\"srp-actions\">\n @if (manualAvailable()) { <ui-button variant=\"primary\" size=\"sm\" data-testid=\"reader-take-manual\" (click)=\"manual.emit()\">{{ labels.t('stripeReader.takeManual') }}</ui-button> }\n <ui-button [variant]=\"manualAvailable() ? 'secondary' : 'primary'\" size=\"sm\" data-testid=\"reader-start-again\" (click)=\"startAgain()\">{{ labels.t('stripeReader.startAgain') }}</ui-button>\n </div>\n </ui-alert>\n }\n @case ('failed') {\n <ui-alert variant=\"danger\" [title]=\"labels.t('stripeReader.failed.title')\" data-testid=\"reader-failed\" tabindex=\"-1\" class=\"srp-focus\">\n <p class=\"srp-text\">{{ labels.t('stripeReader.failed.text') }}</p>\n <div class=\"srp-actions\">\n @if (manualAvailable()) { <ui-button variant=\"primary\" size=\"sm\" data-testid=\"reader-take-manual\" (click)=\"manual.emit()\">{{ labels.t('stripeReader.takeManual') }}</ui-button> }\n <ui-button [variant]=\"manualAvailable() ? 'secondary' : 'primary'\" size=\"sm\" data-testid=\"reader-start-again\" (click)=\"startAgain()\">{{ labels.t('stripeReader.startAgain') }}</ui-button>\n </div>\n </ui-alert>\n }\n @case ('idle') {\n <section class=\"srp-box\" data-testid=\"reader-ready-section\">\n @switch (idleNotice()) {\n @case ('paid') {\n <ui-alert variant=\"info\" [quiet]=\"true\" data-testid=\"reader-paid\">{{ labels.t('stripeReader.refusal.paid') }}</ui-alert>\n }\n @case ('pending-other') {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-pending-other\">{{ labels.t('stripeReader.refusal.outcome_checking') }}</ui-alert>\n }\n @case ('cancel-timeout') {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-cancel-busy-timeout\">{{ labels.t('stripeReader.cancelBusy.timeout') }}\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"reader-cancel-busy-recheck\" (click)=\"dismissCancelTimeout()\">{{ labels.t('stripeReader.status.recheck') }}</ui-button>\n </ui-alert>\n }\n @case ('quote-changed') {\n @if (flow.refusal(); as refusal) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-refusal\" [attr.data-code]=\"refusal.code\">{{ refusalText() }}</ui-alert>\n }\n <div class=\"srp-actions\" role=\"group\" data-testid=\"reader-quote-changed\">\n <ui-button variant=\"primary\" size=\"sm\" data-testid=\"reader-confirm-total\" [disabled]=\"quoting()\" (click)=\"confirmNewTotal()\">{{ labels.t('stripeReader.confirmTotal', { amount: confirmTotalText() }) }}</ui-button>\n </div>\n }\n @case ('refusal') {\n @if (flow.refusal(); as refusal) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-refusal\" [attr.data-code]=\"refusal.code\">{{ refusalText() }}\n @if (refusal.code === 'reader_not_paired') {\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"reader-refusal-connect\" (click)=\"connectReader.emit()\">{{ labels.t('squareTerminal.status.connect') }}</ui-button>\n }\n @if (existingPaymentHref(); as href) {\n <a [href]=\"href\" target=\"_blank\" rel=\"noopener noreferrer\" data-testid=\"reader-existing-payment\">{{ labels.t('stripeReader.refusal.viewExisting') }}<span class=\"srp-sr\">{{ labels.t('squareConnect.opensInNewTabSr') }}</span></a>\n }\n </ui-alert>\n }\n }\n }\n @if (ready() && !blockReason()) {\n @if (freeReaders().length > 1) {\n <ui-select [label]=\"labels.t('stripeReader.selectReader')\" [options]=\"readerOptions()\" [ngModel]=\"readerId()\" (ngModelChange)=\"selectedReaderId.set($event ?? '')\" data-testid=\"reader-select\" />\n } @else {\n <p class=\"srp-text\" data-testid=\"reader-name\">{{ labels.t('squareTerminal.readerLine', { reader: readerName() }) }}</p>\n }\n @if (amount() == null) {\n <p class=\"srp-text\" data-testid=\"reader-amount-needed\">{{ labels.t('squarePaymentMethod.amountNeeded') }}</p>\n }\n @if (feesMissing()) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-fees-unavailable\">{{ labels.t('stripeReader.fees.unavailable') }}</ui-alert>\n } @else if (quoteFailed()) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-fees-failed\">{{ labels.t('stripeReader.fees.failed') }}\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"reader-fees-retry\" (click)=\"retryQuote()\">{{ labels.t('common.tryAgain') }}</ui-button>\n </ui-alert>\n } @else if (quoting()) {\n <p class=\"srp-text\" data-testid=\"reader-fees-loading\" role=\"status\">{{ labels.t('stripeReader.fees.loading') }}</p>\n }\n @if (feeRows().length) { <ng-container [ngTemplateOutlet]=\"feeTable\" /> }\n <div class=\"srp-actions\">\n <ui-button variant=\"primary\" data-testid=\"reader-start\" [disabled]=\"!canStart()\" (click)=\"start()\">{{ startLabel() }}</ui-button>\n </div>\n }\n @if (manualAvailable()) {\n <div class=\"srp-actions\">\n <ui-button variant=\"link\" data-testid=\"reader-manual\" (click)=\"manual.emit()\">{{ labels.t('stripeReader.manualInstead') }}</ui-button>\n </div>\n }\n </section>\n }\n @default {\n <!-- Focus lands on this box when it appears; it has NO role and NO accessible name on purpose: the polite live region announces the title and the text, a labelled group would read them a second time. -->\n <section class=\"srp-wait\" data-testid=\"reader-waiting\" [attr.data-phase]=\"flow.phase()\" tabindex=\"-1\">\n <div class=\"srp-wait-head\">\n <span class=\"srp-pulse\" aria-hidden=\"true\" data-testid=\"reader-indicator\"><ui-icon name=\"card\" [size]=\"22\" [interactive]=\"false\" /></span>\n <h3 class=\"srp-title\" data-testid=\"reader-wait-title\">{{ waitTitle() }}</h3>\n </div>\n <p class=\"srp-text\" data-testid=\"reader-wait-text\">{{ waitText() }}</p>\n @if (waitAmount(); as shown) { <p class=\"srp-text\" data-testid=\"reader-wait-amount\">{{ shown }}</p> }\n @if (flow.phase() === 'recovering') { <p class=\"srp-elapsed\" data-testid=\"reader-leave-hint\">{{ labels.t('stripeReader.leaveHint') }}</p> }\n\n @if (flow.connectionLost()) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-connection-lost\">{{ labels.t('stripeReader.connectionLost') }}</ui-alert>\n }\n @if (flow.readerOffline() && !flow.connectionLost()) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-disconnected\">{{ labels.t('squareTerminal.readerDisconnected') }}</ui-alert>\n }\n @if (flow.checking() && !flow.connectionLost()) {\n <ui-alert [variant]=\"degraded()?.kind === 'transient' ? 'info' : 'warning'\" [quiet]=\"true\" data-testid=\"reader-still-checking\" [attr.data-kind]=\"degraded()?.kind ?? 'transient'\">{{ checkingText() }}</ui-alert>\n }\n @if (flow.cancelPending()) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-cancel-pending\">{{ labels.t('squareTerminal.cancelPending') }}</ui-alert>\n }\n @if (flow.cancelUnreachable()) {\n <ui-alert variant=\"danger\" [quiet]=\"true\" data-testid=\"reader-cancel-unreachable\">{{ labels.t('squareTerminal.cancelUnreachable') }}</ui-alert>\n }\n @if (flow.refusal(); as refusal) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"reader-refusal\" [attr.data-code]=\"refusal.code\">{{ refusalText() }}</ui-alert>\n }\n @if (feeRows().length) { <ng-container [ngTemplateOutlet]=\"feeTable\" /> }\n <p class=\"srp-elapsed\" data-testid=\"reader-elapsed\">{{ labels.t('stripeReader.elapsed', { time: elapsedText() }) }}</p>\n <div class=\"srp-actions\">\n @if (flow.phase() === 'recovering' && flow.recoveryExpired()) {\n <ui-button variant=\"primary\" data-testid=\"reader-recheck\" [loading]=\"flow.rechecking()\" [disabled]=\"flow.rechecking()\" (click)=\"recheck()\">{{ labels.t('stripeReader.status.recheck') }}</ui-button>\n }\n @if (flow.retryable()) {\n <ui-button variant=\"primary\" data-testid=\"reader-retry\" (click)=\"retry()\">{{ labels.t('common.tryAgain') }}</ui-button>\n }\n @if (flow.cancellable() || flow.phase() === 'cancelling') {\n <ui-button [variant]=\"flow.retryable() ? 'secondary' : 'danger'\" data-testid=\"reader-cancel\" [loading]=\"flow.phase() === 'cancelling'\" [disabled]=\"flow.phase() === 'cancelling'\" (click)=\"cancelPayment()\">{{ labels.t('squareTerminal.cancel') }}</ui-button>\n }\n @if (flow.retryable() && manualAvailable()) {\n <ui-button variant=\"ghost\" data-testid=\"reader-use-manual\" (click)=\"switchToManual()\">{{ labels.t('stripeReader.takeManual') }}</ui-button>\n }\n </div>\n </section>\n }\n }\n }\n\n <ng-template #feeTable>\n <dl class=\"srp-fees\" data-testid=\"reader-fees\" [attr.aria-label]=\"labels.t('squarePaymentMethod.paymentTotal')\">\n @for (row of feeRows(); track row.key) {\n <div class=\"srp-fee\" [attr.data-testid]=\"'reader-fee-' + row.key\"><dt>{{ row.label }}</dt><dd>{{ row.value }}</dd></div>\n }\n </dl>\n </ng-template>\n `,\n styles: [`\n ui-square-terminal-payment { display: block; min-width: 0; }\n ui-square-terminal-payment .srp-box, ui-square-terminal-payment .srp-wait { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; min-width: 0; }\n ui-square-terminal-payment .srp-wait { padding: 16px; border: 2px solid var(--ui-psp-border, #cbd5e1); border-radius: 12px; background: var(--ui-psp-sunken, #f8fafc); }\n ui-square-terminal-payment .srp-wait[data-phase='declined'], ui-square-terminal-payment .srp-wait[data-phase='stopped'] { border-color: var(--ui-psp-danger, #b91c1c); }\n ui-square-terminal-payment .srp-wait:focus { outline: none; }\n ui-square-terminal-payment .srp-wait-head { display: flex; align-items: center; gap: 12px; }\n ui-square-terminal-payment .srp-title { margin: 0; font-size: 1.0625rem; font-weight: 700; color: var(--ui-psp-text, #1e293b); }\n ui-square-terminal-payment .srp-text, ui-square-terminal-payment .srp-elapsed { margin: 0; font-size: 0.9375rem; color: var(--ui-psp-text, #1e293b); }\n ui-square-terminal-payment .srp-elapsed { font-size: 0.8125rem; color: var(--ui-psp-muted, #475569); font-variant-numeric: tabular-nums; }\n ui-square-terminal-payment .srp-actions { display: flex; flex-wrap: wrap; gap: 8px; }\n ui-square-terminal-payment .srp-focus:focus { outline: none; }\n ui-square-terminal-payment .srp-pulse { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; color: var(--ui-psp-text, #1e293b); border: 2px solid currentColor; animation: srp-pulse 1.6s ease-in-out infinite; }\n ui-square-terminal-payment .srp-fees { margin: 0; padding: 12px 14px; border: 1px solid var(--ui-psp-border, #e2e8f0); border-radius: 10px; font-size: 0.8125rem; }\n ui-square-terminal-payment .srp-fee { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; color: var(--ui-psp-muted, #475569); }\n ui-square-terminal-payment .srp-fee dt, ui-square-terminal-payment .srp-fee dd { margin: 0; }\n ui-square-terminal-payment .srp-fee:last-child { font-weight: 700; color: var(--ui-psp-text, #1e293b); }\n ui-square-terminal-payment .srp-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }\n @keyframes srp-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.55; transform: scale(0.94); } }\n @media (prefers-reduced-motion: reduce) { ui-square-terminal-payment .srp-pulse { animation: none; } }\n @media (forced-colors: active) { ui-square-terminal-payment .srp-wait, ui-square-terminal-payment .srp-fees { border-color: CanvasText; } }\n `],\n})\nexport class SquareTerminalPaymentComponent {\n protected readonly labels = inject(UiLabelsService);\n private readonly destroyRef = inject(DestroyRef);\n private readonly injector = inject(Injector);\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly storage = inject(PAYMENT_ATTEMPT_STORAGE);\n\n // ── Inputs: what is paid ─────────────────────────────────────────────────\n /** The amount the customer owes before fees, major units. `null` = nothing to take yet. */\n readonly amount = input<number | null>(null);\n readonly currency = input('USD');\n /** The payable (an invoice, a balance): the attempt marker is stored under it, so a reload or a second tab finds an open payment instead of starting another. */\n readonly payableRef = input<string | null>(null);\n /** A key the host supplies; empty = derived from the payable / generated by the attempt machine. */\n readonly attemptKey = input<string | null>(null);\n /** The payable is paid (host re-render): no payment can start. */\n readonly paid = input(false);\n /** Extra fields the host's backend wants with the start (the payment panel passes its date, note and allocation). */\n readonly startExtras = input<{ receivedDate?: string; notes?: string | null; allocation?: PaymentAllocation } | null>(null);\n\n // ── Inputs: the host's calls (see docs/card-readers.md) ─────────────────\n readonly getReadiness = input<SquareTerminalGetReadinessFn | null>(null);\n readonly startPayment = input<SquareTerminalStartFn | null>(null);\n readonly getPayment = input<SquareTerminalGetPaymentFn | null>(null);\n readonly retryPayment = input<SquareTerminalRetryFn | null>(null);\n readonly cancelPaymentFn = input<SquareTerminalCancelFn | null>(null, { alias: 'cancelPayment' });\n /** The CARD_PRESENT fee quote. REQUIRED: a reader payment always shows the card reader fee breakdown before the tap, so without it \"Send to the reader\" stays off and says the fees are not available. */\n readonly estimateFees = input<SquareTerminalFeesFn | null>(null);\n readonly receiptUrl = input<((payment: SquareTerminalPayment) => string | null | undefined) | null>(null);\n /** The id of an open reader payment THIS user owns (from the host's records): with it the \"reader busy\" banner offers \"Cancel that payment\". */\n readonly ownPaymentId = input<string | null>(null);\n\n // ── Inputs: behaviour ───────────────────────────────────────────────────\n /** `true` = the full reader screen; `false` = only the banner (the payment screen is in manual mode but still tells that a reader could be used). */\n readonly active = input(true);\n /** A manual payment path exists: \"Enter the card manually instead\" / \"Take a manual payment instead\" show and the offline text says a manual payment can still be recorded. */\n readonly manualAvailable = input(true);\n /** The buttons that start something do nothing (a read-only user). Cancel stays possible. */\n readonly disabled = input(false);\n /**\n * Library 2026-11-21 (additive; NOT set by the payment panel's Square body, so nothing in the library uses it): `true` draws NO \"checking\" placeholder while there is no usable answer (a usable answer, or a payment, is still drawn here).\n * It is for a host that shows its own checking text elsewhere. NOTE: `ui-square-terminal-banner` (the payment panel's top banner) shows NOTHING while the read is pending, failed or `checking`, so with `hideChecking` nobody speaks for that state.\n * Default `false`: the screen shows its own checking state with \"Check again\" (also inside the payment panel).\n */\n readonly hideChecking = input(false);\n /**\n * Library 2026-11-21 (additive): the payment panel's top banner (`ctx.readerBanner`) is ALWAYS on screen and shows the \"get a card reader\" message when the organization has NO usable reader. With this input this screen draws no readiness banner for\n * those states (`no_reader`, `unsupported_only`, `merchant_not_ready`, and `reader_offline` / `reader_pairing`: \"not connected\" + \"Connect Your Terminal\") so the message never shows twice, and keeps everything else: its own \"checking\", busy (with \"Cancel that payment\"), connection notices, the reader choice, fees, \"Send to the reader\" and the\n * payment boxes. A standalone host that keeps `ui-square-terminal-banner` above its tab bar passes it too. Default `false`.\n */\n readonly hideBanner = input(false);\n /** Asked right before \"Send to the reader\" starts anything; `false` = do not start (the payment panel validates its own fields here and shows their messages). */\n readonly beforeStart = input<(() => boolean) | null>(null);\n readonly readinessEveryMs = input(15_000);\n readonly readinessTimeoutMs = input(4000);\n /** How often the waiting payment's status is read (ms; default 2000). Clamped to 500..30 000 ms. */\n readonly pollMs = input(2000);\n readonly pollTimeoutMs = input(8000);\n /** After a lost start answer (or an adopted attempt) the service's \"no payment for this attempt key\" is believed only after this long, counted from the moment recovery starts. Default 6 minutes: the service's 5-minute create window plus a minute (ms). */\n readonly lostAnswerGraceMs = input(SQUARE_TERMINAL_LOST_ANSWER_GRACE_MS);\n /** A start / retry / cancel call slower than this is unreachable (ms): a start is looked up by its attempt key, a retry / cancel leaves the payment as it was. */\n readonly requestTimeoutMs = input(SQUARE_TERMINAL_REQUEST_TIMEOUT_MS);\n /** A quote slower than this: \"Try again\" is offered and Send stays off (ms). */\n readonly feeTimeoutMs = input(10_000);\n /** Managed environments where `navigator.onLine === false` is a false negative: the browser's offline flag does not block (default false). */\n readonly offlineOverride = input(false);\n\n // ── Outputs ─────────────────────────────────────────────────────────────\n /** The user wants to enter the card manually (the host switches its method). Emitted only when nothing is waiting on the reader. */\n readonly manual = output<void>();\n /** \"Connect Your Terminal\": the host opens its pairing panel. */\n readonly connectReader = output<void>();\n /** \"Get a card reader\": the host opens its order flow. */\n readonly getReader = output<void>();\n /** \"Set up payments\": the host opens payment setup. */\n readonly openSetup = output<void>();\n /** The payment succeeded. */\n readonly succeeded = output<SquareTerminalSucceededEvent>();\n /** Everything else that happened, for the host to word. */\n readonly outcome = output<SquareTerminalOutcome>();\n /** A readiness read finished: its state (`null` = no answer / the read failed). The payment panel's FIRST answer decides whether the reader is the default. */\n readonly readinessChange = output<SquareTerminalReadinessState | null>();\n /** A payment is open on the reader (starting, waiting, declined, cancelling...): the host locks everything else. */\n readonly busyChange = output<boolean>();\n\n // ── State ───────────────────────────────────────────────────────────────\n readonly readiness = signal<SquareTerminalReadiness | null>(null);\n protected readonly readinessLoading = signal(false);\n readonly selectedReaderId = signal('');\n /** `quote_changed`: the total shown is not the total any more; Send stays off until the payer confirms the new one. */\n protected readonly quoteChanged = signal<{ total: number | null } | null>(null);\n readonly closeBlocked = signal(false);\n protected readonly cancellingBusy = signal(false);\n /** The \"Cancel that payment\" call did not answer in time: the payment may still be open (a notice with \"Check again\" shows instead of the banner). */\n protected readonly cancelTimedOut = signal(false);\n protected readonly quote = signal<SquareFees | null>(null);\n /** The amount the quote was asked for (a quote is shown only while it matches the amount on screen). */\n private readonly quotedFor = signal<number | null>(null);\n protected readonly quoting = signal(false);\n protected readonly quoteFailed = signal(false);\n private readonly quoteTick = signal(0);\n private quoteRun = 0;\n /** What the held quote was asked for: a phase change alone (a refusal, a canceled payment) keeps a held quote of the same amount; the service still checks the total (`quote_changed`). */\n private heldEstimate: unknown = null;\n private heldAmount: number | null | undefined = undefined;\n private heldTick = -1;\n private readonly builtIns = signal<string[]>([]);\n\n readonly attempt = new PaymentAttempt({\n destroyRef: this.destroyRef,\n payableRef: () => this.payableRef(),\n amount: () => this.amount(),\n method: () => 'CARD_PRESENT',\n attemptKey: () => this.attemptKey(),\n checkStatus: () => null,\n paid: () => this.paid(),\n offlineMidFlight: false,\n offlineOverride: () => this.offlineOverride(),\n storage: this.storage,\n });\n\n readonly flow = new SquareTerminalFlow({\n attempt: this.attempt,\n start: () => this.startPayment(),\n getPayment: () => this.getPayment(),\n retry: () => this.retryPayment(),\n cancel: () => this.cancelPaymentFn(),\n pollMs: () => clampReaderPollMs(this.pollMs()),\n pollTimeoutMs: () => this.pollTimeoutMs(),\n lostAnswerGraceMs: () => this.lostAnswerGraceMs(),\n requestTimeoutMs: () => this.requestTimeoutMs(),\n onEvent: event => this.onFlowEvent(event),\n });\n\n /** The user pressed a button that changes the screen: when the phase changes, focus moves to the new box (the pressed button is gone). */\n private acted = false;\n private lastPhase = this.flow.phase();\n private destroyed = false;\n private readRun = 0;\n private readTimer: ReturnType<typeof setTimeout> | null = null;\n\n protected readonly ready = computed(() => this.readiness()?.state === 'reader_ready');\n protected readonly freeReaders = computed(() => (this.readiness()?.readers ?? []).filter(isReaderFree));\n protected readonly readerId = computed(() => {\n const free = this.freeReaders();\n const chosen = this.selectedReaderId();\n if (chosen && free.some(r => r.id === chosen)) return chosen;\n const def = this.readiness()?.defaultReaderId;\n if (def && free.some(r => r.id === def)) return def;\n return free[0]?.id ?? '';\n });\n protected readonly readerOptions = computed(() => this.freeReaders().map(r => ({ value: r.id, label: r.model && r.label ? `${readerDisplayName(r)} (${r.model})` : readerDisplayName(r) })));\n /** The name of the reader the payment is (or would be) on. */\n protected readonly readerName = computed(() => {\n const id = this.flow.terminal()?.readerId ?? this.readerId();\n const readers = this.readiness()?.readers ?? [];\n return readerDisplayName(readers.find(r => r.id === id) ?? null) || this.labels.t('squareTerminal.theReader');\n });\n /** Why a reader payment cannot be started before it starts: offline, a slow connection, a browser that cannot pay safely. Empty = none. */\n protected readonly blockReason = computed((): '' | 'offline' | 'slow_connection' | 'unsupported_browser' => {\n if (this.attempt.blockedOffline()) return 'offline';\n const reasons = this.builtIns();\n if (reasons.includes('slow_connection')) return 'slow_connection';\n if (reasons.includes('unsupported_browser')) return 'unsupported_browser';\n return '';\n });\n protected readonly blockText = computed(() => {\n switch (this.blockReason()) {\n case 'offline': return this.labels.t(this.manualAvailable() ? 'stripeReader.offline.withManual' : 'stripeReader.offline.noManual');\n case 'slow_connection': return this.labels.t('paymentReadiness.slow_connection');\n case 'unsupported_browser': return this.labels.t('paymentReadiness.unsupported_browser');\n default: return '';\n }\n });\n /** No fee quote call: a reader payment must always show the CARD_PRESENT breakdown before the tap, so nothing can be sent. */\n protected readonly feesMissing = computed(() => !this.estimateFees());\n /**\n * The ONE message block of the idle screen, by precedence: already paid > an earlier payment still being confirmed > a cancel that timed out > the total changed > a refusal of the last start. The readiness banner and\n * the \"blocked\" notice show only when none of these does (and never in the canceled / failed boxes).\n */\n protected readonly idleNotice = computed((): 'paid' | 'pending-other' | 'cancel-timeout' | 'quote-changed' | 'refusal' | null => {\n if (!this.active() || this.flow.phase() !== 'idle') return null;\n if (this.attempt.paidLocked()) return 'paid';\n if (this.foreignPending()) return 'pending-other';\n if (this.cancelTimedOut()) return 'cancel-timeout';\n if (this.quoteChanged()) return 'quote-changed';\n if (this.flow.refusal()) return 'refusal';\n return null;\n });\n protected readonly showBlocked = computed(() => this.active() && this.flow.phase() === 'idle' && !this.idleNotice());\n /**\n * Library source 2026-11-21: this screen is showing a card reader message of its own right now (the readiness banner, a connection notice, one of the idle notices, or a payment box), so a second reader banner elsewhere\n * on the page must step aside. `false` when it shows nothing about the reader (a ready reader and an idle screen). Mirrors the template exactly (with `hideBanner` the no-reader states are not drawn here, so they do not count).\n */\n readonly ownsReaderMessage = computed(() => {\n if (this.flow.phase() !== 'idle' || this.flow.locked()) return true;\n if (this.idleNotice()) return true;\n if (this.blockReason()) return this.showBlocked();\n return this.showReadiness() && this.shownReadiness()?.state !== 'reader_ready';\n });\n /**\n * The readiness the banner is drawn from: a usable answer only. No answer (loading, failed, slow) and a service `checking` (old name `unknown`) that does not need the account's attention are NOT shown as a state of their own (there is no \"unknown\" banner): `null`, and the status component's \"Checking the card reader\" placeholder speaks (unless the host set `hideChecking`; the top banner never speaks for that state).\n */\n protected readonly shownReadiness = computed((): SquareTerminalReadiness | null => {\n const r = this.readiness();\n if (!r) return null;\n if ((r.state === 'checking' || r.state === 'unknown') && readerDegraded({ state: 'checking', stale: true, degradedReason: r.degradedReason })?.kind !== 'attention') return null;\n return r;\n });\n protected readonly showReadiness = computed(() => {\n if (this.flow.locked() || this.flow.phase() === 'succeeded') return false;\n if (!this.shownReadiness() && this.hideChecking()) return false; // no usable answer: the panel's top banner speaks, nothing of our own\n if (this.hideBanner() && SQUARE_TERMINAL_NO_READER_STATES.includes(this.shownReadiness()?.state as SquareTerminalReadinessState)) return false; // the top banner speaks for these states (get a Terminal / connect your Terminal)\n return this.active() ? this.flow.phase() === 'idle' && !this.idleNotice() : true;\n });\n /** The own payment that holds a reader, when the host knows it. */\n protected readonly busyOwnPaymentId = computed(() => {\n const id = this.ownPaymentId();\n return id && (this.readiness()?.readers ?? []).some(r => r.busyPaymentId === id) ? id : null;\n });\n private readonly amountValid = computed(() => { const a = this.amount(); return a != null && Number.isFinite(a) && a > 0; });\n /** The quote of the amount on screen (a quote for another amount is never shown). */\n protected readonly currentQuote = computed(() => (this.quotedFor() === this.amount() ? this.quote() : null));\n protected readonly feeRows = computed(() => {\n const fees = this.currentQuote();\n const amount = this.flow.locked() || this.flow.phase() === 'succeeded' ? (this.flow.baseAmount() ?? this.amount()) : this.amount();\n if (!fees || amount == null || (fees.processingFee === undefined && fees.platformFee === undefined && fees.totalAmount === undefined)) return [];\n const money = (n: number) => formatCurrency(n, { currency: this.currency() });\n const rows: { key: string; label: string; value: string }[] = [{ key: 'amount', label: this.labels.t('squarePaymentMethod.paymentAmount'), value: money(amount) }];\n if (fees.processingFee !== undefined) rows.push({ key: 'processing', label: `${this.labels.t('squarePaymentMethod.processingFee')}${fees.processingFeeLabel ? ` (${fees.processingFeeLabel})` : ''}`, value: money(fees.processingFee) });\n if (fees.platformFee !== undefined) rows.push({ key: 'platform', label: `${this.labels.t('squarePaymentMethod.platformFee')}${fees.platformFeeLabel ? ` (${fees.platformFeeLabel})` : ''}`, value: money(fees.platformFee) });\n if (fees.totalAmount !== undefined) rows.push({ key: 'total', label: this.labels.t('squarePaymentMethod.totalCharged'), value: money(fees.totalAmount) });\n return rows;\n });\n /** Everything that must be true before \"Send to the reader\" works. */\n readonly canStart = computed(() =>\n this.active() && this.ready() && !this.blockReason() && !!this.readerId() && this.amountValid() && !this.disabled() && !this.paid() && !this.flow.locked()\n && this.flow.phase() !== 'succeeded' && !this.attempt.locked() && !this.quoting() && !this.quoteFailed() && !this.feesMissing() && !!this.currentQuote() && !this.quoteChanged());\n protected readonly startLabel = computed(() => (this.amount() != null && this.amountValid()\n ? this.labels.t('squareTerminal.start', { amount: formatCurrency(this.currentQuote()?.totalAmount ?? this.amount(), { currency: this.currency() }) })\n : this.labels.t('squareTerminal.startNoAmount')));\n /** A reload / second tab found an undecided attempt of ANOTHER method (a manual card): it is never followed as a reader payment, only worded. */\n protected readonly foreignPending = computed(() => this.attempt.unknown() && !this.flow.locked() && this.flow.phase() === 'idle' && this.attempt.pinnedMethod() !== 'CARD_PRESENT');\n protected readonly degraded = computed(() => readerDegraded(this.flow.terminal()));\n protected readonly checkingText = computed(() => {\n const d = this.degraded();\n if (d?.kind === 'attention') return this.labels.t('stripeReader.degraded.attention');\n if (d?.kind === 'since') return this.labels.t('stripeReader.degraded.since', { time: d.since });\n return this.labels.t('stripeReader.stillChecking');\n });\n /** What was actually charged (the service's `amountCents`), else the quote total of the open payment; `null` when neither is known. */\n private readonly chargedTotal = computed((): number | null => paymentChargedAmount(this.flow.payment()) ?? (this.flow.locked() || this.flow.phase() === 'succeeded' ? this.currentQuote()?.totalAmount ?? null : null));\n /** The amount line of the waiting screen: the total when known, else the base amount (fees may be added). Always present once an amount is known, quote or not (also after a reload that adopted the payment). */\n protected readonly waitAmount = computed(() => {\n const money = (n: number) => formatCurrency(n, { currency: this.currency() });\n const total = this.chargedTotal();\n if (total != null) return this.labels.t('stripeReader.wait.amount', { amount: money(total) });\n const base = this.flow.baseAmount();\n return base != null ? this.labels.t('stripeReader.wait.amountBase', { amount: money(base) }) : '';\n });\n protected readonly confirmTotalText = computed(() => { const total = this.currentQuote()?.totalAmount ?? this.quoteChanged()?.total ?? null; return total == null ? '' : formatCurrency(total, { currency: this.currency() }); });\n protected readonly existingPaymentHref = computed(() => {\n const refusal = this.flow.refusal();\n if (refusal?.code !== 'duplicate_suspected' || !refusal.paymentId) return null;\n const url = this.receiptUrl()?.({ id: refusal.paymentId });\n return isSafeReceiptUrl(url) ? url : null;\n });\n protected readonly elapsedText = computed(() => formatElapsed(this.flow.elapsedMs()));\n protected readonly waitTitle = computed(() => this.labels.t(`stripeReader.wait.${this.waitKey()}.title` as UiLabelKey));\n protected readonly waitText = computed(() => {\n const t = this.flow.terminal();\n if (this.waitKey() === 'declined' && t?.message) return t.message;\n return this.labels.t(terminalLabelKey(`stripeReader.wait.${this.waitKey()}.text` as UiLabelKey), { reader: this.readerName() });\n });\n private readonly waitKey = computed((): 'waiting' | 'declined' | 'stopped' | 'retrying' | 'cancelling' | 'recovering' | 'unconfirmed' => {\n const p = this.flow.phase();\n if (p === 'recovering' && this.flow.recoveryExpired()) return 'unconfirmed';\n return p === 'declined' || p === 'stopped' || p === 'retrying' || p === 'cancelling' || p === 'recovering' ? p : 'waiting';\n });\n protected readonly refusalText = computed(() => {\n const refusal = this.flow.refusal();\n if (!refusal) return '';\n if (refusal.code === 'quote_changed') {\n return typeof refusal.amountCents === 'number'\n ? this.labels.t('stripeReader.refusal.quote_changed', { amount: formatCurrency(refusal.amountCents / 100, { currency: this.currency() }) })\n : this.labels.t('stripeReader.refusal.quote_changedNoAmount');\n }\n if (refusal.code === 'reader_not_paired') return refusal.pairingCode ? this.labels.t('squareTerminal.refusal.reader_not_paired', { code: refusal.pairingCode }) : this.labels.t('squareTerminal.refusal.reader_not_paired_nocode');\n const key = readerRefusalLabelKey(refusal.code);\n return key ? this.labels.t(key) : refusal.message || this.labels.t('stripeReader.refusal.generic');\n });\n protected readonly succeededText = computed(() => {\n // What was actually charged (the service's own total), else the quote the payer saw, else the base amount; never a made-up 0.\n const amount = this.chargedTotal() ?? this.flow.baseAmount() ?? this.amount();\n return amount == null\n ? this.labels.t('stripeReader.done.textNoAmount', { reader: this.readerName() })\n : this.labels.t('stripeReader.done.text', { amount: formatCurrency(amount, { currency: this.currency() }), reader: this.readerName() });\n });\n protected readonly cardLine = computed(() => {\n const p = this.flow.payment();\n return p?.last4 ? this.labels.t('stripeReader.done.card', { brand: p.brand ? String(p.brand).replace(/^./, c => c.toUpperCase()) : this.labels.t('stripeReader.done.cardWord'), last4: p.last4 }) : '';\n });\n protected readonly receiptHref = computed(() => {\n const payment = this.flow.payment();\n const url = payment ? this.receiptUrl()?.(payment) : null;\n return isSafeReceiptUrl(url) ? url : null;\n });\n /** What the polite region says: one text, the most important thing first, changing with every state. */\n protected readonly announcement = computed(() => {\n const phase = this.flow.phase();\n if (!this.active()) return ''; // manual mode: the reader is only a banner, the manual form speaks for the page\n if (this.blockReason() && !this.flow.locked() && phase !== 'succeeded') return this.blockText();\n if (this.closeBlocked() && this.flow.locked()) return this.labels.t('stripeReader.closeBlocked');\n if (phase === 'idle') return this.foreignPending() ? this.labels.t('stripeReader.refusal.outcome_checking') : '';\n if (phase === 'starting') return this.labels.t('squareTerminal.startingText');\n if (phase === 'succeeded') return ''; // the success alert is the announcement (a second one here would say it twice, and with another amount)\n if (phase === 'canceled') return `${this.labels.t('stripeReader.canceled.title')}. ${this.labels.t('squareTerminal.canceled.text')}`;\n if (phase === 'failed') return `${this.labels.t('stripeReader.failed.title')}. ${this.labels.t('stripeReader.failed.text')}`;\n if (this.flow.cancelPending()) return this.labels.t('squareTerminal.cancelPending');\n if (this.flow.cancelUnreachable()) return this.labels.t('squareTerminal.cancelUnreachable');\n if (this.flow.connectionLost()) return this.labels.t('stripeReader.connectionLost');\n if (this.flow.readerOffline()) return this.labels.t('squareTerminal.readerDisconnected');\n if (this.flow.checking()) return this.checkingText();\n return `${this.waitTitle()}. ${this.waitText()}`;\n });\n\n constructor() {\n this.refreshBuiltIns();\n if (typeof window !== 'undefined') {\n const refresh = (): void => this.refreshBuiltIns();\n window.addEventListener('online', refresh);\n window.addEventListener('offline', refresh);\n this.destroyRef.onDestroy(() => { window.removeEventListener('online', refresh); window.removeEventListener('offline', refresh); });\n }\n this.destroyRef.onDestroy(() => { this.destroyed = true; this.flow.dispose(); if (this.readTimer) clearTimeout(this.readTimer); this.quoteRun++; });\n // The readiness is read as soon as the host gave the call, then every `readinessEveryMs` (and again after a payment ends).\n effect(() => { const read = this.getReadiness(); untracked(() => { if (read) void this.loadReadiness(); }); });\n effect(() => { const locked = this.flow.locked(); untracked(() => { this.busyChange.emit(locked); if (!locked) this.closeBlocked.set(false); }); });\n effect(() => {\n const phase = this.flow.phase();\n untracked(() => {\n const changed = phase !== this.lastPhase;\n this.lastPhase = phase;\n if (changed && this.acted && phase !== 'idle') { this.acted = false; afterNextRender(() => this.host.nativeElement.querySelector<HTMLElement>('[data-testid=\"reader-starting\"], [data-testid=\"reader-waiting\"], [data-testid=\"reader-succeeded\"], [data-testid=\"reader-canceled\"], [data-testid=\"reader-failed\"]')?.focus(), { injector: this.injector }); }\n });\n });\n effect(() => { const phase = this.flow.phase(); untracked(() => { if (phase === 'canceled' || phase === 'failed' || phase === 'succeeded') void this.loadReadiness(); }); });\n // A reload / a second tab found an open attempt of this payable: look its payment up (never start another). The marker is per PAYABLE, not per method: only a card READER attempt is followed on the terminal\n // channel; a manual card attempt is worded (\"still confirming an earlier payment\") and keeps Send off, but is never polled as a reader payment.\n effect(() => {\n const unknown = this.attempt.unknown();\n const method = this.attempt.pinnedMethod();\n untracked(() => { if (unknown && method === 'CARD_PRESENT' && !this.flow.locked() && this.flow.phase() === 'idle') this.flow.adopt(); });\n });\n // `quote_changed`: the total shown is stale. The quote is asked again at once and Send stays off until the payer confirms the new total. `reader_not_paired`: the device is not a Terminal yet, so the readiness is read again (it then says `reader_pairing`).\n effect(() => {\n const refusal = this.flow.refusal();\n untracked(() => {\n if (refusal?.code === 'quote_changed') { this.quoteChanged.set({ total: typeof refusal.amountCents === 'number' ? refusal.amountCents / 100 : null }); this.quoteTick.update(n => n + 1); }\n if (refusal?.code === 'reader_not_paired') void this.loadReadiness();\n });\n });\n // Another amount is another quote: the \"confirm the new total\" step is over.\n effect(() => { this.amount(); untracked(() => this.quoteChanged.set(null)); });\n // Without a payable reference the reload / second-tab protection cannot work (the marker is stored under it).\n effect(() => { const ref = this.payableRef(); untracked(() => { if (isDevMode() && ref == null) console.warn('[ui-square-terminal-payment] payableRef is not set: a reload or a second tab cannot find an open reader payment, so the duplicate protection only covers this page instance.'); }); });\n effect(() => { const estimate = this.estimateFees(); untracked(() => { if (isDevMode() && !estimate) console.warn('[ui-square-terminal-payment] estimateFees is not set: a reader payment must show the card reader fee breakdown before the tap.'); }); });\n // The browser's own offline / online events while a payment is open.\n effect(() => { const offline = this.attempt.offline(); untracked(() => { if (this.flow.locked()) this.flow.markConnection(!offline); }); });\n // The fee quote: cleared AT ONCE when the amount changes (a quote for another amount is never shown), asked again after a short pause, and Send stays off until the quote of the current amount arrives.\n effect(onCleanup => {\n const estimate = this.estimateFees();\n const amount = this.amount();\n const tick = this.quoteTick();\n const phase = this.flow.phase();\n const active = this.active();\n if (phase !== 'idle' && phase !== 'canceled' && phase !== 'failed') return; // while a payment is open (or done) the quote on screen belongs to it\n if (!active) { this.heldTick = -1; untracked(() => { this.quote.set(null); this.quotedFor.set(null); this.quoteFailed.set(false); this.quoting.set(false); }); return; } // the reader is only a banner (manual mode): no card-present quote is asked\n // Only the phase moved (a refusal or a canceled payment brought the screen back): the quote held for this very amount is still the one to show. Anything else (another amount, another call, \"Try again\", a changed total) asks again.\n const unchanged = estimate === this.heldEstimate && amount === this.heldAmount && tick === this.heldTick;\n if (unchanged && untracked(() => !!this.quote() && this.quotedFor() === amount)) return;\n this.heldEstimate = estimate; this.heldAmount = amount; this.heldTick = tick;\n const run = ++this.quoteRun;\n untracked(() => { this.quote.set(null); this.quotedFor.set(null); this.quoteFailed.set(false); this.quoting.set(false); });\n if (!estimate || amount == null || !Number.isFinite(amount) || amount <= 0) return;\n untracked(() => this.quoting.set(true));\n let hung: ReturnType<typeof setTimeout> | null = null;\n const timer = setTimeout(async () => {\n hung = setTimeout(() => { if (run === this.quoteRun) { this.quoting.set(false); this.quoteFailed.set(true); } }, Math.max(1, this.feeTimeoutMs()));\n let fees: SquareFees | null = null;\n try { fees = (await callHost(() => estimate({ amount, paymentMethod: 'CARD_PRESENT', paymentMethodType: 'card_present' }))) ?? null; } catch { fees = null; }\n if (hung) { clearTimeout(hung); hung = null; }\n if (this.destroyed || run !== this.quoteRun) return;\n this.quoting.set(false);\n if (fees) { this.quote.set(fees); this.quotedFor.set(amount); this.quoteFailed.set(false); } else { this.quote.set(null); this.quotedFor.set(null); this.quoteFailed.set(true); }\n }, 300);\n onCleanup(() => { clearTimeout(timer); if (hung) clearTimeout(hung); });\n });\n }\n\n private refreshBuiltIns(): void { this.builtIns.set(builtInReadinessReasons(this.offlineOverride())); }\n\n // ── Readiness ───────────────────────────────────────────────────────────\n\n /** Reads the readiness now (\"Check again\"). A slow (over `readinessTimeoutMs`) or failed read leaves NO answer: the banner says it could not be checked and nothing is started. */\n async loadReadiness(): Promise<void> {\n const read = this.getReadiness();\n if (!read || this.destroyed) return;\n if (this.readTimer) { clearTimeout(this.readTimer); this.readTimer = null; }\n const run = ++this.readRun;\n this.readinessLoading.set(true);\n let result: SquareTerminalReadiness | null = null;\n let timer: ReturnType<typeof setTimeout> | null = null;\n try {\n const timeout = new Promise<'timeout'>(resolve => { timer = setTimeout(() => resolve('timeout'), this.readinessTimeoutMs()); });\n const raw = await Promise.race([callHost(() => read()), timeout]);\n result = raw === 'timeout' ? null : normalizeReadiness(raw);\n } catch { result = null; } finally { if (timer) clearTimeout(timer); }\n if (this.destroyed || run !== this.readRun) return;\n this.readinessLoading.set(false);\n this.readiness.set(result);\n // \"Not paired yet\" is over once the readiness says a Terminal is ready: the old refusal must not stay above \"Send\".\n if (result?.state === 'reader_ready' && this.flow.refusal()?.code === 'reader_not_paired' && !this.flow.locked()) this.flow.refusal.set(null);\n this.readinessChange.emit(result?.state ?? null);\n this.scheduleReadiness();\n }\n\n private scheduleReadiness(): void {\n if (this.destroyed) return;\n if (this.readTimer) clearTimeout(this.readTimer);\n this.readTimer = setTimeout(() => { this.readTimer = null; if (this.flow.locked()) this.scheduleReadiness(); else void this.loadReadiness(); }, Math.max(1, this.readinessEveryMs()));\n }\n\n // ── Actions ─────────────────────────────────────────────────────────────\n\n /** \"Send to the reader\". Synchronous up to the attempt lock: a double click sends ONE payment. */\n start(): void {\n this.refreshBuiltIns();\n if (!this.canStart()) return;\n const before = this.beforeStart();\n if (before && !before()) return;\n const amount = this.amount() as number;\n const total = this.currentQuote()?.totalAmount;\n this.closeBlocked.set(false);\n void this.flow.start({\n readerId: this.readerId(), amount, payableRef: this.payableRef(), extras: this.startExtras() ?? undefined,\n ...(total !== undefined && Number.isFinite(total) ? { expectedAmountCents: Math.round(total * 100) } : {}),\n });\n this.acted = true;\n }\n\n /** \"Confirm the new total\": the payer saw the new total, Send is available again. */\n protected confirmNewTotal(): void { this.quoteChanged.set(null); }\n\n protected retry(): void { this.acted = true; void this.flow.retry(); }\n\n /** \"Check again\" of an unconfirmed payment: reads the attempt key once more (found: followed; still none after the grace: released, \"Start again\"). */\n protected recheck(): void { void this.flow.recheck(); }\n\n protected dismissCancelTimeout(): void { this.cancelTimedOut.set(false); void this.loadReadiness(); }\n\n protected cancelPayment(): void { this.acted = true; void this.flow.cancel(); }\n\n protected startAgain(): void { this.flow.reset(); }\n\n protected retryQuote(): void { this.quoteTick.update(n => n + 1); }\n\n /** \"Take a manual payment instead\" while a payment is open: the payment is canceled FIRST; the host is told only when the service confirmed it. */\n protected async switchToManual(): Promise<void> {\n if (await this.cancelAndWait()) this.manual.emit();\n }\n\n /** Cancels an open reader payment and resolves true when nothing is open any more (nothing was waiting, or the service confirmed the cancel). False = the payment is STILL open. */\n async cancelAndWait(): Promise<boolean> {\n if (!this.flow.locked()) return true;\n if (this.flow.phase() === 'starting' || this.flow.phase() === 'recovering' || this.flow.phase() === 'retrying') return false;\n return this.flow.cancel();\n }\n\n /** Is a reader payment open (starting, waiting, declined, cancelling...)? */\n isLocked(): boolean { return this.flow.locked(); }\n\n /** The panel wants to close: allowed (true) only when nothing is open. Otherwise the warning shows and focus goes to \"Cancel payment\". */\n requestClose(): boolean {\n if (!this.flow.locked()) return true;\n // Nothing is waiting on the reader yet (the answer of the start is on its way or lost): there is nothing to cancel. The panel may close; the attempt marker is kept, so reopening it\n // finds the payment by its attempt key (\"Checking the payment\" with the same hint) and NEVER starts another.\n const phase = this.flow.phase();\n if (phase === 'starting' || phase === 'recovering') { this.outcome.emit({ kind: 'left-pending' }); return true; }\n this.closeBlocked.set(true);\n afterNextRender(() => this.host.nativeElement.querySelector<HTMLElement>('[data-testid=\"reader-cancel\"] button, [data-testid=\"reader-waiting\"]')?.focus(), { injector: this.injector });\n return false;\n }\n\n /** Fire-and-forget cancel of an open payment (the host closed the panel anyway). Never claims the payment is canceled. */\n cancelBestEffort(): void {\n const cancel = this.cancelPaymentFn();\n const id = this.flow.payment()?.id;\n if (!cancel || !id || !this.flow.cancellable()) return;\n callHost(() => cancel(id)).catch(() => { /* the service keeps the payment open and the reconciler settles it */ });\n }\n\n /** \"Cancel that payment\" of the busy banner: cancels the user's own payment that holds the reader, then reads the readiness again. */\n protected async cancelBusy(id: string): Promise<void> {\n const cancel = this.cancelPaymentFn();\n if (!cancel || this.cancellingBusy()) return;\n this.cancellingBusy.set(true);\n this.cancelTimedOut.set(false);\n let timer: ReturnType<typeof setTimeout> | null = null;\n try {\n // Raced against the request timeout: a call that never answers cannot leave \"Cancel that payment\" busy forever. A timed-out cancel may have gone through: the readiness is read again at once.\n const timeout = new Promise<never>((_, reject) => { timer = setTimeout(() => reject(Object.assign(new Error('request timeout'), { status: null, code: 'request_timeout' })), Math.max(1, this.requestTimeoutMs())); });\n await Promise.race([callHost(() => cancel(id)), timeout]);\n } catch (error) {\n const code = readerErrorInfo(error).code;\n if (code === 'request_timeout') this.cancelTimedOut.set(!this.destroyed);\n this.outcome.emit({ kind: 'refused', code: code || 'reader_unreachable' });\n } finally { if (timer) clearTimeout(timer); }\n if (this.destroyed) return;\n this.cancellingBusy.set(false);\n void this.loadReadiness();\n }\n\n private onFlowEvent(event: SquareTerminalFlowEvent): void {\n switch (event.kind) {\n case 'started': this.outcome.emit({ kind: 'started', payment: event.payment }); break;\n case 'declined': this.outcome.emit({ kind: 'declined', payment: event.payment }); break;\n case 'succeeded':\n // The amount of THIS payment: the service's base amount (also after a reload that adopted it), else what this screen started with; never a made-up 0.\n this.succeeded.emit({ payment: event.payment, attemptKey: event.attemptKey, amount: this.flow.baseAmount() ?? this.amount() ?? paymentChargedAmount(event.payment) ?? 0, readerId: event.payment.terminal?.readerId ?? this.flow.lastStartInput()?.readerId ?? '' });\n break;\n case 'canceled': this.outcome.emit({ kind: 'canceled' }); break;\n case 'failed': this.outcome.emit({ kind: 'failed' }); break;\n case 'refused': this.outcome.emit({ kind: 'refused', code: event.refusal.code }); break;\n case 'connection-lost': this.outcome.emit({ kind: 'connection-lost' }); break;\n case 'connection-restored': this.outcome.emit({ kind: 'connection-restored' }); break;\n }\n }\n}\n","import type { PaymentAllocation } from '@forgeroute/ui/payments';\nimport { uiText } from '@forgeroute/ui/core';\nimport type { SquareCardType, SquareMethod, SquareTokenDetails } from '../square-payment/square-outcomes';\n\n/** What the host's `createPayment` receives: the entered payment, how it is applied to charges, and the single-use token Square gave for the customer's card / bank account. */\nexport interface SquarePaymentContext extends PaymentAllocation {\n /** The amount the payer owes (before processing fees), in major units (12.5 = $12.50). */\n amount: number;\n /** The method value that was selected (`'CARD'` / `'ACH'`). */\n paymentMethod: string;\n /** Square's side of it: `'card'` or `'ach'`. */\n method: SquareMethod;\n receivedDate: string;\n notes: string | null;\n /** The single-use source id: send it to your backend (which sends it to the payments service). */\n token: string;\n /** Brand, last four, bank name ... as far as the SDK sent them. */\n details: SquareTokenDetails;\n /** The card funding when the SDK already told it at tokenization (`null` otherwise: a backend that needs it reads `card_type` from Square once the card exists). */\n funding: SquareCardType | null;\n /** The buyer-verification (SCA) token, when the form ran `verifyBuyer`. */\n verificationToken: string | null;\n /**\n * @deprecated A new id per tokenization: do NOT use it as the Square `idempotency_key` (a retry with a new token would then be a second payment). Send `token` and `attemptKey` instead, and derive\n * the idempotency key from `attemptKey`.\n */\n idempotencyKey: string;\n /**\n * The key of this PAYMENT ATTEMPT: stable across retries after a timeout / offline loss, a reload and a second tab (with a `payableRef` it is derived from payable, amount and method, so every tab holds\n * the SAME key); renewed only after a definitive failure or success. Send it to your backend with the charge (it looks the attempt up by it FIRST and derives the processor's idempotency key from it) and\n * answer `checkStatus(attemptKey)` with it.\n */\n attemptKey: string;\n /** The payable of this attempt (the plugin's `payableRef` at the click): the backend allows ONE open or succeeded attempt per payable and answers 409 `payment_in_flight` to a second key. */\n payableRef: string | null;\n}\n\n/**\n * What the host's `createPayment` answers. `status` is Square's payment status: `COMPLETED` = paid (a payment the host created with autocomplete answers `COMPLETED`), `APPROVED` (authorized, NOT captured yet)\n * and `PENDING` (and any other non-final value) = submitted and settling (a bank debit takes days), `FAILED` / `CANCELED` = not paid (the panel shows `failureMessage` / a default text and the payer can try again). Fees are optional;\n * when given they are shown as rows under the form.\n */\nexport interface SquarePaymentResult {\n paymentId?: string | null;\n status?: string;\n failureMessage?: string;\n processingFee?: number;\n platformFee?: number;\n totalAmount?: number;\n processingFeeLabel?: string;\n platformFeeLabel?: string;\n}\n\n/** The fees of a payment, shown before the payer pays (the host's `estimateFees`) or after the payment exists. */\nexport interface SquareFees {\n processingFee?: number;\n platformFee?: number;\n /** What the payer is charged (amount + fees), shown as \"Total charged\". Display only: Square's form is not created for an amount. */\n totalAmount?: number;\n processingFeeLabel?: string;\n platformFeeLabel?: string;\n}\n\nexport interface SquareFeeContext {\n amount: number;\n paymentMethod: string;\n method: SquareMethod;\n /**\n * The card funding. Square's SDK does not know it before the customer pays, so this is `null` in the estimate; a credit-only fee schedule shows the credit fee\n * (or the highest) here and corrects the rows from the `createPayment` answer.\n */\n funding: SquareCardType | null;\n}\n\nexport type SquareOutcomeKind = 'paid' | 'processing' | 'failed';\n\n// `APPROVED` is an authorization that is not captured yet: the money has not moved, so it is NOT paid (it is `processing`, like any other non-final status).\nconst PAID = new Set(['COMPLETED', 'PAID']);\nconst FAILED = new Set(['FAILED', 'CANCELED', 'CANCELLED']);\n\n/**\n * Square's payment `status` as one outcome. A non-final status (`PENDING`, `APPROVED` = authorized but not captured, anything unknown) counts as `'processing'`: the payment exists, so the payer is told it was submitted,\n * never \"failed\". No status at all (a host that answers nothing after it created the payment) is `'paid'` for a card and `'processing'` for a bank account, which never settles at once.\n */\nexport function squareOutcomeOf(status: string | null | undefined, method: SquareMethod = 'card'): SquareOutcomeKind {\n const value = (status ?? '').trim().toUpperCase();\n if (!value) return method === 'ach' ? 'processing' : 'paid';\n if (PAID.has(value)) return 'paid';\n if (FAILED.has(value)) return 'failed';\n return 'processing';\n}\n\n/** The method values the plugin takes over by default. */\nexport const SQUARE_PAYMENT_METHOD_VALUES = ['CARD', 'ACH'] as const;\n\n/** The name of a method in the app's active language (an unknown value is shown as it is). */\nexport const squareMethodLabel = (value: string): string =>\n value === 'CARD' ? uiText('squarePaymentMethod.methodCard') : value === 'ACH' ? uiText('squarePaymentMethod.methodAch') : value;\n\nexport const squareMethodOf = (method: string): SquareMethod => (method === 'ACH' ? 'ach' : 'card');\n\n/** The texts of the Square payment method; read on every access, so they follow the app's active language. */\nexport const SQUARE_METHOD_TEXTS = {\n get amountNeeded() { return uiText('squarePaymentMethod.amountNeeded'); },\n get notCompleted() { return uiText('squarePaymentMethod.notCompleted'); },\n get achTitle() { return uiText('squarePaymentMethod.achTitle'); },\n achMessage: (amount: string) => uiText('squarePaymentMethod.achMessage', { amount }),\n get pendingTitle() { return uiText('squarePaymentMethod.pendingTitle'); },\n pendingMessage: (amount: string) => uiText('squarePaymentMethod.pendingMessage', { amount }),\n get receiptNote() { return uiText('squarePaymentMethod.receiptNote'); },\n};\n","import { FormsModule } from '@angular/forms';\nimport { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, Injector, ViewEncapsulation, afterNextRender, computed, effect, inject, input, signal, untracked, viewChild } from '@angular/core';\nimport { AlertComponent } from '@forgeroute/ui/alert';\nimport { ButtonComponent, UiLabelsService } from '@forgeroute/ui/core';\nimport { HintComponent } from '@forgeroute/ui/hint';\nimport { KpiCardComponent } from '@forgeroute/ui/kpi-card';\nimport { RadioGroupComponent } from '@forgeroute/ui/radio';\nimport { PaymentAttemptStatusComponent, callHost, classifyHostError, isAwaitingVerificationError, isFinalPaymentRefusal, paymentErrorLabelKey, wasQueuedOffline, warnQueuedPayment, createPaymentProtection, hostErrorMessage, type PaymentAttempt, type PaymentAttemptControls, type PaymentAttemptOutcome, type PaymentMethodContext, type PaymentProtectionInputs, type PaymentReadiness } from '@forgeroute/ui/payments';\nimport { formatCurrency } from '@forgeroute/ui/utils';\nimport { SquarePaymentComponent } from '../square-payment/square-payment.component';\nimport { SquareTerminalPaymentComponent, type SquareTerminalSucceededEvent } from '../square-terminal/square-terminal-payment.component';\nimport { SQUARE_TERMINAL_POLL_MS } from '../square-terminal/square-terminal.flow';\nimport { paymentBaseAmount, type SquareTerminalReadinessState } from '../square-terminal/square-terminal.models';\nimport type { SquareFailure } from '../square-payment/square-outcomes';\nimport type { SquarePaymentMethodComponent } from './payment-square-method.component';\nimport { SQUARE_METHOD_TEXTS, squareMethodOf, squareOutcomeOf, type SquareFees, type SquarePaymentContext, type SquarePaymentResult } from './payment-square-method.models';\n\n/** The body `ui-square-payment-method` hands to the panel: the Square form, the fee rows and the whole flow (tokenize, host callback, outcome), talking to the panel through `ctx`. */\n@Component({\n selector: 'ui-payment-square-body',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n imports: [FormsModule, AlertComponent, ButtonComponent, HintComponent, KpiCardComponent, PaymentAttemptStatusComponent, RadioGroupComponent, SquarePaymentComponent, SquareTerminalPaymentComponent],\n template: `\n <div class=\"psq\">\n @if (confirmation(); as notice) {\n <ui-alert variant=\"success\" [title]=\"notice.title\" tabindex=\"-1\" class=\"psq-notice\" data-testid=\"square-method-confirmation\">\n <p>{{ notice.message }}</p>\n <p>{{ receiptNote() }}</p>\n </ui-alert>\n } @else {\n <!-- the region stays in the DOM (only its content toggles) so a screen reader announces the reason when it appears -->\n <div role=\"status\" aria-live=\"polite\" class=\"psq-blocked\" data-testid=\"square-method-blocked-status\">\n @if (blockedMessage(); as reason) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" data-testid=\"square-method-blocked\">{{ reason }}</ui-alert>\n }\n </div>\n @if (readerEnabled()) {\n @if (!readerPaid()) {\n <!-- a refused switch re-creates the group (new epoch) so the radio shows the mode that is really in effect -->\n @for (epoch of [modeEpoch()]; track epoch) {\n <ui-radio-group class=\"psq-mode\" [label]=\"labels.t('stripeReader.mode.label')\" [options]=\"modeOptions()\" orientation=\"horizontal\" [ngModel]=\"modeShown()\" (ngModelChange)=\"chooseMode($event)\"\n [disabled]=\"modeLocked()\" data-testid=\"square-reader-mode\" />\n }\n @if (modeBlocked()) {\n <ui-alert variant=\"warning\" [quiet]=\"true\" class=\"psq-mode-blocked\" data-testid=\"square-reader-mode-blocked\">{{ labels.t(modeBlockedWhy() === 'manual-pending' ? 'stripeReader.mode.blockedManual' : 'stripeReader.mode.blocked') }}</ui-alert>\n }\n }\n <ui-square-terminal-payment [active]=\"mode() === 'reader'\" [amount]=\"ctx().amount\" [currency]=\"ctx().currency\" [payableRef]=\"config().payableRef()\" [paid]=\"config().paid()\"\n [startExtras]=\"readerExtras()\" [getReadiness]=\"reader()!.getReadiness\" [startPayment]=\"reader()!.startPayment\" [getPayment]=\"reader()!.getPayment\" [retryPayment]=\"reader()!.retryPayment\"\n [cancelPayment]=\"reader()!.cancelPayment\" [estimateFees]=\"reader()!.estimateFees\" [receiptUrl]=\"reader()!.receiptUrl ?? null\"\n [offlineOverride]=\"config().offlineOverride()\" [beforeStart]=\"beforeReaderStart\" [manualAvailable]=\"true\" [disabled]=\"isBlocked()\" [hideBanner]=\"!!ctx().readerBanner\" [pollMs]=\"readerPollMs()\"\n (manual)=\"onReaderManual()\" (connectReader)=\"config().readerConnect.emit()\" (getReader)=\"config().readerOrder.emit()\" (openSetup)=\"config().readerSetup.emit()\"\n (succeeded)=\"onReaderPaid($event)\" (readinessChange)=\"onReaderReadiness($event)\" (busyChange)=\"onReaderBusy($event)\" />\n @if (readerPaid()) {\n <ui-kpi-card class=\"psq-total\" data-testid=\"square-reader-paid-total\" [label]=\"labels.t('squarePaymentMethod.paymentAmount')\" [value]=\"readerPaidAmountText()\" icon=\"dollar\" color=\"blue\" valueColor=\"blue\" />\n }\n }\n @if (showManual()) {\n <ui-payment-attempt-status [attempt]=\"attempt\" [readiness]=\"readiness\" [allowStartOver]=\"config().allowStartOver()\" [showPaid]=\"!confirmation() && !done()\" (retryLoad)=\"payment()?.reset()\" />\n @if (ctx().amount == null) {\n <ui-hint data-testid=\"square-method-amount-needed\">{{ texts.amountNeeded }}</ui-hint>\n }\n @if (estimateError()) {\n <div class=\"psq-error\">\n <ui-alert variant=\"warning\" data-testid=\"square-method-estimate-error\">{{ estimateError() }}\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"square-method-estimate-retry\" (click)=\"retryEstimate()\">{{ labels.t('common.tryAgain') }}</ui-button>\n </ui-alert>\n </div>\n }\n @if (lastAmount() != null) {\n <ui-square-payment #payment mode=\"payment\" [method]=\"squareMethod()\" [applicationId]=\"config().applicationId()\" [locationId]=\"config().locationId()\" [environment]=\"config().environment()\"\n [amount]=\"chargedAmount()\" [currency]=\"ctx().currency\" [billingContact]=\"config().billingContact()\" [accountHolderName]=\"config().accountHolderName()\"\n [requireAchConsent]=\"config().requireAchConsent()\" [cardStyle]=\"config().cardStyle()\" [styleFromTokens]=\"true\" [showSubmit]=\"false\" [showErrors]=\"false\"\n [showStatus]=\"false\" [offlineOverride]=\"config().offlineOverride()\" [disabled]=\"processing() || done() || attempt.unknown() || attempt.paidLocked()\" [label]=\"labels.t('squarePaymentMethod.paymentDetails')\" (ready)=\"onReady()\" (failed)=\"onFailed($event)\" (loadError)=\"onFailed($event)\" />\n @if (totalCard(); as card) {\n <ui-kpi-card class=\"psq-total\" data-testid=\"square-method-total\" [label]=\"labels.t('squarePaymentMethod.totalCharged')\" [value]=\"card.value\" [subtitle]=\"card.subtitle\" icon=\"dollar\" color=\"blue\" valueColor=\"blue\" />\n }\n @if (feeRows().length) {\n <dl class=\"psq-fees\" data-testid=\"square-method-fees\" [attr.aria-label]=\"labels.t('squarePaymentMethod.paymentTotal')\">\n @for (row of feeRows(); track row.key) {\n <div class=\"psq-fee\" [attr.data-testid]=\"'square-fee-' + row.key\"><dt>{{ row.label }}</dt><dd>{{ row.value }}</dd></div>\n }\n </dl>\n }\n @if (error()) { <div class=\"psq-error\"><ui-alert variant=\"danger\" data-testid=\"square-method-error\">{{ error() }}</ui-alert></div> }\n }\n }\n }\n </div>\n `,\n styles: [`\n ui-payment-square-body { display: block; min-width: 0; }\n ui-payment-square-body .psq-error { margin-top: 12px; }\n ui-payment-square-body .psq-mode, ui-payment-square-body .psq-mode-blocked, ui-payment-square-body .psq-blocked { display: block; margin-bottom: 12px; }\n ui-payment-square-body .psq-blocked:empty { display: none; }\n ui-payment-square-body .psq-total { display: block; margin-top: 16px; }\n ui-payment-square-body .psq-fees { margin: 16px 0 0; padding: 14px 16px; border: 1px solid var(--ui-psp-border, #e2e8f0); border-radius: 10px; font-size: 0.8125rem; }\n ui-payment-square-body .psq-fee { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; color: var(--ui-psp-muted, #475569); }\n ui-payment-square-body .psq-fee dt, ui-payment-square-body .psq-fee dd { margin: 0; }\n ui-payment-square-body .psq-notice:focus { outline: none; }\n ui-payment-square-body .psq-notice p { margin: 0 0 6px; }\n `],\n})\nexport class PaymentSquareBodyComponent {\n protected readonly labels = inject(UiLabelsService);\n private readonly injector = inject(Injector);\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n readonly ctx = input.required<PaymentMethodContext>();\n readonly config = input.required<SquarePaymentMethodComponent>();\n private readonly payment = viewChild(SquarePaymentComponent);\n private readonly readerView = viewChild(SquareTerminalPaymentComponent);\n\n // ── Square Terminal (card reader) mode (opt-in: only with `[reader]` on the plugin and the method Card) ──\n protected readonly reader = computed(() => this.config().reader());\n protected readonly readerEnabled = computed(() => !!this.reader() && this.ctx().method === 'CARD');\n /** The last readiness state the reader screen reported (`null` = no answer / failed). */\n readonly readerState = signal<SquareTerminalReadinessState | null>(null);\n private readerAnswered = false;\n /** The payer's choice. `null` until the FIRST readiness answer: then the Terminal when it is ready (and `readerFirst`), else manual. Never changes by itself after that. */\n readonly choice = signal<'reader' | 'manual' | null>(null);\n protected readonly modeShown = signal<string>('manual');\n /** The Terminal payment that was taken (the success box and \"Done\" show). */\n readonly readerPaid = signal<SquareTerminalSucceededEvent | null>(null);\n private readerBusy = false;\n private readerAttemptKey: string | undefined;\n readonly mode = computed((): 'reader' | 'manual' => (this.readerEnabled() ? (this.choice() ?? 'manual') : 'manual'));\n /** The Square form shows (manual card): no Terminal, or manual chosen after the first readiness answer. */\n protected readonly showManual = computed(() => !this.readerEnabled() || (this.choice() === 'manual'));\n protected readonly readerActive = computed(() => this.readerEnabled() && this.mode() === 'reader');\n protected readonly modeOptions = computed(() => [\n { value: 'reader', label: this.labels.t('stripeReader.mode.reader'), testId: 'square-reader-mode-reader' },\n { value: 'manual', label: this.labels.t('stripeReader.mode.manual'), testId: 'square-reader-mode-manual' },\n ]);\n protected readonly modeLocked = computed(() => this.processing() || this.done() || this.switching() || this.isBlocked());\n protected readonly readerPollMs = computed(() => this.config().readerPollMs() ?? this.reader()?.pollMs ?? SQUARE_TERMINAL_POLL_MS);\n /** Blocked by the plugin's own `[blocked]` or by the panel's (`ctx.blocked`). */\n protected readonly isBlocked = computed(() => this.config().blocked() || !!this.ctx().blocked);\n protected readonly blockedMessage = computed(() => (this.config().blocked() && !this.ctx().blocked && !this.done() && !this.readerPaid() && !this.confirmation()\n ? (this.config().blockedReason().trim() || this.labels.t('paymentBlocked.default')) : ''));\n private readonly switching = signal(false);\n protected readonly modeBlocked = signal(false);\n protected readonly modeBlockedWhy = signal<'reader-open' | 'manual-pending'>('reader-open');\n protected readonly modeEpoch = signal(0);\n protected readonly readerExtras = computed(() => { const c = this.ctx(); return { receivedDate: c.receivedDate, notes: c.note || null, allocation: c.allocation }; });\n /** Called by the Terminal screen's Send button: the panel's fields must be valid (and show their messages). */\n protected readonly beforeReaderStart = (): boolean => this.ctx().validate();\n protected readonly readerPaidAmountText = computed(() => { const e = this.readerPaid(); return e ? formatCurrency(e.amount, { currency: this.ctx().currency }) : ''; });\n\n protected readonly texts = SQUARE_METHOD_TEXTS;\n\n readonly ready = signal(false);\n readonly processing = signal(false);\n /** The payment was accepted (the panel was told, or the notice is up): Pay stays off even if the host keeps the panel open. */\n readonly done = signal(false);\n readonly error = signal('');\n /** The service gave an answer a retry cannot change (see `isFinalPaymentRefusal`), for THIS method, payable and amount: the text stays and Pay stays off until one of them changes (then the refusal and its text are cleared for good; it comes back only if the service answers it again). */\n readonly finalRefusal = signal<{ method: string; ref: string | null; amount: number } | null>(null);\n /** Fees from the host's estimate (before the payer pays). */\n readonly estimate = signal<SquareFees | null>(null);\n private readonly estimating = signal(false);\n protected readonly estimateError = signal('');\n private readonly estimateTick = signal(0);\n /** Fees the host answered when it created the payment. */\n private readonly resultFees = signal<SquareFees | null>(null);\n protected readonly confirmation = signal<{ title: string; message: string } | null>(null);\n /** The last valid amount: the form stays mounted (and keeps the typed card data) while the amount is briefly empty or invalid. */\n protected readonly lastAmount = signal<number | null>(null);\n /** What the attempt was STARTED with (pinned at the click; a later amount edit or method change never changes what is recorded). */\n private payAmount: number | null = null;\n private payMethod: string | null = null;\n /** What the payment that was RECORDED (or accepted) was made with: a late answer of an older attempt is recorded with ITS OWN amount and method, never the newest click's. */\n private doneAmount: number | null = null;\n private doneMethod: string | null = null;\n private estimateRun = 0;\n\n private readonly amountValue = computed(() => this.ctx().amount);\n private readonly methodValue = computed(() => this.ctx().method);\n protected readonly squareMethod = computed(() => squareMethodOf(this.ctx().method));\n private readonly total = computed(() => this.resultFees()?.totalAmount ?? this.estimate()?.totalAmount ?? this.lastAmount() ?? 0);\n /** What the card is actually charged (amount + fees the host showed): the amount Square's buyer verification must be asked for. Falls back to the entered amount. */\n protected readonly chargedAmount = computed(() => this.estimate()?.totalAmount ?? this.resultFees()?.totalAmount ?? this.lastAmount());\n protected readonly receiptNote = computed(() => this.config().receiptNote());\n protected readonly feeRows = computed(() => {\n const fees = this.resultFees() ?? this.estimate();\n const amount = this.lastAmount();\n if (!fees || amount == null || (fees.processingFee === undefined && fees.platformFee === undefined)) return [];\n const money = (n: number) => formatCurrency(n, { currency: this.ctx().currency });\n const rows: { key: string; label: string; value: string }[] = [{ key: 'amount', label: this.labels.t('squarePaymentMethod.paymentAmount'), value: money(amount) }];\n if (fees.processingFee !== undefined) rows.push({ key: 'processing', label: `${this.labels.t('squarePaymentMethod.processingFee')}${fees.processingFeeLabel ? ` (${fees.processingFeeLabel})` : ''}`, value: money(fees.processingFee) });\n if (fees.platformFee !== undefined) rows.push({ key: 'platform', label: `${this.labels.t('squarePaymentMethod.platformFee')}${fees.platformFeeLabel ? ` (${fees.platformFeeLabel})` : ''}`, value: money(fees.platformFee) });\n return rows;\n });\n /** The headline figure: what the payer is charged, once fees are known. */\n protected readonly totalCard = computed(() => {\n const fees = this.resultFees() ?? this.estimate();\n if (!fees || this.lastAmount() == null || fees.totalAmount === undefined) return null;\n return { value: formatCurrency(fees.totalAmount, { currency: this.ctx().currency }), subtitle: this.labels.t('squarePaymentMethod.amountPlusFees') };\n });\n\n /** The duplicate-payment protection of this payment (lock, attempt key, unknown state) and its readiness gate, driven by the plugin's inputs. */\n readonly attempt: PaymentAttempt;\n readonly readiness: PaymentReadiness;\n private gone = false;\n\n constructor() {\n // offlineOverride is read once while the readiness gate is constructed, before the inputs are bound: an unset required input counts as \"no override\" until the config arrives.\n const configured = <T>(read: (config: SquarePaymentMethodComponent) => T) => computed(() => read(this.config()));\n const inputs: PaymentProtectionInputs = {\n payableRef: configured(c => c.payableRef()), attemptKey: configured(c => c.attemptKey()), checkStatus: configured(c => c.checkStatus()), paid: configured(c => c.paid()), hostPending: configured(c => c.hostPending()),\n statusPollMs: configured(c => c.statusPollMs()), statusPollMaxMs: configured(c => c.statusPollMaxMs()),\n statusCheckTimeoutMs: configured(c => c.statusCheckTimeoutMs()), statusFailGraceMs: configured(c => c.statusFailGraceMs()), authTimeoutMs: configured(c => c.authTimeoutMs()), readinessCheck: configured(c => c.readinessCheck()),\n readinessTimeoutMs: configured(c => c.readinessTimeoutMs()), readinessEveryMs: configured(c => c.readinessEveryMs()), offlineOverride: computed(() => { try { return this.config().offlineOverride(); } catch { return false; } }),\n };\n const protection = createPaymentProtection(inputs, {\n amount: () => this.ctx().amount,\n method: () => this.ctx().method,\n sdk: () => (this.payment()?.loadErrorText() ? 'blocked' : 'ok'),\n onOutcome: o => this.onAttemptOutcome(o),\n });\n this.attempt = protection.attempt;\n this.readiness = protection.readiness;\n inject(DestroyRef).onDestroy(() => { this.gone = true; });\n // The host resolves an undecided attempt through the plugin component (markSucceeded / markFailed / markNotCharged / markUnknown), without a status check.\n const controls: PaymentAttemptControls = {\n markUnknown: () => this.attempt.markUnknown('host'),\n markSucceeded: () => this.attempt.succeed('host'),\n markFailed: () => this.attempt.fail('host'),\n resetPaid: () => { this.attempt.resetPaid(); this.readerView()?.attempt.resetPaid(); this.readerPaid.set(null); this.done.set(false); this.confirmation.set(null); this.error.set(''); this.ctx().setExclusive(false); },\n markNotCharged: () => { this.attempt.markNotCharged(); this.payment()?.markNotCharged(); this.processing.set(false); this.ctx().setBusy(false); this.ctx().flowOver?.(); },\n };\n // The controls are handed to the plugin that is bound NOW and taken back from that same one when the binding changes or the body is destroyed. (Reading `this.config()` in a destroy callback threw NG0950 when the body\n // was destroyed before its required config input was ever bound, which aborted the rest of the view's cleanups.)\n effect(onCleanup => {\n const config = this.config();\n untracked(() => config.attachControls(controls));\n onCleanup(() => config.detachControls(controls));\n });\n effect(() => { const amount = this.amountValue(); if (amount != null) untracked(() => this.lastAmount.set(amount)); });\n // A final refusal belongs to the method, payable and amount it was raised for: when one of them changes the refusal and its text are cleared (and stay cleared unless the service answers it again).\n effect(() => {\n const scope = this.finalRefusal();\n if (!scope) return;\n const ctx = this.ctx();\n if (ctx.method !== scope.method || ctx.amount !== scope.amount || this.config().payableRef() !== scope.ref) untracked(() => { this.finalRefusal.set(null); this.error.set(''); });\n });\n // The panel's footer button for this method.\n effect(() => {\n const ctx = this.ctx();\n const processing = this.processing();\n const notice = this.confirmation();\n const ready = this.ready();\n const estimating = this.estimating();\n const done = this.done();\n const estimateFailed = !!this.estimateError();\n const unknown = this.attempt.unknown();\n const paidLocked = this.attempt.paidLocked();\n const finalRefusal = !!this.finalRefusal();\n const gateReady = this.readiness.ready();\n const readerActive = this.readerActive();\n const readerPaid = this.readerPaid();\n const blocked = this.isBlocked();\n const label = notice ? this.labels.t('common.done') : ctx.amount != null ? `${this.labels.t('squarePaymentMethod.pay')} ${formatCurrency(this.total(), { currency: ctx.currency })}` : this.labels.t('squarePaymentMethod.pay');\n // Terminal mode: the Terminal screen has its own buttons (Send / Cancel); after a Terminal payment only \"Done\" shows.\n if (readerPaid) { untracked(() => ctx.setPrimary({ label: this.labels.t('common.done'), disabled: done, onClick: () => this.finish() })); return; }\n if (readerActive) { untracked(() => ctx.setPrimary(null)); return; }\n untracked(() => ctx.setPrimary({\n label, loading: processing && !notice,\n disabled: notice ? done : !ready || processing || estimating || estimateFailed || ctx.amount == null || done || unknown || paidLocked || finalRefusal || !gateReady || blocked,\n onClick: () => (notice ? this.finish() : void this.pay()),\n }));\n });\n // Estimated fees, debounced (display only: Square's form is not created for an amount).\n effect((onCleanup) => {\n const estimate = this.config().estimateFees();\n const amount = this.amountValue();\n const method = this.methodValue();\n const readerActive = this.readerActive();\n // Before the FIRST readiness answer nothing is estimated (the ONLINE quote would be asked for a payer who may pay on the Terminal).\n const modePending = this.readerEnabled() && this.choice() === null;\n this.estimateTick();\n const run = ++this.estimateRun; // any change makes an answer that is still on its way stale\n untracked(() => { this.estimate.set(null); this.resultFees.set(null); this.estimateError.set(''); });\n if (!estimate || amount == null || readerActive || modePending) { untracked(() => this.estimating.set(false)); return; }\n untracked(() => this.estimating.set(true));\n let hung: ReturnType<typeof setTimeout> | null = null;\n const failure = this.labels.t('squarePaymentMethod.feesFailed');\n const timer = setTimeout(async () => {\n // A hung estimate must not block the user forever: after the timeout \"Try again\" is offered (and Pay stays off when fees are required). A late answer still recovers.\n hung = setTimeout(() => {\n if (run !== this.estimateRun) return;\n this.estimating.set(false);\n if (this.feesMustBeKnown()) this.estimateError.set(failure);\n }, Math.max(1, this.config().estimateTimeoutMs()));\n let fees: SquareFees | null = null;\n try { fees = (await callHost(() => estimate({ amount, paymentMethod: method, method: squareMethodOf(method), funding: null }))) ?? null; } catch { fees = null; }\n if (hung) { clearTimeout(hung); hung = null; }\n if (run !== this.estimateRun) return;\n this.estimating.set(false);\n if (fees) { this.estimate.set(fees); this.estimateError.set(''); }\n else { this.estimate.set(null); this.estimateError.set(this.feesMustBeKnown() ? failure : ''); }\n }, 300);\n onCleanup(() => { clearTimeout(timer); if (hung) clearTimeout(hung); });\n });\n // A new form is built for another method, or for another application / location / environment: it is not ready until Square says so (Pay stays off meanwhile).\n effect(() => {\n this.methodValue();\n const config = this.config();\n config.applicationId(); config.locationId(); config.environment();\n untracked(() => { this.ready.set(false); this.error.set(''); });\n });\n // A new method starts the Terminal choice again (the first readiness answer decides the default).\n effect(() => { this.methodValue(); untracked(() => { this.choice.set(null); this.readerState.set(null); this.readerAnswered = false; }); });\n // The panel tells us when it is closing or the method changes before this body is removed: an accepted payment whose notice is still up is reported as recorded.\n effect(() => { const ctx = this.ctx(); untracked(() => ctx.onCancel(() => {\n // The panel clears the close guard when it runs this hook: the guard is registered again, or a panel that stays open (a reset) would let the payment be abandoned.\n this.registerCloseGuard(ctx);\n if (this.readerPaid()) { this.finish(); return; }\n const view = this.readerView();\n if (view?.isLocked()) { view.cancelBestEffort(); return; }\n if (this.confirmation()) this.finish();\n })); });\n // The panel asks before it closes: a payment that waits on a Terminal must be canceled first.\n effect(() => { const ctx = this.ctx(); untracked(() => this.registerCloseGuard(ctx)); });\n // The panel's top banner (`ctx.readerBanner`) never steps aside; this screen draws no reader banner of its own then (`hideBanner`), so exactly ONE banner per state.\n effect(() => { const mode = this.mode(); const pending = this.readerEnabled() && this.choice() === null; untracked(() => { this.modeShown.set(pending ? '' : mode); }); });\n inject(DestroyRef).onDestroy(() => { this.estimateRun++; });\n // The body is going away: a Terminal payment that was open MAY STILL EXIST at the processor, so the host hears `readerLeftPending` (never \"idle\").\n inject(DestroyRef).onDestroy(() => this.leaveReaderPending('destroyed'));\n // The Terminal screen is removed while a payment is open on it (the reader was switched off, or the method left Card): the same rule applies.\n effect(() => { const enabled = this.readerEnabled(); untracked(() => { if (!enabled && this.readerBusy) this.leaveReaderPending('unmounted'); }); });\n }\n\n // ── Terminal handlers ──\n\n private registerCloseGuard(ctx: PaymentMethodContext): void {\n ctx.setCloseGuard?.(() => {\n const view = this.readerView();\n const wasOpen = !!view?.isLocked();\n const allowed = view?.requestClose() ?? true;\n // The panel may close while the start answer is still on its way (starting / recovering): the payment is not canceled, so the host hears which attempt is left open.\n if (allowed && wasOpen) ctx.report('reader-left-pending', { ...(this.readerAttemptKey ? { attemptKey: this.readerAttemptKey } : {}) });\n return allowed;\n });\n }\n\n /** A Terminal payment that MAY STILL EXIST is let go of: never reported idle. The host hears `readerLeftPending` (and a panel hears `ctx.leavePending`). Once per busy period. */\n private leaveReaderPending(reason: 'destroyed' | 'unmounted'): void {\n if (!this.readerBusy) return;\n this.readerBusy = false;\n const paymentAttemptKey = this.readerAttemptKey;\n try { this.config().readerLeftPending.emit({ reason, ...(paymentAttemptKey ? { paymentAttemptKey } : {}) }); } catch { /* the plugin is already gone */ }\n if (reason === 'unmounted') { try { this.ctx().leavePending?.({ reason: 'unmounted', ...(paymentAttemptKey ? { paymentAttemptKey } : {}) }); } catch { /* the panel is already gone */ } }\n }\n\n /** The Terminal screen read the readiness. The FIRST answer decides the default: the Terminal when it is ready, else manual. */\n protected onReaderReadiness(state: SquareTerminalReadinessState | null): void {\n const previous = this.readerState();\n const answeredBefore = this.readerAnswered;\n this.readerAnswered = true;\n this.readerState.set(state);\n // The panel's top banner is the only reader banner on screen: when this screen's own read sees the state CHANGE the top banner reads again.\n if (answeredBefore && state !== null && previous !== state && this.ctx().readerBanner) { try { this.ctx().refreshReaderBanner?.(); } catch { /* the panel is already gone */ } }\n if (this.choice() === null) this.choice.set(state === 'reader_ready' && this.config().readerFirst() ? 'reader' : 'manual');\n }\n\n /** A Terminal payment is open: everything else is locked (fields, method, the manual form). */\n protected onReaderBusy(locked: boolean): void {\n if (locked === this.readerBusy) return;\n this.readerBusy = locked;\n if (locked) {\n try { this.readerAttemptKey = this.readerView()?.attempt.key() || undefined; } catch { this.readerAttemptKey = undefined; }\n this.config().rememberAttempt(this.readerAttemptKey, 'reader', this.ctx().amount ?? undefined);\n }\n this.config().readerBusyChange.emit(locked);\n if (!locked) this.modeBlocked.set(false);\n // A Terminal payment is open (started here, or found again after a reload / in a second tab): its screen is the one to show, never the manual form behind it.\n else if (this.choice() !== 'reader') this.choice.set('reader');\n this.ctx().setBusy(locked);\n if (!locked) this.ctx().flowOver?.();\n }\n\n /** The payer picks Terminal or manual. Leaving the Terminal while a payment waits first cancels it THROUGH THE HOST; only when the service confirmed it does the manual form open. */\n protected async chooseMode(next: string | null): Promise<void> {\n const target = next === 'reader' ? 'reader' : 'manual';\n if (this.switching() || (target === this.mode() && this.choice() !== null)) return;\n this.modeBlocked.set(false);\n if (target === 'manual') {\n const view = this.readerView();\n if (view?.isLocked()) {\n this.switching.set(true);\n let canceled = false;\n try { canceled = await view.cancelAndWait(); } finally { this.switching.set(false); }\n if (!canceled) { this.refuseSwitch('reader-open'); return; }\n this.ctx().flowOver?.();\n }\n } else if (this.processing() || this.attempt.unknown()) { this.refuseSwitch('manual-pending'); return; }\n this.choice.set(target);\n }\n\n private refuseSwitch(why: 'reader-open' | 'manual-pending'): void {\n this.modeBlockedWhy.set(why);\n this.modeBlocked.set(true);\n this.modeEpoch.update(n => n + 1);\n this.modeShown.set(this.mode());\n afterNextRender(() => this.host.nativeElement.querySelector<HTMLElement>('[data-testid=\"square-reader-mode\"] input:checked')?.focus(), { injector: this.injector });\n }\n\n /** The Terminal screen asked for the manual form (its payment is already canceled or never started). */\n protected onReaderManual(): void { this.choice.set('manual'); this.ctx().flowOver?.(); }\n\n /** The Terminal took the payment: reported like any live payment; \"Done\" completes the panel. */\n protected onReaderPaid(event: SquareTerminalSucceededEvent): void {\n if (this.done() || this.readerPaid()) return;\n const ctx = this.ctx();\n // Never reported as 0 while any amount is known: the event's, else the payment's own base amount, else what the panel says now, else the last amount it said.\n const amount = event.amount > 0 ? event.amount : (paymentBaseAmount(event.payment) ?? ctx.amount ?? this.lastAmount() ?? event.amount);\n this.readerPaid.set({ ...event, amount });\n this.doneAmount = amount;\n this.doneMethod = ctx.method;\n ctx.report('paid', { result: { type: 'stripe', paymentMethod: ctx.method, amount, processor: 'square' } });\n ctx.setExclusive(true);\n ctx.setBusy(false);\n if (this.readerBusy) { this.readerBusy = false; this.config().readerBusyChange.emit(false); }\n }\n\n /**\n * Pay stays off while an estimate that was asked for failed when the payer covers fees (`feesRequired`) OR when buyer verification is on (`billingContact`): the verification is\n * done for the charged total, so a failed estimate would verify the base amount while the host may still add fees (Square then declines with a verification error).\n */\n private feesMustBeKnown(): boolean { return this.config().feesRequired() || !!this.config().billingContact(); }\n\n protected retryEstimate(): void { this.estimateTick.update(n => n + 1); }\n\n protected onReady(): void {\n this.ready.set(true);\n this.ctx().announce(this.labels.t('squarePaymentMethod.announceReady'));\n }\n\n protected onFailed(failure: SquareFailure): void {\n // A failed buyer verification (3-D Secure) happened BEFORE any charge: the payer can try again, for the SAME total the Pay button shows.\n const message = failure.stage === 'verify' ? `${failure.message} ${this.labels.t('paymentAttempt.verifyRetry', { amount: formatCurrency(this.total(), { currency: this.ctx().currency }) })}` : failure.message;\n failure = { ...failure, message };\n this.error.set(failure.message); // shown in a role=alert ui-alert: that is the announcement\n this.processing.set(false);\n this.ctx().report('failed', { message: failure.message });\n }\n\n /**\n * Pays: the gate (paid / unknown / not ready / offline: nothing is sent), validates the panel, then ONE attempt under the synchronous lock: tokenizes the Square form and creates the\n * payment through the host with the attempt key. A timeout, going offline or an ambiguous host error makes the outcome UNKNOWN (locked, \"Checking your payment...\", status check by\n * key); only a definitive refusal unlocks with a new key. The component never retries a charge itself.\n */\n async pay(): Promise<void> {\n const ctx = this.ctx();\n const payment = this.payment();\n if (this.processing() || this.estimating() || this.done() || !payment || this.isBlocked()) return;\n if (this.refused(ctx)) return;\n if (!ctx.validate() || ctx.amount == null) return;\n this.payAmount = ctx.amount;\n this.payMethod = ctx.method;\n const attemptAmount: number = ctx.amount; // captured for THIS attempt: a late answer must not read the fields a newer click overwrote\n const attemptMethod: string = ctx.method;\n const create = this.config().createPayment();\n if (!create) { this.onFailed({ code: 'not_configured', message: this.labels.t('squarePaymentMethod.unavailable'), squareMessage: '', stage: 'tokenize' }); return; }\n this.error.set('');\n this.processing.set(true);\n ctx.setBusy(true);\n ctx.announce(this.labels.t('squarePaymentMethod.announceProcessing'));\n let finished = false;\n const run = await this.attempt.run<SquarePaymentResult | null>(async key => {\n // A LATE answer (the attempt moved on while this call was still running) must not touch the newer attempt's screen, error text, busy state or inner form: every side effect below asks `live()` first.\n const live = (): boolean => this.attempt.isLive(key);\n try {\n // The tokenization starts synchronously from the click (the bank window of an ACH payment needs the user gesture).\n if (squareMethodOf(attemptMethod) === 'ach') this.attempt.markPending('bank_window'); // the bank window may stay open for minutes: the request timeout is replaced by authTimeoutMs meanwhile\n const event = await payment.tokenize();\n if (!event) return { kind: 'released' }; // the form reported the failure (onFailed): nothing was charged\n if (this.gone) return { kind: 'released', reason: 'destroyed' }; // destroyed before the host call: NOTHING was sent, the marker must not outlive the page\n const request: SquarePaymentContext = {\n amount: attemptAmount, paymentMethod: attemptMethod, method: event.method, receivedDate: ctx.receivedDate, notes: ctx.note || null, ...ctx.allocation,\n token: event.token, details: event.details, funding: event.details.cardType, verificationToken: event.verificationToken, idempotencyKey: event.idempotencyKey, attemptKey: key, payableRef: this.attempt.pinnedRef(),\n };\n let result: SquarePaymentResult | null | undefined;\n try { result = await callHost(() => create(request)); } catch (err) { // after the panel closed (`this.gone`) the classification still decides and the core writes the records: there is no screen left to touch\n const kind = classifyHostError(err);\n if (kind === 'unknown') return { kind: 'unknown', reason: isAwaitingVerificationError(err) ? 'microdeposits' : 'host_error' }; // the open payment waits for the payer's bank verification: say so, never \"already processed\"\n // The reference / payment-link codes are worded in OUR (translated) words; a final one (the balance changed, the link was paid / ended, the processor cannot do it) keeps the text and turns Pay off instead of looping.\n const labelKey = paymentErrorLabelKey(err);\n const message = labelKey ? this.labels.t(labelKey) : hostErrorMessage(err, this.labels.t('squarePaymentMethod.paymentFailed'));\n if (live() && isFinalPaymentRefusal(err)) this.finalRefusal.set({ method: attemptMethod, ref: this.config().payableRef(), amount: attemptAmount });\n if (kind === 'not_sent') { // the request never left (offline layer): nothing was charged, the key is KEPT and the payer may try again\n if (live()) { this.error.set(message); ctx.report('refused', { message }); }\n return { kind: 'released', reason: 'not_sent' };\n }\n if (live()) { this.error.set(message); ctx.report('failed', { message }); }\n return { kind: 'failure', reason: 'host_refused' };\n }\n if (wasQueuedOffline(result)) { // the offline layer QUEUED the request instead of sending it (a synthetic 202): no payment exists, the key is KEPT\n warnQueuedPayment();\n const message = this.labels.t('paymentAttempt.queuedOffline');\n if (live()) { this.error.set(message); ctx.report('refused', { message }); }\n return { kind: 'released', reason: 'not_sent' };\n }\n if (this.gone) return { kind: squareOutcomeOf(result?.status, squareMethodOf(attemptMethod)) === 'failed' ? 'failure' : 'success', value: result ?? null, reason: 'created' }; // the panel closed meanwhile: the answer is still the payment's outcome (the core records it for the next form of the payable)\n finished = this.afterCreate(result ?? null, ctx, live(), attemptAmount, attemptMethod);\n return { kind: squareOutcomeOf(result?.status, squareMethodOf(attemptMethod)) === 'failed' ? 'failure' : 'success', value: result ?? null, reason: 'created' };\n } finally { if (live()) payment.markNotCharged(); } // the token was handed to the host: the INNER form's own lock ends with this attempt (never the lock of a NEWER attempt)\n }, { timeoutMs: this.config().paymentTimeoutMs() });\n this.processing.set(false);\n if ('refused' in run && run.refused) { ctx.setBusy(false); return; }\n if (run.kind === 'unknown') return; // stays locked (busy) until the status check, the host or a late answer resolves it\n if (!finished) ctx.setBusy(false);\n }\n\n /** Refuses to start (nothing is sent): a paid payable, an unknown earlier outcome, a failed readiness gate or being offline. Returns true when refused. */\n private refused(ctx: PaymentMethodContext): boolean {\n if (!this.readiness.passSync()) {\n const reason = this.readiness.reasons()[0] ?? 'checking';\n const message = this.labels.t(this.readiness.labelKeyFor(reason));\n this.error.set(message);\n ctx.report('refused', { message });\n ctx.announce(message);\n return true;\n }\n if (this.attempt.paidLocked() || this.attempt.unknown()) { this.attempt.begin(); return true; } // refuses and reports `refused`\n return false;\n }\n\n /** The attempt resolved OUTSIDE the click (a status check, the host's `markSucceeded` / `markFailed`, a late answer) or became unknown. */\n private onAttemptOutcome(outcome: PaymentAttemptOutcome): void {\n const ctx = this.ctx();\n if (outcome.kind === 'unknown' && outcome.reason === 'duplicate_suspected') {\n // A SECOND payment of a payable that is already paid: nothing about the lock, the amount or the method changes; the host is told (with the key of the second payment) so it can resolve it.\n const message = this.labels.t('paymentAttempt.duplicate');\n this.error.set(message);\n ctx.report('duplicate_suspected', { message, attemptKey: outcome.attemptKey });\n ctx.announce(message);\n } else if (outcome.kind === 'unknown') {\n this.payAmount = this.attempt.pinnedAmount() ?? this.payAmount; // the amount and method of the attempt that is UNKNOWN (an adopted one included), never a stale earlier one\n this.payMethod = this.attempt.pinnedMethod() ?? this.payMethod;\n const message = this.labels.t(outcome.reason === 'offline' ? 'paymentAttempt.offlineInFlight' : outcome.reason === 'timeout' ? 'paymentAttempt.timeout' : outcome.reason === 'microdeposits' || this.attempt.awaitingVerification() ? 'paymentAttempt.awaitingVerification' : 'paymentAttempt.checking'); // a reload / another tab that adopted a bank verification wait says so too\n ctx.report('unknown', { message });\n ctx.announce(message);\n } else if (outcome.kind === 'refused') {\n const refusedReason = outcome.reason ?? '';\n // `unknown` while a bank verification wait is on is the verification text, never \"Checking your payment...\"\n const refusedKey = refusedReason === 'unknown' && this.attempt.awaitingVerification() ? 'paymentAttempt.awaitingVerification' : this.readiness.labelKeyFor(refusedReason);\n ctx.report('refused', { message: this.labels.t(refusedKey) });\n } else if (outcome.kind === 'succeeded' && outcome.reason === 'other_tab') {\n // Another tab / page load paid this payable: this form only shows the paid lock. Nothing is recorded here (no `paid`, no `complete`): no money moved through THIS form and the amount typed here is not what was paid.\n // A host that wants to reconcile reads the paid attempt's key, amount and method from the report (and from the form's own `(outcome)`).\n ctx.report('paid_elsewhere', { message: this.labels.t('paymentAttempt.paid'), attemptKey: outcome.attemptKey, ...(outcome.method !== undefined ? { paid: { amount: outcome.amount ?? null, method: outcome.method } } : {}) });\n } else if (outcome.kind === 'succeeded' && (outcome.reason === 'status_check' || outcome.reason === 'host') && !this.done()) {\n const paid = { type: 'stripe' as const, paymentMethod: outcome.method ?? this.payMethod ?? ctx.method, amount: outcome.amount ?? this.payAmount ?? ctx.amount ?? this.lastAmount() ?? 0, processor: 'square' };\n this.doneAmount = paid.amount;\n this.doneMethod = paid.paymentMethod;\n ctx.report('paid', { result: paid });\n this.done.set(true);\n ctx.setBusy(false);\n ctx.complete(paid);\n } else if (outcome.kind === 'failed') {\n if (outcome.reason === 'status_check' || outcome.reason === 'host') {\n const message = this.labels.t('paymentAttempt.failedAfterCheck');\n this.error.set(message);\n ctx.report('failed', { message });\n }\n this.payment()?.markNotCharged(); // the attempt is decided: the INNER form's lock (kept while the host charged) ends with it, so a NEW attempt can tokenize even when the old request never answers\n ctx.setBusy(false); // also a LATE definitive refusal (the answer came after a timeout): the panel is free again\n }\n }\n\n private afterCreate(result: SquarePaymentResult | null, ctx: PaymentMethodContext, live: boolean, amount: number, method: string): boolean {\n if (this.done() || this.confirmation()) return true; // a status check or the host already recorded this payment: report it exactly once\n const money = formatCurrency(amount, { currency: ctx.currency });\n const outcome = squareOutcomeOf(result?.status, squareMethodOf(method));\n if (outcome === 'failed') {\n if (live) { // a late decline of an OLDER attempt says nothing on the newer attempt's screen\n const message = result?.failureMessage || this.texts.notCompleted;\n this.error.set(message);\n ctx.report('failed', { message });\n }\n return false;\n }\n if (live && result && (result.processingFee !== undefined || result.platformFee !== undefined || result.totalAmount !== undefined)) {\n this.resultFees.set({ processingFee: result.processingFee, platformFee: result.platformFee, totalAmount: result.totalAmount, processingFeeLabel: result.processingFeeLabel, platformFeeLabel: result.platformFeeLabel });\n }\n const paid = { type: 'stripe' as const, paymentMethod: method, amount, processor: 'square' };\n this.doneAmount = amount;\n this.doneMethod = method;\n if (outcome === 'paid') {\n ctx.report('paid', { result: paid });\n this.done.set(true);\n ctx.complete(paid);\n return true;\n }\n ctx.report('processing', { result: paid });\n this.confirmation.set(squareMethodOf(method) === 'ach'\n ? { title: this.texts.achTitle, message: this.texts.achMessage(money) }\n : { title: this.texts.pendingTitle, message: this.texts.pendingMessage(money) });\n ctx.setExclusive(true);\n ctx.setBusy(false);\n afterNextRender(() => this.host.nativeElement.querySelector<HTMLElement>('.psq-notice')?.focus(), { injector: this.injector });\n return true;\n }\n\n /** \"Done\" on the submitted notice, or closing the panel while the notice is up: the accepted payment is reported as recorded (once). */\n private finish(): void {\n const ctx = this.ctx();\n if (this.done()) return;\n this.done.set(true);\n ctx.complete({ type: 'stripe', paymentMethod: this.doneMethod ?? this.payMethod ?? ctx.method, amount: this.doneAmount ?? this.payAmount ?? ctx.amount ?? this.lastAmount() ?? 0, processor: 'square' });\n }\n}\n","import { ChangeDetectionStrategy, Component, DestroyRef, ViewEncapsulation, computed, effect, inject, input, output, signal, untracked } from '@angular/core';\nimport { AlertComponent } from '@forgeroute/ui/alert';\nimport { ButtonComponent, UiLabelsService } from '@forgeroute/ui/core';\nimport { builtInReadinessReasons, callHost, type PaymentReaderBannerConfig, type PaymentReaderState } from '@forgeroute/ui/payments';\nimport { normalizeReadiness, readerBannerReasonKey, type SquareTerminalGetReadinessFn, type SquareTerminalReadiness } from './square-terminal.models';\n\n/**\n * Gives a host without `ui-square-payment-method` in its panel the `[readerBanner]` config of `ui-payment-side-panel` (merchant not ready, collection off, no payable version: no plugin is rendered, but the banner must show).\n * With the plugin rendered a plain `{ getReadiness }` object is enough (the plugin supplies the component).\n *\n * readonly banner = computed(() => squareTerminalBannerConfig({ getReadiness: this.readiness, refreshKey: this.readersVersion() }));\n */\nexport function squareTerminalBannerConfig(config: Omit<PaymentReaderBannerConfig, 'component'>): PaymentReaderBannerConfig {\n return { ...config, component: SquareTerminalBannerComponent };\n}\n\n/**\n * The service states the banner shows: the organization has NO usable Terminal (`no_reader`, `unsupported_only`, `merchant_not_ready`) or HAS one that is not connected (`reader_offline`, `reader_pairing`: a pairing code was issued but not entered on the Terminal).\n * Busy, ready, checking and a failed read show nothing (busy means in use, never \"not connected\").\n */\nexport const SQUARE_TERMINAL_BANNER_STATES: readonly SquareTerminalReadiness['state'][] = ['no_reader', 'unsupported_only', 'merchant_not_ready', 'reader_offline', 'reader_pairing'];\n\n/** The banner states in which a Terminal exists but is not connected: the message \"Your Square Terminal is not connected.\" with the one action \"Connect Your Terminal\". */\nexport const SQUARE_TERMINAL_NOT_CONNECTED_STATES: readonly SquareTerminalReadiness['state'][] = ['reader_offline', 'reader_pairing'];\n\n/**\n * The Square Terminal banner: a SMALL `ui-alert` (info, one line, ONE action) for a STAFF place where a customer payment can be taken. Two situations show it:\n * - NO Terminal (`no_reader`, `unsupported_only`): \"Get a Square Terminal to take in-person card payments.\" with ONLY \"How to get one\" (`order`);\n * - a Terminal that is NOT CONNECTED (`reader_offline`, `reader_pairing`): \"Your Square Terminal is not connected.\" with ONLY \"Connect Your Terminal\" (`connect`);\n * - `merchant_not_ready`: payments must be set up first (`setup`).\n * It renders NOTHING in every other state (reader ready, busy = in use, still checking, a failed read, an offline browser): those belong to the reader screen the payment plugin shows when Card is chosen. `ui-payment-side-panel [readerBanner]` renders it as the first element of the panel. Never use it in a payer-facing component.\n *\n * <ui-square-terminal-banner [getReadiness]=\"readiness\" [refreshKey]=\"readersVersion()\" [hardwareShopAvailable]=\"canOrder()\" (connect)=\"openPairing()\" (order)=\"openOrder()\" (setup)=\"openSetup()\" />\n *\n * A readiness `reason` of `sandbox`, `service_disabled` or `processor_unsupported` (in any state the banner shows) gives its own plain message and NO button (see `SQUARE_TERMINAL_BANNER_REASONS`: \"Card readers are not available in a sandbox account.\", \"Card readers are turned off for this account.\", \"Card readers are not available with this payment processor.\"; Spanish in the dictionary); the banner still appears only in its listed states (no_reader, unsupported_only, merchant_not_ready, reader_offline, reader_pairing).\n * `hardwareShopAvailable` is ignored (always \"How to get one\"); `merchant_not_ready` says payments must be\n * set up first and offers \"Set up payments\" (\"Reconnect payments\" when the account must be reconnected; `setup`). The container is always in the DOM (it mounts when the panel opens, the host never gates anything on the read); the alert appears when the answer\n * arrives. The readiness is read FRESH on every start and every `refreshKey` change (and `refresh()`), never cached or polled; a failed or slow read (over `readinessTimeoutMs`) or an offline browser shows nothing and asks nothing more. No HTTP: the host's `getReadiness` calls its own backend.\n */\n@Component({\n selector: 'ui-square-terminal-banner',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n // the host is `hidden` (display: none) while the banner shows nothing, so a flex / gap parent (the payment panel) leaves no empty gap\n host: { '[hidden]': '!shown()' },\n imports: [AlertComponent, ButtonComponent],\n template: `\n <div class=\"srb\" data-testid=\"reader-banner\" [attr.data-state]=\"shownState()\">\n @if (shown(); as r) {\n <ui-alert variant=\"info\" [quiet]=\"true\" data-testid=\"reader-banner-message\">\n <span class=\"srb-line\">{{ message() }}</span>\n @if (!reasonKey()) {\n <!-- a sandbox / service-off / unsupported-processor reason has no action: only the message -->\n <span class=\"srb-actions\">\n @if (r.state === 'merchant_not_ready') {\n <ui-button variant=\"link\" size=\"sm\" data-testid=\"reader-banner-setup\" (click)=\"setup.emit()\">{{ labels.t(r.reason === 'reconnect_required' ? 'stripeReader.status.reconnect' : 'stripeReader.status.setup') }}</ui-button>\n } @else if (notConnected()) {\n <!-- a Terminal exists but is not connected (offline, or its pairing code was not entered yet): the ONLY action is to connect it -->\n <ui-button variant=\"link\" size=\"sm\" data-testid=\"reader-banner-connect\" (click)=\"connect.emit()\">{{ labels.t('squareTerminal.status.connectYours') }}</ui-button>\n } @else {\n <!-- no Terminal yet: the ONLY action is how to get one (pairing a Terminal the seller already owns lives in the host's Terminals screen, never in this banner) -->\n <ui-button variant=\"link\" size=\"sm\" data-testid=\"reader-banner-get\" (click)=\"order.emit()\">{{ labels.t('squareTerminal.status.getInfo') }}</ui-button>\n }\n </span>\n }\n </ui-alert>\n }\n </div>\n `,\n styles: [`\n ui-square-terminal-banner { display: block; min-width: 0; }\n ui-square-terminal-banner[hidden] { display: none; }\n ui-square-terminal-banner .srb-line { margin-right: 8px; }\n ui-square-terminal-banner .srb-actions { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; }\n `],\n})\nexport class SquareTerminalBannerComponent {\n protected readonly labels = inject(UiLabelsService);\n private readonly destroyRef = inject(DestroyRef);\n\n /** The host's readiness call (`GET /v1/terminal/readiness`, through its own backend). Called FRESH every time. */\n readonly getReadiness = input<SquareTerminalGetReadinessFn | null>(null);\n /** Any value that changes when the host knows the readers changed (a reader was connected, an order was placed): every change reads the readiness again. */\n readonly refreshKey = input<unknown>(null);\n /** Kept for backward compatibility: Square sells no Terminal in the app, so the action is always \"How to get one\" (`order`, the host opens an info card) and this input changes nothing. */\n readonly hardwareShopAvailable = input(true);\n /** Kept for backward compatibility: there is no connected line any more, so it changes nothing. */\n readonly hideReady = input(false);\n /** A read slower than this shows nothing (ms). */\n readonly readinessTimeoutMs = input(4000);\n /** Managed environments where `navigator.onLine === false` is a false negative: do not treat the browser's offline flag as offline (default false). */\n readonly offlineOverride = input(false);\n /** `true` while the banner is kept but not shown (the panel hides it after a payment was taken): it asks the host nothing; shown again it reads once only if a read was asked for meanwhile. */\n readonly paused = input(false);\n\n /** \"Connect Your Terminal\" (a Terminal that is not connected): the host opens its pairing screen. */\n readonly connect = output<void>();\n /** \"Get a card reader\" / \"How to get a card reader\": the host opens its order flow or an info card. */\n readonly order = output<void>();\n /** \"Set up payments\" / \"Reconnect payments\": the host opens payment setup. */\n readonly setup = output<void>();\n /** The banner's readiness state whenever it changes (`{ state, stale, at, ready }`; `state` is `checking` when the last read failed; never `unknown`). `ui-payment-side-panel` re-emits it as `(readerState)`. */\n readonly stateChange = output<PaymentReaderState>();\n\n private readonly confirmed = signal<{ readiness: SquareTerminalReadiness; at: Date } | null>(null);\n private readonly failed = signal(false);\n private readonly offline = signal(false);\n private run = 0;\n private destroyed = false;\n private readWhenShown = false;\n\n /** The answer on screen: only a CONFIRMED, latest answer in which the organization has no usable reader. */\n protected readonly shown = computed((): SquareTerminalReadiness | null => {\n const c = this.confirmed();\n return c && !this.failed() && !this.offline() && SQUARE_TERMINAL_BANNER_STATES.includes(c.readiness.state) ? c.readiness : null;\n });\n readonly shownState = computed(() => this.shown()?.state ?? 'none');\n /** A Terminal exists but is not connected (`reader_offline`, `reader_pairing`). */\n protected readonly notConnected = computed(() => SQUARE_TERMINAL_NOT_CONNECTED_STATES.includes(this.shown()?.state as SquareTerminalReadiness['state']));\n /** The label key of a reason with its own no-button wording (`sandbox`, `service_disabled`, `processor_unsupported`), else null. Never for a not-connected Terminal (its message is about the Terminal). */\n protected readonly reasonKey = computed(() => (this.notConnected() ? null : readerBannerReasonKey(this.shown()?.reason)));\n protected readonly message = computed(() => this.labels.t(this.reasonKey() ?? (this.notConnected() ? 'squareTerminal.banner.notConnected' : this.shown()?.state === 'merchant_not_ready' ? 'squareTerminal.banner.setupFirst' : 'squareTerminal.banner.getReader')));\n\n constructor() {\n this.destroyRef.onDestroy(() => { this.destroyed = true; });\n const syncOffline = (): void => { this.offline.set(builtInReadinessReasons(this.offlineOverride()).includes('offline')); };\n if (typeof window !== 'undefined') {\n const update = (): void => { syncOffline(); untracked(() => { if (!this.offline()) void this.refresh(); }); };\n window.addEventListener('online', update);\n window.addEventListener('offline', update);\n this.destroyRef.onDestroy(() => { window.removeEventListener('online', update); window.removeEventListener('offline', update); });\n }\n effect(() => {\n const read = this.getReadiness();\n this.refreshKey();\n this.offlineOverride();\n untracked(() => { syncOffline(); if (read) void this.refresh(); });\n });\n effect(() => {\n const paused = this.paused();\n untracked(() => { if (!paused && this.readWhenShown) { this.readWhenShown = false; void this.refresh(); } });\n });\n effect(() => {\n const c = this.confirmed();\n const failed = this.failed();\n const next: PaymentReaderState | null = c && !failed ? { state: c.readiness.state, stale: false, at: c.at, ready: c.readiness.state === 'reader_ready' } : failed ? { state: 'checking', stale: true, at: null, ready: false } : null;\n untracked(() => { if (next) this.stateChange.emit(next); });\n });\n }\n\n /** Reads the readiness NOW. Never cached. A failed, slow or `checking` answer shows nothing; offline asks nothing. */\n async refresh(): Promise<void> {\n const read = this.getReadiness();\n if (!read || this.destroyed || this.offline()) return;\n if (untracked(() => this.paused())) { this.readWhenShown = true; return; }\n const run = ++this.run;\n let result: SquareTerminalReadiness | null = null;\n let timer: ReturnType<typeof setTimeout> | null = null;\n try {\n const timeout = new Promise<'timeout'>(resolve => { timer = setTimeout(() => resolve('timeout'), Math.max(1, this.readinessTimeoutMs())); });\n const raw = await Promise.race([callHost(() => read()), timeout]);\n result = raw === 'timeout' ? null : normalizeReadiness(raw);\n } catch { result = null; } finally { if (timer) clearTimeout(timer); }\n if (this.destroyed || run !== this.run) return;\n if (result && result.state !== 'checking') {\n const at = result.checkedAt ? new Date(result.checkedAt) : new Date();\n this.confirmed.set({ readiness: result, at: Number.isNaN(at.getTime()) ? new Date() : at });\n this.failed.set(false);\n } else {\n this.failed.set(true);\n }\n }\n}\n","import { ChangeDetectionStrategy, Component, TemplateRef, forwardRef, input, output, viewChild, computed, signal } from '@angular/core';\nimport { callHost, PAYMENT_METHOD_PLUGIN, PAYMENT_READINESS_EVERY_MS, PAYMENT_READINESS_TIMEOUT_MS, PAYMENT_REQUEST_TIMEOUT_MS, PAYMENT_STATUS_CHECK_TIMEOUT_MS, PAYMENT_STATUS_FAIL_GRACE_MS, PAYMENT_AUTH_TIMEOUT_MS, PAYMENT_STATUS_POLL_MAX_MS, PAYMENT_STATUS_POLL_MS, PaymentMethodPlugin, type PaymentPendingCheckInfo, type PaymentPendingCheckResult, type CheckPaymentStatusFn, type PaymentAttemptControls, type HostResult, type PaymentMethodBodyContext, type PaymentPluginMethod, type ReadinessCheckFn } from '@forgeroute/ui/payments';\nimport type { SquareBillingContact } from '../square-loader/square-types';\nimport type { SquareCardStyle } from '../square-payment/square-style';\nimport { PaymentSquareBodyComponent } from './payment-square-body.component';\nimport { SquareTerminalBannerComponent } from '../square-terminal/square-terminal-banner.component';\nimport { SQUARE_TERMINAL_LOST_ANSWER_GRACE_MS } from '../square-terminal/square-terminal.flow';\nimport { paymentBaseAmount, readerErrorInfo, type SquareTerminalConfig, type SquareTerminalLeftPending, type SquareTerminalPayment } from '../square-terminal/square-terminal.models';\nimport { SQUARE_PAYMENT_METHOD_VALUES, SQUARE_METHOD_TEXTS, squareMethodLabel, type SquareFeeContext, type SquareFees, type SquarePaymentContext, type SquarePaymentResult } from './payment-square-method.models';\n\n/**\n * Adds LIVE Card and ACH (Square) to `ui-payment-side-panel`. Put it inside the panel only for customers who use Square: its presence replaces the record-only\n * Card / ACH (last 4 digits) with the Square card form / bank authorization; remove it and the panel is record-only again.\n *\n * <ui-payment-side-panel ...>\n * @if (squareEnabled()) {\n * <ui-square-payment-method [applicationId]=\"app\" [locationId]=\"loc\" environment=\"production\" [createPayment]=\"createPayment\" />\n * }\n * </ui-payment-side-panel>\n *\n * The host owns the HTTP: `createPayment(ctx)` receives the single-use token (and the entered amount, date, notes, allocation) and answers the payment result\n * (`{ status, fees... }`). Outcomes arrive as the panel's `outcome` events with kind `'plugin'` and codes `paid`, `processing` and `failed`.\n */\n@Component({\n selector: 'ui-square-payment-method',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [PaymentSquareBodyComponent],\n providers: [{ provide: PAYMENT_METHOD_PLUGIN, useExisting: forwardRef(() => SquarePaymentMethodComponent) }],\n host: { style: 'display: none' },\n template: `<ng-template #body let-ctx><ui-payment-square-body [ctx]=\"ctx\" [config]=\"self\" /></ng-template>`,\n})\nexport class SquarePaymentMethodComponent extends PaymentMethodPlugin {\n protected readonly self = this;\n /** Creates the payment on the host's backend from the token (called when the payer presses Pay, after Square tokenized). */\n readonly createPayment = input<((ctx: SquarePaymentContext) => HostResult<SquarePaymentResult>) | null>(null);\n /** Optional fee preview before paying (display only). */\n readonly estimateFees = input<((ctx: SquareFeeContext) => HostResult<SquareFees>) | null>(null);\n readonly applicationId = input<string | null>(null);\n readonly locationId = input<string | null>(null);\n readonly environment = input<'production' | 'sandbox' | null>(null);\n /** The buyer's billing contact: with it the card form runs buyer verification (SCA / 3-D Secure) before the token reaches your backend. */\n readonly billingContact = input<SquareBillingContact | null>(null);\n /** The account holder name offered for the bank account. */\n readonly accountHolderName = input('');\n /** ACH: the authorization checkbox must be ticked before the bank window opens. */\n readonly requireAchConsent = input(true);\n readonly cardStyle = input<SquareCardStyle | null>(null);\n /** The methods this plugin takes over (default: Card and ACH / Bank Transfer). Pass `[{ value: 'CARD', label: 'Card' }]` for cards only. */\n readonly methodListInput = input<readonly PaymentPluginMethod[] | null>(null, { alias: 'methodList' });\n readonly methodList = computed((): readonly PaymentPluginMethod[] => this.methodListInput() ?? SQUARE_PAYMENT_METHOD_VALUES.map(value => ({ value, label: squareMethodLabel(value) })));\n /** How long a fee estimate may take before Pay is released and \"Try again\" is offered (ms). */\n readonly estimateTimeoutMs = input(10000);\n // ── Duplicate-payment protection and readiness gate (docs: \"Duplicate-payment protection\", \"Readiness gate\") ──\n /**\n * The payable this is for (an invoice, a balance, a payment link). While an attempt is undecided its opaque marker (key, amount, method) is stored under it in `localStorage`, so a RELOAD or a\n * SECOND TAB of the same payable starts locked (unknown) with the same attempt key. Without it the protection covers this page instance only. Nothing else is stored.\n */\n readonly payableRef = input<string | null>(null);\n /** A key the host supplies for the charge; empty = the plugin generates one per payment attempt session (it arrives in `createPayment(ctx).attemptKey`). */\n readonly attemptKey = input<string | null>(null);\n /** The host's status check by attempt key: resolves an UNKNOWN outcome (timeout, offline mid-flight). */\n readonly checkStatus = input<CheckPaymentStatusFn | null>(null);\n /** The payable is paid (host re-render, back navigation): Pay stays locked for good. */\n readonly paid = input(false);\n /** The host reports an ambiguous result of ITS charge call: the plugin goes to \"Checking your payment...\" while true. */\n readonly hostPending = input(false);\n readonly statusPollMs = input(PAYMENT_STATUS_POLL_MS);\n readonly statusPollMaxMs = input(PAYMENT_STATUS_POLL_MAX_MS);\n /** A status check slower than this counts as unknown (ms). */\n readonly statusCheckTimeoutMs = input(PAYMENT_STATUS_CHECK_TIMEOUT_MS);\n /** While the attempt's own request is unsettled, a status answer `failed` is ignored for this long (ms). */\n readonly statusFailGraceMs = input(PAYMENT_STATUS_FAIL_GRACE_MS);\n /** Offer \"Start over\" after the status polling window (a new attempt with a NEW key). Turn it on ONLY when your backend allows ONE open or succeeded attempt per payable and answers 409 `payment_in_flight` to a second key: that rule is what makes it safe. */\n readonly allowStartOver = input(false);\n /** Managed environments where `navigator.onLine === false` is a false negative (captive portal, VPN): do not refuse a payment because of the browser's offline flag (default false). */\n readonly offlineOverride = input(false);\n /** The request timeout is replaced by this while a 3-D Secure challenge or the bank window is open (ms). */\n readonly authTimeoutMs = input(PAYMENT_AUTH_TIMEOUT_MS);\n /** How long ONE `createPayment` (tokenize + charge) may take before the outcome counts as unknown (ms). */\n readonly paymentTimeoutMs = input(PAYMENT_REQUEST_TIMEOUT_MS);\n /** The host's readiness endpoint (`GET /api/payments/ready`): `{ ready, reasons[] }`. */\n readonly readinessCheck = input<ReadinessCheckFn | null>(null);\n readonly readinessTimeoutMs = input(PAYMENT_READINESS_TIMEOUT_MS);\n readonly readinessEveryMs = input(PAYMENT_READINESS_EVERY_MS);\n /** The payer covers fees: a rejected or empty estimate keeps Pay off (with \"Try again\") instead of paying without the fee preview. */\n readonly feesRequired = input(false);\n readonly receiptNoteInput = input<string | null>(null, { alias: 'receiptNote' });\n readonly receiptNote = computed((): string => this.receiptNoteInput() ?? SQUARE_METHOD_TEXTS.receiptNote);\n\n // ── Square Terminal (card reader) mode (opt-in: with no `[reader]` nothing changes) ──\n /**\n * The Square Terminal calls. With it, the method Card gets a choice \"Card reader | Enter card manually\" above the form and the Terminal is the default as soon as the first readiness answer says `reader_ready` (`[readerFirst]`);\n * otherwise manual stays the default and the panel's one reader banner explains why. Switching away while a Terminal payment waits first cancels it through `reader.cancelPayment`. See docs/card-readers.md.\n */\n readonly reader = input<SquareTerminalConfig | null>(null);\n /** The Terminal is the default when it is ready (default true). */\n readonly readerFirst = input(true);\n /** \"Connect Your Terminal\" (banner, a Terminal that is not connected): the host opens its pairing screen (`ui-square-terminal-pairing`). */\n readonly readerConnect = output<void>();\n /** \"Get a Square Terminal\" / \"How to get one\": the host opens its order flow or an info card. */\n readonly readerOrder = output<void>();\n /** \"Set up payments\". */\n readonly readerSetup = output<void>();\n /** How often (ms) the waiting payment's status is read (default 2000; clamped to 500..30 000). Wins over `reader.pollMs`. */\n readonly readerPollMs = input<number | null>(null);\n /** `true` while a Terminal payment is open; emitted only on change. NEVER sent as `false` for a payment that may still exist at the processor (see `readerLeftPending`). */\n readonly readerBusyChange = output<boolean>();\n /** The body went away or the reader screen was removed while a Terminal payment was open: the payment MAY STILL EXIST. */\n readonly readerLeftPending = output<SquareTerminalLeftPending>();\n /** While `true` Pay, \"Send to the Terminal\" and the Reader | Manual choice do nothing (a payment already open keeps Cancel); `blockedReason` is shown as a status message. Inside `ui-payment-side-panel` use the panel's own `[blocked]`. */\n readonly blocked = input(false);\n readonly blockedReason = input('');\n\n private readonly body = viewChild<TemplateRef<PaymentMethodBodyContext>>('body');\n\n // ── The host resolves an undecided attempt itself (without a status check): the body registers its controls here ──\n private readonly controls = signal<PaymentAttemptControls | null>(null);\n /** @internal The body registers itself. */\n attachControls(controls: PaymentAttemptControls): void { this.controls.set(controls); }\n /** @internal The body leaves. */\n detachControls(controls: PaymentAttemptControls): void { if (this.controls() === controls) this.controls.set(null); }\n /** The host's charge of this payment is ambiguous (its call timed out): the plugin shows \"Checking your payment...\" and stays locked (see `checkStatus`). */\n markUnknown(): void { this.controls()?.markUnknown(); }\n /** The host's charge succeeded: the plugin records it (paid + complete) and locks the payable. */\n markSucceeded(): void { this.controls()?.markSucceeded(); }\n /** The host's charge was DEFINITIVELY refused: the plugin unlocks with a NEW attempt key. */\n markFailed(): void { this.controls()?.markFailed(); }\n /** NOTHING was sent to the processor: the plugin unlocks and the attempt key is KEPT (the backend must still answer the state of an attempt it already holds for that key). */\n markNotCharged(): void { this.controls()?.markNotCharged(); }\n /** The host starts a deliberate SECOND payment of this payable (an explicit \"pay again\" flow): forgets the paid state this form saw, removes the succeeded record and moves the epoch so the next attempt has a NEW key. Does nothing against the host's own `paid` input. */\n resetPaid(): void { this.controls()?.resetPaid(); }\n\n\n /** The attempt this plugin last started (a Terminal payment or a manual card confirmation), kept here because the body is gone when the panel closes: what the panel's \"Check again\" reads. */\n private remembered: { key: string; kind: 'reader' | 'manual'; amount?: number } | null = null;\n /** @internal The body names the attempt it just started. */\n rememberAttempt(key: string | undefined, kind: 'reader' | 'manual', amount?: number): void { if (key) this.remembered = { key, kind, ...(amount !== undefined ? { amount } : {}) }; }\n\n /**\n * The truth of the payment the panel is holding, read by ATTEMPT KEY. A Terminal payment is read with `reader.getPayment`, a manual card with `checkStatus`. `over` only when the answer proves nothing is open (\"never seen\" only once the\n * hold is older than the processing window); `succeeded` when paid; `open` while it runs; `checking` when it cannot be told.\n */\n override async checkPending(info: PaymentPendingCheckInfo): Promise<PaymentPendingCheckResult> {\n const key = info.paymentAttemptKey ?? this.remembered?.key;\n if (!key) return { state: 'checking' };\n const known = this.remembered && this.remembered.key === key ? this.remembered : null;\n const kind = known?.kind ?? (this.reader() ? 'reader' : 'manual');\n if (kind === 'reader') {\n const reader = this.reader();\n if (!reader) return { state: 'checking' };\n let payment: SquareTerminalPayment | null = null;\n try { payment = (await callHost(() => reader.getPayment({ paymentId: null, attemptKey: key }))) ?? null; } catch (error) {\n if (readerErrorInfo(error).status !== 404) return { state: 'checking' };\n payment = null;\n }\n if (!payment || typeof payment !== 'object' || typeof payment.id !== 'string') return { state: info.ageMs >= SQUARE_TERMINAL_LOST_ANSWER_GRACE_MS ? 'over' : 'checking' };\n const status = String(payment.status ?? '').toUpperCase();\n const terminal = payment.terminal?.state;\n if (status === 'SUCCEEDED' || terminal === 'succeeded') {\n const amount = paymentBaseAmount(payment) ?? known?.amount;\n return { state: 'succeeded', result: { type: 'stripe', paymentMethod: info.method, processor: 'square', ...(amount !== undefined && amount !== null ? { amount } : {}) } };\n }\n if (status === 'CANCELED' || status === 'FAILED' || terminal === 'canceled') return { state: 'over' };\n return { state: 'open' };\n }\n const check = this.checkStatus();\n if (!check) return { state: 'checking' };\n let answer: string;\n try { answer = String(await callHost(() => check(key))); } catch { return { state: 'checking' }; }\n switch (answer) {\n case 'succeeded': return { state: 'succeeded', result: { type: 'stripe', paymentMethod: info.method, processor: 'square', ...(known?.amount !== undefined ? { amount: known.amount } : {}) } };\n case 'failed': return { state: 'over' };\n case 'not_found': return { state: info.ageMs >= this.paymentTimeoutMs() + this.statusFailGraceMs() ? 'over' : 'checking' };\n case 'in_flight':\n case 'awaiting_verification': return { state: 'open' };\n default: return { state: 'checking' };\n }\n }\n\n readonly methods = this.methodList;\n readonly template = this.body;\n /** The Square Terminal banner the panel's `[readerBanner]` renders: rendering this plugin in the panel is all a host needs for it (the host gives the panel `[readerBanner]=\"{ getReadiness }\"`, or `squareTerminalBannerConfig({ getReadiness })`). */\n override readonly readerBannerComponent = SquareTerminalBannerComponent;\n}\n","import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, Injector, ViewEncapsulation, afterNextRender, computed, effect, inject, input, output, signal, untracked, viewChildren } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { AlertComponent } from '@forgeroute/ui/alert';\nimport { ButtonComponent, UiFieldValidity, UiLabelsService } from '@forgeroute/ui/core';\nimport { LiveRegionComponent } from '@forgeroute/ui/live-region';\nimport { TextInputComponent } from '@forgeroute/ui/text-input';\nimport { callHost, type HostResult } from '@forgeroute/ui/payments';\nimport { SQUARE_TERMINAL_REQUEST_TIMEOUT_MS } from './square-terminal.flow';\nimport {\n formatElapsed, isSquareTerminal, normalizeReadiness, readerDisplayName, safePairingCode,\n type SquareTerminalRegisterFn, type SquareTerminal, type SquareTerminalGetReadinessFn,\n} from './square-terminal.models';\n\n/** The fastest and the slowest poll of the pairing wait (ms). */\nexport const SQUARE_PAIRING_POLL_MIN_MS = 1000;\nexport const SQUARE_PAIRING_POLL_MAX_MS = 30_000;\n/** Square device codes expire after 5 minutes; the wait never lasts longer than the host's `timeoutMs` (clamped to this range). */\nexport const SQUARE_PAIRING_TIMEOUT_MIN_MS = 10_000;\nexport const SQUARE_PAIRING_TIMEOUT_MAX_MS = 900_000;\n\n/** A pairing poll cadence the library will actually use: not a finite number > 0 = 3000 ms; otherwise rounded and clamped to 1000..30 000 ms. */\nexport function clampPairingPollMs(value: number | null | undefined): number {\n if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0) return 3000;\n return Math.min(SQUARE_PAIRING_POLL_MAX_MS, Math.max(SQUARE_PAIRING_POLL_MIN_MS, Math.round(value)));\n}\n\n/** A pairing wait the library will actually use: not a finite number > 0 = 300 000 ms (5 minutes); otherwise rounded and clamped to 10 000..900 000 ms. */\nexport function clampPairingTimeoutMs(value: number | null | undefined): number {\n if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0) return 300_000;\n return Math.min(SQUARE_PAIRING_TIMEOUT_MAX_MS, Math.max(SQUARE_PAIRING_TIMEOUT_MIN_MS, Math.round(value)));\n}\n\n/**\n * The reader the pairing is waiting for, found in the readers of a readiness read, or `null` while the Terminal has not connected yet:\n * - the registered reader is still listed (same id): paired when it no longer carries a `pairingCode` and its status is `online`;\n * - the registered id is gone from the list (the device code became the device): paired when exactly ONE Square Terminal with the same name is online without a `pairingCode`.\n * Nothing else counts (never a guess between two Terminals).\n */\nexport function findPairedTerminal(readers: readonly SquareTerminal[], registered: Pick<SquareTerminal, 'id' | 'label'>): SquareTerminal | null {\n const same = readers.find(r => r.id === registered.id);\n if (same) return !same.pairingCode && same.status === 'online' ? same : null;\n const name = (registered.label ?? '').trim().toLowerCase();\n const matches = readers.filter(r => isSquareTerminal(r) && !r.pairingCode && r.status === 'online' && (r.label ?? '').trim().toLowerCase() === name);\n return name && matches.length === 1 ? matches[0] : null;\n}\n\n/** What `(outcome)` reports (the component never toasts: the host words a toast if it wants one). */\nexport type SquareTerminalPairingOutcome =\n | { kind: 'code'; reader: SquareTerminal }\n | { kind: 'paired'; reader: SquareTerminal }\n | { kind: 'timeout' }\n | { kind: 'canceled' }\n | { kind: 'failed' };\n\ntype Phase = 'form' | 'registering' | 'waiting' | 'paired' | 'timeout';\n\n/**\n * \"Connect a Square Terminal\" (a Square Terminal has no connection token and no SDK: it is paired with a DEVICE CODE). The flow, with every call a HOST function (the browser never talks to the payments service):\n *\n * 1. staff name the Terminal and press \"Get a pairing code\": `registerTerminal({ label, locationId? })` (the host calls `POST /v1/terminal/readers`; the answer is the reader with its `pairingCode`);\n * 2. the code is shown with plain instructions (\"On the Terminal choose Sign in > Use a device code and enter <code>\") and announced politely;\n * 3. the component reads the readiness (`getReadiness`) every `pollMs` until that reader is paired (see {@link findPairedTerminal}): `(paired)` carries it, \"Terminal <name> connected.\" is shown;\n * 4. the wait is BOUNDED (`timeoutMs`, default 5 minutes, the life of a Square device code) and cancellable: at the end \"The code was not used in time\" with \"Get a new code\". A failed or slow poll never ends the wait by itself.\n *\n * A Square Terminal can only be renamed or removed in the Square dashboard (the screen says so): there is no rename / remove here. The reader list of the screen is the host's own (or the payment screen's reader choice).\n *\n * <ui-square-terminal-pairing [registerTerminal]=\"register\" [getReadiness]=\"readiness\" locationId=\"L123\" (paired)=\"onPaired($event)\" (canceled)=\"close()\" />\n */\n@Component({\n selector: 'ui-square-terminal-pairing',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n imports: [FormsModule, AlertComponent, ButtonComponent, LiveRegionComponent, TextInputComponent],\n template: `\n <ui-live-region data-testid=\"square-pairing-live\" [message]=\"announcement()\" />\n <section class=\"stp\" [attr.aria-labelledby]=\"ids + '-title'\" data-testid=\"square-pairing\" [attr.data-phase]=\"phase()\">\n <h3 class=\"stp-h\" [id]=\"ids + '-title'\">{{ labels.t('squareTerminal.pairing.title') }}</h3>\n @switch (phase()) {\n @case ('waiting') {\n <div class=\"stp-wait\" data-testid=\"square-pairing-waiting\" tabindex=\"-1\">\n <p class=\"stp-muted\">{{ labels.t('squareTerminal.pairing.code.label') }}</p>\n <strong class=\"stp-code\" data-testid=\"square-pairing-code\">{{ code() }}</strong>\n <p class=\"stp-text\" data-testid=\"square-pairing-steps\">{{ labels.t('squareTerminal.pairing.steps', { code: code() }) }}</p>\n <p class=\"stp-muted\" data-testid=\"square-pairing-countdown\">{{ labels.t('squareTerminal.pairing.waiting', { time: remainingText() }) }}</p>\n <div class=\"stp-actions\">\n <ui-button variant=\"secondary\" data-testid=\"square-pairing-cancel\" (click)=\"cancel()\">{{ labels.t('common.cancel') }}</ui-button>\n </div>\n </div>\n }\n @case ('paired') {\n <ui-alert variant=\"success\" [quiet]=\"true\" data-testid=\"square-pairing-paired\" tabindex=\"-1\" class=\"stp-focus\">{{ labels.t('squareTerminal.pairing.paired', { name: pairedName() }) }}</ui-alert>\n }\n @case ('timeout') {\n <ui-alert variant=\"warning\" [title]=\"labels.t('squareTerminal.pairing.timeout.title')\" data-testid=\"square-pairing-timeout\" tabindex=\"-1\" class=\"stp-focus\">\n <p class=\"stp-text\">{{ labels.t('squareTerminal.pairing.timeout.text') }}</p>\n <div class=\"stp-actions\">\n <ui-button variant=\"primary\" data-testid=\"square-pairing-new-code\" (click)=\"getCode()\">{{ labels.t('squareTerminal.pairing.newCode') }}</ui-button>\n <ui-button variant=\"secondary\" data-testid=\"square-pairing-cancel\" (click)=\"cancel()\">{{ labels.t('common.cancel') }}</ui-button>\n </div>\n </ui-alert>\n }\n @default {\n <p class=\"stp-text\" data-testid=\"square-pairing-intro\">{{ labels.t('squareTerminal.pairing.intro') }}</p>\n @if (error()) { <ui-alert variant=\"danger\" [quiet]=\"true\" data-testid=\"square-pairing-error\">{{ error() }}</ui-alert> }\n <ui-text-input [label]=\"labels.t('squareTerminal.pairing.name.label')\" [hint]=\"labels.t('squareTerminal.pairing.name.hint')\" [required]=\"true\" [maxlength]=\"100\"\n [ngModel]=\"label()\" (ngModelChange)=\"label.set($event ?? '')\" [showErrors]=\"touched()\" [disabled]=\"phase() === 'registering'\" inputTestId=\"square-pairing-name\" />\n <div class=\"stp-actions\">\n <ui-button variant=\"primary\" data-testid=\"square-pairing-start\" [loading]=\"phase() === 'registering'\" [disabled]=\"phase() === 'registering' || (touched() && hasInvalid())\" (click)=\"getCode()\">{{ labels.t(phase() === 'registering' ? 'squareTerminal.pairing.starting' : 'squareTerminal.pairing.start') }}</ui-button>\n </div>\n }\n }\n </section>\n `,\n styles: [`\n ui-square-terminal-pairing { display: block; min-width: 0; }\n ui-square-terminal-pairing .stp { display: flex; flex-direction: column; gap: 12px; min-width: 0; }\n ui-square-terminal-pairing .stp-h { margin: 0; font-size: 0.9375rem; font-weight: 700; color: var(--ui-psp-text, #1e293b); }\n ui-square-terminal-pairing .stp-text { margin: 0; font-size: 0.9375rem; color: var(--ui-psp-text, #1e293b); }\n ui-square-terminal-pairing .stp-muted { margin: 0; font-size: 0.8125rem; color: var(--ui-psp-muted, #475569); font-variant-numeric: tabular-nums; }\n ui-square-terminal-pairing .stp-wait { display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 2px solid var(--ui-psp-border, #cbd5e1); border-radius: 12px; background: var(--ui-psp-sunken, #f8fafc); }\n ui-square-terminal-pairing .stp-wait:focus, ui-square-terminal-pairing .stp-focus:focus { outline: none; }\n ui-square-terminal-pairing .stp-code { font-size: 1.75rem; line-height: 1.2; letter-spacing: 0.18em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; color: var(--ui-psp-text, #1e293b); }\n ui-square-terminal-pairing .stp-actions { display: flex; flex-wrap: wrap; gap: 8px; }\n @media (forced-colors: active) { ui-square-terminal-pairing .stp-wait { border-color: CanvasText; } }\n `],\n})\nexport class SquareTerminalPairingComponent {\n protected readonly labels = inject(UiLabelsService);\n private readonly destroyRef = inject(DestroyRef);\n private readonly injector = inject(Injector);\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private static seq = 0;\n /** Unique per instance: two screens on one page never share an id. */\n protected readonly ids = `stp-${++SquareTerminalPairingComponent.seq}`;\n\n /** Registers the Terminal (`POST /v1/terminal/readers`): answers the reader with its `pairingCode` (the device code). */\n readonly registerTerminal = input<SquareTerminalRegisterFn | null>(null);\n /** Reads `GET /v1/terminal/readiness` through the host; polled while the code waits. */\n readonly getReadiness = input<SquareTerminalGetReadinessFn | null>(null);\n /** The Square location the Terminal belongs to, when the host's backend does not choose it itself (sent as `locationId`). */\n readonly locationId = input<string | null>(null);\n /** The name the field starts with. */\n readonly defaultLabel = input('');\n /** How often the readiness is read while waiting (ms; default 3000; clamped to 1000..30 000). */\n readonly pollMs = input(3000);\n /** How long the code is waited for (ms; default 300 000 = 5 minutes, the life of a Square device code; clamped to 10 000..900 000). */\n readonly timeoutMs = input(300_000);\n /** A host call (register, read) slower than this is unreachable (ms). */\n readonly requestTimeoutMs = input(SQUARE_TERMINAL_REQUEST_TIMEOUT_MS);\n\n /** The Terminal connected: the host refreshes its readers (the payment screen then offers it). */\n readonly paired = output<SquareTerminal>();\n /** The user left the pairing (Cancel). The device code is left to expire at Square. */\n readonly canceled = output<void>();\n readonly outcome = output<SquareTerminalPairingOutcome>();\n\n protected readonly phase = signal<Phase>('form');\n protected readonly label = signal('');\n protected readonly touched = signal(false);\n protected readonly error = signal('');\n protected readonly code = signal('');\n protected readonly announcement = signal('');\n protected readonly pairedName = signal('');\n private readonly now = signal(Date.now());\n private deadline = 0;\n private registered: Pick<SquareTerminal, 'id' | 'label'> | null = null;\n private pollTimer: ReturnType<typeof setTimeout> | null = null;\n private tickTimer: ReturnType<typeof setInterval> | null = null;\n private busyRead = false;\n private run = 0;\n private destroyed = false;\n\n private readonly fields = viewChildren(UiFieldValidity);\n protected readonly hasInvalid = computed(() => this.fields().some(f => f.invalid()) || !this.label().trim());\n protected readonly remainingText = computed(() => formatElapsed(Math.max(0, this.deadline - this.now())));\n\n constructor() {\n effect(() => { const start = this.defaultLabel(); untracked(() => { if (!this.label()) this.label.set(start); }); });\n this.destroyRef.onDestroy(() => { this.destroyed = true; this.stopTimers(); });\n }\n\n private stopTimers(): void {\n if (this.pollTimer) { clearTimeout(this.pollTimer); this.pollTimer = null; }\n if (this.tickTimer) { clearInterval(this.tickTimer); this.tickTimer = null; }\n }\n\n private async call<T>(thunk: () => HostResult<T>): Promise<T> {\n let timer: ReturnType<typeof setTimeout> | null = null;\n try {\n const timeout = new Promise<never>((_, reject) => { timer = setTimeout(() => reject(Object.assign(new Error('request timeout'), { code: 'request_timeout' })), Math.max(1, this.requestTimeoutMs())); });\n return await Promise.race([callHost(thunk), timeout]);\n } finally { if (timer) clearTimeout(timer); }\n }\n\n private focus(testId: string): void {\n afterNextRender(() => this.host.nativeElement.querySelector<HTMLElement>(`[data-testid=\"${testId}\"]`)?.focus(), { injector: this.injector });\n }\n\n /** \"Get a pairing code\" / \"Get a new code\": registers the Terminal and starts the bounded wait. A second click while a registration runs does nothing. */\n async getCode(): Promise<void> {\n const register = this.registerTerminal();\n if (!register || this.phase() === 'registering' || this.phase() === 'waiting') return;\n this.touched.set(true);\n if (this.hasInvalid()) return;\n const label = this.label().trim();\n const location = this.locationId();\n const run = ++this.run;\n this.stopTimers();\n this.error.set('');\n this.phase.set('registering');\n try {\n const reader = await this.call(() => register({ label, ...(location ? { locationId: location } : {}) }));\n if (this.destroyed || run !== this.run) return;\n const code = safePairingCode(reader?.pairingCode) ?? '';\n if (!reader || typeof reader.id !== 'string' || !code) throw Object.assign(new Error('no pairing code'), { code: 'no_pairing_code' });\n this.registered = { id: reader.id, label: reader.label ?? label };\n this.code.set(code);\n this.touched.set(false);\n this.deadline = Date.now() + clampPairingTimeoutMs(this.timeoutMs());\n this.now.set(Date.now());\n this.phase.set('waiting');\n this.announcement.set(this.labels.t('squareTerminal.pairing.live', { code: code.split('').join(' ') }));\n this.outcome.emit({ kind: 'code', reader });\n this.focus('square-pairing-waiting');\n this.tickTimer = setInterval(() => this.tick(run), 1000);\n this.schedulePoll(run);\n } catch {\n if (this.destroyed || run !== this.run) return;\n this.phase.set('form');\n const text = this.labels.t('squareTerminal.pairing.failed');\n this.error.set(text);\n this.announcement.set(text);\n this.outcome.emit({ kind: 'failed' });\n }\n }\n\n private schedulePoll(run: number): void {\n if (this.pollTimer) clearTimeout(this.pollTimer);\n this.pollTimer = setTimeout(() => { this.pollTimer = null; void this.poll(run); }, clampPairingPollMs(this.pollMs()));\n }\n\n private tick(run: number): void {\n if (this.destroyed || run !== this.run || this.phase() !== 'waiting') return;\n this.now.set(Date.now());\n if (Date.now() >= this.deadline) void this.poll(run, true);\n }\n\n /** One read of the readiness: paired -> done; not paired -> keep waiting (or, at the end of the wait, \"The code was not used in time\"). A failed or slow read changes nothing. */\n private async poll(run: number, final = false): Promise<void> {\n const read = this.getReadiness();\n const registered = this.registered;\n if (this.destroyed || run !== this.run || this.phase() !== 'waiting' || !registered) return;\n if (this.busyRead) { if (!final) this.schedulePoll(run); return; }\n this.busyRead = true;\n let found: SquareTerminal | null = null;\n try {\n if (read) { const readiness = normalizeReadiness(await this.call(() => read())); found = findPairedTerminal(readiness.readers, registered); }\n } catch { found = null; } finally { this.busyRead = false; }\n if (this.destroyed || run !== this.run || this.phase() !== 'waiting') return;\n if (found) {\n this.stopTimers();\n this.pairedName.set(readerDisplayName(found));\n this.phase.set('paired');\n this.announcement.set(this.labels.t('squareTerminal.pairing.paired', { name: this.pairedName() }));\n this.outcome.emit({ kind: 'paired', reader: found });\n this.paired.emit(found);\n this.focus('square-pairing-paired');\n return;\n }\n if (final || Date.now() >= this.deadline) {\n this.stopTimers();\n this.phase.set('timeout');\n this.announcement.set(`${this.labels.t('squareTerminal.pairing.timeout.title')}. ${this.labels.t('squareTerminal.pairing.timeout.text')}`);\n this.outcome.emit({ kind: 'timeout' });\n this.focus('square-pairing-timeout');\n return;\n }\n this.schedulePoll(run);\n }\n\n /** Cancel: the wait ends, the device code is left to expire at Square, the host closes the screen. */\n cancel(): void {\n this.run++;\n this.stopTimers();\n this.busyRead = false;\n this.registered = null;\n this.code.set('');\n this.phase.set('form');\n this.outcome.emit({ kind: 'canceled' });\n this.canceled.emit();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAa,iBAAiB;AAC9B,MAAa,yBAAyB;AAMtC,MAAa,yBAAyB;AAKtC,SAAgB,kBAAqB,MAAsB,WAAsB;CAC/E,OAAO,IAAI,SAAY,SAAS,WAAU;EACxC,MAAM,QAAQ,iBAAiB,OAAO,UAAS,CAAE,GAAG,sBAAsB;EAC1E,QAAQ,QAAQ,IAAI,CAAC,CAAC,MAAK,UAAQ;GAAG,aAAa,KAAK;GAAG,QAAQ,KAAK;EAAG,IAAG,UAAQ;GAAG,aAAa,KAAK;GAAG,OAAO,KAAK;EAAG,CAAC;CAChI,CAAC;AACH;AAGA,MAAM,kBAAkB;AAGxB,IAAa,kBAAb,cAAqC,MAAK;CACxC,YAAqB,MAAqC;EACxD,MAAM,IAAI;EADS,KAAA,OAAA;EAEnB,KAAK,OAAO;CACd;AACD;AAMD,MAAM,qBAAgD,OAAgD;AAUtG,MAAa,eAAe;CAE1B,yBAAS,IAAI,IAAG;CAEhB,QAAQ;CAER,wBAAQ,IAAI,IAAG;CACf,KAAK,KAAW;EACd,MAAM,YAAY,aAAa,WAAW,QAAQ,aAAa,WAAW;EAC1E,IAAI,aAAY,KAAM,CAAC,WAAW,OAAO,QAAQ,QAAO;EAExD,KAAK,MAAM,CAAC,OAAO,aAAa,aAAa,SAAS,IAAI,UAAU,KAAK,OAAO,SAAS,YAAY,MAAS,CAAC,CAAC,WAAW,aAAa,KAAK,GAAG,CAAC;EAEjJ,MAAM,UAAU,aAAa,QAAQ,IAAI,GAAG;EAC5C,IAAI,SAAS,OAAO;EACpB,MAAM,QAAQ,CAAA;EACd,aAAa,OAAO,IAAI,KAAK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