@arbidocs/react 0.4.158 → 0.4.160

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 (116) hide show
  1. package/README.md +13 -6
  2. package/dist/{store-CoLuVSxI.d.ts → ProductionDialog.d-BD1osHeq.d.cts} +33 -33
  3. package/dist/{store-BEXGdE1y.d.cts → ProductionDialog.d-CttHqQAh.d.ts} +33 -33
  4. package/dist/annotations/freeze/index.cjs +15 -15
  5. package/dist/annotations/freeze/index.d.cts +8 -3
  6. package/dist/annotations/freeze/index.d.ts +8 -3
  7. package/dist/annotations/freeze/index.js +3 -3
  8. package/dist/annotations/index.cjs +56 -56
  9. package/dist/annotations/index.d.cts +9 -4
  10. package/dist/annotations/index.d.ts +9 -4
  11. package/dist/annotations/index.js +2 -2
  12. package/dist/artifacts/index.cjs +12 -11
  13. package/dist/artifacts/index.cjs.map +1 -1
  14. package/dist/artifacts/index.d.cts +4 -4
  15. package/dist/artifacts/index.d.ts +4 -4
  16. package/dist/artifacts/index.js +3 -2
  17. package/dist/artifacts/index.js.map +1 -1
  18. package/dist/bundle-COMT7X3A.js +4 -0
  19. package/dist/{bundle-N2JIJ2T6.js.map → bundle-COMT7X3A.js.map} +1 -1
  20. package/dist/bundle-UWCOLMAA.cjs +13 -0
  21. package/dist/{bundle-T6BEVYHE.cjs.map → bundle-UWCOLMAA.cjs.map} +1 -1
  22. package/dist/{chunk-RDLAOB55.cjs → chunk-3LMX6GXR.cjs} +150 -14
  23. package/dist/chunk-3LMX6GXR.cjs.map +1 -0
  24. package/dist/{chunk-37TQBT7Y.cjs → chunk-6MTKKT2O.cjs} +188 -126
  25. package/dist/chunk-6MTKKT2O.cjs.map +1 -0
  26. package/dist/{chunk-HKIR456G.js → chunk-CEZCFQ47.js} +149 -92
  27. package/dist/chunk-CEZCFQ47.js.map +1 -0
  28. package/dist/chunk-CPZ36AQS.js +11 -0
  29. package/dist/chunk-CPZ36AQS.js.map +1 -0
  30. package/dist/{chunk-JFKWH6EP.cjs → chunk-EUC2BTNS.cjs} +35 -4
  31. package/dist/chunk-EUC2BTNS.cjs.map +1 -0
  32. package/dist/chunk-GTJ667CP.cjs +26 -0
  33. package/dist/chunk-GTJ667CP.cjs.map +1 -0
  34. package/dist/{chunk-3XYIQZTH.js → chunk-I5ZBQ63Y.js} +33 -5
  35. package/dist/chunk-I5ZBQ63Y.js.map +1 -0
  36. package/dist/chunk-JSSKEXRR.js +22 -0
  37. package/dist/chunk-JSSKEXRR.js.map +1 -0
  38. package/dist/{chunk-SSOPIPEX.cjs → chunk-LRBOMQ6Q.cjs} +4 -3
  39. package/dist/chunk-LRBOMQ6Q.cjs.map +1 -0
  40. package/dist/{chunk-COWZGCL5.js → chunk-NBIW7AEE.js} +4 -3
  41. package/dist/chunk-NBIW7AEE.js.map +1 -0
  42. package/dist/{chunk-QKNJ6FRD.cjs → chunk-ON4PL6DQ.cjs} +4 -4
  43. package/dist/chunk-ON4PL6DQ.cjs.map +1 -0
  44. package/dist/{chunk-ZJMUNGOY.js → chunk-R66GNDO7.js} +42 -4
  45. package/dist/chunk-R66GNDO7.js.map +1 -0
  46. package/dist/chunk-RCKA7BEF.cjs +14 -0
  47. package/dist/chunk-RCKA7BEF.cjs.map +1 -0
  48. package/dist/{chunk-L2PXZWJM.cjs → chunk-RDF2Q45F.cjs} +75 -20
  49. package/dist/chunk-RDF2Q45F.cjs.map +1 -0
  50. package/dist/{chunk-IHTBAY57.js → chunk-S33P6THG.js} +59 -4
  51. package/dist/chunk-S33P6THG.js.map +1 -0
  52. package/dist/{chunk-2HNEVAXO.js → chunk-SVHGCX25.js} +3 -3
  53. package/dist/chunk-SVHGCX25.js.map +1 -0
  54. package/dist/{chunk-QJXFRP5R.cjs → chunk-UP6PIBVF.cjs} +46 -8
  55. package/dist/chunk-UP6PIBVF.cjs.map +1 -0
  56. package/dist/{chunk-CNGWJDMG.js → chunk-WOXITGVS.js} +139 -15
  57. package/dist/chunk-WOXITGVS.js.map +1 -0
  58. package/dist/document-tools/index.cjs +188 -57
  59. package/dist/document-tools/index.cjs.map +1 -1
  60. package/dist/document-tools/index.d.cts +112 -15
  61. package/dist/document-tools/index.d.ts +112 -15
  62. package/dist/document-tools/index.js +141 -24
  63. package/dist/document-tools/index.js.map +1 -1
  64. package/dist/index.cjs +1771 -1509
  65. package/dist/index.cjs.map +1 -1
  66. package/dist/{index-DyFzmDZ2.d.ts → index.d-DfCFKora.d.cts} +49 -5
  67. package/dist/{index-DyFzmDZ2.d.cts → index.d-DfCFKora.d.ts} +49 -5
  68. package/dist/{index-CDTwtUr9.d.cts → index.d-eRbU1qpQ.d.cts} +333 -196
  69. package/dist/{index-CDTwtUr9.d.ts → index.d-eRbU1qpQ.d.ts} +333 -196
  70. package/dist/index.d.cts +1797 -1504
  71. package/dist/index.d.ts +1797 -1504
  72. package/dist/index.js +931 -768
  73. package/dist/index.js.map +1 -1
  74. package/dist/{model-DIwXRuGC.d.cts → model.d-D63gedpb.d.cts} +5 -0
  75. package/dist/{model-DIwXRuGC.d.ts → model.d-D63gedpb.d.ts} +5 -0
  76. package/dist/shell/index.cjs +24 -15
  77. package/dist/shell/index.d.cts +1 -1
  78. package/dist/shell/index.d.ts +1 -1
  79. package/dist/shell/index.js +2 -1
  80. package/dist/ui/index.cjs +200 -151
  81. package/dist/ui/index.d.cts +1 -1
  82. package/dist/ui/index.d.ts +1 -1
  83. package/dist/ui/index.js +3 -2
  84. package/dist/viewers/index.cjs +3 -2
  85. package/dist/viewers/index.cjs.map +1 -1
  86. package/dist/viewers/index.d.cts +2 -2
  87. package/dist/viewers/index.d.ts +2 -2
  88. package/dist/viewers/index.js +2 -1
  89. package/dist/viewers/index.js.map +1 -1
  90. package/package.json +4 -6
  91. package/dist/bundle-N2JIJ2T6.js +0 -4
  92. package/dist/bundle-T6BEVYHE.cjs +0 -13
  93. package/dist/chunk-2HNEVAXO.js.map +0 -1
  94. package/dist/chunk-37TQBT7Y.cjs.map +0 -1
  95. package/dist/chunk-3XYIQZTH.js.map +0 -1
  96. package/dist/chunk-CNGWJDMG.js.map +0 -1
  97. package/dist/chunk-COWZGCL5.js.map +0 -1
  98. package/dist/chunk-CPPBN2JB.js +0 -31
  99. package/dist/chunk-CPPBN2JB.js.map +0 -1
  100. package/dist/chunk-HKIR456G.js.map +0 -1
  101. package/dist/chunk-IHTBAY57.js.map +0 -1
  102. package/dist/chunk-JFKWH6EP.cjs.map +0 -1
  103. package/dist/chunk-L2PXZWJM.cjs.map +0 -1
  104. package/dist/chunk-QJXFRP5R.cjs.map +0 -1
  105. package/dist/chunk-QKNJ6FRD.cjs.map +0 -1
  106. package/dist/chunk-R2MF7YCW.cjs +0 -36
  107. package/dist/chunk-R2MF7YCW.cjs.map +0 -1
  108. package/dist/chunk-RDLAOB55.cjs.map +0 -1
  109. package/dist/chunk-SSOPIPEX.cjs.map +0 -1
  110. package/dist/chunk-ZJMUNGOY.js.map +0 -1
  111. /package/dist/{PdfViewer-bQH9yxFg.d.cts → PdfViewer.d-bQH9yxFg.d.cts} +0 -0
  112. /package/dist/{PdfViewer-bQH9yxFg.d.ts → PdfViewer.d-bQH9yxFg.d.ts} +0 -0
  113. /package/dist/{bundle-BnCSbHy2.d.cts → bundle.d-BnCSbHy2.d.cts} +0 -0
  114. /package/dist/{bundle-BnCSbHy2.d.ts → bundle.d-BnCSbHy2.d.ts} +0 -0
  115. /package/dist/{stored-markdown-Bp18vrbr.d.cts → stored-markdown.d-Bp18vrbr.d.cts} +0 -0
  116. /package/dist/{stored-markdown-Bp18vrbr.d.ts → stored-markdown.d-Bp18vrbr.d.ts} +0 -0
@@ -1,15 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var chunkQKNJ6FRD_cjs = require('../chunk-QKNJ6FRD.cjs');
3
+ var chunkON4PL6DQ_cjs = require('../chunk-ON4PL6DQ.cjs');
4
+ var chunkRDF2Q45F_cjs = require('../chunk-RDF2Q45F.cjs');
5
+ var chunkLRBOMQ6Q_cjs = require('../chunk-LRBOMQ6Q.cjs');
4
6
  var chunkZWFMFOGP_cjs = require('../chunk-ZWFMFOGP.cjs');
5
7
  require('../chunk-VOFNX4P6.cjs');
6
- var chunkL2PXZWJM_cjs = require('../chunk-L2PXZWJM.cjs');
7
- var chunkSSOPIPEX_cjs = require('../chunk-SSOPIPEX.cjs');
8
- require('../chunk-Z3LLUO32.cjs');
8
+ require('../chunk-GTJ667CP.cjs');
9
9
  require('../chunk-WYZJLZ67.cjs');
10
+ require('../chunk-Z3LLUO32.cjs');
10
11
  require('../chunk-HJDR5HEO.cjs');
11
12
  require('../chunk-S6A6FSG7.cjs');
12
- require('../chunk-R2MF7YCW.cjs');
13
+ require('../chunk-RCKA7BEF.cjs');
13
14
  var react = require('react');
14
15
  var reactQuery = require('@tanstack/react-query');
15
16
  var client = require('@arbidocs/client');
@@ -39,9 +40,9 @@ async function fetchProductionPdf(client, doc) {
39
40
  const pdf = isPdfDocument(doc);
40
41
  let blob;
41
42
  try {
42
- blob = await (pdf ? chunkQKNJ6FRD_cjs.fetchDocumentFile : chunkQKNJ6FRD_cjs.fetchDocumentPdf)(client, doc.external_id);
43
+ blob = await (pdf ? chunkON4PL6DQ_cjs.fetchDocumentFile : chunkON4PL6DQ_cjs.fetchDocumentPdf)(client, doc.external_id);
43
44
  } catch (e) {
44
- if (!pdf && e instanceof chunkQKNJ6FRD_cjs.DocumentFetchError) return null;
45
+ if (!pdf && e instanceof chunkON4PL6DQ_cjs.DocumentFetchError) return null;
45
46
  throw e;
46
47
  }
47
48
  const bytes = new Uint8Array(await blob.arrayBuffer());
@@ -104,7 +105,7 @@ async function buildProduction(client, documents, choices, options) {
104
105
  if (items.length === 0) {
105
106
  throw new Error("None of these documents has a PDF version to number yet.");
106
107
  }
107
- const { buildBundle } = await import('../bundle-T6BEVYHE.cjs');
108
+ const { buildBundle } = await import('../bundle-UWCOLMAA.cjs');
108
109
  const result = await buildBundle(items, {
109
110
  layout: choices.layout,
110
111
  bates: {
@@ -158,15 +159,15 @@ var MarkupStoreError = class extends Error {
158
159
  status;
159
160
  };
160
161
  var detailOf = (error, fallback) => {
161
- const detail2 = error?.detail;
162
- return typeof detail2 === "string" ? detail2 : fallback;
162
+ const detail3 = error?.detail;
163
+ return typeof detail3 === "string" ? detail3 : fallback;
163
164
  };
164
165
  async function call(request) {
165
166
  try {
166
167
  return await request();
167
168
  } catch (e) {
168
169
  if (e instanceof TypeError || typeof navigator !== "undefined" && !navigator.onLine) {
169
- throw new chunkL2PXZWJM_cjs.AnnotationStoreOfflineError();
170
+ throw new chunkRDF2Q45F_cjs.AnnotationStoreOfflineError();
170
171
  }
171
172
  throw e;
172
173
  }
@@ -195,8 +196,8 @@ function createMarkupStore({ version, client, onSaved }) {
195
196
  response.status
196
197
  );
197
198
  }
198
- const layer = chunkSSOPIPEX_cjs.parseLayer({
199
- schema: chunkSSOPIPEX_cjs.LAYER_SCHEMA_VERSION,
199
+ const layer = chunkLRBOMQ6Q_cjs.parseLayer({
200
+ schema: chunkLRBOMQ6Q_cjs.LAYER_SCHEMA_VERSION,
200
201
  documentId,
201
202
  annotations: data.annotations ?? [],
202
203
  updatedAt: data.updated_at ?? (/* @__PURE__ */ new Date()).toISOString()
@@ -249,7 +250,7 @@ function createMarkupStore({ version, client, onSaved }) {
249
250
  const deleted = new Set(
250
251
  [...seen].filter((id) => !mine.annotations.some((a) => a.id === id))
251
252
  );
252
- const merged = chunkL2PXZWJM_cjs.mergeLayers({ base, mine, theirs: latest.layer, deleted });
253
+ const merged = chunkRDF2Q45F_cjs.mergeLayers({ base, mine, theirs: latest.layer, deleted });
253
254
  revision = latest.revision;
254
255
  canEdit = latest.canEdit;
255
256
  base = latest.layer;
@@ -287,7 +288,7 @@ function readLegacyLayer(documentId) {
287
288
  try {
288
289
  const raw = storage()?.getItem(LEGACY_LAYER_PREFIX + documentId);
289
290
  if (!raw) return null;
290
- return chunkSSOPIPEX_cjs.parseLayer(JSON.parse(raw));
291
+ return chunkLRBOMQ6Q_cjs.parseLayer(JSON.parse(raw));
291
292
  } catch {
292
293
  return null;
293
294
  }
@@ -316,12 +317,12 @@ async function addToMarkup(documentId, version, marks, client) {
316
317
  const store = createMarkupStore({ version, client });
317
318
  const current = await store.load(documentId);
318
319
  const incoming = {
319
- ...chunkSSOPIPEX_cjs.emptyLayer(documentId, (/* @__PURE__ */ new Date()).toISOString()),
320
+ ...chunkLRBOMQ6Q_cjs.emptyLayer(documentId, (/* @__PURE__ */ new Date()).toISOString()),
320
321
  annotations: marks
321
322
  };
322
- const merged = chunkL2PXZWJM_cjs.mergeLayers({ base: null, mine: current, theirs: incoming });
323
+ const merged = chunkRDF2Q45F_cjs.mergeLayers({ base: null, mine: current, theirs: incoming });
323
324
  const added = merged.annotations.length - current.annotations.length;
324
- if (added > 0) await store.save(chunkSSOPIPEX_cjs.parseLayer({ ...merged, schema: chunkSSOPIPEX_cjs.LAYER_SCHEMA_VERSION }));
325
+ if (added > 0) await store.save(chunkLRBOMQ6Q_cjs.parseLayer({ ...merged, schema: chunkLRBOMQ6Q_cjs.LAYER_SCHEMA_VERSION }));
325
326
  return added;
326
327
  }
327
328
  async function migrateLegacyLayer(documentId, layer, versions, currentVersion, client) {
@@ -385,7 +386,7 @@ async function fetchMarkupPdf(client, documentId, version) {
385
386
  }
386
387
  var SIGNED_UNCHANGED = "The signed PDF is unchanged: the comments are kept beside it as markup.";
387
388
  function useDocumentMarkup(documentData, snapshotVersion, currentSigned = false) {
388
- const { client, notify, saveFile, onDocumentsChanged } = chunkQKNJ6FRD_cjs.useDocumentTools();
389
+ const { client, notify, saveFile, onDocumentsChanged } = chunkON4PL6DQ_cjs.useDocumentTools();
389
390
  const documentId = documentData?.external_id;
390
391
  const currentVersion = documentData?.current_version ?? 1;
391
392
  const shownVersion = snapshotVersion ?? currentVersion;
@@ -558,7 +559,7 @@ function useIsOnline() {
558
559
  }
559
560
  var documentBytesKey = (documentRef, version, kind) => version === void 0 ? ["arbi", "documentBytes", documentRef] : ["arbi", "documentBytes", documentRef, version, kind ?? "pdf"];
560
561
  function useDocumentBytes(documentRef, options) {
561
- const { client } = chunkQKNJ6FRD_cjs.useDocumentTools();
562
+ const { client } = chunkON4PL6DQ_cjs.useDocumentTools();
562
563
  const { version, kind, enabled = true, fallback } = options;
563
564
  return reactQuery.useQuery({
564
565
  queryKey: documentBytesKey(documentRef, version ?? null, kind),
@@ -568,7 +569,7 @@ function useDocumentBytes(documentRef, options) {
568
569
  if (offline) return offline;
569
570
  }
570
571
  try {
571
- return await (kind === "original" ? chunkQKNJ6FRD_cjs.fetchDocumentFile : chunkQKNJ6FRD_cjs.fetchDocumentPdf)(
572
+ return await (kind === "original" ? chunkON4PL6DQ_cjs.fetchDocumentFile : chunkON4PL6DQ_cjs.fetchDocumentPdf)(
572
573
  client,
573
574
  documentRef,
574
575
  { signal }
@@ -602,8 +603,8 @@ function isLegibleSignatureBox(rect) {
602
603
  var SIGNATURES_PATH = "/v1/document/{document_ext_id}/signatures";
603
604
  var SIGNATURES_KEY = ["get", SIGNATURES_PATH];
604
605
  function errorDetail(error, fallback) {
605
- const detail2 = error?.detail;
606
- return typeof detail2 === "string" ? detail2 : fallback;
606
+ const detail3 = error?.detail;
607
+ return typeof detail3 === "string" ? detail3 : fallback;
607
608
  }
608
609
  async function fetchDocumentSignatures(client, documentRef) {
609
610
  const { docId, version } = chunkZWFMFOGP_cjs.parseVersionRef(documentRef);
@@ -614,7 +615,7 @@ async function fetchDocumentSignatures(client, documentRef) {
614
615
  return data;
615
616
  }
616
617
  function useDocumentSignatures(documentId, enabled = true) {
617
- const { client } = chunkQKNJ6FRD_cjs.useDocumentTools();
618
+ const { client } = chunkON4PL6DQ_cjs.useDocumentTools();
618
619
  const { docId, version } = chunkZWFMFOGP_cjs.parseVersionRef(documentId);
619
620
  return reactQuery.useQuery({
620
621
  queryKey: [
@@ -634,14 +635,14 @@ var SigningError = class extends Error {
634
635
  this.reason = reason;
635
636
  }
636
637
  };
637
- function signingErrorReason(detail2) {
638
- if (/still being prepared/i.test(detail2)) return "preparing";
639
- if (/no longer the current version/i.test(detail2)) return "stale";
638
+ function signingErrorReason(detail3) {
639
+ if (/still being prepared/i.test(detail3)) return "preparing";
640
+ if (/no longer the current version/i.test(detail3)) return "stale";
640
641
  return "failed";
641
642
  }
642
643
  function signingError(error, fallback) {
643
- const detail2 = errorDetail(error, fallback);
644
- return new SigningError(detail2, signingErrorReason(detail2));
644
+ const detail3 = errorDetail(error, fallback);
645
+ return new SigningError(detail3, signingErrorReason(detail3));
645
646
  }
646
647
  var PREPARE_RETRIES = 3;
647
648
  var PREPARE_RETRY_DELAY_MS = 1500;
@@ -685,7 +686,7 @@ async function signDocument(client$1, deploymentDomain, {
685
686
  return signed.data;
686
687
  }
687
688
  function useSignDocument() {
688
- const env = chunkQKNJ6FRD_cjs.useDocumentTools();
689
+ const env = chunkON4PL6DQ_cjs.useDocumentTools();
689
690
  const queryClient = reactQuery.useQueryClient();
690
691
  return reactQuery.useMutation({
691
692
  mutationFn: (vars) => {
@@ -731,7 +732,7 @@ async function fetchSignatureVerification(client, reference) {
731
732
  return data;
732
733
  }
733
734
  function useSignatureVerification(reference) {
734
- const { client } = chunkQKNJ6FRD_cjs.useDocumentTools();
735
+ const { client } = chunkON4PL6DQ_cjs.useDocumentTools();
735
736
  return reactQuery.useQuery({
736
737
  queryKey: ["get", VERIFY_PATH, { params: { path: { reference } } }],
737
738
  queryFn: () => fetchSignatureVerification(client, reference),
@@ -760,9 +761,18 @@ var FIELD_TYPE_LABELS = {
760
761
  var DEFAULT_FIELD_SIZE = {
761
762
  signature: { width: 0.28, height: 0.05 },
762
763
  initials: { width: 0.1, height: 0.04 },
763
- date: { width: 0.2, height: 0.03 },
764
- name: { width: 0.28, height: 0.03 }
764
+ date: { width: 0.22, height: 0.028 },
765
+ name: { width: 0.28, height: 0.028 }
766
+ };
767
+ var SIGNER_PROGRESS_LABELS = {
768
+ invited: "Invited",
769
+ registered: "Not opened yet",
770
+ viewed: "Viewed",
771
+ signed: "Signed",
772
+ declined: "Declined"
765
773
  };
774
+ var EMAIL = /^[^@\s<>,;]{1,64}@[^@\s<>,;]{1,255}\.[^@\s<>,;]{1,63}$/;
775
+ var isEmailSigner = (signer) => EMAIL.test(signer.trim());
766
776
  var MARK_FIELD_TYPES = ["signature", "initials"];
767
777
  var REQUESTS_KEY = ["signature-requests"];
768
778
  function detail(error, fallback) {
@@ -792,9 +802,10 @@ function sendBlocker(fields) {
792
802
  }
793
803
  return null;
794
804
  }
795
- function fieldsFromSuggestions(suggestions, assign) {
805
+ function fieldsFromSuggestions(suggestions, assign, members = /* @__PURE__ */ new Map()) {
796
806
  return suggestions.flatMap((s) => {
797
- const signer = assign[s.group];
807
+ const email = s.signer_email?.toLowerCase();
808
+ const signer = email ? members.get(email) ?? email : assign[s.group];
798
809
  if (!signer) return [];
799
810
  return [
800
811
  {
@@ -806,11 +817,17 @@ function fieldsFromSuggestions(suggestions, assign) {
806
817
  width: s.width,
807
818
  height: s.height,
808
819
  signer,
809
- required: true
820
+ required: s.required ?? true
810
821
  }
811
822
  ];
812
823
  });
813
824
  }
825
+ function splitSuggestions(suggestions) {
826
+ return {
827
+ placed: suggestions.filter((s) => s.source === "anchor"),
828
+ extras: suggestions.filter((s) => s.source !== "anchor")
829
+ };
830
+ }
814
831
  async function fetchDocumentSignatureRequests(client, documentId) {
815
832
  const { data, error } = await client.GET("/v1/document/{document_ext_id}/signature-requests", {
816
833
  params: { path: { document_ext_id: documentId } }
@@ -819,7 +836,7 @@ async function fetchDocumentSignatureRequests(client, documentId) {
819
836
  return data;
820
837
  }
821
838
  function useDocumentSignatureRequests(documentId, enabled = true) {
822
- const { client } = chunkQKNJ6FRD_cjs.useDocumentTools();
839
+ const { client } = chunkON4PL6DQ_cjs.useDocumentTools();
823
840
  return reactQuery.useQuery({
824
841
  queryKey: [...REQUESTS_KEY, "document", documentId],
825
842
  queryFn: () => fetchDocumentSignatureRequests(client, documentId),
@@ -828,7 +845,7 @@ function useDocumentSignatureRequests(documentId, enabled = true) {
828
845
  });
829
846
  }
830
847
  function useSignatureRequestsAwaitingMe(enabled = true) {
831
- const { client } = chunkQKNJ6FRD_cjs.useDocumentTools();
848
+ const { client } = chunkON4PL6DQ_cjs.useDocumentTools();
832
849
  return reactQuery.useQuery({
833
850
  queryKey: [...REQUESTS_KEY, "awaiting-me"],
834
851
  queryFn: async () => {
@@ -843,7 +860,7 @@ function useSignatureRequestsAwaitingMe(enabled = true) {
843
860
  });
844
861
  }
845
862
  function useSignatureRequest(requestId) {
846
- const { client } = chunkQKNJ6FRD_cjs.useDocumentTools();
863
+ const { client } = chunkON4PL6DQ_cjs.useDocumentTools();
847
864
  return reactQuery.useQuery({
848
865
  queryKey: [...REQUESTS_KEY, "one", requestId],
849
866
  queryFn: async () => {
@@ -893,7 +910,7 @@ function useInvalidateRequests() {
893
910
  return () => queryClient.invalidateQueries({ queryKey: REQUESTS_KEY });
894
911
  }
895
912
  function useSaveSignatureRequest() {
896
- const { client } = chunkQKNJ6FRD_cjs.useDocumentTools();
913
+ const { client } = chunkON4PL6DQ_cjs.useDocumentTools();
897
914
  const invalidate = useInvalidateRequests();
898
915
  return reactQuery.useMutation({
899
916
  mutationFn: (vars) => saveSignatureRequest(client, vars),
@@ -901,7 +918,7 @@ function useSaveSignatureRequest() {
901
918
  });
902
919
  }
903
920
  function useVoidSignatureRequest() {
904
- const { client } = chunkQKNJ6FRD_cjs.useDocumentTools();
921
+ const { client } = chunkON4PL6DQ_cjs.useDocumentTools();
905
922
  const invalidate = useInvalidateRequests();
906
923
  return reactQuery.useMutation({
907
924
  mutationFn: async (requestId) => {
@@ -915,7 +932,7 @@ function useVoidSignatureRequest() {
915
932
  });
916
933
  }
917
934
  function useDeclineSignatureRequest() {
918
- const { client } = chunkQKNJ6FRD_cjs.useDocumentTools();
935
+ const { client } = chunkON4PL6DQ_cjs.useDocumentTools();
919
936
  const invalidate = useInvalidateRequests();
920
937
  return reactQuery.useMutation({
921
938
  mutationFn: async ({ requestId, reason }) => {
@@ -955,7 +972,7 @@ async function signSignatureRequest(client$1, deploymentDomain, { request, pdfBl
955
972
  return signed.data;
956
973
  }
957
974
  function useSignSignatureRequest() {
958
- const env = chunkQKNJ6FRD_cjs.useDocumentTools();
975
+ const env = chunkON4PL6DQ_cjs.useDocumentTools();
959
976
  const invalidate = useInvalidateRequests();
960
977
  const queryClient = reactQuery.useQueryClient();
961
978
  return reactQuery.useMutation({
@@ -975,13 +992,13 @@ function useSignSignatureRequest() {
975
992
  });
976
993
  }
977
994
  function useSignerCandidates(enabled = true) {
978
- const { client, user } = chunkQKNJ6FRD_cjs.useDocumentTools();
995
+ const { client, user } = chunkON4PL6DQ_cjs.useDocumentTools();
979
996
  return reactQuery.useQuery({
980
997
  queryKey: [...REQUESTS_KEY, "candidates"],
981
998
  queryFn: async () => {
982
999
  const { data, error } = await client.GET("/v1/workspace/users");
983
1000
  if (!data) throw new Error(detail(error, "The workspace members could not be read"));
984
- const people = data.filter((m) => m.user.external_id.startsWith("usr-") && m.role !== "guest").map((m) => ({
1001
+ const people = data.filter((m) => m.user.external_id.startsWith("usr-")).map((m) => ({
985
1002
  externalId: m.user.external_id,
986
1003
  name: [m.user.given_name, m.user.family_name].filter(Boolean).join(" ") || m.user.email,
987
1004
  email: m.user.email,
@@ -996,57 +1013,158 @@ function useSignerCandidates(enabled = true) {
996
1013
  staleTime: 6e4
997
1014
  });
998
1015
  }
1016
+ async function inviteSigners(client, documentId, emails) {
1017
+ if (!emails.length) return;
1018
+ const { error, response } = await client.POST("/v1/workspace/users", {
1019
+ body: {
1020
+ emails,
1021
+ role: "guest",
1022
+ confirm_invite: true,
1023
+ resource_type: "document",
1024
+ resource_ext_id: documentId
1025
+ }
1026
+ });
1027
+ if (response.status === 409) {
1028
+ throw new Error("Share the document with the workspace before asking others to sign it.");
1029
+ }
1030
+ if (error && response.status !== 404) {
1031
+ throw new Error(detail(error, "The signers could not be invited"));
1032
+ }
1033
+ }
1034
+ function useInviteSigners() {
1035
+ const { client } = chunkON4PL6DQ_cjs.useDocumentTools();
1036
+ const invalidate = useInvalidateRequests();
1037
+ const queryClient = reactQuery.useQueryClient();
1038
+ return reactQuery.useMutation({
1039
+ mutationFn: ({ documentId, emails }) => inviteSigners(client, documentId, emails),
1040
+ onSuccess: async () => {
1041
+ await invalidate();
1042
+ await queryClient.invalidateQueries({ queryKey: [...REQUESTS_KEY, "candidates"] });
1043
+ }
1044
+ });
1045
+ }
1046
+ var INFORMAL_SIGNATURE_NOTE = "Informal signature: for verified signing, use Request signatures.";
1047
+ var KEY = ["saved-signature"];
1048
+ async function keypair(source = client.getUserEncryptionKeypair) {
1049
+ await client.initSodium();
1050
+ const pair = await source();
1051
+ if (!pair) throw new Error("Sign in again to use your saved signature.");
1052
+ return pair;
1053
+ }
1054
+ function detail2(error, fallback) {
1055
+ const d = error?.detail;
1056
+ return typeof d === "string" ? d : fallback;
1057
+ }
1058
+ async function fetchSavedSignature(client$1, source) {
1059
+ const { data, error } = await client$1.GET("/v1/user/signature");
1060
+ if (!data) throw new Error(detail2(error, "Your saved signature could not be read"));
1061
+ if (!data.sealed) return null;
1062
+ const pair = await keypair(source);
1063
+ const json = new TextDecoder().decode(client.sealedBoxDecrypt(data.sealed, pair.secretKey));
1064
+ return JSON.parse(json);
1065
+ }
1066
+ async function storeSavedSignature(client$1, signature, source) {
1067
+ const pair = await keypair(source);
1068
+ const sealed = client.sealedBoxEncrypt(
1069
+ Uint8Array.from(new TextEncoder().encode(JSON.stringify(signature))),
1070
+ pair.publicKey
1071
+ );
1072
+ const { error, response } = await client$1.PUT("/v1/user/signature", { body: { sealed } });
1073
+ if (!response.ok) throw new Error(detail2(error, "Your signature could not be saved"));
1074
+ }
1075
+ async function deleteSavedSignature(client) {
1076
+ const { error, response } = await client.DELETE("/v1/user/signature");
1077
+ if (!response.ok) throw new Error(detail2(error, "Your saved signature could not be deleted"));
1078
+ }
1079
+ function useSavedSignature(enabled = true) {
1080
+ const { client } = chunkON4PL6DQ_cjs.useDocumentTools();
1081
+ return reactQuery.useQuery({
1082
+ queryKey: KEY,
1083
+ queryFn: () => fetchSavedSignature(client),
1084
+ enabled,
1085
+ staleTime: 6e4,
1086
+ retry: false
1087
+ });
1088
+ }
1089
+ function useStoreSavedSignature() {
1090
+ const { client } = chunkON4PL6DQ_cjs.useDocumentTools();
1091
+ const queryClient = reactQuery.useQueryClient();
1092
+ return reactQuery.useMutation({
1093
+ mutationFn: (signature) => storeSavedSignature(client, signature),
1094
+ onSuccess: (_, signature) => queryClient.setQueryData(KEY, signature)
1095
+ });
1096
+ }
1097
+ function useDeleteSavedSignature() {
1098
+ const { client } = chunkON4PL6DQ_cjs.useDocumentTools();
1099
+ const queryClient = reactQuery.useQueryClient();
1100
+ return reactQuery.useMutation({
1101
+ mutationFn: () => deleteSavedSignature(client),
1102
+ onSuccess: () => queryClient.setQueryData(KEY, null)
1103
+ });
1104
+ }
1105
+ function pngBytes(base64) {
1106
+ const raw = atob(base64);
1107
+ const out = new Uint8Array(raw.length);
1108
+ for (let i = 0; i < raw.length; i++) out[i] = raw.charCodeAt(i);
1109
+ return out;
1110
+ }
1111
+ function pngSize(base64) {
1112
+ const bytes = pngBytes(base64.slice(0, 64));
1113
+ const view = new DataView(bytes.buffer);
1114
+ return { width: view.getUint32(16), height: view.getUint32(20) };
1115
+ }
999
1116
 
1000
1117
  Object.defineProperty(exports, "DocumentFetchError", {
1001
1118
  enumerable: true,
1002
- get: function () { return chunkQKNJ6FRD_cjs.DocumentFetchError; }
1119
+ get: function () { return chunkON4PL6DQ_cjs.DocumentFetchError; }
1003
1120
  });
1004
1121
  Object.defineProperty(exports, "DocumentToolsProvider", {
1005
1122
  enumerable: true,
1006
- get: function () { return chunkQKNJ6FRD_cjs.DocumentToolsProvider; }
1123
+ get: function () { return chunkON4PL6DQ_cjs.DocumentToolsProvider; }
1007
1124
  });
1008
1125
  Object.defineProperty(exports, "certificateLink", {
1009
1126
  enumerable: true,
1010
- get: function () { return chunkQKNJ6FRD_cjs.certificateLink; }
1127
+ get: function () { return chunkON4PL6DQ_cjs.certificateLink; }
1011
1128
  });
1012
1129
  Object.defineProperty(exports, "clientUpload", {
1013
1130
  enumerable: true,
1014
- get: function () { return chunkQKNJ6FRD_cjs.clientUpload; }
1131
+ get: function () { return chunkON4PL6DQ_cjs.clientUpload; }
1015
1132
  });
1016
1133
  Object.defineProperty(exports, "contentDispositionFileName", {
1017
1134
  enumerable: true,
1018
- get: function () { return chunkQKNJ6FRD_cjs.contentDispositionFileName; }
1135
+ get: function () { return chunkON4PL6DQ_cjs.contentDispositionFileName; }
1019
1136
  });
1020
1137
  Object.defineProperty(exports, "defaultCertificateUrl", {
1021
1138
  enumerable: true,
1022
- get: function () { return chunkQKNJ6FRD_cjs.defaultCertificateUrl; }
1139
+ get: function () { return chunkON4PL6DQ_cjs.defaultCertificateUrl; }
1023
1140
  });
1024
1141
  Object.defineProperty(exports, "downloadBlob", {
1025
1142
  enumerable: true,
1026
- get: function () { return chunkQKNJ6FRD_cjs.downloadBlob; }
1143
+ get: function () { return chunkON4PL6DQ_cjs.downloadBlob; }
1027
1144
  });
1028
1145
  Object.defineProperty(exports, "fetchDocumentFile", {
1029
1146
  enumerable: true,
1030
- get: function () { return chunkQKNJ6FRD_cjs.fetchDocumentFile; }
1147
+ get: function () { return chunkON4PL6DQ_cjs.fetchDocumentFile; }
1031
1148
  });
1032
1149
  Object.defineProperty(exports, "fetchDocumentPdf", {
1033
1150
  enumerable: true,
1034
- get: function () { return chunkQKNJ6FRD_cjs.fetchDocumentPdf; }
1151
+ get: function () { return chunkON4PL6DQ_cjs.fetchDocumentPdf; }
1035
1152
  });
1036
1153
  Object.defineProperty(exports, "uploadQueryString", {
1037
1154
  enumerable: true,
1038
- get: function () { return chunkQKNJ6FRD_cjs.uploadQueryString; }
1155
+ get: function () { return chunkON4PL6DQ_cjs.uploadQueryString; }
1039
1156
  });
1040
1157
  Object.defineProperty(exports, "useDocumentTools", {
1041
1158
  enumerable: true,
1042
- get: function () { return chunkQKNJ6FRD_cjs.useDocumentTools; }
1159
+ get: function () { return chunkON4PL6DQ_cjs.useDocumentTools; }
1043
1160
  });
1044
1161
  Object.defineProperty(exports, "useOptionalDocumentTools", {
1045
1162
  enumerable: true,
1046
- get: function () { return chunkQKNJ6FRD_cjs.useOptionalDocumentTools; }
1163
+ get: function () { return chunkON4PL6DQ_cjs.useOptionalDocumentTools; }
1047
1164
  });
1048
1165
  exports.DEFAULT_FIELD_SIZE = DEFAULT_FIELD_SIZE;
1049
1166
  exports.FIELD_TYPE_LABELS = FIELD_TYPE_LABELS;
1167
+ exports.INFORMAL_SIGNATURE_NOTE = INFORMAL_SIGNATURE_NOTE;
1050
1168
  exports.LEGACY_LAYER_PREFIX = LEGACY_LAYER_PREFIX;
1051
1169
  exports.MARK_FIELD_TYPES = MARK_FIELD_TYPES;
1052
1170
  exports.MAX_MERGE_ATTEMPTS = MAX_MERGE_ATTEMPTS;
@@ -1056,6 +1174,7 @@ exports.PRODUCTIONS_FOLDER = PRODUCTIONS_FOLDER;
1056
1174
  exports.SIGNATURE_FIELD_TYPES = SIGNATURE_FIELD_TYPES;
1057
1175
  exports.SIGNED_LOCKED_REASON = SIGNED_LOCKED_REASON;
1058
1176
  exports.SIGNED_UNCHANGED = SIGNED_UNCHANGED;
1177
+ exports.SIGNER_PROGRESS_LABELS = SIGNER_PROGRESS_LABELS;
1059
1178
  exports.SignatureVerificationError = SignatureVerificationError;
1060
1179
  exports.SigningError = SigningError;
1061
1180
  exports.VERIFY_PATH = VERIFY_PATH;
@@ -1065,11 +1184,13 @@ exports.canAnnotate = canAnnotate;
1065
1184
  exports.copyOpenThreads = copyOpenThreads;
1066
1185
  exports.createMarkupStore = createMarkupStore;
1067
1186
  exports.currentHasMarkup = currentHasMarkup;
1187
+ exports.deleteSavedSignature = deleteSavedSignature;
1068
1188
  exports.documentBytesKey = documentBytesKey;
1069
1189
  exports.fetchDocumentSignatureRequests = fetchDocumentSignatureRequests;
1070
1190
  exports.fetchDocumentSignatures = fetchDocumentSignatures;
1071
1191
  exports.fetchMarkupPdf = fetchMarkupPdf;
1072
1192
  exports.fetchProductionPdf = fetchProductionPdf;
1193
+ exports.fetchSavedSignature = fetchSavedSignature;
1073
1194
  exports.fetchSignatureVerification = fetchSignatureVerification;
1074
1195
  exports.fieldsFromSuggestions = fieldsFromSuggestions;
1075
1196
  exports.fieldsInSigningOrder = fieldsInSigningOrder;
@@ -1078,6 +1199,8 @@ exports.frozenCopyName = frozenCopyName;
1078
1199
  exports.hasNoRendition = hasNoRendition;
1079
1200
  exports.initialsOf = initialsOf;
1080
1201
  exports.intentText = intentText;
1202
+ exports.inviteSigners = inviteSigners;
1203
+ exports.isEmailSigner = isEmailSigner;
1081
1204
  exports.isLegibleSignatureBox = isLegibleSignatureBox;
1082
1205
  exports.isPdfDocument = isPdfDocument;
1083
1206
  exports.isSignatureReference = isSignatureReference;
@@ -1087,6 +1210,8 @@ exports.matchSignedCopy = matchSignedCopy;
1087
1210
  exports.migrateLegacyLayer = migrateLegacyLayer;
1088
1211
  exports.newFieldId = newFieldId;
1089
1212
  exports.openThreadsOf = openThreadsOf;
1213
+ exports.pngBytes = pngBytes;
1214
+ exports.pngSize = pngSize;
1090
1215
  exports.productionDocumentName = productionDocumentName;
1091
1216
  exports.productionFileName = productionFileName;
1092
1217
  exports.productionFolder = productionFolder;
@@ -1100,22 +1225,28 @@ exports.sendBlocker = sendBlocker;
1100
1225
  exports.sha256Hex = sha256Hex;
1101
1226
  exports.signDocument = signDocument;
1102
1227
  exports.signSignatureRequest = signSignatureRequest;
1228
+ exports.splitSuggestions = splitSuggestions;
1229
+ exports.storeSavedSignature = storeSavedSignature;
1103
1230
  exports.suggestSignatureFields = suggestSignatureFields;
1104
1231
  exports.toAppearance = toAppearance;
1105
1232
  exports.uploadFrozenCopy = uploadFrozenCopy;
1106
1233
  exports.useDeclineSignatureRequest = useDeclineSignatureRequest;
1234
+ exports.useDeleteSavedSignature = useDeleteSavedSignature;
1107
1235
  exports.useDocumentBytes = useDocumentBytes;
1108
1236
  exports.useDocumentMarkup = useDocumentMarkup;
1109
1237
  exports.useDocumentSignatureRequests = useDocumentSignatureRequests;
1110
1238
  exports.useDocumentSignatures = useDocumentSignatures;
1239
+ exports.useInviteSigners = useInviteSigners;
1111
1240
  exports.useIsOnline = useIsOnline;
1112
1241
  exports.useSaveSignatureRequest = useSaveSignatureRequest;
1242
+ exports.useSavedSignature = useSavedSignature;
1113
1243
  exports.useSignDocument = useSignDocument;
1114
1244
  exports.useSignSignatureRequest = useSignSignatureRequest;
1115
1245
  exports.useSignatureRequest = useSignatureRequest;
1116
1246
  exports.useSignatureRequestsAwaitingMe = useSignatureRequestsAwaitingMe;
1117
1247
  exports.useSignatureVerification = useSignatureVerification;
1118
1248
  exports.useSignerCandidates = useSignerCandidates;
1249
+ exports.useStoreSavedSignature = useStoreSavedSignature;
1119
1250
  exports.useVoidSignatureRequest = useVoidSignatureRequest;
1120
1251
  exports.versionsWithMarkup = versionsWithMarkup;
1121
1252
  //# sourceMappingURL=index.cjs.map