@arbidocs/react 0.4.167 → 0.4.169
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/artifacts/index.cjs +15 -12
- package/dist/artifacts/index.cjs.map +1 -1
- package/dist/artifacts/index.js +6 -3
- package/dist/artifacts/index.js.map +1 -1
- package/dist/calls/livekit/index.cjs +977 -0
- package/dist/calls/livekit/index.cjs.map +1 -0
- package/dist/calls/livekit/index.d.cts +280 -0
- package/dist/calls/livekit/index.d.ts +280 -0
- package/dist/calls/livekit/index.js +961 -0
- package/dist/calls/livekit/index.js.map +1 -0
- package/dist/{chunk-ON4PL6DQ.cjs → chunk-2M4B4FFA.cjs} +48 -4
- package/dist/chunk-2M4B4FFA.cjs.map +1 -0
- package/dist/chunk-3NVSUYUV.js +528 -0
- package/dist/chunk-3NVSUYUV.js.map +1 -0
- package/dist/{chunk-QJHCVQ6C.js → chunk-3WIBD44F.js} +4734 -4673
- package/dist/chunk-3WIBD44F.js.map +1 -0
- package/dist/chunk-5HDC43MF.js +145 -0
- package/dist/chunk-5HDC43MF.js.map +1 -0
- package/dist/{chunk-D66JCVBB.cjs → chunk-7NHOKV7N.cjs} +4093 -4040
- package/dist/chunk-7NHOKV7N.cjs.map +1 -0
- package/dist/chunk-7NY2J3TR.js +986 -0
- package/dist/chunk-7NY2J3TR.js.map +1 -0
- package/dist/chunk-APZZQZ6P.js +147 -0
- package/dist/chunk-APZZQZ6P.js.map +1 -0
- package/dist/{chunk-I5ZBQ63Y.js → chunk-DGMK3EUN.js} +188 -181
- package/dist/chunk-DGMK3EUN.js.map +1 -0
- package/dist/chunk-DPYBZDJB.js +18 -0
- package/dist/chunk-DPYBZDJB.js.map +1 -0
- package/dist/chunk-EEIYXVM4.cjs +181 -0
- package/dist/chunk-EEIYXVM4.cjs.map +1 -0
- package/dist/chunk-GGYCK5A6.cjs +1035 -0
- package/dist/chunk-GGYCK5A6.cjs.map +1 -0
- package/dist/{chunk-JSSKEXRR.js → chunk-KGCGA452.js} +2 -2
- package/dist/chunk-KGCGA452.js.map +1 -0
- package/dist/chunk-N73IMVFF.cjs +21 -0
- package/dist/chunk-N73IMVFF.cjs.map +1 -0
- package/dist/chunk-NVAIVJID.js +298 -0
- package/dist/chunk-NVAIVJID.js.map +1 -0
- package/dist/{chunk-GTJ667CP.cjs → chunk-QQ7SCJRY.cjs} +2 -2
- package/dist/chunk-QQ7SCJRY.cjs.map +1 -0
- package/dist/chunk-S4PCA3ES.cjs +572 -0
- package/dist/chunk-S4PCA3ES.cjs.map +1 -0
- package/dist/chunk-VAMPYLQ4.cjs +157 -0
- package/dist/chunk-VAMPYLQ4.cjs.map +1 -0
- package/dist/chunk-VLK52VXC.cjs +307 -0
- package/dist/chunk-VLK52VXC.cjs.map +1 -0
- package/dist/chunk-VPKFUYGW.cjs +2551 -0
- package/dist/chunk-VPKFUYGW.cjs.map +1 -0
- package/dist/chunk-W6DYNLA2.js +2362 -0
- package/dist/chunk-W6DYNLA2.js.map +1 -0
- package/dist/{chunk-SVHGCX25.js → chunk-YWYCEEBF.js} +43 -4
- package/dist/chunk-YWYCEEBF.js.map +1 -0
- package/dist/{chunk-EUC2BTNS.cjs → chunk-ZI2VJOID.cjs} +206 -199
- package/dist/chunk-ZI2VJOID.cjs.map +1 -0
- package/dist/document-tools/index.cjs +79 -107
- package/dist/document-tools/index.cjs.map +1 -1
- package/dist/document-tools/index.d.cts +4 -5
- package/dist/document-tools/index.d.ts +4 -5
- package/dist/document-tools/index.js +23 -68
- package/dist/document-tools/index.js.map +1 -1
- package/dist/index.cjs +12650 -9452
- package/dist/index.cjs.map +1 -1
- package/dist/{index.d-DfCFKora.d.cts → index.d-Bvp6rKNo.d.cts} +139 -1
- package/dist/{index.d-DfCFKora.d.ts → index.d-Bvp6rKNo.d.ts} +139 -1
- package/dist/{index.d-DCjYj7YK.d.ts → index.d-Dx9sGkW2.d.cts} +20 -8
- package/dist/{index.d-DCjYj7YK.d.cts → index.d-Dx9sGkW2.d.ts} +20 -8
- package/dist/index.d.cts +5465 -2291
- package/dist/index.d.ts +5465 -2291
- package/dist/index.js +11047 -8858
- package/dist/index.js.map +1 -1
- package/dist/query-keys.d-Kw0JMoff.d.cts +308 -0
- package/dist/query-keys.d-Kw0JMoff.d.ts +308 -0
- package/dist/shell/index.cjs +78 -21
- package/dist/shell/index.d.cts +1 -1
- package/dist/shell/index.d.ts +1 -1
- package/dist/shell/index.js +6 -1
- package/dist/ui/index.cjs +191 -186
- package/dist/ui/index.d.cts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +3 -2
- package/dist/useAudioRecorder.d-CWFDsb_S.d.cts +778 -0
- package/dist/useAudioRecorder.d-CWFDsb_S.d.ts +778 -0
- package/dist/viewers/index.cjs +22 -13
- package/dist/viewers/index.cjs.map +1 -1
- package/dist/viewers/index.js +21 -12
- package/dist/viewers/index.js.map +1 -1
- package/package.json +13 -3
- package/dist/chunk-6MTKKT2O.cjs +0 -999
- package/dist/chunk-6MTKKT2O.cjs.map +0 -1
- package/dist/chunk-CEZCFQ47.js +0 -932
- package/dist/chunk-CEZCFQ47.js.map +0 -1
- package/dist/chunk-D66JCVBB.cjs.map +0 -1
- package/dist/chunk-EUC2BTNS.cjs.map +0 -1
- package/dist/chunk-GTJ667CP.cjs.map +0 -1
- package/dist/chunk-I5ZBQ63Y.js.map +0 -1
- package/dist/chunk-JSSKEXRR.js.map +0 -1
- package/dist/chunk-ON4PL6DQ.cjs.map +0 -1
- package/dist/chunk-QJHCVQ6C.js.map +0 -1
- package/dist/chunk-SVHGCX25.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseVersionRef } from './chunk-NNWMHMEC.js';
|
|
2
|
-
import { useDeploymentDomain } from './chunk-
|
|
2
|
+
import { useDeploymentDomain } from './chunk-KGCGA452.js';
|
|
3
3
|
import { createContext, useMemo, useContext } from 'react';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
5
|
|
|
@@ -161,6 +161,45 @@ async function fetchDocumentFile(client, documentRef, options = {}) {
|
|
|
161
161
|
return name ? new File([blob], name, { type: blob.type }) : blob;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
// src/document-tools/markup-download.ts
|
|
165
|
+
var SIGNED_LOCKED_REASON = "Signed documents can't be changed \u2014 download the signed file instead";
|
|
166
|
+
function isSignedVersion(doc, version) {
|
|
167
|
+
const n = version ?? doc.current_version ?? 1;
|
|
168
|
+
return (doc.versions ?? []).some((v) => v.n === n && v.reason === "signed");
|
|
169
|
+
}
|
|
170
|
+
var MarkupDownloadError = class extends Error {
|
|
171
|
+
constructor(message, status) {
|
|
172
|
+
super(message);
|
|
173
|
+
this.status = status;
|
|
174
|
+
this.name = "MarkupDownloadError";
|
|
175
|
+
}
|
|
176
|
+
status;
|
|
177
|
+
};
|
|
178
|
+
function currentHasMarkup(doc) {
|
|
179
|
+
const n = doc.current_version ?? 1;
|
|
180
|
+
return (doc.versions ?? []).some((v) => v.n === n && (v.markup_count ?? 0) > 0);
|
|
181
|
+
}
|
|
182
|
+
async function fetchMarkupPdf(client, documentId, version) {
|
|
183
|
+
const { data, response } = await client.GET("/v1/document/{document_ext_id}/markup/pdf", {
|
|
184
|
+
params: { path: { document_ext_id: documentId }, query: version ? { version } : {} },
|
|
185
|
+
parseAs: "blob"
|
|
186
|
+
});
|
|
187
|
+
if (!response.ok || !data) {
|
|
188
|
+
throw new MarkupDownloadError(
|
|
189
|
+
response.status === 404 ? "This document has no markup yet" : (
|
|
190
|
+
// The server refuses a signed version: its PDF takes no more changes.
|
|
191
|
+
response.status === 409 ? SIGNED_LOCKED_REASON : "The markup could not be downloaded"
|
|
192
|
+
),
|
|
193
|
+
response.status
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
const disposition = response.headers.get("content-disposition") ?? "";
|
|
197
|
+
const utf8 = /filename\*=UTF-8''([^;]+)/i.exec(disposition)?.[1];
|
|
198
|
+
const plain = /filename="([^"]+)"/i.exec(disposition)?.[1];
|
|
199
|
+
const fileName = utf8 ? decodeURIComponent(utf8) : plain ?? "markup.pdf";
|
|
200
|
+
return { blob: data, fileName };
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export { DocumentFetchError, DocumentToolsProvider, MarkupDownloadError, SIGNED_LOCKED_REASON, certificateLink, clientUpload, contentDispositionFileName, currentHasMarkup, defaultCertificateUrl, downloadBlob, fetchDocumentFile, fetchDocumentPdf, fetchMarkupPdf, isSignedVersion, uploadQueryString, useDocumentTools, useOptionalDocumentTools };
|
|
204
|
+
//# sourceMappingURL=chunk-YWYCEEBF.js.map
|
|
205
|
+
//# sourceMappingURL=chunk-YWYCEEBF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/document-tools/environment.tsx","../src/document-tools/document-pdf.ts","../src/document-tools/markup-download.ts"],"names":[],"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;AAmDO,SAAS,YAAA,CAAa,MAAY,QAAA,EAAwB;AAC/D,EAAA,MAAM,GAAA,GAAM,GAAA,CAAI,eAAA,CAAgB,IAAI,CAAA;AACpC,EAAA,MAAM,CAAA,GAAI,QAAA,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6C;AAAA,IACvF,MAAA,EAAQ,EAAE,IAAA,EAAM,EAAE,eAAA,EAAiB,UAAA,EAAW,EAAG,KAAA,EAAO,OAAA,GAAU,EAAE,OAAA,EAAQ,GAAI,EAAC,EAAE;AAAA,IACnF,OAAA,EAAS;AAAA,GACV,CAAA;AACD,EAAA,IAAI,CAAC,QAAA,CAAS,EAAA,IAAM,CAAC,IAAA,EAAM;AACzB,IAAA,MAAM,IAAI,mBAAA;AAAA,MACR,QAAA,CAAS,WAAW,GAAA,GAChB,iCAAA;AAAA;AAAA,QAEA,QAAA,CAAS,MAAA,KAAW,GAAA,GAClB,oBAAA,GACA;AAAA,OAAA;AAAA,MACN,QAAA,CAAS;AAAA,KACX;AAAA,EACF;AACA,EAAA,MAAM,WAAA,GAAc,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,qBAAqB,CAAA,IAAK,EAAA;AACnE,EAAA,MAAM,IAAA,GAAO,4BAAA,CAA6B,IAAA,CAAK,WAAW,IAAI,CAAC,CAAA;AAC/D,EAAA,MAAM,KAAA,GAAQ,qBAAA,CAAsB,IAAA,CAAK,WAAW,IAAI,CAAC,CAAA;AACzD,EAAA,MAAM,QAAA,GAAW,IAAA,GAAO,kBAAA,CAAmB,IAAI,IAAK,KAAA,IAAS,YAAA;AAC7D,EAAA,OAAO,EAAE,IAAA,EAAM,IAAA,EAAc,QAAA,EAAS;AACxC","file":"chunk-YWYCEEBF.js","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, useContext, useMemo, 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 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 {\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 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 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 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: { path: { document_ext_id: ref.docId }, query: version ? { version } : {} },\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): Promise<{ blob: Blob; fileName: string }> {\n const { data, response } = await client.GET('/v1/document/{document_ext_id}/markup/pdf', {\n params: { path: { document_ext_id: documentId }, query: version ? { version } : {} },\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"]}
|
|
@@ -1,44 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkVAMPYLQ4_cjs = require('./chunk-VAMPYLQ4.cjs');
|
|
4
|
+
var chunkN73IMVFF_cjs = require('./chunk-N73IMVFF.cjs');
|
|
5
|
+
var chunkZWFMFOGP_cjs = require('./chunk-ZWFMFOGP.cjs');
|
|
3
6
|
var chunkHUZB36QU_cjs = require('./chunk-HUZB36QU.cjs');
|
|
4
7
|
var chunkHJDR5HEO_cjs = require('./chunk-HJDR5HEO.cjs');
|
|
5
8
|
var chunkS6A6FSG7_cjs = require('./chunk-S6A6FSG7.cjs');
|
|
6
9
|
var chunkRCKA7BEF_cjs = require('./chunk-RCKA7BEF.cjs');
|
|
7
|
-
var react = require('react');
|
|
8
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
9
10
|
var vanilla = require('zustand/vanilla');
|
|
10
|
-
var server = require('react-dom/server');
|
|
11
11
|
var sonner = require('sonner');
|
|
12
|
-
var
|
|
12
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
13
|
+
var react = require('react');
|
|
13
14
|
var lucideReact = require('lucide-react');
|
|
14
15
|
|
|
15
|
-
// src/host/merge.ts
|
|
16
|
-
var MERGED = /* @__PURE__ */ new Set(["environment"]);
|
|
17
|
-
var OWN_SESSION_SLOT = "__ownSession";
|
|
18
|
-
function defined(record) {
|
|
19
|
-
return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== void 0));
|
|
20
|
-
}
|
|
21
|
-
function mergeHostConfig(parent, config2) {
|
|
22
|
-
const next = { ...parent };
|
|
23
|
-
for (const [key, value] of Object.entries(defined(config2))) {
|
|
24
|
-
if (key === "connection") continue;
|
|
25
|
-
next[key] = MERGED.has(key) && value && typeof value === "object" ? { ...parent[key], ...defined(value) } : value;
|
|
26
|
-
}
|
|
27
|
-
return next;
|
|
28
|
-
}
|
|
29
|
-
function ArbiHost({
|
|
30
|
-
config: config2,
|
|
31
|
-
children
|
|
32
|
-
}) {
|
|
33
|
-
const parent = react.useContext(chunkRCKA7BEF_cjs.ArbiHostContext);
|
|
34
|
-
const [ownSession] = react.useState(() => ({ current: null }));
|
|
35
|
-
const value = react.useMemo(() => {
|
|
36
|
-
const merged = mergeHostConfig(parent, config2);
|
|
37
|
-
return merged[OWN_SESSION_SLOT] ? merged : { ...merged, [OWN_SESSION_SLOT]: ownSession };
|
|
38
|
-
}, [parent, config2, ownSession]);
|
|
39
|
-
const Connection = config2.connection?.Provider;
|
|
40
|
-
return /* @__PURE__ */ jsxRuntime.jsx(chunkRCKA7BEF_cjs.ArbiHostContext.Provider, { value, children: Connection ? /* @__PURE__ */ jsxRuntime.jsx(Connection, { children }) : children });
|
|
41
|
-
}
|
|
42
16
|
var EMPTY = {
|
|
43
17
|
query: "",
|
|
44
18
|
results: [],
|
|
@@ -87,141 +61,24 @@ function persistSearchSession(key, storage = globalThis.localStorage, session =
|
|
|
87
61
|
}
|
|
88
62
|
});
|
|
89
63
|
}
|
|
90
|
-
var
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
var useNotify = zustand.create((set) => ({
|
|
98
|
-
notifications: [],
|
|
99
|
-
muted: false,
|
|
100
|
-
setMuted: (muted) => set({ muted }),
|
|
101
|
-
markRead: (id) => set((s) => ({
|
|
102
|
-
notifications: s.notifications.map((n) => n.id === id ? { ...n, read: true } : n)
|
|
103
|
-
})),
|
|
104
|
-
markAllRead: () => set((s) => ({ notifications: s.notifications.map((n) => ({ ...n, read: true })) })),
|
|
105
|
-
removeNotification: (id) => set((s) => ({ notifications: s.notifications.filter((n) => n.id !== id) })),
|
|
106
|
-
removeNotifications: (ids) => {
|
|
107
|
-
const drop = new Set(ids);
|
|
108
|
-
set((s) => ({ notifications: s.notifications.filter((n) => !drop.has(n.id)) }));
|
|
109
|
-
},
|
|
110
|
-
clearNotifications: () => set({ notifications: [] }),
|
|
111
|
-
seed: (items) => set({ notifications: items }),
|
|
112
|
-
record: (note) => set((s) => ({ notifications: capSession([note, ...s.notifications]) })),
|
|
113
|
-
syncSource: (source, items) => set((s) => ({
|
|
114
|
-
notifications: [
|
|
115
|
-
...items.map((n) => ({ ...n, source })),
|
|
116
|
-
...s.notifications.filter((n) => n.source !== source)
|
|
117
|
-
].sort((a, b) => b.ts - a.ts)
|
|
118
|
-
}))
|
|
119
|
-
}));
|
|
120
|
-
var config = {};
|
|
121
|
-
function configureNotify(next) {
|
|
122
|
-
config = { ...config, ...next };
|
|
123
|
-
}
|
|
124
|
-
function richMarkup(title) {
|
|
125
|
-
try {
|
|
126
|
-
return server.renderToStaticMarkup(title);
|
|
127
|
-
} catch {
|
|
128
|
-
return void 0;
|
|
64
|
+
var DEFAULT_TOAST_OPTIONS = {
|
|
65
|
+
classNames: {
|
|
66
|
+
toast: "group toast group-[.toaster]:bg-card group-[.toaster]:text-foreground group-[.toaster]:border group-[.toaster]:border-border group-[.toaster]:shadow-lg group-[.toaster]:rounded-lg",
|
|
67
|
+
description: "group-[.toast]:text-muted-foreground",
|
|
68
|
+
actionButton: "group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",
|
|
69
|
+
cancelButton: "group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"
|
|
129
70
|
}
|
|
130
|
-
}
|
|
131
|
-
var textOf = (html) => (html ?? "").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
|
|
132
|
-
function make(variant) {
|
|
133
|
-
return (title, opts = {}) => {
|
|
134
|
-
const { workspaceId } = opts;
|
|
135
|
-
const ambient = opts.ambient ?? config.ambient ?? false;
|
|
136
|
-
if (opts.toast !== false && !useNotify.getState().muted) {
|
|
137
|
-
sonner.toast[variant](title, {
|
|
138
|
-
description: opts.description,
|
|
139
|
-
duration: opts.duration,
|
|
140
|
-
action: opts.action,
|
|
141
|
-
icon: opts.icon ?? (workspaceId ? config.workspaceIcon?.(workspaceId) : void 0),
|
|
142
|
-
className: opts.className
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
const id = uid();
|
|
146
|
-
if (opts.record !== false) {
|
|
147
|
-
const html = opts.html ?? (typeof title === "string" || title == null ? void 0 : richMarkup(title));
|
|
148
|
-
useNotify.getState().record({
|
|
149
|
-
id,
|
|
150
|
-
// A rich toast still needs a READABLE title — "Passage copied: gamma-services p.1",
|
|
151
|
-
// not "Notification" — so it comes from the rendered markup, tags stripped.
|
|
152
|
-
title: opts.recordTitle ?? (typeof title === "string" ? title : textOf(html) || "Notification"),
|
|
153
|
-
description: typeof opts.description === "string" ? opts.description : void 0,
|
|
154
|
-
variant,
|
|
155
|
-
ts: Date.now(),
|
|
156
|
-
// Ambient activity is a log line, not a claim on attention: it never wears an unread dot.
|
|
157
|
-
read: ambient,
|
|
158
|
-
// Clicking the entry goes where the notification points: its action (when it has one),
|
|
159
|
-
// an explicit link, or the workspace it happened in.
|
|
160
|
-
href: opts.href ?? (workspaceId ? config.workspaceHref?.(workspaceId) : void 0),
|
|
161
|
-
onSelect: opts.action?.onClick,
|
|
162
|
-
actionLabel: opts.action ? String(opts.action.label) : void 0,
|
|
163
|
-
workspaceId,
|
|
164
|
-
html,
|
|
165
|
-
ambient
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
return id;
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
var notify = {
|
|
172
|
-
success: make("success"),
|
|
173
|
-
error: make("error"),
|
|
174
|
-
info: make("info"),
|
|
175
|
-
warning: make("warning")
|
|
176
71
|
};
|
|
177
|
-
function
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const saved2 = JSON.parse(storage.getItem(key) ?? "null");
|
|
185
|
-
if (saved2) {
|
|
186
|
-
const known = new Set(useNotify.getState().notifications.map((n) => n.id));
|
|
187
|
-
useNotify.setState((s) => ({
|
|
188
|
-
muted: saved2.muted ?? s.muted,
|
|
189
|
-
notifications: capSession(
|
|
190
|
-
[
|
|
191
|
-
...s.notifications,
|
|
192
|
-
...(saved2.notifications ?? []).filter((n) => !n.source && !known.has(n.id))
|
|
193
|
-
].sort((a, b) => b.ts - a.ts)
|
|
194
|
-
)
|
|
195
|
-
}));
|
|
196
|
-
}
|
|
197
|
-
} catch {
|
|
198
|
-
}
|
|
199
|
-
let saved = [];
|
|
200
|
-
let savedMuted;
|
|
201
|
-
return useNotify.subscribe((s) => {
|
|
202
|
-
const session = s.notifications.filter((n) => !n.source);
|
|
203
|
-
if (s.muted === savedMuted && session.length === saved.length && session.every((n, i) => n === saved[i]))
|
|
204
|
-
return;
|
|
205
|
-
saved = session;
|
|
206
|
-
savedMuted = s.muted;
|
|
207
|
-
const notifications = session.map((n) => ({
|
|
208
|
-
...n,
|
|
209
|
-
onSelect: void 0,
|
|
210
|
-
actionLabel: void 0
|
|
211
|
-
}));
|
|
212
|
-
try {
|
|
213
|
-
storage.setItem(key, JSON.stringify({ muted: s.muted, notifications }));
|
|
214
|
-
} catch {
|
|
72
|
+
function Toaster({ toastOptions, ...props }) {
|
|
73
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
74
|
+
sonner.Toaster,
|
|
75
|
+
{
|
|
76
|
+
className: "toaster group",
|
|
77
|
+
toastOptions: toastOptions ?? DEFAULT_TOAST_OPTIONS,
|
|
78
|
+
...props
|
|
215
79
|
}
|
|
216
|
-
|
|
80
|
+
);
|
|
217
81
|
}
|
|
218
|
-
var selectUnread = (s) => s.notifications.filter((n) => !n.read && !n.ambient).length;
|
|
219
|
-
var DEFAULT_NOTIFY_TONE = {
|
|
220
|
-
success: "text-green-600",
|
|
221
|
-
error: "text-destructive",
|
|
222
|
-
warning: "text-amber-500",
|
|
223
|
-
info: "text-blue-500"
|
|
224
|
-
};
|
|
225
82
|
|
|
226
83
|
// src/lib/format-relative-time.ts
|
|
227
84
|
var FORMATTERS = /* @__PURE__ */ new Map();
|
|
@@ -278,13 +135,13 @@ function NotificationBell({
|
|
|
278
135
|
align = "end"
|
|
279
136
|
}) {
|
|
280
137
|
const [open, setOpen] = react.useState(false);
|
|
281
|
-
const notifications = useNotify((s) => s.notifications);
|
|
282
|
-
const unread = useNotify(selectUnread);
|
|
283
|
-
const markAllRead = useNotify((s) => s.markAllRead);
|
|
284
|
-
const markRead = useNotify((s) => s.markRead);
|
|
285
|
-
const muted = useNotify((s) => s.muted);
|
|
286
|
-
const setMuted = useNotify((s) => s.setMuted);
|
|
287
|
-
const tone = (v) => toneClassNames?.[v] ?? DEFAULT_NOTIFY_TONE[v];
|
|
138
|
+
const notifications = chunkVAMPYLQ4_cjs.useNotify((s) => s.notifications);
|
|
139
|
+
const unread = chunkVAMPYLQ4_cjs.useNotify(chunkVAMPYLQ4_cjs.selectUnread);
|
|
140
|
+
const markAllRead = chunkVAMPYLQ4_cjs.useNotify((s) => s.markAllRead);
|
|
141
|
+
const markRead = chunkVAMPYLQ4_cjs.useNotify((s) => s.markRead);
|
|
142
|
+
const muted = chunkVAMPYLQ4_cjs.useNotify((s) => s.muted);
|
|
143
|
+
const setMuted = chunkVAMPYLQ4_cjs.useNotify((s) => s.setMuted);
|
|
144
|
+
const tone = (v) => toneClassNames?.[v] ?? chunkVAMPYLQ4_cjs.DEFAULT_NOTIFY_TONE[v];
|
|
288
145
|
const visible = notifications.filter((n) => !n.ambient).slice(0, BELL_LIMIT);
|
|
289
146
|
return /* @__PURE__ */ jsxRuntime.jsxs(chunkHJDR5HEO_cjs.DropdownMenu, { open, onOpenChange: setOpen, children: [
|
|
290
147
|
/* @__PURE__ */ jsxRuntime.jsx(chunkHJDR5HEO_cjs.DropdownMenuTrigger, { asChild: true, children: renderTrigger ? renderTrigger({
|
|
@@ -424,48 +281,198 @@ function NotificationBell({
|
|
|
424
281
|
)
|
|
425
282
|
] });
|
|
426
283
|
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
284
|
+
function ArbiHost({
|
|
285
|
+
config,
|
|
286
|
+
children
|
|
287
|
+
}) {
|
|
288
|
+
const parent = react.useContext(chunkRCKA7BEF_cjs.ArbiHostContext);
|
|
289
|
+
const [ownSession] = react.useState(() => ({ current: null }));
|
|
290
|
+
const value = react.useMemo(() => {
|
|
291
|
+
const merged = chunkN73IMVFF_cjs.mergeHostConfig(parent, config);
|
|
292
|
+
return merged[chunkN73IMVFF_cjs.OWN_SESSION_SLOT] ? merged : { ...merged, [chunkN73IMVFF_cjs.OWN_SESSION_SLOT]: ownSession };
|
|
293
|
+
}, [parent, config, ownSession]);
|
|
294
|
+
const Connection = config.connection?.Provider;
|
|
295
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkRCKA7BEF_cjs.ArbiHostContext.Provider, { value, children: Connection ? /* @__PURE__ */ jsxRuntime.jsx(Connection, { children }) : children });
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// src/chat/mentions.ts
|
|
299
|
+
var MAX_QUERY_LENGTH = 40;
|
|
300
|
+
function findMentionQuery(text, caret) {
|
|
301
|
+
const before = text.slice(0, caret);
|
|
302
|
+
const at = before.lastIndexOf("@");
|
|
303
|
+
if (at < 0) return null;
|
|
304
|
+
if (at > 0 && !/\s/.test(before[at - 1])) return null;
|
|
305
|
+
const query = before.slice(at + 1);
|
|
306
|
+
if (query.length > MAX_QUERY_LENGTH || query.includes("\n") || query.startsWith(" ")) return null;
|
|
307
|
+
return { start: at, query };
|
|
308
|
+
}
|
|
309
|
+
function filterMentionCandidates(candidates, query) {
|
|
310
|
+
const q = query.trim().toLowerCase();
|
|
311
|
+
if (!q) return candidates.slice();
|
|
312
|
+
const scored = [];
|
|
313
|
+
for (const c of candidates) {
|
|
314
|
+
const label = c.label.toLowerCase();
|
|
315
|
+
if (label.startsWith(q)) scored.push({ c, score: 0 });
|
|
316
|
+
else if (label.split(/\s+/).some((word) => word.startsWith(q))) scored.push({ c, score: 1 });
|
|
317
|
+
else if (c.description?.toLowerCase().startsWith(q)) scored.push({ c, score: 2 });
|
|
433
318
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
319
|
+
return scored.sort((a, b) => a.score - b.score).map((s) => s.c);
|
|
320
|
+
}
|
|
321
|
+
function insertMention(text, start, caret, label) {
|
|
322
|
+
const inserted = `@${label} `;
|
|
323
|
+
return {
|
|
324
|
+
text: text.slice(0, start) + inserted + text.slice(caret),
|
|
325
|
+
caret: start + inserted.length
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
function tokenRanges(text, label) {
|
|
329
|
+
const needle = `@${label}`;
|
|
330
|
+
const ranges = [];
|
|
331
|
+
let from = 0;
|
|
332
|
+
for (; ; ) {
|
|
333
|
+
const i = text.indexOf(needle, from);
|
|
334
|
+
if (i < 0) break;
|
|
335
|
+
const end = i + needle.length;
|
|
336
|
+
const startsToken = i === 0 || /\s|\(|\[/.test(text[i - 1]);
|
|
337
|
+
const endsToken = end === text.length || !/[\p{L}\p{N}_]/u.test(text[end]);
|
|
338
|
+
if (startsToken && endsToken) ranges.push([i, end]);
|
|
339
|
+
from = end;
|
|
340
|
+
}
|
|
341
|
+
return ranges;
|
|
342
|
+
}
|
|
343
|
+
function extractMentions(text, candidates) {
|
|
344
|
+
const taken = [];
|
|
345
|
+
const found = [];
|
|
346
|
+
const byLength = [...candidates].sort((a, b) => b.label.length - a.label.length);
|
|
347
|
+
for (const c of byLength) {
|
|
348
|
+
if (!c.label) continue;
|
|
349
|
+
for (const [from, to] of tokenRanges(text, c.label)) {
|
|
350
|
+
if (taken.some(([a, b]) => from < b && to > a)) continue;
|
|
351
|
+
taken.push([from, to]);
|
|
352
|
+
if (!found.some((f) => f.c.id === c.id)) found.push({ c, at: from });
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return found.sort((a, b) => a.at - b.at).map((f) => f.c);
|
|
356
|
+
}
|
|
357
|
+
function toMessageMentions(mentioned) {
|
|
358
|
+
return mentioned.map(
|
|
359
|
+
(c) => c.kind === "assistant" ? { type: "assistant" } : { type: "user", user_ext_id: c.id }
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
var MENTION_HREF_PREFIX = "#mention-";
|
|
363
|
+
function escapeLinkText(label) {
|
|
364
|
+
return label.replace(/[[\]\\]/g, (ch) => `\\${ch}`);
|
|
365
|
+
}
|
|
366
|
+
function linkMentions(content, mentions, assistantLabels = []) {
|
|
367
|
+
if (!mentions || mentions.length === 0 || !content) return content;
|
|
368
|
+
const targets = [];
|
|
369
|
+
for (const m of mentions) {
|
|
370
|
+
const id = m.type === "assistant" ? "assistant" : m.user_ext_id;
|
|
371
|
+
if (!id) continue;
|
|
372
|
+
const labels = m.type === "assistant" ? [m.label ?? "", ...assistantLabels] : [m.label ?? ""];
|
|
373
|
+
for (const label of labels) if (label) targets.push({ label, id });
|
|
374
|
+
}
|
|
375
|
+
targets.sort((a, b) => b.label.length - a.label.length);
|
|
376
|
+
const replacements = [];
|
|
377
|
+
for (const { label, id } of targets) {
|
|
378
|
+
for (const [from, to] of tokenRanges(content, label)) {
|
|
379
|
+
if (replacements.some((r) => from < r.to && to > r.from)) continue;
|
|
380
|
+
replacements.push({
|
|
381
|
+
from,
|
|
382
|
+
to,
|
|
383
|
+
text: `[@${escapeLinkText(label)}](${MENTION_HREF_PREFIX}${id})`
|
|
384
|
+
});
|
|
442
385
|
}
|
|
386
|
+
}
|
|
387
|
+
replacements.sort((a, b) => b.from - a.from);
|
|
388
|
+
let out = content;
|
|
389
|
+
for (const r of replacements) out = out.slice(0, r.from) + r.text + out.slice(r.to);
|
|
390
|
+
return out;
|
|
391
|
+
}
|
|
392
|
+
function mentionFromHref(href) {
|
|
393
|
+
if (!href?.startsWith(MENTION_HREF_PREFIX)) return null;
|
|
394
|
+
const id = href.slice(MENTION_HREF_PREFIX.length);
|
|
395
|
+
if (!id) return null;
|
|
396
|
+
return { kind: id === "assistant" ? "assistant" : "user", id };
|
|
397
|
+
}
|
|
398
|
+
function hasMessageBody(value, recipientLabel = "ARBI") {
|
|
399
|
+
const text = value.trim();
|
|
400
|
+
return !!text && text.toLowerCase() !== `@${recipientLabel}`.toLowerCase();
|
|
401
|
+
}
|
|
402
|
+
function savedDocumentIdFor(input) {
|
|
403
|
+
const { documentId, isDraft, isStreaming, isBlobArtifact, documentData } = input;
|
|
404
|
+
if (!documentId || isDraft || isStreaming || isBlobArtifact) return null;
|
|
405
|
+
if (documentData?.wp_type !== "artifact" && !documentData?.file_name?.toLowerCase().endsWith(".docx"))
|
|
406
|
+
return null;
|
|
407
|
+
if (documentData.external_id !== documentId) return null;
|
|
408
|
+
return documentId;
|
|
409
|
+
}
|
|
410
|
+
var entries = [];
|
|
411
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
412
|
+
function subscribe(listener) {
|
|
413
|
+
listeners.add(listener);
|
|
414
|
+
return () => listeners.delete(listener);
|
|
415
|
+
}
|
|
416
|
+
function emit() {
|
|
417
|
+
listeners.forEach((l) => l());
|
|
418
|
+
}
|
|
419
|
+
var top = () => entries[entries.length - 1];
|
|
420
|
+
function useRegisterOpenDocument(registration) {
|
|
421
|
+
const latest = react.useRef(registration);
|
|
422
|
+
react.useEffect(() => {
|
|
423
|
+
latest.current = registration;
|
|
424
|
+
});
|
|
425
|
+
const { documentId } = registration;
|
|
426
|
+
react.useEffect(() => {
|
|
427
|
+
if (!documentId) return;
|
|
428
|
+
const entry = { documentId, current: () => latest.current };
|
|
429
|
+
entries = [...entries, entry];
|
|
430
|
+
emit();
|
|
431
|
+
return () => {
|
|
432
|
+
entries = entries.filter((e) => e !== entry);
|
|
433
|
+
emit();
|
|
434
|
+
};
|
|
435
|
+
}, [documentId]);
|
|
436
|
+
}
|
|
437
|
+
function useOpenDocumentId() {
|
|
438
|
+
return react.useSyncExternalStore(
|
|
439
|
+
subscribe,
|
|
440
|
+
() => top()?.documentId ?? null,
|
|
441
|
+
() => null
|
|
443
442
|
);
|
|
444
443
|
}
|
|
444
|
+
function takeOpenDocumentForTurn(options) {
|
|
445
|
+
const entry = top();
|
|
446
|
+
if (!entry) return null;
|
|
447
|
+
const { shownId, showLive, workspaceId } = entry.current();
|
|
448
|
+
if (options?.workspaceId && workspaceId && options.workspaceId !== workspaceId) return null;
|
|
449
|
+
if (shownId && shownId !== entry.documentId && chunkZWFMFOGP_cjs.parseVersionRef(shownId).docId === entry.documentId)
|
|
450
|
+
showLive?.();
|
|
451
|
+
return entry.documentId;
|
|
452
|
+
}
|
|
445
453
|
|
|
446
|
-
Object.defineProperty(exports, "toast", {
|
|
447
|
-
enumerable: true,
|
|
448
|
-
get: function () { return sonner.toast; }
|
|
449
|
-
});
|
|
450
454
|
exports.ArbiHost = ArbiHost;
|
|
451
|
-
exports.
|
|
452
|
-
exports.MAX_SESSION_NOTIFICATIONS = MAX_SESSION_NOTIFICATIONS;
|
|
455
|
+
exports.MENTION_HREF_PREFIX = MENTION_HREF_PREFIX;
|
|
453
456
|
exports.NotificationBell = NotificationBell;
|
|
454
|
-
exports.OWN_SESSION_SLOT = OWN_SESSION_SLOT;
|
|
455
457
|
exports.Toaster = Toaster;
|
|
456
458
|
exports.clearSearchSession = clearSearchSession;
|
|
457
|
-
exports.configureNotify = configureNotify;
|
|
458
459
|
exports.createSearchSession = createSearchSession;
|
|
460
|
+
exports.extractMentions = extractMentions;
|
|
461
|
+
exports.filterMentionCandidates = filterMentionCandidates;
|
|
462
|
+
exports.findMentionQuery = findMentionQuery;
|
|
459
463
|
exports.formatRelativeTime = formatRelativeTime;
|
|
460
|
-
exports.
|
|
461
|
-
exports.
|
|
462
|
-
exports.
|
|
464
|
+
exports.hasMessageBody = hasMessageBody;
|
|
465
|
+
exports.insertMention = insertMention;
|
|
466
|
+
exports.linkMentions = linkMentions;
|
|
467
|
+
exports.mentionFromHref = mentionFromHref;
|
|
463
468
|
exports.persistSearchSession = persistSearchSession;
|
|
464
469
|
exports.requestSearch = requestSearch;
|
|
465
|
-
exports.
|
|
466
|
-
exports.selectUnread = selectUnread;
|
|
470
|
+
exports.savedDocumentIdFor = savedDocumentIdFor;
|
|
467
471
|
exports.sharedSearchSession = sharedSearchSession;
|
|
472
|
+
exports.takeOpenDocumentForTurn = takeOpenDocumentForTurn;
|
|
468
473
|
exports.takePendingSearch = takePendingSearch;
|
|
469
|
-
exports.
|
|
470
|
-
|
|
471
|
-
|
|
474
|
+
exports.toMessageMentions = toMessageMentions;
|
|
475
|
+
exports.useOpenDocumentId = useOpenDocumentId;
|
|
476
|
+
exports.useRegisterOpenDocument = useRegisterOpenDocument;
|
|
477
|
+
//# sourceMappingURL=chunk-ZI2VJOID.cjs.map
|
|
478
|
+
//# sourceMappingURL=chunk-ZI2VJOID.cjs.map
|