@arbidocs/react 0.5.165 → 0.5.166
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/MessageArtifactCard.js +16 -0
- package/dist/ai/MessageArtifactCard.js.map +2 -2
- package/dist/artifacts/artifact-kind.js +12 -1
- package/dist/artifacts/artifact-kind.js.map +2 -2
- package/dist/artifacts/index.cjs +58 -47
- package/dist/artifacts/index.cjs.map +1 -1
- package/dist/artifacts/index.d.ts +3 -20
- package/dist/artifacts/index.js +3 -1
- package/dist/artifacts/index.js.map +2 -2
- package/dist/calls/livekit/index.cjs +51 -51
- package/dist/chat/ChatBubble.js +56 -65
- package/dist/chat/ChatBubble.js.map +2 -2
- package/dist/chat/open-document.js +4 -1
- package/dist/chat/open-document.js.map +2 -2
- package/dist/{chunk-XSJNRWLD.cjs → chunk-3DPOR5IR.cjs} +9 -6
- package/dist/chunk-3DPOR5IR.cjs.map +1 -0
- package/dist/{chunk-ZBRJEM25.cjs → chunk-4TWXQFHU.cjs} +70 -70
- package/dist/{chunk-ZBRJEM25.cjs.map → chunk-4TWXQFHU.cjs.map} +1 -1
- package/dist/{chunk-ZZBCZRA5.cjs → chunk-5QOZLKAY.cjs} +5 -2
- package/dist/chunk-5QOZLKAY.cjs.map +1 -0
- package/dist/{chunk-B3W7WDVY.cjs → chunk-BI4SYRLX.cjs} +73 -66
- package/dist/chunk-BI4SYRLX.cjs.map +1 -0
- package/dist/{chunk-ONAYOSSV.cjs → chunk-HRQS27DO.cjs} +39 -39
- package/dist/{chunk-ONAYOSSV.cjs.map → chunk-HRQS27DO.cjs.map} +1 -1
- package/dist/{chunk-DQODLWFX.cjs → chunk-KULS4YWP.cjs} +3 -3
- package/dist/{chunk-DQODLWFX.cjs.map → chunk-KULS4YWP.cjs.map} +1 -1
- package/dist/{chunk-V5WCKJEH.cjs → chunk-Q7BGWKHP.cjs} +44 -44
- package/dist/{chunk-V5WCKJEH.cjs.map → chunk-Q7BGWKHP.cjs.map} +1 -1
- package/dist/{chunk-352P2C4E.cjs → chunk-TX7UCN73.cjs} +14 -14
- package/dist/{chunk-352P2C4E.cjs.map → chunk-TX7UCN73.cjs.map} +1 -1
- package/dist/{chunk-WJIRX5MS.cjs → chunk-W4W75MSO.cjs} +134 -25
- package/dist/chunk-W4W75MSO.cjs.map +1 -0
- package/dist/chunk-WABJGKVA.cjs +246 -0
- package/dist/chunk-WABJGKVA.cjs.map +1 -0
- package/dist/databases.js.map +2 -2
- package/dist/directmessages/DmComposer.js +26 -10
- package/dist/directmessages/DmComposer.js.map +2 -2
- package/dist/directmessages/index.js +2 -0
- package/dist/directmessages/index.js.map +2 -2
- package/dist/directmessages/useChats.js +11 -0
- package/dist/directmessages/useChats.js.map +2 -2
- package/dist/document-tools/core.cjs +102 -102
- package/dist/document-tools/core.d.ts +2 -2
- package/dist/document-tools/index.cjs +104 -104
- package/dist/document-tools/index.d.ts +2 -2
- package/dist/entities/DocumentEntity.js +8 -3
- package/dist/entities/DocumentEntity.js.map +2 -2
- package/dist/entities/EntityActionsMenu.js +53 -0
- package/dist/entities/EntityActionsMenu.js.map +7 -0
- package/dist/entities/EntityPill.js +50 -16
- package/dist/entities/EntityPill.js.map +2 -2
- package/dist/entities/ProjectEntity.js +4 -0
- package/dist/entities/ProjectEntity.js.map +2 -2
- package/dist/entities/TagEntity.js +1 -0
- package/dist/entities/TagEntity.js.map +2 -2
- package/dist/entities/UserEntity.js +25 -3
- package/dist/entities/UserEntity.js.map +2 -2
- package/dist/entities/links.js +9 -0
- package/dist/entities/links.js.map +7 -0
- package/dist/entities/reference-data.js +56 -0
- package/dist/entities/reference-data.js.map +7 -0
- package/dist/{file-shares.d-Bwy9k3Db.d.ts → file-shares.d-Dlt7pKRi.d.ts} +3 -0
- package/dist/host/config.js.map +2 -2
- package/dist/index.cjs +2537 -2449
- package/dist/index.cjs.map +1 -1
- package/dist/{index.d-Dy_Pz6Vl.d.ts → index.d-BaZUctD1.d.ts} +34 -10
- package/dist/index.d.ts +164 -20
- package/dist/index.js +5 -0
- package/dist/index.js.map +2 -2
- package/dist/query-keys.js +3 -0
- package/dist/query-keys.js.map +2 -2
- package/dist/session/conversation-panels.js +5 -3
- package/dist/session/conversation-panels.js.map +2 -2
- package/dist/session/layout.js +5 -0
- package/dist/session/layout.js.map +2 -2
- package/dist/shell/index.cjs +40 -40
- package/dist/{stored-markdown.d-Bp18vrbr.d.ts → stored-markdown.d-BLQPny3e.d.ts} +21 -1
- package/dist/ui/index.cjs +168 -164
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +2 -0
- package/dist/ui/index.js.map +2 -2
- package/dist/viewers/AudioViewer.js +13 -3
- package/dist/viewers/AudioViewer.js.map +2 -2
- package/dist/viewers/MediaTranscriptPlayer.js +171 -0
- package/dist/viewers/MediaTranscriptPlayer.js.map +7 -0
- package/dist/viewers/VideoViewer.js +4 -11
- package/dist/viewers/VideoViewer.js.map +2 -2
- package/dist/viewers/index.cjs +16 -12
- package/dist/viewers/index.d.ts +17 -3
- package/dist/viewers/index.js +2 -0
- package/dist/viewers/index.js.map +2 -2
- package/package.json +3 -3
- package/dist/chunk-B3W7WDVY.cjs.map +0 -1
- package/dist/chunk-TMPDW7J5.cjs +0 -79
- package/dist/chunk-TMPDW7J5.cjs.map +0 -1
- package/dist/chunk-WJIRX5MS.cjs.map +0 -1
- package/dist/chunk-XSJNRWLD.cjs.map +0 -1
- package/dist/chunk-ZZBCZRA5.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/document-tools/environment.tsx","../src/document-tools/document-pdf.ts","../src/document-tools/markup-download.ts","../src/document-tools/signing.ts","../src/document-tools/file-shares.ts"],"names":["createContext","useDeploymentDomain","useRef","useCallback","useMemo","jsx","useContext","parseVersionRef","useQuery","arbiQueryKeys","client","unlockIdentityWithPassword","signMessage","useQueryClient","useMutation"],"mappings":";;;;;;;;;AAmEO,SAAS,kBAAkB,KAAA,EAAoC;A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M,MAAA,GAAS,MAAM,MAAA,CAAO,IAAA;AAAA,IAC1B,+DAAA;AAAA,IACA,EAAE,MAAA,EAAQ,EAAE,IAAA,EAAM,EAAE,eAAA,EAAiB,KAAA,CAAM,eAAA,EAAiB,QAAA,EAAU,KAAA,CAAM,WAAA,EAAY,EAAE;AAAE,GAC9F;AACA,EAAA,IAAI,CAAC,MAAA,CAAO,IAAA,EAAM,MAAM,IAAI,MAAM,oDAAoD,CAAA;AACtF,EAAA,OAAO,MAAA,CAAO,IAAA;AAChB","file":"chunk-352P2C4E.cjs","sourcesContent":["/**\n * The host app's side of the document tools (markup, freeze, e-signing, versions): the one place\n * the tools reach the app. They never import a store, a router, a toast library or app API code;\n * the host passes what it has to `<DocumentToolsProvider>` and every optional field has a default.\n *\n * `client` is an openapi-fetch client for the ARBI API (`ArbiClient['fetch']` from\n * `@arbidocs/client`, or `arbi.getClient().fetch` from an `@arbidocs/sdk` `Arbi`), signed in with the\n * user's session; it carries the auth.\n */\n\nimport { createContext, useCallback, useContext, useMemo, useRef, type ReactNode } from 'react'\nimport type { ArbiClient, operations } from '@arbidocs/client'\nimport { useDeploymentDomain } from '../useArbi'\n\nexport type DocumentToolsClient = ArbiClient['fetch']\n\nexport type DocumentToolsNoticeKind = 'success' | 'error' | 'info' | 'warning'\n\nexport interface DocumentToolsNoticeOptions {\n /** A second line under the message. */\n description?: string\n /** One action button on the notice (\"Email it\"). */\n action?: { label: string; onClick: () => void }\n}\n\nexport type DocumentToolsNotify = (\n message: string,\n kind: DocumentToolsNoticeKind,\n options?: DocumentToolsNoticeOptions\n) => void\n\nexport interface DocumentToolsUser {\n /** The name marks are authored as and the signer's name is prefilled with. */\n name: string\n /** The sign-in email: signing re-derives the user's key from it and the password. */\n email?: string | null\n /** The user's id (usr-*): which fields of a signature request are theirs. */\n externalId?: string | null\n}\n\n/** What changed about a document, so the host can refresh its own lists and caches. */\nexport type DocumentChange =\n /** A version's markup got its first mark or lost its last one. */\n | 'markup'\n /** A signature was added: the document has a new current version. */\n | 'signed'\n /** A new document was made from it (a frozen copy). The ids are the NEW documents. */\n | 'copy'\n /** A new version was saved (the Word editor's Save version): the document's current version. */\n | 'version'\n\n/**\n * The `/v1/document/upload` query, typed from the API schema: `derived_from` is a list (a\n * production set is derived from every document in it), `shared` a boolean.\n */\nexport type DocumentUploadQuery = NonNullable<operations['upload_documents']['parameters']['query']>\n\nexport interface DocumentUploadRequest {\n file: File\n /** `/v1/document/upload` query: `derived_from`, `derived_role`, `shared`, `folder`. */\n query: DocumentUploadQuery\n}\n\n/**\n * The upload query as a URL query string, for a host that posts the upload itself (an XHR with\n * progress): a list repeats its key (`derived_from=a&derived_from=b`), empty values are left out.\n */\nexport function uploadQueryString(query: DocumentUploadQuery): string {\n const params = new URLSearchParams()\n for (const [key, value] of Object.entries(query)) {\n if (value === null || value === undefined) continue\n for (const item of Array.isArray(value) ? value : [value]) params.append(key, String(item))\n }\n return params.toString()\n}\n\nexport interface DocumentToolsEnvironment {\n client: DocumentToolsClient\n /**\n * The deployment domain the user's keys are derived for. Needed for signing. Default: the one\n * the host's `Arbi` computes (`arbi.getDeploymentDomain()`), if any.\n */\n deploymentDomain?: string\n /** The signed-in user; marks are authored as \"You\" without one, and signing is unavailable. */\n user?: DocumentToolsUser | null\n /** Surface a transient message. Default: none (errors still show inline where they can). */\n notify?: DocumentToolsNotify\n /** Open a document or a version reference (`doc-…@v2`): the copy just made, the signed copy. */\n openDocument?: (documentRef: string) => void\n /**\n * Documents changed on the server (see {@link DocumentChange}); refresh the host's lists. The\n * tools wait for it before opening the document, so a copy is listed when it opens.\n */\n onDocumentsChanged?: (documentIds: string[], change: DocumentChange) => void | Promise<void>\n /** Upload a derived copy. Default: `POST /v1/document/upload` through `client`. */\n uploadDocument?: (\n request: DocumentUploadRequest\n ) => Promise<{ doc_ext_ids?: string[] } | undefined>\n /** Save a file to the user's computer. Default: a temporary download link. */\n saveFile?: (blob: Blob, fileName: string) => void\n /** Email a document (offered once it is signed). Omitted: no \"Email it\". */\n emailDocument?: (documentRef: string) => void\n /**\n * The public page that checks a signature (the certificate) in this app. When given, \"View\n * certificate\" opens it in preference to the backend's `certificate_url` (which is on the\n * deployment domain, like the link embedded in the signed PDF). Without it: the backend's\n * `certificate_url`, else `/verify/{reference}` on this origin.\n */\n certificateUrl?: (reference: string) => string\n}\n\n/** The environment with every default filled in. */\nexport interface ResolvedDocumentToolsEnvironment extends DocumentToolsEnvironment {\n prepareFileShare: (documentId: string) => Promise<void>\n registerBeforeFileShare: (documentId: string, flush: () => Promise<void>) => () => void\n notify: DocumentToolsNotify\n saveFile: (blob: Blob, fileName: string) => void\n uploadDocument: (\n request: DocumentUploadRequest\n ) => Promise<{ doc_ext_ids?: string[] } | undefined>\n}\n\n/**\n * Save a blob through a temporary `<a download>`. The object URL is revoked a minute later, not at\n * once: revoking straight after `click()` can cancel the download (Safari, and large files\n * elsewhere) before the browser has read the blob.\n */\nexport function downloadBlob(blob: Blob, fileName: string): void {\n const url = URL.createObjectURL(blob)\n const a = document.createElement('a')\n a.href = url\n a.download = fileName\n document.body.appendChild(a)\n a.click()\n a.remove()\n setTimeout(() => URL.revokeObjectURL(url), 60_000)\n}\n\n/** The default upload: multipart `files` to `/v1/document/upload` through the API client. */\nexport function clientUpload(client: DocumentToolsClient) {\n return async ({ file, query }: DocumentUploadRequest) => {\n const formData = new FormData()\n formData.append('files', file)\n const { data, response } = await client.POST('/v1/document/upload', {\n params: { query },\n // The schema types the multipart body as `{ files: string[] }`; the FormData is sent as is.\n body: formData as unknown as { files: string[] },\n bodySerializer: () => formData,\n })\n if (!response.ok) throw new Error(`Upload failed with status ${response.status}`)\n return data\n }\n}\n\nexport function defaultCertificateUrl(reference: string): string {\n const origin = typeof location === 'undefined' ? '' : location.origin\n return `${origin}/verify/${encodeURIComponent(reference)}`\n}\n\n/**\n * Where \"View certificate\" goes for a signature: the host's `certificateUrl(reference)` when it\n * gives one, else the `certificate_url` the backend returned, else `/verify/{reference}` here.\n */\nexport function certificateLink(\n signature: { reference: string; certificate_url?: string | null },\n certificateUrl?: (reference: string) => string\n): string {\n if (certificateUrl) return certificateUrl(signature.reference)\n return signature.certificate_url || defaultCertificateUrl(signature.reference)\n}\n\nconst DocumentToolsContext = createContext<ResolvedDocumentToolsEnvironment | null>(null)\n\nexport interface DocumentToolsProviderProps extends DocumentToolsEnvironment {\n children: ReactNode\n}\n\nexport function DocumentToolsProvider({ children, ...env }: DocumentToolsProviderProps) {\n const arbiDeploymentDomain = useDeploymentDomain()\n const guards = useRef(new Map<string, () => Promise<void>>())\n const pendingFlushes = useRef(new Map<string, Promise<void>>())\n const registerBeforeFileShare = useCallback((id: string, flush: () => Promise<void>) => {\n guards.current.set(id, flush)\n return () => {\n if (guards.current.get(id) !== flush) return\n guards.current.delete(id)\n const pending = flush()\n pendingFlushes.current.set(id, pending)\n void pending.then(\n () => {\n if (pendingFlushes.current.get(id) === pending) pendingFlushes.current.delete(id)\n },\n () => {}\n )\n }\n }, [])\n const prepareFileShare = useCallback(async (id: string) => {\n const guard = guards.current.get(id)\n if (guard) {\n await guard()\n pendingFlushes.current.delete(id)\n } else await pendingFlushes.current.get(id)\n }, [])\n const {\n client,\n deploymentDomain,\n user,\n notify,\n openDocument,\n onDocumentsChanged,\n uploadDocument,\n saveFile,\n emailDocument,\n certificateUrl,\n } = env\n const value = useMemo<ResolvedDocumentToolsEnvironment>(\n () => ({\n client,\n prepareFileShare,\n registerBeforeFileShare,\n deploymentDomain: deploymentDomain ?? arbiDeploymentDomain,\n user,\n openDocument,\n onDocumentsChanged,\n emailDocument,\n notify: notify ?? (() => {}),\n saveFile: saveFile ?? downloadBlob,\n uploadDocument: uploadDocument ?? clientUpload(client),\n certificateUrl,\n }),\n [\n client,\n prepareFileShare,\n registerBeforeFileShare,\n deploymentDomain,\n arbiDeploymentDomain,\n user,\n notify,\n openDocument,\n onDocumentsChanged,\n uploadDocument,\n saveFile,\n emailDocument,\n certificateUrl,\n ]\n )\n return <DocumentToolsContext.Provider value={value}>{children}</DocumentToolsContext.Provider>\n}\n\n/** The host's environment, or `null` outside a `<DocumentToolsProvider>`. */\nexport function useOptionalDocumentTools(): ResolvedDocumentToolsEnvironment | null {\n return useContext(DocumentToolsContext)\n}\n\n/** The host's environment; throws outside a `<DocumentToolsProvider>`. */\nexport function useDocumentTools(): ResolvedDocumentToolsEnvironment {\n const env = useContext(DocumentToolsContext)\n if (!env) throw new Error('The document tools must be used within a <DocumentToolsProvider>')\n return env\n}\n","/**\n * A document's bytes, through the host's API client: the PDF the viewer and the tools draw on\n * (`/view`: the file itself for a PDF, its PDF rendering for a Word or text file) and the stored\n * file (`/download`). Either takes a document id or a version reference `doc-…@v{n}`.\n */\n\nimport { parseVersionRef } from '../artifacts/versions'\nimport type { DocumentToolsClient } from './environment'\n\nexport interface DocumentFetchOptions {\n /** The version to fetch. Default: the one `documentRef` names, else the current version. */\n version?: number | null\n workspaceExtId?: string\n signal?: AbortSignal\n}\n\n/** A document's bytes could not be fetched; `status` is the HTTP status. */\nexport class DocumentFetchError extends Error {\n readonly status: number\n constructor(message: string, status: number) {\n super(message)\n this.name = 'DocumentFetchError'\n this.status = status\n }\n}\n\nasync function fetchDocumentBytes(\n client: DocumentToolsClient,\n endpoint: '/v1/document/{document_ext_id}/view' | '/v1/document/{document_ext_id}/download',\n documentRef: string,\n options: DocumentFetchOptions,\n headers: Record<string, string>,\n what: string\n): Promise<{ blob: Blob; response: Response }> {\n const ref = parseVersionRef(documentRef)\n const version = options.version ?? ref.version\n const { data, response } = await client.GET(endpoint, {\n params: {\n path: { document_ext_id: ref.docId },\n query: {\n ...(version ? { version } : {}),\n ...(options.workspaceExtId ? { workspace_ext_id: options.workspaceExtId } : {}),\n },\n },\n headers,\n parseAs: 'blob',\n signal: options.signal,\n })\n if (!response.ok || !(data instanceof Blob)) {\n throw new DocumentFetchError(\n `${what} could not be loaded (${response.status})`,\n response.status\n )\n }\n return { blob: data, response }\n}\n\n/**\n * The file name a `Content-Disposition` header gives, or `undefined`. Prefers the RFC 5987\n * `filename*=UTF-8''…` form (percent-encoded, any script) over the plain `filename=`.\n */\nexport function contentDispositionFileName(header: string | null | undefined): string | undefined {\n if (!header) return undefined\n const extended = /filename\\*\\s*=\\s*(?:[\\w-]+)?'[^']*'([^;]+)/i.exec(header)\n if (extended) {\n try {\n return decodeURIComponent(extended[1].trim().replace(/^\"|\"$/g, '')) || undefined\n } catch {\n // A malformed escape: fall back to the plain parameter.\n }\n }\n const plain = /filename\\s*=\\s*(\"((?:[^\"\\\\]|\\\\.)*)\"|[^;]+)/i.exec(header)\n if (!plain) return undefined\n const name = plain[2] !== undefined ? plain[2].replace(/\\\\(.)/g, '$1') : plain[1].trim()\n return name || undefined\n}\n\n/**\n * The PDF of a document version: `GET /v1/document/{id}/view?version=` with\n * `Accept: application/pdf`. Throws a {@link DocumentFetchError} when there is none (yet).\n */\nexport async function fetchDocumentPdf(\n client: DocumentToolsClient,\n documentRef: string,\n options: DocumentFetchOptions = {}\n): Promise<Blob> {\n const { blob } = await fetchDocumentBytes(\n client,\n '/v1/document/{document_ext_id}/view',\n documentRef,\n options,\n { Accept: 'application/pdf' },\n 'The PDF'\n )\n return blob\n}\n\n/**\n * The stored file of a document version, as uploaded: `GET /v1/document/{id}/download`. When the\n * server names the file (`Content-Disposition`), the result is a `File` carrying that name.\n */\nexport async function fetchDocumentFile(\n client: DocumentToolsClient,\n documentRef: string,\n options: DocumentFetchOptions = {}\n): Promise<Blob | File> {\n const { blob, response } = await fetchDocumentBytes(\n client,\n '/v1/document/{document_ext_id}/download',\n documentRef,\n options,\n {},\n 'The file'\n )\n const name = contentDispositionFileName(response.headers.get('Content-Disposition'))\n return name ? new File([blob], name, { type: blob.type }) : blob\n}\n","/**\n * \"Download with markup\": a document version's markup PDF, the PDF with its annotations as native\n * PDF annotations (comments, highlights, stamps, unapplied redactions), which Acrobat and Preview\n * show. The plain Download serves the original. Kept apart from the annotation layer code so a\n * documents list can offer it without loading the annotation tools.\n *\n * A SIGNED version is locked: nothing but a further signature changes it. Its markup stays in the\n * separate markup layer (a title beside the signature, say) and is never written into its PDF, so\n * it has no \"Download with markup\"; the plain Download is the signed file as it is.\n */\n\nimport type { DocumentToolsClient } from './environment'\n\ninterface DocumentVersions {\n current_version?: number | null\n versions?: Array<{ n: number; markup_count?: number | null; reason?: string | null }> | null\n}\n\n/** Why \"Download with markup\" is off for a signed version. */\nexport const SIGNED_LOCKED_REASON =\n \"Signed documents can't be changed — download the signed file instead\"\n\n/** Whether a version (default: the current one) is a signed copy, per its version entry. */\nexport function isSignedVersion(doc: DocumentVersions, version?: number): boolean {\n const n = version ?? doc.current_version ?? 1\n return (doc.versions ?? []).some((v) => v.n === n && v.reason === 'signed')\n}\n\nexport class MarkupDownloadError extends Error {\n constructor(\n message: string,\n readonly status?: number\n ) {\n super(message)\n this.name = 'MarkupDownloadError'\n }\n}\n\n/** Whether a document's current version has markup (per its version entries). */\nexport function currentHasMarkup(doc: DocumentVersions): boolean {\n const n = doc.current_version ?? 1\n return (doc.versions ?? []).some((v) => v.n === n && (v.markup_count ?? 0) > 0)\n}\n\n/** Fetch a version's markup PDF (default: the current version's). */\nexport async function fetchMarkupPdf(\n client: DocumentToolsClient,\n documentId: string,\n version?: number,\n workspaceExtId?: string\n): Promise<{ blob: Blob; fileName: string }> {\n const { data, response } = await client.GET('/v1/document/{document_ext_id}/markup/pdf', {\n params: {\n path: { document_ext_id: documentId },\n query: {\n ...(version ? { version } : {}),\n ...(workspaceExtId ? { workspace_ext_id: workspaceExtId } : {}),\n },\n },\n parseAs: 'blob',\n })\n if (!response.ok || !data) {\n throw new MarkupDownloadError(\n response.status === 404\n ? 'This document has no markup yet'\n : // The server refuses a signed version: its PDF takes no more changes.\n response.status === 409\n ? SIGNED_LOCKED_REASON\n : 'The markup could not be downloaded',\n response.status\n )\n }\n const disposition = response.headers.get('content-disposition') ?? ''\n const utf8 = /filename\\*=UTF-8''([^;]+)/i.exec(disposition)?.[1]\n const plain = /filename=\"([^\"]+)\"/i.exec(disposition)?.[1]\n const fileName = utf8 ? decodeURIComponent(utf8) : (plain ?? 'markup.pdf')\n return { blob: data as Blob, fileName }\n}\n","/**\n * Electronic signing. The backend (`src/core/esign.py` in ARBI) defines what a signature binds;\n * the helpers mirror the two pieces the browser must reproduce exactly: the statement of intent\n * shown to the signer, and the SHA-256 of the PDF the viewer displayed.\n */\n\nimport { signMessage, unlockIdentityWithPassword, type components } from '@arbidocs/client'\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'\nimport { parseVersionRef } from '../artifacts/versions'\nimport { useDocumentTools, type DocumentToolsClient } from './environment'\nimport { arbiQueryKeys } from '../query-keys'\n\n/**\n * Who signs: the name only. A role, a firm or a place go on the page as ordinary annotation text,\n * which is not part of the signature.\n */\nexport type SignerDetails = components['schemas']['SignerDetails']\n\n/** Same sentence as `esign.intent_text`; the dialog refuses to sign if the server's differs. */\nexport function intentText(signer: SignerDetails): string {\n return `I, ${signer.name.trim()}, sign this document electronically. I intend this electronic signature to have the same effect as my handwritten signature.`\n}\n\nexport async function sha256Hex(blob: Blob): Promise<string> {\n const digest = await crypto.subtle.digest('SHA-256', new Uint8Array(await blob.arrayBuffer()))\n return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, '0')).join('')\n}\n\n/** A signature box drawn on the annotation overlay, as the signing API's placement. */\nexport function toAppearance(box: {\n page: number\n rect: { x: number; y: number; w: number; h: number }\n}): { page: number; x: number; y: number; width: number; height: number } {\n // The layer counts pages from 1, the signing API from 0. Both use fractions of the page as\n // displayed, origin top-left.\n return { page: box.page - 1, x: box.rect.x, y: box.rect.y, width: box.rect.w, height: box.rect.h }\n}\n\n/**\n * The smallest box the backend can draw a legible signature in: the signer's name and the\n * details line shrink to fit, so a box under these fractions of the page is shrunk to near\n * unreadable size. The backend's own default box is 0.40 x 0.10.\n */\nconst MIN_SIGNATURE_BOX = { width: 0.3, height: 0.07 }\n\nexport function isLegibleSignatureBox(rect: { w: number; h: number }): boolean {\n return rect.w >= MIN_SIGNATURE_BOX.width && rect.h >= MIN_SIGNATURE_BOX.height\n}\n\n// ── Signing through the API ─────────────────────────────────────────────────────────────────\n\nexport type SignatureAppearance = components['schemas']['SignatureAppearance']\nexport type SignatureStatusResponse = components['schemas']['SignatureStatusResponse']\nexport type SignatureRecord = components['schemas']['SignatureRecord']\nexport type SignDocumentResponse = components['schemas']['SignDocumentResponse']\n\nconst SIGNATURES_PATH = '/v1/document/{document_ext_id}/signatures'\n/**\n * The same key openapi-react-query gives this request (`['get', path, init]`), so a host that\n * reads or persists the API cache by path treats it like its own queries.\n */\n\nfunction errorDetail(error: unknown, fallback: string): string {\n const detail = (error as { detail?: unknown } | undefined)?.detail\n return typeof detail === 'string' ? detail : fallback\n}\n\n/** Whether a document version is a signed copy, and its signatures. */\nexport async function fetchDocumentSignatures(\n client: DocumentToolsClient,\n documentRef: string\n): Promise<SignatureStatusResponse> {\n const { docId, version } = parseVersionRef(documentRef)\n const { data, error } = await client.GET(SIGNATURES_PATH, {\n params: { path: { document_ext_id: docId }, ...(version ? { query: { version } } : {}) },\n })\n if (!data) throw new Error(errorDetail(error, 'The signatures could not be read'))\n return data\n}\n\n/**\n * Is a document version a signed copy? `documentId` is a document id (its current version) or a\n * version reference `doc-…@v{n}`. Needs a React Query `QueryClientProvider`.\n */\nexport function useDocumentSignatures(documentId: string | null | undefined, enabled = true) {\n const { client } = useDocumentTools()\n const { docId, version } = parseVersionRef(documentId)\n return useQuery({\n queryKey: arbiQueryKeys.documentSignatures(docId ?? '', version),\n queryFn: () => fetchDocumentSignatures(client, documentId!),\n enabled: enabled && !!docId,\n staleTime: 60_000,\n })\n}\n\n/**\n * Why the server would not sign: the PDF of a Word or text document is still being rendered\n * (`preparing`, worth another try in a moment), or the version on screen is no longer the current\n * one (`stale`: only the current version can be signed, so the signer reopens it).\n */\nexport type SigningErrorReason = 'preparing' | 'stale' | 'failed'\n\nexport class SigningError extends Error {\n readonly reason: SigningErrorReason\n constructor(message: string, reason: SigningErrorReason) {\n super(message)\n this.name = 'SigningError'\n this.reason = reason\n }\n}\n\n/** The 409s the backend's signing router raises, told apart by their wording. */\nfunction signingErrorReason(detail: string): SigningErrorReason {\n if (/still being prepared/i.test(detail)) return 'preparing'\n if (/no longer the current version/i.test(detail)) return 'stale'\n return 'failed'\n}\n\nfunction signingError(error: unknown, fallback: string): SigningError {\n const detail = errorDetail(error, fallback)\n return new SigningError(detail, signingErrorReason(detail))\n}\n\n/** How often, and how long apart, a prepare is retried while the PDF is still being rendered. */\nexport const PREPARE_RETRIES = 3\nconst PREPARE_RETRY_DELAY_MS = 1500\n\nconst wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))\n\nexport interface SignDocumentVars {\n documentId: string\n /**\n * The PDF bytes the viewer is showing (`GET /view?version=`, never the original's download): the\n * signer signs exactly these.\n */\n pdfBlob: Blob\n /**\n * The version `pdfBlob` is of. The server signs only the current version and refuses\n * (`SigningError` `stale`) when this one has been superseded. Omitted = the current version.\n */\n version?: number\n email: string\n password: string\n signer: SignerDetails\n /** Where the signature goes; omitted = the backend default (bottom of the last page). */\n appearance?: SignatureAppearance\n /** Draw the signing date under the signature. Default off: only the signature is drawn. */\n includeDate?: boolean\n}\n\n/**\n * Sign a document: the server prepares the statement, the browser checks that it covers the PDF\n * on screen under the wording the signer read, re-derives the user's Ed25519 key from their\n * password and signs it, and the server seals the signed copy as a new version.\n *\n * What is drawn on the page is only the signature (the signer's name as the signature mark) and,\n * with `includeDate`, the date; anyone can click it to open its certificate. A role, a firm or a\n * place go on the page as ordinary annotation text, which is not part of the signature.\n */\nexport async function signDocument(\n client: DocumentToolsClient,\n deploymentDomain: string,\n {\n documentId,\n pdfBlob,\n email,\n password,\n signer,\n appearance,\n includeDate = false,\n version,\n }: SignDocumentVars\n): Promise<SignDocumentResponse> {\n const path = { document_ext_id: documentId }\n // One body for both calls: the server refuses a /sign whose include_date (or placement) differs\n // from what was prepared, since what the signature shows is part of what is signed.\n const body = {\n signer: { name: signer.name },\n ...(appearance ? { appearance } : {}),\n include_date: includeDate,\n ...(version ? { version } : {}),\n }\n\n // A Word or text document's PDF is rendered after upload: while it is, prepare says so, and a\n // short wait usually sees it ready.\n const prepare = () =>\n client.POST('/v1/document/{document_ext_id}/sign/prepare', { params: { path }, body })\n let prepared = await prepare()\n for (let attempt = 0; !prepared.data && attempt < PREPARE_RETRIES; attempt++) {\n if (signingError(prepared.error, '').reason !== 'preparing') break\n await wait(PREPARE_RETRY_DELAY_MS)\n prepared = await prepare()\n }\n if (!prepared.data) throw signingError(prepared.error, 'Could not prepare signing')\n const { statement, intent, source_sha256, timestamp } = prepared.data\n // Sign only what was on screen, under the wording the signer read.\n if ((await sha256Hex(pdfBlob)) !== source_sha256) {\n throw new Error('The document changed since it was opened. Reopen it and sign again.')\n }\n if (intent !== intentText(signer)) throw new Error('Signing statement mismatch; not signed.')\n\n // The re-typed password must open the session's identity, which is the key the server verifies.\n const identity = await unlockIdentityWithPassword(email, password, deploymentDomain)\n const signed = await client.POST('/v1/document/{document_ext_id}/sign', {\n params: { path },\n body: { ...body, timestamp, signature: signMessage(statement, identity) },\n })\n if (!signed.data) throw signingError(signed.error, 'Signing failed')\n return signed.data\n}\n\n/** The signing mutation. On success the host hears the document changed (`'signed'`). */\nexport function useSignDocument() {\n const env = useDocumentTools()\n const queryClient = useQueryClient()\n return useMutation({\n mutationFn: (vars: SignDocumentVars) => {\n if (!env.deploymentDomain) throw new Error('Signing is not set up: no deployment domain')\n return signDocument(env.client, env.deploymentDomain, vars)\n },\n onSuccess: async (result) => {\n // The signed copy is the document's new current version: the host refreshes its row,\n // versions and rendered PDF, and the signature badge reads again.\n await env.onDocumentsChanged?.([result.doc_ext_id], 'signed')\n await queryClient.invalidateQueries({ queryKey: arbiQueryKeys.documentSignatures() })\n },\n })\n}\n","import { useCallback } from 'react'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { arbiQueryKeys } from '../query-keys'\n/** Share one immutable file version with named recipients, independently of workspace membership. */\nimport { signMessage, unlockIdentityWithPassword, type components } from '@arbidocs/client'\nimport type { DocumentToolsClient } from './environment'\nimport { intentText, sha256Hex } from './signing'\nimport type {\n SignatureRequest,\n SignRequestVars,\n SignRequestSignResponse,\n} from './signature-requests'\n\nexport type FileShare = components['schemas']['FileShareResponse']\nexport type CreateFileShare = components['schemas']['CreateFileShare']\n\nfunction failure(error: unknown): Error {\n const detail = (error as { detail?: unknown } | undefined)?.detail\n return new Error(typeof detail === 'string' ? detail : 'The shared file request failed')\n}\n\nexport async function createFileShare(\n client: DocumentToolsClient,\n documentId: string,\n body: CreateFileShare\n) {\n const result = await client.POST('/v1/document/{document_ext_id}/file-shares', {\n params: { path: { document_ext_id: documentId } },\n body,\n })\n if (!result.data) throw failure(result.error)\n return result.data\n}\n\nexport async function getFileShare(client: DocumentToolsClient, id: string): Promise<FileShare> {\n const result = await client.GET('/v1/file-shares/{share_id}', {\n params: { path: { share_id: id } },\n })\n if (!result.data) throw failure(result.error)\n return result.data\n}\n\nexport async function fileShareBytes(\n client: DocumentToolsClient,\n id: string,\n kind: 'view' | 'original' | 'signed'\n) {\n const result = await client.GET('/v1/file-shares/{share_id}/file', {\n params: { path: { share_id: id }, query: { kind } },\n parseAs: 'blob',\n })\n if (!result.data) throw failure(result.error)\n return result.data\n}\n\n/** Adapt only the guided viewer's presentation data; sharing uses its own authorization endpoints. */\nexport function fileShareSigningRequest(share: FileShare): SignatureRequest {\n return {\n external_id: share.external_id,\n doc_ext_id: share.document_ext_id,\n version: share.version,\n source_sha256: share.source_sha256,\n fields: share.fields,\n message: share.message,\n status:\n share.status === 'signing' ? 'sent' : share.status === 'completed' ? 'completed' : 'voided',\n signers: share.recipients\n .filter((r) => r.permission === 'sign')\n .map((r) => ({\n external_id: r.email,\n email: r.email,\n name: r.email,\n status: r.status === 'signed' ? 'signed' : 'pending',\n progress: r.status === 'signed' ? 'signed' : 'registered',\n fields: share.fields.filter((f) => f.signer === r.email).length,\n })),\n created_at: new Date(0).toISOString(),\n stale: false,\n }\n}\n\nexport async function signFileShare(\n client: DocumentToolsClient,\n domain: string,\n vars: SignRequestVars\n): Promise<SignRequestSignResponse> {\n const path = { share_id: vars.request.external_id }\n const body = { adopted: vars.adopted, fields: vars.fields }\n const prepared = await client.POST('/v1/file-shares/{share_id}/sign/prepare', {\n params: { path },\n body,\n })\n if (!prepared.data) throw failure(prepared.error)\n const { statement, timestamp, source_sha256, intent } = prepared.data\n if (\n source_sha256 !== vars.request.source_sha256 ||\n (await sha256Hex(vars.pdfBlob)) !== source_sha256\n )\n throw new Error('The shared file changed. Ask the sender for a new request.')\n if (intent !== intentText({ name: vars.adopted.name }))\n throw new Error('Signing statement mismatch')\n const identity = await unlockIdentityWithPassword(vars.email, vars.password, domain)\n const result = await client.POST('/v1/file-shares/{share_id}/sign', {\n params: { path },\n body: { ...body, timestamp, signature: signMessage(statement, identity) },\n })\n if (!result.data) throw failure(result.error)\n return {\n request: fileShareSigningRequest(result.data),\n completed: result.data.status === 'completed',\n }\n}\n\nexport function useFileShare(client: DocumentToolsClient, shareId: string, signing: boolean) {\n return useQuery({\n queryKey: arbiQueryKeys.fileShare(shareId),\n queryFn: () => getFileShare(client, shareId),\n refetchInterval: signing ? false : 5000,\n })\n}\n\nexport function useFileSharePdf(client: DocumentToolsClient, shareId: string, share?: FileShare) {\n return useQuery({\n queryKey: arbiQueryKeys.fileSharePdf(shareId, share?.status),\n queryFn: () =>\n fileShareBytes(client, shareId, share?.status === 'completed' ? 'signed' : 'view'),\n enabled: !!share?.can_preview,\n staleTime: Infinity,\n })\n}\n\n/** The shares I created or was invited to (revoked and expired ones are not listed). Listing does\n * not open a share, so it never starts a recipient's access window. Null client: not loaded. */\nexport function useFileShares(client: DocumentToolsClient | null) {\n return useQuery({\n queryKey: arbiQueryKeys.fileShares(),\n queryFn: async () => {\n const result = await client?.GET('/v1/file-shares')\n if (!result?.data) throw new Error('Could not load shared files')\n return result.data\n },\n enabled: !!client,\n })\n}\n\n/** Read the share list again (after a change made to a share: signed, declined, saved, revoked). */\nexport function useRefreshFileShares(): () => Promise<void> {\n const queryClient = useQueryClient()\n return useCallback(\n () => queryClient.invalidateQueries({ queryKey: arbiQueryKeys.fileShares() }),\n [queryClient]\n )\n}\n\n/**\n * Save a completed share's signed PDF as its document's next version, in the share's workspace\n * (its key must be on the session: open that workspace first).\n */\nexport async function publishFileShare(client: DocumentToolsClient, share: FileShare) {\n const result = await client.POST(\n '/v1/document/{document_ext_id}/file-shares/{share_id}/publish',\n { params: { path: { document_ext_id: share.document_ext_id, share_id: share.external_id } } }\n )\n if (!result.data) throw new Error('Could not save the signed version to its workspace')\n return result.data\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/document-tools/environment.tsx","../src/document-tools/document-pdf.ts","../src/document-tools/markup-download.ts","../src/document-tools/signing.ts","../src/document-tools/file-shares.ts"],"names":["createContext","useDeploymentDomain","useRef","useCallback","useMemo","jsx","useContext","parseVersionRef","useQuery","arbiQueryKeys","client","unlockIdentityWithPassword","signMessage","useQueryClient","useMutation"],"mappings":";;;;;;;;;AAmEO,SAAS,kBAAkB,KAAA,EAAoC;AACpE,EAAA,MAAM,MAAA,GAAS,IAAI,eAAA,EAAgB;AACnC,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,EAAG;AAChD,IAAA,IAAI,KAAA,KAAU,IAAA,IAAQ,KAAA,KAAU,MAAA,EAAW;AAC3C,IAAA,KAAA,MAAW,IAAA,IAAQ,KAAA,CAAM,OAAA,CAAQ,KAAK,IAAI,KAAA,GAAQ,CAAC,KAAK,CAAA,EAAG,MAAA,CAAO,MAAA,CAAO,GAAA,EAAK,MAAA,CAAO,IAAI,CAAC,CAAA;AAAA,EAC5F;AACA,EAAA,OAAO,OAAO,QAAA,EAAS;AACzB;AAqDO,SAAS,YAAA,CAAa,MAAY,QAAA,EAAwB;AAC/D,EAAA,MAAM,GAAA,GAAM,GAAA,CAAI,eAAA,CA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;AACH;AAIO,SAAS,cAAc,MAAA,EAAoC;AAChE,EAAA,OAAOD,mBAAAA,CAAS;AAAA,IACd,QAAA,EAAUC,gCAAc,UAAA,EAAW;AAAA,IACnC,SAAS,YAAY;AACnB,MAAA,MAAM,MAAA,GAAS,MAAM,MAAA,EAAQ,GAAA,CAAI,iBAAiB,CAAA;AAClD,MAAA,IAAI,CAAC,MAAA,EAAQ,IAAA,EAAM,MAAM,IAAI,MAAM,6BAA6B,CAAA;AAChE,MAAA,OAAO,MAAA,CAAO,IAAA;AAAA,IAChB,CAAA;AAAA,IACA,OAAA,EAAS,CAAC,CAAC;AAAA,GACZ,CAAA;AACH;AAGO,SAAS,oBAAA,GAA4C;AAC1D,EAAA,MAAM,cAAcI,yBAAAA,EAAe;AACnC,EAAA,OAAOV,iBAAAA;AAAA,IACL,MAAM,YAAY,iBAAA,CAAkB,EAAE,UAAUM,+BAAA,CAAc,UAAA,IAAc,CAAA;AAAA,IAC5E,CAAC,WAAW;AAAA,GACd;AACF;AAMA,eAAsB,gBAAA,CAAiB,QAA6B,KAAA,EAAkB;AACpF,EAAA,MAAM,MAAA,GAAS,MAAM,MAAA,CAAO,IAAA;AAAA,IAC1B,+DAAA;AAAA,IACA,EAAE,MAAA,EAAQ,EAAE,IAAA,EAAM,EAAE,eAAA,EAAiB,KAAA,CAAM,eAAA,EAAiB,QAAA,EAAU,KAAA,CAAM,WAAA,EAAY,EAAE;AAAE,GAC9F;AACA,EAAA,IAAI,CAAC,MAAA,CAAO,IAAA,EAAM,MAAM,IAAI,MAAM,oDAAoD,CAAA;AACtF,EAAA,OAAO,MAAA,CAAO,IAAA;AAChB","file":"chunk-TX7UCN73.cjs","sourcesContent":["/**\n * The host app's side of the document tools (markup, freeze, e-signing, versions): the one place\n * the tools reach the app. They never import a store, a router, a toast library or app API code;\n * the host passes what it has to `<DocumentToolsProvider>` and every optional field has a default.\n *\n * `client` is an openapi-fetch client for the ARBI API (`ArbiClient['fetch']` from\n * `@arbidocs/client`, or `arbi.getClient().fetch` from an `@arbidocs/sdk` `Arbi`), signed in with the\n * user's session; it carries the auth.\n */\n\nimport { createContext, useCallback, useContext, useMemo, useRef, type ReactNode } from 'react'\nimport type { ArbiClient, operations } from '@arbidocs/client'\nimport { useDeploymentDomain } from '../useArbi'\n\nexport type DocumentToolsClient = ArbiClient['fetch']\n\nexport type DocumentToolsNoticeKind = 'success' | 'error' | 'info' | 'warning'\n\nexport interface DocumentToolsNoticeOptions {\n /** A second line under the message. */\n description?: string\n /** One action button on the notice (\"Email it\"). */\n action?: { label: string; onClick: () => void }\n}\n\nexport type DocumentToolsNotify = (\n message: string,\n kind: DocumentToolsNoticeKind,\n options?: DocumentToolsNoticeOptions\n) => void\n\nexport interface DocumentToolsUser {\n /** The name marks are authored as and the signer's name is prefilled with. */\n name: string\n /** The sign-in email: signing re-derives the user's key from it and the password. */\n email?: string | null\n /** The user's id (usr-*): which fields of a signature request are theirs. */\n externalId?: string | null\n}\n\n/** What changed about a document, so the host can refresh its own lists and caches. */\nexport type DocumentChange =\n /** A version's markup got its first mark or lost its last one. */\n | 'markup'\n /** A signature was added: the document has a new current version. */\n | 'signed'\n /** A new document was made from it (a frozen copy). The ids are the NEW documents. */\n | 'copy'\n /** A new version was saved (the Word editor's Save version): the document's current version. */\n | 'version'\n\n/**\n * The `/v1/document/upload` query, typed from the API schema: `derived_from` is a list (a\n * production set is derived from every document in it), `shared` a boolean.\n */\nexport type DocumentUploadQuery = NonNullable<operations['upload_documents']['parameters']['query']>\n\nexport interface DocumentUploadRequest {\n file: File\n /** `/v1/document/upload` query: `derived_from`, `derived_role`, `shared`, `folder`. */\n query: DocumentUploadQuery\n}\n\n/**\n * The upload query as a URL query string, for a host that posts the upload itself (an XHR with\n * progress): a list repeats its key (`derived_from=a&derived_from=b`), empty values are left out.\n */\nexport function uploadQueryString(query: DocumentUploadQuery): string {\n const params = new URLSearchParams()\n for (const [key, value] of Object.entries(query)) {\n if (value === null || value === undefined) continue\n for (const item of Array.isArray(value) ? value : [value]) params.append(key, String(item))\n }\n return params.toString()\n}\n\nexport interface DocumentToolsEnvironment {\n client: DocumentToolsClient\n /**\n * The deployment domain the user's keys are derived for. Needed for signing. Default: the one\n * the host's `Arbi` computes (`arbi.getDeploymentDomain()`), if any.\n */\n deploymentDomain?: string\n /** The signed-in user; marks are authored as \"You\" without one, and signing is unavailable. */\n user?: DocumentToolsUser | null\n /** Surface a transient message. Default: none (errors still show inline where they can). */\n notify?: DocumentToolsNotify\n /** Open a document or a version reference (`doc-…@v2`): the copy just made, the signed copy. */\n openDocument?: (documentRef: string) => void\n /**\n * Documents changed on the server (see {@link DocumentChange}); refresh the host's lists. The\n * tools wait for it before opening the document, so a copy is listed when it opens.\n */\n onDocumentsChanged?: (documentIds: string[], change: DocumentChange) => void | Promise<void>\n /** Upload a derived copy. Default: `POST /v1/document/upload` through `client`. */\n uploadDocument?: (\n request: DocumentUploadRequest\n ) => Promise<{ doc_ext_ids?: string[] } | undefined>\n /** Save a file to the user's computer. Default: a temporary download link. */\n saveFile?: (blob: Blob, fileName: string) => void\n /** Email a document (offered once it is signed). Omitted: no \"Email it\". */\n emailDocument?: (documentRef: string) => void\n /**\n * The public page that checks a signature (the certificate) in this app. When given, \"View\n * certificate\" opens it in preference to the backend's `certificate_url` (which is on the\n * deployment domain, like the link embedded in the signed PDF). Without it: the backend's\n * `certificate_url`, else `/verify/{reference}` on this origin.\n */\n certificateUrl?: (reference: string) => string\n}\n\n/** The environment with every default filled in. */\nexport interface ResolvedDocumentToolsEnvironment extends DocumentToolsEnvironment {\n prepareFileShare: (documentId: string) => Promise<void>\n registerBeforeFileShare: (documentId: string, flush: () => Promise<void>) => () => void\n notify: DocumentToolsNotify\n saveFile: (blob: Blob, fileName: string) => void\n uploadDocument: (\n request: DocumentUploadRequest\n ) => Promise<{ doc_ext_ids?: string[] } | undefined>\n}\n\n/**\n * Save a blob through a temporary `<a download>`. The object URL is revoked a minute later, not at\n * once: revoking straight after `click()` can cancel the download (Safari, and large files\n * elsewhere) before the browser has read the blob.\n */\nexport function downloadBlob(blob: Blob, fileName: string): void {\n const url = URL.createObjectURL(blob)\n const a = document.createElement('a')\n a.href = url\n a.download = fileName\n document.body.appendChild(a)\n a.click()\n a.remove()\n setTimeout(() => URL.revokeObjectURL(url), 60_000)\n}\n\n/** The default upload: multipart `files` to `/v1/document/upload` through the API client. */\nexport function clientUpload(client: DocumentToolsClient) {\n return async ({ file, query }: DocumentUploadRequest) => {\n const formData = new FormData()\n formData.append('files', file)\n const { data, response } = await client.POST('/v1/document/upload', {\n params: { query },\n // The schema types the multipart body as `{ files: string[] }`; the FormData is sent as is.\n body: formData as unknown as { files: string[] },\n bodySerializer: () => formData,\n })\n if (!response.ok) throw new Error(`Upload failed with status ${response.status}`)\n return data\n }\n}\n\nexport function defaultCertificateUrl(reference: string): string {\n const origin = typeof location === 'undefined' ? '' : location.origin\n return `${origin}/verify/${encodeURIComponent(reference)}`\n}\n\n/**\n * Where \"View certificate\" goes for a signature: the host's `certificateUrl(reference)` when it\n * gives one, else the `certificate_url` the backend returned, else `/verify/{reference}` here.\n */\nexport function certificateLink(\n signature: { reference: string; certificate_url?: string | null },\n certificateUrl?: (reference: string) => string\n): string {\n if (certificateUrl) return certificateUrl(signature.reference)\n return signature.certificate_url || defaultCertificateUrl(signature.reference)\n}\n\nconst DocumentToolsContext = createContext<ResolvedDocumentToolsEnvironment | null>(null)\n\nexport interface DocumentToolsProviderProps extends DocumentToolsEnvironment {\n children: ReactNode\n}\n\nexport function DocumentToolsProvider({ children, ...env }: DocumentToolsProviderProps) {\n const arbiDeploymentDomain = useDeploymentDomain()\n const guards = useRef(new Map<string, () => Promise<void>>())\n const pendingFlushes = useRef(new Map<string, Promise<void>>())\n const registerBeforeFileShare = useCallback((id: string, flush: () => Promise<void>) => {\n guards.current.set(id, flush)\n return () => {\n if (guards.current.get(id) !== flush) return\n guards.current.delete(id)\n const pending = flush()\n pendingFlushes.current.set(id, pending)\n void pending.then(\n () => {\n if (pendingFlushes.current.get(id) === pending) pendingFlushes.current.delete(id)\n },\n () => {}\n )\n }\n }, [])\n const prepareFileShare = useCallback(async (id: string) => {\n const guard = guards.current.get(id)\n if (guard) {\n await guard()\n pendingFlushes.current.delete(id)\n } else await pendingFlushes.current.get(id)\n }, [])\n const {\n client,\n deploymentDomain,\n user,\n notify,\n openDocument,\n onDocumentsChanged,\n uploadDocument,\n saveFile,\n emailDocument,\n certificateUrl,\n } = env\n const value = useMemo<ResolvedDocumentToolsEnvironment>(\n () => ({\n client,\n prepareFileShare,\n registerBeforeFileShare,\n deploymentDomain: deploymentDomain ?? arbiDeploymentDomain,\n user,\n openDocument,\n onDocumentsChanged,\n emailDocument,\n notify: notify ?? (() => {}),\n saveFile: saveFile ?? downloadBlob,\n uploadDocument: uploadDocument ?? clientUpload(client),\n certificateUrl,\n }),\n [\n client,\n prepareFileShare,\n registerBeforeFileShare,\n deploymentDomain,\n arbiDeploymentDomain,\n user,\n notify,\n openDocument,\n onDocumentsChanged,\n uploadDocument,\n saveFile,\n emailDocument,\n certificateUrl,\n ]\n )\n return <DocumentToolsContext.Provider value={value}>{children}</DocumentToolsContext.Provider>\n}\n\n/** The host's environment, or `null` outside a `<DocumentToolsProvider>`. */\nexport function useOptionalDocumentTools(): ResolvedDocumentToolsEnvironment | null {\n return useContext(DocumentToolsContext)\n}\n\n/** The host's environment; throws outside a `<DocumentToolsProvider>`. */\nexport function useDocumentTools(): ResolvedDocumentToolsEnvironment {\n const env = useContext(DocumentToolsContext)\n if (!env) throw new Error('The document tools must be used within a <DocumentToolsProvider>')\n return env\n}\n","/**\n * A document's bytes, through the host's API client: the PDF the viewer and the tools draw on\n * (`/view`: the file itself for a PDF, its PDF rendering for a Word or text file) and the stored\n * file (`/download`). Either takes a document id or a version reference `doc-…@v{n}`.\n */\n\nimport { parseVersionRef } from '../artifacts/versions'\nimport type { DocumentToolsClient } from './environment'\n\nexport interface DocumentFetchOptions {\n /** The version to fetch. Default: the one `documentRef` names, else the current version. */\n version?: number | null\n workspaceExtId?: string\n signal?: AbortSignal\n}\n\n/** A document's bytes could not be fetched; `status` is the HTTP status. */\nexport class DocumentFetchError extends Error {\n readonly status: number\n constructor(message: string, status: number) {\n super(message)\n this.name = 'DocumentFetchError'\n this.status = status\n }\n}\n\nasync function fetchDocumentBytes(\n client: DocumentToolsClient,\n endpoint: '/v1/document/{document_ext_id}/view' | '/v1/document/{document_ext_id}/download',\n documentRef: string,\n options: DocumentFetchOptions,\n headers: Record<string, string>,\n what: string\n): Promise<{ blob: Blob; response: Response }> {\n const ref = parseVersionRef(documentRef)\n const version = options.version ?? ref.version\n const { data, response } = await client.GET(endpoint, {\n params: {\n path: { document_ext_id: ref.docId },\n query: {\n ...(version ? { version } : {}),\n ...(options.workspaceExtId ? { workspace_ext_id: options.workspaceExtId } : {}),\n },\n },\n headers,\n parseAs: 'blob',\n signal: options.signal,\n })\n if (!response.ok || !(data instanceof Blob)) {\n throw new DocumentFetchError(\n `${what} could not be loaded (${response.status})`,\n response.status\n )\n }\n return { blob: data, response }\n}\n\n/**\n * The file name a `Content-Disposition` header gives, or `undefined`. Prefers the RFC 5987\n * `filename*=UTF-8''…` form (percent-encoded, any script) over the plain `filename=`.\n */\nexport function contentDispositionFileName(header: string | null | undefined): string | undefined {\n if (!header) return undefined\n const extended = /filename\\*\\s*=\\s*(?:[\\w-]+)?'[^']*'([^;]+)/i.exec(header)\n if (extended) {\n try {\n return decodeURIComponent(extended[1].trim().replace(/^\"|\"$/g, '')) || undefined\n } catch {\n // A malformed escape: fall back to the plain parameter.\n }\n }\n const plain = /filename\\s*=\\s*(\"((?:[^\"\\\\]|\\\\.)*)\"|[^;]+)/i.exec(header)\n if (!plain) return undefined\n const name = plain[2] !== undefined ? plain[2].replace(/\\\\(.)/g, '$1') : plain[1].trim()\n return name || undefined\n}\n\n/**\n * The PDF of a document version: `GET /v1/document/{id}/view?version=` with\n * `Accept: application/pdf`. Throws a {@link DocumentFetchError} when there is none (yet).\n */\nexport async function fetchDocumentPdf(\n client: DocumentToolsClient,\n documentRef: string,\n options: DocumentFetchOptions = {}\n): Promise<Blob> {\n const { blob } = await fetchDocumentBytes(\n client,\n '/v1/document/{document_ext_id}/view',\n documentRef,\n options,\n { Accept: 'application/pdf' },\n 'The PDF'\n )\n return blob\n}\n\n/**\n * The stored file of a document version, as uploaded: `GET /v1/document/{id}/download`. When the\n * server names the file (`Content-Disposition`), the result is a `File` carrying that name.\n */\nexport async function fetchDocumentFile(\n client: DocumentToolsClient,\n documentRef: string,\n options: DocumentFetchOptions = {}\n): Promise<Blob | File> {\n const { blob, response } = await fetchDocumentBytes(\n client,\n '/v1/document/{document_ext_id}/download',\n documentRef,\n options,\n {},\n 'The file'\n )\n const name = contentDispositionFileName(response.headers.get('Content-Disposition'))\n return name ? new File([blob], name, { type: blob.type }) : blob\n}\n","/**\n * \"Download with markup\": a document version's markup PDF, the PDF with its annotations as native\n * PDF annotations (comments, highlights, stamps, unapplied redactions), which Acrobat and Preview\n * show. The plain Download serves the original. Kept apart from the annotation layer code so a\n * documents list can offer it without loading the annotation tools.\n *\n * A SIGNED version is locked: nothing but a further signature changes it. Its markup stays in the\n * separate markup layer (a title beside the signature, say) and is never written into its PDF, so\n * it has no \"Download with markup\"; the plain Download is the signed file as it is.\n */\n\nimport type { DocumentToolsClient } from './environment'\n\ninterface DocumentVersions {\n current_version?: number | null\n versions?: Array<{ n: number; markup_count?: number | null; reason?: string | null }> | null\n}\n\n/** Why \"Download with markup\" is off for a signed version. */\nexport const SIGNED_LOCKED_REASON =\n \"Signed documents can't be changed — download the signed file instead\"\n\n/** Whether a version (default: the current one) is a signed copy, per its version entry. */\nexport function isSignedVersion(doc: DocumentVersions, version?: number): boolean {\n const n = version ?? doc.current_version ?? 1\n return (doc.versions ?? []).some((v) => v.n === n && v.reason === 'signed')\n}\n\nexport class MarkupDownloadError extends Error {\n constructor(\n message: string,\n readonly status?: number\n ) {\n super(message)\n this.name = 'MarkupDownloadError'\n }\n}\n\n/** Whether a document's current version has markup (per its version entries). */\nexport function currentHasMarkup(doc: DocumentVersions): boolean {\n const n = doc.current_version ?? 1\n return (doc.versions ?? []).some((v) => v.n === n && (v.markup_count ?? 0) > 0)\n}\n\n/** Fetch a version's markup PDF (default: the current version's). */\nexport async function fetchMarkupPdf(\n client: DocumentToolsClient,\n documentId: string,\n version?: number,\n workspaceExtId?: string\n): Promise<{ blob: Blob; fileName: string }> {\n const { data, response } = await client.GET('/v1/document/{document_ext_id}/markup/pdf', {\n params: {\n path: { document_ext_id: documentId },\n query: {\n ...(version ? { version } : {}),\n ...(workspaceExtId ? { workspace_ext_id: workspaceExtId } : {}),\n },\n },\n parseAs: 'blob',\n })\n if (!response.ok || !data) {\n throw new MarkupDownloadError(\n response.status === 404\n ? 'This document has no markup yet'\n : // The server refuses a signed version: its PDF takes no more changes.\n response.status === 409\n ? SIGNED_LOCKED_REASON\n : 'The markup could not be downloaded',\n response.status\n )\n }\n const disposition = response.headers.get('content-disposition') ?? ''\n const utf8 = /filename\\*=UTF-8''([^;]+)/i.exec(disposition)?.[1]\n const plain = /filename=\"([^\"]+)\"/i.exec(disposition)?.[1]\n const fileName = utf8 ? decodeURIComponent(utf8) : (plain ?? 'markup.pdf')\n return { blob: data as Blob, fileName }\n}\n","/**\n * Electronic signing. The backend (`src/core/esign.py` in ARBI) defines what a signature binds;\n * the helpers mirror the two pieces the browser must reproduce exactly: the statement of intent\n * shown to the signer, and the SHA-256 of the PDF the viewer displayed.\n */\n\nimport { signMessage, unlockIdentityWithPassword, type components } from '@arbidocs/client'\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'\nimport { parseVersionRef } from '../artifacts/versions'\nimport { useDocumentTools, type DocumentToolsClient } from './environment'\nimport { arbiQueryKeys } from '../query-keys'\n\n/**\n * Who signs: the name only. A role, a firm or a place go on the page as ordinary annotation text,\n * which is not part of the signature.\n */\nexport type SignerDetails = components['schemas']['SignerDetails']\n\n/** Same sentence as `esign.intent_text`; the dialog refuses to sign if the server's differs. */\nexport function intentText(signer: SignerDetails): string {\n return `I, ${signer.name.trim()}, sign this document electronically. I intend this electronic signature to have the same effect as my handwritten signature.`\n}\n\nexport async function sha256Hex(blob: Blob): Promise<string> {\n const digest = await crypto.subtle.digest('SHA-256', new Uint8Array(await blob.arrayBuffer()))\n return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, '0')).join('')\n}\n\n/** A signature box drawn on the annotation overlay, as the signing API's placement. */\nexport function toAppearance(box: {\n page: number\n rect: { x: number; y: number; w: number; h: number }\n}): { page: number; x: number; y: number; width: number; height: number } {\n // The layer counts pages from 1, the signing API from 0. Both use fractions of the page as\n // displayed, origin top-left.\n return { page: box.page - 1, x: box.rect.x, y: box.rect.y, width: box.rect.w, height: box.rect.h }\n}\n\n/**\n * The smallest box the backend can draw a legible signature in: the signer's name and the\n * details line shrink to fit, so a box under these fractions of the page is shrunk to near\n * unreadable size. The backend's own default box is 0.40 x 0.10.\n */\nconst MIN_SIGNATURE_BOX = { width: 0.3, height: 0.07 }\n\nexport function isLegibleSignatureBox(rect: { w: number; h: number }): boolean {\n return rect.w >= MIN_SIGNATURE_BOX.width && rect.h >= MIN_SIGNATURE_BOX.height\n}\n\n// ── Signing through the API ─────────────────────────────────────────────────────────────────\n\nexport type SignatureAppearance = components['schemas']['SignatureAppearance']\nexport type SignatureStatusResponse = components['schemas']['SignatureStatusResponse']\nexport type SignatureRecord = components['schemas']['SignatureRecord']\nexport type SignDocumentResponse = components['schemas']['SignDocumentResponse']\n\nconst SIGNATURES_PATH = '/v1/document/{document_ext_id}/signatures'\n/**\n * The same key openapi-react-query gives this request (`['get', path, init]`), so a host that\n * reads or persists the API cache by path treats it like its own queries.\n */\n\nfunction errorDetail(error: unknown, fallback: string): string {\n const detail = (error as { detail?: unknown } | undefined)?.detail\n return typeof detail === 'string' ? detail : fallback\n}\n\n/** Whether a document version is a signed copy, and its signatures. */\nexport async function fetchDocumentSignatures(\n client: DocumentToolsClient,\n documentRef: string\n): Promise<SignatureStatusResponse> {\n const { docId, version } = parseVersionRef(documentRef)\n const { data, error } = await client.GET(SIGNATURES_PATH, {\n params: { path: { document_ext_id: docId }, ...(version ? { query: { version } } : {}) },\n })\n if (!data) throw new Error(errorDetail(error, 'The signatures could not be read'))\n return data\n}\n\n/**\n * Is a document version a signed copy? `documentId` is a document id (its current version) or a\n * version reference `doc-…@v{n}`. Needs a React Query `QueryClientProvider`.\n */\nexport function useDocumentSignatures(documentId: string | null | undefined, enabled = true) {\n const { client } = useDocumentTools()\n const { docId, version } = parseVersionRef(documentId)\n return useQuery({\n queryKey: arbiQueryKeys.documentSignatures(docId ?? '', version),\n queryFn: () => fetchDocumentSignatures(client, documentId!),\n enabled: enabled && !!docId,\n staleTime: 60_000,\n })\n}\n\n/**\n * Why the server would not sign: the PDF of a Word or text document is still being rendered\n * (`preparing`, worth another try in a moment), or the version on screen is no longer the current\n * one (`stale`: only the current version can be signed, so the signer reopens it).\n */\nexport type SigningErrorReason = 'preparing' | 'stale' | 'failed'\n\nexport class SigningError extends Error {\n readonly reason: SigningErrorReason\n constructor(message: string, reason: SigningErrorReason) {\n super(message)\n this.name = 'SigningError'\n this.reason = reason\n }\n}\n\n/** The 409s the backend's signing router raises, told apart by their wording. */\nfunction signingErrorReason(detail: string): SigningErrorReason {\n if (/still being prepared/i.test(detail)) return 'preparing'\n if (/no longer the current version/i.test(detail)) return 'stale'\n return 'failed'\n}\n\nfunction signingError(error: unknown, fallback: string): SigningError {\n const detail = errorDetail(error, fallback)\n return new SigningError(detail, signingErrorReason(detail))\n}\n\n/** How often, and how long apart, a prepare is retried while the PDF is still being rendered. */\nexport const PREPARE_RETRIES = 3\nconst PREPARE_RETRY_DELAY_MS = 1500\n\nconst wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))\n\nexport interface SignDocumentVars {\n documentId: string\n /**\n * The PDF bytes the viewer is showing (`GET /view?version=`, never the original's download): the\n * signer signs exactly these.\n */\n pdfBlob: Blob\n /**\n * The version `pdfBlob` is of. The server signs only the current version and refuses\n * (`SigningError` `stale`) when this one has been superseded. Omitted = the current version.\n */\n version?: number\n email: string\n password: string\n signer: SignerDetails\n /** Where the signature goes; omitted = the backend default (bottom of the last page). */\n appearance?: SignatureAppearance\n /** Draw the signing date under the signature. Default off: only the signature is drawn. */\n includeDate?: boolean\n}\n\n/**\n * Sign a document: the server prepares the statement, the browser checks that it covers the PDF\n * on screen under the wording the signer read, re-derives the user's Ed25519 key from their\n * password and signs it, and the server seals the signed copy as a new version.\n *\n * What is drawn on the page is only the signature (the signer's name as the signature mark) and,\n * with `includeDate`, the date; anyone can click it to open its certificate. A role, a firm or a\n * place go on the page as ordinary annotation text, which is not part of the signature.\n */\nexport async function signDocument(\n client: DocumentToolsClient,\n deploymentDomain: string,\n {\n documentId,\n pdfBlob,\n email,\n password,\n signer,\n appearance,\n includeDate = false,\n version,\n }: SignDocumentVars\n): Promise<SignDocumentResponse> {\n const path = { document_ext_id: documentId }\n // One body for both calls: the server refuses a /sign whose include_date (or placement) differs\n // from what was prepared, since what the signature shows is part of what is signed.\n const body = {\n signer: { name: signer.name },\n ...(appearance ? { appearance } : {}),\n include_date: includeDate,\n ...(version ? { version } : {}),\n }\n\n // A Word or text document's PDF is rendered after upload: while it is, prepare says so, and a\n // short wait usually sees it ready.\n const prepare = () =>\n client.POST('/v1/document/{document_ext_id}/sign/prepare', { params: { path }, body })\n let prepared = await prepare()\n for (let attempt = 0; !prepared.data && attempt < PREPARE_RETRIES; attempt++) {\n if (signingError(prepared.error, '').reason !== 'preparing') break\n await wait(PREPARE_RETRY_DELAY_MS)\n prepared = await prepare()\n }\n if (!prepared.data) throw signingError(prepared.error, 'Could not prepare signing')\n const { statement, intent, source_sha256, timestamp } = prepared.data\n // Sign only what was on screen, under the wording the signer read.\n if ((await sha256Hex(pdfBlob)) !== source_sha256) {\n throw new Error('The document changed since it was opened. Reopen it and sign again.')\n }\n if (intent !== intentText(signer)) throw new Error('Signing statement mismatch; not signed.')\n\n // The re-typed password must open the session's identity, which is the key the server verifies.\n const identity = await unlockIdentityWithPassword(email, password, deploymentDomain)\n const signed = await client.POST('/v1/document/{document_ext_id}/sign', {\n params: { path },\n body: { ...body, timestamp, signature: signMessage(statement, identity) },\n })\n if (!signed.data) throw signingError(signed.error, 'Signing failed')\n return signed.data\n}\n\n/** The signing mutation. On success the host hears the document changed (`'signed'`). */\nexport function useSignDocument() {\n const env = useDocumentTools()\n const queryClient = useQueryClient()\n return useMutation({\n mutationFn: (vars: SignDocumentVars) => {\n if (!env.deploymentDomain) throw new Error('Signing is not set up: no deployment domain')\n return signDocument(env.client, env.deploymentDomain, vars)\n },\n onSuccess: async (result) => {\n // The signed copy is the document's new current version: the host refreshes its row,\n // versions and rendered PDF, and the signature badge reads again.\n await env.onDocumentsChanged?.([result.doc_ext_id], 'signed')\n await queryClient.invalidateQueries({ queryKey: arbiQueryKeys.documentSignatures() })\n },\n })\n}\n","import { useCallback } from 'react'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { arbiQueryKeys } from '../query-keys'\n/** Share one immutable file version with named recipients, independently of workspace membership. */\nimport { signMessage, unlockIdentityWithPassword, type components } from '@arbidocs/client'\nimport type { DocumentToolsClient } from './environment'\nimport { intentText, sha256Hex } from './signing'\nimport type {\n SignatureRequest,\n SignRequestVars,\n SignRequestSignResponse,\n} from './signature-requests'\n\nexport type FileShare = components['schemas']['FileShareResponse']\nexport type CreateFileShare = components['schemas']['CreateFileShare']\n\nfunction failure(error: unknown): Error {\n const detail = (error as { detail?: unknown } | undefined)?.detail\n return new Error(typeof detail === 'string' ? detail : 'The shared file request failed')\n}\n\nexport async function createFileShare(\n client: DocumentToolsClient,\n documentId: string,\n body: CreateFileShare\n) {\n const result = await client.POST('/v1/document/{document_ext_id}/file-shares', {\n params: { path: { document_ext_id: documentId } },\n body,\n })\n if (!result.data) throw failure(result.error)\n return result.data\n}\n\nexport async function getFileShare(client: DocumentToolsClient, id: string): Promise<FileShare> {\n const result = await client.GET('/v1/file-shares/{share_id}', {\n params: { path: { share_id: id } },\n })\n if (!result.data) throw failure(result.error)\n return result.data\n}\n\nexport async function fileShareBytes(\n client: DocumentToolsClient,\n id: string,\n kind: 'view' | 'original' | 'signed'\n) {\n const result = await client.GET('/v1/file-shares/{share_id}/file', {\n params: { path: { share_id: id }, query: { kind } },\n parseAs: 'blob',\n })\n if (!result.data) throw failure(result.error)\n return result.data\n}\n\n/** Adapt only the guided viewer's presentation data; sharing uses its own authorization endpoints. */\nexport function fileShareSigningRequest(share: FileShare): SignatureRequest {\n return {\n external_id: share.external_id,\n doc_ext_id: share.document_ext_id,\n version: share.version,\n source_sha256: share.source_sha256,\n fields: share.fields,\n message: share.message,\n status:\n share.status === 'signing' ? 'sent' : share.status === 'completed' ? 'completed' : 'voided',\n signers: share.recipients\n .filter((r) => r.permission === 'sign')\n .map((r) => ({\n external_id: r.email,\n email: r.email,\n name: r.email,\n status: r.status === 'signed' ? 'signed' : 'pending',\n progress: r.status === 'signed' ? 'signed' : 'registered',\n fields: share.fields.filter((f) => f.signer === r.email).length,\n })),\n created_at: new Date(0).toISOString(),\n stale: false,\n }\n}\n\nexport async function signFileShare(\n client: DocumentToolsClient,\n domain: string,\n vars: SignRequestVars\n): Promise<SignRequestSignResponse> {\n const path = { share_id: vars.request.external_id }\n const body = { adopted: vars.adopted, fields: vars.fields }\n const prepared = await client.POST('/v1/file-shares/{share_id}/sign/prepare', {\n params: { path },\n body,\n })\n if (!prepared.data) throw failure(prepared.error)\n const { statement, timestamp, source_sha256, intent } = prepared.data\n if (\n source_sha256 !== vars.request.source_sha256 ||\n (await sha256Hex(vars.pdfBlob)) !== source_sha256\n )\n throw new Error('The shared file changed. Ask the sender for a new request.')\n if (intent !== intentText({ name: vars.adopted.name }))\n throw new Error('Signing statement mismatch')\n const identity = await unlockIdentityWithPassword(vars.email, vars.password, domain)\n const result = await client.POST('/v1/file-shares/{share_id}/sign', {\n params: { path },\n body: { ...body, timestamp, signature: signMessage(statement, identity) },\n })\n if (!result.data) throw failure(result.error)\n return {\n request: fileShareSigningRequest(result.data),\n completed: result.data.status === 'completed',\n }\n}\n\nexport function useFileShare(client: DocumentToolsClient, shareId: string, signing: boolean) {\n return useQuery({\n queryKey: arbiQueryKeys.fileShare(shareId),\n queryFn: () => getFileShare(client, shareId),\n refetchInterval: signing ? false : 5000,\n })\n}\n\nexport function useFileSharePdf(client: DocumentToolsClient, shareId: string, share?: FileShare) {\n return useQuery({\n queryKey: arbiQueryKeys.fileSharePdf(shareId, share?.status),\n queryFn: () =>\n fileShareBytes(client, shareId, share?.status === 'completed' ? 'signed' : 'view'),\n enabled: !!share?.can_preview,\n staleTime: Infinity,\n })\n}\n\n/** The shares I created or was invited to (revoked and expired ones are not listed). Listing does\n * not open a share, so it never starts a recipient's access window. Null client: not loaded. */\nexport function useFileShares(client: DocumentToolsClient | null) {\n return useQuery({\n queryKey: arbiQueryKeys.fileShares(),\n queryFn: async () => {\n const result = await client?.GET('/v1/file-shares')\n if (!result?.data) throw new Error('Could not load shared files')\n return result.data\n },\n enabled: !!client,\n })\n}\n\n/** Read the share list again (after a change made to a share: signed, declined, saved, revoked). */\nexport function useRefreshFileShares(): () => Promise<void> {\n const queryClient = useQueryClient()\n return useCallback(\n () => queryClient.invalidateQueries({ queryKey: arbiQueryKeys.fileShares() }),\n [queryClient]\n )\n}\n\n/**\n * Save a completed share's signed PDF as its document's next version, in the share's workspace\n * (its key must be on the session: open that workspace first).\n */\nexport async function publishFileShare(client: DocumentToolsClient, share: FileShare) {\n const result = await client.POST(\n '/v1/document/{document_ext_id}/file-shares/{share_id}/publish',\n { params: { path: { document_ext_id: share.document_ext_id, share_id: share.external_id } } }\n )\n if (!result.data) throw new Error('Could not save the signed version to its workspace')\n return result.data\n}\n"]}
|
|
@@ -8,9 +8,9 @@ var chunkHJDR5HEO_cjs = require('./chunk-HJDR5HEO.cjs');
|
|
|
8
8
|
var chunk5NOZDH3F_cjs = require('./chunk-5NOZDH3F.cjs');
|
|
9
9
|
var chunkS6A6FSG7_cjs = require('./chunk-S6A6FSG7.cjs');
|
|
10
10
|
var React = require('react');
|
|
11
|
-
var reactDom = require('react-dom');
|
|
12
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
13
11
|
var lucideReact = require('lucide-react');
|
|
12
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
13
|
+
var reactDom = require('react-dom');
|
|
14
14
|
var classVarianceAuthority = require('class-variance-authority');
|
|
15
15
|
var HoverCardPrimitive = require('@radix-ui/react-hover-card');
|
|
16
16
|
var SelectPrimitive = require('@radix-ui/react-select');
|
|
@@ -156,6 +156,46 @@ var COLUMN_LABEL_FALLBACKS = {
|
|
|
156
156
|
doc_id: "DocID",
|
|
157
157
|
related: "Related"
|
|
158
158
|
};
|
|
159
|
+
function EntityActionsMenu({
|
|
160
|
+
label,
|
|
161
|
+
href,
|
|
162
|
+
actions = []
|
|
163
|
+
}) {
|
|
164
|
+
const [copyError, setCopyError] = React.useState(false);
|
|
165
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(chunkHJDR5HEO_cjs.DropdownMenu, { onOpenChange: () => setCopyError(false), children: [
|
|
166
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkHJDR5HEO_cjs.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
167
|
+
"button",
|
|
168
|
+
{
|
|
169
|
+
type: "button",
|
|
170
|
+
"aria-label": `Actions for ${label}`,
|
|
171
|
+
className: "relative inline-flex h-5 w-4 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
172
|
+
onClick: (e) => e.stopPropagation(),
|
|
173
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MoreVertical, { className: "h-3.5 w-3.5" })
|
|
174
|
+
}
|
|
175
|
+
) }),
|
|
176
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkHJDR5HEO_cjs.DropdownMenuContent, { align: "end", onClick: (e) => e.stopPropagation(), children: [
|
|
177
|
+
actions.map((action) => /* @__PURE__ */ jsxRuntime.jsxs(chunkHJDR5HEO_cjs.DropdownMenuItem, { disabled: action.disabled, onSelect: action.onSelect, children: [
|
|
178
|
+
action.icon,
|
|
179
|
+
action.label
|
|
180
|
+
] }, action.id)),
|
|
181
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
182
|
+
chunkHJDR5HEO_cjs.DropdownMenuItem,
|
|
183
|
+
{
|
|
184
|
+
onSelect: (event) => {
|
|
185
|
+
event.preventDefault();
|
|
186
|
+
setCopyError(false);
|
|
187
|
+
void Promise.resolve().then(() => navigator.clipboard.writeText(new URL(href, window.location.href).href)).catch(() => setCopyError(true));
|
|
188
|
+
},
|
|
189
|
+
children: [
|
|
190
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { className: "mr-2 h-4 w-4" }),
|
|
191
|
+
"Copy link"
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
),
|
|
195
|
+
copyError && /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", className: "px-2 py-1 text-xs text-destructive", children: "Could not copy link. Please try again." })
|
|
196
|
+
] })
|
|
197
|
+
] });
|
|
198
|
+
}
|
|
159
199
|
var TooltipContext = React__namespace.createContext(null);
|
|
160
200
|
var DEFAULT_DELAY = 300;
|
|
161
201
|
var TooltipConfigContext = React__namespace.createContext({
|
|
@@ -355,6 +395,12 @@ var TooltipContent = React__namespace.forwardRef(
|
|
|
355
395
|
}
|
|
356
396
|
);
|
|
357
397
|
TooltipContent.displayName = "TooltipContent";
|
|
398
|
+
|
|
399
|
+
// src/entities/links.ts
|
|
400
|
+
function useEntityHref(id) {
|
|
401
|
+
const links = chunk5NOZDH3F_cjs.useHostConfigRecord().entities;
|
|
402
|
+
return id ? links?.hrefFor(id) : void 0;
|
|
403
|
+
}
|
|
358
404
|
var PILL_TOUCH_HIT = "pointer-coarse:after:absolute pointer-coarse:after:left-1/2 pointer-coarse:after:top-1/2 pointer-coarse:after:h-11 pointer-coarse:after:w-[max(100%,2.75rem)] pointer-coarse:after:-translate-x-1/2 pointer-coarse:after:-translate-y-1/2 pointer-coarse:after:content-['']";
|
|
359
405
|
var MAIN_AREA_TOUCH_HIT = "relative pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:top-1/2 pointer-coarse:after:h-11 pointer-coarse:after:-translate-y-1/2 pointer-coarse:after:content-['']";
|
|
360
406
|
var EntityPill = React.forwardRef(function EntityPill2({
|
|
@@ -374,11 +420,16 @@ var EntityPill = React.forwardRef(function EntityPill2({
|
|
|
374
420
|
onMoreClick,
|
|
375
421
|
moreContent,
|
|
376
422
|
href,
|
|
423
|
+
copyHref,
|
|
424
|
+
entityId,
|
|
425
|
+
actions,
|
|
377
426
|
disabled = false,
|
|
378
427
|
pressed,
|
|
379
428
|
tooltipContent,
|
|
380
429
|
"data-testid": testId
|
|
381
430
|
}, ref) {
|
|
431
|
+
const hostHref = useEntityHref(entityId);
|
|
432
|
+
const primaryRef = React__namespace.default.useRef(null);
|
|
382
433
|
const shapeClass = shape === "pill" ? "rounded-full" : "rounded-md";
|
|
383
434
|
const sizeClasses2 = size === "md" ? "gap-1.5 px-1.5 py-0.5" : "gap-1 px-1";
|
|
384
435
|
const textSizeClass = size === "md" ? "text-base" : "text-sm";
|
|
@@ -387,13 +438,13 @@ var EntityPill = React.forwardRef(function EntityPill2({
|
|
|
387
438
|
fullWidth ? "flex w-full" : "inline-flex",
|
|
388
439
|
sizeClasses2,
|
|
389
440
|
shapeClass,
|
|
390
|
-
"
|
|
441
|
+
"min-w-0 max-w-full align-middle",
|
|
391
442
|
"transition-colors",
|
|
392
443
|
className
|
|
393
444
|
);
|
|
394
|
-
const interactiveClasses = chunkS6A6FSG7_cjs.cn("relative cursor-pointer
|
|
445
|
+
const interactiveClasses = chunkS6A6FSG7_cjs.cn("relative cursor-pointer", PILL_TOUCH_HIT);
|
|
395
446
|
const disabledClasses = "cursor-default opacity-60";
|
|
396
|
-
const highlightClasses = "
|
|
447
|
+
const highlightClasses = "text-primary font-semibold";
|
|
397
448
|
const mainContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
398
449
|
onIconClick ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
399
450
|
"span",
|
|
@@ -413,7 +464,7 @@ var EntityPill = React.forwardRef(function EntityPill2({
|
|
|
413
464
|
{
|
|
414
465
|
className: chunkS6A6FSG7_cjs.cn(
|
|
415
466
|
textSizeClass,
|
|
416
|
-
"font-medium truncate leading-tight min-w-0",
|
|
467
|
+
"font-medium tracking-[0.01em] truncate leading-tight min-w-0 underline decoration-dotted decoration-current/35 underline-offset-4",
|
|
417
468
|
labelMaxWidth,
|
|
418
469
|
labelClassName
|
|
419
470
|
),
|
|
@@ -434,20 +485,45 @@ var EntityPill = React.forwardRef(function EntityPill2({
|
|
|
434
485
|
),
|
|
435
486
|
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side, className: "p-2", children: tip })
|
|
436
487
|
] });
|
|
437
|
-
const mainAreaClass = chunkS6A6FSG7_cjs.cn("inline-flex items-center gap-1", fullWidth && "
|
|
488
|
+
const mainAreaClass = chunkS6A6FSG7_cjs.cn("inline-flex min-w-0 items-center gap-1", fullWidth && "flex-1");
|
|
438
489
|
const mainAreaTouchClass = chunkS6A6FSG7_cjs.cn(
|
|
439
490
|
mainAreaClass,
|
|
440
491
|
(onClick || href) && !disabled && MAIN_AREA_TOUCH_HIT
|
|
441
492
|
);
|
|
442
|
-
|
|
493
|
+
const entityHref = copyHref ?? href ?? hostHref;
|
|
494
|
+
const defaultMenu = entityHref && !disabled ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
495
|
+
EntityActionsMenu,
|
|
496
|
+
{
|
|
497
|
+
label,
|
|
498
|
+
href: entityHref,
|
|
499
|
+
actions: [
|
|
500
|
+
...onClick || href ? [
|
|
501
|
+
{
|
|
502
|
+
id: "open",
|
|
503
|
+
label: "Open",
|
|
504
|
+
onSelect: () => {
|
|
505
|
+
if (onClick) primaryRef.current?.click();
|
|
506
|
+
else if (href) window.open(href, "_blank", "noopener,noreferrer");
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
] : [],
|
|
510
|
+
...actions ?? []
|
|
511
|
+
]
|
|
512
|
+
}
|
|
513
|
+
) : null;
|
|
514
|
+
const trailing = moreContent ?? (onMoreClick ? null : defaultMenu);
|
|
515
|
+
if (onMoreClick || trailing) {
|
|
443
516
|
let mainArea;
|
|
444
|
-
if (tooltipContent) {
|
|
517
|
+
if (tooltipContent && !href) {
|
|
445
518
|
mainArea = tooltipWrap(
|
|
446
519
|
mainContent,
|
|
447
520
|
tooltipContent,
|
|
448
521
|
"bottom",
|
|
449
522
|
chunkS6A6FSG7_cjs.cn(mainAreaTouchClass, disabled && "opacity-60"),
|
|
450
523
|
{
|
|
524
|
+
ref: (el) => {
|
|
525
|
+
primaryRef.current = el;
|
|
526
|
+
},
|
|
451
527
|
type: "button",
|
|
452
528
|
onClick: href ? onClick : disabled ? void 0 : onClick,
|
|
453
529
|
disabled: disabled || void 0,
|
|
@@ -458,6 +534,9 @@ var EntityPill = React.forwardRef(function EntityPill2({
|
|
|
458
534
|
mainArea = /* @__PURE__ */ jsxRuntime.jsx(
|
|
459
535
|
"a",
|
|
460
536
|
{
|
|
537
|
+
ref: (el) => {
|
|
538
|
+
primaryRef.current = el;
|
|
539
|
+
},
|
|
461
540
|
href,
|
|
462
541
|
target: "_blank",
|
|
463
542
|
rel: "noopener noreferrer",
|
|
@@ -470,26 +549,25 @@ var EntityPill = React.forwardRef(function EntityPill2({
|
|
|
470
549
|
mainArea = /* @__PURE__ */ jsxRuntime.jsx(
|
|
471
550
|
"button",
|
|
472
551
|
{
|
|
552
|
+
ref: (el) => {
|
|
553
|
+
primaryRef.current = el;
|
|
554
|
+
},
|
|
473
555
|
type: "button",
|
|
474
556
|
onClick: disabled ? void 0 : onClick,
|
|
475
557
|
disabled,
|
|
476
558
|
"aria-pressed": pressed,
|
|
477
|
-
className: chunkS6A6FSG7_cjs.cn(
|
|
478
|
-
"inline-flex items-center gap-1",
|
|
479
|
-
MAIN_AREA_TOUCH_HIT,
|
|
480
|
-
disabled && "opacity-60"
|
|
481
|
-
),
|
|
559
|
+
className: chunkS6A6FSG7_cjs.cn(mainAreaClass, MAIN_AREA_TOUCH_HIT, disabled && "opacity-60"),
|
|
482
560
|
children: mainContent
|
|
483
561
|
}
|
|
484
562
|
);
|
|
485
563
|
} else {
|
|
486
564
|
mainArea = /* @__PURE__ */ jsxRuntime.jsx("span", { className: mainAreaTouchClass, children: mainContent });
|
|
487
565
|
}
|
|
488
|
-
const moreArea =
|
|
566
|
+
const moreArea = trailing ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-shrink-0 leading-none opacity-0 transition-opacity group-hover/pill:opacity-100 group-focus-within/pill:opacity-100 has-[[data-state=open]]:opacity-100 pointer-coarse:opacity-100", children: trailing }) : tooltipWrap(
|
|
489
567
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.MoreVertical, { className: "w-3.5 h-3.5" }),
|
|
490
568
|
"Click for more",
|
|
491
569
|
"bottom",
|
|
492
|
-
"flex-shrink-0 leading-none text-muted-foreground hover:text-foreground",
|
|
570
|
+
"flex-shrink-0 leading-none text-muted-foreground hover:text-foreground opacity-0 group-hover/pill:opacity-100 group-focus-within/pill:opacity-100 pointer-coarse:opacity-100",
|
|
493
571
|
{
|
|
494
572
|
type: "button",
|
|
495
573
|
onClick: (e) => {
|
|
@@ -504,7 +582,7 @@ var EntityPill = React.forwardRef(function EntityPill2({
|
|
|
504
582
|
ref,
|
|
505
583
|
className: chunkS6A6FSG7_cjs.cn(
|
|
506
584
|
baseClasses,
|
|
507
|
-
(onClick || href) && !disabled && "cursor-pointer
|
|
585
|
+
(onClick || href) && !disabled && "cursor-pointer",
|
|
508
586
|
highlight && highlightClasses
|
|
509
587
|
),
|
|
510
588
|
style,
|
|
@@ -1295,9 +1373,11 @@ function getDocumentTitle(document2, defaultValue = "") {
|
|
|
1295
1373
|
if (!document2) return defaultValue;
|
|
1296
1374
|
return document2.doc_metadata?.title || document2.file_name || defaultValue;
|
|
1297
1375
|
}
|
|
1298
|
-
var IMAGE_FILE_TYPES = /* @__PURE__ */ new Set(["png", "jpg", "jpeg", "gif", "bmp", "tiff", "webp"]);
|
|
1376
|
+
var IMAGE_FILE_TYPES = /* @__PURE__ */ new Set(["png", "jpg", "jpeg", "gif", "bmp", "tif", "tiff", "webp"]);
|
|
1299
1377
|
function isImageDocument(document2) {
|
|
1300
|
-
|
|
1378
|
+
const fileType = document2?.file_type?.toLowerCase().split(";")[0].trim();
|
|
1379
|
+
const extension = document2?.file_name?.split(".").pop()?.toLowerCase();
|
|
1380
|
+
return !!(fileType && (fileType.startsWith("image/") || IMAGE_FILE_TYPES.has(fileType)) || extension && IMAGE_FILE_TYPES.has(extension));
|
|
1301
1381
|
}
|
|
1302
1382
|
var MAX_LABEL_CHARS = 30;
|
|
1303
1383
|
function clampLabel(text) {
|
|
@@ -1348,6 +1428,7 @@ function DocumentEntity({
|
|
|
1348
1428
|
iconBadge,
|
|
1349
1429
|
status,
|
|
1350
1430
|
actions,
|
|
1431
|
+
copyHref,
|
|
1351
1432
|
tooltipContent,
|
|
1352
1433
|
className,
|
|
1353
1434
|
fullWidth,
|
|
@@ -1360,7 +1441,7 @@ function DocumentEntity({
|
|
|
1360
1441
|
const eyeSizeClass = size === "md" ? "h-4 w-4" : "h-3.5 w-3.5";
|
|
1361
1442
|
const baseIcon = icon ?? getDocIcon(doc.file_name, iconSize, doc.folder);
|
|
1362
1443
|
const displayIcon = viewing || iconBadge ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "relative inline-flex flex-shrink-0 items-center justify-center", children: [
|
|
1363
|
-
viewing ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { className: chunkS6A6FSG7_cjs.cn("text-primary
|
|
1444
|
+
viewing ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { className: chunkS6A6FSG7_cjs.cn("text-primary", eyeSizeClass) }) : baseIcon,
|
|
1364
1445
|
iconBadge
|
|
1365
1446
|
] }) : baseIcon;
|
|
1366
1447
|
const defaultTooltip = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 text-xs max-w-[440px]", children: [
|
|
@@ -1383,6 +1464,7 @@ function DocumentEntity({
|
|
|
1383
1464
|
EntityPill,
|
|
1384
1465
|
{
|
|
1385
1466
|
icon: displayIcon,
|
|
1467
|
+
entityId: onClick ? doc.external_id : void 0,
|
|
1386
1468
|
size,
|
|
1387
1469
|
label: fullWidth || noClamp ? title : clampLabel(title),
|
|
1388
1470
|
labelMaxWidth: labelMaxWidth ?? "max-w-[140px]",
|
|
@@ -1392,6 +1474,7 @@ function DocumentEntity({
|
|
|
1392
1474
|
onClick,
|
|
1393
1475
|
onIconClick,
|
|
1394
1476
|
moreContent: actions,
|
|
1477
|
+
copyHref,
|
|
1395
1478
|
className,
|
|
1396
1479
|
highlight: viewing,
|
|
1397
1480
|
"data-testid": testId,
|
|
@@ -1560,6 +1643,7 @@ function TagEntity({
|
|
|
1560
1643
|
{
|
|
1561
1644
|
icon: iconElement,
|
|
1562
1645
|
label: tag.name,
|
|
1646
|
+
entityId: !onCheckedChange && onClick ? tag.external_id : void 0,
|
|
1563
1647
|
size: pillSize,
|
|
1564
1648
|
shape: "pill",
|
|
1565
1649
|
style: { borderColor: tagColor },
|
|
@@ -2800,6 +2884,8 @@ function resolveVariant(relation, paid, hasCollaborators) {
|
|
|
2800
2884
|
}
|
|
2801
2885
|
function ProjectEntity({
|
|
2802
2886
|
name,
|
|
2887
|
+
copyHref,
|
|
2888
|
+
projectId,
|
|
2803
2889
|
label,
|
|
2804
2890
|
icon,
|
|
2805
2891
|
subscription = "none",
|
|
@@ -2819,6 +2905,8 @@ function ProjectEntity({
|
|
|
2819
2905
|
{
|
|
2820
2906
|
icon: iconNode,
|
|
2821
2907
|
label: label ?? name,
|
|
2908
|
+
copyHref,
|
|
2909
|
+
entityId: projectId,
|
|
2822
2910
|
shape: "rounded",
|
|
2823
2911
|
className: chunkS6A6FSG7_cjs.cn(pill, className),
|
|
2824
2912
|
onClick,
|
|
@@ -2935,8 +3023,11 @@ var UserEntity = React.memo(function UserEntity2({
|
|
|
2935
3023
|
displayStatus,
|
|
2936
3024
|
onClick,
|
|
2937
3025
|
tooltipContent,
|
|
2938
|
-
empty = false
|
|
3026
|
+
empty = false,
|
|
3027
|
+
copyHref,
|
|
3028
|
+
entityId
|
|
2939
3029
|
}) {
|
|
3030
|
+
const entityHref = useEntityHref(entityId);
|
|
2940
3031
|
if (empty) {
|
|
2941
3032
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2942
3033
|
chunkEEIYXVM4_cjs.Avatar,
|
|
@@ -3022,16 +3113,33 @@ var UserEntity = React.memo(function UserEntity2({
|
|
|
3022
3113
|
] })
|
|
3023
3114
|
);
|
|
3024
3115
|
const resolvedTooltip = showTooltip ? tooltipContent : void 0;
|
|
3116
|
+
if (variant === "pill" && (copyHref || entityHref))
|
|
3117
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { "data-variant": "pill", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3118
|
+
EntityPill,
|
|
3119
|
+
{
|
|
3120
|
+
icon: pillAvatar,
|
|
3121
|
+
label: displayName || "Person",
|
|
3122
|
+
secondaryText: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3123
|
+
isVerified && !isAgent2 && /* @__PURE__ */ jsxRuntime.jsx(VerifiedBadge, {}),
|
|
3124
|
+
agentBadge
|
|
3125
|
+
] }),
|
|
3126
|
+
copyHref: copyHref || entityHref,
|
|
3127
|
+
onClick: interactive ? onClick : void 0,
|
|
3128
|
+
tooltipContent: resolvedTooltip,
|
|
3129
|
+
className,
|
|
3130
|
+
"data-testid": "user-entity-pill"
|
|
3131
|
+
}
|
|
3132
|
+
) });
|
|
3025
3133
|
if (variant === "pill") {
|
|
3026
3134
|
const row = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3027
3135
|
pillAvatar,
|
|
3028
|
-
displayName && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 max-w-[320px] truncate text-sm leading-tight", children: displayName }),
|
|
3136
|
+
displayName && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 max-w-[320px] truncate text-sm font-medium tracking-[0.01em] underline decoration-dotted decoration-current/35 underline-offset-4 leading-tight", children: displayName }),
|
|
3029
3137
|
isVerified && !isAgent2 && /* @__PURE__ */ jsxRuntime.jsx(VerifiedBadge, {}),
|
|
3030
3138
|
agentBadge
|
|
3031
3139
|
] });
|
|
3032
3140
|
const rowClass = "group/pill inline-flex min-w-0 items-center gap-2";
|
|
3033
3141
|
const clickable = interactive && !!onClick;
|
|
3034
|
-
const clickableClass = "relative cursor-pointer rounded-md px-1 py-0.5 -mx-1 transition-colors
|
|
3142
|
+
const clickableClass = "relative cursor-pointer rounded-md px-1 py-0.5 -mx-1 transition-colors pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:-inset-y-3 pointer-coarse:after:content-['']";
|
|
3035
3143
|
if (resolvedTooltip) {
|
|
3036
3144
|
return /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
|
|
3037
3145
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -5192,6 +5300,7 @@ exports.DocIcon = DocIcon;
|
|
|
5192
5300
|
exports.DocumentEntity = DocumentEntity;
|
|
5193
5301
|
exports.ENTITY_MAPPINGS = ENTITY_MAPPINGS;
|
|
5194
5302
|
exports.EmlIcon = EmlIcon;
|
|
5303
|
+
exports.EntityActionsMenu = EntityActionsMenu;
|
|
5195
5304
|
exports.EntityIcon = EntityIcon;
|
|
5196
5305
|
exports.EntityPill = EntityPill;
|
|
5197
5306
|
exports.FILE_TYPE_COLORS = FILE_TYPE_COLORS;
|
|
@@ -5334,5 +5443,5 @@ exports.toggleVariants = toggleVariants;
|
|
|
5334
5443
|
exports.useAudioRecorder = useAudioRecorder;
|
|
5335
5444
|
exports.useDictateContext = useDictateContext;
|
|
5336
5445
|
exports.usesOriginalBytesForViewer = usesOriginalBytesForViewer;
|
|
5337
|
-
//# sourceMappingURL=chunk-
|
|
5338
|
-
//# sourceMappingURL=chunk-
|
|
5446
|
+
//# sourceMappingURL=chunk-W4W75MSO.cjs.map
|
|
5447
|
+
//# sourceMappingURL=chunk-W4W75MSO.cjs.map
|