@alfadocs/ui-kit-debug 0.39.0 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ import { forwardRef as ie, useId as oe, useMemo as M, useRef as k, useState as b
3
3
  import { c as i } from "./index-D2ZczOXr.js";
4
4
  import { useTranslation as ce } from "react-i18next";
5
5
  import { P as le } from "./pdf-viewer-Cy6Ul3hZ.js";
6
- import { S as ge } from "./signature-capture-BRzCklg4.js";
6
+ import { S as ge } from "./signature-capture-DoiBd6i3.js";
7
7
  import { u as me } from "./registry-nPAVE19X.js";
8
8
  import { C as O } from "./circle-check-9AeSgJD_.js";
9
9
  const ue = {
@@ -78,14 +78,15 @@ const ue = {
78
78
  ].join(" ")
79
79
  ), xe = i(
80
80
  [
81
- "ds:inline-flex ds:items-center ds:justify-center ds:self-start",
81
+ "ds:inline-flex ds:inline-size-full ds:items-center ds:justify-center",
82
82
  "ds:min-block-size-[var(--min-target-size)]",
83
83
  "ds:min-inline-size-[var(--min-target-size)]",
84
84
  "ds:gap-[var(--spacing-xs)]",
85
85
  "ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)]",
86
+ "ds:pt-[var(--spacing-md)] ds:pb-[var(--spacing-md)]",
86
87
  "ds:rounded-[var(--radius-sm)]",
87
88
  "ds:bg-[var(--primary)] ds:text-[var(--primary-foreground)]",
88
- "ds:text-[length:var(--font-size-sm)] ds:font-medium",
89
+ "ds:text-[length:var(--font-size-base)] ds:font-medium",
89
90
  "ds:transition-colors ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none",
90
91
  "ds:hover:bg-[var(--primary-hover)]",
91
92
  "ds:focus-visible:outline-[length:var(--focus-ring-width)]",
@@ -133,9 +134,9 @@ const Se = ie(
133
134
  ariaLabel: N,
134
135
  className: G
135
136
  }, J) => {
136
- const { t: s, i18n: V } = ce(), z = oe(), u = M(
137
- () => `sign-doc-${z.replace(/[^a-zA-Z0-9-_]/g, "")}`,
138
- [z]
137
+ const { t: s, i18n: z } = ce(), V = oe(), u = M(
138
+ () => `sign-doc-${V.replace(/[^a-zA-Z0-9-_]/g, "")}`,
139
+ [V]
139
140
  ), R = `${u}-doc-heading`, H = `${u}-sign-label`, Q = `${u}-live`, C = `${u}-gate-hint`, p = k(null), [E, w] = b(0), [U, $] = b(1), [W, j] = b(!1), [T, l] = b(!1), g = x != null, X = D || S || g, f = k(h), v = k(y);
140
141
  L(() => {
141
142
  f.current = h, v.current = y;
@@ -182,7 +183,7 @@ const Se = ie(
182
183
  );
183
184
  de(J, () => P, [P]), me(ue, P, n);
184
185
  const ne = N ?? (a ? s("signDocument.regionLabelNamed", { title: a }) : s("signDocument.regionLabel")), ae = a ?? s("signDocument.documentLabel"), te = g ? s("signDocument.signedOn", {
185
- date: Z(x, V.language)
186
+ date: Z(x, z.language)
186
187
  }) : o ? s("signDocument.readyToSign") : "", re = o ? T ? "" : s("signDocument.signToEnable") : s("signDocument.scrollToEnd");
187
188
  return /* @__PURE__ */ d(
188
189
  "div",
@@ -239,7 +240,7 @@ const Se = ie(
239
240
  /* @__PURE__ */ r("strong", { className: "ds:font-semibold", children: s("signDocument.signed") }),
240
241
  " — ",
241
242
  s("signDocument.signedOn", {
242
- date: Z(x, V.language)
243
+ date: Z(x, z.language)
243
244
  })
244
245
  ] })
245
246
  ]
@@ -312,4 +313,4 @@ export {
312
313
  Se as S,
313
314
  ue as s
314
315
  };
315
- //# sourceMappingURL=sign-document-DId1p-nn.js.map
316
+ //# sourceMappingURL=sign-document-CpLDZ6Db.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sign-document-CpLDZ6Db.js","sources":["../../src/components/sign-document/sign-document.agent.ts","../../src/components/sign-document/sign-document.tsx"],"sourcesContent":["/* -------------------------------------------------------------------- */\n/* Agent adapter — SignDocument. */\n/* */\n/* State exposes only structural lifecycle info — never the signature */\n/* bytes (the signed consent is sensitive; persistence is the consumer's */\n/* concern). The single write action confirms the captured signature. */\n/* */\n/* See `src/docs/26-agent-readiness.mdx` for the contract. */\n/* -------------------------------------------------------------------- */\n\nimport type { AgentAdapter } from '../../agent/types';\nimport type { SignDocumentHandle } from './sign-document';\n\nexport const signDocumentAgent: AgentAdapter<SignDocumentHandle> = {\n id: 'sign-document',\n capabilities: ['submit'],\n state: {\n isReadComplete: {\n type: 'boolean',\n descriptionKey: 'signDocument.agent.state.isReadComplete',\n description:\n 'True when the reader has reached the last page (or read-gating is off).',\n read: (handle) => handle.isReadComplete(),\n },\n },\n actions: {\n submit: {\n safety: 'write',\n descriptionKey: 'signDocument.agent.actions.confirm',\n description:\n 'Confirm the current signature, emitting it via onSign. No-op if unsigned.',\n invoke: (handle) => handle.confirm(),\n },\n reset: {\n safety: 'destructive',\n descriptionKey: 'signDocument.agent.actions.reset',\n description: 'Clear the captured signature and return to unsigned.',\n invoke: (handle) => {\n handle.reset();\n },\n },\n },\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'sign-document',\n description: 'Marks the SignDocument wrapper.',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description: 'Sourced from the id prop.',\n },\n },\n};\n","/* ------------------------------------------------------------------ */\n/* SignDocument — review a PDF document, then sign it. */\n/* */\n/* Fills the kit gap where consumers hand-composed PDFViewer + */\n/* SignatureCapture for consents (e.g. sign.alfadocs.com, HTP-4889). */\n/* This component owns the composition and the read-gate so the consent */\n/* flow is a single primitive: */\n/* */\n/* - PDFViewer (the document) renders above; the signing surface */\n/* renders below. */\n/* - When `requireReadToEnd` (default), the SignatureCapture pad and */\n/* the \"Confirm & sign\" button are gated until the reader reaches the */\n/* LAST page. We track this via PDFViewer's onLoadComplete (numPages) */\n/* + onPageChange (currentPage === numPages). NOTE: last-page-reached */\n/* is an APPROXIMATE read signal — a fit-page zoom can show the last */\n/* page without scrolling. That is acceptable for this gate; a */\n/* legal-grade \"read every page\" guarantee is the consumer's call. */\n/* - When `signedAt` is set the component renders an already-signed */\n/* read-only state (no pad) so re-sign-on-change consumers can show */\n/* signed status. */\n/* - Security: no fetch / XHR / storage / globals here. SignatureCapture */\n/* owns the export payload (PNG/SVG + sha256); the consumer owns */\n/* persistence via onSign. */\n/* - i18n: every authored string via `t('signDocument.*')` (bare keys */\n/* under the `ui` namespace). PDFViewer's `pdf.*` and */\n/* SignatureCapture's `signature.*` strings already exist. */\n/* ------------------------------------------------------------------ */\n\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { cva } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { CheckCircle2 } from 'lucide-react';\nimport { PDFViewer } from '../pdf-viewer';\nimport {\n SignatureCapture,\n type SignatureCaptureHandle,\n type SignatureConfirmPayload,\n} from '../signature-capture';\nimport { useAgentRegistration } from '../../agent';\nimport { signDocumentAgent } from './sign-document.agent';\n\n/* ------------------------------------------------------------------ */\n/* Public types */\n/* ------------------------------------------------------------------ */\n\nexport interface SignDocumentProps {\n /** Opaque instance id — emitted as `data-component-id` for the agent registry. */\n id?: string;\n /** Document PDF — URL string, ArrayBuffer, or Uint8Array. Passed to PDFViewer. */\n src: string | ArrayBuffer | Uint8Array;\n /** Accessible name for the document region (also used as a heading). */\n documentTitle?: string;\n /**\n * Gate the signature + Confirm until the reader reaches the last page.\n * Default `true`. Last-page-reached is an approximate read signal (a\n * fit-page zoom can show the last page without scrolling) — adequate for\n * this gate; legal-grade read tracking is the consumer's concern.\n */\n requireReadToEnd?: boolean;\n /** Fired when the user captures a signature AND confirms. */\n onSign?: (payload: SignatureConfirmPayload) => void;\n /** Forwarded from PDFViewer on any load / render error. */\n onError?: (error: Error) => void;\n /**\n * When set, render the already-signed read-only state: shows \"Signed\" +\n * the signed date and hides the pad. Use for re-sign-on-change consumers\n * that surface signed status. `null` / `undefined` → unsigned.\n */\n signedAt?: string | null;\n /** Disable all controls (document still readable). */\n disabled?: boolean;\n /** Render read-only: the document is shown but the pad is suppressed. */\n readOnly?: boolean;\n /** Accessible label for the component's group region. */\n ariaLabel?: string;\n /** Extra class names merged onto the outermost wrapper. */\n className?: string;\n}\n\n/** Curated imperative handle for agent / external automation. */\nexport interface SignDocumentHandle {\n /** Clear the captured signature, returning to the unsigned state. */\n reset: () => void;\n /** Confirm the current signature; resolves the payload, or null if unsigned. */\n confirm: () => Promise<SignatureConfirmPayload | null>;\n /** True when the reader has reached the last page (or the gate is off). */\n isReadComplete: () => boolean;\n}\n\n/* ------------------------------------------------------------------ */\n/* CVA */\n/* ------------------------------------------------------------------ */\n\nconst rootVariants = cva(\n [\n 'ds:flex ds:flex-col ds:gap-[var(--spacing-md)]',\n 'ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--card-border)]',\n 'ds:shadow-[var(--shadow-card)] ds:[.theme-accessible_&]:border-2',\n 'ds:bg-[var(--background)] ds:text-[var(--foreground)]',\n 'ds:p-[var(--spacing-md)]',\n 'ds:aria-disabled:opacity-[var(--opacity-50)] ds:aria-disabled:cursor-not-allowed',\n ].join(' '),\n);\n\nconst headingVariants = cva(\n ['type-heading-sm ds:text-[var(--foreground)]'].join(' '),\n);\n\nconst signSectionVariants = cva(\n ['ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]'].join(' '),\n);\n\nconst sectionLabelVariants = cva(\n ['type-body-sm ds:font-medium ds:text-[var(--foreground)]'].join(' '),\n);\n\nconst progressVariants = cva(\n [\n 'ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]',\n 'type-body-sm ds:text-[var(--muted-foreground)]',\n ].join(' '),\n);\n\n// The \"scroll to the end to sign\" hint uses --info as a low-emphasis\n// informational tint — tokenised, logical-property insets, no accent over\n// arbitrary content.\nconst hintVariants = cva(\n [\n 'ds:flex ds:items-center ds:gap-[var(--spacing-xs)]',\n 'type-body-sm',\n 'ds:rounded-[var(--radius-sm)]',\n 'ds:ps-[var(--spacing-sm)] ds:pe-[var(--spacing-sm)]',\n 'ds:pt-[var(--spacing-xs)] ds:pb-[var(--spacing-xs)]',\n 'ds:bg-[color-mix(in_srgb,var(--info)_10%,transparent)]',\n 'ds:text-[var(--foreground)]',\n 'ds:border ds:border-[color:color-mix(in_srgb,var(--info)_40%,transparent)]',\n ].join(' '),\n);\n\nconst confirmButtonVariants = cva(\n [\n 'ds:inline-flex ds:inline-size-full ds:items-center ds:justify-center',\n 'ds:min-block-size-[var(--min-target-size)]',\n 'ds:min-inline-size-[var(--min-target-size)]',\n 'ds:gap-[var(--spacing-xs)]',\n 'ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)]',\n 'ds:pt-[var(--spacing-md)] ds:pb-[var(--spacing-md)]',\n 'ds:rounded-[var(--radius-sm)]',\n 'ds:bg-[var(--primary)] ds:text-[var(--primary-foreground)]',\n 'ds:text-[length:var(--font-size-base)] ds:font-medium',\n 'ds:transition-colors ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none',\n 'ds:hover:bg-[var(--primary-hover)]',\n 'ds:focus-visible:outline-[length:var(--focus-ring-width)]',\n 'ds:focus-visible:outline-solid',\n 'ds:focus-visible:outline-[var(--ring)]',\n 'ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]',\n 'ds:forced-colors:focus-visible:outline-[CanvasText]',\n 'ds:disabled:opacity-[var(--opacity-50)] ds:disabled:cursor-not-allowed',\n 'ds:disabled:hover:bg-[var(--primary)]',\n ].join(' '),\n);\n\n// The signed banner uses the semantic --success alias for the confirmed\n// state — never the raw ramp step (constraint §11).\nconst signedBannerVariants = cva(\n [\n 'ds:flex ds:items-center ds:gap-[var(--spacing-sm)]',\n 'ds:rounded-[var(--radius-sm)]',\n 'ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)]',\n 'ds:pt-[var(--spacing-sm)] ds:pb-[var(--spacing-sm)]',\n 'ds:bg-[color-mix(in_srgb,var(--success)_12%,transparent)]',\n 'ds:text-[var(--foreground)]',\n 'ds:border ds:border-[color:color-mix(in_srgb,var(--success)_45%,transparent)]',\n ].join(' '),\n);\n\n/* ------------------------------------------------------------------ */\n/* Helpers */\n/* ------------------------------------------------------------------ */\n\n/**\n * Format an ISO timestamp using the active i18n locale. Falls back to the\n * raw string if it can't be parsed so a malformed `signedAt` never throws.\n */\nfunction formatSignedAt(iso: string, locale: string): string {\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return iso;\n try {\n return new Intl.DateTimeFormat(locale, {\n dateStyle: 'long',\n timeStyle: 'short',\n }).format(date);\n } catch {\n return date.toISOString();\n }\n}\n\n/* ------------------------------------------------------------------ */\n/* SignDocument */\n/* ------------------------------------------------------------------ */\n\nexport const SignDocument = forwardRef<SignDocumentHandle, SignDocumentProps>(\n (\n {\n id,\n src,\n documentTitle,\n requireReadToEnd = true,\n onSign,\n onError,\n signedAt = null,\n disabled = false,\n readOnly = false,\n ariaLabel,\n className,\n },\n ref,\n ) => {\n const { t, i18n } = useTranslation();\n const rawId = useId();\n const idSafe = useMemo(\n () => `sign-doc-${rawId.replace(/[^a-zA-Z0-9-_]/g, '')}`,\n [rawId],\n );\n const docHeadingId = `${idSafe}-doc-heading`;\n const signLabelId = `${idSafe}-sign-label`;\n const liveRegionId = `${idSafe}-live`;\n // Stable, static describedby target for the sign section + Confirm —\n // kept separate from the polite live region so describedby points at\n // unchanging text, not the transition announcer (which only carries\n // gate-met / signed announcements).\n const gateHintId = `${idSafe}-gate-hint`;\n\n const signatureRef = useRef<SignatureCaptureHandle>(null);\n\n const [numPages, setNumPages] = useState(0);\n const [currentPage, setCurrentPage] = useState(1);\n // True once the reader has reached the last page at least once. Sticky:\n // scrolling back up does not re-lock the signature.\n const [reachedEnd, setReachedEnd] = useState(false);\n // Mirrors the pad's ink state so the Confirm button re-renders when a\n // signature lands. SignatureCapture's isEmpty() is a sync ref read (no\n // re-render) and its onStart only fires on a DRAWN stroke — not on the\n // typed fallback. We poll the handle so both paths gate Confirm\n // identically; onStart/onClear below are immediate-feedback hints.\n const [hasSignature, setHasSignature] = useState(false);\n\n const isSigned = signedAt != null;\n const inert = disabled || readOnly || isSigned;\n\n // Latest callbacks via refs so the async confirm path never closes over\n // a stale prop.\n const onSignRef = useRef(onSign);\n const onErrorRef = useRef(onError);\n useEffect(() => {\n onSignRef.current = onSign;\n onErrorRef.current = onError;\n }, [onSign, onError]);\n\n /* ---- Per-document reset -------------------------------------- */\n // When the consumer swaps `src` to a NEW document, the previous \"read\n // complete\" state must NOT carry over — otherwise the new document\n // could be signed without being read. Reset the per-document state;\n // PDFViewer's onLoadComplete re-sets reachedEnd for single-page docs.\n useEffect(() => {\n setReachedEnd(false);\n setNumPages(0);\n setCurrentPage(1);\n setHasSignature(false);\n }, [src]);\n\n /* ---- Read-gate tracking -------------------------------------- */\n const handleLoadComplete = useCallback(\n (info: { numPages: number; title?: string }) => {\n setNumPages(info.numPages);\n // A single-page document is \"read to the end\" the moment it loads.\n if (info.numPages <= 1) setReachedEnd(true);\n },\n [],\n );\n\n const handlePageChange = useCallback((page: number) => {\n setCurrentPage(page);\n setNumPages((total) => {\n if (total > 0 && page >= total) setReachedEnd(true);\n return total;\n });\n }, []);\n\n const handleError = useCallback((error: Error) => {\n onErrorRef.current?.(error);\n }, []);\n\n /* ---- Signature-presence polling ------------------------------ */\n // Poll the pad's isEmpty() while the signing surface is live so the\n // Confirm button reflects both drawn AND typed signatures. Cheap\n // (a single boolean ref read on an interval); torn down when signed,\n // read-only, or unmounted.\n const signLive = !isSigned && !readOnly;\n useEffect(() => {\n if (!signLive) return undefined;\n const tick = (): void => {\n const pad = signatureRef.current;\n if (!pad) return;\n setHasSignature(!pad.isEmpty());\n };\n tick();\n const interval = window.setInterval(tick, 200);\n return () => window.clearInterval(interval);\n }, [signLive]);\n\n // The gate is satisfied when reading isn't required, or the reader has\n // reached the last page at least once.\n const readComplete = !requireReadToEnd || reachedEnd;\n const canSign = !inert && readComplete;\n const confirmDisabled = !canSign || !hasSignature;\n\n /* ---- Confirm path -------------------------------------------- */\n // `onSign` fires from SignatureCapture's `onConfirm` (wired below) — the\n // single source of truth, so it fires once whether the user clicks the\n // pad's own Confirm or this component's \"Confirm & sign\". This handle\n // just proxies the pad's confirm() and returns its payload.\n const handleSigned = useCallback((payload: SignatureConfirmPayload) => {\n onSignRef.current?.(payload);\n }, []);\n\n const confirm =\n useCallback(async (): Promise<SignatureConfirmPayload | null> => {\n const pad = signatureRef.current;\n if (!pad) return null;\n return pad.confirm();\n }, []);\n\n const reset = useCallback(() => {\n signatureRef.current?.clear();\n setHasSignature(false);\n }, []);\n\n /* ---- Imperative handle + agent registration ------------------ */\n const agentHandle = useMemo<SignDocumentHandle>(\n () => ({\n reset,\n confirm,\n isReadComplete: () => readComplete,\n }),\n [reset, confirm, readComplete],\n );\n useImperativeHandle(ref, () => agentHandle, [agentHandle]);\n useAgentRegistration(signDocumentAgent, agentHandle, id);\n\n /* ---- Derived strings ----------------------------------------- */\n const regionLabel =\n ariaLabel ??\n (documentTitle\n ? t('signDocument.regionLabelNamed', { title: documentTitle })\n : t('signDocument.regionLabel'));\n const documentRegionLabel =\n documentTitle ?? t('signDocument.documentLabel');\n\n // Live region — ONLY transition announcements (gate met / signed).\n const liveText = isSigned\n ? t('signDocument.signedOn', {\n date: formatSignedAt(signedAt as string, i18n.language),\n })\n : readComplete\n ? t('signDocument.readyToSign')\n : '';\n\n // Static describedby target — always names WHY Confirm is unavailable\n // (or stays empty when it's actionable). Stable text, never live.\n const gateHintText = !readComplete\n ? t('signDocument.scrollToEnd')\n : !hasSignature\n ? t('signDocument.signToEnable')\n : '';\n\n return (\n <div\n role=\"group\"\n // Prefer labelling by the visible heading so the visible + accessible\n // names match; fall back to aria-label only when there's no heading.\n aria-labelledby={!ariaLabel && documentTitle ? docHeadingId : undefined}\n aria-label={ariaLabel || !documentTitle ? regionLabel : undefined}\n aria-disabled={disabled || undefined}\n className={[rootVariants(), className].filter(Boolean).join(' ')}\n data-component=\"sign-document\"\n data-component-id={id}\n data-signed={isSigned || undefined}\n >\n {/* Polite live region — ONLY transition announcements (gate met /\n signed). Static describedby text lives in the gate-hint span. */}\n <span\n role=\"status\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n className=\"ds:sr-only\"\n data-testid=\"sign-document-live\"\n id={liveRegionId}\n >\n {liveText}\n </span>\n\n {/* Static, non-live describedby target for the sign group + Confirm:\n names why Confirm is unavailable (or empty when actionable). */}\n <span className=\"ds:sr-only\" id={gateHintId}>\n {gateHintText}\n </span>\n\n {documentTitle ? (\n <h2 id={docHeadingId} className={headingVariants()}>\n {documentTitle}\n </h2>\n ) : null}\n\n {/* The document. PDFViewer owns its own toolbar, a11y, and zoom. */}\n <PDFViewer\n src={src}\n ariaLabel={documentRegionLabel}\n onLoadComplete={handleLoadComplete}\n onPageChange={handlePageChange}\n onError={handleError}\n />\n\n {isSigned ? (\n /* ---- Already-signed, read-only ---- */\n <div\n className={signedBannerVariants()}\n data-testid=\"sign-document-signed\"\n >\n <CheckCircle2\n aria-hidden=\"true\"\n className=\"ds:size-5 ds:text-[var(--success)] ds:shrink-0\"\n />\n <span className=\"type-body-sm\">\n <strong className=\"ds:font-semibold\">\n {t('signDocument.signed')}\n </strong>\n {' — '}\n {t('signDocument.signedOn', {\n date: formatSignedAt(signedAt as string, i18n.language),\n })}\n </span>\n </div>\n ) : readOnly ? null : (\n /* ---- Sign surface ---- */\n <div\n className={signSectionVariants()}\n role=\"group\"\n aria-labelledby={signLabelId}\n aria-describedby={gateHintId}\n >\n <div className=\"ds:flex ds:flex-wrap ds:items-center ds:justify-between ds:gap-[var(--spacing-sm)]\">\n <span id={signLabelId} className={sectionLabelVariants()}>\n {t('signDocument.signatureSection')}\n </span>\n {numPages > 0 ? (\n <span\n className={progressVariants()}\n data-testid=\"sign-document-progress\"\n >\n {t('signDocument.pageProgress', {\n current: currentPage,\n total: numPages,\n })}\n </span>\n ) : null}\n </div>\n\n {requireReadToEnd && !readComplete ? (\n <p className={hintVariants()} data-testid=\"sign-document-hint\">\n {t('signDocument.scrollToEnd')}\n </p>\n ) : null}\n\n {/* The pad is always mounted so a keyboard user can prepare a\n typed signature; the Confirm button is the gate. When the\n read-gate is unmet the pad is disabled so it can't accept\n ink prematurely. */}\n <SignatureCapture\n ref={signatureRef}\n ariaLabel={t('signDocument.signatureSection')}\n disabled={disabled || !readComplete}\n onStart={() => setHasSignature(true)}\n onClear={() => setHasSignature(false)}\n onConfirm={handleSigned}\n />\n\n {/* Native `disabled` (not aria-disabled) so a gated Confirm\n leaves the tab order entirely — mirrors how Button gates a\n primary action. describedby names WHY it's unavailable. */}\n <button\n type=\"button\"\n onClick={() => {\n if (confirmDisabled) return;\n void confirm();\n }}\n disabled={confirmDisabled}\n aria-describedby={gateHintId}\n className={confirmButtonVariants()}\n data-testid=\"sign-document-confirm\"\n >\n <CheckCircle2 aria-hidden=\"true\" className=\"ds:size-4\" />\n {t('signDocument.confirm')}\n </button>\n </div>\n )}\n </div>\n );\n },\n);\n\nSignDocument.displayName = 'SignDocument';\n\nexport { rootVariants as signDocumentRootVariants };\n"],"names":["signDocumentAgent","handle","rootVariants","cva","headingVariants","signSectionVariants","sectionLabelVariants","progressVariants","hintVariants","confirmButtonVariants","signedBannerVariants","formatSignedAt","iso","locale","date","SignDocument","forwardRef","id","src","documentTitle","requireReadToEnd","onSign","onError","signedAt","disabled","readOnly","ariaLabel","className","ref","t","i18n","useTranslation","rawId","useId","idSafe","useMemo","docHeadingId","signLabelId","liveRegionId","gateHintId","signatureRef","useRef","numPages","setNumPages","useState","currentPage","setCurrentPage","reachedEnd","setReachedEnd","hasSignature","setHasSignature","isSigned","inert","onSignRef","onErrorRef","useEffect","handleLoadComplete","useCallback","info","handlePageChange","page","total","handleError","error","_a","signLive","tick","pad","interval","readComplete","confirmDisabled","handleSigned","payload","confirm","reset","agentHandle","useImperativeHandle","useAgentRegistration","regionLabel","documentRegionLabel","liveText","gateHintText","jsxs","jsx","PDFViewer","CheckCircle2","SignatureCapture"],"mappings":";;;;;;;;AAaO,MAAMA,KAAsD;AAAA,EACjE,IAAI;AAAA,EACJ,cAAc,CAA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AAA,kBAAA;AAAA,kBAMb,gBAAAW;AAAA,oBAAC;AAAA,oBAAA;AAAA,sBACC,MAAK;AAAA,sBACL,SAAS,MAAM;AACb,wBAAIZ,KACCG,EAAA;AAAA,sBACP;AAAA,sBACA,UAAUH;AAAA,sBACV,oBAAkB/B;AAAA,sBAClB,WAAW9B,GAAA;AAAA,sBACX,eAAY;AAAA,sBAEZ,UAAA;AAAA,wBAAA,gBAAA0E,EAACE,GAAA,EAAa,eAAY,QAAO,WAAU,aAAY;AAAA,wBACtDxD,EAAE,sBAAsB;AAAA,sBAAA;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBAC3B;AAAA,cAAA;AAAA,YAAA;AAAA;AAAA,QACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEAd,GAAa,cAAc;"}
@@ -1,5 +1,5 @@
1
- import { jsxs as X, jsx as h } from "react/jsx-runtime";
2
- import { forwardRef as ze, useId as Se, useMemo as ae, useRef as C, useState as N, useEffect as P, useCallback as T, useImperativeHandle as Re } from "react";
1
+ import { jsxs as W, jsx as k } from "react/jsx-runtime";
2
+ import { forwardRef as Ce, useId as Se, useMemo as se, useRef as z, useState as N, useEffect as P, useCallback as T, useImperativeHandle as Re } from "react";
3
3
  import Ae from "signature_pad";
4
4
  import { c as R } from "./index-D2ZczOXr.js";
5
5
  import { useTranslation as Me } from "react-i18next";
@@ -78,18 +78,21 @@ const Pe = {
78
78
  "ds:select-none"
79
79
  ].join(" ")
80
80
  ), Ee = R(
81
- ["ds:flex ds:items-center ds:flex-wrap ds:gap-[var(--spacing-xs)]"].join(" ")
82
- ), q = R(
81
+ ["ds:flex ds:items-stretch ds:flex-wrap ds:gap-[var(--spacing-sm)]"].join(
82
+ " "
83
+ )
84
+ ), ae = R(
83
85
  [
84
- "ds:inline-flex ds:items-center ds:justify-center",
86
+ "ds:inline-flex ds:flex-1 ds:items-center ds:justify-center",
85
87
  "ds:min-block-size-[var(--min-target-size)]",
86
88
  "ds:min-inline-size-[var(--min-target-size)]",
87
89
  "ds:gap-[var(--spacing-xs)]",
88
- "ds:ps-[var(--spacing-sm)] ds:pe-[var(--spacing-sm)]",
90
+ "ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)]",
91
+ "ds:pt-[var(--spacing-md)] ds:pb-[var(--spacing-md)]",
89
92
  "ds:rounded-[var(--radius-sm)]",
90
93
  "ds:border ds:border-[color:var(--border)]",
91
94
  "ds:bg-transparent ds:text-[var(--foreground)]",
92
- "ds:text-[length:var(--font-size-sm)] ds:font-medium",
95
+ "ds:text-[length:var(--font-size-base)] ds:font-medium",
93
96
  "ds:transition-colors ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none",
94
97
  "ds:hover:bg-[var(--muted)]",
95
98
  "ds:focus-visible:outline-[length:var(--focus-ring-width)]",
@@ -101,13 +104,14 @@ const Pe = {
101
104
  ].join(" ")
102
105
  ), Be = R(
103
106
  [
104
- "ds:inline-flex ds:items-center ds:justify-center",
107
+ "ds:inline-flex ds:flex-1 ds:items-center ds:justify-center",
105
108
  "ds:min-block-size-[var(--min-target-size)]",
106
109
  "ds:min-inline-size-[var(--min-target-size)]",
107
110
  "ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)]",
111
+ "ds:pt-[var(--spacing-md)] ds:pb-[var(--spacing-md)]",
108
112
  "ds:rounded-[var(--radius-sm)]",
109
113
  "ds:bg-[var(--primary)] ds:text-[var(--primary-foreground)]",
110
- "ds:text-[length:var(--font-size-sm)] ds:font-medium",
114
+ "ds:text-[length:var(--font-size-base)] ds:font-medium",
111
115
  "ds:transition-colors ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none",
112
116
  "ds:hover:bg-[var(--primary-hover)]",
113
117
  "ds:focus-visible:outline-[length:var(--focus-ring-width)]",
@@ -193,12 +197,12 @@ function He(t, n, s, i, a) {
193
197
  const v = Math.max(
194
198
  1,
195
199
  typeof window < "u" ? window.devicePixelRatio : 1
196
- ), z = document.createElement("canvas");
197
- z.width = Math.floor(n * v), z.height = Math.floor(s * v);
198
- const l = z.getContext("2d");
199
- return l && (l.setTransform(v, 0, 0, v, 0, 0), l.fillStyle = a, l.fillRect(0, 0, n, s), l.fillStyle = i, l.font = "32px italic sans-serif", l.textAlign = "center", l.textBaseline = "middle", l.fillText(t, n / 2, s / 2, n - 16)), z;
200
+ ), C = document.createElement("canvas");
201
+ C.width = Math.floor(n * v), C.height = Math.floor(s * v);
202
+ const d = C.getContext("2d");
203
+ return d && (d.setTransform(v, 0, 0, v, 0, 0), d.fillStyle = a, d.fillRect(0, 0, n, s), d.fillStyle = i, d.font = "32px italic sans-serif", d.textAlign = "center", d.textBaseline = "middle", d.fillText(t, n / 2, s / 2, n - 16)), C;
200
204
  }
201
- const Ue = ze(
205
+ const Ue = Ce(
202
206
  ({
203
207
  id: t,
204
208
  onConfirm: n,
@@ -206,31 +210,31 @@ const Ue = ze(
206
210
  onStart: i,
207
211
  width: a = 400,
208
212
  height: v = 200,
209
- penColor: z,
210
- backgroundColor: l,
213
+ penColor: C,
214
+ backgroundColor: d,
211
215
  allowTypedFallback: ce = !0,
212
- disabled: f = !1,
216
+ disabled: b = !1,
213
217
  ariaLabel: le,
214
218
  className: ue
215
219
  }, fe) => {
216
- const { t: o } = Me(), G = Se(), Z = `${ae(
217
- () => `sig-${G.replace(/[^a-zA-Z0-9-_]/g, "")}`,
218
- [G]
219
- )}-live`, F = C(null), J = C(null), V = C(null), K = C(null), y = C(null), [d, ge] = N("draw"), [S, L] = N(""), [pe, I] = N(!1), me = C("empty"), [ve, be] = N(""), [b, he] = N(""), [w, ye] = N(""), j = C(i), E = C(s), B = C(n);
220
+ const { t: c } = Me(), X = Se(), q = `${se(
221
+ () => `sig-${X.replace(/[^a-zA-Z0-9-_]/g, "")}`,
222
+ [X]
223
+ )}-live`, F = z(null), G = z(null), V = z(null), Z = z(null), h = z(null), [l, ge] = N("draw"), [S, L] = N(""), [pe, I] = N(!1), ve = z("empty"), [me, be] = N(""), [m, he] = N(""), [y, ye] = N(""), j = z(i), E = z(s), B = z(n);
220
224
  P(() => {
221
225
  j.current = i, E.current = s, B.current = n;
222
226
  }, [i, s, n]);
223
- const g = T(
227
+ const f = T(
224
228
  (e) => {
225
- me.current = e, be(o(`signature.state.${e}`));
229
+ ve.current = e, be(c(`signature.state.${e}`));
226
230
  },
227
- [o]
231
+ [c]
228
232
  );
229
233
  P(() => {
230
234
  if (typeof document > "u") return;
231
235
  function e() {
232
- const c = z ?? ie("--foreground"), p = l ?? ie("--background");
233
- he(c || "currentColor"), ye(p || "transparent");
236
+ const o = C ?? ie("--foreground"), g = d ?? ie("--background");
237
+ he(o || "currentColor"), ye(g || "transparent");
234
238
  }
235
239
  e();
236
240
  const r = new MutationObserver(() => {
@@ -240,47 +244,47 @@ const Ue = ze(
240
244
  attributes: !0,
241
245
  attributeFilter: ["class"]
242
246
  }), () => r.disconnect();
243
- }, [z, l]), P(() => {
244
- const e = y.current;
245
- e && (b && (e.penColor = b), w && (e.backgroundColor = w));
246
- }, [b, w]), P(() => {
247
- if (d !== "draw") return;
247
+ }, [C, d]), P(() => {
248
+ const e = h.current;
249
+ e && (m && (e.penColor = m), y && (e.backgroundColor = y));
250
+ }, [m, y]), P(() => {
251
+ if (l !== "draw") return;
248
252
  const e = V.current;
249
253
  if (!e) return;
250
254
  const r = new Ae(e, {
251
- penColor: b || "currentColor",
252
- backgroundColor: w || "transparent",
255
+ penColor: m || "currentColor",
256
+ backgroundColor: y || "transparent",
253
257
  minWidth: 0.5,
254
258
  maxWidth: 2.5,
255
259
  velocityFilterWeight: 0.7
256
260
  });
257
- y.current = r;
258
- const c = () => {
259
- var x;
260
- I(!0), g("drawing"), (x = j.current) == null || x.call(j);
261
- }, p = () => {
261
+ h.current = r;
262
+ const o = () => {
263
+ var w;
264
+ I(!0), f("drawing"), (w = j.current) == null || w.call(j);
265
+ }, g = () => {
262
266
  };
263
- return r.addEventListener("beginStroke", c), r.addEventListener("endStroke", p), $(e), g("empty"), () => {
264
- r.removeEventListener("beginStroke", c), r.removeEventListener("endStroke", p), r.clear(), r.off(), y.current = null;
267
+ return r.addEventListener("beginStroke", o), r.addEventListener("endStroke", g), $(e), f("empty"), () => {
268
+ r.removeEventListener("beginStroke", o), r.removeEventListener("endStroke", g), r.clear(), r.off(), h.current = null;
265
269
  };
266
- }, [d]), P(() => {
267
- const e = y.current;
268
- e && (f ? e.off() : e.on());
269
- }, [f, d]);
270
- const Q = 4096, $ = T(
270
+ }, [l]), P(() => {
271
+ const e = h.current;
272
+ e && (b ? e.off() : e.on());
273
+ }, [b, l]);
274
+ const J = 4096, $ = T(
271
275
  (e) => {
272
- const r = e.getBoundingClientRect(), c = Math.max(
276
+ const r = e.getBoundingClientRect(), o = Math.max(
273
277
  1,
274
278
  typeof window < "u" ? window.devicePixelRatio : 1
275
- ), p = Math.max(1, Math.floor(r.width * c)), x = Math.max(1, Math.floor(r.height * c)), A = Math.min(p, Q), k = Math.min(x, Q);
276
- if (e.width === A && e.height === k)
279
+ ), g = Math.max(1, Math.floor(r.width * o)), w = Math.max(1, Math.floor(r.height * o)), A = Math.min(g, J), x = Math.min(w, J);
280
+ if (e.width === A && e.height === x)
277
281
  return;
278
- const m = y.current, M = m ? m.toData() : null;
279
- e.width = A, e.height = k;
282
+ const p = h.current, M = p ? p.toData() : null;
283
+ e.width = A, e.height = x;
280
284
  const D = e.getContext("2d");
281
- D && D.scale(c, c), m && (w && (m.backgroundColor = w), b && (m.penColor = b), m.clear(), M && M.length > 0 && m.fromData(M));
285
+ D && D.scale(o, o), p && (y && (p.backgroundColor = y), m && (p.penColor = m), p.clear(), M && M.length > 0 && p.fromData(M));
282
286
  },
283
- [w, b]
287
+ [y, m]
284
288
  );
285
289
  P(() => {
286
290
  const e = V.current;
@@ -296,69 +300,69 @@ const Ue = ze(
296
300
  }, [$]);
297
301
  const H = T(() => {
298
302
  var r;
299
- const e = y.current;
300
- e && e.clear(), L(""), I(!1), g("cleared"), (r = E.current) == null || r.call(E);
301
- }, [g]), U = T(() => {
302
- const e = y.current;
303
+ const e = h.current;
304
+ e && e.clear(), L(""), I(!1), f("cleared"), (r = E.current) == null || r.call(E);
305
+ }, [f]), K = T(() => {
306
+ const e = h.current;
303
307
  if (!e) return;
304
308
  const r = e.toData();
305
- !r || r.length === 0 || (r.pop(), e.fromData(r), r.length === 0 && (I(!1), g("empty")));
306
- }, [g]), Y = T(() => {
307
- if (d === "typed") return S.trim().length === 0;
308
- const e = y.current;
309
+ !r || r.length === 0 || (r.pop(), e.fromData(r), r.length === 0 && (I(!1), f("empty")));
310
+ }, [f]), Q = T(() => {
311
+ if (l === "typed") return S.trim().length === 0;
312
+ const e = h.current;
309
313
  return e ? e.isEmpty() : !0;
310
- }, [d, S]), _ = T(async () => {
311
- var ne;
314
+ }, [l, S]), U = T(async () => {
315
+ var re;
312
316
  const e = de(
313
317
  typeof a == "number" ? `${a}` : String(a)
314
318
  ), r = de(
315
319
  typeof v == "number" ? `${v}` : String(v)
316
- ), c = d === "draw" ? V.current ?? J.current ?? F.current : K.current ?? F.current, p = c == null ? void 0 : c.getBoundingClientRect(), x = e ?? (p ? p.width : 400), A = r ?? (p ? p.height : 200);
317
- let k = "", m = "", M;
318
- if (d === "draw") {
319
- const u = y.current;
320
+ ), o = l === "draw" ? V.current ?? G.current ?? F.current : Z.current ?? F.current, g = o == null ? void 0 : o.getBoundingClientRect(), w = e ?? (g ? g.width : 400), A = r ?? (g ? g.height : 200);
321
+ let x = "", p = "", M;
322
+ if (l === "draw") {
323
+ const u = h.current;
320
324
  if (!u || u.isEmpty()) return null;
321
- k = u.toDataURL("image/png"), m = u.toSVG(), M = u.toData();
325
+ x = u.toDataURL("image/png"), p = u.toSVG(), M = u.toData();
322
326
  } else {
323
327
  const u = S.trim();
324
328
  if (u.length === 0) return null;
325
- k = He(
329
+ x = He(
326
330
  u,
327
- x,
331
+ w,
328
332
  A,
329
- b || "currentColor",
330
- w || "transparent"
333
+ m || "currentColor",
334
+ y || "transparent"
331
335
  ).toDataURL("image/png");
332
- const W = u.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
333
- m = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${x} ${A}" width="${x}" height="${A}"><text x="50%" y="50%" dominant-baseline="middle" text-anchor="middle" font-family="sans-serif" font-style="italic" font-size="32" fill="${b || "currentColor"}" letter-spacing="3">${W}</text></svg>`;
336
+ const O = u.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
337
+ p = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${w} ${A}" width="${w}" height="${A}"><text x="50%" y="50%" dominant-baseline="middle" text-anchor="middle" font-family="sans-serif" font-style="italic" font-size="32" fill="${m || "currentColor"}" letter-spacing="3">${O}</text></svg>`;
334
338
  }
335
- const D = x * 25.4 / 96, ke = A * 25.4 / 96, Ce = (/* @__PURE__ */ new Date()).toISOString();
336
- let te = "";
337
- if (k) {
338
- const u = k.indexOf(","), se = u >= 0 ? k.slice(u + 1) : "", W = Le(se);
339
- te = await Ie(W);
339
+ const D = w * 25.4 / 96, ke = A * 25.4 / 96, ze = (/* @__PURE__ */ new Date()).toISOString();
340
+ let ee = "";
341
+ if (x) {
342
+ const u = x.indexOf(","), ne = u >= 0 ? x.slice(u + 1) : "", O = Le(ne);
343
+ ee = await Ie(O);
340
344
  }
341
- const re = {
342
- png: k,
343
- svg: m,
345
+ const te = {
346
+ png: x,
347
+ svg: p,
344
348
  widthMm: D,
345
349
  heightMm: ke,
346
- capturedAt: Ce,
347
- sha256: te,
350
+ capturedAt: ze,
351
+ sha256: ee,
348
352
  strokes: M
349
353
  };
350
- return g("captured"), (ne = B.current) == null || ne.call(B, re), re;
351
- }, [d, S, a, v, b, w, g]), O = ae(
354
+ return f("captured"), (re = B.current) == null || re.call(B, te), te;
355
+ }, [l, S, a, v, m, y, f]), _ = se(
352
356
  () => ({
353
357
  clear: H,
354
- undo: U,
355
- isEmpty: Y,
356
- confirm: _
358
+ undo: K,
359
+ isEmpty: Q,
360
+ confirm: U
357
361
  }),
358
- [H, U, Y, _]
362
+ [H, K, Q, U]
359
363
  );
360
- Re(fe, () => O, [O]), Ne(Pe, O, t);
361
- const we = d === "typed" ? S.trim().length > 0 : pe, ee = f || !we, xe = {
364
+ Re(fe, () => _, [_]), Ne(Pe, _, t);
365
+ const we = l === "typed" ? S.trim().length > 0 : pe, Y = b || !we, xe = {
362
366
  "--signature-width": oe(
363
367
  a,
364
368
  "var(--signature-default-width)"
@@ -368,121 +372,109 @@ const Ue = ze(
368
372
  "var(--signature-default-height)"
369
373
  )
370
374
  };
371
- return /* @__PURE__ */ X(
375
+ return /* @__PURE__ */ W(
372
376
  "div",
373
377
  {
374
378
  ref: F,
375
379
  role: "group",
376
- "aria-label": le ?? o("signature.padLabel"),
377
- "aria-disabled": f || void 0,
380
+ "aria-label": le ?? c("signature.padLabel"),
381
+ "aria-disabled": b || void 0,
378
382
  className: [Te(), ue].filter(Boolean).join(" "),
379
383
  style: xe,
380
384
  "data-component": "signature-capture",
381
385
  "data-component-id": t,
382
386
  children: [
383
- d === "draw" ? /* @__PURE__ */ h("div", { ref: J, className: Ve(), children: /* @__PURE__ */ h(
387
+ l === "draw" ? /* @__PURE__ */ k("div", { ref: G, className: Ve(), children: /* @__PURE__ */ k(
384
388
  "canvas",
385
389
  {
386
390
  ref: V,
387
391
  role: "img",
388
- "aria-label": o("signature.padLabel"),
392
+ "aria-label": c("signature.padLabel"),
389
393
  className: je(),
390
394
  "data-testid": "signature-canvas"
391
395
  }
392
- ) }) : /* @__PURE__ */ X("label", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
393
- /* @__PURE__ */ h("span", { className: "type-body-sm ds:text-[var(--muted-foreground)]", children: o("signature.typedFallback.label") }),
394
- /* @__PURE__ */ h(
396
+ ) }) : /* @__PURE__ */ W("label", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
397
+ /* @__PURE__ */ k("span", { className: "type-body-sm ds:text-[var(--muted-foreground)]", children: c("signature.typedFallback.label") }),
398
+ /* @__PURE__ */ k(
395
399
  "input",
396
400
  {
397
401
  type: "text",
398
402
  value: S,
399
403
  onChange: (e) => {
400
- L(e.target.value), e.target.value.length > 0 ? g("drawing") : g("empty");
404
+ L(e.target.value), e.target.value.length > 0 ? f("drawing") : f("empty");
401
405
  },
402
- placeholder: o("signature.typedFallback.placeholder"),
403
- "aria-label": o("signature.typedFallback.label"),
404
- disabled: f,
406
+ placeholder: c("signature.typedFallback.placeholder"),
407
+ "aria-label": c("signature.typedFallback.label"),
408
+ disabled: b,
405
409
  className: $e(),
406
410
  "data-testid": "signature-typed-input"
407
411
  }
408
412
  ),
409
- S ? /* @__PURE__ */ h(
413
+ S ? /* @__PURE__ */ k(
410
414
  "div",
411
415
  {
412
- ref: K,
416
+ ref: Z,
413
417
  className: De(),
414
418
  "aria-hidden": "true",
415
419
  children: S
416
420
  }
417
421
  ) : null
418
422
  ] }),
419
- /* @__PURE__ */ h(
423
+ /* @__PURE__ */ k(
420
424
  "div",
421
425
  {
422
- id: Z,
426
+ id: q,
423
427
  "aria-live": "polite",
424
428
  "aria-atomic": "true",
425
429
  className: "ds:sr-only",
426
430
  "data-testid": "signature-live",
427
- children: ve
431
+ children: me
428
432
  }
429
433
  ),
430
- /* @__PURE__ */ X(
434
+ /* @__PURE__ */ W(
431
435
  "div",
432
436
  {
433
437
  className: Ee(),
434
438
  role: "group",
435
- "aria-label": o("signature.padLabel"),
439
+ "aria-label": c("signature.padLabel"),
436
440
  children: [
437
- /* @__PURE__ */ h(
441
+ /* @__PURE__ */ k(
438
442
  "button",
439
443
  {
440
444
  type: "button",
441
445
  onClick: () => {
442
- f || H();
446
+ b || H();
443
447
  },
444
- "aria-disabled": f || void 0,
445
- className: q(),
446
- children: o("signature.clear")
448
+ "aria-disabled": b || void 0,
449
+ className: ae(),
450
+ children: c("signature.clear")
447
451
  }
448
452
  ),
449
- d === "draw" ? /* @__PURE__ */ h(
450
- "button",
451
- {
452
- type: "button",
453
- onClick: () => {
454
- f || U();
455
- },
456
- "aria-disabled": f || void 0,
457
- className: q(),
458
- children: o("signature.undo")
459
- }
460
- ) : null,
461
- ce ? /* @__PURE__ */ h(
453
+ ce ? /* @__PURE__ */ k(
462
454
  "button",
463
455
  {
464
456
  type: "button",
465
457
  onClick: () => {
466
- f || (L(""), ge((e) => e === "draw" ? "typed" : "draw"), g("cleared"));
458
+ b || (L(""), ge((e) => e === "draw" ? "typed" : "draw"), f("cleared"));
467
459
  },
468
- "aria-disabled": f || void 0,
469
- className: q(),
470
- "aria-pressed": d === "typed",
471
- children: o(d === "draw" ? "signature.typedFallback.toggle" : "signature.typedFallback.toggleDraw")
460
+ "aria-disabled": b || void 0,
461
+ className: ae(),
462
+ "aria-pressed": l === "typed",
463
+ children: c(l === "draw" ? "signature.typedFallback.toggle" : "signature.typedFallback.toggleDraw")
472
464
  }
473
465
  ) : null,
474
- /* @__PURE__ */ h(
466
+ /* @__PURE__ */ k(
475
467
  "button",
476
468
  {
477
469
  type: "button",
478
470
  onClick: () => {
479
- ee || _();
471
+ Y || U();
480
472
  },
481
- "aria-disabled": ee || void 0,
482
- "aria-describedby": Z,
473
+ "aria-disabled": Y || void 0,
474
+ "aria-describedby": q,
483
475
  className: Be(),
484
476
  "data-testid": "signature-confirm",
485
- children: o("signature.confirm")
477
+ children: c("signature.confirm")
486
478
  }
487
479
  )
488
480
  ]
@@ -498,4 +490,4 @@ export {
498
490
  Ue as S,
499
491
  Pe as s
500
492
  };
501
- //# sourceMappingURL=signature-capture-BRzCklg4.js.map
493
+ //# sourceMappingURL=signature-capture-DoiBd6i3.js.map