@arbidocs/react 0.4.154 → 0.4.156
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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkZWFMFOGP_cjs = require('./chunk-ZWFMFOGP.cjs');
|
|
3
4
|
var chunkR2MF7YCW_cjs = require('./chunk-R2MF7YCW.cjs');
|
|
4
5
|
var react = require('react');
|
|
5
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -98,13 +99,81 @@ function useDocumentTools() {
|
|
|
98
99
|
return env;
|
|
99
100
|
}
|
|
100
101
|
|
|
102
|
+
// src/document-tools/document-pdf.ts
|
|
103
|
+
var DocumentFetchError = class extends Error {
|
|
104
|
+
status;
|
|
105
|
+
constructor(message, status) {
|
|
106
|
+
super(message);
|
|
107
|
+
this.name = "DocumentFetchError";
|
|
108
|
+
this.status = status;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
async function fetchDocumentBytes(client, endpoint, documentRef, options, headers, what) {
|
|
112
|
+
const ref = chunkZWFMFOGP_cjs.parseVersionRef(documentRef);
|
|
113
|
+
const version = options.version ?? ref.version;
|
|
114
|
+
const { data, response } = await client.GET(endpoint, {
|
|
115
|
+
params: { path: { document_ext_id: ref.docId }, query: version ? { version } : {} },
|
|
116
|
+
headers,
|
|
117
|
+
parseAs: "blob",
|
|
118
|
+
signal: options.signal
|
|
119
|
+
});
|
|
120
|
+
if (!response.ok || !(data instanceof Blob)) {
|
|
121
|
+
throw new DocumentFetchError(
|
|
122
|
+
`${what} could not be loaded (${response.status})`,
|
|
123
|
+
response.status
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
return { blob: data, response };
|
|
127
|
+
}
|
|
128
|
+
function contentDispositionFileName(header) {
|
|
129
|
+
if (!header) return void 0;
|
|
130
|
+
const extended = /filename\*\s*=\s*(?:[\w-]+)?'[^']*'([^;]+)/i.exec(header);
|
|
131
|
+
if (extended) {
|
|
132
|
+
try {
|
|
133
|
+
return decodeURIComponent(extended[1].trim().replace(/^"|"$/g, "")) || void 0;
|
|
134
|
+
} catch {
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const plain = /filename\s*=\s*("((?:[^"\\]|\\.)*)"|[^;]+)/i.exec(header);
|
|
138
|
+
if (!plain) return void 0;
|
|
139
|
+
const name = plain[2] !== void 0 ? plain[2].replace(/\\(.)/g, "$1") : plain[1].trim();
|
|
140
|
+
return name || void 0;
|
|
141
|
+
}
|
|
142
|
+
async function fetchDocumentPdf(client, documentRef, options = {}) {
|
|
143
|
+
const { blob } = await fetchDocumentBytes(
|
|
144
|
+
client,
|
|
145
|
+
"/v1/document/{document_ext_id}/view",
|
|
146
|
+
documentRef,
|
|
147
|
+
options,
|
|
148
|
+
{ Accept: "application/pdf" },
|
|
149
|
+
"The PDF"
|
|
150
|
+
);
|
|
151
|
+
return blob;
|
|
152
|
+
}
|
|
153
|
+
async function fetchDocumentFile(client, documentRef, options = {}) {
|
|
154
|
+
const { blob, response } = await fetchDocumentBytes(
|
|
155
|
+
client,
|
|
156
|
+
"/v1/document/{document_ext_id}/download",
|
|
157
|
+
documentRef,
|
|
158
|
+
options,
|
|
159
|
+
{},
|
|
160
|
+
"The file"
|
|
161
|
+
);
|
|
162
|
+
const name = contentDispositionFileName(response.headers.get("Content-Disposition"));
|
|
163
|
+
return name ? new File([blob], name, { type: blob.type }) : blob;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
exports.DocumentFetchError = DocumentFetchError;
|
|
101
167
|
exports.DocumentToolsProvider = DocumentToolsProvider;
|
|
102
168
|
exports.certificateLink = certificateLink;
|
|
103
169
|
exports.clientUpload = clientUpload;
|
|
170
|
+
exports.contentDispositionFileName = contentDispositionFileName;
|
|
104
171
|
exports.defaultCertificateUrl = defaultCertificateUrl;
|
|
105
172
|
exports.downloadBlob = downloadBlob;
|
|
173
|
+
exports.fetchDocumentFile = fetchDocumentFile;
|
|
174
|
+
exports.fetchDocumentPdf = fetchDocumentPdf;
|
|
106
175
|
exports.uploadQueryString = uploadQueryString;
|
|
107
176
|
exports.useDocumentTools = useDocumentTools;
|
|
108
177
|
exports.useOptionalDocumentTools = useOptionalDocumentTools;
|
|
109
|
-
//# sourceMappingURL=chunk-
|
|
110
|
-
//# sourceMappingURL=chunk-
|
|
178
|
+
//# sourceMappingURL=chunk-QKNJ6FRD.cjs.map
|
|
179
|
+
//# sourceMappingURL=chunk-QKNJ6FRD.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/document-tools/environment.tsx","../src/document-tools/document-pdf.ts"],"names":["createContext","useDeploymentDomain","useMemo","jsx","useContext","parseVersionRef"],"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,CAAS,aAAA,CAAc,GAAG,CAAA;AACpC,EAAA,CAAA,CAAE,IAAA,GAAO,GAAA;AACT,EAAA,CAAA,CAAE,QAAA,GAAW,QAAA;AACb,EAAA,QAAA,CAAS,IAAA,CAAK,YAAY,CAAC,CAAA;AAC3B,EAAA,CAAA,CAAE,KAAA,EAAM;AACR,EAAA,CAAA,CAAE,MAAA,EAAO;AACT,EAAA,UAAA,CAAW,MAAM,GAAA,CAAI,eAAA,CAAgB,GAAG,GAAG,GAAM,CAAA;AACnD;AAGO,SAAS,aAAa,MAA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ACzE,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF;AACA,EAAA,MAAM,KAAA,GAAQ,6CAAA,CAA8C,IAAA,CAAK,MAAM,CAAA;AACvE,EAAA,IAAI,CAAC,OAAO,OAAO,MAAA;AACnB,EAAA,MAAM,IAAA,GAAO,KAAA,CAAM,CAAC,CAAA,KAAM,SAAY,KAAA,CAAM,CAAC,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-QKNJ6FRD.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, 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,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var chunkOC7F5SNA_cjs = require('./chunk-OC7F5SNA.cjs');
|
|
4
3
|
var chunkWYZJLZ67_cjs = require('./chunk-WYZJLZ67.cjs');
|
|
4
|
+
var chunkOC7F5SNA_cjs = require('./chunk-OC7F5SNA.cjs');
|
|
5
5
|
var chunkHJDR5HEO_cjs = require('./chunk-HJDR5HEO.cjs');
|
|
6
6
|
var chunkS6A6FSG7_cjs = require('./chunk-S6A6FSG7.cjs');
|
|
7
7
|
var React = require('react');
|
|
@@ -3282,6 +3282,96 @@ var EmlIcon = ({ size = 16, className = "" }) => {
|
|
|
3282
3282
|
}
|
|
3283
3283
|
);
|
|
3284
3284
|
};
|
|
3285
|
+
var TextIcon = lucideReact.FileText;
|
|
3286
|
+
var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "bmp", "tiff", "tif", "webp", "svg"]);
|
|
3287
|
+
var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set(["mp4", "mpeg", "mpg", "webm", "mov", "avi", "mkv"]);
|
|
3288
|
+
var AUDIO_EXTENSIONS = /* @__PURE__ */ new Set(["mp3", "wav", "m4a", "aac", "ogg", "flac"]);
|
|
3289
|
+
var DOCX_EXTENSIONS = /* @__PURE__ */ new Set(["doc", "docx", "odt", "rtf"]);
|
|
3290
|
+
var XLSX_EXTENSIONS = /* @__PURE__ */ new Set(["xls", "xlsx", "csv", "ods"]);
|
|
3291
|
+
var EMAIL_EXTENSIONS = /* @__PURE__ */ new Set(["eml", "msg"]);
|
|
3292
|
+
var HTML_EXTENSIONS = /* @__PURE__ */ new Set(["html", "htm", "mhtml"]);
|
|
3293
|
+
var PDF_EXTENSIONS = /* @__PURE__ */ new Set(["pdf"]);
|
|
3294
|
+
var TEXT_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
3295
|
+
"txt",
|
|
3296
|
+
"text",
|
|
3297
|
+
"md",
|
|
3298
|
+
"markdown",
|
|
3299
|
+
"log",
|
|
3300
|
+
"json",
|
|
3301
|
+
"xml",
|
|
3302
|
+
"yaml",
|
|
3303
|
+
"yml"
|
|
3304
|
+
]);
|
|
3305
|
+
function getFileExtension(fileName) {
|
|
3306
|
+
if (!fileName) return "";
|
|
3307
|
+
const dot = fileName.lastIndexOf(".");
|
|
3308
|
+
if (dot <= 0 || dot === fileName.length - 1) return "";
|
|
3309
|
+
return fileName.slice(dot + 1).toLowerCase();
|
|
3310
|
+
}
|
|
3311
|
+
var MIME_TO_EXTENSION = {
|
|
3312
|
+
"application/pdf": "pdf",
|
|
3313
|
+
"text/plain": "txt",
|
|
3314
|
+
"text/markdown": "md",
|
|
3315
|
+
"text/html": "html",
|
|
3316
|
+
"text/csv": "csv",
|
|
3317
|
+
"application/json": "json",
|
|
3318
|
+
"application/xml": "xml",
|
|
3319
|
+
"application/msword": "doc",
|
|
3320
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
|
|
3321
|
+
"application/rtf": "rtf",
|
|
3322
|
+
"application/vnd.oasis.opendocument.text": "odt",
|
|
3323
|
+
"application/vnd.ms-excel": "xls",
|
|
3324
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
|
|
3325
|
+
"application/vnd.oasis.opendocument.spreadsheet": "ods",
|
|
3326
|
+
"image/png": "png",
|
|
3327
|
+
"image/jpeg": "jpg",
|
|
3328
|
+
"image/gif": "gif",
|
|
3329
|
+
"image/webp": "webp",
|
|
3330
|
+
"image/svg+xml": "svg",
|
|
3331
|
+
"image/tiff": "tiff",
|
|
3332
|
+
"image/bmp": "bmp",
|
|
3333
|
+
"video/mp4": "mp4",
|
|
3334
|
+
"video/webm": "webm",
|
|
3335
|
+
"video/quicktime": "mov",
|
|
3336
|
+
"audio/mpeg": "mp3",
|
|
3337
|
+
"audio/wav": "wav",
|
|
3338
|
+
"audio/ogg": "ogg",
|
|
3339
|
+
"message/rfc822": "eml"
|
|
3340
|
+
};
|
|
3341
|
+
function extensionFromMime(mime) {
|
|
3342
|
+
if (!mime) return "";
|
|
3343
|
+
return MIME_TO_EXTENSION[mime.toLowerCase()] ?? "";
|
|
3344
|
+
}
|
|
3345
|
+
function iconFromExtension(ext) {
|
|
3346
|
+
if (VIDEO_EXTENSIONS.has(ext)) return VidIcon;
|
|
3347
|
+
if (AUDIO_EXTENSIONS.has(ext)) return AudIcon;
|
|
3348
|
+
if (IMAGE_EXTENSIONS.has(ext)) return ImgIcon;
|
|
3349
|
+
if (DOCX_EXTENSIONS.has(ext)) return DocIcon;
|
|
3350
|
+
if (XLSX_EXTENSIONS.has(ext)) return XlsIcon;
|
|
3351
|
+
if (EMAIL_EXTENSIONS.has(ext)) return EmlIcon;
|
|
3352
|
+
if (HTML_EXTENSIONS.has(ext)) return HtmlIcon;
|
|
3353
|
+
if (PDF_EXTENSIONS.has(ext)) return PdfIcon;
|
|
3354
|
+
if (TEXT_EXTENSIONS.has(ext)) return TextIcon;
|
|
3355
|
+
return null;
|
|
3356
|
+
}
|
|
3357
|
+
function iconFromMime(mime) {
|
|
3358
|
+
const m = mime.toLowerCase();
|
|
3359
|
+
if (m.startsWith("image/")) return ImgIcon;
|
|
3360
|
+
if (m.startsWith("video/")) return VidIcon;
|
|
3361
|
+
if (m.startsWith("audio/")) return AudIcon;
|
|
3362
|
+
if (m === "application/pdf") return PdfIcon;
|
|
3363
|
+
if (m === "text/html") return HtmlIcon;
|
|
3364
|
+
if (m === "message/rfc822" || m.includes("outlook")) return EmlIcon;
|
|
3365
|
+
if (m.includes("word") || m === "application/rtf" || m.includes("opendocument.text"))
|
|
3366
|
+
return DocIcon;
|
|
3367
|
+
if (m.includes("sheet") || m.includes("excel") || m === "text/csv" || m.includes("opendocument.spreadsheet"))
|
|
3368
|
+
return XlsIcon;
|
|
3369
|
+
if (m.startsWith("text/") || m === "application/json" || m === "application/xml") return TextIcon;
|
|
3370
|
+
return null;
|
|
3371
|
+
}
|
|
3372
|
+
function getFileTypeIcon(fileName, opts) {
|
|
3373
|
+
return iconFromExtension(getFileExtension(fileName)) ?? (opts?.mime ? iconFromMime(opts.mime) : null) ?? (opts?.defaultToPdf ? PdfIcon : TextIcon);
|
|
3374
|
+
}
|
|
3285
3375
|
var ArbiIcon = ({
|
|
3286
3376
|
size = 20,
|
|
3287
3377
|
className = "",
|
|
@@ -3596,14 +3686,14 @@ var MAX_LABEL_CHARS = 30;
|
|
|
3596
3686
|
function clampLabel(text) {
|
|
3597
3687
|
return text.length > MAX_LABEL_CHARS ? `${text.slice(0, MAX_LABEL_CHARS).trimEnd()}\u2026` : text;
|
|
3598
3688
|
}
|
|
3599
|
-
var
|
|
3600
|
-
var
|
|
3601
|
-
var
|
|
3602
|
-
var
|
|
3603
|
-
var
|
|
3604
|
-
var
|
|
3605
|
-
var
|
|
3606
|
-
var
|
|
3689
|
+
var IMAGE_EXTENSIONS2 = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "bmp", "tiff", "tif", "webp"]);
|
|
3690
|
+
var VIDEO_EXTENSIONS2 = /* @__PURE__ */ new Set(["mp4", "mpeg", "mpg", "webm", "mov", "avi", "mkv"]);
|
|
3691
|
+
var AUDIO_EXTENSIONS2 = /* @__PURE__ */ new Set(["mp3", "wav", "m4a", "aac", "ogg", "flac"]);
|
|
3692
|
+
var EMAIL_EXTENSIONS2 = /* @__PURE__ */ new Set(["eml", "msg"]);
|
|
3693
|
+
var DOCX_EXTENSIONS2 = /* @__PURE__ */ new Set(["doc", "docx", "odt", "rtf"]);
|
|
3694
|
+
var XLSX_EXTENSIONS2 = /* @__PURE__ */ new Set(["xls", "xlsx", "csv", "ods"]);
|
|
3695
|
+
var HTML_EXTENSIONS2 = /* @__PURE__ */ new Set(["html", "htm", "mhtml"]);
|
|
3696
|
+
var TEXT_EXTENSIONS2 = /* @__PURE__ */ new Set([
|
|
3607
3697
|
"txt",
|
|
3608
3698
|
"text",
|
|
3609
3699
|
"md",
|
|
@@ -3616,14 +3706,14 @@ var TEXT_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
3616
3706
|
]);
|
|
3617
3707
|
function getDocIcon(fileName, iconSize = 14) {
|
|
3618
3708
|
const ext = fileName?.split(".").pop()?.toLowerCase();
|
|
3619
|
-
if (ext &&
|
|
3620
|
-
if (ext &&
|
|
3621
|
-
if (ext &&
|
|
3622
|
-
if (ext &&
|
|
3623
|
-
if (ext &&
|
|
3624
|
-
if (ext &&
|
|
3625
|
-
if (ext &&
|
|
3626
|
-
if (ext &&
|
|
3709
|
+
if (ext && VIDEO_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsxRuntime.jsx(VidIcon, { size: iconSize, className: "flex-shrink-0" });
|
|
3710
|
+
if (ext && AUDIO_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsxRuntime.jsx(AudIcon, { size: iconSize, className: "flex-shrink-0" });
|
|
3711
|
+
if (ext && IMAGE_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsxRuntime.jsx(ImgIcon, { size: iconSize, className: "flex-shrink-0" });
|
|
3712
|
+
if (ext && EMAIL_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsxRuntime.jsx(EmlIcon, { size: iconSize, className: "flex-shrink-0" });
|
|
3713
|
+
if (ext && DOCX_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsxRuntime.jsx(DocIcon, { size: iconSize, className: "flex-shrink-0" });
|
|
3714
|
+
if (ext && XLSX_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsxRuntime.jsx(XlsIcon, { size: iconSize, className: "flex-shrink-0" });
|
|
3715
|
+
if (ext && HTML_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsxRuntime.jsx(HtmlIcon, { size: iconSize, className: "flex-shrink-0" });
|
|
3716
|
+
if (ext && TEXT_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsxRuntime.jsx(TxtIcon, { size: iconSize, className: "flex-shrink-0" });
|
|
3627
3717
|
return /* @__PURE__ */ jsxRuntime.jsx(PdfIcon, { size: iconSize, className: "flex-shrink-0" });
|
|
3628
3718
|
}
|
|
3629
3719
|
function DocumentEntity({
|
|
@@ -3940,7 +4030,7 @@ var UserEntity = React.memo(function UserEntity2({
|
|
|
3940
4030
|
picture,
|
|
3941
4031
|
avatarImageClassName,
|
|
3942
4032
|
colorClass = "",
|
|
3943
|
-
isAgent = false,
|
|
4033
|
+
isAgent: isAgent2 = false,
|
|
3944
4034
|
isVerified = false,
|
|
3945
4035
|
agentStyle,
|
|
3946
4036
|
avatarStyle,
|
|
@@ -3960,16 +4050,16 @@ var UserEntity = React.memo(function UserEntity2({
|
|
|
3960
4050
|
}
|
|
3961
4051
|
);
|
|
3962
4052
|
}
|
|
3963
|
-
const agentBadge =
|
|
3964
|
-
const canMessage = interactive && !isMe && !
|
|
3965
|
-
const showUnread = hasUnreadMessages && !isMe && !
|
|
4053
|
+
const agentBadge = isAgent2 ? /* @__PURE__ */ jsxRuntime.jsx(ArbiBotHeadIcon, { className: "w-3.5 h-3.5 text-muted-foreground" }) : void 0;
|
|
4054
|
+
const canMessage = interactive && !isMe && !isAgent2;
|
|
4055
|
+
const showUnread = hasUnreadMessages && !isMe && !isAgent2;
|
|
3966
4056
|
const surfaceStyle = avatarStyle ?? agentStyle;
|
|
3967
4057
|
const avatarCore = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3968
4058
|
Avatar,
|
|
3969
4059
|
{
|
|
3970
4060
|
className: chunkS6A6FSG7_cjs.cn(
|
|
3971
4061
|
sizeClasses[size],
|
|
3972
|
-
|
|
4062
|
+
isAgent2 ? "rounded-full border-2 border-dashed" : "border border-white"
|
|
3973
4063
|
),
|
|
3974
4064
|
style: surfaceStyle,
|
|
3975
4065
|
"data-testid": "user-entity",
|
|
@@ -3981,7 +4071,7 @@ var UserEntity = React.memo(function UserEntity2({
|
|
|
3981
4071
|
className: chunkS6A6FSG7_cjs.cn(
|
|
3982
4072
|
textSizeClasses[size],
|
|
3983
4073
|
"font-semibold leading-none",
|
|
3984
|
-
|
|
4074
|
+
isAgent2 ? "rounded-full bg-transparent" : `text-white ${colorClass}`
|
|
3985
4075
|
),
|
|
3986
4076
|
style: surfaceStyle,
|
|
3987
4077
|
children: initials
|
|
@@ -4041,7 +4131,7 @@ var UserEntity = React.memo(function UserEntity2({
|
|
|
4041
4131
|
const row = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4042
4132
|
pillAvatar,
|
|
4043
4133
|
displayName && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 max-w-[320px] truncate text-sm leading-tight", children: displayName }),
|
|
4044
|
-
isVerified && !
|
|
4134
|
+
isVerified && !isAgent2 && /* @__PURE__ */ jsxRuntime.jsx(VerifiedBadge, {}),
|
|
4045
4135
|
agentBadge
|
|
4046
4136
|
] });
|
|
4047
4137
|
const rowClass = "group/pill inline-flex min-w-0 items-center gap-2";
|
|
@@ -4339,7 +4429,7 @@ var DOWNLOAD_ONLY_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
4339
4429
|
".ai",
|
|
4340
4430
|
".sketch"
|
|
4341
4431
|
]);
|
|
4342
|
-
var
|
|
4432
|
+
var IMAGE_EXTENSIONS3 = /* @__PURE__ */ new Set([
|
|
4343
4433
|
".jpg",
|
|
4344
4434
|
".jpeg",
|
|
4345
4435
|
".png",
|
|
@@ -4349,16 +4439,16 @@ var IMAGE_EXTENSIONS2 = /* @__PURE__ */ new Set([
|
|
|
4349
4439
|
".tif",
|
|
4350
4440
|
".webp"
|
|
4351
4441
|
]);
|
|
4352
|
-
var
|
|
4353
|
-
var
|
|
4442
|
+
var VIDEO_EXTENSIONS3 = /* @__PURE__ */ new Set([".mp4", ".mpeg", ".mpg", ".webm", ".mov", ".avi", ".mkv"]);
|
|
4443
|
+
var AUDIO_EXTENSIONS3 = /* @__PURE__ */ new Set([".mp3", ".wav", ".m4a", ".aac", ".ogg", ".flac"]);
|
|
4354
4444
|
function isImageFile(fileName) {
|
|
4355
|
-
return
|
|
4445
|
+
return IMAGE_EXTENSIONS3.has(getDottedExtension(fileName));
|
|
4356
4446
|
}
|
|
4357
4447
|
function isVideoFile(fileName) {
|
|
4358
|
-
return
|
|
4448
|
+
return VIDEO_EXTENSIONS3.has(getDottedExtension(fileName));
|
|
4359
4449
|
}
|
|
4360
4450
|
function isAudioFile(fileName) {
|
|
4361
|
-
return
|
|
4451
|
+
return AUDIO_EXTENSIONS3.has(getDottedExtension(fileName));
|
|
4362
4452
|
}
|
|
4363
4453
|
function isMediaFile(fileName) {
|
|
4364
4454
|
return isImageFile(fileName) || isVideoFile(fileName) || isAudioFile(fileName);
|
|
@@ -4706,16 +4796,16 @@ var STATUS_LABEL = {
|
|
|
4706
4796
|
indexing: "Indexing",
|
|
4707
4797
|
analysing: "Analysing"
|
|
4708
4798
|
};
|
|
4709
|
-
var
|
|
4710
|
-
var
|
|
4711
|
-
var
|
|
4712
|
-
var
|
|
4799
|
+
var IMAGE_EXTENSIONS4 = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "bmp", "tiff", "tif", "webp"]);
|
|
4800
|
+
var VIDEO_EXTENSIONS4 = /* @__PURE__ */ new Set(["mp4", "mpeg", "mpg", "webm", "mov", "avi", "mkv"]);
|
|
4801
|
+
var AUDIO_EXTENSIONS4 = /* @__PURE__ */ new Set(["mp3", "wav", "m4a", "aac", "ogg", "flac"]);
|
|
4802
|
+
var EMAIL_EXTENSIONS3 = /* @__PURE__ */ new Set(["eml", "msg"]);
|
|
4713
4803
|
function fileIcon(fileName, size) {
|
|
4714
4804
|
const ext = fileName?.split(".").pop()?.toLowerCase();
|
|
4715
|
-
if (ext &&
|
|
4716
|
-
if (ext &&
|
|
4717
|
-
if (ext &&
|
|
4718
|
-
if (ext &&
|
|
4805
|
+
if (ext && VIDEO_EXTENSIONS4.has(ext)) return /* @__PURE__ */ jsxRuntime.jsx(VidIcon, { size });
|
|
4806
|
+
if (ext && AUDIO_EXTENSIONS4.has(ext)) return /* @__PURE__ */ jsxRuntime.jsx(AudIcon, { size });
|
|
4807
|
+
if (ext && IMAGE_EXTENSIONS4.has(ext)) return /* @__PURE__ */ jsxRuntime.jsx(ImgIcon, { size });
|
|
4808
|
+
if (ext && EMAIL_EXTENSIONS3.has(ext)) return /* @__PURE__ */ jsxRuntime.jsx(EmlIcon, { size });
|
|
4719
4809
|
return /* @__PURE__ */ jsxRuntime.jsx(PdfIcon, { size });
|
|
4720
4810
|
}
|
|
4721
4811
|
function RenameField({
|
|
@@ -4901,6 +4991,56 @@ function DocumentCard({
|
|
|
4901
4991
|
}
|
|
4902
4992
|
);
|
|
4903
4993
|
}
|
|
4994
|
+
function isAgent(user) {
|
|
4995
|
+
return user.external_id.startsWith("agt-");
|
|
4996
|
+
}
|
|
4997
|
+
function getUserAvatarColor(userId) {
|
|
4998
|
+
let fifthChar = "0";
|
|
4999
|
+
if (userId && userId.length >= 5) {
|
|
5000
|
+
fifthChar = userId.charAt(4);
|
|
5001
|
+
}
|
|
5002
|
+
const colorMap = {
|
|
5003
|
+
"0": "bg-emerald-700",
|
|
5004
|
+
"1": "bg-blue-700",
|
|
5005
|
+
"2": "bg-violet-700",
|
|
5006
|
+
"3": "bg-rose-700",
|
|
5007
|
+
"4": "bg-amber-700",
|
|
5008
|
+
"5": "bg-lime-700",
|
|
5009
|
+
"6": "bg-purple-700",
|
|
5010
|
+
"7": "bg-cyan-700",
|
|
5011
|
+
"8": "bg-orange-700",
|
|
5012
|
+
"9": "bg-teal-700",
|
|
5013
|
+
a: "bg-red-700",
|
|
5014
|
+
b: "bg-indigo-700",
|
|
5015
|
+
c: "bg-pink-700",
|
|
5016
|
+
d: "bg-green-700",
|
|
5017
|
+
e: "bg-yellow-700",
|
|
5018
|
+
f: "bg-sky-700"
|
|
5019
|
+
};
|
|
5020
|
+
return colorMap[fifthChar] || "bg-emerald-700";
|
|
5021
|
+
}
|
|
5022
|
+
function getUserInitials(user) {
|
|
5023
|
+
const first = user.given_name[0] ?? "";
|
|
5024
|
+
const last = user.family_name?.[0] ?? "";
|
|
5025
|
+
return (first + last).toUpperCase();
|
|
5026
|
+
}
|
|
5027
|
+
function getUserDisplayName(user) {
|
|
5028
|
+
return user.family_name ? `${user.given_name} ${user.family_name}` : user.given_name;
|
|
5029
|
+
}
|
|
5030
|
+
function createUserAvatarIcon(user) {
|
|
5031
|
+
const initials = getUserInitials(user);
|
|
5032
|
+
const colorClass = getUserAvatarColor(user.external_id);
|
|
5033
|
+
return React__namespace.default.createElement(
|
|
5034
|
+
Avatar,
|
|
5035
|
+
{ className: "h-5 w-5 border border-white" },
|
|
5036
|
+
user.picture && React__namespace.default.createElement(AvatarImage, { src: user.picture, alt: initials }),
|
|
5037
|
+
React__namespace.default.createElement(
|
|
5038
|
+
AvatarFallback,
|
|
5039
|
+
{ className: `text-[9px] text-white font-semibold ${colorClass}` },
|
|
5040
|
+
initials
|
|
5041
|
+
)
|
|
5042
|
+
);
|
|
5043
|
+
}
|
|
4904
5044
|
|
|
4905
5045
|
exports.AUDIO_MIME_PREFERENCE = AUDIO_MIME_PREFERENCE;
|
|
4906
5046
|
exports.AgentBadge = AgentBadge;
|
|
@@ -5030,6 +5170,8 @@ exports.configureEntityRegistry = configureEntityRegistry;
|
|
|
5030
5170
|
exports.configureRagLabels = configureRagLabels;
|
|
5031
5171
|
exports.configureStatusRegistry = configureStatusRegistry;
|
|
5032
5172
|
exports.createChunkedRecorder = createChunkedRecorder;
|
|
5173
|
+
exports.createUserAvatarIcon = createUserAvatarIcon;
|
|
5174
|
+
exports.extensionFromMime = extensionFromMime;
|
|
5033
5175
|
exports.flushSegmenter = flushSegmenter;
|
|
5034
5176
|
exports.formatElapsed = formatElapsed;
|
|
5035
5177
|
exports.formatFriendlyDate = formatFriendlyDate;
|
|
@@ -5040,10 +5182,16 @@ exports.getEntityColor = getEntityColor2;
|
|
|
5040
5182
|
exports.getEntityColorStyles = getEntityColorStyles;
|
|
5041
5183
|
exports.getEntityIcon = getEntityIcon;
|
|
5042
5184
|
exports.getEntityLabel = getEntityLabel;
|
|
5185
|
+
exports.getFileExtension = getFileExtension;
|
|
5186
|
+
exports.getFileTypeIcon = getFileTypeIcon;
|
|
5043
5187
|
exports.getStatusVariant = getStatusVariant;
|
|
5044
5188
|
exports.getTagTypeIcon = getTagTypeIcon;
|
|
5045
5189
|
exports.getTagTypeLabel = getTagTypeLabel;
|
|
5190
|
+
exports.getUserAvatarColor = getUserAvatarColor;
|
|
5191
|
+
exports.getUserDisplayName = getUserDisplayName;
|
|
5192
|
+
exports.getUserInitials = getUserInitials;
|
|
5046
5193
|
exports.getWorkspaceColor = getWorkspaceColor;
|
|
5194
|
+
exports.isAgent = isAgent;
|
|
5047
5195
|
exports.isAudioFile = isAudioFile;
|
|
5048
5196
|
exports.isDownloadOnlyFile = isDownloadOnlyFile;
|
|
5049
5197
|
exports.isImageDocument = isImageDocument;
|
|
@@ -5060,5 +5208,5 @@ exports.toggleVariants = toggleVariants;
|
|
|
5060
5208
|
exports.useAudioRecorder = useAudioRecorder;
|
|
5061
5209
|
exports.useDictateContext = useDictateContext;
|
|
5062
5210
|
exports.usesOriginalBytesForViewer = usesOriginalBytesForViewer;
|
|
5063
|
-
//# sourceMappingURL=chunk-
|
|
5064
|
-
//# sourceMappingURL=chunk-
|
|
5211
|
+
//# sourceMappingURL=chunk-VKWGRGY6.cjs.map
|
|
5212
|
+
//# sourceMappingURL=chunk-VKWGRGY6.cjs.map
|