pdfjs-dist 2.1.266 → 2.5.207

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.

Potentially problematic release.


This version of pdfjs-dist might be problematic. Click here for more details.

Files changed (191) hide show
  1. package/CODE_OF_CONDUCT.md +15 -0
  2. package/README.md +4 -0
  3. package/bower.json +1 -1
  4. package/build/pdf.js +8382 -18492
  5. package/build/pdf.js.map +1 -1
  6. package/build/pdf.min.js +22 -1
  7. package/build/pdf.worker.entry.js +5 -3
  8. package/build/pdf.worker.js +20417 -29816
  9. package/build/pdf.worker.js.map +1 -1
  10. package/build/pdf.worker.min.js +22 -1
  11. package/es5/build/pdf.js +25688 -0
  12. package/es5/build/pdf.js.map +1 -0
  13. package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
  14. package/es5/build/pdf.worker.js +58239 -0
  15. package/es5/build/pdf.worker.js.map +1 -0
  16. package/es5/web/images/annotation-check.svg +11 -0
  17. package/es5/web/images/annotation-comment.svg +16 -0
  18. package/es5/web/images/annotation-help.svg +26 -0
  19. package/es5/web/images/annotation-insert.svg +10 -0
  20. package/es5/web/images/annotation-key.svg +11 -0
  21. package/es5/web/images/annotation-newparagraph.svg +11 -0
  22. package/es5/web/images/annotation-noicon.svg +7 -0
  23. package/es5/web/images/annotation-note.svg +42 -0
  24. package/es5/web/images/annotation-paragraph.svg +16 -0
  25. package/es5/web/images/loading-icon.gif +0 -0
  26. package/es5/web/images/shadow.png +0 -0
  27. package/es5/web/images/texture.png +0 -0
  28. package/es5/web/pdf_viewer.css +403 -0
  29. package/es5/web/pdf_viewer.js +7742 -0
  30. package/es5/web/pdf_viewer.js.map +1 -0
  31. package/image_decoders/pdf.image_decoders.js +1475 -4897
  32. package/image_decoders/pdf.image_decoders.js.map +1 -1
  33. package/image_decoders/pdf.image_decoders.min.js +22 -1
  34. package/lib/README.md +7 -0
  35. package/lib/core/annotation.js +750 -899
  36. package/lib/core/arithmetic_decoder.js +81 -97
  37. package/lib/core/bidi.js +54 -46
  38. package/lib/core/ccitt.js +88 -81
  39. package/lib/core/ccitt_stream.js +15 -14
  40. package/lib/core/cff_parser.js +235 -183
  41. package/lib/core/charsets.js +4 -4
  42. package/lib/core/chunked_stream.js +447 -542
  43. package/lib/core/cmap.js +222 -264
  44. package/lib/core/colorspace.js +699 -863
  45. package/lib/core/core_utils.js +152 -0
  46. package/lib/core/crypto.js +379 -437
  47. package/lib/core/document.js +573 -660
  48. package/lib/core/encodings.js +15 -15
  49. package/lib/core/evaluator.js +1103 -868
  50. package/lib/core/font_renderer.js +135 -178
  51. package/lib/core/fonts.js +570 -491
  52. package/lib/core/function.js +291 -288
  53. package/lib/core/glyphlist.js +4527 -4526
  54. package/lib/core/image.js +145 -149
  55. package/lib/core/image_utils.js +170 -0
  56. package/lib/core/jbig2.js +325 -316
  57. package/lib/core/jbig2_stream.js +18 -17
  58. package/lib/core/jpeg_stream.js +21 -26
  59. package/lib/core/jpg.js +284 -232
  60. package/lib/core/jpx.js +161 -143
  61. package/lib/core/jpx_stream.js +28 -28
  62. package/lib/core/metrics.js +2929 -2929
  63. package/lib/core/murmurhash3.js +90 -101
  64. package/lib/core/obj.js +1183 -1157
  65. package/lib/core/operator_list.js +99 -67
  66. package/lib/core/parser.js +972 -911
  67. package/lib/core/pattern.js +87 -70
  68. package/lib/core/pdf_manager.js +150 -315
  69. package/lib/core/primitives.js +83 -56
  70. package/lib/core/ps_parser.js +175 -214
  71. package/lib/core/standard_fonts.js +237 -236
  72. package/lib/core/stream.js +94 -74
  73. package/lib/core/type1_parser.js +87 -69
  74. package/lib/core/unicode.js +1654 -1654
  75. package/lib/core/worker.js +193 -390
  76. package/lib/core/worker_stream.js +168 -0
  77. package/lib/display/annotation_layer.js +741 -972
  78. package/lib/display/api.js +1500 -1791
  79. package/lib/display/api_compatibility.js +12 -17
  80. package/lib/display/canvas.js +165 -165
  81. package/lib/display/content_disposition.js +40 -59
  82. package/lib/display/display_utils.js +515 -0
  83. package/lib/display/fetch_stream.js +183 -298
  84. package/lib/display/font_loader.js +273 -413
  85. package/lib/display/metadata.js +86 -98
  86. package/lib/display/network.js +266 -359
  87. package/lib/display/network_utils.js +25 -18
  88. package/lib/display/node_stream.js +285 -458
  89. package/lib/display/pattern_helper.js +113 -65
  90. package/lib/display/svg.js +1166 -901
  91. package/lib/display/text_layer.js +156 -132
  92. package/lib/display/transport_stream.js +262 -278
  93. package/lib/display/webgl.js +70 -83
  94. package/lib/display/worker_options.js +3 -3
  95. package/lib/display/xml_parser.js +303 -392
  96. package/lib/examples/node/domstubs.js +40 -37
  97. package/lib/pdf.js +226 -59
  98. package/lib/pdf.worker.js +14 -6
  99. package/lib/shared/compatibility.js +3 -246
  100. package/lib/shared/is_node.js +7 -6
  101. package/lib/shared/message_handler.js +327 -332
  102. package/lib/shared/util.js +266 -416
  103. package/lib/test/unit/annotation_spec.js +1555 -701
  104. package/lib/test/unit/api_spec.js +802 -604
  105. package/lib/test/unit/bidi_spec.js +7 -7
  106. package/lib/test/unit/cff_parser_spec.js +84 -69
  107. package/lib/test/unit/clitests_helper.js +7 -9
  108. package/lib/test/unit/cmap_spec.js +74 -76
  109. package/lib/test/unit/colorspace_spec.js +166 -161
  110. package/lib/test/unit/core_utils_spec.js +211 -0
  111. package/lib/test/unit/crypto_spec.js +181 -181
  112. package/lib/test/unit/custom_spec.js +20 -22
  113. package/lib/test/unit/display_svg_spec.js +34 -39
  114. package/lib/test/unit/display_utils_spec.js +263 -0
  115. package/lib/test/unit/document_spec.js +16 -21
  116. package/lib/test/unit/encodings_spec.js +12 -34
  117. package/lib/test/unit/evaluator_spec.js +83 -83
  118. package/lib/test/unit/fetch_stream_spec.js +111 -0
  119. package/lib/test/unit/function_spec.js +206 -204
  120. package/lib/test/unit/jasmine-boot.js +46 -30
  121. package/lib/test/unit/message_handler_spec.js +173 -159
  122. package/lib/test/unit/metadata_spec.js +69 -69
  123. package/lib/test/unit/murmurhash3_spec.js +12 -12
  124. package/lib/test/unit/network_spec.js +13 -61
  125. package/lib/test/unit/network_utils_spec.js +183 -119
  126. package/lib/test/unit/node_stream_spec.js +78 -92
  127. package/lib/test/unit/parser_spec.js +172 -114
  128. package/lib/test/unit/pdf_find_controller_spec.js +55 -86
  129. package/lib/test/unit/pdf_find_utils_spec.js +32 -32
  130. package/lib/test/unit/pdf_history_spec.js +32 -32
  131. package/lib/test/unit/primitives_spec.js +140 -125
  132. package/lib/test/unit/stream_spec.js +16 -14
  133. package/lib/test/unit/test_utils.js +131 -143
  134. package/lib/test/unit/testreporter.js +19 -19
  135. package/lib/test/unit/type1_parser_spec.js +42 -42
  136. package/lib/test/unit/ui_utils_spec.js +297 -459
  137. package/lib/test/unit/unicode_spec.js +38 -38
  138. package/lib/test/unit/util_spec.js +121 -305
  139. package/lib/web/annotation_layer_builder.js +66 -103
  140. package/lib/web/app.js +1328 -1214
  141. package/lib/web/app_options.js +105 -107
  142. package/lib/web/base_viewer.js +824 -838
  143. package/lib/web/chromecom.js +165 -252
  144. package/lib/web/debugger.js +149 -205
  145. package/lib/web/download_manager.js +39 -55
  146. package/lib/web/firefox_print_service.js +37 -27
  147. package/lib/web/firefoxcom.js +212 -363
  148. package/lib/web/genericcom.js +26 -108
  149. package/lib/web/genericl10n.js +24 -153
  150. package/lib/web/grab_to_pan.js +32 -30
  151. package/lib/web/interfaces.js +80 -254
  152. package/lib/web/overlay_manager.js +70 -246
  153. package/lib/web/password_prompt.js +38 -64
  154. package/lib/web/pdf_attachment_viewer.js +113 -131
  155. package/lib/web/pdf_cursor_tools.js +75 -102
  156. package/lib/web/pdf_document_properties.js +221 -306
  157. package/lib/web/pdf_find_bar.js +136 -170
  158. package/lib/web/pdf_find_controller.js +491 -548
  159. package/lib/web/pdf_find_utils.js +13 -13
  160. package/lib/web/pdf_history.js +397 -406
  161. package/lib/web/pdf_link_service.js +304 -348
  162. package/lib/web/pdf_outline_viewer.js +140 -175
  163. package/lib/web/pdf_page_view.js +452 -523
  164. package/lib/web/pdf_presentation_mode.js +308 -357
  165. package/lib/web/pdf_print_service.js +90 -104
  166. package/lib/web/pdf_rendering_queue.js +84 -108
  167. package/lib/web/pdf_sidebar.js +276 -306
  168. package/lib/web/pdf_sidebar_resizer.js +92 -119
  169. package/lib/web/pdf_single_page_viewer.js +77 -126
  170. package/lib/web/pdf_thumbnail_view.js +276 -297
  171. package/lib/web/pdf_thumbnail_viewer.js +186 -206
  172. package/lib/web/pdf_viewer.component.js +20 -21
  173. package/lib/web/pdf_viewer.js +55 -115
  174. package/lib/web/preferences.js +82 -286
  175. package/lib/web/secondary_toolbar.js +164 -196
  176. package/lib/web/text_layer_builder.js +282 -339
  177. package/lib/web/toolbar.js +217 -210
  178. package/lib/web/ui_utils.js +267 -420
  179. package/lib/web/view_history.js +52 -226
  180. package/lib/web/viewer_compatibility.js +21 -6
  181. package/package.json +2 -9
  182. package/web/pdf_viewer.css +35 -25
  183. package/web/pdf_viewer.js +3489 -4855
  184. package/web/pdf_viewer.js.map +1 -1
  185. package/webpack.js +14 -5
  186. package/external/streams/streams-lib.js +0 -3962
  187. package/external/url/url-lib.js +0 -627
  188. package/lib/display/dom_utils.js +0 -494
  189. package/lib/shared/streams_polyfill.js +0 -43
  190. package/lib/shared/url_polyfill.js +0 -56
  191. package/lib/test/unit/dom_utils_spec.js +0 -89
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2018 Mozilla Foundation
5
+ * Copyright 2020 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -26,130 +26,97 @@ Object.defineProperty(exports, "__esModule", {
26
26
  });
27
27
  exports.AnnotationLayer = void 0;
28
28
 
29
- var _dom_utils = require("./dom_utils");
29
+ var _display_utils = require("./display_utils.js");
30
30
 
31
- var _util = require("../shared/util");
31
+ var _util = require("../shared/util.js");
32
32
 
33
- function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
33
+ class AnnotationElementFactory {
34
+ static create(parameters) {
35
+ const subtype = parameters.data.annotationType;
34
36
 
35
- function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
37
+ switch (subtype) {
38
+ case _util.AnnotationType.LINK:
39
+ return new LinkAnnotationElement(parameters);
36
40
 
37
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
41
+ case _util.AnnotationType.TEXT:
42
+ return new TextAnnotationElement(parameters);
38
43
 
39
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
44
+ case _util.AnnotationType.WIDGET:
45
+ const fieldType = parameters.data.fieldType;
40
46
 
41
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
47
+ switch (fieldType) {
48
+ case "Tx":
49
+ return new TextWidgetAnnotationElement(parameters);
42
50
 
43
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
51
+ case "Btn":
52
+ if (parameters.data.radioButton) {
53
+ return new RadioButtonWidgetAnnotationElement(parameters);
54
+ } else if (parameters.data.checkBox) {
55
+ return new CheckboxWidgetAnnotationElement(parameters);
56
+ }
44
57
 
45
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
58
+ return new PushButtonWidgetAnnotationElement(parameters);
46
59
 
47
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
48
-
49
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
50
-
51
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
52
-
53
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
54
-
55
- var AnnotationElementFactory =
56
- /*#__PURE__*/
57
- function () {
58
- function AnnotationElementFactory() {
59
- _classCallCheck(this, AnnotationElementFactory);
60
- }
61
-
62
- _createClass(AnnotationElementFactory, null, [{
63
- key: "create",
64
- value: function create(parameters) {
65
- var subtype = parameters.data.annotationType;
66
-
67
- switch (subtype) {
68
- case _util.AnnotationType.LINK:
69
- return new LinkAnnotationElement(parameters);
70
-
71
- case _util.AnnotationType.TEXT:
72
- return new TextAnnotationElement(parameters);
73
-
74
- case _util.AnnotationType.WIDGET:
75
- var fieldType = parameters.data.fieldType;
76
-
77
- switch (fieldType) {
78
- case 'Tx':
79
- return new TextWidgetAnnotationElement(parameters);
80
-
81
- case 'Btn':
82
- if (parameters.data.radioButton) {
83
- return new RadioButtonWidgetAnnotationElement(parameters);
84
- } else if (parameters.data.checkBox) {
85
- return new CheckboxWidgetAnnotationElement(parameters);
86
- }
60
+ case "Ch":
61
+ return new ChoiceWidgetAnnotationElement(parameters);
62
+ }
87
63
 
88
- return new PushButtonWidgetAnnotationElement(parameters);
64
+ return new WidgetAnnotationElement(parameters);
89
65
 
90
- case 'Ch':
91
- return new ChoiceWidgetAnnotationElement(parameters);
92
- }
66
+ case _util.AnnotationType.POPUP:
67
+ return new PopupAnnotationElement(parameters);
93
68
 
94
- return new WidgetAnnotationElement(parameters);
69
+ case _util.AnnotationType.FREETEXT:
70
+ return new FreeTextAnnotationElement(parameters);
95
71
 
96
- case _util.AnnotationType.POPUP:
97
- return new PopupAnnotationElement(parameters);
72
+ case _util.AnnotationType.LINE:
73
+ return new LineAnnotationElement(parameters);
98
74
 
99
- case _util.AnnotationType.LINE:
100
- return new LineAnnotationElement(parameters);
75
+ case _util.AnnotationType.SQUARE:
76
+ return new SquareAnnotationElement(parameters);
101
77
 
102
- case _util.AnnotationType.SQUARE:
103
- return new SquareAnnotationElement(parameters);
78
+ case _util.AnnotationType.CIRCLE:
79
+ return new CircleAnnotationElement(parameters);
104
80
 
105
- case _util.AnnotationType.CIRCLE:
106
- return new CircleAnnotationElement(parameters);
81
+ case _util.AnnotationType.POLYLINE:
82
+ return new PolylineAnnotationElement(parameters);
107
83
 
108
- case _util.AnnotationType.POLYLINE:
109
- return new PolylineAnnotationElement(parameters);
84
+ case _util.AnnotationType.CARET:
85
+ return new CaretAnnotationElement(parameters);
110
86
 
111
- case _util.AnnotationType.INK:
112
- return new InkAnnotationElement(parameters);
87
+ case _util.AnnotationType.INK:
88
+ return new InkAnnotationElement(parameters);
113
89
 
114
- case _util.AnnotationType.POLYGON:
115
- return new PolygonAnnotationElement(parameters);
90
+ case _util.AnnotationType.POLYGON:
91
+ return new PolygonAnnotationElement(parameters);
116
92
 
117
- case _util.AnnotationType.HIGHLIGHT:
118
- return new HighlightAnnotationElement(parameters);
93
+ case _util.AnnotationType.HIGHLIGHT:
94
+ return new HighlightAnnotationElement(parameters);
119
95
 
120
- case _util.AnnotationType.UNDERLINE:
121
- return new UnderlineAnnotationElement(parameters);
96
+ case _util.AnnotationType.UNDERLINE:
97
+ return new UnderlineAnnotationElement(parameters);
122
98
 
123
- case _util.AnnotationType.SQUIGGLY:
124
- return new SquigglyAnnotationElement(parameters);
99
+ case _util.AnnotationType.SQUIGGLY:
100
+ return new SquigglyAnnotationElement(parameters);
125
101
 
126
- case _util.AnnotationType.STRIKEOUT:
127
- return new StrikeOutAnnotationElement(parameters);
102
+ case _util.AnnotationType.STRIKEOUT:
103
+ return new StrikeOutAnnotationElement(parameters);
128
104
 
129
- case _util.AnnotationType.STAMP:
130
- return new StampAnnotationElement(parameters);
105
+ case _util.AnnotationType.STAMP:
106
+ return new StampAnnotationElement(parameters);
131
107
 
132
- case _util.AnnotationType.FILEATTACHMENT:
133
- return new FileAttachmentAnnotationElement(parameters);
108
+ case _util.AnnotationType.FILEATTACHMENT:
109
+ return new FileAttachmentAnnotationElement(parameters);
134
110
 
135
- default:
136
- return new AnnotationElement(parameters);
137
- }
111
+ default:
112
+ return new AnnotationElement(parameters);
138
113
  }
139
- }]);
140
-
141
- return AnnotationElementFactory;
142
- }();
143
-
144
- var AnnotationElement =
145
- /*#__PURE__*/
146
- function () {
147
- function AnnotationElement(parameters) {
148
- var isRenderable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
149
- var ignoreBorder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
114
+ }
150
115
 
151
- _classCallCheck(this, AnnotationElement);
116
+ }
152
117
 
118
+ class AnnotationElement {
119
+ constructor(parameters, isRenderable = false, ignoreBorder = false) {
153
120
  this.isRenderable = isRenderable;
154
121
  this.data = parameters.data;
155
122
  this.layer = parameters.layer;
@@ -166,1117 +133,919 @@ function () {
166
133
  }
167
134
  }
168
135
 
169
- _createClass(AnnotationElement, [{
170
- key: "_createContainer",
171
- value: function _createContainer() {
172
- var ignoreBorder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
173
- var data = this.data,
136
+ _createContainer(ignoreBorder = false) {
137
+ const data = this.data,
174
138
  page = this.page,
175
139
  viewport = this.viewport;
176
- var container = document.createElement('section');
177
- var width = data.rect[2] - data.rect[0];
178
- var height = data.rect[3] - data.rect[1];
179
- container.setAttribute('data-annotation-id', data.id);
140
+ const container = document.createElement("section");
141
+ let width = data.rect[2] - data.rect[0];
142
+ let height = data.rect[3] - data.rect[1];
143
+ container.setAttribute("data-annotation-id", data.id);
180
144
 
181
- var rect = _util.Util.normalizeRect([data.rect[0], page.view[3] - data.rect[1] + page.view[1], data.rect[2], page.view[3] - data.rect[3] + page.view[1]]);
145
+ const rect = _util.Util.normalizeRect([data.rect[0], page.view[3] - data.rect[1] + page.view[1], data.rect[2], page.view[3] - data.rect[3] + page.view[1]]);
182
146
 
183
- container.style.transform = 'matrix(' + viewport.transform.join(',') + ')';
184
- container.style.transformOrigin = -rect[0] + 'px ' + -rect[1] + 'px';
147
+ container.style.transform = `matrix(${viewport.transform.join(",")})`;
148
+ container.style.transformOrigin = `-${rect[0]}px -${rect[1]}px`;
185
149
 
186
- if (!ignoreBorder && data.borderStyle.width > 0) {
187
- container.style.borderWidth = data.borderStyle.width + 'px';
150
+ if (!ignoreBorder && data.borderStyle.width > 0) {
151
+ container.style.borderWidth = `${data.borderStyle.width}px`;
188
152
 
189
- if (data.borderStyle.style !== _util.AnnotationBorderStyleType.UNDERLINE) {
190
- width = width - 2 * data.borderStyle.width;
191
- height = height - 2 * data.borderStyle.width;
192
- }
193
-
194
- var horizontalRadius = data.borderStyle.horizontalCornerRadius;
195
- var verticalRadius = data.borderStyle.verticalCornerRadius;
153
+ if (data.borderStyle.style !== _util.AnnotationBorderStyleType.UNDERLINE) {
154
+ width = width - 2 * data.borderStyle.width;
155
+ height = height - 2 * data.borderStyle.width;
156
+ }
196
157
 
197
- if (horizontalRadius > 0 || verticalRadius > 0) {
198
- var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
199
- container.style.borderRadius = radius;
200
- }
158
+ const horizontalRadius = data.borderStyle.horizontalCornerRadius;
159
+ const verticalRadius = data.borderStyle.verticalCornerRadius;
201
160
 
202
- switch (data.borderStyle.style) {
203
- case _util.AnnotationBorderStyleType.SOLID:
204
- container.style.borderStyle = 'solid';
205
- break;
161
+ if (horizontalRadius > 0 || verticalRadius > 0) {
162
+ const radius = `${horizontalRadius}px / ${verticalRadius}px`;
163
+ container.style.borderRadius = radius;
164
+ }
206
165
 
207
- case _util.AnnotationBorderStyleType.DASHED:
208
- container.style.borderStyle = 'dashed';
209
- break;
166
+ switch (data.borderStyle.style) {
167
+ case _util.AnnotationBorderStyleType.SOLID:
168
+ container.style.borderStyle = "solid";
169
+ break;
210
170
 
211
- case _util.AnnotationBorderStyleType.BEVELED:
212
- (0, _util.warn)('Unimplemented border style: beveled');
213
- break;
171
+ case _util.AnnotationBorderStyleType.DASHED:
172
+ container.style.borderStyle = "dashed";
173
+ break;
214
174
 
215
- case _util.AnnotationBorderStyleType.INSET:
216
- (0, _util.warn)('Unimplemented border style: inset');
217
- break;
175
+ case _util.AnnotationBorderStyleType.BEVELED:
176
+ (0, _util.warn)("Unimplemented border style: beveled");
177
+ break;
218
178
 
219
- case _util.AnnotationBorderStyleType.UNDERLINE:
220
- container.style.borderBottomStyle = 'solid';
221
- break;
179
+ case _util.AnnotationBorderStyleType.INSET:
180
+ (0, _util.warn)("Unimplemented border style: inset");
181
+ break;
222
182
 
223
- default:
224
- break;
225
- }
183
+ case _util.AnnotationBorderStyleType.UNDERLINE:
184
+ container.style.borderBottomStyle = "solid";
185
+ break;
226
186
 
227
- if (data.color) {
228
- container.style.borderColor = _util.Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
229
- } else {
230
- container.style.borderWidth = 0;
231
- }
187
+ default:
188
+ break;
232
189
  }
233
190
 
234
- container.style.left = rect[0] + 'px';
235
- container.style.top = rect[1] + 'px';
236
- container.style.width = width + 'px';
237
- container.style.height = height + 'px';
238
- return container;
239
- }
240
- }, {
241
- key: "_createPopup",
242
- value: function _createPopup(container, trigger, data) {
243
- if (!trigger) {
244
- trigger = document.createElement('div');
245
- trigger.style.height = container.style.height;
246
- trigger.style.width = container.style.width;
247
- container.appendChild(trigger);
191
+ if (data.color) {
192
+ container.style.borderColor = _util.Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
193
+ } else {
194
+ container.style.borderWidth = 0;
248
195
  }
249
-
250
- var popupElement = new PopupElement({
251
- container: container,
252
- trigger: trigger,
253
- color: data.color,
254
- title: data.title,
255
- contents: data.contents,
256
- hideWrapper: true
257
- });
258
- var popup = popupElement.render();
259
- popup.style.left = container.style.width;
260
- container.appendChild(popup);
261
196
  }
262
- }, {
263
- key: "render",
264
- value: function render() {
265
- (0, _util.unreachable)('Abstract method `AnnotationElement.render` called');
197
+
198
+ container.style.left = `${rect[0]}px`;
199
+ container.style.top = `${rect[1]}px`;
200
+ container.style.width = `${width}px`;
201
+ container.style.height = `${height}px`;
202
+ return container;
203
+ }
204
+
205
+ _createPopup(container, trigger, data) {
206
+ if (!trigger) {
207
+ trigger = document.createElement("div");
208
+ trigger.style.height = container.style.height;
209
+ trigger.style.width = container.style.width;
210
+ container.appendChild(trigger);
266
211
  }
267
- }]);
268
212
 
269
- return AnnotationElement;
270
- }();
213
+ const popupElement = new PopupElement({
214
+ container,
215
+ trigger,
216
+ color: data.color,
217
+ title: data.title,
218
+ modificationDate: data.modificationDate,
219
+ contents: data.contents,
220
+ hideWrapper: true
221
+ });
222
+ const popup = popupElement.render();
223
+ popup.style.left = container.style.width;
224
+ container.appendChild(popup);
225
+ }
271
226
 
272
- var LinkAnnotationElement =
273
- /*#__PURE__*/
274
- function (_AnnotationElement) {
275
- _inherits(LinkAnnotationElement, _AnnotationElement);
227
+ render() {
228
+ (0, _util.unreachable)("Abstract method `AnnotationElement.render` called");
229
+ }
276
230
 
277
- function LinkAnnotationElement(parameters) {
278
- _classCallCheck(this, LinkAnnotationElement);
231
+ }
279
232
 
280
- var isRenderable = !!(parameters.data.url || parameters.data.dest || parameters.data.action);
281
- return _possibleConstructorReturn(this, _getPrototypeOf(LinkAnnotationElement).call(this, parameters, isRenderable));
233
+ class LinkAnnotationElement extends AnnotationElement {
234
+ constructor(parameters) {
235
+ const isRenderable = !!(parameters.data.url || parameters.data.dest || parameters.data.action);
236
+ super(parameters, isRenderable);
282
237
  }
283
238
 
284
- _createClass(LinkAnnotationElement, [{
285
- key: "render",
286
- value: function render() {
287
- this.container.className = 'linkAnnotation';
288
- var data = this.data,
289
- linkService = this.linkService;
290
- var link = document.createElement('a');
291
- (0, _dom_utils.addLinkAttributes)(link, {
239
+ render() {
240
+ this.container.className = "linkAnnotation";
241
+ const {
242
+ data,
243
+ linkService
244
+ } = this;
245
+ const link = document.createElement("a");
246
+
247
+ if (data.url) {
248
+ (0, _display_utils.addLinkAttributes)(link, {
292
249
  url: data.url,
293
- target: data.newWindow ? _dom_utils.LinkTarget.BLANK : linkService.externalLinkTarget,
294
- rel: linkService.externalLinkRel
250
+ target: data.newWindow ? _display_utils.LinkTarget.BLANK : linkService.externalLinkTarget,
251
+ rel: linkService.externalLinkRel,
252
+ enabled: linkService.externalLinkEnabled
295
253
  });
296
-
297
- if (!data.url) {
298
- if (data.action) {
299
- this._bindNamedAction(link, data.action);
300
- } else {
301
- this._bindLink(link, data.dest);
302
- }
303
- }
304
-
305
- this.container.appendChild(link);
306
- return this.container;
254
+ } else if (data.action) {
255
+ this._bindNamedAction(link, data.action);
256
+ } else {
257
+ this._bindLink(link, data.dest);
307
258
  }
308
- }, {
309
- key: "_bindLink",
310
- value: function _bindLink(link, destination) {
311
- var _this = this;
312
259
 
313
- link.href = this.linkService.getDestinationHash(destination);
314
-
315
- link.onclick = function () {
316
- if (destination) {
317
- _this.linkService.navigateTo(destination);
318
- }
260
+ this.container.appendChild(link);
261
+ return this.container;
262
+ }
319
263
 
320
- return false;
321
- };
264
+ _bindLink(link, destination) {
265
+ link.href = this.linkService.getDestinationHash(destination);
322
266
 
267
+ link.onclick = () => {
323
268
  if (destination) {
324
- link.className = 'internalLink';
269
+ this.linkService.navigateTo(destination);
325
270
  }
326
- }
327
- }, {
328
- key: "_bindNamedAction",
329
- value: function _bindNamedAction(link, action) {
330
- var _this2 = this;
331
271
 
332
- link.href = this.linkService.getAnchorUrl('');
272
+ return false;
273
+ };
333
274
 
334
- link.onclick = function () {
335
- _this2.linkService.executeNamedAction(action);
336
-
337
- return false;
338
- };
339
-
340
- link.className = 'internalLink';
275
+ if (destination) {
276
+ link.className = "internalLink";
341
277
  }
342
- }]);
343
-
344
- return LinkAnnotationElement;
345
- }(AnnotationElement);
346
-
347
- var TextAnnotationElement =
348
- /*#__PURE__*/
349
- function (_AnnotationElement2) {
350
- _inherits(TextAnnotationElement, _AnnotationElement2);
351
-
352
- function TextAnnotationElement(parameters) {
353
- _classCallCheck(this, TextAnnotationElement);
354
-
355
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
356
- return _possibleConstructorReturn(this, _getPrototypeOf(TextAnnotationElement).call(this, parameters, isRenderable));
357
278
  }
358
279
 
359
- _createClass(TextAnnotationElement, [{
360
- key: "render",
361
- value: function render() {
362
- this.container.className = 'textAnnotation';
363
- var image = document.createElement('img');
364
- image.style.height = this.container.style.height;
365
- image.style.width = this.container.style.width;
366
- image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
367
- image.alt = '[{{type}} Annotation]';
368
- image.dataset.l10nId = 'text_annotation_type';
369
- image.dataset.l10nArgs = JSON.stringify({
370
- type: this.data.name
371
- });
280
+ _bindNamedAction(link, action) {
281
+ link.href = this.linkService.getAnchorUrl("");
372
282
 
373
- if (!this.data.hasPopup) {
374
- this._createPopup(this.container, image, this.data);
375
- }
283
+ link.onclick = () => {
284
+ this.linkService.executeNamedAction(action);
285
+ return false;
286
+ };
376
287
 
377
- this.container.appendChild(image);
378
- return this.container;
379
- }
380
- }]);
381
-
382
- return TextAnnotationElement;
383
- }(AnnotationElement);
384
-
385
- var WidgetAnnotationElement =
386
- /*#__PURE__*/
387
- function (_AnnotationElement3) {
388
- _inherits(WidgetAnnotationElement, _AnnotationElement3);
288
+ link.className = "internalLink";
289
+ }
389
290
 
390
- function WidgetAnnotationElement() {
391
- _classCallCheck(this, WidgetAnnotationElement);
291
+ }
392
292
 
393
- return _possibleConstructorReturn(this, _getPrototypeOf(WidgetAnnotationElement).apply(this, arguments));
293
+ class TextAnnotationElement extends AnnotationElement {
294
+ constructor(parameters) {
295
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
296
+ super(parameters, isRenderable);
394
297
  }
395
298
 
396
- _createClass(WidgetAnnotationElement, [{
397
- key: "render",
398
- value: function render() {
399
- return this.container;
299
+ render() {
300
+ this.container.className = "textAnnotation";
301
+ const image = document.createElement("img");
302
+ image.style.height = this.container.style.height;
303
+ image.style.width = this.container.style.width;
304
+ image.src = this.imageResourcesPath + "annotation-" + this.data.name.toLowerCase() + ".svg";
305
+ image.alt = "[{{type}} Annotation]";
306
+ image.dataset.l10nId = "text_annotation_type";
307
+ image.dataset.l10nArgs = JSON.stringify({
308
+ type: this.data.name
309
+ });
310
+
311
+ if (!this.data.hasPopup) {
312
+ this._createPopup(this.container, image, this.data);
400
313
  }
401
- }]);
402
-
403
- return WidgetAnnotationElement;
404
- }(AnnotationElement);
405
314
 
406
- var TextWidgetAnnotationElement =
407
- /*#__PURE__*/
408
- function (_WidgetAnnotationElem) {
409
- _inherits(TextWidgetAnnotationElement, _WidgetAnnotationElem);
315
+ this.container.appendChild(image);
316
+ return this.container;
317
+ }
410
318
 
411
- function TextWidgetAnnotationElement(parameters) {
412
- _classCallCheck(this, TextWidgetAnnotationElement);
319
+ }
413
320
 
414
- var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
415
- return _possibleConstructorReturn(this, _getPrototypeOf(TextWidgetAnnotationElement).call(this, parameters, isRenderable));
321
+ class WidgetAnnotationElement extends AnnotationElement {
322
+ render() {
323
+ return this.container;
416
324
  }
417
325
 
418
- _createClass(TextWidgetAnnotationElement, [{
419
- key: "render",
420
- value: function render() {
421
- var TEXT_ALIGNMENT = ['left', 'center', 'right'];
422
- this.container.className = 'textWidgetAnnotation';
423
- var element = null;
424
-
425
- if (this.renderInteractiveForms) {
426
- if (this.data.multiLine) {
427
- element = document.createElement('textarea');
428
- element.textContent = this.data.fieldValue;
429
- } else {
430
- element = document.createElement('input');
431
- element.type = 'text';
432
- element.setAttribute('value', this.data.fieldValue);
433
- }
326
+ }
434
327
 
435
- element.disabled = this.data.readOnly;
328
+ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
329
+ constructor(parameters) {
330
+ const isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
331
+ super(parameters, isRenderable);
332
+ }
436
333
 
437
- if (this.data.maxLen !== null) {
438
- element.maxLength = this.data.maxLen;
439
- }
334
+ render() {
335
+ const TEXT_ALIGNMENT = ["left", "center", "right"];
336
+ this.container.className = "textWidgetAnnotation";
337
+ let element = null;
440
338
 
441
- if (this.data.comb) {
442
- var fieldWidth = this.data.rect[2] - this.data.rect[0];
443
- var combWidth = fieldWidth / this.data.maxLen;
444
- element.classList.add('comb');
445
- element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
446
- }
447
- } else {
448
- element = document.createElement('div');
339
+ if (this.renderInteractiveForms) {
340
+ if (this.data.multiLine) {
341
+ element = document.createElement("textarea");
449
342
  element.textContent = this.data.fieldValue;
450
- element.style.verticalAlign = 'middle';
451
- element.style.display = 'table-cell';
452
- var font = null;
343
+ } else {
344
+ element = document.createElement("input");
345
+ element.type = "text";
346
+ element.setAttribute("value", this.data.fieldValue);
347
+ }
453
348
 
454
- if (this.data.fontRefName && this.page.commonObjs.has(this.data.fontRefName)) {
455
- font = this.page.commonObjs.get(this.data.fontRefName);
456
- }
349
+ element.disabled = this.data.readOnly;
350
+ element.name = this.data.fieldName;
457
351
 
458
- this._setTextStyle(element, font);
352
+ if (this.data.maxLen !== null) {
353
+ element.maxLength = this.data.maxLen;
459
354
  }
460
355
 
461
- if (this.data.textAlignment !== null) {
462
- element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
356
+ if (this.data.comb) {
357
+ const fieldWidth = this.data.rect[2] - this.data.rect[0];
358
+ const combWidth = fieldWidth / this.data.maxLen;
359
+ element.classList.add("comb");
360
+ element.style.letterSpacing = `calc(${combWidth}px - 1ch)`;
463
361
  }
464
-
465
- this.container.appendChild(element);
466
- return this.container;
467
- }
468
- }, {
469
- key: "_setTextStyle",
470
- value: function _setTextStyle(element, font) {
471
- var style = element.style;
472
- style.fontSize = this.data.fontSize + 'px';
473
- style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
474
-
475
- if (!font) {
476
- return;
362
+ } else {
363
+ element = document.createElement("div");
364
+ element.textContent = this.data.fieldValue;
365
+ element.style.verticalAlign = "middle";
366
+ element.style.display = "table-cell";
367
+ let font = null;
368
+
369
+ if (this.data.fontRefName && this.page.commonObjs.has(this.data.fontRefName)) {
370
+ font = this.page.commonObjs.get(this.data.fontRefName);
477
371
  }
478
372
 
479
- style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
480
- style.fontStyle = font.italic ? 'italic' : 'normal';
481
- var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
482
- var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
483
- style.fontFamily = fontFamily + fallbackName;
373
+ this._setTextStyle(element, font);
484
374
  }
485
- }]);
486
375
 
487
- return TextWidgetAnnotationElement;
488
- }(WidgetAnnotationElement);
489
-
490
- var CheckboxWidgetAnnotationElement =
491
- /*#__PURE__*/
492
- function (_WidgetAnnotationElem2) {
493
- _inherits(CheckboxWidgetAnnotationElement, _WidgetAnnotationElem2);
494
-
495
- function CheckboxWidgetAnnotationElement(parameters) {
496
- _classCallCheck(this, CheckboxWidgetAnnotationElement);
376
+ if (this.data.textAlignment !== null) {
377
+ element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
378
+ }
497
379
 
498
- return _possibleConstructorReturn(this, _getPrototypeOf(CheckboxWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));
380
+ this.container.appendChild(element);
381
+ return this.container;
499
382
  }
500
383
 
501
- _createClass(CheckboxWidgetAnnotationElement, [{
502
- key: "render",
503
- value: function render() {
504
- this.container.className = 'buttonWidgetAnnotation checkBox';
505
- var element = document.createElement('input');
506
- element.disabled = this.data.readOnly;
507
- element.type = 'checkbox';
508
-
509
- if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
510
- element.setAttribute('checked', true);
511
- }
384
+ _setTextStyle(element, font) {
385
+ const style = element.style;
386
+ style.fontSize = `${this.data.fontSize}px`;
387
+ style.direction = this.data.fontDirection < 0 ? "rtl" : "ltr";
512
388
 
513
- this.container.appendChild(element);
514
- return this.container;
389
+ if (!font) {
390
+ return;
515
391
  }
516
- }]);
517
-
518
- return CheckboxWidgetAnnotationElement;
519
- }(WidgetAnnotationElement);
520
392
 
521
- var RadioButtonWidgetAnnotationElement =
522
- /*#__PURE__*/
523
- function (_WidgetAnnotationElem3) {
524
- _inherits(RadioButtonWidgetAnnotationElement, _WidgetAnnotationElem3);
393
+ let bold = "normal";
525
394
 
526
- function RadioButtonWidgetAnnotationElement(parameters) {
527
- _classCallCheck(this, RadioButtonWidgetAnnotationElement);
395
+ if (font.black) {
396
+ bold = "900";
397
+ } else if (font.bold) {
398
+ bold = "bold";
399
+ }
528
400
 
529
- return _possibleConstructorReturn(this, _getPrototypeOf(RadioButtonWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));
401
+ style.fontWeight = bold;
402
+ style.fontStyle = font.italic ? "italic" : "normal";
403
+ const fontFamily = font.loadedName ? `"${font.loadedName}", ` : "";
404
+ const fallbackName = font.fallbackName || "Helvetica, sans-serif";
405
+ style.fontFamily = fontFamily + fallbackName;
530
406
  }
531
407
 
532
- _createClass(RadioButtonWidgetAnnotationElement, [{
533
- key: "render",
534
- value: function render() {
535
- this.container.className = 'buttonWidgetAnnotation radioButton';
536
- var element = document.createElement('input');
537
- element.disabled = this.data.readOnly;
538
- element.type = 'radio';
539
- element.name = this.data.fieldName;
408
+ }
540
409
 
541
- if (this.data.fieldValue === this.data.buttonValue) {
542
- element.setAttribute('checked', true);
543
- }
410
+ class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
411
+ constructor(parameters) {
412
+ super(parameters, parameters.renderInteractiveForms);
413
+ }
544
414
 
545
- this.container.appendChild(element);
546
- return this.container;
547
- }
548
- }]);
415
+ render() {
416
+ this.container.className = "buttonWidgetAnnotation checkBox";
417
+ const element = document.createElement("input");
418
+ element.disabled = this.data.readOnly;
419
+ element.type = "checkbox";
420
+ element.name = this.data.fieldName;
549
421
 
550
- return RadioButtonWidgetAnnotationElement;
551
- }(WidgetAnnotationElement);
422
+ if (this.data.fieldValue && this.data.fieldValue !== "Off") {
423
+ element.setAttribute("checked", true);
424
+ }
552
425
 
553
- var PushButtonWidgetAnnotationElement =
554
- /*#__PURE__*/
555
- function (_LinkAnnotationElemen) {
556
- _inherits(PushButtonWidgetAnnotationElement, _LinkAnnotationElemen);
426
+ this.container.appendChild(element);
427
+ return this.container;
428
+ }
557
429
 
558
- function PushButtonWidgetAnnotationElement() {
559
- _classCallCheck(this, PushButtonWidgetAnnotationElement);
430
+ }
560
431
 
561
- return _possibleConstructorReturn(this, _getPrototypeOf(PushButtonWidgetAnnotationElement).apply(this, arguments));
432
+ class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {
433
+ constructor(parameters) {
434
+ super(parameters, parameters.renderInteractiveForms);
562
435
  }
563
436
 
564
- _createClass(PushButtonWidgetAnnotationElement, [{
565
- key: "render",
566
- value: function render() {
567
- var container = _get(_getPrototypeOf(PushButtonWidgetAnnotationElement.prototype), "render", this).call(this);
437
+ render() {
438
+ this.container.className = "buttonWidgetAnnotation radioButton";
439
+ const element = document.createElement("input");
440
+ element.disabled = this.data.readOnly;
441
+ element.type = "radio";
442
+ element.name = this.data.fieldName;
568
443
 
569
- container.className = 'buttonWidgetAnnotation pushButton';
570
- return container;
444
+ if (this.data.fieldValue === this.data.buttonValue) {
445
+ element.setAttribute("checked", true);
571
446
  }
572
- }]);
573
447
 
574
- return PushButtonWidgetAnnotationElement;
575
- }(LinkAnnotationElement);
448
+ this.container.appendChild(element);
449
+ return this.container;
450
+ }
451
+
452
+ }
576
453
 
577
- var ChoiceWidgetAnnotationElement =
578
- /*#__PURE__*/
579
- function (_WidgetAnnotationElem4) {
580
- _inherits(ChoiceWidgetAnnotationElement, _WidgetAnnotationElem4);
454
+ class PushButtonWidgetAnnotationElement extends LinkAnnotationElement {
455
+ render() {
456
+ const container = super.render();
457
+ container.className = "buttonWidgetAnnotation pushButton";
458
+ return container;
459
+ }
581
460
 
582
- function ChoiceWidgetAnnotationElement(parameters) {
583
- _classCallCheck(this, ChoiceWidgetAnnotationElement);
461
+ }
584
462
 
585
- return _possibleConstructorReturn(this, _getPrototypeOf(ChoiceWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));
463
+ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
464
+ constructor(parameters) {
465
+ super(parameters, parameters.renderInteractiveForms);
586
466
  }
587
467
 
588
- _createClass(ChoiceWidgetAnnotationElement, [{
589
- key: "render",
590
- value: function render() {
591
- this.container.className = 'choiceWidgetAnnotation';
592
- var selectElement = document.createElement('select');
593
- selectElement.disabled = this.data.readOnly;
468
+ render() {
469
+ this.container.className = "choiceWidgetAnnotation";
470
+ const selectElement = document.createElement("select");
471
+ selectElement.disabled = this.data.readOnly;
472
+ selectElement.name = this.data.fieldName;
594
473
 
595
- if (!this.data.combo) {
596
- selectElement.size = this.data.options.length;
474
+ if (!this.data.combo) {
475
+ selectElement.size = this.data.options.length;
597
476
 
598
- if (this.data.multiSelect) {
599
- selectElement.multiple = true;
600
- }
477
+ if (this.data.multiSelect) {
478
+ selectElement.multiple = true;
601
479
  }
480
+ }
602
481
 
603
- for (var i = 0, ii = this.data.options.length; i < ii; i++) {
604
- var option = this.data.options[i];
605
- var optionElement = document.createElement('option');
606
- optionElement.textContent = option.displayValue;
607
- optionElement.value = option.exportValue;
482
+ for (const option of this.data.options) {
483
+ const optionElement = document.createElement("option");
484
+ optionElement.textContent = option.displayValue;
485
+ optionElement.value = option.exportValue;
608
486
 
609
- if (this.data.fieldValue.includes(option.displayValue)) {
610
- optionElement.setAttribute('selected', true);
611
- }
612
-
613
- selectElement.appendChild(optionElement);
487
+ if (this.data.fieldValue.includes(option.displayValue)) {
488
+ optionElement.setAttribute("selected", true);
614
489
  }
615
490
 
616
- this.container.appendChild(selectElement);
617
- return this.container;
491
+ selectElement.appendChild(optionElement);
618
492
  }
619
- }]);
620
-
621
- return ChoiceWidgetAnnotationElement;
622
- }(WidgetAnnotationElement);
623
493
 
624
- var PopupAnnotationElement =
625
- /*#__PURE__*/
626
- function (_AnnotationElement4) {
627
- _inherits(PopupAnnotationElement, _AnnotationElement4);
494
+ this.container.appendChild(selectElement);
495
+ return this.container;
496
+ }
628
497
 
629
- function PopupAnnotationElement(parameters) {
630
- _classCallCheck(this, PopupAnnotationElement);
498
+ }
631
499
 
632
- var isRenderable = !!(parameters.data.title || parameters.data.contents);
633
- return _possibleConstructorReturn(this, _getPrototypeOf(PopupAnnotationElement).call(this, parameters, isRenderable));
500
+ class PopupAnnotationElement extends AnnotationElement {
501
+ constructor(parameters) {
502
+ const isRenderable = !!(parameters.data.title || parameters.data.contents);
503
+ super(parameters, isRenderable);
634
504
  }
635
505
 
636
- _createClass(PopupAnnotationElement, [{
637
- key: "render",
638
- value: function render() {
639
- var IGNORE_TYPES = ['Line', 'Square', 'Circle', 'PolyLine', 'Polygon', 'Ink'];
640
- this.container.className = 'popupAnnotation';
641
-
642
- if (IGNORE_TYPES.includes(this.data.parentType)) {
643
- return this.container;
644
- }
506
+ render() {
507
+ const IGNORE_TYPES = ["Line", "Square", "Circle", "PolyLine", "Polygon", "Ink"];
508
+ this.container.className = "popupAnnotation";
645
509
 
646
- var selector = '[data-annotation-id="' + this.data.parentId + '"]';
647
- var parentElement = this.layer.querySelector(selector);
510
+ if (IGNORE_TYPES.includes(this.data.parentType)) {
511
+ return this.container;
512
+ }
648
513
 
649
- if (!parentElement) {
650
- return this.container;
651
- }
514
+ const selector = `[data-annotation-id="${this.data.parentId}"]`;
515
+ const parentElement = this.layer.querySelector(selector);
652
516
 
653
- var popup = new PopupElement({
654
- container: this.container,
655
- trigger: parentElement,
656
- color: this.data.color,
657
- title: this.data.title,
658
- contents: this.data.contents
659
- });
660
- var parentLeft = parseFloat(parentElement.style.left);
661
- var parentWidth = parseFloat(parentElement.style.width);
662
- this.container.style.transformOrigin = -(parentLeft + parentWidth) + 'px -' + parentElement.style.top;
663
- this.container.style.left = parentLeft + parentWidth + 'px';
664
- this.container.appendChild(popup.render());
517
+ if (!parentElement) {
665
518
  return this.container;
666
519
  }
667
- }]);
668
520
 
669
- return PopupAnnotationElement;
670
- }(AnnotationElement);
521
+ const popup = new PopupElement({
522
+ container: this.container,
523
+ trigger: parentElement,
524
+ color: this.data.color,
525
+ title: this.data.title,
526
+ modificationDate: this.data.modificationDate,
527
+ contents: this.data.contents
528
+ });
529
+ const parentLeft = parseFloat(parentElement.style.left);
530
+ const parentWidth = parseFloat(parentElement.style.width);
531
+ this.container.style.transformOrigin = `-${parentLeft + parentWidth}px -${parentElement.style.top}`;
532
+ this.container.style.left = `${parentLeft + parentWidth}px`;
533
+ this.container.appendChild(popup.render());
534
+ return this.container;
535
+ }
671
536
 
672
- var PopupElement =
673
- /*#__PURE__*/
674
- function () {
675
- function PopupElement(parameters) {
676
- _classCallCheck(this, PopupElement);
537
+ }
677
538
 
539
+ class PopupElement {
540
+ constructor(parameters) {
678
541
  this.container = parameters.container;
679
542
  this.trigger = parameters.trigger;
680
543
  this.color = parameters.color;
681
544
  this.title = parameters.title;
545
+ this.modificationDate = parameters.modificationDate;
682
546
  this.contents = parameters.contents;
683
547
  this.hideWrapper = parameters.hideWrapper || false;
684
548
  this.pinned = false;
685
549
  }
686
550
 
687
- _createClass(PopupElement, [{
688
- key: "render",
689
- value: function render() {
690
- var BACKGROUND_ENLIGHT = 0.7;
691
- var wrapper = document.createElement('div');
692
- wrapper.className = 'popupWrapper';
693
- this.hideElement = this.hideWrapper ? wrapper : this.container;
694
- this.hideElement.setAttribute('hidden', true);
695
- var popup = document.createElement('div');
696
- popup.className = 'popup';
697
- var color = this.color;
698
-
699
- if (color) {
700
- var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
701
- var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
702
- var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
703
- popup.style.backgroundColor = _util.Util.makeCssRgb(r | 0, g | 0, b | 0);
704
- }
705
-
706
- var contents = this._formatContents(this.contents);
707
-
708
- var title = document.createElement('h1');
709
- title.textContent = this.title;
710
- this.trigger.addEventListener('click', this._toggle.bind(this));
711
- this.trigger.addEventListener('mouseover', this._show.bind(this, false));
712
- this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
713
- popup.addEventListener('click', this._hide.bind(this, true));
714
- popup.appendChild(title);
715
- popup.appendChild(contents);
716
- wrapper.appendChild(popup);
717
- return wrapper;
551
+ render() {
552
+ const BACKGROUND_ENLIGHT = 0.7;
553
+ const wrapper = document.createElement("div");
554
+ wrapper.className = "popupWrapper";
555
+ this.hideElement = this.hideWrapper ? wrapper : this.container;
556
+ this.hideElement.setAttribute("hidden", true);
557
+ const popup = document.createElement("div");
558
+ popup.className = "popup";
559
+ const color = this.color;
560
+
561
+ if (color) {
562
+ const r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
563
+ const g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
564
+ const b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
565
+ popup.style.backgroundColor = _util.Util.makeCssRgb(r | 0, g | 0, b | 0);
718
566
  }
719
- }, {
720
- key: "_formatContents",
721
- value: function _formatContents(contents) {
722
- var p = document.createElement('p');
723
- var lines = contents.split(/(?:\r\n?|\n)/);
724
-
725
- for (var i = 0, ii = lines.length; i < ii; ++i) {
726
- var line = lines[i];
727
- p.appendChild(document.createTextNode(line));
728
-
729
- if (i < ii - 1) {
730
- p.appendChild(document.createElement('br'));
731
- }
732
- }
733
567
 
734
- return p;
735
- }
736
- }, {
737
- key: "_toggle",
738
- value: function _toggle() {
739
- if (this.pinned) {
740
- this._hide(true);
741
- } else {
742
- this._show(true);
743
- }
744
- }
745
- }, {
746
- key: "_show",
747
- value: function _show() {
748
- var pin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
568
+ const title = document.createElement("h1");
569
+ title.textContent = this.title;
570
+ popup.appendChild(title);
749
571
 
750
- if (pin) {
751
- this.pinned = true;
752
- }
572
+ const dateObject = _display_utils.PDFDateString.toDateObject(this.modificationDate);
753
573
 
754
- if (this.hideElement.hasAttribute('hidden')) {
755
- this.hideElement.removeAttribute('hidden');
756
- this.container.style.zIndex += 1;
757
- }
574
+ if (dateObject) {
575
+ const modificationDate = document.createElement("span");
576
+ modificationDate.textContent = "{{date}}, {{time}}";
577
+ modificationDate.dataset.l10nId = "annotation_date_string";
578
+ modificationDate.dataset.l10nArgs = JSON.stringify({
579
+ date: dateObject.toLocaleDateString(),
580
+ time: dateObject.toLocaleTimeString()
581
+ });
582
+ popup.appendChild(modificationDate);
758
583
  }
759
- }, {
760
- key: "_hide",
761
- value: function _hide() {
762
- var unpin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
763
584
 
764
- if (unpin) {
765
- this.pinned = false;
766
- }
585
+ const contents = this._formatContents(this.contents);
767
586
 
768
- if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
769
- this.hideElement.setAttribute('hidden', true);
770
- this.container.style.zIndex -= 1;
771
- }
772
- }
773
- }]);
587
+ popup.appendChild(contents);
588
+ this.trigger.addEventListener("click", this._toggle.bind(this));
589
+ this.trigger.addEventListener("mouseover", this._show.bind(this, false));
590
+ this.trigger.addEventListener("mouseout", this._hide.bind(this, false));
591
+ popup.addEventListener("click", this._hide.bind(this, true));
592
+ wrapper.appendChild(popup);
593
+ return wrapper;
594
+ }
774
595
 
775
- return PopupElement;
776
- }();
596
+ _formatContents(contents) {
597
+ const p = document.createElement("p");
598
+ const lines = contents.split(/(?:\r\n?|\n)/);
777
599
 
778
- var LineAnnotationElement =
779
- /*#__PURE__*/
780
- function (_AnnotationElement5) {
781
- _inherits(LineAnnotationElement, _AnnotationElement5);
600
+ for (let i = 0, ii = lines.length; i < ii; ++i) {
601
+ const line = lines[i];
602
+ p.appendChild(document.createTextNode(line));
782
603
 
783
- function LineAnnotationElement(parameters) {
784
- _classCallCheck(this, LineAnnotationElement);
604
+ if (i < ii - 1) {
605
+ p.appendChild(document.createElement("br"));
606
+ }
607
+ }
785
608
 
786
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
787
- return _possibleConstructorReturn(this, _getPrototypeOf(LineAnnotationElement).call(this, parameters, isRenderable, true));
609
+ return p;
788
610
  }
789
611
 
790
- _createClass(LineAnnotationElement, [{
791
- key: "render",
792
- value: function render() {
793
- this.container.className = 'lineAnnotation';
794
- var data = this.data;
795
- var width = data.rect[2] - data.rect[0];
796
- var height = data.rect[3] - data.rect[1];
797
- var svg = this.svgFactory.create(width, height);
798
- var line = this.svgFactory.createElement('svg:line');
799
- line.setAttribute('x1', data.rect[2] - data.lineCoordinates[0]);
800
- line.setAttribute('y1', data.rect[3] - data.lineCoordinates[1]);
801
- line.setAttribute('x2', data.rect[2] - data.lineCoordinates[2]);
802
- line.setAttribute('y2', data.rect[3] - data.lineCoordinates[3]);
803
- line.setAttribute('stroke-width', data.borderStyle.width);
804
- line.setAttribute('stroke', 'transparent');
805
- svg.appendChild(line);
806
- this.container.append(svg);
807
-
808
- this._createPopup(this.container, line, data);
612
+ _toggle() {
613
+ if (this.pinned) {
614
+ this._hide(true);
615
+ } else {
616
+ this._show(true);
617
+ }
618
+ }
809
619
 
810
- return this.container;
620
+ _show(pin = false) {
621
+ if (pin) {
622
+ this.pinned = true;
623
+ }
624
+
625
+ if (this.hideElement.hasAttribute("hidden")) {
626
+ this.hideElement.removeAttribute("hidden");
627
+ this.container.style.zIndex += 1;
811
628
  }
812
- }]);
629
+ }
813
630
 
814
- return LineAnnotationElement;
815
- }(AnnotationElement);
631
+ _hide(unpin = true) {
632
+ if (unpin) {
633
+ this.pinned = false;
634
+ }
816
635
 
817
- var SquareAnnotationElement =
818
- /*#__PURE__*/
819
- function (_AnnotationElement6) {
820
- _inherits(SquareAnnotationElement, _AnnotationElement6);
636
+ if (!this.hideElement.hasAttribute("hidden") && !this.pinned) {
637
+ this.hideElement.setAttribute("hidden", true);
638
+ this.container.style.zIndex -= 1;
639
+ }
640
+ }
821
641
 
822
- function SquareAnnotationElement(parameters) {
823
- _classCallCheck(this, SquareAnnotationElement);
642
+ }
824
643
 
825
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
826
- return _possibleConstructorReturn(this, _getPrototypeOf(SquareAnnotationElement).call(this, parameters, isRenderable, true));
644
+ class FreeTextAnnotationElement extends AnnotationElement {
645
+ constructor(parameters) {
646
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
647
+ super(parameters, isRenderable, true);
827
648
  }
828
649
 
829
- _createClass(SquareAnnotationElement, [{
830
- key: "render",
831
- value: function render() {
832
- this.container.className = 'squareAnnotation';
833
- var data = this.data;
834
- var width = data.rect[2] - data.rect[0];
835
- var height = data.rect[3] - data.rect[1];
836
- var svg = this.svgFactory.create(width, height);
837
- var borderWidth = data.borderStyle.width;
838
- var square = this.svgFactory.createElement('svg:rect');
839
- square.setAttribute('x', borderWidth / 2);
840
- square.setAttribute('y', borderWidth / 2);
841
- square.setAttribute('width', width - borderWidth);
842
- square.setAttribute('height', height - borderWidth);
843
- square.setAttribute('stroke-width', borderWidth);
844
- square.setAttribute('stroke', 'transparent');
845
- square.setAttribute('fill', 'none');
846
- svg.appendChild(square);
847
- this.container.append(svg);
848
-
849
- this._createPopup(this.container, square, data);
650
+ render() {
651
+ this.container.className = "freeTextAnnotation";
850
652
 
851
- return this.container;
653
+ if (!this.data.hasPopup) {
654
+ this._createPopup(this.container, null, this.data);
852
655
  }
853
- }]);
854
-
855
- return SquareAnnotationElement;
856
- }(AnnotationElement);
857
656
 
858
- var CircleAnnotationElement =
859
- /*#__PURE__*/
860
- function (_AnnotationElement7) {
861
- _inherits(CircleAnnotationElement, _AnnotationElement7);
657
+ return this.container;
658
+ }
862
659
 
863
- function CircleAnnotationElement(parameters) {
864
- _classCallCheck(this, CircleAnnotationElement);
660
+ }
865
661
 
866
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
867
- return _possibleConstructorReturn(this, _getPrototypeOf(CircleAnnotationElement).call(this, parameters, isRenderable, true));
662
+ class LineAnnotationElement extends AnnotationElement {
663
+ constructor(parameters) {
664
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
665
+ super(parameters, isRenderable, true);
868
666
  }
869
667
 
870
- _createClass(CircleAnnotationElement, [{
871
- key: "render",
872
- value: function render() {
873
- this.container.className = 'circleAnnotation';
874
- var data = this.data;
875
- var width = data.rect[2] - data.rect[0];
876
- var height = data.rect[3] - data.rect[1];
877
- var svg = this.svgFactory.create(width, height);
878
- var borderWidth = data.borderStyle.width;
879
- var circle = this.svgFactory.createElement('svg:ellipse');
880
- circle.setAttribute('cx', width / 2);
881
- circle.setAttribute('cy', height / 2);
882
- circle.setAttribute('rx', width / 2 - borderWidth / 2);
883
- circle.setAttribute('ry', height / 2 - borderWidth / 2);
884
- circle.setAttribute('stroke-width', borderWidth);
885
- circle.setAttribute('stroke', 'transparent');
886
- circle.setAttribute('fill', 'none');
887
- svg.appendChild(circle);
888
- this.container.append(svg);
889
-
890
- this._createPopup(this.container, circle, data);
891
-
892
- return this.container;
893
- }
894
- }]);
668
+ render() {
669
+ this.container.className = "lineAnnotation";
670
+ const data = this.data;
671
+ const width = data.rect[2] - data.rect[0];
672
+ const height = data.rect[3] - data.rect[1];
673
+ const svg = this.svgFactory.create(width, height);
674
+ const line = this.svgFactory.createElement("svg:line");
675
+ line.setAttribute("x1", data.rect[2] - data.lineCoordinates[0]);
676
+ line.setAttribute("y1", data.rect[3] - data.lineCoordinates[1]);
677
+ line.setAttribute("x2", data.rect[2] - data.lineCoordinates[2]);
678
+ line.setAttribute("y2", data.rect[3] - data.lineCoordinates[3]);
679
+ line.setAttribute("stroke-width", data.borderStyle.width || 1);
680
+ line.setAttribute("stroke", "transparent");
681
+ svg.appendChild(line);
682
+ this.container.append(svg);
683
+
684
+ this._createPopup(this.container, line, data);
685
+
686
+ return this.container;
687
+ }
895
688
 
896
- return CircleAnnotationElement;
897
- }(AnnotationElement);
689
+ }
898
690
 
899
- var PolylineAnnotationElement =
900
- /*#__PURE__*/
901
- function (_AnnotationElement8) {
902
- _inherits(PolylineAnnotationElement, _AnnotationElement8);
691
+ class SquareAnnotationElement extends AnnotationElement {
692
+ constructor(parameters) {
693
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
694
+ super(parameters, isRenderable, true);
695
+ }
903
696
 
904
- function PolylineAnnotationElement(parameters) {
905
- var _this3;
697
+ render() {
698
+ this.container.className = "squareAnnotation";
699
+ const data = this.data;
700
+ const width = data.rect[2] - data.rect[0];
701
+ const height = data.rect[3] - data.rect[1];
702
+ const svg = this.svgFactory.create(width, height);
703
+ const borderWidth = data.borderStyle.width;
704
+ const square = this.svgFactory.createElement("svg:rect");
705
+ square.setAttribute("x", borderWidth / 2);
706
+ square.setAttribute("y", borderWidth / 2);
707
+ square.setAttribute("width", width - borderWidth);
708
+ square.setAttribute("height", height - borderWidth);
709
+ square.setAttribute("stroke-width", borderWidth || 1);
710
+ square.setAttribute("stroke", "transparent");
711
+ square.setAttribute("fill", "none");
712
+ svg.appendChild(square);
713
+ this.container.append(svg);
714
+
715
+ this._createPopup(this.container, square, data);
716
+
717
+ return this.container;
718
+ }
906
719
 
907
- _classCallCheck(this, PolylineAnnotationElement);
720
+ }
908
721
 
909
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
910
- _this3 = _possibleConstructorReturn(this, _getPrototypeOf(PolylineAnnotationElement).call(this, parameters, isRenderable, true));
911
- _this3.containerClassName = 'polylineAnnotation';
912
- _this3.svgElementName = 'svg:polyline';
913
- return _this3;
722
+ class CircleAnnotationElement extends AnnotationElement {
723
+ constructor(parameters) {
724
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
725
+ super(parameters, isRenderable, true);
914
726
  }
915
727
 
916
- _createClass(PolylineAnnotationElement, [{
917
- key: "render",
918
- value: function render() {
919
- this.container.className = this.containerClassName;
920
- var data = this.data;
921
- var width = data.rect[2] - data.rect[0];
922
- var height = data.rect[3] - data.rect[1];
923
- var svg = this.svgFactory.create(width, height);
924
- var vertices = data.vertices;
925
- var points = [];
926
-
927
- for (var i = 0, ii = vertices.length; i < ii; i++) {
928
- var x = vertices[i].x - data.rect[0];
929
- var y = data.rect[3] - vertices[i].y;
930
- points.push(x + ',' + y);
931
- }
728
+ render() {
729
+ this.container.className = "circleAnnotation";
730
+ const data = this.data;
731
+ const width = data.rect[2] - data.rect[0];
732
+ const height = data.rect[3] - data.rect[1];
733
+ const svg = this.svgFactory.create(width, height);
734
+ const borderWidth = data.borderStyle.width;
735
+ const circle = this.svgFactory.createElement("svg:ellipse");
736
+ circle.setAttribute("cx", width / 2);
737
+ circle.setAttribute("cy", height / 2);
738
+ circle.setAttribute("rx", width / 2 - borderWidth / 2);
739
+ circle.setAttribute("ry", height / 2 - borderWidth / 2);
740
+ circle.setAttribute("stroke-width", borderWidth || 1);
741
+ circle.setAttribute("stroke", "transparent");
742
+ circle.setAttribute("fill", "none");
743
+ svg.appendChild(circle);
744
+ this.container.append(svg);
745
+
746
+ this._createPopup(this.container, circle, data);
747
+
748
+ return this.container;
749
+ }
932
750
 
933
- points = points.join(' ');
934
- var borderWidth = data.borderStyle.width;
935
- var polyline = this.svgFactory.createElement(this.svgElementName);
936
- polyline.setAttribute('points', points);
937
- polyline.setAttribute('stroke-width', borderWidth);
938
- polyline.setAttribute('stroke', 'transparent');
939
- polyline.setAttribute('fill', 'none');
940
- svg.appendChild(polyline);
941
- this.container.append(svg);
751
+ }
942
752
 
943
- this._createPopup(this.container, polyline, data);
753
+ class PolylineAnnotationElement extends AnnotationElement {
754
+ constructor(parameters) {
755
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
756
+ super(parameters, isRenderable, true);
757
+ this.containerClassName = "polylineAnnotation";
758
+ this.svgElementName = "svg:polyline";
759
+ }
944
760
 
945
- return this.container;
761
+ render() {
762
+ this.container.className = this.containerClassName;
763
+ const data = this.data;
764
+ const width = data.rect[2] - data.rect[0];
765
+ const height = data.rect[3] - data.rect[1];
766
+ const svg = this.svgFactory.create(width, height);
767
+ let points = [];
768
+
769
+ for (const coordinate of data.vertices) {
770
+ const x = coordinate.x - data.rect[0];
771
+ const y = data.rect[3] - coordinate.y;
772
+ points.push(x + "," + y);
946
773
  }
947
- }]);
948
774
 
949
- return PolylineAnnotationElement;
950
- }(AnnotationElement);
775
+ points = points.join(" ");
776
+ const polyline = this.svgFactory.createElement(this.svgElementName);
777
+ polyline.setAttribute("points", points);
778
+ polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
779
+ polyline.setAttribute("stroke", "transparent");
780
+ polyline.setAttribute("fill", "none");
781
+ svg.appendChild(polyline);
782
+ this.container.append(svg);
951
783
 
952
- var PolygonAnnotationElement =
953
- /*#__PURE__*/
954
- function (_PolylineAnnotationEl) {
955
- _inherits(PolygonAnnotationElement, _PolylineAnnotationEl);
784
+ this._createPopup(this.container, polyline, data);
956
785
 
957
- function PolygonAnnotationElement(parameters) {
958
- var _this4;
786
+ return this.container;
787
+ }
959
788
 
960
- _classCallCheck(this, PolygonAnnotationElement);
789
+ }
961
790
 
962
- _this4 = _possibleConstructorReturn(this, _getPrototypeOf(PolygonAnnotationElement).call(this, parameters));
963
- _this4.containerClassName = 'polygonAnnotation';
964
- _this4.svgElementName = 'svg:polygon';
965
- return _this4;
791
+ class PolygonAnnotationElement extends PolylineAnnotationElement {
792
+ constructor(parameters) {
793
+ super(parameters);
794
+ this.containerClassName = "polygonAnnotation";
795
+ this.svgElementName = "svg:polygon";
966
796
  }
967
797
 
968
- return PolygonAnnotationElement;
969
- }(PolylineAnnotationElement);
798
+ }
970
799
 
971
- var InkAnnotationElement =
972
- /*#__PURE__*/
973
- function (_AnnotationElement9) {
974
- _inherits(InkAnnotationElement, _AnnotationElement9);
800
+ class CaretAnnotationElement extends AnnotationElement {
801
+ constructor(parameters) {
802
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
803
+ super(parameters, isRenderable, true);
804
+ }
975
805
 
976
- function InkAnnotationElement(parameters) {
977
- var _this5;
806
+ render() {
807
+ this.container.className = "caretAnnotation";
978
808
 
979
- _classCallCheck(this, InkAnnotationElement);
809
+ if (!this.data.hasPopup) {
810
+ this._createPopup(this.container, null, this.data);
811
+ }
980
812
 
981
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
982
- _this5 = _possibleConstructorReturn(this, _getPrototypeOf(InkAnnotationElement).call(this, parameters, isRenderable, true));
983
- _this5.containerClassName = 'inkAnnotation';
984
- _this5.svgElementName = 'svg:polyline';
985
- return _this5;
813
+ return this.container;
986
814
  }
987
815
 
988
- _createClass(InkAnnotationElement, [{
989
- key: "render",
990
- value: function render() {
991
- this.container.className = this.containerClassName;
992
- var data = this.data;
993
- var width = data.rect[2] - data.rect[0];
994
- var height = data.rect[3] - data.rect[1];
995
- var svg = this.svgFactory.create(width, height);
996
- var inkLists = data.inkLists;
997
-
998
- for (var i = 0, ii = inkLists.length; i < ii; i++) {
999
- var inkList = inkLists[i];
1000
- var points = [];
1001
-
1002
- for (var j = 0, jj = inkList.length; j < jj; j++) {
1003
- var x = inkList[j].x - data.rect[0];
1004
- var y = data.rect[3] - inkList[j].y;
1005
- points.push(x + ',' + y);
1006
- }
816
+ }
1007
817
 
1008
- points = points.join(' ');
1009
- var borderWidth = data.borderStyle.width;
1010
- var polyline = this.svgFactory.createElement(this.svgElementName);
1011
- polyline.setAttribute('points', points);
1012
- polyline.setAttribute('stroke-width', borderWidth);
1013
- polyline.setAttribute('stroke', 'transparent');
1014
- polyline.setAttribute('fill', 'none');
818
+ class InkAnnotationElement extends AnnotationElement {
819
+ constructor(parameters) {
820
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
821
+ super(parameters, isRenderable, true);
822
+ this.containerClassName = "inkAnnotation";
823
+ this.svgElementName = "svg:polyline";
824
+ }
1015
825
 
1016
- this._createPopup(this.container, polyline, data);
826
+ render() {
827
+ this.container.className = this.containerClassName;
828
+ const data = this.data;
829
+ const width = data.rect[2] - data.rect[0];
830
+ const height = data.rect[3] - data.rect[1];
831
+ const svg = this.svgFactory.create(width, height);
1017
832
 
1018
- svg.appendChild(polyline);
1019
- }
833
+ for (const inkList of data.inkLists) {
834
+ let points = [];
1020
835
 
1021
- this.container.append(svg);
1022
- return this.container;
1023
- }
1024
- }]);
836
+ for (const coordinate of inkList) {
837
+ const x = coordinate.x - data.rect[0];
838
+ const y = data.rect[3] - coordinate.y;
839
+ points.push(`${x},${y}`);
840
+ }
1025
841
 
1026
- return InkAnnotationElement;
1027
- }(AnnotationElement);
842
+ points = points.join(" ");
843
+ const polyline = this.svgFactory.createElement(this.svgElementName);
844
+ polyline.setAttribute("points", points);
845
+ polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
846
+ polyline.setAttribute("stroke", "transparent");
847
+ polyline.setAttribute("fill", "none");
1028
848
 
1029
- var HighlightAnnotationElement =
1030
- /*#__PURE__*/
1031
- function (_AnnotationElement10) {
1032
- _inherits(HighlightAnnotationElement, _AnnotationElement10);
849
+ this._createPopup(this.container, polyline, data);
1033
850
 
1034
- function HighlightAnnotationElement(parameters) {
1035
- _classCallCheck(this, HighlightAnnotationElement);
851
+ svg.appendChild(polyline);
852
+ }
1036
853
 
1037
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
1038
- return _possibleConstructorReturn(this, _getPrototypeOf(HighlightAnnotationElement).call(this, parameters, isRenderable, true));
854
+ this.container.append(svg);
855
+ return this.container;
1039
856
  }
1040
857
 
1041
- _createClass(HighlightAnnotationElement, [{
1042
- key: "render",
1043
- value: function render() {
1044
- this.container.className = 'highlightAnnotation';
858
+ }
1045
859
 
1046
- if (!this.data.hasPopup) {
1047
- this._createPopup(this.container, null, this.data);
1048
- }
860
+ class HighlightAnnotationElement extends AnnotationElement {
861
+ constructor(parameters) {
862
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
863
+ super(parameters, isRenderable, true);
864
+ }
1049
865
 
1050
- return this.container;
1051
- }
1052
- }]);
866
+ render() {
867
+ this.container.className = "highlightAnnotation";
1053
868
 
1054
- return HighlightAnnotationElement;
1055
- }(AnnotationElement);
869
+ if (!this.data.hasPopup) {
870
+ this._createPopup(this.container, null, this.data);
871
+ }
1056
872
 
1057
- var UnderlineAnnotationElement =
1058
- /*#__PURE__*/
1059
- function (_AnnotationElement11) {
1060
- _inherits(UnderlineAnnotationElement, _AnnotationElement11);
873
+ return this.container;
874
+ }
1061
875
 
1062
- function UnderlineAnnotationElement(parameters) {
1063
- _classCallCheck(this, UnderlineAnnotationElement);
876
+ }
1064
877
 
1065
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
1066
- return _possibleConstructorReturn(this, _getPrototypeOf(UnderlineAnnotationElement).call(this, parameters, isRenderable, true));
878
+ class UnderlineAnnotationElement extends AnnotationElement {
879
+ constructor(parameters) {
880
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
881
+ super(parameters, isRenderable, true);
1067
882
  }
1068
883
 
1069
- _createClass(UnderlineAnnotationElement, [{
1070
- key: "render",
1071
- value: function render() {
1072
- this.container.className = 'underlineAnnotation';
1073
-
1074
- if (!this.data.hasPopup) {
1075
- this._createPopup(this.container, null, this.data);
1076
- }
884
+ render() {
885
+ this.container.className = "underlineAnnotation";
1077
886
 
1078
- return this.container;
887
+ if (!this.data.hasPopup) {
888
+ this._createPopup(this.container, null, this.data);
1079
889
  }
1080
- }]);
1081
-
1082
- return UnderlineAnnotationElement;
1083
- }(AnnotationElement);
1084
890
 
1085
- var SquigglyAnnotationElement =
1086
- /*#__PURE__*/
1087
- function (_AnnotationElement12) {
1088
- _inherits(SquigglyAnnotationElement, _AnnotationElement12);
891
+ return this.container;
892
+ }
1089
893
 
1090
- function SquigglyAnnotationElement(parameters) {
1091
- _classCallCheck(this, SquigglyAnnotationElement);
894
+ }
1092
895
 
1093
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
1094
- return _possibleConstructorReturn(this, _getPrototypeOf(SquigglyAnnotationElement).call(this, parameters, isRenderable, true));
896
+ class SquigglyAnnotationElement extends AnnotationElement {
897
+ constructor(parameters) {
898
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
899
+ super(parameters, isRenderable, true);
1095
900
  }
1096
901
 
1097
- _createClass(SquigglyAnnotationElement, [{
1098
- key: "render",
1099
- value: function render() {
1100
- this.container.className = 'squigglyAnnotation';
1101
-
1102
- if (!this.data.hasPopup) {
1103
- this._createPopup(this.container, null, this.data);
1104
- }
902
+ render() {
903
+ this.container.className = "squigglyAnnotation";
1105
904
 
1106
- return this.container;
905
+ if (!this.data.hasPopup) {
906
+ this._createPopup(this.container, null, this.data);
1107
907
  }
1108
- }]);
1109
908
 
1110
- return SquigglyAnnotationElement;
1111
- }(AnnotationElement);
1112
-
1113
- var StrikeOutAnnotationElement =
1114
- /*#__PURE__*/
1115
- function (_AnnotationElement13) {
1116
- _inherits(StrikeOutAnnotationElement, _AnnotationElement13);
909
+ return this.container;
910
+ }
1117
911
 
1118
- function StrikeOutAnnotationElement(parameters) {
1119
- _classCallCheck(this, StrikeOutAnnotationElement);
912
+ }
1120
913
 
1121
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
1122
- return _possibleConstructorReturn(this, _getPrototypeOf(StrikeOutAnnotationElement).call(this, parameters, isRenderable, true));
914
+ class StrikeOutAnnotationElement extends AnnotationElement {
915
+ constructor(parameters) {
916
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
917
+ super(parameters, isRenderable, true);
1123
918
  }
1124
919
 
1125
- _createClass(StrikeOutAnnotationElement, [{
1126
- key: "render",
1127
- value: function render() {
1128
- this.container.className = 'strikeoutAnnotation';
920
+ render() {
921
+ this.container.className = "strikeoutAnnotation";
1129
922
 
1130
- if (!this.data.hasPopup) {
1131
- this._createPopup(this.container, null, this.data);
1132
- }
1133
-
1134
- return this.container;
923
+ if (!this.data.hasPopup) {
924
+ this._createPopup(this.container, null, this.data);
1135
925
  }
1136
- }]);
1137
-
1138
- return StrikeOutAnnotationElement;
1139
- }(AnnotationElement);
1140
926
 
1141
- var StampAnnotationElement =
1142
- /*#__PURE__*/
1143
- function (_AnnotationElement14) {
1144
- _inherits(StampAnnotationElement, _AnnotationElement14);
927
+ return this.container;
928
+ }
1145
929
 
1146
- function StampAnnotationElement(parameters) {
1147
- _classCallCheck(this, StampAnnotationElement);
930
+ }
1148
931
 
1149
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
1150
- return _possibleConstructorReturn(this, _getPrototypeOf(StampAnnotationElement).call(this, parameters, isRenderable, true));
932
+ class StampAnnotationElement extends AnnotationElement {
933
+ constructor(parameters) {
934
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
935
+ super(parameters, isRenderable, true);
1151
936
  }
1152
937
 
1153
- _createClass(StampAnnotationElement, [{
1154
- key: "render",
1155
- value: function render() {
1156
- this.container.className = 'stampAnnotation';
1157
-
1158
- if (!this.data.hasPopup) {
1159
- this._createPopup(this.container, null, this.data);
1160
- }
938
+ render() {
939
+ this.container.className = "stampAnnotation";
1161
940
 
1162
- return this.container;
941
+ if (!this.data.hasPopup) {
942
+ this._createPopup(this.container, null, this.data);
1163
943
  }
1164
- }]);
1165
944
 
1166
- return StampAnnotationElement;
1167
- }(AnnotationElement);
945
+ return this.container;
946
+ }
1168
947
 
1169
- var FileAttachmentAnnotationElement =
1170
- /*#__PURE__*/
1171
- function (_AnnotationElement15) {
1172
- _inherits(FileAttachmentAnnotationElement, _AnnotationElement15);
948
+ }
949
+
950
+ class FileAttachmentAnnotationElement extends AnnotationElement {
951
+ constructor(parameters) {
952
+ super(parameters, true);
953
+ const {
954
+ filename,
955
+ content
956
+ } = this.data.file;
957
+ this.filename = (0, _display_utils.getFilenameFromUrl)(filename);
958
+ this.content = content;
959
+
960
+ if (this.linkService.eventBus) {
961
+ this.linkService.eventBus.dispatch("fileattachmentannotation", {
962
+ source: this,
963
+ id: (0, _util.stringToPDFString)(filename),
964
+ filename,
965
+ content
966
+ });
967
+ }
968
+ }
1173
969
 
1174
- function FileAttachmentAnnotationElement(parameters) {
1175
- var _this6;
970
+ render() {
971
+ this.container.className = "fileAttachmentAnnotation";
972
+ const trigger = document.createElement("div");
973
+ trigger.style.height = this.container.style.height;
974
+ trigger.style.width = this.container.style.width;
975
+ trigger.addEventListener("dblclick", this._download.bind(this));
1176
976
 
1177
- _classCallCheck(this, FileAttachmentAnnotationElement);
977
+ if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
978
+ this._createPopup(this.container, trigger, this.data);
979
+ }
1178
980
 
1179
- _this6 = _possibleConstructorReturn(this, _getPrototypeOf(FileAttachmentAnnotationElement).call(this, parameters, true));
1180
- var _this6$data$file = _this6.data.file,
1181
- filename = _this6$data$file.filename,
1182
- content = _this6$data$file.content;
1183
- _this6.filename = (0, _dom_utils.getFilenameFromUrl)(filename);
1184
- _this6.content = content;
981
+ this.container.appendChild(trigger);
982
+ return this.container;
983
+ }
1185
984
 
1186
- if (_this6.linkService.eventBus) {
1187
- _this6.linkService.eventBus.dispatch('fileattachmentannotation', {
1188
- source: _assertThisInitialized(_assertThisInitialized(_this6)),
1189
- id: (0, _util.stringToPDFString)(filename),
1190
- filename: filename,
1191
- content: content
1192
- });
985
+ _download() {
986
+ if (!this.downloadManager) {
987
+ (0, _util.warn)("Download cannot be started due to unavailable download manager");
988
+ return;
1193
989
  }
1194
990
 
1195
- return _this6;
991
+ this.downloadManager.downloadData(this.content, this.filename, "");
1196
992
  }
1197
993
 
1198
- _createClass(FileAttachmentAnnotationElement, [{
1199
- key: "render",
1200
- value: function render() {
1201
- this.container.className = 'fileAttachmentAnnotation';
1202
- var trigger = document.createElement('div');
1203
- trigger.style.height = this.container.style.height;
1204
- trigger.style.width = this.container.style.width;
1205
- trigger.addEventListener('dblclick', this._download.bind(this));
1206
-
1207
- if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
1208
- this._createPopup(this.container, trigger, this.data);
994
+ }
995
+
996
+ class AnnotationLayer {
997
+ static render(parameters) {
998
+ const sortedAnnotations = [],
999
+ popupAnnotations = [];
1000
+
1001
+ for (const data of parameters.annotations) {
1002
+ if (!data) {
1003
+ continue;
1209
1004
  }
1210
1005
 
1211
- this.container.appendChild(trigger);
1212
- return this.container;
1213
- }
1214
- }, {
1215
- key: "_download",
1216
- value: function _download() {
1217
- if (!this.downloadManager) {
1218
- (0, _util.warn)('Download cannot be started due to unavailable download manager');
1219
- return;
1006
+ if (data.annotationType === _util.AnnotationType.POPUP) {
1007
+ popupAnnotations.push(data);
1008
+ continue;
1220
1009
  }
1221
1010
 
1222
- this.downloadManager.downloadData(this.content, this.filename, '');
1011
+ sortedAnnotations.push(data);
1012
+ }
1013
+
1014
+ if (popupAnnotations.length) {
1015
+ sortedAnnotations.push(...popupAnnotations);
1223
1016
  }
1224
- }]);
1225
1017
 
1226
- return FileAttachmentAnnotationElement;
1227
- }(AnnotationElement);
1018
+ for (const data of sortedAnnotations) {
1019
+ const element = AnnotationElementFactory.create({
1020
+ data,
1021
+ layer: parameters.div,
1022
+ page: parameters.page,
1023
+ viewport: parameters.viewport,
1024
+ linkService: parameters.linkService,
1025
+ downloadManager: parameters.downloadManager,
1026
+ imageResourcesPath: parameters.imageResourcesPath || "",
1027
+ renderInteractiveForms: parameters.renderInteractiveForms || false,
1028
+ svgFactory: new _display_utils.DOMSVGFactory()
1029
+ });
1228
1030
 
1229
- var AnnotationLayer =
1230
- /*#__PURE__*/
1231
- function () {
1232
- function AnnotationLayer() {
1233
- _classCallCheck(this, AnnotationLayer);
1031
+ if (element.isRenderable) {
1032
+ parameters.div.appendChild(element.render());
1033
+ }
1034
+ }
1234
1035
  }
1235
1036
 
1236
- _createClass(AnnotationLayer, null, [{
1237
- key: "render",
1238
- value: function render(parameters) {
1239
- for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
1240
- var data = parameters.annotations[i];
1037
+ static update(parameters) {
1038
+ for (const data of parameters.annotations) {
1039
+ const element = parameters.div.querySelector(`[data-annotation-id="${data.id}"]`);
1241
1040
 
1242
- if (!data) {
1243
- continue;
1244
- }
1245
-
1246
- var element = AnnotationElementFactory.create({
1247
- data: data,
1248
- layer: parameters.div,
1249
- page: parameters.page,
1250
- viewport: parameters.viewport,
1251
- linkService: parameters.linkService,
1252
- downloadManager: parameters.downloadManager,
1253
- imageResourcesPath: parameters.imageResourcesPath || '',
1254
- renderInteractiveForms: parameters.renderInteractiveForms || false,
1255
- svgFactory: new _dom_utils.DOMSVGFactory()
1256
- });
1257
-
1258
- if (element.isRenderable) {
1259
- parameters.div.appendChild(element.render());
1260
- }
1041
+ if (element) {
1042
+ element.style.transform = `matrix(${parameters.viewport.transform.join(",")})`;
1261
1043
  }
1262
1044
  }
1263
- }, {
1264
- key: "update",
1265
- value: function update(parameters) {
1266
- for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
1267
- var data = parameters.annotations[i];
1268
- var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
1269
-
1270
- if (element) {
1271
- element.style.transform = 'matrix(' + parameters.viewport.transform.join(',') + ')';
1272
- }
1273
- }
1274
1045
 
1275
- parameters.div.removeAttribute('hidden');
1276
- }
1277
- }]);
1046
+ parameters.div.removeAttribute("hidden");
1047
+ }
1278
1048
 
1279
- return AnnotationLayer;
1280
- }();
1049
+ }
1281
1050
 
1282
1051
  exports.AnnotationLayer = AnnotationLayer;