@rhc-office/sdk 6.6.256

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 (126) hide show
  1. package/README.md +176 -0
  2. package/dist/api/annotation-tool.d.ts +127 -0
  3. package/dist/api/annotation-tool.d.ts.map +1 -0
  4. package/dist/api/callbacks.d.ts +25 -0
  5. package/dist/api/callbacks.d.ts.map +1 -0
  6. package/dist/api/common.d.ts +83 -0
  7. package/dist/api/common.d.ts.map +1 -0
  8. package/dist/api/crypto-tool.d.ts +9 -0
  9. package/dist/api/crypto-tool.d.ts.map +1 -0
  10. package/dist/api/digital-sign-environment.d.ts +100 -0
  11. package/dist/api/digital-sign-environment.d.ts.map +1 -0
  12. package/dist/api/document-sdk.d.ts +111 -0
  13. package/dist/api/document-sdk.d.ts.map +1 -0
  14. package/dist/api/document-tool.d.ts +68 -0
  15. package/dist/api/document-tool.d.ts.map +1 -0
  16. package/dist/api/ekey-tool.d.ts +8 -0
  17. package/dist/api/ekey-tool.d.ts.map +1 -0
  18. package/dist/api/extension-tool.d.ts +5 -0
  19. package/dist/api/extension-tool.d.ts.map +1 -0
  20. package/dist/api/find-tool.d.ts +6 -0
  21. package/dist/api/find-tool.d.ts.map +1 -0
  22. package/dist/api/menu-visibility.d.ts +16 -0
  23. package/dist/api/menu-visibility.d.ts.map +1 -0
  24. package/dist/api/networking-tool.d.ts +7 -0
  25. package/dist/api/networking-tool.d.ts.map +1 -0
  26. package/dist/api/page-tool.d.ts +28 -0
  27. package/dist/api/page-tool.d.ts.map +1 -0
  28. package/dist/api/pdf-formfiller.d.ts +12 -0
  29. package/dist/api/pdf-formfiller.d.ts.map +1 -0
  30. package/dist/api/review-tool.d.ts +71 -0
  31. package/dist/api/review-tool.d.ts.map +1 -0
  32. package/dist/api/sign-server.d.ts +32 -0
  33. package/dist/api/sign-server.d.ts.map +1 -0
  34. package/dist/api/sign-tool.d.ts +31 -0
  35. package/dist/api/sign-tool.d.ts.map +1 -0
  36. package/dist/api/symbology-tool.d.ts +4 -0
  37. package/dist/api/symbology-tool.d.ts.map +1 -0
  38. package/dist/api/template-sign.d.ts +88 -0
  39. package/dist/api/template-sign.d.ts.map +1 -0
  40. package/dist/api/ui-tool.d.ts +35 -0
  41. package/dist/api/ui-tool.d.ts.map +1 -0
  42. package/dist/api/watermark.d.ts +25 -0
  43. package/dist/api/watermark.d.ts.map +1 -0
  44. package/dist/index.d.ts +23 -0
  45. package/dist/index.d.ts.map +1 -0
  46. package/dist/index.js +1061 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/index.umd.cjs +2 -0
  49. package/dist/index.umd.cjs.map +1 -0
  50. package/dist/tools/DocumentToolImpl.d.ts +27 -0
  51. package/dist/tools/DocumentToolImpl.d.ts.map +1 -0
  52. package/dist/tools/FindToolImpl.d.ts +10 -0
  53. package/dist/tools/FindToolImpl.d.ts.map +1 -0
  54. package/dist/tools/NetworkingToolImpl.d.ts +10 -0
  55. package/dist/tools/NetworkingToolImpl.d.ts.map +1 -0
  56. package/dist/tools/PageToolImpl.d.ts +31 -0
  57. package/dist/tools/PageToolImpl.d.ts.map +1 -0
  58. package/dist/tools/PdfFormFillerImpl.d.ts +13 -0
  59. package/dist/tools/PdfFormFillerImpl.d.ts.map +1 -0
  60. package/dist/tools/Phase1ToolPlaceholder.d.ts +5 -0
  61. package/dist/tools/Phase1ToolPlaceholder.d.ts.map +1 -0
  62. package/dist/tools/SDKValueObjects.d.ts +55 -0
  63. package/dist/tools/SDKValueObjects.d.ts.map +1 -0
  64. package/dist/tools/UIToolImpl.d.ts +31 -0
  65. package/dist/tools/UIToolImpl.d.ts.map +1 -0
  66. package/dist/tools/index.d.ts +9 -0
  67. package/dist/tools/index.d.ts.map +1 -0
  68. package/dist/viewer/AdapterProtocol.d.ts +78 -0
  69. package/dist/viewer/AdapterProtocol.d.ts.map +1 -0
  70. package/dist/viewer/BridgeToolAdapter.d.ts +23 -0
  71. package/dist/viewer/BridgeToolAdapter.d.ts.map +1 -0
  72. package/dist/viewer/DocumentSDK.d.ts +85 -0
  73. package/dist/viewer/DocumentSDK.d.ts.map +1 -0
  74. package/dist/viewer/ReaderBridgeClient.d.ts +31 -0
  75. package/dist/viewer/ReaderBridgeClient.d.ts.map +1 -0
  76. package/dist/viewer/ReaderConfiguration.d.ts +11 -0
  77. package/dist/viewer/ReaderConfiguration.d.ts.map +1 -0
  78. package/dist/viewer/ReaderScriptLoader.d.ts +10 -0
  79. package/dist/viewer/ReaderScriptLoader.d.ts.map +1 -0
  80. package/dist/viewer/ReaderStateStore.d.ts +21 -0
  81. package/dist/viewer/ReaderStateStore.d.ts.map +1 -0
  82. package/dist/viewer/SdkCallbackRegistry.d.ts +18 -0
  83. package/dist/viewer/SdkCallbackRegistry.d.ts.map +1 -0
  84. package/dist/viewer/index.d.ts +2 -0
  85. package/dist/viewer/index.d.ts.map +1 -0
  86. package/package.json +48 -0
  87. package/src/api/annotation-tool.ts +199 -0
  88. package/src/api/callbacks.ts +59 -0
  89. package/src/api/common.ts +117 -0
  90. package/src/api/crypto-tool.ts +10 -0
  91. package/src/api/digital-sign-environment.ts +411 -0
  92. package/src/api/document-sdk.ts +152 -0
  93. package/src/api/document-tool.ts +106 -0
  94. package/src/api/ekey-tool.ts +11 -0
  95. package/src/api/extension-tool.ts +5 -0
  96. package/src/api/find-tool.ts +7 -0
  97. package/src/api/menu-visibility.ts +17 -0
  98. package/src/api/networking-tool.ts +9 -0
  99. package/src/api/page-tool.ts +56 -0
  100. package/src/api/pdf-formfiller.ts +13 -0
  101. package/src/api/review-tool.ts +105 -0
  102. package/src/api/sign-server.ts +53 -0
  103. package/src/api/sign-tool.ts +50 -0
  104. package/src/api/symbology-tool.ts +11 -0
  105. package/src/api/template-sign.ts +102 -0
  106. package/src/api/ui-tool.ts +66 -0
  107. package/src/api/watermark.ts +35 -0
  108. package/src/index.ts +22 -0
  109. package/src/tools/DocumentToolImpl.ts +158 -0
  110. package/src/tools/FindToolImpl.ts +32 -0
  111. package/src/tools/NetworkingToolImpl.ts +36 -0
  112. package/src/tools/PageToolImpl.ts +181 -0
  113. package/src/tools/PdfFormFillerImpl.ts +67 -0
  114. package/src/tools/Phase1ToolPlaceholder.ts +35 -0
  115. package/src/tools/SDKValueObjects.ts +172 -0
  116. package/src/tools/UIToolImpl.ts +145 -0
  117. package/src/tools/index.ts +8 -0
  118. package/src/viewer/AdapterProtocol.ts +114 -0
  119. package/src/viewer/BridgeToolAdapter.ts +137 -0
  120. package/src/viewer/DocumentSDK.ts +688 -0
  121. package/src/viewer/ReaderBridgeClient.ts +216 -0
  122. package/src/viewer/ReaderConfiguration.ts +59 -0
  123. package/src/viewer/ReaderScriptLoader.ts +130 -0
  124. package/src/viewer/ReaderStateStore.ts +55 -0
  125. package/src/viewer/SdkCallbackRegistry.ts +89 -0
  126. package/src/viewer/index.ts +1 -0
package/dist/index.js ADDED
@@ -0,0 +1,1061 @@
1
+ var K = /* @__PURE__ */ ((n) => (n.DEFAULT = "default", n.COMPACT = "compact", n.HIDE = "none", n))(K || {});
2
+ const w = "RIGHT_CENTER", _ = "REGULAR_ESM", F = "auto", b = "__RHC_OFFICE_DIGITAL_SIGN_ENVIRONMENT__", y = {
3
+ defaults: {
4
+ bjca: {
5
+ pin: ""
6
+ },
7
+ deviceType: "client",
8
+ edgePosition: w,
9
+ kol: {
10
+ appId: "",
11
+ appName: "",
12
+ pin: "",
13
+ serviceUrl: "",
14
+ token: ""
15
+ },
16
+ plugin: {
17
+ pin: "",
18
+ usbKeyType: 14
19
+ },
20
+ rsaMode: F,
21
+ signatureType: _
22
+ },
23
+ signServer: {
24
+ authSource: "Password",
25
+ defaultLogin: "",
26
+ defaultPassword: "",
27
+ defaultServer: "",
28
+ kol: {
29
+ appId: "",
30
+ appName: "",
31
+ serviceUrl: "",
32
+ token: ""
33
+ },
34
+ macAddress: "",
35
+ token: "",
36
+ usbKey: {
37
+ checkCertificateBinding: !1,
38
+ usbKeyType: 14
39
+ }
40
+ }
41
+ }, O = (n) => ({
42
+ bjca: {
43
+ pin: n.bjca.pin
44
+ },
45
+ deviceType: n.deviceType,
46
+ edgePosition: n.edgePosition,
47
+ kol: {
48
+ appId: n.kol.appId,
49
+ appName: n.kol.appName,
50
+ pin: n.kol.pin,
51
+ serviceUrl: n.kol.serviceUrl,
52
+ token: n.kol.token
53
+ },
54
+ plugin: {
55
+ pin: n.plugin.pin,
56
+ usbKeyType: n.plugin.usbKeyType
57
+ },
58
+ rsaMode: n.rsaMode,
59
+ signatureType: n.signatureType
60
+ }), L = (n) => ({
61
+ authSource: n.authSource,
62
+ defaultLogin: n.defaultLogin,
63
+ defaultPassword: n.defaultPassword,
64
+ defaultServer: n.defaultServer,
65
+ kol: {
66
+ appId: n.kol.appId,
67
+ appName: n.kol.appName,
68
+ serviceUrl: n.kol.serviceUrl,
69
+ token: n.kol.token
70
+ },
71
+ macAddress: n.macAddress,
72
+ token: n.token,
73
+ usbKey: {
74
+ checkCertificateBinding: n.usbKey.checkCertificateBinding,
75
+ usbKeyType: n.usbKey.usbKeyType
76
+ }
77
+ }), m = (n) => ({
78
+ defaults: O(n.defaults),
79
+ signServer: L(n.signServer)
80
+ }), N = (n) => ({
81
+ defaults: n.defaults ? {
82
+ ...n.defaults,
83
+ bjca: n.defaults.bjca ? { ...n.defaults.bjca } : void 0,
84
+ kol: n.defaults.kol ? { ...n.defaults.kol } : void 0,
85
+ plugin: n.defaults.plugin ? { ...n.defaults.plugin } : void 0
86
+ } : void 0,
87
+ signServer: n.signServer ? {
88
+ ...n.signServer,
89
+ kol: n.signServer.kol ? { ...n.signServer.kol } : void 0,
90
+ usbKey: n.signServer.usbKey ? { ...n.signServer.usbKey } : void 0
91
+ } : void 0
92
+ }), G = (n, t) => t ? {
93
+ bjca: {
94
+ pin: t.bjca?.pin ?? n.bjca.pin
95
+ },
96
+ deviceType: t.deviceType ?? n.deviceType,
97
+ edgePosition: t.edgePosition ?? n.edgePosition,
98
+ kol: {
99
+ appId: t.kol?.appId ?? n.kol.appId,
100
+ appName: t.kol?.appName ?? n.kol.appName,
101
+ pin: t.kol?.pin ?? n.kol.pin,
102
+ serviceUrl: t.kol?.serviceUrl ?? n.kol.serviceUrl,
103
+ token: t.kol?.token ?? n.kol.token
104
+ },
105
+ plugin: {
106
+ pin: t.plugin?.pin ?? n.plugin.pin,
107
+ usbKeyType: t.plugin?.usbKeyType ?? n.plugin.usbKeyType
108
+ },
109
+ rsaMode: t.rsaMode ?? n.rsaMode,
110
+ signatureType: t.signatureType ?? n.signatureType
111
+ } : O(n), H = (n, t) => t ? {
112
+ authSource: t.authSource ?? n.authSource,
113
+ defaultLogin: t.defaultLogin ?? n.defaultLogin,
114
+ defaultPassword: t.defaultPassword ?? n.defaultPassword,
115
+ defaultServer: t.defaultServer ?? n.defaultServer,
116
+ kol: {
117
+ appId: t.kol?.appId ?? n.kol.appId,
118
+ appName: t.kol?.appName ?? n.kol.appName,
119
+ serviceUrl: t.kol?.serviceUrl ?? n.kol.serviceUrl,
120
+ token: t.kol?.token ?? n.kol.token
121
+ },
122
+ macAddress: t.macAddress ?? n.macAddress,
123
+ token: t.token ?? n.token,
124
+ usbKey: {
125
+ checkCertificateBinding: t.usbKey?.checkCertificateBinding ?? n.usbKey.checkCertificateBinding,
126
+ usbKeyType: t.usbKey?.usbKeyType ?? n.usbKey.usbKeyType
127
+ }
128
+ } : L(n), U = (n, t) => ({
129
+ defaults: G(n.defaults, t.defaults),
130
+ signServer: H(n.signServer, t.signServer)
131
+ }), q = (n, t) => ({
132
+ defaults: n.defaults || t.defaults ? {
133
+ ...n.defaults,
134
+ ...t.defaults,
135
+ bjca: {
136
+ ...n.defaults?.bjca ?? {},
137
+ ...t.defaults?.bjca ?? {}
138
+ },
139
+ kol: {
140
+ ...n.defaults?.kol ?? {},
141
+ ...t.defaults?.kol ?? {}
142
+ },
143
+ plugin: {
144
+ ...n.defaults?.plugin ?? {},
145
+ ...t.defaults?.plugin ?? {}
146
+ }
147
+ } : void 0,
148
+ signServer: n.signServer || t.signServer ? {
149
+ ...n.signServer,
150
+ ...t.signServer,
151
+ kol: {
152
+ ...n.signServer?.kol ?? {},
153
+ ...t.signServer?.kol ?? {}
154
+ },
155
+ usbKey: {
156
+ ...n.signServer?.usbKey ?? {},
157
+ ...t.signServer?.usbKey ?? {}
158
+ }
159
+ } : void 0
160
+ }), Q = () => globalThis, k = () => {
161
+ const n = Q();
162
+ return n[b] || (n[b] = {
163
+ current: m(y),
164
+ defaults: m(y),
165
+ overrides: {}
166
+ }), n[b];
167
+ }, Ue = () => k().current, xe = (n) => {
168
+ const t = k();
169
+ return t.defaults = m(n), t.current = U(t.defaults, t.overrides), t.current;
170
+ }, Ve = (n) => {
171
+ const t = k();
172
+ return t.current = m(n), t.overrides = N(n), t.current;
173
+ }, Be = (n) => {
174
+ const t = k();
175
+ return t.overrides = q(t.overrides, N(n)), t.current = U(t.current, n), t.current;
176
+ }, Ke = (n) => {
177
+ const t = k();
178
+ return n && (t.defaults = m(n)), t.overrides = {}, t.current = m(t.defaults), t.current;
179
+ }, Ge = {
180
+ EDGE_POSITION: w,
181
+ RSA_MODE: F,
182
+ SIGNATURE_TYPE: _
183
+ }, T = (n) => {
184
+ if (n.length !== 0)
185
+ return n.length === 1 ? n[0] : n;
186
+ }, c = (n, t, e) => new Proxy(
187
+ {},
188
+ {
189
+ get: (i, r) => {
190
+ if (r === "then")
191
+ return;
192
+ if (typeof r == "symbol")
193
+ return r === Symbol.toStringTag ? n : void 0;
194
+ const o = t[r];
195
+ return o ? (...a) => {
196
+ if (o.kind === "callbackRegister") {
197
+ o.callback?.(e.callbacks, a);
198
+ return;
199
+ }
200
+ if (o.kind === "stateGetter")
201
+ return o.state?.(e.state.snapshot(), a);
202
+ const s = o.adapterMethod ?? r;
203
+ if (o.kind === "query")
204
+ return e.bridge.request(n, s, T(a));
205
+ if (o.kind === "callbackQuery") {
206
+ const l = a.find((d) => typeof d == "function"), p = a.filter((d) => typeof d != "function");
207
+ e.bridge.request(n, s, T(p)).then((d) => {
208
+ const f = o.mapCallbackResult?.(d) ?? [d];
209
+ l?.(...f);
210
+ }).catch(e.onAsyncError);
211
+ return;
212
+ }
213
+ e.bridge.request(n, s, T(a)).catch(e.onAsyncError);
214
+ } : (...a) => {
215
+ const s = new Error(`${n}.${r} is not implemented by the SDK adapter.`);
216
+ e.onAsyncError(s);
217
+ };
218
+ }
219
+ }
220
+ ), u = (n, t) => new Proxy(
221
+ {},
222
+ {
223
+ get: (e, i) => {
224
+ if (i !== "then" && typeof i != "symbol")
225
+ return (...r) => {
226
+ const o = `${n}.${i} is not implemented by the SDK adapter.`;
227
+ t.onAsyncError(new Error(o));
228
+ };
229
+ }
230
+ }
231
+ ), z = {
232
+ addDocumentOpenedCallback: {
233
+ kind: "callbackRegister",
234
+ callback: (n, t) => {
235
+ const e = t[0];
236
+ typeof e == "function" && n.documentOpened.push(e);
237
+ }
238
+ },
239
+ addDocumentSavedCallback: {
240
+ kind: "callbackRegister",
241
+ callback: (n, t) => {
242
+ const e = t[0];
243
+ typeof e == "function" && n.documentSaved.push(e);
244
+ }
245
+ },
246
+ addDocumentClosedCallback: {
247
+ kind: "callbackRegister",
248
+ callback: (n, t) => {
249
+ const e = t[0];
250
+ typeof e == "function" && n.documentClosed.push(e);
251
+ }
252
+ },
253
+ openPDFDocument: { kind: "callbackQuery", adapterMethod: "open" },
254
+ openPdfDocument: { kind: "callbackQuery", adapterMethod: "open" },
255
+ openOFDDocument: { kind: "callbackQuery", adapterMethod: "open" },
256
+ openOfdDocument: { kind: "callbackQuery", adapterMethod: "open" },
257
+ openOfficeDocument: { kind: "callbackQuery", adapterMethod: "open" },
258
+ openImageDocument: { kind: "callbackQuery", adapterMethod: "open" },
259
+ openTextDocument: { kind: "callbackQuery", adapterMethod: "open" },
260
+ openFromLocalStorage: { kind: "command" },
261
+ setUploadUrl: { kind: "command" },
262
+ save: { kind: "callbackQuery" },
263
+ saveAs: { kind: "query" },
264
+ getDocumentContent: {
265
+ kind: "callbackQuery",
266
+ mapCallbackResult: (n) => {
267
+ const t = n;
268
+ return [t?.fileCacheId, t?.fileBuffer];
269
+ }
270
+ },
271
+ closeDocument: { kind: "callbackQuery" },
272
+ isDocumentOpened: {
273
+ kind: "stateGetter",
274
+ state: (n) => n.documentOpened
275
+ },
276
+ isDocumentModified: {
277
+ kind: "stateGetter",
278
+ state: (n) => n.documentModified
279
+ },
280
+ print: { kind: "command" },
281
+ createPreview: { kind: "command" }
282
+ };
283
+ class W {
284
+ constructor(t) {
285
+ this.addDocumentOpenedCallback = (e) => this.adapter.addDocumentOpenedCallback(e), this.addDocumentSavedCallback = (e) => this.adapter.addDocumentSavedCallback(e), this.addDocumentClosedCallback = (e) => this.adapter.addDocumentClosedCallback(e), this.openPDFDocument = (e, i) => this.adapter.openPDFDocument(e, i), this.openPdfDocument = (e, i) => this.adapter.openPdfDocument(e, i), this.openOFDDocument = (e, i) => this.adapter.openOFDDocument(e, i), this.openOfdDocument = (e, i) => this.adapter.openOfdDocument(e, i), this.openOfficeDocument = (e, i) => this.adapter.openOfficeDocument(e, i), this.openImageDocument = (e, i) => this.adapter.openImageDocument(e, i), this.openTextDocument = (e, i) => this.adapter.openTextDocument(e, i), this.openFromLocalStorage = () => this.adapter.openFromLocalStorage(), this.setUploadUrl = (e) => this.adapter.setUploadUrl(e), this.save = (e, i, r) => this.adapter.save(e, i, r), this.saveAs = (e) => this.adapter.saveAs(e), this.getDocumentContent = (e) => this.adapter.getDocumentContent(e), this.closeDocument = (e, i, r) => this.adapter.closeDocument(e, i, r), this.isDocumentOpened = () => this.adapter.isDocumentOpened(), this.isDocumentModified = () => this.adapter.isDocumentModified(), this.print = () => this.adapter.print(), this.createPreview = (e, i) => this.adapter.createPreview(e, i), this.adapter = c(
286
+ "document",
287
+ z,
288
+ t
289
+ );
290
+ }
291
+ }
292
+ const $ = {
293
+ clearFind: { kind: "command" },
294
+ findNext: { kind: "command" },
295
+ findPrevious: { kind: "command" }
296
+ };
297
+ class j {
298
+ constructor(t) {
299
+ this.clearFind = () => this.adapter.clearFind(), this.findNext = (e) => this.adapter.findNext(e), this.findPrevious = (e) => this.adapter.findPrevious(e), this.adapter = c("find", $, t);
300
+ }
301
+ }
302
+ const Y = {
303
+ configFileUpload: { kind: "command" },
304
+ setHttpHeaders: { kind: "command" },
305
+ setHttpFormFields: { kind: "command" }
306
+ };
307
+ class X {
308
+ constructor(t) {
309
+ this.configFileUpload = (e) => this.adapter.configFileUpload(e), this.setHttpHeaders = (e) => this.adapter.setHttpHeaders(e), this.setHttpFormFields = (e) => this.adapter.setHttpFormFields(e), this.adapter = c(
310
+ "networking",
311
+ Y,
312
+ t
313
+ );
314
+ }
315
+ }
316
+ const J = (n) => ({
317
+ addPageChangeCallback: {
318
+ kind: "callbackRegister",
319
+ callback: (t, e) => {
320
+ const i = e[0];
321
+ typeof i == "function" && t.pageChange.push(i);
322
+ }
323
+ },
324
+ addPageModeChangeCallback: {
325
+ kind: "callbackRegister",
326
+ callback: (t, e) => {
327
+ const i = e[0];
328
+ typeof i == "function" && t.pageModeChange.push(i);
329
+ }
330
+ },
331
+ getPageCount: {
332
+ kind: "callbackRegister",
333
+ callback: (t, e) => {
334
+ const i = e[0];
335
+ typeof i == "function" && i(n.state.snapshot().pageCount);
336
+ }
337
+ },
338
+ getPageIndex: {
339
+ kind: "callbackRegister",
340
+ callback: (t, e) => {
341
+ const i = e[0];
342
+ typeof i == "function" && i(n.state.snapshot().pageIndex);
343
+ }
344
+ },
345
+ setSinglePageViewMode: { kind: "command" },
346
+ setTwoPagesViewMode: { kind: "command" },
347
+ setPageScrollVertical: { kind: "command" },
348
+ setPageScrollHorizontal: { kind: "command" },
349
+ setPageCursorPanDrag: { kind: "command" },
350
+ setPageCursorTextSelect: { kind: "command" },
351
+ rotateCW: { kind: "command" },
352
+ rotateCCW: { kind: "command" },
353
+ autoFitPage: { kind: "command" },
354
+ fitPageSize: { kind: "command" },
355
+ fitPageWidth: { kind: "command" },
356
+ fitPageHeight: { kind: "command" },
357
+ increasePageScale: { kind: "command" },
358
+ decreasePageScale: { kind: "command" },
359
+ setPageScale: { kind: "command" },
360
+ setPageBlendColor: { kind: "command" },
361
+ gotoPage: { kind: "command" },
362
+ gotoNextPage: { kind: "command" },
363
+ gotoPreviousPage: { kind: "command" },
364
+ rotatePage: { kind: "command" }
365
+ });
366
+ class Z {
367
+ constructor(t) {
368
+ this.addPageChangeCallback = (e) => this.adapter.addPageChangeCallback(e), this.addPageModeChangeCallback = (e) => this.adapter.addPageModeChangeCallback(e), this.getPageCount = (e) => this.adapter.getPageCount(e), this.getPageIndex = (e) => this.adapter.getPageIndex(e), this.setSinglePageViewMode = () => this.adapter.setSinglePageViewMode(), this.setTwoPagesViewMode = () => this.adapter.setTwoPagesViewMode(), this.setPageScrollVertical = () => this.adapter.setPageScrollVertical(), this.setPageScrollHorizontal = () => this.adapter.setPageScrollHorizontal(), this.setPageCursorPanDrag = () => this.adapter.setPageCursorPanDrag(), this.setPageCursorTextSelect = () => this.adapter.setPageCursorTextSelect(), this.rotateCW = () => this.adapter.rotateCW(), this.rotateCCW = () => this.adapter.rotateCCW(), this.autoFitPage = () => this.adapter.autoFitPage(), this.fitPageSize = () => this.adapter.fitPageSize(), this.fitPageWidth = () => this.adapter.fitPageWidth(), this.fitPageHeight = () => this.adapter.fitPageHeight(), this.increasePageScale = () => this.adapter.increasePageScale(), this.decreasePageScale = () => this.adapter.decreasePageScale(), this.setPageScale = (e) => this.adapter.setPageScale(e), this.setPageBlendColor = (e, i, r, o) => this.adapter.setPageBlendColor(e, i, r, o), this.gotoPage = (e, i, r) => this.adapter.gotoPage(e, i, r), this.gotoNextPage = () => this.adapter.gotoNextPage(), this.gotoPreviousPage = () => this.adapter.gotoPreviousPage(), this.rotatePage = (e) => this.adapter.rotatePage(e), this.adapter = c(
369
+ "page",
370
+ J(t),
371
+ t
372
+ );
373
+ }
374
+ }
375
+ const ee = {
376
+ open: { kind: "command" },
377
+ setFormFieldValue: { kind: "command" },
378
+ setFormFieldReadonly: { kind: "command" },
379
+ commit: {
380
+ kind: "callbackQuery",
381
+ mapCallbackResult: () => []
382
+ },
383
+ clear: {
384
+ kind: "callbackQuery",
385
+ mapCallbackResult: () => []
386
+ },
387
+ toKeyValue: {
388
+ kind: "callbackQuery",
389
+ mapCallbackResult: (n) => [Array.isArray(n) ? n : []]
390
+ }
391
+ };
392
+ class te {
393
+ constructor(t) {
394
+ this.open = () => this.adapter.open(), this.setFormFieldValue = (e, i) => this.adapter.setFormFieldValue(e, i), this.setFormFieldReadonly = (e, i) => this.adapter.setFormFieldReadonly(e, i), this.commit = (e) => this.adapter.commit(e), this.clear = (e) => this.adapter.clear(e), this.toKeyValue = (e) => this.adapter.toKeyValue(e), this.adapter = c(
395
+ "pdfFormFiller",
396
+ ee,
397
+ t
398
+ );
399
+ }
400
+ }
401
+ const ne = /\s*,\s*/, ie = /\s*-\s*/, E = (n) => {
402
+ const t = Number.parseInt(n.trim(), 10);
403
+ return !Number.isFinite(t) || t <= 0 ? null : t;
404
+ }, re = (n) => {
405
+ const t = n.split(ie);
406
+ if (t.length === 1) {
407
+ const r = E(t[0] ?? "");
408
+ return r ? [r] : [];
409
+ }
410
+ const e = E(t[0] ?? ""), i = E(t[1] ?? "");
411
+ return !e || !i || i < e ? [] : Array.from({ length: i - e + 1 }, (r, o) => e + o);
412
+ }, oe = (n) => n ? n.split(ne).flatMap((e) => re(e)).filter((e, i, r) => r.indexOf(e) === i) : [];
413
+ class ae {
414
+ constructor(t, e, i) {
415
+ this.setFieldName = (r) => {
416
+ this.key = r;
417
+ }, this.setFieldValue = (r) => {
418
+ this.value = r;
419
+ }, this.setDescription = (r) => {
420
+ this.description = r;
421
+ }, this.key = t, this.value = e, this.description = i;
422
+ }
423
+ }
424
+ class se {
425
+ constructor() {
426
+ this.fields = [], this.keywordTextFixedPositions = void 0, this.keywordOffsetX = 0, this.keywordOffsetY = 0, this.bookmarkOffsetX = 0, this.bookmarkOffsetY = 0, this.printMargin = 0, this.grayscaleSealImage = !1, this.signType = 0, this.sealPosition = 0, this.getSignType = () => this.signType, this.setSignType = (t) => {
427
+ this.signType = t;
428
+ }, this.isCrossPageSideSign = () => this.signType === 2 || this.signType === 3, this.getSealPosition = () => this.sealPosition, this.setSignOnPageSides = (t) => {
429
+ t >= 0 && t <= 3 && (this.signType = t);
430
+ }, this.setSignPositionOnPageSides = (t) => {
431
+ this.sealPosition = t;
432
+ }, this.setPageRange = (t) => {
433
+ this.pageRange = t;
434
+ }, this.getPageRange = () => this.pageRange, this.getPageRanges = () => oe(this.pageRange), this.setSignUserData = (t) => {
435
+ this.signUserData = t;
436
+ }, this.setPrintMargin = (t) => {
437
+ this.printMargin = t;
438
+ }, this.getPrintMargin = () => this.printMargin ?? 0, this.setSignReason = (t) => {
439
+ this.signReason = t;
440
+ }, this.getSignReason = () => this.signReason, this.setSignLocation = (t) => {
441
+ this.signLocation = t;
442
+ }, this.getSignLocation = () => this.signLocation, this.setDefaultStampPassword = (t) => {
443
+ this.defaultStampPassword = t;
444
+ };
445
+ }
446
+ }
447
+ const de = /* @__PURE__ */ new Set([2, 5]), le = (n) => ({
448
+ showToolbarMenu: { kind: "command" },
449
+ hideToolbarMenu: { kind: "command" },
450
+ setupToolbarMenu: { kind: "command" },
451
+ showToolbarMenuItem: { kind: "command" },
452
+ hideToolbarMenuItem: { kind: "command" },
453
+ setupRibbonMenu: { kind: "command" },
454
+ setupRibbonMenuItem: { kind: "command" },
455
+ setupRibbonTitleBar: { kind: "command" },
456
+ showRibbonMenu: { kind: "command" },
457
+ hideRibbonMenu: { kind: "command" },
458
+ showRibbonMenuItem: { kind: "command" },
459
+ hideRibbonMenuItem: { kind: "command" },
460
+ showRibbonTitleBar: { kind: "command" },
461
+ hideRibbonTitleBar: { kind: "command" },
462
+ selectRibbonMenu: { kind: "command" },
463
+ setRibbonMenuButtonStyle: { kind: "command" },
464
+ setWatermark: { kind: "command" },
465
+ setCompactMode: { kind: "command" },
466
+ enterBookViewMode: {
467
+ kind: "callbackQuery",
468
+ mapCallbackResult: () => []
469
+ },
470
+ exitBookViewMode: { kind: "command" },
471
+ isBookViewActivated: {
472
+ kind: "stateGetter",
473
+ state: () => de.has(n.state.snapshot().pageMode)
474
+ },
475
+ requestFullScreen: { kind: "command" },
476
+ exitFullScreen: { kind: "command" },
477
+ invalidateView: { kind: "command" }
478
+ });
479
+ class ce {
480
+ constructor(t) {
481
+ this.showToolbarMenu = () => this.adapter.showToolbarMenu(), this.hideToolbarMenu = () => this.adapter.hideToolbarMenu(), this.setupToolbarMenu = (e) => this.adapter.setupToolbarMenu(e), this.showToolbarMenuItem = (e) => this.adapter.showToolbarMenuItem(e), this.hideToolbarMenuItem = (e) => this.adapter.hideToolbarMenuItem(e), this.setupRibbonMenu = (e) => this.adapter.setupRibbonMenu(e), this.setupRibbonMenuItem = (e, i, r) => this.adapter.setupRibbonMenuItem(e, i, r), this.setupRibbonTitleBar = (e) => this.adapter.setupRibbonTitleBar(e), this.showRibbonMenu = () => this.adapter.showRibbonMenu(), this.hideRibbonMenu = () => this.adapter.hideRibbonMenu(), this.showRibbonMenuItem = (e, i) => this.adapter.showRibbonMenuItem(e, i), this.hideRibbonMenuItem = (e, i) => this.adapter.hideRibbonMenuItem(e, i), this.showRibbonTitleBar = () => this.adapter.showRibbonTitleBar(), this.hideRibbonTitleBar = () => this.adapter.hideRibbonTitleBar(), this.selectRibbonMenu = (e) => this.adapter.selectRibbonMenu(e), this.setRibbonMenuButtonStyle = (e, i) => this.adapter.setRibbonMenuButtonStyle(e, i), this.setWatermark = (e) => this.adapter.setWatermark(e), this.setCompactMode = (e) => this.adapter.setCompactMode(e), this.enterBookViewMode = (e) => this.adapter.enterBookViewMode(e), this.exitBookViewMode = () => this.adapter.exitBookViewMode(), this.isBookViewActivated = () => this.adapter.isBookViewActivated(), this.requestFullScreen = () => this.adapter.requestFullScreen(), this.exitFullScreen = () => this.adapter.exitFullScreen(), this.invalidateView = () => this.adapter.invalidateView(), this.adapter = c("ui", le(t), t);
482
+ }
483
+ }
484
+ const ue = (n) => {
485
+ if (!n)
486
+ return;
487
+ const t = n.trim().toLowerCase();
488
+ if (t === "application")
489
+ return "auto";
490
+ if (t === "light" || t === "dark" || t === "high-contrast" || t === "auto")
491
+ return t;
492
+ }, x = (n) => {
493
+ const t = new URL(n, globalThis.location?.href ?? "http://localhost/");
494
+ return t.hash = "", t.pathname.endsWith("/") || (t.pathname = `${t.pathname}/`), t.toString();
495
+ }, he = (n) => new URL("editors.bootstrap.js", n).toString(), me = (n, t) => {
496
+ const e = x(n);
497
+ return {
498
+ ...t,
499
+ officeServer: e,
500
+ scrollIntoView: t.scrollIntoView ?? !0,
501
+ theme: ue(t.theme)
502
+ };
503
+ }, h = "rhc-office-editor", R = "__RHC_OFFICE_SDK_READER_LOADER__", V = () => {
504
+ const n = globalThis;
505
+ return n[R] || (n[R] = {
506
+ activeAppUrl: null,
507
+ loadPromises: /* @__PURE__ */ new Map()
508
+ }), n[R];
509
+ }, pe = (n) => Array.from(document.querySelectorAll("script")).find((t) => t.src === n) ?? null;
510
+ class S extends Error {
511
+ constructor(t) {
512
+ super(`Failed to load reader bootstrap script: ${t}`), this.name = "ReaderScriptLoadError";
513
+ }
514
+ }
515
+ class ge extends Error {
516
+ constructor(t, e) {
517
+ super(
518
+ `Reader Web Component "${h}" is already bound to ${t} and cannot be reloaded from ${e}.`
519
+ ), this.name = "ReaderSourceConflictError";
520
+ }
521
+ }
522
+ const B = (n) => {
523
+ const t = V();
524
+ if (t.activeAppUrl && t.activeAppUrl !== n)
525
+ throw new ge(t.activeAppUrl, n);
526
+ }, ke = (n) => {
527
+ const t = V();
528
+ B(n);
529
+ const e = t.loadPromises.get(n);
530
+ if (e)
531
+ return e;
532
+ if (globalThis.customElements?.get(h)) {
533
+ t.activeAppUrl = n;
534
+ const a = Promise.resolve();
535
+ return t.loadPromises.set(n, a), a;
536
+ }
537
+ const i = he(n), r = pe(i);
538
+ t.activeAppUrl = n;
539
+ const o = new Promise((a, s) => {
540
+ const l = (f) => {
541
+ f?.remove(), s(new S(i));
542
+ }, p = () => {
543
+ globalThis.customElements.whenDefined(h).then(() => {
544
+ a();
545
+ }).catch(s);
546
+ };
547
+ if (r) {
548
+ if (globalThis.customElements?.get(h)) {
549
+ a();
550
+ return;
551
+ }
552
+ r.addEventListener(
553
+ "error",
554
+ () => s(new S(i)),
555
+ {
556
+ once: !0
557
+ }
558
+ ), p();
559
+ return;
560
+ }
561
+ const d = document.createElement("script");
562
+ d.src = i, d.async = !0, d.dataset.rhcOfficeSdkReader = n, d.addEventListener("load", p, { once: !0 }), d.addEventListener("error", () => l(d), { once: !0 }), document.head.appendChild(d);
563
+ }).catch((a) => {
564
+ throw t.loadPromises.delete(n), !globalThis.customElements?.get(h) && t.activeAppUrl === n && (t.activeAppUrl = null), a;
565
+ });
566
+ return t.loadPromises.set(n, o), o;
567
+ }, fe = "rhc-office.editor-adapter", be = 1, Te = "__RHC_OFFICE_EDITOR_ADAPTER__", C = "rhcOfficeAdapterReady", P = "rhcOfficeAdapterEvent", Ee = "data-rhc-office-reader-id", Re = 5e3, ve = 5e3, ye = () => {
568
+ const n = globalThis.crypto;
569
+ return typeof n?.randomUUID == "function" ? n.randomUUID() : `adapter-${Date.now()}-${Math.random().toString(36).slice(2)}`;
570
+ }, g = () => globalThis[Te];
571
+ class Se extends Error {
572
+ constructor(t, e, i) {
573
+ super(e), this.name = "ReaderBridgeError", this.code = t, this.details = i;
574
+ }
575
+ }
576
+ class Ce {
577
+ constructor(t) {
578
+ this.readerId = null, this.readyTimeoutMs = t?.readyTimeoutMs ?? ve, this.requestTimeoutMs = t?.requestTimeoutMs ?? Re;
579
+ }
580
+ configureTimeouts(t) {
581
+ this.readyTimeoutMs = t?.readyTimeoutMs ?? this.readyTimeoutMs, this.requestTimeoutMs = t?.requestTimeoutMs ?? this.requestTimeoutMs;
582
+ }
583
+ setReaderId(t) {
584
+ this.readerId = t;
585
+ }
586
+ getReaderId() {
587
+ return this.readerId;
588
+ }
589
+ async request(t, e, i, r) {
590
+ const o = await this.requestRaw(t, e, i, r);
591
+ if (o.ok)
592
+ return o.result;
593
+ throw new Se(
594
+ o.error.code,
595
+ o.error.message,
596
+ o.error.details
597
+ );
598
+ }
599
+ async requestRaw(t, e, i, r) {
600
+ if (!this.readerId)
601
+ return {
602
+ ok: !1,
603
+ requestId: "",
604
+ error: {
605
+ code: "READER_NOT_READY",
606
+ message: "Reader is not mounted."
607
+ }
608
+ };
609
+ const o = await this.waitForAdapter(this.readerId, r?.timeoutMs);
610
+ if (!o)
611
+ return {
612
+ ok: !1,
613
+ requestId: "",
614
+ error: {
615
+ code: "ADAPTER_UNAVAILABLE",
616
+ message: "Editor adapter is not available."
617
+ }
618
+ };
619
+ const a = {
620
+ protocol: fe,
621
+ version: be,
622
+ requestId: ye(),
623
+ readerId: this.readerId,
624
+ tool: t,
625
+ method: e,
626
+ params: i
627
+ };
628
+ return this.withTimeout(
629
+ o.request(a),
630
+ a.requestId,
631
+ r?.timeoutMs ?? this.requestTimeoutMs
632
+ );
633
+ }
634
+ getCapabilities() {
635
+ return this.readerId ? g()?.getCapabilities(this.readerId) ?? null : null;
636
+ }
637
+ async waitForAdapter(t, e = this.readyTimeoutMs) {
638
+ const i = g();
639
+ return i?.getCapabilities(t) ? i : new Promise((r) => {
640
+ let o;
641
+ const a = () => {
642
+ o && clearTimeout(o), globalThis.removeEventListener(C, s);
643
+ }, s = (l) => {
644
+ if ((l instanceof CustomEvent ? l.detail : void 0)?.readerId !== t)
645
+ return;
646
+ const d = g();
647
+ a(), r(d ?? null);
648
+ };
649
+ globalThis.addEventListener(C, s), o = setTimeout(() => {
650
+ a(), r(g()?.getCapabilities(t) ? g() : null);
651
+ }, e);
652
+ });
653
+ }
654
+ async withTimeout(t, e, i) {
655
+ return new Promise((r) => {
656
+ const o = setTimeout(() => {
657
+ r({
658
+ ok: !1,
659
+ requestId: e,
660
+ error: {
661
+ code: "TIMEOUT",
662
+ message: `Editor adapter request timed out after ${i}ms.`
663
+ }
664
+ });
665
+ }, i);
666
+ t.then((a) => r(a)).catch((a) => {
667
+ r({
668
+ ok: !1,
669
+ requestId: e,
670
+ error: {
671
+ code: "EXECUTION_FAILED",
672
+ message: a instanceof Error ? a.message : String(a)
673
+ }
674
+ });
675
+ }).finally(() => {
676
+ clearTimeout(o);
677
+ });
678
+ });
679
+ }
680
+ }
681
+ const A = {
682
+ annotationEnabled: !1,
683
+ documentModified: !1,
684
+ documentOpened: !1,
685
+ extensionState: "disconnected",
686
+ pageCount: 0,
687
+ pageIndex: 1,
688
+ pageMode: 0,
689
+ zoomLevel: 100
690
+ };
691
+ class Pe {
692
+ constructor() {
693
+ this.state = { ...A };
694
+ }
695
+ reset() {
696
+ this.state = { ...A };
697
+ }
698
+ update(t) {
699
+ t && (this.state = {
700
+ ...this.state,
701
+ ...t
702
+ });
703
+ }
704
+ setDocumentOpened(t) {
705
+ this.state = {
706
+ ...this.state,
707
+ documentOpened: t
708
+ };
709
+ }
710
+ snapshot() {
711
+ return { ...this.state };
712
+ }
713
+ }
714
+ class Ae {
715
+ constructor() {
716
+ this.annotationEvents = [], this.annotationPersist = [], this.annotationRetrieve = [], this.digitalAnnotationRetrieve = [], this.digitalSignatureParse = [], this.digitalSignatureRetrieve = [], this.documentClosed = [], this.documentOpened = [], this.documentSaved = [], this.extensionStateChanged = [], this.pageChange = [], this.pageModeChange = [];
717
+ }
718
+ emit(t, e) {
719
+ switch (t) {
720
+ case "documentOpened":
721
+ case "documentLoaded":
722
+ this.documentOpened.forEach((i) => i("ok", ""));
723
+ return;
724
+ case "documentSaved":
725
+ this.documentSaved.forEach((i) => i(e));
726
+ return;
727
+ case "documentClosed":
728
+ this.documentClosed.forEach((i) => i(e));
729
+ return;
730
+ case "pageChange": {
731
+ const i = e;
732
+ this.pageChange.forEach(
733
+ (r) => r(i.pageIndex ?? 1, i.pageCount ?? 0)
734
+ );
735
+ return;
736
+ }
737
+ case "pageModeChange": {
738
+ const i = e;
739
+ this.pageModeChange.forEach((r) => r(i.pageMode ?? 0));
740
+ return;
741
+ }
742
+ case "annotationEvent": {
743
+ const i = e;
744
+ this.annotationEvents.forEach(
745
+ (r) => r(i.event ?? "annotationEvent", i.payload)
746
+ );
747
+ return;
748
+ }
749
+ case "annotationPersist":
750
+ this.annotationPersist.forEach((i) => i(e));
751
+ return;
752
+ case "annotationRetrieve":
753
+ this.annotationRetrieve.forEach((i) => i(e));
754
+ return;
755
+ case "digitalAnnotationRetrieve":
756
+ this.digitalAnnotationRetrieve.forEach(
757
+ (i) => i(Array.isArray(e) ? e : [])
758
+ );
759
+ return;
760
+ case "digitalSignatureRetrieve":
761
+ this.digitalSignatureRetrieve.forEach(
762
+ (i) => i(Array.isArray(e) ? e : [])
763
+ );
764
+ return;
765
+ case "digitalSignatureParse":
766
+ this.digitalSignatureParse.forEach(
767
+ (i) => i(Array.isArray(e) ? e : [])
768
+ );
769
+ return;
770
+ case "extensionStateChanged": {
771
+ const i = e;
772
+ this.extensionStateChanged.forEach(
773
+ (r) => r(i.state ?? "disconnected")
774
+ );
775
+ return;
776
+ }
777
+ default:
778
+ return;
779
+ }
780
+ }
781
+ }
782
+ const De = [
783
+ "documentLoaded",
784
+ "documentStateChange",
785
+ "documentError"
786
+ ], Me = "readerReady", Ie = "readerUnload", v = "readerError", we = () => typeof globalThis.crypto?.randomUUID == "function" ? globalThis.crypto.randomUUID() : `rhc-reader-${Date.now()}-${Math.random().toString(36).slice(2)}`, D = (n, t) => ({
787
+ appUrl: t?.officeServer ?? null,
788
+ configuration: t,
789
+ element: n
790
+ }), _e = (n) => {
791
+ if (typeof n == "string") {
792
+ const t = document.getElementById(n);
793
+ if (!t)
794
+ throw new Error(`Reader container "${n}" was not found.`);
795
+ if (!(t instanceof HTMLDivElement))
796
+ throw new Error(`Reader container "${n}" must be a div element.`);
797
+ return t;
798
+ }
799
+ if (!(n instanceof HTMLDivElement))
800
+ throw new Error("Reader container must be a div element.");
801
+ return n;
802
+ }, Fe = () => {
803
+ const n = typeof globalThis.matchMedia == "function";
804
+ return (n ? globalThis.matchMedia("(prefers-contrast: more)").matches : !1) ? "high-contrast" : (n ? globalThis.matchMedia("(prefers-color-scheme: dark)").matches : !1) ? "dark" : "light";
805
+ }, M = (n, t) => {
806
+ const e = n;
807
+ if (typeof e.addEventListener == "function") {
808
+ e.addEventListener("change", t);
809
+ return;
810
+ }
811
+ typeof e.addListener == "function" && e.addListener(t);
812
+ }, I = (n, t) => {
813
+ const e = n;
814
+ if (typeof e.removeEventListener == "function") {
815
+ e.removeEventListener("change", t);
816
+ return;
817
+ }
818
+ typeof e.removeListener == "function" && e.removeListener(t);
819
+ }, Oe = (n, t) => {
820
+ t.style && (n.style.cssText = t.style), n.style.display || (n.style.display = "block"), n.style.width ? t.width && (n.style.width = t.width) : n.style.width = t.width ?? "100%", n.style.height ? t.height && (n.style.height = t.height) : n.style.height = t.height ?? "100%";
821
+ }, Le = (n, t) => {
822
+ const e = t.theme;
823
+ if (!e)
824
+ return n.removeAttribute("theme"), null;
825
+ if (e !== "auto")
826
+ return n.setAttribute("theme", e), null;
827
+ const i = () => {
828
+ n.setAttribute("theme", Fe());
829
+ };
830
+ if (i(), typeof globalThis.matchMedia != "function")
831
+ return null;
832
+ const r = globalThis.matchMedia("(prefers-color-scheme: dark)"), o = globalThis.matchMedia("(prefers-contrast: more)"), a = () => {
833
+ i();
834
+ };
835
+ return M(r, a), M(o, a), () => {
836
+ I(r, a), I(o, a);
837
+ };
838
+ };
839
+ class Ne {
840
+ constructor(t) {
841
+ this.bridge = new Ce(), this.callbacks = new Ae(), this.readerState = new Pe(), this.bridgeToolContext = {
842
+ bridge: this.bridge,
843
+ callbacks: this.callbacks,
844
+ debug: () => this.debugEnabled,
845
+ onAsyncError: (e) => this.reportAdapterError(e),
846
+ state: this.readerState
847
+ }, this.documentTool = new W(this.bridgeToolContext), this.uiTool = new ce(this.bridgeToolContext), this.pageTool = new Z(this.bridgeToolContext), this.findTool = new j(this.bridgeToolContext), this.signServerTool = u(
848
+ "signServer",
849
+ this.bridgeToolContext
850
+ ), this.digitalSignTool = u(
851
+ "digitalSign",
852
+ this.bridgeToolContext
853
+ ), this.reviewTool = u(
854
+ "review",
855
+ this.bridgeToolContext
856
+ ), this.ekeyTool = u(
857
+ "ekey",
858
+ this.bridgeToolContext
859
+ ), this.symbologyTool = u(
860
+ "symbology",
861
+ this.bridgeToolContext
862
+ ), this.annotationTool = this.createAnnotationTool(), this.templateSignTool = u(
863
+ "templateSign",
864
+ this.bridgeToolContext
865
+ ), this.pdfFormFiller = new te(this.bridgeToolContext), this.extensionTool = this.createExtensionTool(), this.networkingTool = new X(this.bridgeToolContext), this.cryptoTool = u(
866
+ "crypto",
867
+ this.bridgeToolContext
868
+ ), this.readyCallbacks = [], this.unloadCallbacks = [], this.debugEnabled = !1, this.isReady = !1, this.removed = !1, this.mountToken = 0, this.hostContainer = null, this.readerElement = null, this.readerId = null, this.normalizedConfiguration = null, this.nativeEventCleanupCallbacks = [], this.themeCleanup = null, this.enableDebug = (e) => {
869
+ this.debugEnabled = e;
870
+ }, this.changeLanguage = () => {
871
+ }, this.setLicense = (e, i) => {
872
+ this.license = { license: e, feature: i };
873
+ }, this.setSessionUser = (e) => {
874
+ this.sessionUser = e;
875
+ }, this.setSessionUserId = (e) => {
876
+ if (typeof this.sessionUser == "string" || !this.sessionUser) {
877
+ this.sessionUser = {
878
+ userName: typeof this.sessionUser == "string" ? this.sessionUser : "",
879
+ userId: e
880
+ };
881
+ return;
882
+ }
883
+ this.sessionUser = {
884
+ ...this.sessionUser,
885
+ userId: e
886
+ };
887
+ }, this.setSessionData = (e) => {
888
+ this.sessionData = e;
889
+ }, this.isReaderReady = () => this.isReady, this.isReaderDestroyed = () => this.removed && !this.isReady, this.addReaderReadyCallback = (e) => {
890
+ this.readyCallbacks.push(e);
891
+ }, this.addReaderUnloadCallback = (e) => {
892
+ this.unloadCallbacks.push(e);
893
+ }, this.setReaderEventListener = (e) => {
894
+ this.readerEventListener = e;
895
+ }, this.embedReader = (e, i, r) => {
896
+ const o = _e(e), a = x(i);
897
+ B(a);
898
+ const s = me(a, r), l = this.mountToken + 1;
899
+ this.removeReader(), this.mountToken = l, this.removed = !1, this.hostContainer = o, this.normalizedConfiguration = s, this.mountReader(o, s, l);
900
+ }, this.removeReader = () => {
901
+ const e = !!(this.readerElement || this.hostContainer);
902
+ if (this.mountToken += 1, this.cleanupNativeEventForwarders(), this.cleanupThemeBinding(), this.readerElement?.parentNode && this.readerElement.parentNode.removeChild(this.readerElement), this.readerElement = null, this.readerId = null, this.bridge.setReaderId(null), this.readerState.reset(), this.hostContainer = null, this.normalizedConfiguration = null, this.isReady = !1, this.removed = !0, !e)
903
+ return;
904
+ const i = D(null, null);
905
+ this.emitReaderEvent(Ie, i), this.unloadCallbacks.forEach((r) => r());
906
+ }, this.getDocumentTool = () => this.documentTool, this.getUITool = () => this.uiTool, this.getPageTool = () => this.pageTool, this.getFindTool = () => this.findTool, this.getSignServerTool = () => this.signServerTool, this.getDigitalSignTool = () => this.digitalSignTool, this.getReviewTool = () => this.reviewTool, this.getEkeyTool = () => this.ekeyTool, this.getSymbologyTool = () => this.symbologyTool, this.getAnnotationTool = () => this.annotationTool, this.getTemplateSignTool = () => this.templateSignTool, this.getPdfFormFiller = () => this.pdfFormFiller, this.getExtensionTool = () => this.extensionTool, this.getNetworkingTool = () => this.networkingTool, this.getCryptoTool = () => this.cryptoTool, this.createDigitalSignOptions = () => new se(), this.createKVField = (e, i, r) => new ae(e, i, r), this.mountReader = async (e, i, r) => {
907
+ try {
908
+ if (await ke(i.officeServer), this.mountToken !== r)
909
+ return;
910
+ const o = document.createElement(h), a = we();
911
+ if (o.setAttribute(Ee, a), this.readerId = a, this.bridge.setReaderId(a), Oe(o, i), this.themeCleanup = Le(o, i), this.bindNativeReaderEvents(o), e.replaceChildren(o), this.readerElement = o, await Promise.resolve(), this.mountToken !== r)
912
+ return;
913
+ i.scrollIntoView && typeof e.scrollIntoView == "function" && e.scrollIntoView({ behavior: "smooth", block: "nearest" }), this.isReady = !0;
914
+ const s = D(o, i);
915
+ this.emitReaderEvent(Me, s), this.readyCallbacks.forEach((l) => l());
916
+ } catch (o) {
917
+ if (this.mountToken !== r)
918
+ return;
919
+ this.reportReaderError(o);
920
+ }
921
+ }, this.bindNativeReaderEvents = (e) => {
922
+ this.cleanupNativeEventForwarders();
923
+ const i = (r) => {
924
+ const o = r instanceof CustomEvent ? r.detail : null;
925
+ !o || o.readerId !== this.readerId || (this.readerState.update(o.statePatch), this.callbacks.emit(o.event, o.payload), this.emitReaderEvent(o.event, o.payload));
926
+ };
927
+ e.addEventListener(P, i), this.nativeEventCleanupCallbacks.push(() => {
928
+ e.removeEventListener(
929
+ P,
930
+ i
931
+ );
932
+ }), De.forEach((r) => {
933
+ const o = (a) => {
934
+ const s = a instanceof CustomEvent ? a.detail : a;
935
+ r === "documentLoaded" && this.readerState.setDocumentOpened(!0), this.emitReaderEvent(r, s), r === "documentError" && this.emitReaderEvent(v, s);
936
+ };
937
+ e.addEventListener(r, o), this.nativeEventCleanupCallbacks.push(() => {
938
+ e.removeEventListener(r, o);
939
+ });
940
+ });
941
+ }, this.cleanupNativeEventForwarders = () => {
942
+ this.nativeEventCleanupCallbacks.splice(0).forEach((e) => e());
943
+ }, this.cleanupThemeBinding = () => {
944
+ this.themeCleanup?.(), this.themeCleanup = null;
945
+ }, this.emitReaderEvent = (e, i) => {
946
+ this.readerEventListener?.(e, i);
947
+ }, this.reportReaderError = (e) => {
948
+ this.isReady = !1, this.debugEnabled && console.error("[RHC Office SDK] Reader mount failed", e), this.emitReaderEvent(v, e);
949
+ }, this.reportAdapterError = (e) => {
950
+ this.debugEnabled && console.error("[RHC Office SDK] Adapter command failed", e), this.emitReaderEvent(v, e);
951
+ }, this.bridge.configureTimeouts({
952
+ readyTimeoutMs: t?.adapterReadyTimeoutMs,
953
+ requestTimeoutMs: t?.adapterRequestTimeoutMs
954
+ });
955
+ }
956
+ createAnnotationTool() {
957
+ return c(
958
+ "annotation",
959
+ {
960
+ addAnnotationEventCallback: {
961
+ kind: "callbackRegister",
962
+ callback: (t, e) => {
963
+ const i = e[0];
964
+ typeof i == "function" && t.annotationEvents.push(i);
965
+ }
966
+ },
967
+ addAnnotationPersistCallback: {
968
+ kind: "callbackRegister",
969
+ callback: (t, e) => {
970
+ const i = e[0];
971
+ typeof i == "function" && t.annotationPersist.push(i);
972
+ }
973
+ },
974
+ addAnnotationRetrieveCallback: {
975
+ kind: "callbackRegister",
976
+ callback: (t, e) => {
977
+ const i = e[0];
978
+ typeof i == "function" && t.annotationRetrieve.push(i);
979
+ }
980
+ },
981
+ addDigitalAnnotationRetrieveCallback: {
982
+ kind: "callbackRegister",
983
+ callback: (t, e) => {
984
+ const i = e[0];
985
+ typeof i == "function" && t.digitalAnnotationRetrieve.push(
986
+ i
987
+ );
988
+ }
989
+ },
990
+ isInAnnotationMode: {
991
+ kind: "stateGetter",
992
+ state: (t) => t.annotationEnabled
993
+ },
994
+ getAnnotations: { kind: "stateGetter", state: () => [] },
995
+ getAnnotationsCount: { kind: "stateGetter", state: () => 0 },
996
+ queryAnnotationsBy: { kind: "stateGetter", state: () => [] },
997
+ setToolSource: { kind: "command" },
998
+ openAnnotationView: { kind: "command" },
999
+ closeAnnotationView: { kind: "command" },
1000
+ openTextAnnotationView: { kind: "command" },
1001
+ setTextAnnotationFontColor: { kind: "command" },
1002
+ setTextAnnotationFontSize: { kind: "command" },
1003
+ closeTextAnnotationView: { kind: "command" },
1004
+ createTextAnnotation: { kind: "command" },
1005
+ setPersistToDocument: { kind: "command" },
1006
+ saveAnnotations: { kind: "callbackQuery" },
1007
+ saveTextAnnotations: { kind: "command" },
1008
+ clearAnnotations: { kind: "command" },
1009
+ clearTextAnnotations: { kind: "command" },
1010
+ undoAnnotation: { kind: "command" },
1011
+ redoAnnotation: { kind: "command" },
1012
+ selectAnnotationTool: { kind: "command" },
1013
+ showAnnotationColorPicker: { kind: "command" },
1014
+ setAnnotationPenType: { kind: "command" },
1015
+ appendAnnotations: { kind: "callbackQuery" },
1016
+ batchAppendAnnotations: { kind: "callbackQuery" },
1017
+ setAnnotationPenColor: { kind: "command" },
1018
+ setAnnotationPenWidth: { kind: "command" },
1019
+ setAnnotationPenThickness: { kind: "command" },
1020
+ enableAnnotationsInfoView: { kind: "command" },
1021
+ enableAnnotationsDeletion: { kind: "command" },
1022
+ enableAnnotationsDeletionOnlyByAuthor: { kind: "command" },
1023
+ listDigitalStamps: { kind: "command" },
1024
+ listAnnotations: { kind: "command" },
1025
+ deleteAnnotationsBy: { kind: "command" },
1026
+ deleteAnnotationsById: { kind: "command" },
1027
+ addDigitalAnnotation: { kind: "command" },
1028
+ addInkAnnotationCallback: { kind: "callbackRegister" }
1029
+ },
1030
+ this.bridgeToolContext
1031
+ );
1032
+ }
1033
+ createExtensionTool() {
1034
+ return c(
1035
+ "extension",
1036
+ {
1037
+ addExtensionStateChangedCallback: {
1038
+ kind: "callbackRegister",
1039
+ callback: (t, e) => {
1040
+ const i = e[0];
1041
+ typeof i == "function" && t.extensionStateChanged.push(i);
1042
+ }
1043
+ }
1044
+ },
1045
+ this.bridgeToolContext
1046
+ );
1047
+ }
1048
+ }
1049
+ const He = (n) => new Ne(n);
1050
+ export {
1051
+ Ge as DIGITAL_SIGN_DEFAULTS,
1052
+ Ne as DocumentSDK,
1053
+ K as WatermarkDisplay,
1054
+ He as createNewDocumentSdk,
1055
+ Ue as getDigitalSignEnvironment,
1056
+ xe as initializeDigitalSignEnvironment,
1057
+ Be as patchDigitalSignEnvironment,
1058
+ Ke as resetDigitalSignEnvironment,
1059
+ Ve as setDigitalSignEnvironment
1060
+ };
1061
+ //# sourceMappingURL=index.js.map