{"version":3,"sources":["../../src/react/index.ts","../../src/react/use-payment-fields.ts","../../src/core/browser-info.ts","../../src/core/clover-loader.ts","../../src/core/types.ts","../../src/core/element-registry.ts","../../src/core/theme.ts","../../src/core/threeds-finalize-client.ts","../../src/core/threeds-machine.ts","../../src/core/tokenize.ts","../../src/core/validation-machine.ts","../../src/core/payment-fields-machine.ts","../../src/react/PaymentFields.tsx","../../src/react/styles.ts"],"sourcesContent":["// ── @weeconnectpay/payment-fields/react ─────────────────────────\n//\n// React 18+ bindings. Two consumption modes:\n//\n// 1. Hook (`usePaymentFields`) — host owns layout. WC Blocks uses this.\n// 2. Composite (`<PaymentFields>`) — Design-5 layout baked in. Dashboard + PrestaShop use this.\n//\n// Both go through the same `PaymentFieldsMachine` under the hood, so behavior\n// (state machine, GPay prepare-and-wait, 3DS flow) is identical.\n\nexport {\n  usePaymentFields,\n  type UsePaymentFieldsOptions,\n  type UsePaymentFieldsReturn,\n} from './use-payment-fields';\n\nexport { PaymentFields, type PaymentFieldsProps } from './PaymentFields';\n\nexport { PAYMENT_FIELDS_CSS } from './styles';\n\n// Re-export the core types consumers will reach for from React land.\nexport type {\n  CloverFieldTheme,\n  HeadersProvider,\n  MountTargets,\n  PaymentFieldsConfig,\n  PaymentFieldsEndpoints,\n  PaymentFieldsError,\n  PaymentFieldsErrorCode,\n  PaymentFieldsFeatures,\n  PaymentFieldsSnapshot,\n  PaymentFieldsState,\n  SavedCredential,\n  ThreeDsInterim,\n  ThreeDsResult,\n  TokenizationResult,\n  ValidationSnapshot,\n} from '../core/index';\n","// ── usePaymentFields hook ───────────────────────────────────────\n//\n// React 18+ binding for `PaymentFieldsMachine`. Uses `useSyncExternalStore`\n// so React stays in sync with the machine's snapshot without unnecessary\n// re-renders or tearing in concurrent mode.\n//\n// Lifecycle: one machine per hook invocation. The machine is created lazily\n// on first render and destroyed on unmount. Re-configuring requires unmount\n// (e.g., key change on the parent) — the SDK does not support config swaps\n// because Clover iframes can't be re-themed after mount.\n\nimport { useCallback, useEffect, useMemo, useRef, useSyncExternalStore } from 'react';\nimport {\n  PaymentFieldsMachine,\n  type MountTargets,\n  type PaymentFieldsConfig,\n  type PaymentFieldsError,\n  type PaymentFieldsSnapshot,\n  type PaymentFieldsState,\n  type ThreeDsInterim,\n  type ThreeDsResult,\n  type TokenizationResult,\n  type ValidationSnapshot,\n} from '../core/index';\n\nexport interface UsePaymentFieldsOptions extends PaymentFieldsConfig {}\n\n/**\n * Input to `usePaymentFields`. Either a config (hook constructs the machine\n * and destroys it on unmount) or an existing machine (hook subscribes only,\n * leaves lifecycle to the caller — used by the web-component layer).\n */\nexport type UsePaymentFieldsInput = UsePaymentFieldsOptions | PaymentFieldsMachine;\n\nexport interface UsePaymentFieldsReturn {\n  // ── Flattened snapshot fields (most common reads) ──\n  readonly state: PaymentFieldsState;\n  readonly validation: ValidationSnapshot;\n  readonly result?: TokenizationResult;\n  readonly error?: PaymentFieldsError;\n  readonly threeDs?: ThreeDsInterim;\n  /** Full snapshot, for hosts that want everything at once. */\n  readonly snapshot: PaymentFieldsSnapshot;\n\n  // ── Actions (stable references) ──\n  readonly mount: (targets: MountTargets) => Promise<void>;\n  readonly tokenize: () => Promise<TokenizationResult>;\n  readonly runThreeDs: (\n    interim: ThreeDsInterim,\n    options?: { readonly extraBody?: Record<string, unknown> },\n  ) => Promise<ThreeDsResult>;\n  readonly resetToIdle: () => void;\n\n  /** Escape hatch for advanced cases (the underlying machine instance). */\n  readonly machine: PaymentFieldsMachine;\n}\n\nexport function usePaymentFields(input: UsePaymentFieldsInput): UsePaymentFieldsReturn {\n  // Lazy-init pattern: capture the machine on first render, persist across renders.\n  // In React Strict Mode the function body runs twice; the ref persists, so we\n  // only construct one machine. `ownsRef` tracks whether we should destroy it on\n  // unmount (true when we constructed it; false when the caller passed one in).\n  const machineRef = useRef<PaymentFieldsMachine | null>(null);\n  const ownsRef = useRef<boolean>(false);\n  if (machineRef.current === null) {\n    if (input instanceof PaymentFieldsMachine) {\n      machineRef.current = input;\n      ownsRef.current = false;\n    } else {\n      machineRef.current = new PaymentFieldsMachine(input);\n      ownsRef.current = true;\n    }\n  }\n  const machine = machineRef.current;\n\n  // Subscribe + getSnapshot must have stable identity for useSyncExternalStore.\n  const subscribe = useCallback(\n    (onChange: () => void) => machine.subscribe(() => onChange()),\n    [machine],\n  );\n  const getSnapshot = useCallback(() => machine.getSnapshot(), [machine]);\n  const snapshot = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n\n  // Destroy on unmount only if we own the machine. Externally-supplied machines\n  // are the caller's responsibility (web-component layer destroys in disconnectedCallback).\n  useEffect(() => {\n    return () => {\n      if (ownsRef.current) {\n        machine.destroy();\n      }\n      machineRef.current = null;\n    };\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, []);\n\n  const mount = useCallback((targets: MountTargets) => machine.mount(targets), [machine]);\n  const tokenize = useCallback(() => machine.tokenize(), [machine]);\n  const runThreeDs = useCallback(\n    (interim: ThreeDsInterim, options?: { readonly extraBody?: Record<string, unknown> }) =>\n      machine.runThreeDs(interim, options),\n    [machine],\n  );\n  const resetToIdle = useCallback(() => machine.resetToIdle(), [machine]);\n\n  return useMemo<UsePaymentFieldsReturn>(\n    () => ({\n      state: snapshot.state,\n      validation: snapshot.validation,\n      result: snapshot.result,\n      error: snapshot.error,\n      threeDs: snapshot.threeDs,\n      snapshot,\n      mount,\n      tokenize,\n      runThreeDs,\n      resetToIdle,\n      machine,\n    }),\n    [snapshot, mount, tokenize, runThreeDs, resetToIdle, machine],\n  );\n}\n","// ── 3DS browser fingerprint ─────────────────────────────────────\n//\n// Wraps `Clover3DSUtil.getBrowserInfo()`. Clover requires the EMVCo 3DS2\n// browser fingerprint on the charge request when 3DS is enabled; without it\n// the charge fails with \"Missing or invalid/incomplete browser_info for\n// 3DSecure\". We collect it at tokenization time and bundle it with the result.\n\nimport type { ThreeDSUtil, ThreeDsBrowserInfo } from './types';\n\nexport function getBrowserInfo(util: ThreeDSUtil | undefined | null): ThreeDsBrowserInfo | undefined {\n  if (!util?.getBrowserInfo) {\n    return undefined;\n  }\n  try {\n    return util.getBrowserInfo();\n  } catch (error) {\n    console.warn('[wcp-payment-fields] getBrowserInfo failed', error);\n    return undefined;\n  }\n}\n","// ── Clover SDK loaders ──────────────────────────────────────────\n//\n// Loads the Clover and Clover3DS scripts idempotently. Three cases handled:\n//\n// 1. The global is already set on `window` — common in WP, where the host\n//    enqueues the Clover SDK as a script dependency that loads BEFORE our\n//    adapter runs. Resolve immediately.\n// 2. A `<script>` tag for the URL is already in the DOM but hasn't fired its\n//    `load` event yet — poll the global until it appears (we can't attach a\n//    `load` listener after the event has already fired, which is the\n//    failure mode the v0.1 loader hit in WP).\n// 3. Neither — inject our own `<script>` tag, then poll for the global.\n//\n// Polling is intentional: it works regardless of whether the script tag was\n// injected by us or by the host, and regardless of whether `load` already\n// fired. The poll interval is short enough that there's no visible delay.\n\nimport type { Clover3DSGlobal, CloverGlobal } from './types';\n\nconst POLL_INTERVAL_MS = 50;\nconst DEFAULT_TIMEOUT_MS = 10_000;\n\nconst inFlight = new Map<string, Promise<void>>();\n\ninterface WaitOptions {\n  readonly url: string;\n  readonly globalName: string;\n  readonly timeoutMs?: number;\n}\n\nfunction waitForGlobal({ url, globalName, timeoutMs = DEFAULT_TIMEOUT_MS }: WaitOptions): Promise<void> {\n  const w = window as unknown as Record<string, unknown>;\n\n  // Fast path: global already present.\n  if (w[globalName] !== undefined) {\n    return Promise.resolve();\n  }\n\n  const cached = inFlight.get(url);\n  if (cached) {\n    return cached;\n  }\n\n  const promise = new Promise<void>((resolve, reject) => {\n    // If the host hasn't already added a script tag, add one.\n    const existingTag = document.querySelector<HTMLScriptElement>(`script[src=\"${url}\"]`);\n    if (!existingTag) {\n      const script = document.createElement('script');\n      script.src = url;\n      script.async = true;\n      script.onerror = () => {\n        inFlight.delete(url);\n        reject(new Error(`Failed to load script: ${url}`));\n      };\n      document.head.appendChild(script);\n    }\n\n    // Poll for the global. Works whether the script was just injected by us\n    // (load event will fire in the future) or by the host before our code\n    // started (load event already fired, can't listen for it now).\n    const start = Date.now();\n    const poll = (): void => {\n      if (w[globalName] !== undefined) {\n        resolve();\n        return;\n      }\n      if (Date.now() - start >= timeoutMs) {\n        inFlight.delete(url);\n        reject(new Error(`Timed out waiting for window.${globalName} from ${url}`));\n        return;\n      }\n      setTimeout(poll, POLL_INTERVAL_MS);\n    };\n    poll();\n  });\n\n  inFlight.set(url, promise);\n  return promise;\n}\n\nexport async function loadClover(url: string): Promise<CloverGlobal> {\n  await waitForGlobal({ url, globalName: 'Clover' });\n  const Clover = (window as unknown as { Clover?: CloverGlobal }).Clover;\n  if (!Clover) {\n    throw new Error('Clover SDK loaded but window.Clover is missing.');\n  }\n  return Clover;\n}\n\nexport async function loadClover3DS(url: string): Promise<Clover3DSGlobal> {\n  await waitForGlobal({ url, globalName: 'Clover3DS' });\n  const Clover3DS = (window as unknown as { Clover3DS?: Clover3DSGlobal }).Clover3DS;\n  if (!Clover3DS) {\n    throw new Error('Clover3DS SDK loaded but window.Clover3DS is missing.');\n  }\n  return Clover3DS;\n}\n","// ── Core types · @weeconnectpay/payment-fields ──────────────────\n//\n// All public types live here. The React and web-component layers re-export\n// the ones consumers need; the rest are SDK-internal.\n//\n// The marquee type in this file is `CloverElementStyles` — see the \"Clover\n// SDK constraints\" section of the SDK plan (~/.claude/plans/...) for why this\n// matters. It replaces the legacy `type CloverElementStyles = object` that\n// silently absorbed every selector and property typo for years.\n\n// ── Clover element types (mirrors the SDK's enum) ───────────────\n\nexport const CloverElementType = {\n  CARD: 'CARD',\n  NUMBER: 'CARD_NUMBER',\n  DATE: 'CARD_DATE',\n  CVV: 'CARD_CVV',\n  POSTAL_CODE: 'CARD_POSTAL_CODE',\n  STREET_ADDRESS: 'CARD_STREET_ADDRESS',\n  NAME: 'CARD_NAME',\n  EMAIL_ADDRESS: 'CARD_EMAIL_ADDRESS',\n  PHONE_NUMBER: 'CARD_PHONE_NUMBER',\n  PAYMENT_REQUEST_BUTTON: 'PAYMENT_REQUEST_BUTTON',\n} as const;\n\nexport type CloverElementType = (typeof CloverElementType)[keyof typeof CloverElementType];\n\n/**\n * SDK-internal identifier for each rendered field. One-to-one with the Clover\n * element types except `CARD` (composite — we don't use it).\n */\nexport type FieldKey =\n  | 'cardNumber'\n  | 'cardDate'\n  | 'cardCvv'\n  | 'cardPostalCode'\n  | 'cardName'\n  | 'cardEmail'\n  | 'paymentRequestButton';\n\n/** Maps the SDK's FieldKey to Clover's element type. */\nexport const FIELD_KEY_TO_CLOVER_TYPE: Record<FieldKey, CloverElementType> = {\n  cardNumber: CloverElementType.NUMBER,\n  cardDate: CloverElementType.DATE,\n  cardCvv: CloverElementType.CVV,\n  cardPostalCode: CloverElementType.POSTAL_CODE,\n  cardName: CloverElementType.NAME,\n  cardEmail: CloverElementType.EMAIL_ADDRESS,\n  paymentRequestButton: CloverElementType.PAYMENT_REQUEST_BUTTON,\n};\n\n// ── Clover styling JSON (the marquee type fix) ───────────────────\n\n/**\n * CSS properties Clover supports inside its iframe `<input>`. Curated from\n * production usage in the WP plugin + Clover SDK behavior. Properties not\n * listed here are silently ignored by Clover; we don't pretend they work.\n */\nexport interface CloverCssProperties {\n  // Typography\n  color?: string;\n  fontFamily?: string;\n  fontSize?: string;\n  fontWeight?: string | number;\n  lineHeight?: string | number;\n  letterSpacing?: string;\n  textAlign?: 'left' | 'right' | 'center' | 'inherit' | 'initial';\n  textIndent?: string;\n  // Box model\n  padding?: string;\n  margin?: string;\n  height?: string;\n  width?: string;\n  // Border (shorthand only — Clover ignores per-edge overrides)\n  border?: string;\n  borderRadius?: string;\n  // Background (limited support)\n  background?: string;\n  backgroundColor?: string;\n}\n\n/**\n * Element-scoped selectors Clover honors. Each is the lower-kebab form of the\n * Clover element type (`CARD_EMAIL_ADDRESS` → `card-email-address`). Using a\n * shortened form (e.g. `card-email`) is silently ignored — Clover does not\n * warn, the style just never applies. Discovery captured 2026-05-18.\n */\ntype CloverElementSelector =\n  | 'card-number'\n  | 'card-date'\n  | 'card-cvv'\n  | 'card-postal-code'\n  | 'card-name'\n  | 'card-email-address'\n  | 'card-phone-number'\n  | 'card-street-address';\n\n/**\n * Placeholder pseudo-classes Clover honors. The vendor-prefixed forms are\n * required by older Clover versions; modern `::placeholder` is also accepted.\n * Production code in the WP plugin sets all four prefixed variants.\n */\ntype PlaceholderPseudo =\n  | '::placeholder'\n  | '::-webkit-input-placeholder'\n  | '::-moz-placeholder'\n  | ':-ms-input-placeholder'\n  | ':-moz-placeholder';\n\n/**\n * Every selector key Clover's `elements.create(type, styles)` accepts. The\n * SDK exports this union so consumers get autocomplete and typo safety on\n * a previously-untyped JSON payload.\n *\n * - `'input'` — applies to the input in every element\n * - `'<pseudo>'` — global placeholder rule\n * - `'card-<type> input'` — per-element input rule\n * - `'card-<type> input<pseudo>'` — per-element placeholder rule\n */\nexport type CloverStyleSelector =\n  | 'input'\n  | PlaceholderPseudo\n  | CloverElementSelector\n  | `${CloverElementSelector} input`\n  | `${CloverElementSelector} input${PlaceholderPseudo}`;\n\n/**\n * Strongly-typed styles object for `clover.elements().create()`. Replaces\n * `type CloverElementStyles = object`.\n *\n * Most consumers should NOT construct this directly — pass a higher-level\n * `theme` on `PaymentFieldsConfig` and let `compileTheme()` emit the JSON.\n */\nexport type CloverElementStyles = Partial<Record<CloverStyleSelector, CloverCssProperties>>;\n\n/**\n * High-level theme config. The SDK compiles this into a `CloverElementStyles`\n * JSON object internally — most apps never need to touch the raw selectors.\n */\nexport interface CloverFieldTheme {\n  readonly fontFamily?: string;\n  readonly fontSize?: string;\n  readonly textColor?: string;\n  readonly placeholderColor?: string;\n  /**\n   * Height of the input inside each Clover iframe. Must match (or slightly\n   * exceed) the host wrapper's height so the entire wrapper is clickable.\n   * Defaults to `'46px'` to match `.wcp-pf__field` in the SDK stylesheet.\n   */\n  readonly inputHeight?: string;\n  /** Extra style overrides merged on top of the theme-emitted defaults. */\n  readonly overrides?: CloverElementStyles;\n}\n\n// ── Window-attached Clover globals (typed, not declared) ─────────\n//\n// We deliberately do NOT augment `Window` from a package. Globals leak into\n// every consumer's project. Instead the loader returns typed handles and the\n// rest of the SDK takes those as parameters.\n\nexport interface CloverGlobal {\n  new (pakms: string): CloverInstance;\n}\n\nexport interface CloverInstance {\n  apiKey?: string;\n  merchantId?: string;\n  locale?: string;\n  options?: CloverOptions;\n  elements: () => CloverElements;\n  createToken: () => Promise<CloverIframeTokenizationResponse>;\n}\n\nexport interface CloverOptions {\n  locale?: string;\n  merchantId?: string;\n  showSecurePayments?: boolean;\n  showPrivacyPolicy?: boolean;\n}\n\nexport interface CloverElements {\n  create: (\n    elementType: CloverElementType,\n    styles: CloverElementStyles | CloverPaymentRequestData,\n  ) => CloverElement;\n}\n\nexport interface CloverElement {\n  mount: (selector: string) => void;\n  addEventListener: (type: CloverElementEvent, listener: (event: Event) => void) => void;\n}\n\nexport type CloverElementEvent =\n  | 'change'\n  | 'blur'\n  | 'paymentMethodStart'\n  | 'paymentMethod'\n  | 'paymentMethodEnd';\n\nexport interface CloverIframeTokenizationResponse extends Event {\n  token?: string;\n  errors?: Partial<Record<CloverElementType, string>>;\n  card?: {\n    exp_month: string;\n    exp_year: string;\n    first6: string;\n    last4: string;\n    brand: string;\n    address_zip?: string;\n  };\n}\n\n/** Shape passed to `elements.create(PAYMENT_REQUEST_BUTTON, paymentReqData)`. */\nexport interface CloverPaymentRequestData {\n  readonly paymentReqData: {\n    readonly total: {\n      readonly label: string;\n      readonly currency: string;\n      readonly amount: number;\n    };\n    readonly options?: {\n      readonly button?: {\n        readonly buttonType?: 'short' | 'long';\n      };\n    };\n  };\n}\n\n// ── 3DS globals (typed, not declared) ────────────────────────────\n\nexport interface Clover3DSGlobal {\n  new (config: { merchantUuid: string }): ThreeDSUtil;\n}\n\nexport interface ThreeDSUtil {\n  getBrowserInfo: () => ThreeDsBrowserInfo;\n  perform3DSFingerPrinting: (args: {\n    threeDSServerTransID: string;\n    threeDSMethodUrl: string;\n    methodNotificationUrl: string;\n  }) => void;\n  perform3DSChallenge: (args: {\n    messageVersion: string;\n    acsTransID: string;\n    acsUrl: string;\n    threeDSServerTransID: string;\n  }) => void;\n}\n\nexport type ThreeDsBrowserInfo = Record<string, unknown>;\n\n// ── SDK state machine ────────────────────────────────────────────\n\n/**\n * Lifecycle states the SDK transitions through. See the lifecycle preview at\n * `design-previews/06-states.html` for what the customer sees in each state.\n */\nexport type PaymentFieldsState =\n  | 'idle'\n  | 'gpay_opening'\n  | 'gpay_ready'\n  | 'gpay_cancelled'\n  | 'tokenizing'\n  | 'submitting'\n  | 'threeds_method'\n  | 'threeds_challenge'\n  | 'finalizing'\n  | 'done'\n  | 'error';\n\n/**\n * Per-field validation state. Two error fields — `error` is the raw signal\n * from Clover, `displayedError` is what the UI should actually render. They\n * diverge for the deferred-error UX rule: while the user is mid-typing, raw\n * `error` may report \"incomplete card\", but we don't surface it until they\n * blur once. After first blur, the two stay in sync. See README → Events &\n * Validation, and the comment block at the top of `validation-machine.ts`.\n */\nexport interface FieldValidationState {\n  /** Clover-reported: user has interacted with the field. */\n  readonly touched: boolean;\n  /** Clover-reported: raw error message, fires on every `change` event. */\n  readonly error?: string;\n  /** SDK-derived: user has blurred this field at least once. */\n  readonly hasBlurred: boolean;\n  /** SDK-derived: at least one `change` event has been observed for this field. */\n  readonly hadChangeEver: boolean;\n  /** SDK-derived: the error to render. Undefined until first blur (deferred-error rule). */\n  readonly displayedError?: string;\n}\n\nexport interface ValidationSnapshot {\n  /** Per-field touched + error state. Only fields actually mounted appear. */\n  readonly fields: { readonly [K in FieldKey]?: FieldValidationState };\n  /** True when all required fields are valid (no errors, all touched). */\n  readonly canSubmit: boolean;\n}\n\nexport interface PaymentFieldsSnapshot {\n  readonly state: PaymentFieldsState;\n  readonly validation: ValidationSnapshot;\n  /** Set when state is 'error' or after a recoverable failure. */\n  readonly error?: PaymentFieldsError;\n  /** Set after successful tokenization (either path). */\n  readonly result?: TokenizationResult;\n  /** Set during the 3DS flow. */\n  readonly threeDs?: ThreeDsInterim;\n}\n\nexport interface PaymentFieldsError {\n  readonly code: PaymentFieldsErrorCode;\n  readonly message: string;\n  readonly cause?: unknown;\n}\n\nexport type PaymentFieldsErrorCode =\n  | 'clover_load_failed'\n  | 'clover_3ds_load_failed'\n  | 'not_mounted'\n  | 'rate_limited'\n  | 'tokenization_failed'\n  | 'gpay_unavailable'\n  | 'threeds_prerequisites_missing'\n  | 'threeds_timeout'\n  | 'threeds_finalize_failed'\n  | 'unknown';\n\n// ── Tokenization result ──────────────────────────────────────────\n\nexport interface TokenizationResult {\n  /** 'card' = manual entry tokenized via `clover.createToken()`. 'google_pay' = captured from `PAYMENT_REQUEST_BUTTON` paymentMethod event. */\n  readonly source: 'card' | 'google_pay';\n  readonly token: string;\n  readonly card: {\n    readonly brand: string;\n    readonly last4: string;\n    readonly expMonth?: string;\n    readonly expYear?: string;\n    readonly first6?: string;\n    readonly addressZip?: string;\n  };\n  /** 3DS browser fingerprint, collected when 3DS is enabled. */\n  readonly browserInfo?: ThreeDsBrowserInfo;\n}\n\n// ── 3DS flow types ───────────────────────────────────────────────\n\nexport interface ThreeDsInterim {\n  readonly state: 'method_required' | 'challenge_required';\n  readonly chargeId: string;\n  readonly fields: ThreeDsInterimFields;\n}\n\nexport interface ThreeDsInterimFields {\n  readonly acsUrl?: string;\n  readonly acsTransactionId?: string;\n  readonly methodUrl?: string;\n  readonly methodNotificationUrl?: string;\n  readonly threeDsServerTransactionId?: string;\n  /** Clover varies the field name between `threeds_protocol_version` and `message_version`. The SDK normalizes to this. */\n  readonly protocolVersion?: string;\n}\n\nexport type ThreeDsResult =\n  | { readonly kind: 'success'; readonly redirect?: string; readonly data?: unknown }\n  | { readonly kind: 'escalation'; readonly next: ThreeDsInterim }\n  | { readonly kind: 'failure'; readonly message: string };\n\n// ── Config (what the host passes to PaymentFieldsMachine) ────────\n\nexport interface PaymentFieldsConfig {\n  // Clover SDK init\n  readonly pakmsKey: string;\n  readonly merchantId: string;\n  readonly locale: string;\n\n  // Cart context (for Payment Request Button)\n  readonly cartTotal: number;\n  readonly currency: string;\n  readonly country?: string;\n\n  // SDK script URLs (env-overridable)\n  readonly cloverSdkUrl: string;\n  readonly clover3DSSdkUrl?: string;\n\n  // Features\n  readonly features?: PaymentFieldsFeatures;\n\n  // Endpoints (3DS finalize is host-supplied)\n  readonly endpoints?: PaymentFieldsEndpoints;\n\n  // Styling\n  readonly theme?: CloverFieldTheme;\n\n  // Optional callbacks (in addition to subscribe())\n  readonly onTokenized?: (result: TokenizationResult) => void;\n  readonly onThreeDsRequired?: (interim: ThreeDsInterim) => void;\n  readonly onError?: (error: PaymentFieldsError) => void;\n}\n\nexport interface PaymentFieldsFeatures {\n  readonly googlePay?: boolean;\n  readonly threeDSecure?: boolean;\n  /**\n   * Cardholder name + email field visibility.\n   * - `'auto'` (default) — visible when 3DSecure is enabled\n   * - `'always'` — visible always\n   * - `'hidden'` — never rendered\n   */\n  readonly cardholderFields?: 'auto' | 'always' | 'hidden';\n  readonly savedCredentials?: SavedCredential | readonly SavedCredential[];\n}\n\nexport interface PaymentFieldsEndpoints {\n  /** Host's POST URL for 3DS finalization (e.g., WC's `/wp-json/.../3ds/finalize`). */\n  readonly threeDsFinalize?: string;\n  /** Returns headers (nonce, auth, etc.) for the finalize POST. Called per-request. */\n  readonly headers?: HeadersProvider;\n}\n\nexport type HeadersProvider = () =>\n  | Record<string, string>\n  | Promise<Record<string, string>>;\n\nexport interface SavedCredential {\n  readonly token: string;\n  readonly last4: string;\n  readonly brand: string;\n}\n\n// ── Mounting ─────────────────────────────────────────────────────\n\nexport interface MountTargets {\n  readonly cardNumber: string;\n  readonly cardDate: string;\n  readonly cardCvv: string;\n  readonly cardPostalCode: string;\n  readonly cardName?: string;\n  readonly cardEmail?: string;\n  readonly paymentRequestButton?: string;\n}\n\n// ── Observer pattern ─────────────────────────────────────────────\n\nexport type PaymentFieldsListener = (snapshot: PaymentFieldsSnapshot) => void;\nexport type Unsubscribe = () => void;\n","// ── Clover element lifecycle ────────────────────────────────────\n//\n// Owns `elements.create()` per FieldKey and the subsequent `.mount()` calls.\n// Decoupled from React reconciliation so iframes persist across renders.\n//\n// Clover's SDK does not expose unmount/destroy on its elements. Cleanup is\n// best-effort: we drop our refs and let GC collect the iframes when their\n// host divs are removed from the DOM.\n\nimport {\n  type CloverElement,\n  type CloverElementType,\n  type CloverElementStyles,\n  type CloverInstance,\n  type CloverPaymentRequestData,\n  type FieldKey,\n  FIELD_KEY_TO_CLOVER_TYPE,\n  type MountTargets,\n} from './types';\n\nexport interface ElementRegistryOptions {\n  readonly clover: CloverInstance;\n  readonly styles: CloverElementStyles;\n  /** Required when creating the `paymentRequestButton` field. */\n  readonly paymentRequestData?: CloverPaymentRequestData;\n}\n\nexport class ElementRegistry {\n  private readonly elements = new Map<FieldKey, CloverElement>();\n  private readonly options: ElementRegistryOptions;\n  private destroyed = false;\n\n  constructor(options: ElementRegistryOptions) {\n    this.options = options;\n  }\n\n  /**\n   * Create a Clover element for each key. Skips keys already created.\n   * GPay button creation can throw on devices without PaymentRequest support —\n   * caught + logged + skipped, never breaks the rest of the form.\n   */\n  create(keys: readonly FieldKey[]): this {\n    this.assertAlive();\n    const cloverElements = this.options.clover.elements();\n    for (const key of keys) {\n      if (this.elements.has(key)) {\n        continue;\n      }\n      const type: CloverElementType = FIELD_KEY_TO_CLOVER_TYPE[key];\n      const data: CloverElementStyles | CloverPaymentRequestData =\n        key === 'paymentRequestButton' && this.options.paymentRequestData\n          ? this.options.paymentRequestData\n          : this.options.styles;\n      try {\n        const el = cloverElements.create(type, data);\n        this.elements.set(key, el);\n      } catch (error) {\n        console.warn(`[wcp-payment-fields] failed to create element \"${key}\"`, error);\n      }\n    }\n    return this;\n  }\n\n  /**\n   * Mount each created element at its target CSS selector. Skips fields whose\n   * target is missing or whose host div doesn't exist in the DOM yet.\n   */\n  mount(targets: MountTargets): this {\n    this.assertAlive();\n    this.mountIfTargeted('cardNumber', targets.cardNumber);\n    this.mountIfTargeted('cardDate', targets.cardDate);\n    this.mountIfTargeted('cardCvv', targets.cardCvv);\n    this.mountIfTargeted('cardPostalCode', targets.cardPostalCode);\n    this.mountIfTargeted('cardName', targets.cardName);\n    this.mountIfTargeted('cardEmail', targets.cardEmail);\n    this.mountIfTargeted('paymentRequestButton', targets.paymentRequestButton);\n    return this;\n  }\n\n  get(key: FieldKey): CloverElement | undefined {\n    return this.elements.get(key);\n  }\n\n  entries(): IterableIterator<[FieldKey, CloverElement]> {\n    return this.elements.entries();\n  }\n\n  destroy(): void {\n    this.destroyed = true;\n    this.elements.clear();\n  }\n\n  private mountIfTargeted(key: FieldKey, selector: string | undefined): void {\n    if (!selector) {\n      return;\n    }\n    const el = this.elements.get(key);\n    if (!el) {\n      return;\n    }\n    const host = document.querySelector(selector);\n    if (!host) {\n      return;\n    }\n    try {\n      el.mount(selector);\n    } catch (error) {\n      console.warn(`[wcp-payment-fields] failed to mount \"${key}\" at \"${selector}\"`, error);\n      return;\n    }\n    // Clover's iframe document occasionally renders content a sub-pixel taller\n    // than its viewport (Firefox shows a fading overlay scrollbar; Chrome a\n    // permanent thin one). The CSS-only fixes don't fully suppress it because\n    // (a) Clover's own `updateFrameStyles` postMessage sets inline `height`\n    // on the iframe at runtime, racing our stylesheet, and (b) overflow on\n    // an iframe element is honored inconsistently across browsers. The\n    // deprecated `scrolling=\"no\"` HTML attribute is still honored by every\n    // browser we ship to and is the only reliable kill switch for cross-\n    // origin iframe scrollbars. Apply it after Clover injects the iframe.\n    suppressIframeScrollbars(host);\n  }\n\n  private assertAlive(): void {\n    if (this.destroyed) {\n      throw new Error('ElementRegistry has been destroyed.');\n    }\n  }\n}\n\n/**\n * Apply `scrolling=\"no\"` to every iframe Clover injects into the host element.\n * Runs once synchronously (Clover's mount is sync) and then via MutationObserver\n * in case Clover swaps the iframe later (e.g., re-creating it on `update()`).\n */\nfunction suppressIframeScrollbars(host: Element): void {\n  const apply = (frame: HTMLIFrameElement): void => {\n    frame.setAttribute('scrolling', 'no');\n    // Belt-and-suspenders for browsers that honor CSS overflow on iframes.\n    frame.style.overflow = 'hidden';\n  };\n\n  for (const frame of host.querySelectorAll('iframe')) {\n    apply(frame as HTMLIFrameElement);\n  }\n\n  // Observe in case Clover replaces the iframe (e.g., on PaymentRequest\n  // re-init when cart total changes). The observer is cheap and the host\n  // node lives as long as the SDK does.\n  const observer = new MutationObserver((mutations) => {\n    for (const m of mutations) {\n      for (const node of m.addedNodes) {\n        if (node instanceof HTMLIFrameElement) {\n          apply(node);\n        }\n      }\n    }\n  });\n  observer.observe(host, { childList: true, subtree: true });\n}\n","// ── Theme → CloverElementStyles compiler ────────────────────────\n//\n// Translates the high-level `CloverFieldTheme` config into the JSON shape\n// Clover's `elements.create()` expects.\n//\n// Clover honors per-element selectors (`card-number input`) reliably; global\n// selectors like `'::placeholder'` are inconsistently applied across Clover\n// versions. We emit per-element rules for every field so styling is\n// deterministic. The `'input'` global rule is still emitted as a baseline.\n//\n// Key invariants the legacy plugin established (mirrored here so the visual\n// output matches what merchants are already used to):\n//   - Input fills its iframe: height: 100%, width: 100%, no padding/margin.\n//   - Card number + cardholder name + email get a left text-indent so the\n//     placeholder doesn't sit flush against the iframe edge.\n//   - Date / CVV / postal-code text is centered.\n\nimport type { CloverCssProperties, CloverElementStyles, CloverFieldTheme } from './types';\n\nconst PLACEHOLDER_PSEUDOS = [\n  '::placeholder',\n  '::-webkit-input-placeholder',\n  '::-moz-placeholder',\n  ':-ms-input-placeholder',\n  ':-moz-placeholder',\n] as const;\n\n// Clover's element-scoped CSS selector is the lower-kebab form of the element\n// type name. `CARD_EMAIL_ADDRESS` is `card-email-address`, NOT `card-email` —\n// the short form is silently ignored (verified via discovery 2026-05-18). The\n// legacy WP plugin had the same bug, which is why the email placeholder sat\n// flush against the iframe edge while the name field was indented correctly.\nconst LEFT_ALIGNED_FIELDS = ['card-number', 'card-name', 'card-email-address'] as const;\nconst CENTER_ALIGNED_FIELDS = ['card-date', 'card-cvv', 'card-postal-code'] as const;\n\nexport function compileTheme(theme?: CloverFieldTheme): CloverElementStyles {\n  const styles: CloverElementStyles = {};\n\n  // ── Global input baseline. Applies to every Clover element's input. ──\n  //\n  // `height` must be a definite length, not `100%`. The Clover iframe document's\n  // `<html>`/`<body>` don't have an explicit height, so `100%` resolves to the\n  // input's content-box height (~17px) and clicks on the rest of the 46px\n  // wrapper land on the iframe body instead of the input. Matching the wrapper\n  // height in `styles.ts` (46px) keeps the entire wrapper clickable; the\n  // `overflow: hidden` on `.wcp-pf__field` absorbs any sub-pixel overshoot.\n  // `lineHeight` matches so text is vertically centered without depending on\n  // flex/grid we don't control inside the iframe. `border: 'none'` suppresses\n  // Clover's default input border — the SDK's wrapper owns the border.\n  const inputHeight = theme?.inputHeight ?? '46px';\n  styles.input = stripUndefined<CloverCssProperties>({\n    padding: '0',\n    margin: '0',\n    border: 'none',\n    height: inputHeight,\n    width: '100%',\n    lineHeight: inputHeight,\n    fontFamily: theme?.fontFamily,\n    fontSize: theme?.fontSize,\n    color: theme?.textColor,\n  });\n\n  // ── Per-element input rules: text position. ──\n  for (const field of LEFT_ALIGNED_FIELDS) {\n    styles[`${field} input`] = {\n      textAlign: 'left',\n      textIndent: '14px',\n    };\n  }\n  for (const field of CENTER_ALIGNED_FIELDS) {\n    styles[`${field} input`] = {\n      textAlign: 'center',\n    };\n  }\n\n  // ── Per-element placeholder rules: color only (alignment inherits from input). ──\n  if (theme?.placeholderColor) {\n    for (const pseudo of PLACEHOLDER_PSEUDOS) {\n      for (const field of [...LEFT_ALIGNED_FIELDS, ...CENTER_ALIGNED_FIELDS]) {\n        styles[`${field} input${pseudo}`] = { color: theme.placeholderColor };\n      }\n    }\n  }\n\n  // ── User overrides win over compiled defaults. ──\n  if (theme?.overrides) {\n    Object.assign(styles, theme.overrides);\n  }\n  return styles;\n}\n\nfunction stripUndefined<T extends object>(obj: T): Partial<T> {\n  const out: Partial<T> = {};\n  for (const [k, v] of Object.entries(obj)) {\n    if (v !== undefined) {\n      (out as Record<string, unknown>)[k] = v;\n    }\n  }\n  return out;\n}\n","// ── 3DS finalize HTTP client ────────────────────────────────────\n//\n// POSTs the 3DS flow outcome back to the host's finalize endpoint\n// (e.g., WordPress: `/wp-json/weeconnectpay/v1/woocommerce/3ds/finalize`;\n// dashboard: `/api/v1/clover/charges/3ds/finalize`).\n//\n// Headers are pluggable so each host can inject nonces / auth tokens.\n// Response parsing handles three outcomes: terminal success, escalation\n// (method→challenge or vice versa), or terminal failure.\n\nimport type { HeadersProvider, ThreeDsInterim } from './types';\n\nexport interface FinalizeRequest {\n  readonly url: string;\n  readonly headers?: HeadersProvider;\n  readonly body: Record<string, unknown>;\n}\n\nexport interface FinalizeResponseEnvelope {\n  readonly ok: boolean;\n  readonly data: FinalizeResponseData | null;\n}\n\nexport interface FinalizeResponseData {\n  readonly success?: boolean;\n  readonly redirect?: string;\n  readonly message?: string;\n  /** When Clover escalates the flow, the host returns the next interim payload here. */\n  readonly weeconnectpay_threeds_interim?: ThreeDsInterimRaw;\n}\n\n/** Wire shape from Clover / the host before normalization to ThreeDsInterim. */\nexport interface ThreeDsInterimRaw {\n  readonly state: 'method_required' | 'challenge_required';\n  readonly charge_id: string | null;\n  readonly threeds: {\n    readonly acs_url?: string;\n    readonly acs_transaction_id?: string;\n    readonly method_url?: string;\n    readonly method_notification_url?: string;\n    readonly threeds_server_transaction_id?: string;\n    readonly threeds_protocol_version?: string;\n    /** Older Clover docs used `message_version` — both supported. */\n    readonly message_version?: string;\n  };\n}\n\nexport async function postFinalize(request: FinalizeRequest): Promise<FinalizeResponseEnvelope> {\n  const headers: Record<string, string> = {\n    'Content-Type': 'application/json',\n    Accept: 'application/json',\n  };\n  if (request.headers) {\n    Object.assign(headers, await request.headers());\n  }\n\n  let response: Response;\n  try {\n    response = await fetch(request.url, {\n      method: 'POST',\n      headers,\n      body: JSON.stringify(request.body),\n    });\n  } catch (error) {\n    throw new Error(`Network error during 3DS finalize: ${(error as Error).message}`);\n  }\n\n  let data: FinalizeResponseData | null = null;\n  try {\n    data = (await response.json()) as FinalizeResponseData;\n  } catch {\n    data = null;\n  }\n  return { ok: response.ok, data };\n}\n\n/**\n * Normalize the wire shape into the SDK's `ThreeDsInterim`. Returns null when\n * required fields (charge_id) are missing — the caller should treat as a\n * failure rather than entering a malformed state.\n */\nexport function parseInterim(raw: ThreeDsInterimRaw): ThreeDsInterim | null {\n  if (!raw.charge_id) {\n    return null;\n  }\n  return {\n    state: raw.state,\n    chargeId: raw.charge_id,\n    fields: {\n      acsUrl: raw.threeds.acs_url,\n      acsTransactionId: raw.threeds.acs_transaction_id,\n      methodUrl: raw.threeds.method_url,\n      methodNotificationUrl: raw.threeds.method_notification_url,\n      threeDsServerTransactionId: raw.threeds.threeds_server_transaction_id,\n      protocolVersion: raw.threeds.threeds_protocol_version ?? raw.threeds.message_version,\n    },\n  };\n}\n","// ── 3DS state machine ───────────────────────────────────────────\n//\n// Drives Clover's `_3DSUtil` through method (fingerprinting) and challenge\n// flows, listens for the `executePatch` event Clover dispatches on `document`\n// when its iframe completes, POSTs the outcome to the host's finalize URL,\n// and recurses on escalation (method → challenge or vice versa).\n\nimport { parseInterim, postFinalize } from './threeds-finalize-client';\nimport type { HeadersProvider, ThreeDSUtil, ThreeDsInterim, ThreeDsResult } from './types';\n\nconst DEFAULT_METHOD_TIMEOUT_MS = 30 * 1000;\nconst DEFAULT_CHALLENGE_TIMEOUT_MS = 5 * 60 * 1000;\n\ninterface ExecutePatchDetail {\n  _3DSStatus?: string;\n}\n\nexport interface ThreeDsMachineOptions {\n  readonly util: ThreeDSUtil;\n  readonly finalizeUrl: string;\n  readonly headers?: HeadersProvider;\n  /** Extra fields the host needs in the finalize body (order_id, order_key, nonce). */\n  readonly extraBody?: Record<string, unknown>;\n  readonly methodTimeoutMs?: number;\n  readonly challengeTimeoutMs?: number;\n}\n\nexport class ThreeDsMachine {\n  private readonly options: ThreeDsMachineOptions;\n  private cancelled = false;\n\n  constructor(options: ThreeDsMachineOptions) {\n    this.options = options;\n  }\n\n  cancel(): void {\n    this.cancelled = true;\n  }\n\n  /**\n   * Run a single 3DS interim payload to a terminal result. For escalation\n   * (method completes → Clover wants challenge, or vice versa), the result\n   * is returned with `kind: 'escalation'`; the caller (PaymentFieldsMachine)\n   * re-enters the loop with the next interim.\n   */\n  async run(interim: ThreeDsInterim): Promise<ThreeDsResult> {\n    if (this.cancelled) {\n      return { kind: 'failure', message: 'Cancelled.' };\n    }\n\n    if (interim.state === 'method_required') {\n      try {\n        const status = await this.runMethod(interim);\n        if (this.cancelled) {\n          return { kind: 'failure', message: 'Cancelled.' };\n        }\n        return this.finalize(interim, status);\n      } catch (error) {\n        return { kind: 'failure', message: (error as Error).message };\n      }\n    }\n\n    if (interim.state === 'challenge_required') {\n      const cleanup = this.styleChallengeContainer();\n      try {\n        const status = await this.runChallenge(interim);\n        if (this.cancelled) {\n          return { kind: 'failure', message: 'Cancelled.' };\n        }\n        return await this.finalize(interim, status);\n      } catch (error) {\n        return { kind: 'failure', message: (error as Error).message };\n      } finally {\n        cleanup();\n      }\n    }\n\n    return {\n      kind: 'failure',\n      message: `Unsupported 3DS state: ${(interim as { state: string }).state}`,\n    };\n  }\n\n  // ── flow handlers ──\n\n  private runMethod(interim: ThreeDsInterim): Promise<string> {\n    const f = interim.fields;\n    if (!f.threeDsServerTransactionId || !f.methodUrl || !f.methodNotificationUrl) {\n      return Promise.reject(new Error('3DS method prerequisites missing.'));\n    }\n    return this.awaitExecutePatch(\n      this.options.methodTimeoutMs ?? DEFAULT_METHOD_TIMEOUT_MS,\n      'method flow timed out',\n      () =>\n        this.options.util.perform3DSFingerPrinting({\n          threeDSServerTransID: f.threeDsServerTransactionId!,\n          threeDSMethodUrl: f.methodUrl!,\n          methodNotificationUrl: f.methodNotificationUrl!,\n        }),\n    );\n  }\n\n  private runChallenge(interim: ThreeDsInterim): Promise<string> {\n    const f = interim.fields;\n    if (!f.acsUrl || !f.acsTransactionId || !f.threeDsServerTransactionId || !f.protocolVersion) {\n      return Promise.reject(new Error('3DS challenge prerequisites missing.'));\n    }\n    return this.awaitExecutePatch(\n      this.options.challengeTimeoutMs ?? DEFAULT_CHALLENGE_TIMEOUT_MS,\n      'challenge flow timed out',\n      () =>\n        this.options.util.perform3DSChallenge({\n          messageVersion: f.protocolVersion!,\n          acsTransID: f.acsTransactionId!,\n          acsUrl: f.acsUrl!,\n          threeDSServerTransID: f.threeDsServerTransactionId!,\n        }),\n    );\n  }\n\n  private awaitExecutePatch(timeoutMs: number, timeoutMessage: string, kickoff: () => void): Promise<string> {\n    return new Promise<string>((resolve, reject) => {\n      let settled = false;\n      const finalize = (status: string): void => {\n        if (settled) return;\n        settled = true;\n        window.clearTimeout(timeoutId);\n        document.removeEventListener('executePatch', handler);\n        resolve(status);\n      };\n      const handler = (ev: Event): void => {\n        const detail = (ev as CustomEvent<ExecutePatchDetail>).detail;\n        finalize(detail?._3DSStatus ?? '');\n      };\n      const timeoutId = window.setTimeout(() => {\n        if (settled) return;\n        settled = true;\n        document.removeEventListener('executePatch', handler);\n        reject(new Error(timeoutMessage));\n      }, timeoutMs);\n      document.addEventListener('executePatch', handler);\n      try {\n        kickoff();\n      } catch (error) {\n        settled = true;\n        window.clearTimeout(timeoutId);\n        document.removeEventListener('executePatch', handler);\n        reject(error as Error);\n      }\n    });\n  }\n\n  // ── finalize ──\n\n  private async finalize(interim: ThreeDsInterim, flowStatus: string): Promise<ThreeDsResult> {\n    const body: Record<string, unknown> = {\n      charge_id: interim.chargeId,\n      flow_status: flowStatus,\n      ...(this.options.extraBody ?? {}),\n    };\n\n    let envelope;\n    try {\n      envelope = await postFinalize({\n        url: this.options.finalizeUrl,\n        headers: this.options.headers,\n        body,\n      });\n    } catch (error) {\n      return { kind: 'failure', message: (error as Error).message };\n    }\n\n    const data = envelope.data;\n    if (!data) {\n      return { kind: 'failure', message: 'Verification response unreadable.' };\n    }\n\n    if (data.weeconnectpay_threeds_interim) {\n      const next = parseInterim(data.weeconnectpay_threeds_interim);\n      if (next) {\n        return { kind: 'escalation', next };\n      }\n    }\n\n    if (envelope.ok && data.success === true) {\n      return { kind: 'success', redirect: data.redirect, data };\n    }\n\n    return {\n      kind: 'failure',\n      message: data.message ?? 'Payment verification failed.',\n    };\n  }\n\n  // ── challenge container styling ──\n  //\n  // Clover injects `#threedsContainer` into the DOM when `perform3DSChallenge`\n  // runs. We style it (overlay + centered card) via a MutationObserver so we\n  // don't depend on Clover's render timing.\n\n  private styleChallengeContainer(): () => void {\n    const container = document.getElementById('threedsContainer');\n    if (!container) {\n      return () => undefined;\n    }\n\n    container.style.cssText =\n      'position:fixed;inset:0;z-index:99999;display:flex;flex-direction:column;' +\n      'align-items:center;justify-content:center;background:rgba(0,0,0,0.6);padding:1rem;';\n\n    const styleIframe = (): boolean => {\n      const iframe = container.querySelector('iframe');\n      if (!iframe) {\n        return false;\n      }\n      iframe.style.background = 'white';\n      iframe.style.borderRadius = '0.75rem';\n      iframe.style.boxShadow = '0 25px 50px -12px rgba(0,0,0,0.4)';\n      iframe.style.maxWidth = '100%';\n      iframe.style.display = 'block';\n      return true;\n    };\n\n    let observer: MutationObserver | null = null;\n    if (!styleIframe()) {\n      observer = new MutationObserver(() => {\n        if (styleIframe()) {\n          observer?.disconnect();\n          observer = null;\n        }\n      });\n      observer.observe(container, { childList: true });\n    }\n\n    return () => {\n      observer?.disconnect();\n      container.style.cssText = '';\n    };\n  }\n}\n","// ── Manual card tokenization ────────────────────────────────────\n//\n// Wraps `clover.createToken()` with a rate limiter. The limiter prevents\n// abusive call patterns from spamming Clover's API (the legacy WP plugin\n// observed double-submits from misconfigured themes/plugins).\n//\n// Default: 2 calls per 5-second window.\n\nimport type { CloverIframeTokenizationResponse, CloverInstance } from './types';\n\nexport interface RateLimiter {\n  /** Returns true if a call is allowed (and consumes a slot); false if rate-limited. */\n  check(): boolean;\n}\n\nexport interface CreateRateLimiterOptions {\n  readonly windowMs?: number;\n  readonly maxCalls?: number;\n}\n\nexport function createRateLimiter(options: CreateRateLimiterOptions = {}): RateLimiter {\n  const windowMs = options.windowMs ?? 5000;\n  const maxCalls = options.maxCalls ?? 2;\n  const timestamps: number[] = [];\n\n  return {\n    check(): boolean {\n      const now = Date.now();\n      const cutoff = now - windowMs;\n      while (timestamps.length > 0 && timestamps[0] < cutoff) {\n        timestamps.shift();\n      }\n      if (timestamps.length >= maxCalls) {\n        return false;\n      }\n      timestamps.push(now);\n      return true;\n    },\n  };\n}\n\nexport interface TokenizeOptions {\n  readonly rateLimiter?: RateLimiter;\n}\n\nexport async function tokenize(\n  clover: CloverInstance,\n  options: TokenizeOptions = {},\n): Promise<CloverIframeTokenizationResponse> {\n  if (options.rateLimiter && !options.rateLimiter.check()) {\n    throw new Error('Rate limit exceeded for tokenization. Wait a moment and try again.');\n  }\n  return clover.createToken();\n}\n","// ── Per-field validation state ──────────────────────────────────\n//\n// Listens to Clover's `change` and `blur` events on each mounted element,\n// tracks per-field state, and emits `ValidationSnapshot` to subscribers.\n//\n// ── Two-layer error model ─────────────────────────────────────\n//\n//   raw error  ← what Clover reports (every change/blur)\n//   displayed  ← what the UI shows (deferred until first blur)\n//\n// Why two layers: Clover fires `change` events with `error: \"incomplete\"`\n// or similar on every keystroke. Showing a red border + shake while the\n// user is typing \"4242\" is bad UX — they haven't finished entering the\n// number yet. Mirrors Stripe Elements, Square Web Payments, Braintree.\n//\n// Rules driving `displayedError`:\n//   1. `change` before first blur   → leave `displayedError` undefined\n//   2. `blur` event                 → copy raw error to `displayedError`\n//   3. `change` after first blur    → copy raw error to `displayedError`\n//                                     (live error-clearing as user fixes)\n//\n// Positive feedback (green check) reads raw `touched && !error` directly —\n// it never gets deferred. Asymmetric on purpose.\n//\n// ── Cardholder name / email caveat ───────────────────────────\n//\n// Clover does NOT distinguish empty from valid for `CARD_NAME` and\n// `CARD_EMAIL_ADDRESS` (discovery 2026-05-18):\n//   - cardName empty: no `error` key at all\n//   - cardName valid: no `error` key at all\n//   - cardEmail empty: `error: \"\"`\n//   - cardEmail valid format: `error: \"\"`\n// So we layer our own \"empty?\" detection on top, using `hadChangeEver` as a\n// proxy. If the user blurs without ever firing a `change` event, the field\n// is empty and — if required — we emit `displayedError: \"Required\"` and\n// suppress the green check. We can't catch type-then-delete-to-empty (no\n// access to the iframe value), so server-side validation remains the\n// authoritative gate for those edge cases.\n//\n// ── Clover event shape ────────────────────────────────────────\n//\n// Each event Clover fires carries the full state map for every mounted field,\n// not just the field that triggered it (verified via discovery 2026-05-18):\n//\n//   event.CARD_NUMBER         = { touched, error?, info }\n//   event.CARD_DATE           = { touched, error?, info }\n//   event.CARD_CVV            = { touched, error?, info }\n//   event.CARD_POSTAL_CODE    = { touched, error?, info }\n//   event.CARD_NAME           = { touched, error?, info }\n//   event.CARD_EMAIL_ADDRESS  = { touched, error?, info }\n//\n// We reconcile the full snapshot on every event, but only credit the field\n// that actually fired the event (the listener's owning fieldKey) with\n// `hadChangeEver` / `hasBlurred` flips.\n\nimport type {\n  CloverElement,\n  CloverElementType,\n  FieldKey,\n  FieldValidationState,\n  Unsubscribe,\n  ValidationSnapshot,\n} from './types';\n\n/** Field keys that participate in validation. Payment Request Button does not. */\nconst VALIDATING_FIELDS: readonly FieldKey[] = [\n  'cardNumber',\n  'cardDate',\n  'cardCvv',\n  'cardPostalCode',\n  'cardName',\n  'cardEmail',\n];\n\n/**\n * Fields Clover doesn't enforce non-empty for — we emit \"Required\" ourselves\n * on blur if these are required and the user never typed anything.\n */\nconst REQUIRES_NON_EMPTY_OVERRIDE: ReadonlySet<FieldKey> = new Set(['cardName', 'cardEmail']);\n\nconst CLOVER_KEY_TO_FIELD_KEY: Record<string, FieldKey> = {\n  CARD_NUMBER: 'cardNumber',\n  CARD_DATE: 'cardDate',\n  CARD_CVV: 'cardCvv',\n  CARD_POSTAL_CODE: 'cardPostalCode',\n  CARD_NAME: 'cardName',\n  CARD_EMAIL_ADDRESS: 'cardEmail',\n};\n\ninterface CloverFieldEventState {\n  touched: boolean;\n  error?: string;\n}\n\ntype CloverEventType = 'change' | 'blur';\n\ninterface InternalFieldState {\n  touched: boolean;\n  error?: string;\n  hasBlurred: boolean;\n  hadChangeEver: boolean;\n  displayedError?: string;\n}\n\nfunction emptyFieldState(): InternalFieldState {\n  return {\n    touched: false,\n    error: undefined,\n    hasBlurred: false,\n    hadChangeEver: false,\n    displayedError: undefined,\n  };\n}\n\nfunction toPublic(s: InternalFieldState): FieldValidationState {\n  return {\n    touched: s.touched,\n    error: s.error,\n    hasBlurred: s.hasBlurred,\n    hadChangeEver: s.hadChangeEver,\n    displayedError: s.displayedError,\n  };\n}\n\nfunction isMeaningfulError(err: string | undefined): boolean {\n  // Clover uses `\"\"` (empty string) for cardEmail to mean \"no error\". Treat it\n  // the same as `undefined` so downstream callers only see real error strings.\n  return err !== undefined && err !== '';\n}\n\nexport class ValidationMachine {\n  private readonly state = new Map<FieldKey, InternalFieldState>();\n  private readonly required = new Set<FieldKey>();\n  private readonly listeners = new Set<(snapshot: ValidationSnapshot) => void>();\n\n  constructor(requiredFields: readonly FieldKey[]) {\n    for (const f of requiredFields) {\n      if (VALIDATING_FIELDS.includes(f)) {\n        this.required.add(f);\n      }\n    }\n  }\n\n  /** Wire up the validation machine to a set of Clover elements. */\n  attach(elements: Map<FieldKey, CloverElement>): void {\n    for (const [key, el] of elements.entries()) {\n      if (!VALIDATING_FIELDS.includes(key)) {\n        continue;\n      }\n      // Each listener closes over `key`, so we know which field actually fired\n      // the event — even though Clover's payload carries state for ALL fields.\n      el.addEventListener('change', (event: Event) => this.onCloverEvent(event, 'change', key));\n      el.addEventListener('blur', (event: Event) => this.onCloverEvent(event, 'blur', key));\n    }\n  }\n\n  /**\n   * Overlay tokenize-time errors onto per-field `displayedError`. Used when\n   * `clover.createToken()` returns errors at submit time — we route them\n   * back to the firing fields instead of joining them into a generic banner.\n   *\n   * For each field that errored we also set `hasBlurred = true`, so the\n   * existing live-error-clearing rule kicks in: as soon as the user edits the\n   * field, the next `change` event recomputes `displayedError` from Clover's\n   * current state and clears the submit error.\n   *\n   * The Clover-side empty-vs-valid ambiguity for `CARD_NAME` / `CARD_EMAIL_ADDRESS`\n   * means createToken may or may not emit errors for those fields when empty;\n   * we surface whatever Clover reports and leave the rest as-is.\n   */\n  setSubmitErrors(errors: Partial<Record<CloverElementType, string>>): void {\n    let changed = false;\n    for (const [cloverKey, fieldKey] of Object.entries(CLOVER_KEY_TO_FIELD_KEY)) {\n      const message = errors[cloverKey as CloverElementType];\n      if (!message) {\n        continue;\n      }\n      const prev = this.state.get(fieldKey) ?? emptyFieldState();\n      const next: InternalFieldState = {\n        ...prev,\n        hasBlurred: true,\n        displayedError: message,\n      };\n      if (\n        prev.hasBlurred !== next.hasBlurred ||\n        prev.displayedError !== next.displayedError\n      ) {\n        this.state.set(fieldKey, next);\n        changed = true;\n      }\n    }\n    if (changed) {\n      this.emit();\n    }\n  }\n\n  subscribe(listener: (snapshot: ValidationSnapshot) => void): Unsubscribe {\n    this.listeners.add(listener);\n    return () => {\n      this.listeners.delete(listener);\n    };\n  }\n\n  getSnapshot(): ValidationSnapshot {\n    const fields: { [K in FieldKey]?: FieldValidationState } = {};\n    for (const [key, val] of this.state.entries()) {\n      fields[key] = toPublic(val);\n    }\n    return { fields, canSubmit: this.computeCanSubmit() };\n  }\n\n  private onCloverEvent(event: Event, eventType: CloverEventType, ownerKey: FieldKey): void {\n    const ev = event as unknown as Record<string, CloverFieldEventState | undefined>;\n    let changed = false;\n    for (const [cloverKey, fieldKey] of Object.entries(CLOVER_KEY_TO_FIELD_KEY)) {\n      const cloverState = ev[cloverKey];\n      if (!cloverState) {\n        continue;\n      }\n      const prev = this.state.get(fieldKey) ?? emptyFieldState();\n      const next: InternalFieldState = {\n        ...prev,\n        touched: cloverState.touched,\n        error: isMeaningfulError(cloverState.error) ? cloverState.error : undefined,\n      };\n      // Only credit the field that ACTUALLY fired the event with the\n      // \"user did something\" signal. Other fields' states in the payload are\n      // passive snapshots — they shouldn't flip hadChangeEver/hasBlurred.\n      const isOwnEvent = fieldKey === ownerKey;\n      if (isOwnEvent && eventType === 'change') {\n        next.hadChangeEver = true;\n      }\n      if (isOwnEvent && eventType === 'blur') {\n        next.hasBlurred = true;\n      }\n      // Recompute displayedError.\n      if (eventType === 'blur' || next.hasBlurred) {\n        // Either the field just blurred, or it has blurred at least once and\n        // a change is updating the live displayed error.\n        next.displayedError = computeDisplayedError(fieldKey, next, this.required);\n      } else {\n        // Pre-first-blur change → don't surface errors yet (deferred-error rule).\n        next.displayedError = undefined;\n      }\n      if (\n        prev.touched !== next.touched ||\n        prev.error !== next.error ||\n        prev.hasBlurred !== next.hasBlurred ||\n        prev.hadChangeEver !== next.hadChangeEver ||\n        prev.displayedError !== next.displayedError\n      ) {\n        this.state.set(fieldKey, next);\n        changed = true;\n      }\n    }\n    if (changed) {\n      this.emit();\n    }\n  }\n\n  private computeCanSubmit(): boolean {\n    for (const field of this.required) {\n      const s = this.state.get(field);\n      if (!s || !s.touched || s.error) {\n        return false;\n      }\n      // For cardName/cardEmail, Clover reports no error when empty (it doesn't\n      // enforce required for these). Layer our own check: require at least one\n      // change event before we'll let the form submit.\n      if (REQUIRES_NON_EMPTY_OVERRIDE.has(field) && !s.hadChangeEver) {\n        return false;\n      }\n    }\n    return true;\n  }\n\n  private emit(): void {\n    const snapshot = this.getSnapshot();\n    for (const listener of this.listeners) {\n      listener(snapshot);\n    }\n  }\n}\n\n/**\n * Decide what error string (if any) the UI should render for `fieldKey`. Runs\n * after raw state is reconciled. Returns undefined when no error should show.\n */\nfunction computeDisplayedError(\n  fieldKey: FieldKey,\n  state: InternalFieldState,\n  required: ReadonlySet<FieldKey>,\n): string | undefined {\n  if (state.error) {\n    return state.error;\n  }\n  // No Clover error reported. For cardName/cardEmail specifically — which\n  // Clover doesn't validate as required — emit \"Required\" on blur if the\n  // field is required and the user never typed.\n  if (\n    state.hasBlurred &&\n    !state.hadChangeEver &&\n    required.has(fieldKey) &&\n    REQUIRES_NON_EMPTY_OVERRIDE.has(fieldKey)\n  ) {\n    return 'Required';\n  }\n  return undefined;\n}\n","// ── Top-level orchestrator ──────────────────────────────────────\n//\n// The class hosts integrate with. Composes the loader, element registry,\n// validation machine, tokenizer, and 3DS machine into a single subscribe-able\n// state machine. The React + web-component layers sit on top of this.\n//\n// Lifecycle: construct → subscribe → mount() → tokenize() → (optional) runThreeDs() → destroy()\n//\n// Key invariants:\n// - GPay flow is \"prepare-and-wait\": when Clover fires `paymentMethod`, the SDK\n//   captures the token and enters `gpay_ready`. The host's Place Order click\n//   triggers `tokenize()`, which returns the captured token immediately.\n//   NEVER auto-submit (the form is equivalent to \"card fields filled and valid\").\n// - `tokenize()` is idempotent: calling it again after success returns the same\n//   result; calling it while in a tokenizing/submitting state will throw.\n\nimport { getBrowserInfo } from './browser-info';\nimport { loadClover, loadClover3DS } from './clover-loader';\nimport { ElementRegistry } from './element-registry';\nimport { compileTheme } from './theme';\nimport { ThreeDsMachine } from './threeds-machine';\nimport { createRateLimiter, tokenize, type RateLimiter } from './tokenize';\nimport { ValidationMachine } from './validation-machine';\nimport type {\n  CloverElement,\n  CloverInstance,\n  CloverPaymentRequestData,\n  FieldKey,\n  MountTargets,\n  PaymentFieldsConfig,\n  PaymentFieldsError,\n  PaymentFieldsErrorCode,\n  PaymentFieldsListener,\n  PaymentFieldsSnapshot,\n  ThreeDSUtil,\n  ThreeDsInterim,\n  ThreeDsResult,\n  TokenizationResult,\n  Unsubscribe,\n} from './types';\n\nconst GPAY_CANCEL_DEBOUNCE_MS = 1000;\n\n/**\n * Module-level SDK-singleton caches keyed by their natural ID.\n *\n * Why: Clover's SDK keeps internal singleton state for each\n * `new Clover(pakmsKey)` and especially each `new Clover3DS({merchantUuid})`.\n * Calling either constructor a second time on the same page produces\n * \"Instance already created, no new instance allowed.\" and (for Clover\n * itself) intermittently makes the resulting instance's `.elements()`\n * return null — the WSO-27 TypeError variant.\n *\n * This bites us because WooCommerce's classic-checkout boot replaces the\n * payment-method `<li>` block ~250ms after first render, destroying our\n * `<wcp-payment-fields>` element and instantiating a fresh one. Each\n * fresh element instance otherwise calls `new Clover()` + `new Clover3DS()`\n * from scratch.\n *\n * We do NOT cache the ElementRegistry / its CloverElements. Clover's SDK\n * also dedupes event listeners per-(element, event) and throws on a\n * duplicate `addEventListener('change', ...)` — sharing elements across\n * mounts breaks `ValidationMachine.attach()`. Each mount creates its own\n * fresh elements via `clover.elements()`; mount #1's elements just get\n * orphaned (no change from the pre-fix world).\n */\nconst cloverByPakms = new Map<string, CloverInstance>();\nconst clover3DSByMerchant = new Map<string, ThreeDSUtil>();\n\nexport class PaymentFieldsMachine {\n  /** The config the machine was constructed with. Read-only after construction. */\n  readonly config: PaymentFieldsConfig;\n  private readonly listeners = new Set<PaymentFieldsListener>();\n  private readonly rateLimiter: RateLimiter = createRateLimiter();\n  private snapshot: PaymentFieldsSnapshot = {\n    state: 'idle',\n    validation: { fields: {}, canSubmit: false },\n  };\n\n  private mounted = false;\n  private destroyed = false;\n  private clover: CloverInstance | null = null;\n  private threeDsUtil: ThreeDSUtil | null = null;\n  private registry: ElementRegistry | null = null;\n  private validation: ValidationMachine | null = null;\n  private capturedGpayToken: TokenizationResult | null = null;\n\n  constructor(config: PaymentFieldsConfig) {\n    this.config = config;\n  }\n\n  // ── public API ──\n\n  /** Subscribe to snapshot updates. The listener is called immediately with the current snapshot. */\n  subscribe(listener: PaymentFieldsListener): Unsubscribe {\n    this.listeners.add(listener);\n    listener(this.snapshot);\n    return () => {\n      this.listeners.delete(listener);\n    };\n  }\n\n  getSnapshot(): PaymentFieldsSnapshot {\n    return this.snapshot;\n  }\n\n  /**\n   * Load the Clover SDK(s), create the elements, mount them to the host's DOM\n   * targets, and wire validation + GPay event handlers. Idempotent — calling\n   * again is a no-op.\n   */\n  async mount(targets: MountTargets): Promise<void> {\n    console.log('[wcp-pf] mount() called', { targets, config: { pakmsKey: this.config.pakmsKey?.slice(0, 8) + '…', merchantId: this.config.merchantId, locale: this.config.locale, cartTotal: this.config.cartTotal, currency: this.config.currency, cloverSdkUrl: this.config.cloverSdkUrl, features: this.config.features } });\n    if (this.destroyed) {\n      throw new Error('Machine has been destroyed.');\n    }\n    if (this.mounted) {\n      console.log('[wcp-pf] already mounted, skipping');\n      return;\n    }\n\n    try {\n      const cachedClover = cloverByPakms.get(this.config.pakmsKey);\n      if (cachedClover) {\n        console.log('[wcp-pf] Clover already instantiated for this pakms — reusing');\n        this.clover = cachedClover;\n      } else {\n        console.log('[wcp-pf] loading Clover SDK from', this.config.cloverSdkUrl);\n        const CloverCtor = await loadClover(this.config.cloverSdkUrl);\n        console.log('[wcp-pf] Clover loaded, instantiating with pakms', this.config.pakmsKey?.slice(0, 8) + '…');\n        this.clover = new CloverCtor(this.config.pakmsKey);\n        this.clover.options = {\n          locale: this.config.locale,\n          merchantId: this.config.merchantId,\n        };\n        console.log('[wcp-pf] Clover instantiated', { hasElements: typeof this.clover.elements });\n        cloverByPakms.set(this.config.pakmsKey, this.clover);\n      }\n    } catch (error) {\n      console.error('[wcp-pf] Clover load/instantiate FAILED', error);\n      this.emitError('clover_load_failed', 'Failed to load Clover SDK.', error);\n      throw error;\n    }\n\n    if (this.config.features?.threeDSecure && this.config.clover3DSSdkUrl) {\n      const cached3DS = clover3DSByMerchant.get(this.config.merchantId);\n      if (cached3DS) {\n        this.threeDsUtil = cached3DS;\n      } else {\n        try {\n          const Clover3DSCtor = await loadClover3DS(this.config.clover3DSSdkUrl);\n          this.threeDsUtil = new Clover3DSCtor({ merchantUuid: this.config.merchantId });\n          clover3DSByMerchant.set(this.config.merchantId, this.threeDsUtil);\n        } catch (error) {\n          // Non-fatal — manual card flow can still work without 3DS, the API will surface the error.\n          this.emitError('clover_3ds_load_failed', '3DS SDK failed to load.', error);\n        }\n      }\n    }\n\n    const wantsGpay = this.config.features?.googlePay === true;\n    const cardholderVisible = this.shouldShowCardholderFields();\n\n    const keys: FieldKey[] = ['cardNumber', 'cardDate', 'cardCvv', 'cardPostalCode'];\n    if (cardholderVisible) {\n      keys.push('cardName', 'cardEmail');\n    }\n    if (wantsGpay) {\n      keys.push('paymentRequestButton');\n    }\n\n    const styles = compileTheme(this.config.theme);\n    const paymentRequestData = wantsGpay ? this.buildPaymentRequestData() : undefined;\n\n    console.log('[wcp-pf] creating elements for keys', keys, 'with targets', targets);\n    this.registry = new ElementRegistry({\n      clover: this.clover!,\n      styles,\n      paymentRequestData,\n    });\n    this.registry.create(keys);\n    console.log('[wcp-pf] elements created, checking targets exist in DOM:', keys.map((k) => {\n      const sel = targets[k as keyof MountTargets];\n      return { key: k, selector: sel, found: sel ? !!document.querySelector(sel) : 'no-selector' };\n    }));\n    this.registry.mount(targets);\n    console.log('[wcp-pf] registry.mount() returned');\n\n    // Validation wiring\n    const elements = new Map<FieldKey, CloverElement>();\n    for (const [k, el] of this.registry.entries()) {\n      elements.set(k, el);\n    }\n    this.validation = new ValidationMachine(keys.filter((k) => k !== 'paymentRequestButton'));\n    this.validation.attach(elements);\n    this.validation.subscribe((vs) => {\n      this.update({ validation: vs });\n    });\n\n    // GPay event wiring\n    const gpayEl = this.registry.get('paymentRequestButton');\n    if (gpayEl) {\n      this.wireGpayEvents(gpayEl);\n    }\n\n    this.mounted = true;\n  }\n\n  /**\n   * Return a tokenization result the host can POST to the API.\n   *\n   * Two paths:\n   * - **GPay**: if we're in `gpay_ready`, return the already-captured token immediately (no second prompt).\n   * - **Manual card**: call `clover.createToken()`, rate-limited.\n   *\n   * Throws on rate-limit, invalid card, missing token, or unmounted state.\n   */\n  async tokenize(): Promise<TokenizationResult> {\n    if (!this.mounted) {\n      const error: PaymentFieldsError = { code: 'not_mounted', message: 'mount() must complete before tokenize().' };\n      this.update({ state: 'error', error });\n      throw new Error(error.message);\n    }\n\n    // GPay fast path\n    if (this.snapshot.state === 'gpay_ready' && this.capturedGpayToken) {\n      const result = this.capturedGpayToken;\n      this.update({ state: 'submitting', result });\n      this.config.onTokenized?.(result);\n      return result;\n    }\n\n    if (!this.clover) {\n      const error: PaymentFieldsError = { code: 'not_mounted', message: 'Clover not initialized.' };\n      this.update({ state: 'error', error });\n      throw new Error(error.message);\n    }\n\n    this.update({ state: 'tokenizing' });\n\n    let raw;\n    try {\n      raw = await tokenize(this.clover, { rateLimiter: this.rateLimiter });\n    } catch (error) {\n      const message = (error as Error).message;\n      const code: PaymentFieldsErrorCode = message.toLowerCase().includes('rate')\n        ? 'rate_limited'\n        : 'tokenization_failed';\n      const err: PaymentFieldsError = { code, message, cause: error };\n      this.update({ state: 'error', error: err });\n      this.config.onError?.(err);\n      throw error;\n    }\n\n    if (raw.errors && hasErrors(raw.errors)) {\n      // Route Clover's per-field errors back onto each firing field so the user\n      // sees the error against the field that's actually wrong (e.g., a\n      // \"Required\" message landing on cardName when CARD_NAME comes back empty).\n      // The validation machine clears these the moment the user re-edits.\n      // Clover-side empty-vs-valid ambiguity for cardName/cardEmail means\n      // those fields may or may not appear in raw.errors when empty — we\n      // surface whatever Clover reports.\n      this.validation?.setSubmitErrors(raw.errors);\n      const err: PaymentFieldsError = {\n        code: 'tokenization_failed',\n        message: firstError(raw.errors) ?? 'Card details invalid.',\n      };\n      this.update({ state: 'error', error: err });\n      this.config.onError?.(err);\n      throw new Error(err.message);\n    }\n\n    if (!raw.token || !raw.card) {\n      const err: PaymentFieldsError = {\n        code: 'tokenization_failed',\n        message: 'Tokenization returned no token.',\n      };\n      this.update({ state: 'error', error: err });\n      this.config.onError?.(err);\n      throw new Error(err.message);\n    }\n\n    const result: TokenizationResult = {\n      source: 'card',\n      token: raw.token,\n      card: {\n        brand: raw.card.brand,\n        last4: raw.card.last4,\n        expMonth: raw.card.exp_month,\n        expYear: raw.card.exp_year,\n        first6: raw.card.first6,\n        addressZip: raw.card.address_zip,\n      },\n      browserInfo: this.config.features?.threeDSecure\n        ? getBrowserInfo(this.threeDsUtil)\n        : undefined,\n    };\n\n    this.update({ state: 'submitting', result });\n    this.config.onTokenized?.(result);\n    return result;\n  }\n\n  /**\n   * Drive the 3DS flow given an interim payload from the host's API response.\n   * Handles method/challenge dispatch, the `executePatch` callback, the\n   * finalize POST, and escalation (method ↔ challenge) internally.\n   *\n   * @param options.extraBody Host-specific fields merged into the finalize POST body.\n   *   E.g., WC passes `{ order_id, order_key, nonce }` so the WP REST endpoint\n   *   can find and update the order. Keeps WC-specific concerns out of the SDK.\n   */\n  async runThreeDs(\n    interim: ThreeDsInterim,\n    options: { readonly extraBody?: Record<string, unknown> } = {},\n  ): Promise<ThreeDsResult> {\n    if (!this.threeDsUtil) {\n      const err: PaymentFieldsError = {\n        code: 'threeds_prerequisites_missing',\n        message: '3DS SDK not loaded.',\n      };\n      this.update({ state: 'error', error: err });\n      return { kind: 'failure', message: err.message };\n    }\n\n    const finalizeUrl = this.config.endpoints?.threeDsFinalize;\n    if (!finalizeUrl) {\n      const err: PaymentFieldsError = {\n        code: 'threeds_finalize_failed',\n        message: 'No 3DS finalize URL configured.',\n      };\n      this.update({ state: 'error', error: err });\n      return { kind: 'failure', message: err.message };\n    }\n\n    this.config.onThreeDsRequired?.(interim);\n\n    const machine = new ThreeDsMachine({\n      util: this.threeDsUtil,\n      finalizeUrl,\n      headers: this.config.endpoints?.headers,\n      extraBody: options.extraBody,\n    });\n\n    let current = interim;\n    while (true) {\n      this.update({\n        state: current.state === 'method_required' ? 'threeds_method' : 'threeds_challenge',\n        threeDs: current,\n      });\n      const result = await machine.run(current);\n      if (result.kind === 'escalation') {\n        current = result.next;\n        continue;\n      }\n      if (result.kind === 'success') {\n        this.update({ state: 'done' });\n        return result;\n      }\n      const err: PaymentFieldsError = { code: 'threeds_finalize_failed', message: result.message };\n      this.update({ state: 'error', error: err });\n      this.config.onError?.(err);\n      return result;\n    }\n  }\n\n  /**\n   * Restore the form to idle, discarding any captured GPay token. Used by the\n   * \"Use card details instead\" link on the GPay-ready state.\n   */\n  resetToIdle(): void {\n    this.capturedGpayToken = null;\n    this.update({\n      state: 'idle',\n      result: undefined,\n      threeDs: undefined,\n      error: undefined,\n    });\n  }\n\n  destroy(): void {\n    this.destroyed = true;\n    this.registry?.destroy();\n    this.registry = null;\n    this.validation = null;\n    // The Clover instance and 3DS util are module-level singletons (see the\n    // cache map at the top of this file). We drop our refs but the underlying\n    // SDK objects stay alive for the next mount on this pakms key.\n    this.threeDsUtil = null;\n    this.clover = null;\n    this.capturedGpayToken = null;\n    this.listeners.clear();\n  }\n\n  // ── internals ──\n\n  private shouldShowCardholderFields(): boolean {\n    const setting = this.config.features?.cardholderFields ?? 'auto';\n    if (setting === 'always') return true;\n    if (setting === 'hidden') return false;\n    return this.config.features?.threeDSecure === true;\n  }\n\n  private buildPaymentRequestData(): CloverPaymentRequestData {\n    return {\n      paymentReqData: {\n        total: {\n          label: 'Online purchase via Clover',\n          currency: this.config.currency,\n          amount: this.config.cartTotal,\n        },\n        options: {\n          button: { buttonType: 'short' },\n        },\n      },\n    };\n  }\n\n  private wireGpayEvents(el: CloverElement): void {\n    let methodFiredForCurrentFlow = false;\n\n    el.addEventListener('paymentMethodStart', () => {\n      methodFiredForCurrentFlow = false;\n      this.capturedGpayToken = null;\n      this.update({ state: 'gpay_opening' });\n    });\n\n    el.addEventListener('paymentMethod', (ev: Event) => {\n      methodFiredForCurrentFlow = true;\n      // Clover's GPay `paymentMethod` event payload is shaped completely\n      // differently from manual-card tokenization — brand lives at\n      // `customer.billingInfo.cardNetwork` and last4 at `cardDetails`. Expiry\n      // and first6 are NOT provided by GPay.\n      const evAny = ev as unknown as {\n        token?: string;\n        customer?: {\n          email?: string;\n          billingInfo?: {\n            cardNetwork?: string;\n            cardDetails?: string;\n            billingAddress?: {\n              postalCode?: string;\n            };\n          };\n        };\n      };\n      const billing = evAny.customer?.billingInfo;\n      const brand = billing?.cardNetwork;\n      const last4 = billing?.cardDetails;\n      if (!evAny.token || !brand || !last4) {\n        const err: PaymentFieldsError = {\n          code: 'tokenization_failed',\n          message: 'Google Pay token missing required fields.',\n        };\n        this.update({ state: 'error', error: err });\n        this.config.onError?.(err);\n        return;\n      }\n      const result: TokenizationResult = {\n        source: 'google_pay',\n        token: evAny.token,\n        card: {\n          brand,\n          last4,\n          // GPay doesn't expose expMonth/expYear/first6 in the event payload.\n          addressZip: billing?.billingAddress?.postalCode,\n        },\n        browserInfo: this.config.features?.threeDSecure\n          ? getBrowserInfo(this.threeDsUtil)\n          : undefined,\n      };\n      this.capturedGpayToken = result;\n      // Critical: do NOT call onTokenized here. The host hasn't asked for the token.\n      // We hold it internally; tokenize() returns it when called from Place Order.\n      this.update({ state: 'gpay_ready', result });\n    });\n\n    el.addEventListener('paymentMethodEnd', () => {\n      // Cancellation: if `paymentMethod` never fired within the debounce window,\n      // the user closed the GPay sheet without confirming.\n      window.setTimeout(() => {\n        if (methodFiredForCurrentFlow) {\n          return;\n        }\n        if (this.snapshot.state !== 'gpay_opening') {\n          return;\n        }\n        this.update({ state: 'gpay_cancelled' });\n        window.setTimeout(() => {\n          if (this.snapshot.state === 'gpay_cancelled') {\n            this.update({ state: 'idle' });\n          }\n        }, 100);\n      }, GPAY_CANCEL_DEBOUNCE_MS);\n    });\n  }\n\n  private update(partial: Partial<PaymentFieldsSnapshot>): void {\n    this.snapshot = { ...this.snapshot, ...partial };\n    for (const listener of this.listeners) {\n      listener(this.snapshot);\n    }\n  }\n\n  private emitError(code: PaymentFieldsErrorCode, message: string, cause?: unknown): void {\n    const error: PaymentFieldsError = { code, message, cause };\n    this.update({ state: 'error', error });\n    this.config.onError?.(error);\n  }\n}\n\nfunction hasErrors(errors: Record<string, string | undefined>): boolean {\n  return Object.values(errors).some((v) => !!v);\n}\n\nfunction firstError(errors: Record<string, string | undefined>): string | undefined {\n  return Object.values(errors).find((v) => !!v);\n}\n","// ── <PaymentFields /> composite ─────────────────────────────────\n//\n// Convenience component that renders the full Design-5 layout (card-first +\n// inline GPay button + status strip + trust footer + gpay_ready state).\n// Hosts that want full control can use `usePaymentFields` directly and render\n// their own JSX.\n//\n// Renders fine in either a normal React tree (WC Blocks) or inside a Shadow\n// DOM (web-component layer renders this via createRoot(shadowRoot)).\n//\n// For lifecycle-callback notifications (onTokenized / onError / onThreeDsRequired),\n// wire them on the `config` you pass in — those fire from the machine directly,\n// so they work regardless of which layout you render.\n\nimport { useEffect, useId, useMemo, useRef, useTransition } from 'react';\nimport type {\n  FieldKey,\n  MountTargets,\n  PaymentFieldsConfig,\n  PaymentFieldsError,\n  PaymentFieldsMachine,\n  PaymentFieldsState,\n} from '../core/index';\nimport { PAYMENT_FIELDS_CSS } from './styles';\nimport { usePaymentFields, type UsePaymentFieldsReturn } from './use-payment-fields';\n\nexport interface PaymentFieldsProps {\n  /** Config to construct a machine. Exactly one of `config` or `machine` must be set. */\n  readonly config?: PaymentFieldsConfig;\n  /** Existing machine to render against (used by the web-component layer). Exactly one of `config` or `machine` must be set. */\n  readonly machine?: PaymentFieldsMachine;\n  /** URL for the trust-footer lock icon (e.g., `.../site/img/lock.svg`). */\n  readonly lockIconSrc: string;\n  /** URL for the trust-footer logos PNG (180×40 in the production asset). */\n  readonly trustLogosSrc: string;\n  /** Trust-footer wording. Defaults to \"Payment secured by\" — preserved verbatim from the WP plugin. */\n  readonly trustText?: string;\n  /**\n   * Full-control render-prop. When provided, the default layout is skipped and\n   * you render everything yourself using the returned API. Useful when the\n   * host owns the layout (e.g., WC Blocks Content component).\n   */\n  readonly children?: (api: UsePaymentFieldsReturn) => React.ReactNode;\n}\n\nexport function PaymentFields(props: PaymentFieldsProps): React.ReactElement {\n  const input = props.machine ?? props.config;\n  if (!input) {\n    throw new Error('PaymentFields requires either a `config` or a `machine` prop.');\n  }\n  const api = usePaymentFields(input);\n\n  // Stable per-instance ID prefix for mount-point selectors. Inside Shadow DOM,\n  // the selectors only need to be unique within the shadowRoot — but we prefix\n  // anyway so the same component can render multiple times on one page.\n  const reactId = useId();\n  const idPrefix = useMemo(() => `wcp-pf-${reactId.replace(/[^a-zA-Z0-9_-]/g, '')}`, [reactId]);\n\n  const targets = useMemo<MountTargets>(\n    () => ({\n      cardNumber: `#${idPrefix}-card-number`,\n      cardDate: `#${idPrefix}-card-date`,\n      cardCvv: `#${idPrefix}-card-cvv`,\n      cardPostalCode: `#${idPrefix}-card-postal-code`,\n      cardName: `#${idPrefix}-card-name`,\n      cardEmail: `#${idPrefix}-card-email`,\n      paymentRequestButton: `#${idPrefix}-payment-request-button`,\n    }),\n    [idPrefix],\n  );\n\n  // Mount once after the mount-point divs are in the DOM (first render commit).\n  const mountStarted = useRef(false);\n  useEffect(() => {\n    if (mountStarted.current) {\n      return;\n    }\n    mountStarted.current = true;\n    api.mount(targets).catch((err: unknown) => {\n      console.warn('[wcp-payment-fields] mount failed', err);\n    });\n  }, [api, targets]);\n\n  if (props.children) {\n    return <>{props.children(api)}</>;\n  }\n\n  return (\n    <DefaultLayout\n      api={api}\n      idPrefix={idPrefix}\n      lockIconSrc={props.lockIconSrc}\n      trustLogosSrc={props.trustLogosSrc}\n      trustText={props.trustText ?? 'Payment secured by'}\n      googlePayEnabled={featureFlag(props, 'googlePay')}\n      cardholderVisible={cardholderVisibility(props)}\n    />\n  );\n}\n\n// ── Default Design-5 layout ────────────────────────────────────\n\ninterface DefaultLayoutProps {\n  readonly api: UsePaymentFieldsReturn;\n  readonly idPrefix: string;\n  readonly lockIconSrc: string;\n  readonly trustLogosSrc: string;\n  readonly trustText: string;\n  readonly googlePayEnabled: boolean;\n  readonly cardholderVisible: boolean;\n}\n\nfunction DefaultLayout(props: DefaultLayoutProps) {\n  const { api, idPrefix, googlePayEnabled, cardholderVisible } = props;\n  const isGpayReady = api.state === 'gpay_ready';\n  // When GPay is ready, the card fields collapse out entirely (max-height/opacity\n  // transition). For in-progress states (tokenizing/submitting/3DS), we keep them\n  // visible but dimmed so the user can still see what they entered.\n  const isFormCollapsed = isGpayReady;\n  const isFormDimmed = !isGpayReady && isInProgress(api.state);\n  const [isPending, startTransition] = useTransition();\n\n  const onUseCard = () => {\n    startTransition(() => api.resetToIdle());\n  };\n\n  const machineConfig = api.machine.config;\n  const formattedAmount = formatAmount(\n    machineConfig.cartTotal,\n    machineConfig.currency,\n    machineConfig.locale,\n  );\n\n  return (\n    <div className=\"wcp-pf\">\n      <style>{PAYMENT_FIELDS_CSS}</style>\n\n      {!isGpayReady && (\n        <StatusStrip key={api.state} state={api.state} error={api.error} />\n      )}\n\n      {isGpayReady && api.result && (\n        <GpayReadyCard\n          brand={api.result.card.brand}\n          last4={api.result.card.last4}\n          amount={formattedAmount}\n          onUseCard={onUseCard}\n          isPending={isPending}\n        />\n      )}\n\n      <div className={`wcp-pf__form${isFormCollapsed ? ' wcp-pf__form--collapsed' : ''}${isFormDimmed ? ' wcp-pf__form--dimmed' : ''}`}>\n        {cardholderVisible && (\n          <div className=\"wcp-pf__grid-2\">\n            <FieldSlot api={api} fieldKey=\"cardName\" mountId={`${idPrefix}-card-name`} />\n            <FieldSlot api={api} fieldKey=\"cardEmail\" mountId={`${idPrefix}-card-email`} />\n          </div>\n        )}\n\n        <div className=\"wcp-pf__row\">\n          <FieldSlot api={api} fieldKey=\"cardNumber\" mountId={`${idPrefix}-card-number`} />\n        </div>\n\n        <div className=\"wcp-pf__grid-3\">\n          <FieldSlot api={api} fieldKey=\"cardDate\" mountId={`${idPrefix}-card-date`} />\n          <FieldSlot api={api} fieldKey=\"cardCvv\" mountId={`${idPrefix}-card-cvv`} />\n          <FieldSlot api={api} fieldKey=\"cardPostalCode\" mountId={`${idPrefix}-card-postal-code`} />\n        </div>\n      </div>\n\n      {googlePayEnabled && !isGpayReady && (\n        <div className=\"wcp-pf__gpay-block\">\n          <div className=\"wcp-pf__gpay-label\">Or pay instantly</div>\n          <div className=\"wcp-pf__gpay-mount\" id={`${idPrefix}-payment-request-button`} />\n        </div>\n      )}\n\n      <TrustFooter\n        lockIconSrc={props.lockIconSrc}\n        trustLogosSrc={props.trustLogosSrc}\n        trustText={props.trustText}\n      />\n    </div>\n  );\n}\n\n// ── Sub-components ─────────────────────────────────────────────\n\nfunction StatusStrip({ state, error }: { state: PaymentFieldsState; error?: PaymentFieldsError }) {\n  const message = stateMessage(state, error);\n  if (!message) {\n    return null;\n  }\n  return (\n    <div\n      className={`wcp-pf__strip wcp-pf__strip--${message.tone}`}\n      role={message.tone === 'error' ? 'alert' : 'status'}\n      aria-live={message.tone === 'error' ? undefined : 'polite'}\n    >\n      {message.icon}\n      <span>{message.text}</span>\n    </div>\n  );\n}\n\nfunction GpayReadyCard(props: {\n  brand: string;\n  last4: string;\n  amount: string;\n  onUseCard: () => void;\n  isPending: boolean;\n}) {\n  return (\n    <div className=\"wcp-pf__gpay-card\" role=\"status\">\n      <div className=\"wcp-pf__gpay-card-head\">\n        <span className=\"wcp-pf__gpay-card-check\" aria-hidden=\"true\">\n          <Checkmark />\n        </span>\n        <div className=\"wcp-pf__gpay-card-head-text\">\n          <div className=\"wcp-pf__gpay-card-title\">Google Pay is ready.</div>\n          <div className=\"wcp-pf__gpay-card-sub\">\n            Your payment is queued and runs when you submit.\n          </div>\n        </div>\n      </div>\n      <div className=\"wcp-pf__gpay-card-detail\">\n        <div className=\"wcp-pf__gpay-card-amount\">{props.amount}</div>\n        <div className=\"wcp-pf__gpay-card-info\">\n          <span className=\"wcp-pf__gpay-card-info-row\">\n            via <b>Google Pay</b>\n          </span>\n          <span className=\"wcp-pf__gpay-card-info-row\">\n            {props.brand} •••• <b>{props.last4}</b>\n          </span>\n        </div>\n      </div>\n      <p className=\"wcp-pf__gpay-card-cta\">\n        Click <b>Place Order</b> below to confirm.\n      </p>\n      <button\n        type=\"button\"\n        className=\"wcp-pf__gpay-card-switch\"\n        onClick={props.onUseCard}\n        disabled={props.isPending}\n      >\n        Pay with card instead\n      </button>\n    </div>\n  );\n}\n\nfunction formatAmount(cents: number, currency: string, locale: string): string {\n  try {\n    return new Intl.NumberFormat(locale, {\n      style: 'currency',\n      currency,\n    }).format(cents / 100);\n  } catch {\n    return `${(cents / 100).toFixed(2)} ${currency}`;\n  }\n}\n\nfunction TrustFooter(props: { lockIconSrc: string; trustLogosSrc: string; trustText: string }) {\n  return (\n    <div className=\"wcp-pf__trust\">\n      <div className=\"wcp-pf__trust-lock\">\n        <img src={props.lockIconSrc} alt=\"\" width={20} height={20} />\n      </div>\n      <div className=\"wcp-pf__trust-display\">\n        <span className=\"wcp-pf__trust-text\">{props.trustText}</span>\n        <img\n          className=\"wcp-pf__trust-logos\"\n          src={props.trustLogosSrc}\n          alt=\"Secured by Clover & WeeConnectPay\"\n          width={180}\n          height={40}\n        />\n      </div>\n    </div>\n  );\n}\n\n// ── helpers ─────────────────────────────────────────────────────\n\nfunction cardholderVisibility(props: PaymentFieldsProps): boolean {\n  const features = props.config?.features ?? props.machine?.config?.features;\n  const setting = features?.cardholderFields ?? 'auto';\n  if (setting === 'always') return true;\n  if (setting === 'hidden') return false;\n  return features?.threeDSecure === true;\n}\n\nfunction featureFlag(props: PaymentFieldsProps, flag: 'googlePay' | 'threeDSecure'): boolean {\n  const features = props.config?.features ?? props.machine?.config?.features;\n  return features?.[flag] === true;\n}\n\n/**\n * Renders a single Clover-iframe mount point with deferred error text and\n * positive (valid) confirmation.\n *\n * Wrapped in a `wcp-pf__field-slot` div so it can sit in a row/grid cell as a\n * single child while the error text flows underneath the field without\n * disrupting sibling field alignment (parent grids use `align-items: start`).\n *\n * Error visual reads `displayedError`, NOT raw `error` — so it stays neutral\n * until the user has blurred once (deferred-error rule, see ValidationMachine\n * comment block). The `--valid` green check, on the other hand, reacts\n * immediately to `touched + no error` — positive feedback is never deferred.\n */\nfunction FieldSlot(props: {\n  readonly api: UsePaymentFieldsReturn;\n  readonly fieldKey: FieldKey;\n  readonly mountId: string;\n}): React.ReactElement {\n  const field = props.api.validation.fields[props.fieldKey];\n  const displayedError = field?.displayedError;\n  // Clover doesn't distinguish empty from valid for cardName/cardEmail (see\n  // ValidationMachine comment), so we require at least one change before\n  // calling them valid — otherwise focus+blur with an empty field would draw\n  // a green check on nothing.\n  const requiresChangeForValid = props.fieldKey === 'cardName' || props.fieldKey === 'cardEmail';\n  const valid =\n    !!field?.touched &&\n    !field?.error &&\n    (!requiresChangeForValid || !!field?.hadChangeEver);\n  const fieldClass = displayedError\n    ? 'wcp-pf__field wcp-pf__field--error'\n    : valid\n      ? 'wcp-pf__field wcp-pf__field--valid'\n      : 'wcp-pf__field';\n  const showCheck = valid && props.fieldKey !== 'cardNumber';\n  return (\n    <div className=\"wcp-pf__field-slot\">\n      <div className={fieldClass} id={props.mountId}>\n        {showCheck && (\n          <span className=\"wcp-pf__field-check\" aria-hidden=\"true\">\n            <Checkmark />\n          </span>\n        )}\n      </div>\n      {displayedError && (\n        <div className=\"wcp-pf__error-text\" role=\"alert\">\n          <ErrorIcon />\n          <span>{displayedError}</span>\n        </div>\n      )}\n    </div>\n  );\n}\n\nfunction isInProgress(state: PaymentFieldsState): boolean {\n  return (\n    state === 'gpay_opening' ||\n    state === 'tokenizing' ||\n    state === 'submitting' ||\n    state === 'threeds_method' ||\n    state === 'threeds_challenge' ||\n    state === 'finalizing'\n  );\n}\n\ninterface StripMessage {\n  readonly text: string;\n  readonly tone: 'info' | 'warning' | 'success' | 'error';\n  readonly icon: React.ReactNode;\n}\n\nfunction stateMessage(state: PaymentFieldsState, error?: PaymentFieldsError): StripMessage | null {\n  switch (state) {\n    case 'idle':\n    case 'gpay_cancelled':\n      return null;\n    case 'gpay_opening':\n      return { text: 'Opening Google Pay…', tone: 'info', icon: <Spinner /> };\n    case 'gpay_ready':\n      return {\n        text: 'Google Pay ready — place your order to confirm.',\n        tone: 'success',\n        icon: <Checkmark />,\n      };\n    case 'tokenizing':\n      return { text: 'Securing card details…', tone: 'info', icon: <Spinner /> };\n    case 'submitting':\n      return { text: 'Sending payment…', tone: 'info', icon: <Spinner /> };\n    case 'threeds_method':\n      return { text: 'Preparing bank verification…', tone: 'info', icon: <Spinner /> };\n    case 'threeds_challenge':\n      return { text: 'Complete verification with your bank →', tone: 'warning', icon: <Shield /> };\n    case 'finalizing':\n      return { text: 'Confirming payment…', tone: 'info', icon: <Spinner /> };\n    case 'done':\n      return { text: 'Payment confirmed.', tone: 'success', icon: <Checkmark /> };\n    case 'error':\n      return {\n        text: error?.message ?? 'Something went wrong. Please try again.',\n        tone: 'error',\n        icon: <ErrorIcon />,\n      };\n  }\n}\n\n// ── icons ───────────────────────────────────────────────────────\n\nfunction Spinner() {\n  return <span className=\"wcp-pf__spinner\" aria-hidden=\"true\" />;\n}\nfunction Checkmark() {\n  return (\n    <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"3\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n      <polyline points=\"20 6 9 17 4 12\" />\n    </svg>\n  );\n}\nfunction Shield() {\n  return (\n    <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n      <path d=\"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z\" />\n    </svg>\n  );\n}\nfunction ErrorIcon() {\n  return (\n    <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.4\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n      <circle cx=\"12\" cy=\"12\" r=\"10\" />\n      <line x1=\"12\" y1=\"8\" x2=\"12\" y2=\"12\" />\n      <line x1=\"12\" y1=\"16\" x2=\"12.01\" y2=\"16\" />\n    </svg>\n  );\n}\n","// ── Design 5 styles, as a CSS string ────────────────────────────\n//\n// Single export — the SDK's stylesheet, exported as a plain string so it can\n// be injected into either the document (React in WC Blocks) or a shadowRoot's\n// adoptedStyleSheets (web-component layer). All class names are prefixed\n// `wcp-pf__` to avoid collision with host theme styles when used outside Shadow DOM.\n//\n// Mirrors the look of `design-previews/05-card-only-minimal.html` (post-feedback\n// version with inline GPay button + gpay_ready state).\n\nexport const PAYMENT_FIELDS_CSS = `\n.wcp-pf {\n  --wcp-green: #59B210;\n  --wcp-clover-green: #228800;\n  --wcp-warm: #c4621a;\n  --wcp-error: #d64545;\n  --wcp-focus: #4a7c6a;\n  --wcp-border: #d6d8db;\n  --wcp-border-soft: #e5e7eb;\n  --wcp-bg: #ffffff;\n  --wcp-text: #1a1d21;\n  --wcp-text-muted: #6b7280;\n  --wcp-text-soft: #8a9199;\n  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;\n  color: var(--wcp-text);\n  line-height: 1.5;\n  -webkit-font-smoothing: antialiased;\n  max-width: 480px;\n  margin: 0 auto;\n}\n\n.wcp-pf, .wcp-pf * { box-sizing: border-box; }\n\n/* ── Status strip (top of widget when state !== idle) ── */\n.wcp-pf__strip {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  padding: 10px 14px;\n  border-radius: 8px;\n  font-size: 13px;\n  font-weight: 500;\n  margin-bottom: 16px;\n  animation: wcp-pf-strip-in 240ms cubic-bezier(.2,.7,.2,1);\n}\n.wcp-pf__strip svg { flex: none; }\n.wcp-pf__strip--info {\n  background: #eef4f1;\n  color: var(--wcp-focus);\n  border: 1px solid rgba(74,124,106,0.18);\n}\n.wcp-pf__strip--warning {\n  background: #fdf5ed;\n  color: var(--wcp-warm);\n  border: 1px solid rgba(196,98,26,0.22);\n}\n.wcp-pf__strip--success {\n  background: #f1f8e8;\n  color: var(--wcp-clover-green);\n  border: 1px solid rgba(34,136,0,0.22);\n}\n.wcp-pf__strip--error {\n  background: #fbeded;\n  color: var(--wcp-error);\n  border: 1px solid rgba(214,69,69,0.22);\n}\n.wcp-pf__spinner {\n  width: 14px;\n  height: 14px;\n  border: 2px solid currentColor;\n  border-top-color: transparent;\n  border-radius: 50%;\n  animation: wcp-pf-spin 700ms linear infinite;\n  flex: none;\n  opacity: 0.7;\n}\n\n/* ── Form stack ──\n   - Idle: visible.\n   - In-progress (tokenizing/submitting/3DS): dimmed so user still sees what they entered.\n   - GPay ready: collapsed (max-height + opacity + margin → 0) so the GPay-ready\n     card stands alone. 540px is a safe ceiling — accommodates cardholder name +\n     email + the 4 card fields + per-field error text.\n*/\n.wcp-pf__form {\n  max-height: 540px;\n  overflow: hidden;\n  transition:\n    max-height 320ms cubic-bezier(.4,0,.2,1),\n    opacity 220ms ease,\n    margin 280ms ease,\n    filter 240ms ease;\n}\n.wcp-pf__form--dimmed {\n  opacity: 0.42;\n  filter: saturate(0.7);\n  pointer-events: none;\n}\n.wcp-pf__form--collapsed {\n  max-height: 0;\n  opacity: 0;\n  margin-top: 0;\n  margin-bottom: 0;\n  pointer-events: none;\n}\n\n/* ── Field rows ── */\n.wcp-pf__row { margin-bottom: 10px; }\n.wcp-pf__row:last-child { margin-bottom: 0; }\n.wcp-pf__grid-2 {\n  display: grid;\n  grid-template-columns: 1fr 1fr;\n  gap: 10px;\n  margin-bottom: 10px;\n  align-items: start;\n}\n.wcp-pf__grid-3 {\n  display: grid;\n  grid-template-columns: 1.45fr 1fr 1.1fr;\n  gap: 10px;\n  align-items: start;\n}\n/* Vertical wrapper: field (46px) + optional error text underneath. */\n.wcp-pf__field-slot {\n  display: flex;\n  flex-direction: column;\n  min-width: 0;\n}\n\n/* The host div for Clover's iframe.\n *\n * Layout strategy: the wrapper has a fixed visual height (46px) for border\n * + focus ring + theme resistance, BUT it uses flex centering so the iframe\n * is positioned by Clover's own auto-resize, not stretched to fill the wrapper.\n *\n * Clover's SDK does this internally (see sdk.js updateFrameStyles): the\n * iframe document measures its rendered content and posts {style, width,\n * height} back to the parent, which Clover then applies to the iframe element\n * inline. If we force height:100% with !important on the iframe, we override\n * Clover's measurement and force the viewport to 46px even when the iframe\n * document needs slightly more (e.g., sub-pixel rounding, focus ring inside\n * the iframe, masked-input wrappers Clover adds around the input element).\n * That is what produces the per-field scrollbars.\n *\n * Instead: let Clover size the iframe to its natural content height (the\n * input is height:46px via theme.ts), center it within our 46px wrapper\n * via flex, and clip any sub-pixel overshoot with overflow:hidden.\n */\n.wcp-pf__field {\n  width: 100%;\n  height: 46px;\n  padding: 0;\n  background: #fff;\n  border: 1.5px solid var(--wcp-border);\n  border-radius: 8px;\n  overflow: hidden;\n  transition: border-color 160ms ease, box-shadow 160ms ease;\n  cursor: text;\n  position: relative;\n  display: flex;\n  align-items: center;\n  justify-content: stretch;\n}\n.wcp-pf__field:hover { border-color: #b9bcc1; }\n/* :focus-within bubbles focus across iframe boundaries in modern browsers,\n   which is how we get a focus ring on the wrapper when the user clicks into\n   the Clover-rendered input inside the cross-origin iframe. */\n.wcp-pf__field:focus-within,\n.wcp-pf__field--focused {\n  border-color: var(--wcp-focus);\n  box-shadow: 0 0 0 3px rgba(74,124,106,0.08);\n}\n.wcp-pf__field--error {\n  border-color: var(--wcp-error);\n  box-shadow: 0 0 0 3px rgba(214,69,69,0.08);\n  animation: wcp-pf-shake 360ms cubic-bezier(.36,.07,.19,.97);\n}\n/* Touched + no error → positive visual confirmation. The error state's\n   counterpart so the user can see \"yes, this is accepted\" without needing\n   to read the form. Border + ring use Clover's accent green. */\n.wcp-pf__field--valid {\n  border-color: var(--wcp-clover-green);\n  box-shadow: 0 0 0 3px rgba(34,136,0,0.08);\n}\n.wcp-pf__field-check {\n  position: absolute;\n  top: 50%;\n  right: 10px;\n  transform: translateY(-50%);\n  width: 18px;\n  height: 18px;\n  border-radius: 50%;\n  background: var(--wcp-clover-green);\n  color: #fff;\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  pointer-events: none;\n  animation: wcp-pf-pop 240ms cubic-bezier(.2,.7,.2,1);\n}\n.wcp-pf__field-check svg { display: block; }\n/* No !important on height — let Clover's updateFrameStyles set the iframe\n   height to the measured content size. Width is !important because Clover\n   sets width:100% inline at creation and we don't want themes overriding.\n   scrolling=\"no\" is set programmatically in element-registry.ts after\n   mount — this is the only fully-reliable way to suppress the cross-origin\n   iframe overlay scrollbar (CSS overflow on iframes is browser-spotty). */\n.wcp-pf__field iframe {\n  width: 100% !important;\n  border: 0 !important;\n  display: block !important;\n  background: transparent !important;\n  flex: 0 0 auto;\n  overflow: hidden;\n}\n.wcp-pf__error-text {\n  font-size: 12px;\n  color: var(--wcp-error);\n  margin-top: 6px;\n  display: flex;\n  align-items: center;\n  gap: 5px;\n}\n.wcp-pf__error-text svg { flex: none; }\n\n/* ── GPay block (Clover iframe lives in .wcp-pf__gpay-mount) ──\n * The \"Or pay instantly\" label provides its own horizontal rule via the\n * ::before / ::after pseudo-elements below. The block itself must NOT add\n * a second border-top — two stacked rules read as an extra empty line.\n */\n.wcp-pf__gpay-block {\n  margin-top: 18px;\n}\n.wcp-pf__gpay-label {\n  display: flex;\n  align-items: center;\n  gap: 12px;\n  color: var(--wcp-text-soft);\n  font-size: 12px;\n  margin-bottom: 12px;\n}\n.wcp-pf__gpay-label::before, .wcp-pf__gpay-label::after {\n  content: \"\";\n  flex: 1;\n  height: 1px;\n  background: var(--wcp-border-soft);\n}\n/* The host div for Clover's PAYMENT_REQUEST_BUTTON iframe. Constrain it the\n   same way the legacy PaymentFields.php template did (inline style at line 167:\n   width:100%; max-width:200px; margin:0 auto; height:50px). Without this,\n   the iframe expands to its container's full width. */\n.wcp-pf__gpay-mount {\n  width: 100%;\n  max-width: 240px;\n  height: 48px;\n  margin: 0 auto;\n  overflow: hidden;\n}\n.wcp-pf__gpay-mount iframe {\n  width: 100% !important;\n  height: 100% !important;\n  min-height: 40px !important;\n  min-width: 90px !important;\n  border: 0 !important;\n  display: block !important;\n}\n\n/* ── GPay-ready card (Variation 1: refined receipt-card) ──\n   Single unified card; amount is the dominant element. Replaces the previous\n   \"ready strip + details card + greyed fields\" triplet. Card fields collapse\n   out via .wcp-pf__form--collapsed so this card stands alone.\n*/\n.wcp-pf__gpay-card {\n  background: #ffffff;\n  border: 1px solid var(--wcp-border-soft);\n  border-radius: 12px;\n  padding: 22px 22px 18px;\n  margin-bottom: 10px;\n  box-shadow: 0 1px 2px rgba(20, 20, 40, 0.04);\n  animation: wcp-pf-rise 360ms cubic-bezier(.2,.7,.2,1);\n}\n.wcp-pf__gpay-card-head {\n  display: flex;\n  align-items: flex-start;\n  gap: 12px;\n  margin-bottom: 18px;\n}\n.wcp-pf__gpay-card-check {\n  width: 28px;\n  height: 28px;\n  border-radius: 50%;\n  background: var(--wcp-clover-green);\n  color: #fff;\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  flex: none;\n  box-shadow: 0 0 0 4px #ecfdf5;\n}\n.wcp-pf__gpay-card-check svg { width: 14px; height: 14px; }\n.wcp-pf__gpay-card-head-text { flex: 1; min-width: 0; }\n.wcp-pf__gpay-card-title {\n  font-size: 15px;\n  font-weight: 600;\n  color: var(--wcp-text);\n  line-height: 1.3;\n}\n.wcp-pf__gpay-card-sub {\n  font-size: 12.5px;\n  color: var(--wcp-text-muted);\n  margin-top: 2px;\n  line-height: 1.4;\n}\n.wcp-pf__gpay-card-detail {\n  display: flex;\n  align-items: baseline;\n  justify-content: space-between;\n  gap: 14px;\n  padding-bottom: 14px;\n  border-bottom: 1px dashed var(--wcp-border-soft);\n  margin-bottom: 14px;\n}\n.wcp-pf__gpay-card-amount {\n  font-size: 32px;\n  font-weight: 600;\n  color: var(--wcp-text);\n  letter-spacing: -0.02em;\n  line-height: 1;\n  font-variant-numeric: tabular-nums;\n}\n.wcp-pf__gpay-card-info {\n  font-size: 11px;\n  color: var(--wcp-text-muted);\n  text-transform: uppercase;\n  letter-spacing: 0.06em;\n  text-align: right;\n  line-height: 1.5;\n}\n.wcp-pf__gpay-card-info-row { display: block; }\n.wcp-pf__gpay-card-info b {\n  font-weight: 700;\n  color: var(--wcp-text);\n}\n.wcp-pf__gpay-card-cta {\n  font-size: 13px;\n  color: var(--wcp-text-muted);\n  margin: 0;\n  line-height: 1.5;\n}\n.wcp-pf__gpay-card-cta b {\n  color: var(--wcp-text);\n  font-weight: 600;\n}\n.wcp-pf__gpay-card-switch {\n  display: inline-block;\n  margin-top: 8px;\n  padding: 0;\n  font: inherit;\n  font-size: 12.5px;\n  color: var(--wcp-text-muted);\n  background: transparent;\n  border: none;\n  text-decoration: underline;\n  text-decoration-color: var(--wcp-text-soft);\n  text-underline-offset: 3px;\n  cursor: pointer;\n  transition: color 140ms ease;\n}\n.wcp-pf__gpay-card-switch:hover { color: var(--wcp-text); }\n.wcp-pf__gpay-card-switch:disabled {\n  cursor: default;\n  opacity: 0.55;\n}\n\n/* ── Trust footer (mirrors WP-classic CSS at lines 140-167) ── */\n.wcp-pf__trust {\n  margin-top: 22px;\n  padding-top: 16px;\n  border-top: 1px solid var(--wcp-border-soft);\n  display: flex;\n  align-items: center;\n  justify-content: center;\n}\n.wcp-pf__trust-lock {\n  padding-right: 10px;\n  flex: none;\n  display: flex;\n}\n.wcp-pf__trust-lock img { display: block; width: 20px; height: 20px; }\n.wcp-pf__trust-display {\n  display: flex;\n  align-items: center;\n  flex-wrap: wrap;\n  justify-content: space-around;\n  min-width: 180px;\n  gap: 4px 0;\n}\n.wcp-pf__trust-text {\n  white-space: nowrap;\n  padding-right: 5px;\n  font-size: 12.5px;\n  color: #4a4a4a;\n  font-weight: 500;\n}\n.wcp-pf__trust-logos {\n  vertical-align: middle;\n  margin: 0;\n  display: block;\n  height: auto;\n  max-width: 100%;\n}\n\n/* ── Animations ── */\n@keyframes wcp-pf-spin { to { transform: rotate(360deg); } }\n@keyframes wcp-pf-strip-in {\n  from { opacity: 0; transform: translateY(-6px); }\n  to { opacity: 1; transform: none; }\n}\n@keyframes wcp-pf-rise {\n  from { opacity: 0; transform: translateY(6px); }\n  to { opacity: 1; transform: none; }\n}\n@keyframes wcp-pf-shake {\n  10%, 90% { transform: translate3d(-1px, 0, 0); }\n  20%, 80% { transform: translate3d(2px, 0, 0); }\n  30%, 50%, 70% { transform: translate3d(-3px, 0, 0); }\n  40%, 60% { transform: translate3d(3px, 0, 0); }\n}\n@keyframes wcp-pf-pop {\n  from { opacity: 0; transform: translateY(-50%) scale(0.6); }\n  to   { opacity: 1; transform: translateY(-50%) scale(1); }\n}\n@media (prefers-reduced-motion: reduce) {\n  .wcp-pf__strip, .wcp-pf__gpay-ready, .wcp-pf__field { animation: none; }\n  .wcp-pf__spinner { animation-duration: 1.4s; }\n}\n`;\n"],"mappings":";;;;;;;;;;;;;;;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