@arbidocs/react 0.4.154 → 0.4.155
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 +13 -13
- package/dist/artifacts/index.js +2 -2
- package/dist/{chunk-YYTX3W6C.js → chunk-2HNEVAXO.js} +68 -3
- package/dist/chunk-2HNEVAXO.js.map +1 -0
- package/dist/{chunk-KD7CKXWQ.js → chunk-6FGO7SCY.js} +182 -42
- package/dist/chunk-6FGO7SCY.js.map +1 -0
- package/dist/{chunk-L57RRAII.cjs → chunk-QKNJ6FRD.cjs} +71 -2
- package/dist/chunk-QKNJ6FRD.cjs.map +1 -0
- package/dist/{chunk-L66ZJ2UI.cjs → chunk-VKWGRGY6.cjs} +188 -40
- package/dist/chunk-VKWGRGY6.cjs.map +1 -0
- package/dist/document-tools/index.cjs +41 -93
- package/dist/document-tools/index.cjs.map +1 -1
- package/dist/document-tools/index.js +3 -67
- package/dist/document-tools/index.js.map +1 -1
- package/dist/{index-BV7pBlgY.d.cts → index-CDTwtUr9.d.cts} +89 -1
- package/dist/{index-BV7pBlgY.d.ts → index-CDTwtUr9.d.ts} +89 -1
- package/dist/index.cjs +612 -228
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +187 -3
- package/dist/index.d.ts +187 -3
- package/dist/index.js +340 -7
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +193 -161
- package/dist/ui/index.d.cts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +2 -2
- package/package.json +7 -5
- package/dist/chunk-KD7CKXWQ.js.map +0 -1
- package/dist/chunk-L57RRAII.cjs.map +0 -1
- package/dist/chunk-L66ZJ2UI.cjs.map +0 -1
- package/dist/chunk-YYTX3W6C.js.map +0 -1
package/dist/artifacts/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunk37TQBT7Y_cjs = require('../chunk-37TQBT7Y.cjs');
|
|
4
|
-
var chunk3AADNIOK_cjs = require('../chunk-3AADNIOK.cjs');
|
|
5
4
|
var chunkZWFMFOGP_cjs = require('../chunk-ZWFMFOGP.cjs');
|
|
5
|
+
var chunk3AADNIOK_cjs = require('../chunk-3AADNIOK.cjs');
|
|
6
6
|
var chunkVOFNX4P6_cjs = require('../chunk-VOFNX4P6.cjs');
|
|
7
7
|
var chunkOC7F5SNA_cjs = require('../chunk-OC7F5SNA.cjs');
|
|
8
8
|
require('../chunk-Z3LLUO32.cjs');
|
|
@@ -572,18 +572,6 @@ function viewerTabForArtifactMode(mode) {
|
|
|
572
572
|
return artifactKindFromMode(mode) ? "preview" : "edit";
|
|
573
573
|
}
|
|
574
574
|
|
|
575
|
-
Object.defineProperty(exports, "buildHybridRedlineMarkdown", {
|
|
576
|
-
enumerable: true,
|
|
577
|
-
get: function () { return chunk3AADNIOK_cjs.buildHybridRedlineMarkdown; }
|
|
578
|
-
});
|
|
579
|
-
Object.defineProperty(exports, "buildHybridRedlineWithRegions", {
|
|
580
|
-
enumerable: true,
|
|
581
|
-
get: function () { return chunk3AADNIOK_cjs.buildHybridRedlineWithRegions; }
|
|
582
|
-
});
|
|
583
|
-
Object.defineProperty(exports, "revertRedlineRegion", {
|
|
584
|
-
enumerable: true,
|
|
585
|
-
get: function () { return chunk3AADNIOK_cjs.revertRedlineRegion; }
|
|
586
|
-
});
|
|
587
575
|
Object.defineProperty(exports, "cleanDraftMarkdown", {
|
|
588
576
|
enumerable: true,
|
|
589
577
|
get: function () { return chunkZWFMFOGP_cjs.cleanDraftMarkdown; }
|
|
@@ -652,6 +640,18 @@ Object.defineProperty(exports, "versionRef", {
|
|
|
652
640
|
enumerable: true,
|
|
653
641
|
get: function () { return chunkZWFMFOGP_cjs.versionRef; }
|
|
654
642
|
});
|
|
643
|
+
Object.defineProperty(exports, "buildHybridRedlineMarkdown", {
|
|
644
|
+
enumerable: true,
|
|
645
|
+
get: function () { return chunk3AADNIOK_cjs.buildHybridRedlineMarkdown; }
|
|
646
|
+
});
|
|
647
|
+
Object.defineProperty(exports, "buildHybridRedlineWithRegions", {
|
|
648
|
+
enumerable: true,
|
|
649
|
+
get: function () { return chunk3AADNIOK_cjs.buildHybridRedlineWithRegions; }
|
|
650
|
+
});
|
|
651
|
+
Object.defineProperty(exports, "revertRedlineRegion", {
|
|
652
|
+
enumerable: true,
|
|
653
|
+
get: function () { return chunk3AADNIOK_cjs.revertRedlineRegion; }
|
|
654
|
+
});
|
|
655
655
|
Object.defineProperty(exports, "normalizeMarkdown", {
|
|
656
656
|
enumerable: true,
|
|
657
657
|
get: function () { return chunkVOFNX4P6_cjs.normalizeMarkdown; }
|
package/dist/artifacts/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { arbiQueryKeys, useDocuments, useDocumentVersionList, refreshDocuments } from '../chunk-HKIR456G.js';
|
|
2
|
-
import { revertRedlineRegion, buildHybridRedlineWithRegions, buildHybridRedlineMarkdown } from '../chunk-74N436VK.js';
|
|
3
|
-
export { buildHybridRedlineMarkdown, buildHybridRedlineWithRegions, revertRedlineRegion } from '../chunk-74N436VK.js';
|
|
4
2
|
import { isDocumentId, parseVersionRef, flattenChunks, documentVersions, toArtifactVersions, findVersion, versionLabel, cleanDraftWithReport } from '../chunk-NNWMHMEC.js';
|
|
5
3
|
export { cleanDraftMarkdown, cleanDraftWithReport, documentVersions, findVersion, flattenChunks, isDocumentId, parseVersionRef, promoteBoldTitle, repairParsedStructure, repairParsedTitle, savedFromId, stripAgentPreamble, toArtifactVersions, unescapeMarkdown, unwrapCitationLinks, versionLabel, versionRef } from '../chunk-NNWMHMEC.js';
|
|
4
|
+
import { revertRedlineRegion, buildHybridRedlineWithRegions, buildHybridRedlineMarkdown } from '../chunk-74N436VK.js';
|
|
5
|
+
export { buildHybridRedlineMarkdown, buildHybridRedlineWithRegions, revertRedlineRegion } from '../chunk-74N436VK.js';
|
|
6
6
|
import { normalizeMarkdown } from '../chunk-WUTL62MC.js';
|
|
7
7
|
export { normalizeMarkdown } from '../chunk-WUTL62MC.js';
|
|
8
8
|
import { MarkdownRenderer } from '../chunk-C44GO33B.js';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseVersionRef } from './chunk-NNWMHMEC.js';
|
|
1
2
|
import { useDeploymentDomain } from './chunk-CPPBN2JB.js';
|
|
2
3
|
import { createContext, useMemo, useContext } from 'react';
|
|
3
4
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -96,6 +97,70 @@ function useDocumentTools() {
|
|
|
96
97
|
return env;
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
// src/document-tools/document-pdf.ts
|
|
101
|
+
var DocumentFetchError = class extends Error {
|
|
102
|
+
status;
|
|
103
|
+
constructor(message, status) {
|
|
104
|
+
super(message);
|
|
105
|
+
this.name = "DocumentFetchError";
|
|
106
|
+
this.status = status;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
async function fetchDocumentBytes(client, endpoint, documentRef, options, headers, what) {
|
|
110
|
+
const ref = parseVersionRef(documentRef);
|
|
111
|
+
const version = options.version ?? ref.version;
|
|
112
|
+
const { data, response } = await client.GET(endpoint, {
|
|
113
|
+
params: { path: { document_ext_id: ref.docId }, query: version ? { version } : {} },
|
|
114
|
+
headers,
|
|
115
|
+
parseAs: "blob",
|
|
116
|
+
signal: options.signal
|
|
117
|
+
});
|
|
118
|
+
if (!response.ok || !(data instanceof Blob)) {
|
|
119
|
+
throw new DocumentFetchError(
|
|
120
|
+
`${what} could not be loaded (${response.status})`,
|
|
121
|
+
response.status
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
return { blob: data, response };
|
|
125
|
+
}
|
|
126
|
+
function contentDispositionFileName(header) {
|
|
127
|
+
if (!header) return void 0;
|
|
128
|
+
const extended = /filename\*\s*=\s*(?:[\w-]+)?'[^']*'([^;]+)/i.exec(header);
|
|
129
|
+
if (extended) {
|
|
130
|
+
try {
|
|
131
|
+
return decodeURIComponent(extended[1].trim().replace(/^"|"$/g, "")) || void 0;
|
|
132
|
+
} catch {
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const plain = /filename\s*=\s*("((?:[^"\\]|\\.)*)"|[^;]+)/i.exec(header);
|
|
136
|
+
if (!plain) return void 0;
|
|
137
|
+
const name = plain[2] !== void 0 ? plain[2].replace(/\\(.)/g, "$1") : plain[1].trim();
|
|
138
|
+
return name || void 0;
|
|
139
|
+
}
|
|
140
|
+
async function fetchDocumentPdf(client, documentRef, options = {}) {
|
|
141
|
+
const { blob } = await fetchDocumentBytes(
|
|
142
|
+
client,
|
|
143
|
+
"/v1/document/{document_ext_id}/view",
|
|
144
|
+
documentRef,
|
|
145
|
+
options,
|
|
146
|
+
{ Accept: "application/pdf" },
|
|
147
|
+
"The PDF"
|
|
148
|
+
);
|
|
149
|
+
return blob;
|
|
150
|
+
}
|
|
151
|
+
async function fetchDocumentFile(client, documentRef, options = {}) {
|
|
152
|
+
const { blob, response } = await fetchDocumentBytes(
|
|
153
|
+
client,
|
|
154
|
+
"/v1/document/{document_ext_id}/download",
|
|
155
|
+
documentRef,
|
|
156
|
+
options,
|
|
157
|
+
{},
|
|
158
|
+
"The file"
|
|
159
|
+
);
|
|
160
|
+
const name = contentDispositionFileName(response.headers.get("Content-Disposition"));
|
|
161
|
+
return name ? new File([blob], name, { type: blob.type }) : blob;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export { DocumentFetchError, DocumentToolsProvider, certificateLink, clientUpload, contentDispositionFileName, defaultCertificateUrl, downloadBlob, fetchDocumentFile, fetchDocumentPdf, uploadQueryString, useDocumentTools, useOptionalDocumentTools };
|
|
165
|
+
//# sourceMappingURL=chunk-2HNEVAXO.js.map
|
|
166
|
+
//# sourceMappingURL=chunk-2HNEVAXO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/document-tools/environment.tsx","../src/document-tools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AAC,CAAA,CAAE,OAAA,CAAQ,UAAU,IAAI,CAAA,GAAI,KAAA,CAAM,CAAC,EAAE,IAAA,EAAK;AACvF,EAAA,OAAO,IAAA,IAAQ,MAAA;AACjB;AAMA,eAAsB,gBAAA,CACpB,MAAA,EACA,WAAA,EACA,OAAA,GAAgC,EAAC,EAClB;AACf,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,kBAAA;AAAA,IACrB,MAAA;AAAA,IACA,qCAAA;AAAA,IACA,WAAA;AAAA,IACA,OAAA;AAAA,IACA,EAAE,QAAQ,iBAAA,EAAkB;AAAA,IAC5B;AAAA,GACF;AACA,EAAA,OAAO,IAAA;AACT;AAMA,eAAsB,iBAAA,CACpB,MAAA,EACA,WAAA,EACA,OAAA,GAAgC,EAAC,EACX;AACtB,EAAA,MAAM,EAAE,IAAA,EAAM,QAAA,EAAS,GAAI,MAAM,kBAAA;AAAA,IAC/B,MAAA;AAAA,IACA,yCAAA;AAAA,IACA,WAAA;AAAA,IACA,OAAA;AAAA,IACA,EAAC;AAAA,IACD;AAAA,GACF;AACA,EAAA,MAAM,OAAO,0BAAA,CAA2B,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,qBAAqB,CAAC,CAAA;AACnF,EAAA,OAAO,IAAA,GAAO,IAAI,IAAA,CAAK,CAAC,IAAI,CAAA,EAAG,IAAA,EAAM,EAAE,IAAA,EAAM,IAAA,CAAK,IAAA,EAAM,CAAA,GAAI,IAAA;AAC9D","file":"chunk-2HNEVAXO.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 enclosing `<ArbiProvider>`'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"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { MarkdownRenderer } from './chunk-C44GO33B.js';
|
|
2
1
|
import { Dialog, DialogContent } from './chunk-YNNAJJ5Z.js';
|
|
2
|
+
import { MarkdownRenderer } from './chunk-C44GO33B.js';
|
|
3
3
|
import { getCollisionPadding, usePortalContainer, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuLabel, DropdownMenuItem, DropdownMenuSeparator } from './chunk-47CCGUWR.js';
|
|
4
4
|
import { cn } from './chunk-SN5YV6FF.js';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import React__default, { createContext, forwardRef, memo, useContext, useState, useRef, useEffect, useCallback, useId, useMemo, Fragment as Fragment$1 } from 'react';
|
|
7
7
|
import { createPortal } from 'react-dom';
|
|
8
8
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
9
|
-
import { ChevronDown, ChevronUp, Check, Circle, Search, MessageCircleMore, Loader2, Square, Mic, MoreVertical, BadgeCheck, MessageSquareLock, Info, FileQuestion, BookOpen, Upload, LogOut, LayoutGrid, Bell, MessageSquare, CircleUserRound, Wrench, CreditCard, ClipboardList, UserPlus, UserStar, Settings2, Users, User, NotebookPen, NotebookText, Building2, Contact, Scale, Tags, StickyNote, FolderPlus, Hash, EyeOff, Eye, CaptionsOff, FolderOpen, MessageSquareMore, MessageSquarePlus, MessageSquareText, MessageSquareOff, MessagesSquare, Columns3Cog, SquarePlus, SquareM, ChevronsDown, Bot, Calendar, Folder, List, SquareCheckBig, Minus, Plus, Share2, CheckCircle2, MessageSquareShare, ChevronsUpDown, X, AlertTriangle, FileX, SkipForward, XCircle, CheckCircle } from 'lucide-react';
|
|
9
|
+
import { ChevronDown, ChevronUp, Check, Circle, Search, MessageCircleMore, Loader2, Square, Mic, MoreVertical, BadgeCheck, MessageSquareLock, Info, FileQuestion, BookOpen, Upload, LogOut, LayoutGrid, Bell, MessageSquare, CircleUserRound, Wrench, CreditCard, ClipboardList, UserPlus, UserStar, Settings2, Users, User, NotebookPen, NotebookText, Building2, Contact, Scale, Tags, StickyNote, FolderPlus, Hash, EyeOff, Eye, CaptionsOff, FolderOpen, MessageSquareMore, MessageSquarePlus, MessageSquareText, MessageSquareOff, MessagesSquare, Columns3Cog, SquarePlus, SquareM, ChevronsDown, Bot, Calendar, Folder, List, SquareCheckBig, Minus, Plus, Share2, CheckCircle2, FileText, MessageSquareShare, ChevronsUpDown, X, AlertTriangle, FileX, SkipForward, XCircle, CheckCircle } from 'lucide-react';
|
|
10
10
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
11
11
|
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
12
12
|
import { cva } from 'class-variance-authority';
|
|
@@ -3247,6 +3247,96 @@ var EmlIcon = ({ size = 16, className = "" }) => {
|
|
|
3247
3247
|
}
|
|
3248
3248
|
);
|
|
3249
3249
|
};
|
|
3250
|
+
var TextIcon = FileText;
|
|
3251
|
+
var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "bmp", "tiff", "tif", "webp", "svg"]);
|
|
3252
|
+
var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set(["mp4", "mpeg", "mpg", "webm", "mov", "avi", "mkv"]);
|
|
3253
|
+
var AUDIO_EXTENSIONS = /* @__PURE__ */ new Set(["mp3", "wav", "m4a", "aac", "ogg", "flac"]);
|
|
3254
|
+
var DOCX_EXTENSIONS = /* @__PURE__ */ new Set(["doc", "docx", "odt", "rtf"]);
|
|
3255
|
+
var XLSX_EXTENSIONS = /* @__PURE__ */ new Set(["xls", "xlsx", "csv", "ods"]);
|
|
3256
|
+
var EMAIL_EXTENSIONS = /* @__PURE__ */ new Set(["eml", "msg"]);
|
|
3257
|
+
var HTML_EXTENSIONS = /* @__PURE__ */ new Set(["html", "htm", "mhtml"]);
|
|
3258
|
+
var PDF_EXTENSIONS = /* @__PURE__ */ new Set(["pdf"]);
|
|
3259
|
+
var TEXT_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
3260
|
+
"txt",
|
|
3261
|
+
"text",
|
|
3262
|
+
"md",
|
|
3263
|
+
"markdown",
|
|
3264
|
+
"log",
|
|
3265
|
+
"json",
|
|
3266
|
+
"xml",
|
|
3267
|
+
"yaml",
|
|
3268
|
+
"yml"
|
|
3269
|
+
]);
|
|
3270
|
+
function getFileExtension(fileName) {
|
|
3271
|
+
if (!fileName) return "";
|
|
3272
|
+
const dot = fileName.lastIndexOf(".");
|
|
3273
|
+
if (dot <= 0 || dot === fileName.length - 1) return "";
|
|
3274
|
+
return fileName.slice(dot + 1).toLowerCase();
|
|
3275
|
+
}
|
|
3276
|
+
var MIME_TO_EXTENSION = {
|
|
3277
|
+
"application/pdf": "pdf",
|
|
3278
|
+
"text/plain": "txt",
|
|
3279
|
+
"text/markdown": "md",
|
|
3280
|
+
"text/html": "html",
|
|
3281
|
+
"text/csv": "csv",
|
|
3282
|
+
"application/json": "json",
|
|
3283
|
+
"application/xml": "xml",
|
|
3284
|
+
"application/msword": "doc",
|
|
3285
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
|
|
3286
|
+
"application/rtf": "rtf",
|
|
3287
|
+
"application/vnd.oasis.opendocument.text": "odt",
|
|
3288
|
+
"application/vnd.ms-excel": "xls",
|
|
3289
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
|
|
3290
|
+
"application/vnd.oasis.opendocument.spreadsheet": "ods",
|
|
3291
|
+
"image/png": "png",
|
|
3292
|
+
"image/jpeg": "jpg",
|
|
3293
|
+
"image/gif": "gif",
|
|
3294
|
+
"image/webp": "webp",
|
|
3295
|
+
"image/svg+xml": "svg",
|
|
3296
|
+
"image/tiff": "tiff",
|
|
3297
|
+
"image/bmp": "bmp",
|
|
3298
|
+
"video/mp4": "mp4",
|
|
3299
|
+
"video/webm": "webm",
|
|
3300
|
+
"video/quicktime": "mov",
|
|
3301
|
+
"audio/mpeg": "mp3",
|
|
3302
|
+
"audio/wav": "wav",
|
|
3303
|
+
"audio/ogg": "ogg",
|
|
3304
|
+
"message/rfc822": "eml"
|
|
3305
|
+
};
|
|
3306
|
+
function extensionFromMime(mime) {
|
|
3307
|
+
if (!mime) return "";
|
|
3308
|
+
return MIME_TO_EXTENSION[mime.toLowerCase()] ?? "";
|
|
3309
|
+
}
|
|
3310
|
+
function iconFromExtension(ext) {
|
|
3311
|
+
if (VIDEO_EXTENSIONS.has(ext)) return VidIcon;
|
|
3312
|
+
if (AUDIO_EXTENSIONS.has(ext)) return AudIcon;
|
|
3313
|
+
if (IMAGE_EXTENSIONS.has(ext)) return ImgIcon;
|
|
3314
|
+
if (DOCX_EXTENSIONS.has(ext)) return DocIcon;
|
|
3315
|
+
if (XLSX_EXTENSIONS.has(ext)) return XlsIcon;
|
|
3316
|
+
if (EMAIL_EXTENSIONS.has(ext)) return EmlIcon;
|
|
3317
|
+
if (HTML_EXTENSIONS.has(ext)) return HtmlIcon;
|
|
3318
|
+
if (PDF_EXTENSIONS.has(ext)) return PdfIcon;
|
|
3319
|
+
if (TEXT_EXTENSIONS.has(ext)) return TextIcon;
|
|
3320
|
+
return null;
|
|
3321
|
+
}
|
|
3322
|
+
function iconFromMime(mime) {
|
|
3323
|
+
const m = mime.toLowerCase();
|
|
3324
|
+
if (m.startsWith("image/")) return ImgIcon;
|
|
3325
|
+
if (m.startsWith("video/")) return VidIcon;
|
|
3326
|
+
if (m.startsWith("audio/")) return AudIcon;
|
|
3327
|
+
if (m === "application/pdf") return PdfIcon;
|
|
3328
|
+
if (m === "text/html") return HtmlIcon;
|
|
3329
|
+
if (m === "message/rfc822" || m.includes("outlook")) return EmlIcon;
|
|
3330
|
+
if (m.includes("word") || m === "application/rtf" || m.includes("opendocument.text"))
|
|
3331
|
+
return DocIcon;
|
|
3332
|
+
if (m.includes("sheet") || m.includes("excel") || m === "text/csv" || m.includes("opendocument.spreadsheet"))
|
|
3333
|
+
return XlsIcon;
|
|
3334
|
+
if (m.startsWith("text/") || m === "application/json" || m === "application/xml") return TextIcon;
|
|
3335
|
+
return null;
|
|
3336
|
+
}
|
|
3337
|
+
function getFileTypeIcon(fileName, opts) {
|
|
3338
|
+
return iconFromExtension(getFileExtension(fileName)) ?? (opts?.mime ? iconFromMime(opts.mime) : null) ?? (opts?.defaultToPdf ? PdfIcon : TextIcon);
|
|
3339
|
+
}
|
|
3250
3340
|
var ArbiIcon = ({
|
|
3251
3341
|
size = 20,
|
|
3252
3342
|
className = "",
|
|
@@ -3561,14 +3651,14 @@ var MAX_LABEL_CHARS = 30;
|
|
|
3561
3651
|
function clampLabel(text) {
|
|
3562
3652
|
return text.length > MAX_LABEL_CHARS ? `${text.slice(0, MAX_LABEL_CHARS).trimEnd()}\u2026` : text;
|
|
3563
3653
|
}
|
|
3564
|
-
var
|
|
3565
|
-
var
|
|
3566
|
-
var
|
|
3567
|
-
var
|
|
3568
|
-
var
|
|
3569
|
-
var
|
|
3570
|
-
var
|
|
3571
|
-
var
|
|
3654
|
+
var IMAGE_EXTENSIONS2 = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "bmp", "tiff", "tif", "webp"]);
|
|
3655
|
+
var VIDEO_EXTENSIONS2 = /* @__PURE__ */ new Set(["mp4", "mpeg", "mpg", "webm", "mov", "avi", "mkv"]);
|
|
3656
|
+
var AUDIO_EXTENSIONS2 = /* @__PURE__ */ new Set(["mp3", "wav", "m4a", "aac", "ogg", "flac"]);
|
|
3657
|
+
var EMAIL_EXTENSIONS2 = /* @__PURE__ */ new Set(["eml", "msg"]);
|
|
3658
|
+
var DOCX_EXTENSIONS2 = /* @__PURE__ */ new Set(["doc", "docx", "odt", "rtf"]);
|
|
3659
|
+
var XLSX_EXTENSIONS2 = /* @__PURE__ */ new Set(["xls", "xlsx", "csv", "ods"]);
|
|
3660
|
+
var HTML_EXTENSIONS2 = /* @__PURE__ */ new Set(["html", "htm", "mhtml"]);
|
|
3661
|
+
var TEXT_EXTENSIONS2 = /* @__PURE__ */ new Set([
|
|
3572
3662
|
"txt",
|
|
3573
3663
|
"text",
|
|
3574
3664
|
"md",
|
|
@@ -3581,14 +3671,14 @@ var TEXT_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
3581
3671
|
]);
|
|
3582
3672
|
function getDocIcon(fileName, iconSize = 14) {
|
|
3583
3673
|
const ext = fileName?.split(".").pop()?.toLowerCase();
|
|
3584
|
-
if (ext &&
|
|
3585
|
-
if (ext &&
|
|
3586
|
-
if (ext &&
|
|
3587
|
-
if (ext &&
|
|
3588
|
-
if (ext &&
|
|
3589
|
-
if (ext &&
|
|
3590
|
-
if (ext &&
|
|
3591
|
-
if (ext &&
|
|
3674
|
+
if (ext && VIDEO_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsx(VidIcon, { size: iconSize, className: "flex-shrink-0" });
|
|
3675
|
+
if (ext && AUDIO_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsx(AudIcon, { size: iconSize, className: "flex-shrink-0" });
|
|
3676
|
+
if (ext && IMAGE_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsx(ImgIcon, { size: iconSize, className: "flex-shrink-0" });
|
|
3677
|
+
if (ext && EMAIL_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsx(EmlIcon, { size: iconSize, className: "flex-shrink-0" });
|
|
3678
|
+
if (ext && DOCX_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsx(DocIcon, { size: iconSize, className: "flex-shrink-0" });
|
|
3679
|
+
if (ext && XLSX_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsx(XlsIcon, { size: iconSize, className: "flex-shrink-0" });
|
|
3680
|
+
if (ext && HTML_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsx(HtmlIcon, { size: iconSize, className: "flex-shrink-0" });
|
|
3681
|
+
if (ext && TEXT_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsx(TxtIcon, { size: iconSize, className: "flex-shrink-0" });
|
|
3592
3682
|
return /* @__PURE__ */ jsx(PdfIcon, { size: iconSize, className: "flex-shrink-0" });
|
|
3593
3683
|
}
|
|
3594
3684
|
function DocumentEntity({
|
|
@@ -3905,7 +3995,7 @@ var UserEntity = memo(function UserEntity2({
|
|
|
3905
3995
|
picture,
|
|
3906
3996
|
avatarImageClassName,
|
|
3907
3997
|
colorClass = "",
|
|
3908
|
-
isAgent = false,
|
|
3998
|
+
isAgent: isAgent2 = false,
|
|
3909
3999
|
isVerified = false,
|
|
3910
4000
|
agentStyle,
|
|
3911
4001
|
avatarStyle,
|
|
@@ -3925,16 +4015,16 @@ var UserEntity = memo(function UserEntity2({
|
|
|
3925
4015
|
}
|
|
3926
4016
|
);
|
|
3927
4017
|
}
|
|
3928
|
-
const agentBadge =
|
|
3929
|
-
const canMessage = interactive && !isMe && !
|
|
3930
|
-
const showUnread = hasUnreadMessages && !isMe && !
|
|
4018
|
+
const agentBadge = isAgent2 ? /* @__PURE__ */ jsx(ArbiBotHeadIcon, { className: "w-3.5 h-3.5 text-muted-foreground" }) : void 0;
|
|
4019
|
+
const canMessage = interactive && !isMe && !isAgent2;
|
|
4020
|
+
const showUnread = hasUnreadMessages && !isMe && !isAgent2;
|
|
3931
4021
|
const surfaceStyle = avatarStyle ?? agentStyle;
|
|
3932
4022
|
const avatarCore = /* @__PURE__ */ jsxs(
|
|
3933
4023
|
Avatar,
|
|
3934
4024
|
{
|
|
3935
4025
|
className: cn(
|
|
3936
4026
|
sizeClasses[size],
|
|
3937
|
-
|
|
4027
|
+
isAgent2 ? "rounded-full border-2 border-dashed" : "border border-white"
|
|
3938
4028
|
),
|
|
3939
4029
|
style: surfaceStyle,
|
|
3940
4030
|
"data-testid": "user-entity",
|
|
@@ -3946,7 +4036,7 @@ var UserEntity = memo(function UserEntity2({
|
|
|
3946
4036
|
className: cn(
|
|
3947
4037
|
textSizeClasses[size],
|
|
3948
4038
|
"font-semibold leading-none",
|
|
3949
|
-
|
|
4039
|
+
isAgent2 ? "rounded-full bg-transparent" : `text-white ${colorClass}`
|
|
3950
4040
|
),
|
|
3951
4041
|
style: surfaceStyle,
|
|
3952
4042
|
children: initials
|
|
@@ -4006,7 +4096,7 @@ var UserEntity = memo(function UserEntity2({
|
|
|
4006
4096
|
const row = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4007
4097
|
pillAvatar,
|
|
4008
4098
|
displayName && /* @__PURE__ */ jsx("span", { className: "min-w-0 max-w-[320px] truncate text-sm leading-tight", children: displayName }),
|
|
4009
|
-
isVerified && !
|
|
4099
|
+
isVerified && !isAgent2 && /* @__PURE__ */ jsx(VerifiedBadge, {}),
|
|
4010
4100
|
agentBadge
|
|
4011
4101
|
] });
|
|
4012
4102
|
const rowClass = "group/pill inline-flex min-w-0 items-center gap-2";
|
|
@@ -4304,7 +4394,7 @@ var DOWNLOAD_ONLY_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
4304
4394
|
".ai",
|
|
4305
4395
|
".sketch"
|
|
4306
4396
|
]);
|
|
4307
|
-
var
|
|
4397
|
+
var IMAGE_EXTENSIONS3 = /* @__PURE__ */ new Set([
|
|
4308
4398
|
".jpg",
|
|
4309
4399
|
".jpeg",
|
|
4310
4400
|
".png",
|
|
@@ -4314,16 +4404,16 @@ var IMAGE_EXTENSIONS2 = /* @__PURE__ */ new Set([
|
|
|
4314
4404
|
".tif",
|
|
4315
4405
|
".webp"
|
|
4316
4406
|
]);
|
|
4317
|
-
var
|
|
4318
|
-
var
|
|
4407
|
+
var VIDEO_EXTENSIONS3 = /* @__PURE__ */ new Set([".mp4", ".mpeg", ".mpg", ".webm", ".mov", ".avi", ".mkv"]);
|
|
4408
|
+
var AUDIO_EXTENSIONS3 = /* @__PURE__ */ new Set([".mp3", ".wav", ".m4a", ".aac", ".ogg", ".flac"]);
|
|
4319
4409
|
function isImageFile(fileName) {
|
|
4320
|
-
return
|
|
4410
|
+
return IMAGE_EXTENSIONS3.has(getDottedExtension(fileName));
|
|
4321
4411
|
}
|
|
4322
4412
|
function isVideoFile(fileName) {
|
|
4323
|
-
return
|
|
4413
|
+
return VIDEO_EXTENSIONS3.has(getDottedExtension(fileName));
|
|
4324
4414
|
}
|
|
4325
4415
|
function isAudioFile(fileName) {
|
|
4326
|
-
return
|
|
4416
|
+
return AUDIO_EXTENSIONS3.has(getDottedExtension(fileName));
|
|
4327
4417
|
}
|
|
4328
4418
|
function isMediaFile(fileName) {
|
|
4329
4419
|
return isImageFile(fileName) || isVideoFile(fileName) || isAudioFile(fileName);
|
|
@@ -4671,16 +4761,16 @@ var STATUS_LABEL = {
|
|
|
4671
4761
|
indexing: "Indexing",
|
|
4672
4762
|
analysing: "Analysing"
|
|
4673
4763
|
};
|
|
4674
|
-
var
|
|
4675
|
-
var
|
|
4676
|
-
var
|
|
4677
|
-
var
|
|
4764
|
+
var IMAGE_EXTENSIONS4 = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "bmp", "tiff", "tif", "webp"]);
|
|
4765
|
+
var VIDEO_EXTENSIONS4 = /* @__PURE__ */ new Set(["mp4", "mpeg", "mpg", "webm", "mov", "avi", "mkv"]);
|
|
4766
|
+
var AUDIO_EXTENSIONS4 = /* @__PURE__ */ new Set(["mp3", "wav", "m4a", "aac", "ogg", "flac"]);
|
|
4767
|
+
var EMAIL_EXTENSIONS3 = /* @__PURE__ */ new Set(["eml", "msg"]);
|
|
4678
4768
|
function fileIcon(fileName, size) {
|
|
4679
4769
|
const ext = fileName?.split(".").pop()?.toLowerCase();
|
|
4680
|
-
if (ext &&
|
|
4681
|
-
if (ext &&
|
|
4682
|
-
if (ext &&
|
|
4683
|
-
if (ext &&
|
|
4770
|
+
if (ext && VIDEO_EXTENSIONS4.has(ext)) return /* @__PURE__ */ jsx(VidIcon, { size });
|
|
4771
|
+
if (ext && AUDIO_EXTENSIONS4.has(ext)) return /* @__PURE__ */ jsx(AudIcon, { size });
|
|
4772
|
+
if (ext && IMAGE_EXTENSIONS4.has(ext)) return /* @__PURE__ */ jsx(ImgIcon, { size });
|
|
4773
|
+
if (ext && EMAIL_EXTENSIONS3.has(ext)) return /* @__PURE__ */ jsx(EmlIcon, { size });
|
|
4684
4774
|
return /* @__PURE__ */ jsx(PdfIcon, { size });
|
|
4685
4775
|
}
|
|
4686
4776
|
function RenameField({
|
|
@@ -4866,7 +4956,57 @@ function DocumentCard({
|
|
|
4866
4956
|
}
|
|
4867
4957
|
);
|
|
4868
4958
|
}
|
|
4959
|
+
function isAgent(user) {
|
|
4960
|
+
return user.external_id.startsWith("agt-");
|
|
4961
|
+
}
|
|
4962
|
+
function getUserAvatarColor(userId) {
|
|
4963
|
+
let fifthChar = "0";
|
|
4964
|
+
if (userId && userId.length >= 5) {
|
|
4965
|
+
fifthChar = userId.charAt(4);
|
|
4966
|
+
}
|
|
4967
|
+
const colorMap = {
|
|
4968
|
+
"0": "bg-emerald-700",
|
|
4969
|
+
"1": "bg-blue-700",
|
|
4970
|
+
"2": "bg-violet-700",
|
|
4971
|
+
"3": "bg-rose-700",
|
|
4972
|
+
"4": "bg-amber-700",
|
|
4973
|
+
"5": "bg-lime-700",
|
|
4974
|
+
"6": "bg-purple-700",
|
|
4975
|
+
"7": "bg-cyan-700",
|
|
4976
|
+
"8": "bg-orange-700",
|
|
4977
|
+
"9": "bg-teal-700",
|
|
4978
|
+
a: "bg-red-700",
|
|
4979
|
+
b: "bg-indigo-700",
|
|
4980
|
+
c: "bg-pink-700",
|
|
4981
|
+
d: "bg-green-700",
|
|
4982
|
+
e: "bg-yellow-700",
|
|
4983
|
+
f: "bg-sky-700"
|
|
4984
|
+
};
|
|
4985
|
+
return colorMap[fifthChar] || "bg-emerald-700";
|
|
4986
|
+
}
|
|
4987
|
+
function getUserInitials(user) {
|
|
4988
|
+
const first = user.given_name[0] ?? "";
|
|
4989
|
+
const last = user.family_name?.[0] ?? "";
|
|
4990
|
+
return (first + last).toUpperCase();
|
|
4991
|
+
}
|
|
4992
|
+
function getUserDisplayName(user) {
|
|
4993
|
+
return user.family_name ? `${user.given_name} ${user.family_name}` : user.given_name;
|
|
4994
|
+
}
|
|
4995
|
+
function createUserAvatarIcon(user) {
|
|
4996
|
+
const initials = getUserInitials(user);
|
|
4997
|
+
const colorClass = getUserAvatarColor(user.external_id);
|
|
4998
|
+
return React__default.createElement(
|
|
4999
|
+
Avatar,
|
|
5000
|
+
{ className: "h-5 w-5 border border-white" },
|
|
5001
|
+
user.picture && React__default.createElement(AvatarImage, { src: user.picture, alt: initials }),
|
|
5002
|
+
React__default.createElement(
|
|
5003
|
+
AvatarFallback,
|
|
5004
|
+
{ className: `text-[9px] text-white font-semibold ${colorClass}` },
|
|
5005
|
+
initials
|
|
5006
|
+
)
|
|
5007
|
+
);
|
|
5008
|
+
}
|
|
4869
5009
|
|
|
4870
|
-
export { AUDIO_MIME_PREFERENCE, AgentBadge, AiMarkdown, ArbiBotHeadIcon, ArbiIcon, AudIcon, Avatar, AvatarFallback, AvatarImage, BASE_COLORS2 as BASE_COLORS, Badge, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, DEFAULT_SEGMENTER_CONFIG, DebouncedInput, DictateProvider, DocIcon, DocumentCard, DocumentEntity, ENTITY_MAPPINGS, EmlIcon, EntityIcon, EntityPill, FILE_TYPE_COLORS, HoverCard, HoverCardContent, HoverCardTrigger, HtmlIcon, INITIAL_SEGMENTER_STATE, IconToggle, ImgIcon, InlineMicButton, Input, Label2 as Label, MarkMenu, MicRecordingOverlay, MicWaveformIndicator, NEUTRAL_GRAY2 as NEUTRAL_GRAY, PLACEHOLDER_COLOR, PassageCard, PdfIcon, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, PresenceLabel, Progress, ProjectEntity, RadioGroup, RadioGroupItem, RagDot, RelevanceDot, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator2 as Separator, ShieldIcon, Slider, StatusPill, Switch, TAG_TYPE_ICONS, TAG_TYPE_LABELS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, TagEntity, Textarea, ThreadVisibilityIcon, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TxtIcon, UserEntity, UserMenu, VIDEO_MIME_PREFERENCE, VISIBILITY_ICONS, VerifiedBadge, VerifiedToggle, VidIcon, VisibilityIcon, VisibilityToggle, XlsIcon, agentAvatarColors, badgeVariants, cardVariants, classifyMediaError, configureEntityRegistry, configureRagLabels, configureStatusRegistry, createChunkedRecorder, flushSegmenter, formatElapsed, formatFriendlyDate, friendlyFileType, getDocIcon, getDocumentTitle, getEntityColor2 as getEntityColor, getEntityColorStyles, getEntityIcon, getEntityLabel, getStatusVariant, getTagTypeIcon, getTagTypeLabel, getWorkspaceColor, isAudioFile, isDownloadOnlyFile, isImageDocument, isImageFile, isMediaFile, isVideoFile, levelFromRms, pickRecorderMimeType, returnFocusToMark, stepSegmenter, tagKindNouns, tagKindTitle, toggleVariants, useAudioRecorder, useDictateContext, usesOriginalBytesForViewer };
|
|
4871
|
-
//# sourceMappingURL=chunk-
|
|
4872
|
-
//# sourceMappingURL=chunk-
|
|
5010
|
+
export { AUDIO_MIME_PREFERENCE, AgentBadge, AiMarkdown, ArbiBotHeadIcon, ArbiIcon, AudIcon, Avatar, AvatarFallback, AvatarImage, BASE_COLORS2 as BASE_COLORS, Badge, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, DEFAULT_SEGMENTER_CONFIG, DebouncedInput, DictateProvider, DocIcon, DocumentCard, DocumentEntity, ENTITY_MAPPINGS, EmlIcon, EntityIcon, EntityPill, FILE_TYPE_COLORS, HoverCard, HoverCardContent, HoverCardTrigger, HtmlIcon, INITIAL_SEGMENTER_STATE, IconToggle, ImgIcon, InlineMicButton, Input, Label2 as Label, MarkMenu, MicRecordingOverlay, MicWaveformIndicator, NEUTRAL_GRAY2 as NEUTRAL_GRAY, PLACEHOLDER_COLOR, PassageCard, PdfIcon, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, PresenceLabel, Progress, ProjectEntity, RadioGroup, RadioGroupItem, RagDot, RelevanceDot, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator2 as Separator, ShieldIcon, Slider, StatusPill, Switch, TAG_TYPE_ICONS, TAG_TYPE_LABELS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, TagEntity, Textarea, ThreadVisibilityIcon, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TxtIcon, UserEntity, UserMenu, VIDEO_MIME_PREFERENCE, VISIBILITY_ICONS, VerifiedBadge, VerifiedToggle, VidIcon, VisibilityIcon, VisibilityToggle, XlsIcon, agentAvatarColors, badgeVariants, cardVariants, classifyMediaError, configureEntityRegistry, configureRagLabels, configureStatusRegistry, createChunkedRecorder, createUserAvatarIcon, extensionFromMime, flushSegmenter, formatElapsed, formatFriendlyDate, friendlyFileType, getDocIcon, getDocumentTitle, getEntityColor2 as getEntityColor, getEntityColorStyles, getEntityIcon, getEntityLabel, getFileExtension, getFileTypeIcon, getStatusVariant, getTagTypeIcon, getTagTypeLabel, getUserAvatarColor, getUserDisplayName, getUserInitials, getWorkspaceColor, isAgent, isAudioFile, isDownloadOnlyFile, isImageDocument, isImageFile, isMediaFile, isVideoFile, levelFromRms, pickRecorderMimeType, returnFocusToMark, stepSegmenter, tagKindNouns, tagKindTitle, toggleVariants, useAudioRecorder, useDictateContext, usesOriginalBytesForViewer };
|
|
5011
|
+
//# sourceMappingURL=chunk-6FGO7SCY.js.map
|
|
5012
|
+
//# sourceMappingURL=chunk-6FGO7SCY.js.map
|