@arbidocs/blocks 0.5.137 → 0.5.139

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.
Files changed (50) hide show
  1. package/dist/ConnectedNativeDocxComparison-X2O5OIYZ.cjs +1 -1
  2. package/dist/ConnectedStreamedWordArtifact-BI6WFIAW.cjs +1 -1
  3. package/dist/{DocumentReviewCard-SOWXEXMC.cjs → DocumentReviewCard-NZCGQ7SH.cjs} +12 -12
  4. package/dist/{DocumentReviewCard-SOWXEXMC.cjs.map → DocumentReviewCard-NZCGQ7SH.cjs.map} +1 -1
  5. package/dist/{FilesViewerDialog-A5OAV2YP.cjs → FilesViewerDialog-NKDVTI6H.cjs} +9 -9
  6. package/dist/{FilesViewerDialog-A5OAV2YP.cjs.map → FilesViewerDialog-NKDVTI6H.cjs.map} +1 -1
  7. package/dist/agents/index.cjs +176 -176
  8. package/dist/calls/index.cjs +22 -22
  9. package/dist/{chunk-ALR6NCVR.cjs → chunk-7YIN4Q63.cjs} +4 -4
  10. package/dist/{chunk-ALR6NCVR.cjs.map → chunk-7YIN4Q63.cjs.map} +1 -1
  11. package/dist/{chunk-RUKEMF6Q.cjs → chunk-BT2QTDZ4.cjs} +35 -35
  12. package/dist/{chunk-RUKEMF6Q.cjs.map → chunk-BT2QTDZ4.cjs.map} +1 -1
  13. package/dist/{chunk-PTLILY4Q.cjs → chunk-CKKODA5B.cjs} +3 -3
  14. package/dist/{chunk-PTLILY4Q.cjs.map → chunk-CKKODA5B.cjs.map} +1 -1
  15. package/dist/{chunk-HVVD4YSE.cjs → chunk-F5HT73TR.cjs} +24 -24
  16. package/dist/{chunk-HVVD4YSE.cjs.map → chunk-F5HT73TR.cjs.map} +1 -1
  17. package/dist/{chunk-M5EQGQRC.cjs → chunk-FYNNNQ6H.cjs} +4 -4
  18. package/dist/{chunk-M5EQGQRC.cjs.map → chunk-FYNNNQ6H.cjs.map} +1 -1
  19. package/dist/{chunk-TCVDV5RF.cjs → chunk-HG72AVXX.cjs} +3 -3
  20. package/dist/{chunk-TCVDV5RF.cjs.map → chunk-HG72AVXX.cjs.map} +1 -1
  21. package/dist/{chunk-ZHGIAVAC.cjs → chunk-JXZM5ODS.cjs} +28 -28
  22. package/dist/{chunk-ZHGIAVAC.cjs.map → chunk-JXZM5ODS.cjs.map} +1 -1
  23. package/dist/{chunk-K424CT35.cjs → chunk-LYDPVFNS.cjs} +4 -4
  24. package/dist/{chunk-K424CT35.cjs.map → chunk-LYDPVFNS.cjs.map} +1 -1
  25. package/dist/{chunk-NB6XGPEB.cjs → chunk-N7B5OAI5.cjs} +7 -7
  26. package/dist/chunk-N7B5OAI5.cjs.map +1 -0
  27. package/dist/{chunk-RIONTVEH.cjs → chunk-SHGUTM42.cjs} +5 -5
  28. package/dist/{chunk-RIONTVEH.cjs.map → chunk-SHGUTM42.cjs.map} +1 -1
  29. package/dist/{chunk-7QZ7F3YL.cjs → chunk-SS7IYHLK.cjs} +8 -8
  30. package/dist/{chunk-7QZ7F3YL.cjs.map → chunk-SS7IYHLK.cjs.map} +1 -1
  31. package/dist/{chunk-HQ7M75LU.cjs → chunk-TKWYFNWW.cjs} +51 -51
  32. package/dist/{chunk-HQ7M75LU.cjs.map → chunk-TKWYFNWW.cjs.map} +1 -1
  33. package/dist/{chunk-GRRD7SEY.cjs → chunk-YEGOCUBR.cjs} +4 -4
  34. package/dist/{chunk-GRRD7SEY.cjs.map → chunk-YEGOCUBR.cjs.map} +1 -1
  35. package/dist/connect/docx.cjs +1 -1
  36. package/dist/connect/index.cjs +549 -549
  37. package/dist/connect/index.cjs.map +1 -1
  38. package/dist/connect/viewer.cjs +7 -7
  39. package/dist/connection/files/useBatchCompleteToasts.d.ts +4 -2
  40. package/dist/connection/files/useBatchCompleteToasts.js +1 -1
  41. package/dist/connection/files/useBatchCompleteToasts.js.map +2 -2
  42. package/dist/embed/index.cjs +13 -13
  43. package/dist/files/folders/folderPaths.js +5 -5
  44. package/dist/files/folders/folderPaths.js.map +2 -2
  45. package/dist/files/index.cjs +222 -222
  46. package/dist/index.cjs +645 -645
  47. package/dist/workflow-canvas/index.cjs +20 -20
  48. package/node_modules/@arbidocs/coedit/package.json +1 -1
  49. package/package.json +5 -5
  50. package/dist/chunk-NB6XGPEB.cjs.map +0 -1
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var chunkHQ7M75LU_cjs = require('../chunk-HQ7M75LU.cjs');
4
+ var chunkTKWYFNWW_cjs = require('../chunk-TKWYFNWW.cjs');
5
5
  require('../chunk-JITYC4OS.cjs');
6
6
  require('../chunk-WVZLAAIZ.cjs');
7
7
  require('../chunk-X7ALF4MP.cjs');
@@ -9,12 +9,12 @@ require('../chunk-4CIVQWAX.cjs');
9
9
  var chunk57LUHZLV_cjs = require('../chunk-57LUHZLV.cjs');
10
10
  require('../chunk-QWVUBTW3.cjs');
11
11
  require('../chunk-JVEDKKNO.cjs');
12
- require('../chunk-K424CT35.cjs');
12
+ require('../chunk-LYDPVFNS.cjs');
13
13
  require('../chunk-TIBTTITZ.cjs');
14
- require('../chunk-RUKEMF6Q.cjs');
14
+ require('../chunk-BT2QTDZ4.cjs');
15
15
  require('../chunk-PA7YEXL3.cjs');
16
16
  require('../chunk-HYUKPHCT.cjs');
17
- require('../chunk-NB6XGPEB.cjs');
17
+ require('../chunk-N7B5OAI5.cjs');
18
18
  require('../chunk-223D4727.cjs');
19
19
  require('../chunk-SNUBQMIS.cjs');
20
20
  require('../chunk-REP5GA2Z.cjs');
@@ -41,7 +41,6 @@ require('../chunk-WQMR3O2D.cjs');
41
41
  require('../chunk-NZNBJF3M.cjs');
42
42
  require('../chunk-NWNVWO6L.cjs');
43
43
  require('../chunk-SK6HQ46Q.cjs');
44
- require('../chunk-TG2GM7WJ.cjs');
45
44
  require('../chunk-DEXUL3T6.cjs');
46
45
  require('../chunk-AFQTQC7A.cjs');
47
46
  require('../chunk-XJEXFEWG.cjs');
@@ -49,6 +48,7 @@ require('../chunk-Z2XZ2D4N.cjs');
49
48
  require('../chunk-YZSQ7F5K.cjs');
50
49
  require('../chunk-MCXS6X37.cjs');
51
50
  require('../chunk-KQF7POTG.cjs');
51
+ require('../chunk-TG2GM7WJ.cjs');
52
52
  require('../chunk-L62EU3TQ.cjs');
53
53
  require('../chunk-75BNMCUX.cjs');
54
54
  require('../chunk-OEJQFPWO.cjs');
@@ -61,9 +61,9 @@ require('../chunk-3YEXZX4H.cjs');
61
61
  require('../chunk-4PA6VCCR.cjs');
62
62
  require('../chunk-K3WSXEEI.cjs');
63
63
  require('../chunk-AHDJXIUB.cjs');
64
- require('../chunk-S5OGPQSB.cjs');
65
64
  require('../chunk-RL2HI6NP.cjs');
66
65
  require('../chunk-6UZC4XVV.cjs');
66
+ require('../chunk-S5OGPQSB.cjs');
67
67
  require('../chunk-EQTZQD66.cjs');
68
68
  require('../chunk-JN5YMHGI.cjs');
69
69
  require('../chunk-UDSHVNU3.cjs');
@@ -94,7 +94,7 @@ require('../chunk-PLIF5CUV.cjs');
94
94
 
95
95
  Object.defineProperty(exports, "ConnectedDocumentViewer", {
96
96
  enumerable: true,
97
- get: function () { return chunkHQ7M75LU_cjs.ConnectedDocumentViewer; }
97
+ get: function () { return chunkTKWYFNWW_cjs.ConnectedDocumentViewer; }
98
98
  });
99
99
  Object.defineProperty(exports, "ConnectedDocumentToolsProvider", {
100
100
  enumerable: true,
@@ -6,8 +6,10 @@
6
6
  * field for the same documents, so documents are counted once), with "View results" while an AI
7
7
  * review is open;
8
8
  * - an extraction (`entity_extract`): "<entities> extracted from N documents", View → the tags;
9
- * - an upload made in this session: "N documents indexed successfully" (a background upload, such
10
- * as a mailbox sync, has no session and says nothing: the sync reports once).
9
+ * - an upload made in this session by a client that names no upload set: "N documents indexed
10
+ * successfully" (a background upload, such as a mailbox sync, has no session and says nothing:
11
+ * the sync reports once). A batch of an upload set says nothing: the set's one
12
+ * `upload_set_complete` notification follows when all of it is done.
11
13
  * Mount once, under the shared `ArbiWebSocketProvider`.
12
14
  */
13
15
  export declare function useBatchCompleteToasts(): void;
@@ -61,7 +61,7 @@ function useBatchCompleteToasts() {
61
61
  ...openTags && { action: { label: "View", onClick: openTags } }
62
62
  });
63
63
  } else if (message.batch_type === "upload") {
64
- if (!message.session_id) return;
64
+ if (!message.session_id || message.upload_set_id) return;
65
65
  const n = docIds.length;
66
66
  say(`${n} document${n !== 1 ? "s" : ""} indexed successfully`, "success");
67
67
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/connection/files/useBatchCompleteToasts.ts"],
4
- "sourcesContent": ["/**\n * The notice of a finished batch (the lists themselves follow by themselves: the shared provider\n * and `useAiReviewLiveUpdates`):\n * - AI fields (`doctag_generate`): one \"AI annotation run finished for N documents\" per workspace\n * for every batch finishing within half a second (a run over several fields sends one batch per\n * field for the same documents, so documents are counted once), with \"View results\" while an AI\n * review is open;\n * - an extraction (`entity_extract`): \"<entities> extracted from N documents\", View \u2192 the tags;\n * - an upload made in this session: \"N documents indexed successfully\" (a background upload, such\n * as a mailbox sync, has no session and says nothing: the sync reports once).\n * Mount once, under the shared `ArbiWebSocketProvider`.\n */\n\nimport { createElement, useEffect, useRef, type ReactElement } from 'react'\nimport { isMessageType, type WsBatchCompleteMessage } from '@arbidocs/client'\nimport { useArbiWebSocket, useWorkspaces } from '@arbidocs/react'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { ConnectedWorkspaceEntity } from '../entities/ConnectedWorkspaceEntity'\nimport { documentCount, entitiesPhrase } from '../../tags/page/tagsPageLabels'\nimport { useAiReviewStore } from './store'\n\n/** How long finished AI-field batches are gathered into one notice. */\nconst AI_FIELDS_NOTICE_WINDOW_MS = 500\n\ninterface PendingRun {\n docIds: Set<string>\n icon: ReactElement | undefined\n}\n\nexport function useBatchCompleteToasts(): void {\n const { notify, openTags } = useBlocksEnvironment()\n const { data: workspaces } = useWorkspaces()\n const workspacesRef = useRef(workspaces)\n workspacesRef.current = workspaces\n const pending = useRef(new Map<string, PendingRun>())\n const timer = useRef<ReturnType<typeof setTimeout> | null>(null)\n useEffect(\n () => () => {\n if (timer.current) clearTimeout(timer.current)\n },\n []\n )\n\n useArbiWebSocket((message) => {\n if (!isMessageType<WsBatchCompleteMessage>(message, 'batch_complete')) return\n const workspaceId = message.workspace_ext_id\n const docIds = message.doc_ext_ids ?? []\n const workspace = workspacesRef.current?.find((w) => w.external_id === workspaceId)\n const icon = workspace\n ? createElement(ConnectedWorkspaceEntity, { workspace, variant: 'icon', size: 20 })\n : undefined\n // Arrived from the server: what the bell is for, never ambient.\n const say = (text: string, kind: 'info' | 'success', options: Record<string, unknown> = {}) =>\n notify(text, kind, { workspaceId, icon, ...options, ambient: false })\n\n if (message.batch_type === 'doctag_generate') {\n const run = pending.current.get(workspaceId) ?? { docIds: new Set<string>(), icon }\n for (const id of docIds) run.docIds.add(id)\n pending.current.set(workspaceId, run)\n if (timer.current) return\n timer.current = setTimeout(() => {\n timer.current = null\n const runs = pending.current\n pending.current = new Map()\n const hasReview = !!useAiReviewStore.getState().run\n for (const [id, entry] of runs) {\n const n = entry.docIds.size\n // A finished batch is not a value for every field (a blank answer completes too).\n notify(\n `AI annotation run finished for ${n} document${n !== 1 ? 's' : ''}. Check the table for blank fields.`,\n 'info',\n {\n workspaceId: id,\n icon: entry.icon,\n ambient: false,\n ...(hasReview && {\n action: {\n label: 'View results',\n onClick: () => useAiReviewStore.getState().setOpen(true),\n },\n }),\n }\n )\n }\n }, AI_FIELDS_NOTICE_WINDOW_MS)\n } else if (message.batch_type === 'entity_extract') {\n say(`${entitiesPhrase()} extracted from ${documentCount(docIds.length)}`, 'success', {\n ...(openTags && { action: { label: 'View', onClick: openTags } }),\n })\n } else if (message.batch_type === 'upload') {\n if (!(message as { session_id?: string | null }).session_id) return\n const n = docIds.length\n say(`${n} document${n !== 1 ? 's' : ''} indexed successfully`, 'success')\n }\n })\n}\n"],
5
- "mappings": ";AAaA,SAAS,eAAe,WAAW,cAAiC;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AAO,QAAQ;AACrB,gBAAQ,UAAU,oBAAI,IAAI;AAC1B,cAAM,YAAY,CAAC,CAAC,iBAAiB,SAAS,EAAE;AAChD,mBAAW,CAAC,IAAI,KAAK,KAAK,MAAM;AAC9B,gBAAM,IAAI,MAAM,OAAO;AAEvB;AAAA,YACE,kCAAkC,CAAC,YAAY,MAAM,IAAI,MAAM,EAAE;AAAA,YACjE;AAAA,YACA;AAAA,cACE,aAAa;AAAA,cACb,MAAM,MAAM;AAAA,cACZ,SAAS;AAAA,cACT,GAAI,aAAa;AAAA,gBACf,QAAQ;AAAA,kBACN,OAAO;AAAA,kBACP,SAAS,MAAM,iBAAiB,SAAS,EAAE,QAAQ,IAAI;AAAA,gBACzD;AAAA,cACF;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF,GAAG,0BAA0B;AAAA,IAC/B,WAAW,QAAQ,eAAe,kBAAkB;AAClD,UAAI,GAAG,eAAe,CAAC,mBAAmB,cAAc,OAAO,MAAM,CAAC,IAAI,WAAW;AAAA,QACnF,GAAI,YAAY,EAAE,QAAQ,EAAE,OAAO,QAAQ,SAAS,SAAS,EAAE;AAAA,MACjE,CAAC;AAAA,IACH,WAAW,QAAQ,eAAe,UAAU;AAC1C,UAAI,CAAE,QAA2C,WAAY;AAC7D,YAAM,IAAI,OAAO;AACjB,UAAI,GAAG,CAAC,YAAY,MAAM,IAAI,MAAM,EAAE,yBAAyB,SAAS;AAAA,IAC1E;AAAA,EACF,CAAC;AACH;",
4
+ "sourcesContent": ["/**\n * The notice of a finished batch (the lists themselves follow by themselves: the shared provider\n * and `useAiReviewLiveUpdates`):\n * - AI fields (`doctag_generate`): one \"AI annotation run finished for N documents\" per workspace\n * for every batch finishing within half a second (a run over several fields sends one batch per\n * field for the same documents, so documents are counted once), with \"View results\" while an AI\n * review is open;\n * - an extraction (`entity_extract`): \"<entities> extracted from N documents\", View \u2192 the tags;\n * - an upload made in this session by a client that names no upload set: \"N documents indexed\n * successfully\" (a background upload, such as a mailbox sync, has no session and says nothing:\n * the sync reports once). A batch of an upload set says nothing: the set's one\n * `upload_set_complete` notification follows when all of it is done.\n * Mount once, under the shared `ArbiWebSocketProvider`.\n */\n\nimport { createElement, useEffect, useRef, type ReactElement } from 'react'\nimport { isMessageType, type WsBatchCompleteMessage } from '@arbidocs/client'\nimport { useArbiWebSocket, useWorkspaces } from '@arbidocs/react'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { ConnectedWorkspaceEntity } from '../entities/ConnectedWorkspaceEntity'\nimport { documentCount, entitiesPhrase } from '../../tags/page/tagsPageLabels'\nimport { useAiReviewStore } from './store'\n\n/** How long finished AI-field batches are gathered into one notice. */\nconst AI_FIELDS_NOTICE_WINDOW_MS = 500\n\ninterface PendingRun {\n docIds: Set<string>\n icon: ReactElement | undefined\n}\n\nexport function useBatchCompleteToasts(): void {\n const { notify, openTags } = useBlocksEnvironment()\n const { data: workspaces } = useWorkspaces()\n const workspacesRef = useRef(workspaces)\n workspacesRef.current = workspaces\n const pending = useRef(new Map<string, PendingRun>())\n const timer = useRef<ReturnType<typeof setTimeout> | null>(null)\n useEffect(\n () => () => {\n if (timer.current) clearTimeout(timer.current)\n },\n []\n )\n\n useArbiWebSocket((message) => {\n if (!isMessageType<WsBatchCompleteMessage>(message, 'batch_complete')) return\n const workspaceId = message.workspace_ext_id\n const docIds = message.doc_ext_ids ?? []\n const workspace = workspacesRef.current?.find((w) => w.external_id === workspaceId)\n const icon = workspace\n ? createElement(ConnectedWorkspaceEntity, { workspace, variant: 'icon', size: 20 })\n : undefined\n // Arrived from the server: what the bell is for, never ambient.\n const say = (text: string, kind: 'info' | 'success', options: Record<string, unknown> = {}) =>\n notify(text, kind, { workspaceId, icon, ...options, ambient: false })\n\n if (message.batch_type === 'doctag_generate') {\n const run = pending.current.get(workspaceId) ?? { docIds: new Set<string>(), icon }\n for (const id of docIds) run.docIds.add(id)\n pending.current.set(workspaceId, run)\n if (timer.current) return\n timer.current = setTimeout(() => {\n timer.current = null\n const runs = pending.current\n pending.current = new Map()\n const hasReview = !!useAiReviewStore.getState().run\n for (const [id, entry] of runs) {\n const n = entry.docIds.size\n // A finished batch is not a value for every field (a blank answer completes too).\n notify(\n `AI annotation run finished for ${n} document${n !== 1 ? 's' : ''}. Check the table for blank fields.`,\n 'info',\n {\n workspaceId: id,\n icon: entry.icon,\n ambient: false,\n ...(hasReview && {\n action: {\n label: 'View results',\n onClick: () => useAiReviewStore.getState().setOpen(true),\n },\n }),\n }\n )\n }\n }, AI_FIELDS_NOTICE_WINDOW_MS)\n } else if (message.batch_type === 'entity_extract') {\n say(`${entitiesPhrase()} extracted from ${documentCount(docIds.length)}`, 'success', {\n ...(openTags && { action: { label: 'View', onClick: openTags } }),\n })\n } else if (message.batch_type === 'upload') {\n if (!message.session_id || message.upload_set_id) return\n const n = docIds.length\n say(`${n} document${n !== 1 ? 's' : ''} indexed successfully`, 'success')\n }\n })\n}\n"],
5
+ "mappings": ";AAeA,SAAS,eAAe,WAAW,cAAiC;AACpE,SAAS,qBAAkD;AAC3D,SAAS,kBAAkB,qBAAqB;AAChD,SAAS,4BAA4B;AACrC,SAAS,gCAAgC;AACzC,SAAS,eAAe,sBAAsB;AAC9C,SAAS,wBAAwB;AAGjC,MAAM,6BAA6B;AAO5B,SAAS,yBAA+B;AAC7C,QAAM,EAAE,QAAQ,SAAS,IAAI,qBAAqB;AAClD,QAAM,EAAE,MAAM,WAAW,IAAI,cAAc;AAC3C,QAAM,gBAAgB,OAAO,UAAU;AACvC,gBAAc,UAAU;AACxB,QAAM,UAAU,OAAO,oBAAI,IAAwB,CAAC;AACpD,QAAM,QAAQ,OAA6C,IAAI;AAC/D;AAAA,IACE,MAAM,MAAM;AACV,UAAI,MAAM,QAAS,cAAa,MAAM,OAAO;AAAA,IAC/C;AAAA,IACA,CAAC;AAAA,EACH;AAEA,mBAAiB,CAAC,YAAY;AAC5B,QAAI,CAAC,cAAsC,SAAS,gBAAgB,EAAG;AACvE,UAAM,cAAc,QAAQ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AM,CAAC,IAAI,WAAW;AAAA,QACnF,GAAI,YAAY,EAAE,QAAQ,EAAE,OAAO,QAAQ,SAAS,SAAS,EAAE;AAAA,MACjE,CAAC;AAAA,IACH,WAAW,QAAQ,eAAe,UAAU;AAC1C,UAAI,CAAC,QAAQ,cAAc,QAAQ,cAAe;AAClD,YAAM,IAAI,OAAO;AACjB,UAAI,GAAG,CAAC,YAAY,MAAM,IAAI,MAAM,EAAE,yBAAyB,SAAS;AAAA,IAC1E;AAAA,EACF,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -1,19 +1,19 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var chunk7QZ7F3YL_cjs = require('../chunk-7QZ7F3YL.cjs');
4
+ var chunkSS7IYHLK_cjs = require('../chunk-SS7IYHLK.cjs');
5
5
  require('../chunk-EHFSR633.cjs');
6
6
  require('../chunk-6JI4AXAY.cjs');
7
- require('../chunk-GRRD7SEY.cjs');
8
- require('../chunk-M5EQGQRC.cjs');
7
+ require('../chunk-YEGOCUBR.cjs');
8
+ require('../chunk-FYNNNQ6H.cjs');
9
9
  require('../chunk-RJE6KXJQ.cjs');
10
10
  require('../chunk-TJY7XPDE.cjs');
11
11
  require('../chunk-XNW62J54.cjs');
12
12
  require('../chunk-TIBTTITZ.cjs');
13
- require('../chunk-RUKEMF6Q.cjs');
13
+ require('../chunk-BT2QTDZ4.cjs');
14
14
  require('../chunk-PA7YEXL3.cjs');
15
15
  require('../chunk-HYUKPHCT.cjs');
16
- require('../chunk-NB6XGPEB.cjs');
16
+ require('../chunk-N7B5OAI5.cjs');
17
17
  require('../chunk-223D4727.cjs');
18
18
  require('../chunk-SNUBQMIS.cjs');
19
19
  require('../chunk-OA3AN6WW.cjs');
@@ -31,11 +31,11 @@ require('../chunk-WQMR3O2D.cjs');
31
31
  require('../chunk-NZNBJF3M.cjs');
32
32
  require('../chunk-NWNVWO6L.cjs');
33
33
  require('../chunk-SK6HQ46Q.cjs');
34
- require('../chunk-TG2GM7WJ.cjs');
35
34
  require('../chunk-Z2XZ2D4N.cjs');
36
35
  require('../chunk-YZSQ7F5K.cjs');
37
36
  require('../chunk-MCXS6X37.cjs');
38
37
  require('../chunk-KQF7POTG.cjs');
38
+ require('../chunk-TG2GM7WJ.cjs');
39
39
  require('../chunk-75BNMCUX.cjs');
40
40
  require('../chunk-OEJQFPWO.cjs');
41
41
  require('../chunk-DT4ORVVI.cjs');
@@ -50,9 +50,9 @@ require('../chunk-3YEXZX4H.cjs');
50
50
  require('../chunk-4PA6VCCR.cjs');
51
51
  require('../chunk-K3WSXEEI.cjs');
52
52
  require('../chunk-AHDJXIUB.cjs');
53
- require('../chunk-S5OGPQSB.cjs');
54
53
  require('../chunk-RL2HI6NP.cjs');
55
54
  require('../chunk-6UZC4XVV.cjs');
55
+ require('../chunk-S5OGPQSB.cjs');
56
56
  require('../chunk-EQTZQD66.cjs');
57
57
  require('../chunk-JN5YMHGI.cjs');
58
58
  require('../chunk-UDSHVNU3.cjs');
@@ -86,27 +86,27 @@ require('../chunk-PLIF5CUV.cjs');
86
86
 
87
87
  Object.defineProperty(exports, "ArbiChat", {
88
88
  enumerable: true,
89
- get: function () { return chunk7QZ7F3YL_cjs.ArbiChat; }
89
+ get: function () { return chunkSS7IYHLK_cjs.ArbiChat; }
90
90
  });
91
91
  Object.defineProperty(exports, "ConnectedCompactLogin", {
92
92
  enumerable: true,
93
- get: function () { return chunk7QZ7F3YL_cjs.ConnectedCompactLogin; }
93
+ get: function () { return chunkSS7IYHLK_cjs.ConnectedCompactLogin; }
94
94
  });
95
95
  Object.defineProperty(exports, "ConnectedEmbeddedChat", {
96
96
  enumerable: true,
97
- get: function () { return chunk7QZ7F3YL_cjs.ConnectedEmbeddedChat; }
97
+ get: function () { return chunkSS7IYHLK_cjs.ConnectedEmbeddedChat; }
98
98
  });
99
99
  Object.defineProperty(exports, "ConnectedLoginPage", {
100
100
  enumerable: true,
101
- get: function () { return chunk7QZ7F3YL_cjs.ConnectedLoginPage; }
101
+ get: function () { return chunkSS7IYHLK_cjs.ConnectedLoginPage; }
102
102
  });
103
103
  Object.defineProperty(exports, "EmbeddedChatPanel", {
104
104
  enumerable: true,
105
- get: function () { return chunk7QZ7F3YL_cjs.EmbeddedChatPanel; }
105
+ get: function () { return chunkSS7IYHLK_cjs.EmbeddedChatPanel; }
106
106
  });
107
107
  Object.defineProperty(exports, "defaultHost", {
108
108
  enumerable: true,
109
- get: function () { return chunk7QZ7F3YL_cjs.defaultHost; }
109
+ get: function () { return chunkSS7IYHLK_cjs.defaultHost; }
110
110
  });
111
111
  Object.defineProperty(exports, "useConnection", {
112
112
  enumerable: true,
@@ -29,6 +29,7 @@ function collectFolderDocs(documents, path) {
29
29
  (doc) => isExplorerDocument(doc) && startsWithPath(parseFolderSegments(doc.folder), path)
30
30
  );
31
31
  }
32
+ const NAME_COLLATOR = new Intl.Collator(void 0, { numeric: true, sensitivity: "base" });
32
33
  function compareFiles(a, b, sort) {
33
34
  switch (sort) {
34
35
  case "date": {
@@ -41,10 +42,9 @@ function compareFiles(a, b, sort) {
41
42
  }
42
43
  case "name":
43
44
  default:
44
- return getDocumentTitle(a, a.file_name ?? "").localeCompare(
45
- getDocumentTitle(b, b.file_name ?? ""),
46
- void 0,
47
- { numeric: true, sensitivity: "base" }
45
+ return NAME_COLLATOR.compare(
46
+ getDocumentTitle(a, a.file_name ?? ""),
47
+ getDocumentTitle(b, b.file_name ?? "")
48
48
  );
49
49
  }
50
50
  }
@@ -76,7 +76,7 @@ function buildExplorerEntries(documents, currentPath, sort = "name", pendingFold
76
76
  name,
77
77
  path: [...currentPath, name],
78
78
  count: folderCounts.get(name) ?? 0
79
- })).sort((a, b) => a.name.localeCompare(b.name, void 0, { numeric: true, sensitivity: "base" }));
79
+ })).sort((a, b) => NAME_COLLATOR.compare(a.name, b.name));
80
80
  files.sort((a, b) => compareFiles(a, b, sort));
81
81
  return { folders, files };
82
82
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/files/folders/folderPaths.ts"],
4
- "sourcesContent": ["/**\n * Pure helpers that turn the flat document list into a navigable folder tree.\n *\n * Folders are not a backend entity \u2014 each document carries a slash-separated\n * `folder` path string (e.g. `\"Reports/Q1\"`, or `null`/`\"\"` for the root).\n * These helpers derive, for a given path, the immediate sub-folders (with\n * descendant counts) and the files that live directly in that folder. Kept\n * pure and side-effect-free so the navigation logic is unit-testable.\n */\n\nimport { extensionFromMime, getDocumentTitle, getFileExtension } from '@arbidocs/react/ui'\n\n/** The fields of a document the folder view reads. */\nexport interface FolderDocument {\n external_id: string\n file_name?: string | null\n file_type?: string | null\n file_size?: number | null\n folder?: string | null\n parent_ext_id?: string | null\n created_at?: string | null\n doc_metadata?: { title?: string | null } | null\n}\n\nexport interface ExplorerFolder {\n kind: 'folder'\n /** The folder's own name (last path segment). */\n name: string\n /** Full path segments from the root, including this folder. */\n path: string[]\n /** Number of documents anywhere beneath this folder. */\n count: number\n}\n\nexport interface ExplorerFile<D extends FolderDocument = FolderDocument> {\n kind: 'file'\n doc: D\n}\n\nexport type ExplorerEntry<D extends FolderDocument = FolderDocument> =\n ExplorerFolder | ExplorerFile<D>\n\nexport type ExplorerSort = 'name' | 'date' | 'size'\n\n/**\n * Display name for a document in the explorer, with its real file extension \u2014\n * the familiar \"Report.pdf\" form. Many documents store an AI-generated display\n * title that drops the extension, so we re-attach it from the stored\n * `file_name` or, failing that, the MIME `file_type`.\n */\nexport function getExplorerDisplayName(doc: FolderDocument): string {\n const title = getDocumentTitle(doc, doc.file_name ?? 'Untitled')\n // Already carries an extension \u2192 trust it.\n if (getFileExtension(title)) return title\n const ext = getFileExtension(doc.file_name) || extensionFromMime(doc.file_type)\n return ext ? `${title}.${ext}` : title\n}\n\n/** Split a `Doc.folder` value into trimmed, non-empty path segments. */\nexport function parseFolderSegments(folder?: string | null): string[] {\n if (!folder) return []\n return folder\n .split('/')\n .map((segment) => segment.trim())\n .filter(Boolean)\n}\n\n/** Join path segments back into a canonical `Doc.folder` string (or null at root). */\nexport function joinFolderPath(segments: string[]): string | null {\n return segments.length > 0 ? segments.join('/') : null\n}\n\n/** True when `segments` starts with every segment of `prefix`. */\nfunction startsWithPath(segments: string[], prefix: string[]): boolean {\n if (segments.length < prefix.length) return false\n for (let i = 0; i < prefix.length; i++) {\n if (segments[i] !== prefix[i]) return false\n }\n return true\n}\n\n/**\n * A document is shown in the explorer unless it belongs to an email family:\n * attachments and archived messages (`parent_ext_id` set) live \"inside\" their\n * email / archive and would otherwise clutter the folder view. Versions are not\n * children \u2014 the list holds each document's current version only.\n */\nexport function isExplorerDocument(doc: FolderDocument): boolean {\n return !doc.parent_ext_id\n}\n\n/**\n * Every explorer document that lives anywhere beneath `path` (directly in the\n * folder or in a sub-folder). Used to expand a folder into the documents a\n * folder-level action (select / move / download / delete / rename) applies to \u2014\n * \"act on a folder\" means \"act on everything in it\".\n */\nexport function collectFolderDocs<D extends FolderDocument>(documents: D[], path: string[]): D[] {\n if (path.length === 0) return documents.filter(isExplorerDocument)\n return documents.filter(\n (doc) => isExplorerDocument(doc) && startsWithPath(parseFolderSegments(doc.folder), path)\n )\n}\n\nfunction compareFiles(a: FolderDocument, b: FolderDocument, sort: ExplorerSort): number {\n switch (sort) {\n case 'date': {\n // Newest first.\n const at = a.created_at ? Date.parse(a.created_at) : 0\n const bt = b.created_at ? Date.parse(b.created_at) : 0\n return bt - at\n }\n case 'size': {\n // Largest first.\n return (b.file_size ?? 0) - (a.file_size ?? 0)\n }\n case 'name':\n default:\n return getDocumentTitle(a, a.file_name ?? '').localeCompare(\n getDocumentTitle(b, b.file_name ?? ''),\n undefined,\n { numeric: true, sensitivity: 'base' }\n )\n }\n}\n\n/**\n * Documents in the order the gallery shows them for a sort choice (and its\n * direction toggle). Review mode steps through this same order.\n */\nexport function sortExplorerFiles<D extends FolderDocument>(\n docs: D[],\n sort: ExplorerSort,\n reversed = false\n): D[] {\n const sorted = [...docs].sort((a, b) => compareFiles(a, b, sort))\n return reversed ? sorted.reverse() : sorted\n}\n\n/**\n * Build the folders and files that live directly under `currentPath`.\n *\n * - Files: documents whose folder path exactly equals `currentPath`.\n * - Folders: the distinct next path segment of any document nested deeper than\n * `currentPath`, with `count` = number of documents beneath it.\n *\n * Folders are always sorted by name; files by the requested sort.\n */\nexport function buildExplorerEntries<D extends FolderDocument>(\n documents: D[],\n currentPath: string[],\n sort: ExplorerSort = 'name',\n pendingFolders: string[] = []\n): { folders: ExplorerFolder[]; files: D[] } {\n const folderCounts = new Map<string, number>()\n const files: D[] = []\n\n for (const doc of documents) {\n const segments = parseFolderSegments(doc.folder)\n if (!startsWithPath(segments, currentPath)) continue\n\n if (segments.length === currentPath.length) {\n files.push(doc)\n } else {\n const childName = segments[currentPath.length]\n folderCounts.set(childName, (folderCounts.get(childName) ?? 0) + 1)\n }\n }\n\n // Placeholder (empty) folders the user created that live directly under the\n // current path \u2014 surfaced with count 0 so the UI can render them faded. A\n // pending folder that has since gained documents already appears above.\n const childNames = new Set(folderCounts.keys())\n for (const pending of pendingFolders) {\n const segments = parseFolderSegments(pending)\n if (!startsWithPath(segments, currentPath)) continue\n if (segments.length > currentPath.length) childNames.add(segments[currentPath.length])\n }\n\n const folders: ExplorerFolder[] = Array.from(childNames)\n .map((name) => ({\n kind: 'folder' as const,\n name,\n path: [...currentPath, name],\n count: folderCounts.get(name) ?? 0,\n }))\n .sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: 'base' }))\n\n files.sort((a, b) => compareFiles(a, b, sort))\n\n return { folders, files }\n}\n\n/**\n * Flat, cross-folder search over every top-level document by title / file name.\n * Used when the explorer search box is non-empty (mirrors real file explorers,\n * which flatten results and ignore the current folder while searching).\n */\nexport function searchExplorerDocuments<D extends FolderDocument>(\n documents: D[],\n query: string,\n sort: ExplorerSort = 'name'\n): D[] {\n const needle = query.trim().toLowerCase()\n if (!needle) return []\n return documents\n .filter((doc) => {\n if (!isExplorerDocument(doc)) return false\n const title = getDocumentTitle(doc, doc.file_name ?? '').toLowerCase()\n const name = (doc.file_name ?? '').toLowerCase()\n return title.includes(needle) || name.includes(needle)\n })\n .sort((a, b) => compareFiles(a, b, sort))\n}\n"],
5
- "mappings": ";AAUA,SAAS,mBAAmB,kBAAkB,wBAAwB;AAwC/D,SAAS,uBAAuB,KAA6B;AAClE,QAAM,QAAQ,iBAAiB,KAAK,IAAI,aAAa,UAAU;AAE/D,MAAI,iBAAiB,KAAK,EAAG,QAAO;AACpC,QAAM,MAAM,iBAAiB,IAAI,SAAS,KAAK,kBAAkB,IAAI,SAAS;AAC9E,SAAO,MAAM,GAAG,KAAK,IAAI,GAAG,KAAK;AACnC;AAGO,SAAS,oBAAoB,QAAkC;AACpE,MAAI,CAAC,OAAQ,QAAO,CAAC;AACrB,SAAO,OACJ,MAAM,GAAG,EACT,IAAI,CAAC,YAAY,QAAQ,KAAK,CAAC,EAC/B,OAAO,OAAO;AACnB;AAGO,SAAS,eAAe,UAAmC;AAChE,SAAO,SAAS,SAAS,IAAI,SAAS,KAAK,GAAG,IAAI;AACpD;AAGA,SAAS,eAAe,UAAoB,QAA2B;AACrE,MAAI,SAAS,SAAS,OAAO,OAAQ,QAAO;AAC5C,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACtC,QAAI,SAAS,CAAC,MAAM,OAAO,CAAC,EAAG,QAAO;AAAA,EACxC;AACA,SAAO;AACT;AAQO,SAAS,mBAAmB,KAA8B;AAC/D,SAAO,CAAC,IAAI;AACd;AAQO,SAAS,kBAA4C,WAAgB,MAAqB;AAC/F,MAAI,KAAK,WAAW,EAAG,QAAO,UAAU,OAAO,kBAAkB;AACjE,SAAO,UAAU;AAAA,IACf,CAAC,QAAQ,mBAAmB,GAAG,KAAK,eAAe,oBAAoB,IAAI,MAAM,GAAG,IAAI;AAAA,EAC1F;AACF;AAEA,SAAS,aAAa,GAAmB,GAAmB,MAA4B;AACtF,UAAQ,MAAM;AAAA,IACZ,KAAK,QAAQ;AAEX,YAAM,KAA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,YAAY,MAAM,CAAC;AAAA,EACvF;AAEA,QAAM,UAA4B,MAAM,KAAK,UAAU,EACpD,IAAI,CAAC,UAAU;AAAA,IACd,MAAM;AAAA,IACN;AAAA,IACA,MAAM,CAAC,GAAG,aAAa,IAAI;AAAA,IAC3B,OAAO,aAAa,IAAI,IAAI,KAAK;AAAA,EACnC,EAAE,EACD,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,MAAM,QAAW,EAAE,SAAS,MAAM,aAAa,OAAO,CAAC,CAAC;AAEjG,QAAM,KAAK,CAAC,GAAG,MAAM,aAAa,GAAG,GAAG,IAAI,CAAC;AAE7C,SAAO,EAAE,SAAS,MAAM;AAC1B;AAOO,SAAS,wBACd,WACA,OACA,OAAqB,QAChB;AACL,QAAM,SAAS,MAAM,KAAK,EAAE,YAAY;AACxC,MAAI,CAAC,OAAQ,QAAO,CAAC;AACrB,SAAO,UACJ,OAAO,CAAC,QAAQ;AACf,QAAI,CAAC,mBAAmB,GAAG,EAAG,QAAO;AACrC,UAAM,QAAQ,iBAAiB,KAAK,IAAI,aAAa,EAAE,EAAE,YAAY;AACrE,UAAM,QAAQ,IAAI,aAAa,IAAI,YAAY;AAC/C,WAAO,MAAM,SAAS,MAAM,KAAK,KAAK,SAAS,MAAM;AAAA,EACvD,CAAC,EACA,KAAK,CAAC,GAAG,MAAM,aAAa,GAAG,GAAG,IAAI,CAAC;AAC5C;",
4
+ "sourcesContent": ["/**\n * Pure helpers that turn the flat document list into a navigable folder tree.\n *\n * Folders are not a backend entity \u2014 each document carries a slash-separated\n * `folder` path string (e.g. `\"Reports/Q1\"`, or `null`/`\"\"` for the root).\n * These helpers derive, for a given path, the immediate sub-folders (with\n * descendant counts) and the files that live directly in that folder. Kept\n * pure and side-effect-free so the navigation logic is unit-testable.\n */\n\nimport { extensionFromMime, getDocumentTitle, getFileExtension } from '@arbidocs/react/ui'\n\n/** The fields of a document the folder view reads. */\nexport interface FolderDocument {\n external_id: string\n file_name?: string | null\n file_type?: string | null\n file_size?: number | null\n folder?: string | null\n parent_ext_id?: string | null\n created_at?: string | null\n doc_metadata?: { title?: string | null } | null\n}\n\nexport interface ExplorerFolder {\n kind: 'folder'\n /** The folder's own name (last path segment). */\n name: string\n /** Full path segments from the root, including this folder. */\n path: string[]\n /** Number of documents anywhere beneath this folder. */\n count: number\n}\n\nexport interface ExplorerFile<D extends FolderDocument = FolderDocument> {\n kind: 'file'\n doc: D\n}\n\nexport type ExplorerEntry<D extends FolderDocument = FolderDocument> =\n ExplorerFolder | ExplorerFile<D>\n\nexport type ExplorerSort = 'name' | 'date' | 'size'\n\n/**\n * Display name for a document in the explorer, with its real file extension \u2014\n * the familiar \"Report.pdf\" form. Many documents store an AI-generated display\n * title that drops the extension, so we re-attach it from the stored\n * `file_name` or, failing that, the MIME `file_type`.\n */\nexport function getExplorerDisplayName(doc: FolderDocument): string {\n const title = getDocumentTitle(doc, doc.file_name ?? 'Untitled')\n // Already carries an extension \u2192 trust it.\n if (getFileExtension(title)) return title\n const ext = getFileExtension(doc.file_name) || extensionFromMime(doc.file_type)\n return ext ? `${title}.${ext}` : title\n}\n\n/** Split a `Doc.folder` value into trimmed, non-empty path segments. */\nexport function parseFolderSegments(folder?: string | null): string[] {\n if (!folder) return []\n return folder\n .split('/')\n .map((segment) => segment.trim())\n .filter(Boolean)\n}\n\n/** Join path segments back into a canonical `Doc.folder` string (or null at root). */\nexport function joinFolderPath(segments: string[]): string | null {\n return segments.length > 0 ? segments.join('/') : null\n}\n\n/** True when `segments` starts with every segment of `prefix`. */\nfunction startsWithPath(segments: string[], prefix: string[]): boolean {\n if (segments.length < prefix.length) return false\n for (let i = 0; i < prefix.length; i++) {\n if (segments[i] !== prefix[i]) return false\n }\n return true\n}\n\n/**\n * A document is shown in the explorer unless it belongs to an email family:\n * attachments and archived messages (`parent_ext_id` set) live \"inside\" their\n * email / archive and would otherwise clutter the folder view. Versions are not\n * children \u2014 the list holds each document's current version only.\n */\nexport function isExplorerDocument(doc: FolderDocument): boolean {\n return !doc.parent_ext_id\n}\n\n/**\n * Every explorer document that lives anywhere beneath `path` (directly in the\n * folder or in a sub-folder). Used to expand a folder into the documents a\n * folder-level action (select / move / download / delete / rename) applies to \u2014\n * \"act on a folder\" means \"act on everything in it\".\n */\nexport function collectFolderDocs<D extends FolderDocument>(documents: D[], path: string[]): D[] {\n if (path.length === 0) return documents.filter(isExplorerDocument)\n return documents.filter(\n (doc) => isExplorerDocument(doc) && startsWithPath(parseFolderSegments(doc.folder), path)\n )\n}\n\n// One collator for every comparison: `localeCompare` with options builds one per call, which\n// dominated re-sorting a large folder.\nconst NAME_COLLATOR = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' })\n\nfunction compareFiles(a: FolderDocument, b: FolderDocument, sort: ExplorerSort): number {\n switch (sort) {\n case 'date': {\n // Newest first.\n const at = a.created_at ? Date.parse(a.created_at) : 0\n const bt = b.created_at ? Date.parse(b.created_at) : 0\n return bt - at\n }\n case 'size': {\n // Largest first.\n return (b.file_size ?? 0) - (a.file_size ?? 0)\n }\n case 'name':\n default:\n return NAME_COLLATOR.compare(\n getDocumentTitle(a, a.file_name ?? ''),\n getDocumentTitle(b, b.file_name ?? '')\n )\n }\n}\n\n/**\n * Documents in the order the gallery shows them for a sort choice (and its\n * direction toggle). Review mode steps through this same order.\n */\nexport function sortExplorerFiles<D extends FolderDocument>(\n docs: D[],\n sort: ExplorerSort,\n reversed = false\n): D[] {\n const sorted = [...docs].sort((a, b) => compareFiles(a, b, sort))\n return reversed ? sorted.reverse() : sorted\n}\n\n/**\n * Build the folders and files that live directly under `currentPath`.\n *\n * - Files: documents whose folder path exactly equals `currentPath`.\n * - Folders: the distinct next path segment of any document nested deeper than\n * `currentPath`, with `count` = number of documents beneath it.\n *\n * Folders are always sorted by name; files by the requested sort.\n */\nexport function buildExplorerEntries<D extends FolderDocument>(\n documents: D[],\n currentPath: string[],\n sort: ExplorerSort = 'name',\n pendingFolders: string[] = []\n): { folders: ExplorerFolder[]; files: D[] } {\n const folderCounts = new Map<string, number>()\n const files: D[] = []\n\n for (const doc of documents) {\n const segments = parseFolderSegments(doc.folder)\n if (!startsWithPath(segments, currentPath)) continue\n\n if (segments.length === currentPath.length) {\n files.push(doc)\n } else {\n const childName = segments[currentPath.length]\n folderCounts.set(childName, (folderCounts.get(childName) ?? 0) + 1)\n }\n }\n\n // Placeholder (empty) folders the user created that live directly under the\n // current path \u2014 surfaced with count 0 so the UI can render them faded. A\n // pending folder that has since gained documents already appears above.\n const childNames = new Set(folderCounts.keys())\n for (const pending of pendingFolders) {\n const segments = parseFolderSegments(pending)\n if (!startsWithPath(segments, currentPath)) continue\n if (segments.length > currentPath.length) childNames.add(segments[currentPath.length])\n }\n\n const folders: ExplorerFolder[] = Array.from(childNames)\n .map((name) => ({\n kind: 'folder' as const,\n name,\n path: [...currentPath, name],\n count: folderCounts.get(name) ?? 0,\n }))\n .sort((a, b) => NAME_COLLATOR.compare(a.name, b.name))\n\n files.sort((a, b) => compareFiles(a, b, sort))\n\n return { folders, files }\n}\n\n/**\n * Flat, cross-folder search over every top-level document by title / file name.\n * Used when the explorer search box is non-empty (mirrors real file explorers,\n * which flatten results and ignore the current folder while searching).\n */\nexport function searchExplorerDocuments<D extends FolderDocument>(\n documents: D[],\n query: string,\n sort: ExplorerSort = 'name'\n): D[] {\n const needle = query.trim().toLowerCase()\n if (!needle) return []\n return documents\n .filter((doc) => {\n if (!isExplorerDocument(doc)) return false\n const title = getDocumentTitle(doc, doc.file_name ?? '').toLowerCase()\n const name = (doc.file_name ?? '').toLowerCase()\n return title.includes(needle) || name.includes(needle)\n })\n .sort((a, b) => compareFiles(a, b, sort))\n}\n"],
5
+ "mappings": ";AAUA,SAAS,mBAAmB,kBAAkB,wBAAwB;AAwC/D,SAAS,uBAAuB,KAA6B;AAClE,QAAM,QAAQ,iBAAiB,KAAK,IAAI,aAAa,UAAU;AAE/D,MAAI,iBAAiB,KAAK,EAAG,QAAO;AACpC,QAAM,MAAM,iBA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