@kne/react-pdf-sign 1.0.0

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.
@@ -0,0 +1,2744 @@
1
+ import { pdfjs, Document, Page } from 'react-pdf';
2
+ import { useMemo, useState, useRef, useEffect, forwardRef, useCallback, useImperativeHandle } from 'react';
3
+ import { usePreset } from '@kne/global-context';
4
+ import useResize from '@kne/use-resize';
5
+ import classnames from 'classnames';
6
+ import { Flex, Spin, App, Button } from 'antd';
7
+ import { LeftOutlined, RightOutlined } from '@ant-design/icons';
8
+ import 'react-pdf/dist/Page/TextLayer.css';
9
+ import 'react-pdf/dist/Page/AnnotationLayer.css';
10
+ import { jsxs, jsx } from 'react/jsx-runtime';
11
+ import { Stage, Layer, Group, Image, Rect, Text, Transformer } from 'react-konva';
12
+ import useControlValue from '@kne/use-control-value';
13
+ import useRefCallback from '@kne/use-ref-callback';
14
+ import useImage from 'use-image';
15
+ import { createWithIntlProvider, useIntl } from '@kne/react-intl';
16
+ import { PDFDocument } from 'pdf-lib';
17
+ import SignatureCanvas from 'react-signature-canvas';
18
+
19
+ function _extends() {
20
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
21
+ for (var e = 1; e < arguments.length; e++) {
22
+ var t = arguments[e];
23
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
24
+ }
25
+ return n;
26
+ }, _extends.apply(null, arguments);
27
+ }
28
+ function _objectWithoutPropertiesLoose(r, e) {
29
+ if (null == r) return {};
30
+ var t = {};
31
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
32
+ if (-1 !== e.indexOf(n)) continue;
33
+ t[n] = r[n];
34
+ }
35
+ return t;
36
+ }
37
+
38
+ var style = {"pdf-view-container":"_RgZXN","pdf-view":"_PAju1","pdf-view-children":"_N11Pj","pdf-view-page-control-left":"_IbVpf","pdf-view-page-control-right":"_IIgqj","pdf-view-page-control-current":"_JW3CT","signature-container":"_6TDb-","signature-canvas":"_2CGF4","signature-modal":"_kWe3k"};
39
+
40
+ const _excluded$3 = ["numPages"];
41
+ const PDFViewer = ({
42
+ className,
43
+ defaultPage,
44
+ apis: propsApis,
45
+ pdfjsUrl: pdfjsUrlProps,
46
+ url,
47
+ maxWidth: _maxWidth = 1200,
48
+ children
49
+ }) => {
50
+ var _apis$file;
51
+ const {
52
+ apis: baseApis
53
+ } = usePreset();
54
+ const apis = Object.assign({}, baseApis, propsApis);
55
+ const pdfjsUrl = pdfjsUrlProps || ((_apis$file = apis.file) == null ? void 0 : _apis$file.pdfjsUrl) || 'https://cdn.jsdelivr.net/npm/pdfjs-dist@5.4.296';
56
+ pdfjs.GlobalWorkerOptions.workerSrc = pdfjsUrl + '/build/pdf.worker.min.mjs';
57
+ const documentProps = useMemo(() => {
58
+ return {
59
+ file: url,
60
+ options: {
61
+ standardFontDataUrl: pdfjsUrl + '/standard_fonts/',
62
+ cMapUrl: pdfjsUrl + '/cmaps/',
63
+ cMapPacked: true
64
+ }
65
+ };
66
+ }, [pdfjsUrl, url]);
67
+ const [width, setWidth] = useState(_maxWidth);
68
+ const [size, setSize] = useState(null);
69
+ const [pageSize, setPageSize] = useState(0);
70
+ const [currentPage, setCurrentPage] = useState(defaultPage || 1);
71
+ const ref = useResize(() => {
72
+ if (ref.current && ref.current.clientWidth) {
73
+ setWidth(Math.min(ref.current.clientWidth, _maxWidth));
74
+ }
75
+ });
76
+ return /*#__PURE__*/jsxs("div", {
77
+ ref: ref,
78
+ className: classnames(className, style['pdf-view-container'], 'pdf-view-container'),
79
+ style: {
80
+ maxWidth: _maxWidth
81
+ },
82
+ children: [/*#__PURE__*/jsx("div", {
83
+ className: classnames(style['pdf-view'], 'pdf-view'),
84
+ children: /*#__PURE__*/jsx(Document, _extends({}, Object.assign({}, documentProps), {
85
+ loading: /*#__PURE__*/jsx(Flex, {
86
+ justify: "center",
87
+ children: /*#__PURE__*/jsx(Spin, {})
88
+ }),
89
+ onLoadSuccess: _ref => {
90
+ let {
91
+ numPages
92
+ } = _ref;
93
+ _objectWithoutPropertiesLoose(_ref, _excluded$3);
94
+ setPageSize(numPages);
95
+ if (!Number.isInteger(defaultPage)) {
96
+ setCurrentPage(numPages);
97
+ }
98
+ },
99
+ children: /*#__PURE__*/jsx(Page, {
100
+ width: width,
101
+ pageNumber: currentPage,
102
+ renderTextLayer: true,
103
+ onLoadSuccess: page => {
104
+ setSize({
105
+ width: Math.round(page.width),
106
+ height: Math.round(page.height),
107
+ originalWidth: page.originalWidth,
108
+ originalHeight: page.originalHeight
109
+ });
110
+ }
111
+ })
112
+ }))
113
+ }), size && children && /*#__PURE__*/jsx("div", {
114
+ className: classnames(style['pdf-view-children'], 'pdf-view-children'),
115
+ children: typeof children === 'function' ? children({
116
+ size,
117
+ currentPage,
118
+ pageSize
119
+ }) : children
120
+ }), /*#__PURE__*/jsxs("div", {
121
+ className: classnames(style['pdf-view-page-control'], 'pdf-view-page-control'),
122
+ children: [currentPage > 1 && /*#__PURE__*/jsx(LeftOutlined, {
123
+ className: classnames(style['pdf-view-page-control-left'], 'pdf-view-page-control-left'),
124
+ onClick: () => {
125
+ setCurrentPage(currentPage - 1);
126
+ }
127
+ }), currentPage < pageSize && /*#__PURE__*/jsx(RightOutlined, {
128
+ className: classnames(style['pdf-view-page-control-right'], 'pdf-view-page-control-right'),
129
+ onClick: () => {
130
+ setCurrentPage(currentPage + 1);
131
+ }
132
+ }), pageSize ? /*#__PURE__*/jsxs("div", {
133
+ className: classnames(style['pdf-view-page-control-current'], 'pdf-view-page-control-current'),
134
+ children: [currentPage, "/", pageSize]
135
+ }) : null]
136
+ })]
137
+ });
138
+ };
139
+
140
+ const locale$1 = {
141
+ locationLayerPlaceholder: '签名区域',
142
+ loadingError: 'PDF尚未加载成功,请稍后重试',
143
+ signatureDefaultTitle: '签名',
144
+ signatureConfirmText: '确认',
145
+ signatureCancelText: '取消',
146
+ signatureEmptyError: '签名内容不能为空',
147
+ signatureSuccess: '签名成功'
148
+ };
149
+
150
+ const locale = {
151
+ locationLayerPlaceholder: 'Signature Area',
152
+ loadingError: 'PDF is not loaded successfully, please try again later',
153
+ signatureDefaultTitle: 'Signature',
154
+ signatureConfirmText: 'Confirm',
155
+ signatureCancelText: 'Cancel',
156
+ signatureEmptyError: 'Signature content cannot be empty',
157
+ signatureSuccess: 'Signature Success'
158
+ };
159
+
160
+ const withLocale = createWithIntlProvider({
161
+ defaultLocale: 'zh-CN',
162
+ messages: {
163
+ 'zh-CN': locale$1,
164
+ 'en-US': locale
165
+ },
166
+ namespace: 'react-pdf-sign'
167
+ });
168
+
169
+ const _excluded$2 = ["width", "height", "padding", "stageWidth", "stageHeight", "placeholder", "signature"];
170
+ const LocationLayer = withLocale(p => {
171
+ const {
172
+ formatMessage
173
+ } = useIntl();
174
+ const {
175
+ width = 200,
176
+ height = 50,
177
+ padding = 8,
178
+ stageWidth,
179
+ stageHeight,
180
+ placeholder = formatMessage({
181
+ id: 'locationLayerPlaceholder'
182
+ }),
183
+ signature
184
+ } = p,
185
+ props = _objectWithoutPropertiesLoose(p, _excluded$2);
186
+ const [value, setValue] = useControlValue(props);
187
+ const [isInit, setIsInit] = useState(false);
188
+ const [signatureImage] = useImage(signature);
189
+ const groupRef = useRef();
190
+ const signRef = useRef();
191
+ const transformerRef = useRef();
192
+ const computedSignLocation = () => {
193
+ const absolutePosition = signRef.current.absolutePosition();
194
+ const size = signRef.current.getClientRect();
195
+ setValue({
196
+ size: {
197
+ width: Math.round(size.width),
198
+ height: Math.round(size.height),
199
+ x: Math.round(absolutePosition.x),
200
+ y: Math.round(absolutePosition.y)
201
+ },
202
+ scaleX: Number(transformerRef.current.attrs.scaleX.toFixed(2)),
203
+ scaleY: Number(transformerRef.current.attrs.scaleY.toFixed(2)),
204
+ x: Math.round(groupRef.current.attrs.x),
205
+ y: Math.round(groupRef.current.attrs.y)
206
+ });
207
+ };
208
+ const initValue = useRefCallback(() => {
209
+ if (['scaleX', 'scaleY', 'x', 'y', 'size'].some(name => !Object.assign({}, value).hasOwnProperty(name))) {
210
+ setValue({
211
+ scaleX: 1,
212
+ scaleY: 1,
213
+ x: Math.round((stageWidth - width) / 2),
214
+ y: Math.round((stageHeight - height) / 2),
215
+ size: {
216
+ width,
217
+ height,
218
+ x: Math.round((stageWidth - width) / 2),
219
+ y: Math.round((stageHeight - height) / 2)
220
+ }
221
+ });
222
+ setIsInit(true);
223
+ }
224
+ });
225
+ const themeColor = useMemo(() => {
226
+ const el = document.createElement('div');
227
+ el.style.color = 'var(--primary-color)';
228
+ document.body.appendChild(el);
229
+ const color = window.getComputedStyle(el).color;
230
+ document.body.removeChild(el);
231
+ return color;
232
+ }, []);
233
+ useEffect(() => {
234
+ initValue();
235
+ }, []);
236
+ useEffect(() => {
237
+ if (isInit) {
238
+ transformerRef.current.nodes([groupRef.current]);
239
+ }
240
+ }, [isInit]);
241
+ if (!(isInit && value)) {
242
+ return null;
243
+ }
244
+ return /*#__PURE__*/jsx(Stage, {
245
+ width: stageWidth,
246
+ height: stageHeight,
247
+ children: /*#__PURE__*/jsxs(Layer, {
248
+ children: [/*#__PURE__*/jsxs(Group, {
249
+ x: value.x,
250
+ y: value.y,
251
+ draggable: true,
252
+ ref: groupRef,
253
+ onDragEnd: computedSignLocation,
254
+ onTransformEnd: computedSignLocation,
255
+ children: [signatureImage ? /*#__PURE__*/jsx(Image, {
256
+ width: width,
257
+ height: height,
258
+ image: signatureImage,
259
+ cornerRadius: 8,
260
+ ref: signRef
261
+ }) : /*#__PURE__*/jsx(Rect, {
262
+ width: width,
263
+ height: height,
264
+ fill: "#f0f0f0",
265
+ cornerRadius: 8,
266
+ ref: signRef
267
+ }), /*#__PURE__*/jsx(Text, {
268
+ text: signatureImage ? '' : placeholder,
269
+ fontSize: 16,
270
+ fill: "#666666",
271
+ fontFamily: "Arial",
272
+ align: "center",
273
+ verticalAlign: "middle",
274
+ width: width,
275
+ height: height
276
+ })]
277
+ }), /*#__PURE__*/jsx(Transformer, {
278
+ scaleX: value.scaleX,
279
+ scaleY: value.scaleY,
280
+ centeredScaling: true,
281
+ ref: transformerRef,
282
+ keepRatio: true,
283
+ flipEnabled: false,
284
+ rotateEnabled: false,
285
+ borderStroke: themeColor,
286
+ rotateAnchorStroke: themeColor,
287
+ anchorStroke: themeColor,
288
+ padding: padding,
289
+ enabledAnchors: ['top-left', 'top-right', 'bottom-left', 'bottom-right']
290
+ })]
291
+ })
292
+ });
293
+ });
294
+
295
+ /**
296
+ * Removes all key-value entries from the list cache.
297
+ *
298
+ * @private
299
+ * @name clear
300
+ * @memberOf ListCache
301
+ */
302
+ function listCacheClear() {
303
+ this.__data__ = [];
304
+ this.size = 0;
305
+ }
306
+
307
+ var _listCacheClear = listCacheClear;
308
+
309
+ /**
310
+ * Performs a
311
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
312
+ * comparison between two values to determine if they are equivalent.
313
+ *
314
+ * @static
315
+ * @memberOf _
316
+ * @since 4.0.0
317
+ * @category Lang
318
+ * @param {*} value The value to compare.
319
+ * @param {*} other The other value to compare.
320
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
321
+ * @example
322
+ *
323
+ * var object = { 'a': 1 };
324
+ * var other = { 'a': 1 };
325
+ *
326
+ * _.eq(object, object);
327
+ * // => true
328
+ *
329
+ * _.eq(object, other);
330
+ * // => false
331
+ *
332
+ * _.eq('a', 'a');
333
+ * // => true
334
+ *
335
+ * _.eq('a', Object('a'));
336
+ * // => false
337
+ *
338
+ * _.eq(NaN, NaN);
339
+ * // => true
340
+ */
341
+ function eq(value, other) {
342
+ return value === other || (value !== value && other !== other);
343
+ }
344
+
345
+ var eq_1 = eq;
346
+
347
+ /**
348
+ * Gets the index at which the `key` is found in `array` of key-value pairs.
349
+ *
350
+ * @private
351
+ * @param {Array} array The array to inspect.
352
+ * @param {*} key The key to search for.
353
+ * @returns {number} Returns the index of the matched value, else `-1`.
354
+ */
355
+ function assocIndexOf(array, key) {
356
+ var length = array.length;
357
+ while (length--) {
358
+ if (eq_1(array[length][0], key)) {
359
+ return length;
360
+ }
361
+ }
362
+ return -1;
363
+ }
364
+
365
+ var _assocIndexOf = assocIndexOf;
366
+
367
+ /** Used for built-in method references. */
368
+ var arrayProto = Array.prototype;
369
+
370
+ /** Built-in value references. */
371
+ var splice = arrayProto.splice;
372
+
373
+ /**
374
+ * Removes `key` and its value from the list cache.
375
+ *
376
+ * @private
377
+ * @name delete
378
+ * @memberOf ListCache
379
+ * @param {string} key The key of the value to remove.
380
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
381
+ */
382
+ function listCacheDelete(key) {
383
+ var data = this.__data__,
384
+ index = _assocIndexOf(data, key);
385
+
386
+ if (index < 0) {
387
+ return false;
388
+ }
389
+ var lastIndex = data.length - 1;
390
+ if (index == lastIndex) {
391
+ data.pop();
392
+ } else {
393
+ splice.call(data, index, 1);
394
+ }
395
+ --this.size;
396
+ return true;
397
+ }
398
+
399
+ var _listCacheDelete = listCacheDelete;
400
+
401
+ /**
402
+ * Gets the list cache value for `key`.
403
+ *
404
+ * @private
405
+ * @name get
406
+ * @memberOf ListCache
407
+ * @param {string} key The key of the value to get.
408
+ * @returns {*} Returns the entry value.
409
+ */
410
+ function listCacheGet(key) {
411
+ var data = this.__data__,
412
+ index = _assocIndexOf(data, key);
413
+
414
+ return index < 0 ? undefined : data[index][1];
415
+ }
416
+
417
+ var _listCacheGet = listCacheGet;
418
+
419
+ /**
420
+ * Checks if a list cache value for `key` exists.
421
+ *
422
+ * @private
423
+ * @name has
424
+ * @memberOf ListCache
425
+ * @param {string} key The key of the entry to check.
426
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
427
+ */
428
+ function listCacheHas(key) {
429
+ return _assocIndexOf(this.__data__, key) > -1;
430
+ }
431
+
432
+ var _listCacheHas = listCacheHas;
433
+
434
+ /**
435
+ * Sets the list cache `key` to `value`.
436
+ *
437
+ * @private
438
+ * @name set
439
+ * @memberOf ListCache
440
+ * @param {string} key The key of the value to set.
441
+ * @param {*} value The value to set.
442
+ * @returns {Object} Returns the list cache instance.
443
+ */
444
+ function listCacheSet(key, value) {
445
+ var data = this.__data__,
446
+ index = _assocIndexOf(data, key);
447
+
448
+ if (index < 0) {
449
+ ++this.size;
450
+ data.push([key, value]);
451
+ } else {
452
+ data[index][1] = value;
453
+ }
454
+ return this;
455
+ }
456
+
457
+ var _listCacheSet = listCacheSet;
458
+
459
+ /**
460
+ * Creates an list cache object.
461
+ *
462
+ * @private
463
+ * @constructor
464
+ * @param {Array} [entries] The key-value pairs to cache.
465
+ */
466
+ function ListCache(entries) {
467
+ var index = -1,
468
+ length = entries == null ? 0 : entries.length;
469
+
470
+ this.clear();
471
+ while (++index < length) {
472
+ var entry = entries[index];
473
+ this.set(entry[0], entry[1]);
474
+ }
475
+ }
476
+
477
+ // Add methods to `ListCache`.
478
+ ListCache.prototype.clear = _listCacheClear;
479
+ ListCache.prototype['delete'] = _listCacheDelete;
480
+ ListCache.prototype.get = _listCacheGet;
481
+ ListCache.prototype.has = _listCacheHas;
482
+ ListCache.prototype.set = _listCacheSet;
483
+
484
+ var _ListCache = ListCache;
485
+
486
+ /**
487
+ * Removes all key-value entries from the stack.
488
+ *
489
+ * @private
490
+ * @name clear
491
+ * @memberOf Stack
492
+ */
493
+ function stackClear() {
494
+ this.__data__ = new _ListCache;
495
+ this.size = 0;
496
+ }
497
+
498
+ var _stackClear = stackClear;
499
+
500
+ /**
501
+ * Removes `key` and its value from the stack.
502
+ *
503
+ * @private
504
+ * @name delete
505
+ * @memberOf Stack
506
+ * @param {string} key The key of the value to remove.
507
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
508
+ */
509
+ function stackDelete(key) {
510
+ var data = this.__data__,
511
+ result = data['delete'](key);
512
+
513
+ this.size = data.size;
514
+ return result;
515
+ }
516
+
517
+ var _stackDelete = stackDelete;
518
+
519
+ /**
520
+ * Gets the stack value for `key`.
521
+ *
522
+ * @private
523
+ * @name get
524
+ * @memberOf Stack
525
+ * @param {string} key The key of the value to get.
526
+ * @returns {*} Returns the entry value.
527
+ */
528
+ function stackGet(key) {
529
+ return this.__data__.get(key);
530
+ }
531
+
532
+ var _stackGet = stackGet;
533
+
534
+ /**
535
+ * Checks if a stack value for `key` exists.
536
+ *
537
+ * @private
538
+ * @name has
539
+ * @memberOf Stack
540
+ * @param {string} key The key of the entry to check.
541
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
542
+ */
543
+ function stackHas(key) {
544
+ return this.__data__.has(key);
545
+ }
546
+
547
+ var _stackHas = stackHas;
548
+
549
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
550
+
551
+ function createCommonjsModule(fn) {
552
+ var module = { exports: {} };
553
+ return fn(module, module.exports), module.exports;
554
+ }
555
+
556
+ /** Detect free variable `global` from Node.js. */
557
+
558
+ var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
559
+
560
+ var _freeGlobal = freeGlobal;
561
+
562
+ /** Detect free variable `self`. */
563
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
564
+
565
+ /** Used as a reference to the global object. */
566
+ var root = _freeGlobal || freeSelf || Function('return this')();
567
+
568
+ var _root = root;
569
+
570
+ /** Built-in value references. */
571
+ var Symbol = _root.Symbol;
572
+
573
+ var _Symbol = Symbol;
574
+
575
+ /** Used for built-in method references. */
576
+ var objectProto$b = Object.prototype;
577
+
578
+ /** Used to check objects for own properties. */
579
+ var hasOwnProperty$8 = objectProto$b.hasOwnProperty;
580
+
581
+ /**
582
+ * Used to resolve the
583
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
584
+ * of values.
585
+ */
586
+ var nativeObjectToString$1 = objectProto$b.toString;
587
+
588
+ /** Built-in value references. */
589
+ var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
590
+
591
+ /**
592
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
593
+ *
594
+ * @private
595
+ * @param {*} value The value to query.
596
+ * @returns {string} Returns the raw `toStringTag`.
597
+ */
598
+ function getRawTag(value) {
599
+ var isOwn = hasOwnProperty$8.call(value, symToStringTag$1),
600
+ tag = value[symToStringTag$1];
601
+
602
+ try {
603
+ value[symToStringTag$1] = undefined;
604
+ var unmasked = true;
605
+ } catch (e) {}
606
+
607
+ var result = nativeObjectToString$1.call(value);
608
+ if (unmasked) {
609
+ if (isOwn) {
610
+ value[symToStringTag$1] = tag;
611
+ } else {
612
+ delete value[symToStringTag$1];
613
+ }
614
+ }
615
+ return result;
616
+ }
617
+
618
+ var _getRawTag = getRawTag;
619
+
620
+ /** Used for built-in method references. */
621
+ var objectProto$a = Object.prototype;
622
+
623
+ /**
624
+ * Used to resolve the
625
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
626
+ * of values.
627
+ */
628
+ var nativeObjectToString = objectProto$a.toString;
629
+
630
+ /**
631
+ * Converts `value` to a string using `Object.prototype.toString`.
632
+ *
633
+ * @private
634
+ * @param {*} value The value to convert.
635
+ * @returns {string} Returns the converted string.
636
+ */
637
+ function objectToString(value) {
638
+ return nativeObjectToString.call(value);
639
+ }
640
+
641
+ var _objectToString = objectToString;
642
+
643
+ /** `Object#toString` result references. */
644
+ var nullTag = '[object Null]',
645
+ undefinedTag = '[object Undefined]';
646
+
647
+ /** Built-in value references. */
648
+ var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
649
+
650
+ /**
651
+ * The base implementation of `getTag` without fallbacks for buggy environments.
652
+ *
653
+ * @private
654
+ * @param {*} value The value to query.
655
+ * @returns {string} Returns the `toStringTag`.
656
+ */
657
+ function baseGetTag(value) {
658
+ if (value == null) {
659
+ return value === undefined ? undefinedTag : nullTag;
660
+ }
661
+ return (symToStringTag && symToStringTag in Object(value))
662
+ ? _getRawTag(value)
663
+ : _objectToString(value);
664
+ }
665
+
666
+ var _baseGetTag = baseGetTag;
667
+
668
+ /**
669
+ * Checks if `value` is the
670
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
671
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
672
+ *
673
+ * @static
674
+ * @memberOf _
675
+ * @since 0.1.0
676
+ * @category Lang
677
+ * @param {*} value The value to check.
678
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
679
+ * @example
680
+ *
681
+ * _.isObject({});
682
+ * // => true
683
+ *
684
+ * _.isObject([1, 2, 3]);
685
+ * // => true
686
+ *
687
+ * _.isObject(_.noop);
688
+ * // => true
689
+ *
690
+ * _.isObject(null);
691
+ * // => false
692
+ */
693
+ function isObject(value) {
694
+ var type = typeof value;
695
+ return value != null && (type == 'object' || type == 'function');
696
+ }
697
+
698
+ var isObject_1 = isObject;
699
+
700
+ /** `Object#toString` result references. */
701
+ var asyncTag = '[object AsyncFunction]',
702
+ funcTag$1 = '[object Function]',
703
+ genTag = '[object GeneratorFunction]',
704
+ proxyTag = '[object Proxy]';
705
+
706
+ /**
707
+ * Checks if `value` is classified as a `Function` object.
708
+ *
709
+ * @static
710
+ * @memberOf _
711
+ * @since 0.1.0
712
+ * @category Lang
713
+ * @param {*} value The value to check.
714
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
715
+ * @example
716
+ *
717
+ * _.isFunction(_);
718
+ * // => true
719
+ *
720
+ * _.isFunction(/abc/);
721
+ * // => false
722
+ */
723
+ function isFunction(value) {
724
+ if (!isObject_1(value)) {
725
+ return false;
726
+ }
727
+ // The use of `Object#toString` avoids issues with the `typeof` operator
728
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
729
+ var tag = _baseGetTag(value);
730
+ return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
731
+ }
732
+
733
+ var isFunction_1 = isFunction;
734
+
735
+ /** Used to detect overreaching core-js shims. */
736
+ var coreJsData = _root['__core-js_shared__'];
737
+
738
+ var _coreJsData = coreJsData;
739
+
740
+ /** Used to detect methods masquerading as native. */
741
+ var maskSrcKey = (function() {
742
+ var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || '');
743
+ return uid ? ('Symbol(src)_1.' + uid) : '';
744
+ }());
745
+
746
+ /**
747
+ * Checks if `func` has its source masked.
748
+ *
749
+ * @private
750
+ * @param {Function} func The function to check.
751
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
752
+ */
753
+ function isMasked(func) {
754
+ return !!maskSrcKey && (maskSrcKey in func);
755
+ }
756
+
757
+ var _isMasked = isMasked;
758
+
759
+ /** Used for built-in method references. */
760
+ var funcProto$1 = Function.prototype;
761
+
762
+ /** Used to resolve the decompiled source of functions. */
763
+ var funcToString$1 = funcProto$1.toString;
764
+
765
+ /**
766
+ * Converts `func` to its source code.
767
+ *
768
+ * @private
769
+ * @param {Function} func The function to convert.
770
+ * @returns {string} Returns the source code.
771
+ */
772
+ function toSource(func) {
773
+ if (func != null) {
774
+ try {
775
+ return funcToString$1.call(func);
776
+ } catch (e) {}
777
+ try {
778
+ return (func + '');
779
+ } catch (e) {}
780
+ }
781
+ return '';
782
+ }
783
+
784
+ var _toSource = toSource;
785
+
786
+ /**
787
+ * Used to match `RegExp`
788
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
789
+ */
790
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
791
+
792
+ /** Used to detect host constructors (Safari). */
793
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
794
+
795
+ /** Used for built-in method references. */
796
+ var funcProto = Function.prototype,
797
+ objectProto$9 = Object.prototype;
798
+
799
+ /** Used to resolve the decompiled source of functions. */
800
+ var funcToString = funcProto.toString;
801
+
802
+ /** Used to check objects for own properties. */
803
+ var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
804
+
805
+ /** Used to detect if a method is native. */
806
+ var reIsNative = RegExp('^' +
807
+ funcToString.call(hasOwnProperty$7).replace(reRegExpChar, '\\$&')
808
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
809
+ );
810
+
811
+ /**
812
+ * The base implementation of `_.isNative` without bad shim checks.
813
+ *
814
+ * @private
815
+ * @param {*} value The value to check.
816
+ * @returns {boolean} Returns `true` if `value` is a native function,
817
+ * else `false`.
818
+ */
819
+ function baseIsNative(value) {
820
+ if (!isObject_1(value) || _isMasked(value)) {
821
+ return false;
822
+ }
823
+ var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor;
824
+ return pattern.test(_toSource(value));
825
+ }
826
+
827
+ var _baseIsNative = baseIsNative;
828
+
829
+ /**
830
+ * Gets the value at `key` of `object`.
831
+ *
832
+ * @private
833
+ * @param {Object} [object] The object to query.
834
+ * @param {string} key The key of the property to get.
835
+ * @returns {*} Returns the property value.
836
+ */
837
+ function getValue(object, key) {
838
+ return object == null ? undefined : object[key];
839
+ }
840
+
841
+ var _getValue = getValue;
842
+
843
+ /**
844
+ * Gets the native function at `key` of `object`.
845
+ *
846
+ * @private
847
+ * @param {Object} object The object to query.
848
+ * @param {string} key The key of the method to get.
849
+ * @returns {*} Returns the function if it's native, else `undefined`.
850
+ */
851
+ function getNative(object, key) {
852
+ var value = _getValue(object, key);
853
+ return _baseIsNative(value) ? value : undefined;
854
+ }
855
+
856
+ var _getNative = getNative;
857
+
858
+ /* Built-in method references that are verified to be native. */
859
+ var Map = _getNative(_root, 'Map');
860
+
861
+ var _Map = Map;
862
+
863
+ /* Built-in method references that are verified to be native. */
864
+ var nativeCreate = _getNative(Object, 'create');
865
+
866
+ var _nativeCreate = nativeCreate;
867
+
868
+ /**
869
+ * Removes all key-value entries from the hash.
870
+ *
871
+ * @private
872
+ * @name clear
873
+ * @memberOf Hash
874
+ */
875
+ function hashClear() {
876
+ this.__data__ = _nativeCreate ? _nativeCreate(null) : {};
877
+ this.size = 0;
878
+ }
879
+
880
+ var _hashClear = hashClear;
881
+
882
+ /**
883
+ * Removes `key` and its value from the hash.
884
+ *
885
+ * @private
886
+ * @name delete
887
+ * @memberOf Hash
888
+ * @param {Object} hash The hash to modify.
889
+ * @param {string} key The key of the value to remove.
890
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
891
+ */
892
+ function hashDelete(key) {
893
+ var result = this.has(key) && delete this.__data__[key];
894
+ this.size -= result ? 1 : 0;
895
+ return result;
896
+ }
897
+
898
+ var _hashDelete = hashDelete;
899
+
900
+ /** Used to stand-in for `undefined` hash values. */
901
+ var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
902
+
903
+ /** Used for built-in method references. */
904
+ var objectProto$8 = Object.prototype;
905
+
906
+ /** Used to check objects for own properties. */
907
+ var hasOwnProperty$6 = objectProto$8.hasOwnProperty;
908
+
909
+ /**
910
+ * Gets the hash value for `key`.
911
+ *
912
+ * @private
913
+ * @name get
914
+ * @memberOf Hash
915
+ * @param {string} key The key of the value to get.
916
+ * @returns {*} Returns the entry value.
917
+ */
918
+ function hashGet(key) {
919
+ var data = this.__data__;
920
+ if (_nativeCreate) {
921
+ var result = data[key];
922
+ return result === HASH_UNDEFINED$2 ? undefined : result;
923
+ }
924
+ return hasOwnProperty$6.call(data, key) ? data[key] : undefined;
925
+ }
926
+
927
+ var _hashGet = hashGet;
928
+
929
+ /** Used for built-in method references. */
930
+ var objectProto$7 = Object.prototype;
931
+
932
+ /** Used to check objects for own properties. */
933
+ var hasOwnProperty$5 = objectProto$7.hasOwnProperty;
934
+
935
+ /**
936
+ * Checks if a hash value for `key` exists.
937
+ *
938
+ * @private
939
+ * @name has
940
+ * @memberOf Hash
941
+ * @param {string} key The key of the entry to check.
942
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
943
+ */
944
+ function hashHas(key) {
945
+ var data = this.__data__;
946
+ return _nativeCreate ? (data[key] !== undefined) : hasOwnProperty$5.call(data, key);
947
+ }
948
+
949
+ var _hashHas = hashHas;
950
+
951
+ /** Used to stand-in for `undefined` hash values. */
952
+ var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
953
+
954
+ /**
955
+ * Sets the hash `key` to `value`.
956
+ *
957
+ * @private
958
+ * @name set
959
+ * @memberOf Hash
960
+ * @param {string} key The key of the value to set.
961
+ * @param {*} value The value to set.
962
+ * @returns {Object} Returns the hash instance.
963
+ */
964
+ function hashSet(key, value) {
965
+ var data = this.__data__;
966
+ this.size += this.has(key) ? 0 : 1;
967
+ data[key] = (_nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
968
+ return this;
969
+ }
970
+
971
+ var _hashSet = hashSet;
972
+
973
+ /**
974
+ * Creates a hash object.
975
+ *
976
+ * @private
977
+ * @constructor
978
+ * @param {Array} [entries] The key-value pairs to cache.
979
+ */
980
+ function Hash(entries) {
981
+ var index = -1,
982
+ length = entries == null ? 0 : entries.length;
983
+
984
+ this.clear();
985
+ while (++index < length) {
986
+ var entry = entries[index];
987
+ this.set(entry[0], entry[1]);
988
+ }
989
+ }
990
+
991
+ // Add methods to `Hash`.
992
+ Hash.prototype.clear = _hashClear;
993
+ Hash.prototype['delete'] = _hashDelete;
994
+ Hash.prototype.get = _hashGet;
995
+ Hash.prototype.has = _hashHas;
996
+ Hash.prototype.set = _hashSet;
997
+
998
+ var _Hash = Hash;
999
+
1000
+ /**
1001
+ * Removes all key-value entries from the map.
1002
+ *
1003
+ * @private
1004
+ * @name clear
1005
+ * @memberOf MapCache
1006
+ */
1007
+ function mapCacheClear() {
1008
+ this.size = 0;
1009
+ this.__data__ = {
1010
+ 'hash': new _Hash,
1011
+ 'map': new (_Map || _ListCache),
1012
+ 'string': new _Hash
1013
+ };
1014
+ }
1015
+
1016
+ var _mapCacheClear = mapCacheClear;
1017
+
1018
+ /**
1019
+ * Checks if `value` is suitable for use as unique object key.
1020
+ *
1021
+ * @private
1022
+ * @param {*} value The value to check.
1023
+ * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1024
+ */
1025
+ function isKeyable(value) {
1026
+ var type = typeof value;
1027
+ return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1028
+ ? (value !== '__proto__')
1029
+ : (value === null);
1030
+ }
1031
+
1032
+ var _isKeyable = isKeyable;
1033
+
1034
+ /**
1035
+ * Gets the data for `map`.
1036
+ *
1037
+ * @private
1038
+ * @param {Object} map The map to query.
1039
+ * @param {string} key The reference key.
1040
+ * @returns {*} Returns the map data.
1041
+ */
1042
+ function getMapData(map, key) {
1043
+ var data = map.__data__;
1044
+ return _isKeyable(key)
1045
+ ? data[typeof key == 'string' ? 'string' : 'hash']
1046
+ : data.map;
1047
+ }
1048
+
1049
+ var _getMapData = getMapData;
1050
+
1051
+ /**
1052
+ * Removes `key` and its value from the map.
1053
+ *
1054
+ * @private
1055
+ * @name delete
1056
+ * @memberOf MapCache
1057
+ * @param {string} key The key of the value to remove.
1058
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1059
+ */
1060
+ function mapCacheDelete(key) {
1061
+ var result = _getMapData(this, key)['delete'](key);
1062
+ this.size -= result ? 1 : 0;
1063
+ return result;
1064
+ }
1065
+
1066
+ var _mapCacheDelete = mapCacheDelete;
1067
+
1068
+ /**
1069
+ * Gets the map value for `key`.
1070
+ *
1071
+ * @private
1072
+ * @name get
1073
+ * @memberOf MapCache
1074
+ * @param {string} key The key of the value to get.
1075
+ * @returns {*} Returns the entry value.
1076
+ */
1077
+ function mapCacheGet(key) {
1078
+ return _getMapData(this, key).get(key);
1079
+ }
1080
+
1081
+ var _mapCacheGet = mapCacheGet;
1082
+
1083
+ /**
1084
+ * Checks if a map value for `key` exists.
1085
+ *
1086
+ * @private
1087
+ * @name has
1088
+ * @memberOf MapCache
1089
+ * @param {string} key The key of the entry to check.
1090
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1091
+ */
1092
+ function mapCacheHas(key) {
1093
+ return _getMapData(this, key).has(key);
1094
+ }
1095
+
1096
+ var _mapCacheHas = mapCacheHas;
1097
+
1098
+ /**
1099
+ * Sets the map `key` to `value`.
1100
+ *
1101
+ * @private
1102
+ * @name set
1103
+ * @memberOf MapCache
1104
+ * @param {string} key The key of the value to set.
1105
+ * @param {*} value The value to set.
1106
+ * @returns {Object} Returns the map cache instance.
1107
+ */
1108
+ function mapCacheSet(key, value) {
1109
+ var data = _getMapData(this, key),
1110
+ size = data.size;
1111
+
1112
+ data.set(key, value);
1113
+ this.size += data.size == size ? 0 : 1;
1114
+ return this;
1115
+ }
1116
+
1117
+ var _mapCacheSet = mapCacheSet;
1118
+
1119
+ /**
1120
+ * Creates a map cache object to store key-value pairs.
1121
+ *
1122
+ * @private
1123
+ * @constructor
1124
+ * @param {Array} [entries] The key-value pairs to cache.
1125
+ */
1126
+ function MapCache(entries) {
1127
+ var index = -1,
1128
+ length = entries == null ? 0 : entries.length;
1129
+
1130
+ this.clear();
1131
+ while (++index < length) {
1132
+ var entry = entries[index];
1133
+ this.set(entry[0], entry[1]);
1134
+ }
1135
+ }
1136
+
1137
+ // Add methods to `MapCache`.
1138
+ MapCache.prototype.clear = _mapCacheClear;
1139
+ MapCache.prototype['delete'] = _mapCacheDelete;
1140
+ MapCache.prototype.get = _mapCacheGet;
1141
+ MapCache.prototype.has = _mapCacheHas;
1142
+ MapCache.prototype.set = _mapCacheSet;
1143
+
1144
+ var _MapCache = MapCache;
1145
+
1146
+ /** Used as the size to enable large array optimizations. */
1147
+ var LARGE_ARRAY_SIZE = 200;
1148
+
1149
+ /**
1150
+ * Sets the stack `key` to `value`.
1151
+ *
1152
+ * @private
1153
+ * @name set
1154
+ * @memberOf Stack
1155
+ * @param {string} key The key of the value to set.
1156
+ * @param {*} value The value to set.
1157
+ * @returns {Object} Returns the stack cache instance.
1158
+ */
1159
+ function stackSet(key, value) {
1160
+ var data = this.__data__;
1161
+ if (data instanceof _ListCache) {
1162
+ var pairs = data.__data__;
1163
+ if (!_Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
1164
+ pairs.push([key, value]);
1165
+ this.size = ++data.size;
1166
+ return this;
1167
+ }
1168
+ data = this.__data__ = new _MapCache(pairs);
1169
+ }
1170
+ data.set(key, value);
1171
+ this.size = data.size;
1172
+ return this;
1173
+ }
1174
+
1175
+ var _stackSet = stackSet;
1176
+
1177
+ /**
1178
+ * Creates a stack cache object to store key-value pairs.
1179
+ *
1180
+ * @private
1181
+ * @constructor
1182
+ * @param {Array} [entries] The key-value pairs to cache.
1183
+ */
1184
+ function Stack(entries) {
1185
+ var data = this.__data__ = new _ListCache(entries);
1186
+ this.size = data.size;
1187
+ }
1188
+
1189
+ // Add methods to `Stack`.
1190
+ Stack.prototype.clear = _stackClear;
1191
+ Stack.prototype['delete'] = _stackDelete;
1192
+ Stack.prototype.get = _stackGet;
1193
+ Stack.prototype.has = _stackHas;
1194
+ Stack.prototype.set = _stackSet;
1195
+
1196
+ var _Stack = Stack;
1197
+
1198
+ /** Used to stand-in for `undefined` hash values. */
1199
+ var HASH_UNDEFINED = '__lodash_hash_undefined__';
1200
+
1201
+ /**
1202
+ * Adds `value` to the array cache.
1203
+ *
1204
+ * @private
1205
+ * @name add
1206
+ * @memberOf SetCache
1207
+ * @alias push
1208
+ * @param {*} value The value to cache.
1209
+ * @returns {Object} Returns the cache instance.
1210
+ */
1211
+ function setCacheAdd(value) {
1212
+ this.__data__.set(value, HASH_UNDEFINED);
1213
+ return this;
1214
+ }
1215
+
1216
+ var _setCacheAdd = setCacheAdd;
1217
+
1218
+ /**
1219
+ * Checks if `value` is in the array cache.
1220
+ *
1221
+ * @private
1222
+ * @name has
1223
+ * @memberOf SetCache
1224
+ * @param {*} value The value to search for.
1225
+ * @returns {number} Returns `true` if `value` is found, else `false`.
1226
+ */
1227
+ function setCacheHas(value) {
1228
+ return this.__data__.has(value);
1229
+ }
1230
+
1231
+ var _setCacheHas = setCacheHas;
1232
+
1233
+ /**
1234
+ *
1235
+ * Creates an array cache object to store unique values.
1236
+ *
1237
+ * @private
1238
+ * @constructor
1239
+ * @param {Array} [values] The values to cache.
1240
+ */
1241
+ function SetCache(values) {
1242
+ var index = -1,
1243
+ length = values == null ? 0 : values.length;
1244
+
1245
+ this.__data__ = new _MapCache;
1246
+ while (++index < length) {
1247
+ this.add(values[index]);
1248
+ }
1249
+ }
1250
+
1251
+ // Add methods to `SetCache`.
1252
+ SetCache.prototype.add = SetCache.prototype.push = _setCacheAdd;
1253
+ SetCache.prototype.has = _setCacheHas;
1254
+
1255
+ var _SetCache = SetCache;
1256
+
1257
+ /**
1258
+ * A specialized version of `_.some` for arrays without support for iteratee
1259
+ * shorthands.
1260
+ *
1261
+ * @private
1262
+ * @param {Array} [array] The array to iterate over.
1263
+ * @param {Function} predicate The function invoked per iteration.
1264
+ * @returns {boolean} Returns `true` if any element passes the predicate check,
1265
+ * else `false`.
1266
+ */
1267
+ function arraySome(array, predicate) {
1268
+ var index = -1,
1269
+ length = array == null ? 0 : array.length;
1270
+
1271
+ while (++index < length) {
1272
+ if (predicate(array[index], index, array)) {
1273
+ return true;
1274
+ }
1275
+ }
1276
+ return false;
1277
+ }
1278
+
1279
+ var _arraySome = arraySome;
1280
+
1281
+ /**
1282
+ * Checks if a `cache` value for `key` exists.
1283
+ *
1284
+ * @private
1285
+ * @param {Object} cache The cache to query.
1286
+ * @param {string} key The key of the entry to check.
1287
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1288
+ */
1289
+ function cacheHas(cache, key) {
1290
+ return cache.has(key);
1291
+ }
1292
+
1293
+ var _cacheHas = cacheHas;
1294
+
1295
+ /** Used to compose bitmasks for value comparisons. */
1296
+ var COMPARE_PARTIAL_FLAG$3 = 1,
1297
+ COMPARE_UNORDERED_FLAG$1 = 2;
1298
+
1299
+ /**
1300
+ * A specialized version of `baseIsEqualDeep` for arrays with support for
1301
+ * partial deep comparisons.
1302
+ *
1303
+ * @private
1304
+ * @param {Array} array The array to compare.
1305
+ * @param {Array} other The other array to compare.
1306
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1307
+ * @param {Function} customizer The function to customize comparisons.
1308
+ * @param {Function} equalFunc The function to determine equivalents of values.
1309
+ * @param {Object} stack Tracks traversed `array` and `other` objects.
1310
+ * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
1311
+ */
1312
+ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
1313
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3,
1314
+ arrLength = array.length,
1315
+ othLength = other.length;
1316
+
1317
+ if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
1318
+ return false;
1319
+ }
1320
+ // Check that cyclic values are equal.
1321
+ var arrStacked = stack.get(array);
1322
+ var othStacked = stack.get(other);
1323
+ if (arrStacked && othStacked) {
1324
+ return arrStacked == other && othStacked == array;
1325
+ }
1326
+ var index = -1,
1327
+ result = true,
1328
+ seen = (bitmask & COMPARE_UNORDERED_FLAG$1) ? new _SetCache : undefined;
1329
+
1330
+ stack.set(array, other);
1331
+ stack.set(other, array);
1332
+
1333
+ // Ignore non-index properties.
1334
+ while (++index < arrLength) {
1335
+ var arrValue = array[index],
1336
+ othValue = other[index];
1337
+
1338
+ if (customizer) {
1339
+ var compared = isPartial
1340
+ ? customizer(othValue, arrValue, index, other, array, stack)
1341
+ : customizer(arrValue, othValue, index, array, other, stack);
1342
+ }
1343
+ if (compared !== undefined) {
1344
+ if (compared) {
1345
+ continue;
1346
+ }
1347
+ result = false;
1348
+ break;
1349
+ }
1350
+ // Recursively compare arrays (susceptible to call stack limits).
1351
+ if (seen) {
1352
+ if (!_arraySome(other, function(othValue, othIndex) {
1353
+ if (!_cacheHas(seen, othIndex) &&
1354
+ (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
1355
+ return seen.push(othIndex);
1356
+ }
1357
+ })) {
1358
+ result = false;
1359
+ break;
1360
+ }
1361
+ } else if (!(
1362
+ arrValue === othValue ||
1363
+ equalFunc(arrValue, othValue, bitmask, customizer, stack)
1364
+ )) {
1365
+ result = false;
1366
+ break;
1367
+ }
1368
+ }
1369
+ stack['delete'](array);
1370
+ stack['delete'](other);
1371
+ return result;
1372
+ }
1373
+
1374
+ var _equalArrays = equalArrays;
1375
+
1376
+ /** Built-in value references. */
1377
+ var Uint8Array$1 = _root.Uint8Array;
1378
+
1379
+ var _Uint8Array = Uint8Array$1;
1380
+
1381
+ /**
1382
+ * Converts `map` to its key-value pairs.
1383
+ *
1384
+ * @private
1385
+ * @param {Object} map The map to convert.
1386
+ * @returns {Array} Returns the key-value pairs.
1387
+ */
1388
+ function mapToArray(map) {
1389
+ var index = -1,
1390
+ result = Array(map.size);
1391
+
1392
+ map.forEach(function(value, key) {
1393
+ result[++index] = [key, value];
1394
+ });
1395
+ return result;
1396
+ }
1397
+
1398
+ var _mapToArray = mapToArray;
1399
+
1400
+ /**
1401
+ * Converts `set` to an array of its values.
1402
+ *
1403
+ * @private
1404
+ * @param {Object} set The set to convert.
1405
+ * @returns {Array} Returns the values.
1406
+ */
1407
+ function setToArray(set) {
1408
+ var index = -1,
1409
+ result = Array(set.size);
1410
+
1411
+ set.forEach(function(value) {
1412
+ result[++index] = value;
1413
+ });
1414
+ return result;
1415
+ }
1416
+
1417
+ var _setToArray = setToArray;
1418
+
1419
+ /** Used to compose bitmasks for value comparisons. */
1420
+ var COMPARE_PARTIAL_FLAG$2 = 1,
1421
+ COMPARE_UNORDERED_FLAG = 2;
1422
+
1423
+ /** `Object#toString` result references. */
1424
+ var boolTag$1 = '[object Boolean]',
1425
+ dateTag$1 = '[object Date]',
1426
+ errorTag$1 = '[object Error]',
1427
+ mapTag$2 = '[object Map]',
1428
+ numberTag$1 = '[object Number]',
1429
+ regexpTag$1 = '[object RegExp]',
1430
+ setTag$2 = '[object Set]',
1431
+ stringTag$1 = '[object String]',
1432
+ symbolTag = '[object Symbol]';
1433
+
1434
+ var arrayBufferTag$1 = '[object ArrayBuffer]',
1435
+ dataViewTag$2 = '[object DataView]';
1436
+
1437
+ /** Used to convert symbols to primitives and strings. */
1438
+ var symbolProto = _Symbol ? _Symbol.prototype : undefined,
1439
+ symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
1440
+
1441
+ /**
1442
+ * A specialized version of `baseIsEqualDeep` for comparing objects of
1443
+ * the same `toStringTag`.
1444
+ *
1445
+ * **Note:** This function only supports comparing values with tags of
1446
+ * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
1447
+ *
1448
+ * @private
1449
+ * @param {Object} object The object to compare.
1450
+ * @param {Object} other The other object to compare.
1451
+ * @param {string} tag The `toStringTag` of the objects to compare.
1452
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1453
+ * @param {Function} customizer The function to customize comparisons.
1454
+ * @param {Function} equalFunc The function to determine equivalents of values.
1455
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
1456
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1457
+ */
1458
+ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
1459
+ switch (tag) {
1460
+ case dataViewTag$2:
1461
+ if ((object.byteLength != other.byteLength) ||
1462
+ (object.byteOffset != other.byteOffset)) {
1463
+ return false;
1464
+ }
1465
+ object = object.buffer;
1466
+ other = other.buffer;
1467
+
1468
+ case arrayBufferTag$1:
1469
+ if ((object.byteLength != other.byteLength) ||
1470
+ !equalFunc(new _Uint8Array(object), new _Uint8Array(other))) {
1471
+ return false;
1472
+ }
1473
+ return true;
1474
+
1475
+ case boolTag$1:
1476
+ case dateTag$1:
1477
+ case numberTag$1:
1478
+ // Coerce booleans to `1` or `0` and dates to milliseconds.
1479
+ // Invalid dates are coerced to `NaN`.
1480
+ return eq_1(+object, +other);
1481
+
1482
+ case errorTag$1:
1483
+ return object.name == other.name && object.message == other.message;
1484
+
1485
+ case regexpTag$1:
1486
+ case stringTag$1:
1487
+ // Coerce regexes to strings and treat strings, primitives and objects,
1488
+ // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
1489
+ // for more details.
1490
+ return object == (other + '');
1491
+
1492
+ case mapTag$2:
1493
+ var convert = _mapToArray;
1494
+
1495
+ case setTag$2:
1496
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG$2;
1497
+ convert || (convert = _setToArray);
1498
+
1499
+ if (object.size != other.size && !isPartial) {
1500
+ return false;
1501
+ }
1502
+ // Assume cyclic values are equal.
1503
+ var stacked = stack.get(object);
1504
+ if (stacked) {
1505
+ return stacked == other;
1506
+ }
1507
+ bitmask |= COMPARE_UNORDERED_FLAG;
1508
+
1509
+ // Recursively compare objects (susceptible to call stack limits).
1510
+ stack.set(object, other);
1511
+ var result = _equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
1512
+ stack['delete'](object);
1513
+ return result;
1514
+
1515
+ case symbolTag:
1516
+ if (symbolValueOf) {
1517
+ return symbolValueOf.call(object) == symbolValueOf.call(other);
1518
+ }
1519
+ }
1520
+ return false;
1521
+ }
1522
+
1523
+ var _equalByTag = equalByTag;
1524
+
1525
+ /**
1526
+ * Appends the elements of `values` to `array`.
1527
+ *
1528
+ * @private
1529
+ * @param {Array} array The array to modify.
1530
+ * @param {Array} values The values to append.
1531
+ * @returns {Array} Returns `array`.
1532
+ */
1533
+ function arrayPush(array, values) {
1534
+ var index = -1,
1535
+ length = values.length,
1536
+ offset = array.length;
1537
+
1538
+ while (++index < length) {
1539
+ array[offset + index] = values[index];
1540
+ }
1541
+ return array;
1542
+ }
1543
+
1544
+ var _arrayPush = arrayPush;
1545
+
1546
+ /**
1547
+ * Checks if `value` is classified as an `Array` object.
1548
+ *
1549
+ * @static
1550
+ * @memberOf _
1551
+ * @since 0.1.0
1552
+ * @category Lang
1553
+ * @param {*} value The value to check.
1554
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
1555
+ * @example
1556
+ *
1557
+ * _.isArray([1, 2, 3]);
1558
+ * // => true
1559
+ *
1560
+ * _.isArray(document.body.children);
1561
+ * // => false
1562
+ *
1563
+ * _.isArray('abc');
1564
+ * // => false
1565
+ *
1566
+ * _.isArray(_.noop);
1567
+ * // => false
1568
+ */
1569
+ var isArray = Array.isArray;
1570
+
1571
+ var isArray_1 = isArray;
1572
+
1573
+ /**
1574
+ * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
1575
+ * `keysFunc` and `symbolsFunc` to get the enumerable property names and
1576
+ * symbols of `object`.
1577
+ *
1578
+ * @private
1579
+ * @param {Object} object The object to query.
1580
+ * @param {Function} keysFunc The function to get the keys of `object`.
1581
+ * @param {Function} symbolsFunc The function to get the symbols of `object`.
1582
+ * @returns {Array} Returns the array of property names and symbols.
1583
+ */
1584
+ function baseGetAllKeys(object, keysFunc, symbolsFunc) {
1585
+ var result = keysFunc(object);
1586
+ return isArray_1(object) ? result : _arrayPush(result, symbolsFunc(object));
1587
+ }
1588
+
1589
+ var _baseGetAllKeys = baseGetAllKeys;
1590
+
1591
+ /**
1592
+ * A specialized version of `_.filter` for arrays without support for
1593
+ * iteratee shorthands.
1594
+ *
1595
+ * @private
1596
+ * @param {Array} [array] The array to iterate over.
1597
+ * @param {Function} predicate The function invoked per iteration.
1598
+ * @returns {Array} Returns the new filtered array.
1599
+ */
1600
+ function arrayFilter(array, predicate) {
1601
+ var index = -1,
1602
+ length = array == null ? 0 : array.length,
1603
+ resIndex = 0,
1604
+ result = [];
1605
+
1606
+ while (++index < length) {
1607
+ var value = array[index];
1608
+ if (predicate(value, index, array)) {
1609
+ result[resIndex++] = value;
1610
+ }
1611
+ }
1612
+ return result;
1613
+ }
1614
+
1615
+ var _arrayFilter = arrayFilter;
1616
+
1617
+ /**
1618
+ * This method returns a new empty array.
1619
+ *
1620
+ * @static
1621
+ * @memberOf _
1622
+ * @since 4.13.0
1623
+ * @category Util
1624
+ * @returns {Array} Returns the new empty array.
1625
+ * @example
1626
+ *
1627
+ * var arrays = _.times(2, _.stubArray);
1628
+ *
1629
+ * console.log(arrays);
1630
+ * // => [[], []]
1631
+ *
1632
+ * console.log(arrays[0] === arrays[1]);
1633
+ * // => false
1634
+ */
1635
+ function stubArray() {
1636
+ return [];
1637
+ }
1638
+
1639
+ var stubArray_1 = stubArray;
1640
+
1641
+ /** Used for built-in method references. */
1642
+ var objectProto$6 = Object.prototype;
1643
+
1644
+ /** Built-in value references. */
1645
+ var propertyIsEnumerable$1 = objectProto$6.propertyIsEnumerable;
1646
+
1647
+ /* Built-in method references for those with the same name as other `lodash` methods. */
1648
+ var nativeGetSymbols = Object.getOwnPropertySymbols;
1649
+
1650
+ /**
1651
+ * Creates an array of the own enumerable symbols of `object`.
1652
+ *
1653
+ * @private
1654
+ * @param {Object} object The object to query.
1655
+ * @returns {Array} Returns the array of symbols.
1656
+ */
1657
+ var getSymbols = !nativeGetSymbols ? stubArray_1 : function(object) {
1658
+ if (object == null) {
1659
+ return [];
1660
+ }
1661
+ object = Object(object);
1662
+ return _arrayFilter(nativeGetSymbols(object), function(symbol) {
1663
+ return propertyIsEnumerable$1.call(object, symbol);
1664
+ });
1665
+ };
1666
+
1667
+ var _getSymbols = getSymbols;
1668
+
1669
+ /**
1670
+ * The base implementation of `_.times` without support for iteratee shorthands
1671
+ * or max array length checks.
1672
+ *
1673
+ * @private
1674
+ * @param {number} n The number of times to invoke `iteratee`.
1675
+ * @param {Function} iteratee The function invoked per iteration.
1676
+ * @returns {Array} Returns the array of results.
1677
+ */
1678
+ function baseTimes(n, iteratee) {
1679
+ var index = -1,
1680
+ result = Array(n);
1681
+
1682
+ while (++index < n) {
1683
+ result[index] = iteratee(index);
1684
+ }
1685
+ return result;
1686
+ }
1687
+
1688
+ var _baseTimes = baseTimes;
1689
+
1690
+ /**
1691
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
1692
+ * and has a `typeof` result of "object".
1693
+ *
1694
+ * @static
1695
+ * @memberOf _
1696
+ * @since 4.0.0
1697
+ * @category Lang
1698
+ * @param {*} value The value to check.
1699
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
1700
+ * @example
1701
+ *
1702
+ * _.isObjectLike({});
1703
+ * // => true
1704
+ *
1705
+ * _.isObjectLike([1, 2, 3]);
1706
+ * // => true
1707
+ *
1708
+ * _.isObjectLike(_.noop);
1709
+ * // => false
1710
+ *
1711
+ * _.isObjectLike(null);
1712
+ * // => false
1713
+ */
1714
+ function isObjectLike(value) {
1715
+ return value != null && typeof value == 'object';
1716
+ }
1717
+
1718
+ var isObjectLike_1 = isObjectLike;
1719
+
1720
+ /** `Object#toString` result references. */
1721
+ var argsTag$2 = '[object Arguments]';
1722
+
1723
+ /**
1724
+ * The base implementation of `_.isArguments`.
1725
+ *
1726
+ * @private
1727
+ * @param {*} value The value to check.
1728
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1729
+ */
1730
+ function baseIsArguments(value) {
1731
+ return isObjectLike_1(value) && _baseGetTag(value) == argsTag$2;
1732
+ }
1733
+
1734
+ var _baseIsArguments = baseIsArguments;
1735
+
1736
+ /** Used for built-in method references. */
1737
+ var objectProto$5 = Object.prototype;
1738
+
1739
+ /** Used to check objects for own properties. */
1740
+ var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
1741
+
1742
+ /** Built-in value references. */
1743
+ var propertyIsEnumerable = objectProto$5.propertyIsEnumerable;
1744
+
1745
+ /**
1746
+ * Checks if `value` is likely an `arguments` object.
1747
+ *
1748
+ * @static
1749
+ * @memberOf _
1750
+ * @since 0.1.0
1751
+ * @category Lang
1752
+ * @param {*} value The value to check.
1753
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1754
+ * else `false`.
1755
+ * @example
1756
+ *
1757
+ * _.isArguments(function() { return arguments; }());
1758
+ * // => true
1759
+ *
1760
+ * _.isArguments([1, 2, 3]);
1761
+ * // => false
1762
+ */
1763
+ var isArguments = _baseIsArguments(function() { return arguments; }()) ? _baseIsArguments : function(value) {
1764
+ return isObjectLike_1(value) && hasOwnProperty$4.call(value, 'callee') &&
1765
+ !propertyIsEnumerable.call(value, 'callee');
1766
+ };
1767
+
1768
+ var isArguments_1 = isArguments;
1769
+
1770
+ /**
1771
+ * This method returns `false`.
1772
+ *
1773
+ * @static
1774
+ * @memberOf _
1775
+ * @since 4.13.0
1776
+ * @category Util
1777
+ * @returns {boolean} Returns `false`.
1778
+ * @example
1779
+ *
1780
+ * _.times(2, _.stubFalse);
1781
+ * // => [false, false]
1782
+ */
1783
+ function stubFalse() {
1784
+ return false;
1785
+ }
1786
+
1787
+ var stubFalse_1 = stubFalse;
1788
+
1789
+ var isBuffer_1 = createCommonjsModule(function (module, exports) {
1790
+ /** Detect free variable `exports`. */
1791
+ var freeExports = exports && !exports.nodeType && exports;
1792
+
1793
+ /** Detect free variable `module`. */
1794
+ var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
1795
+
1796
+ /** Detect the popular CommonJS extension `module.exports`. */
1797
+ var moduleExports = freeModule && freeModule.exports === freeExports;
1798
+
1799
+ /** Built-in value references. */
1800
+ var Buffer = moduleExports ? _root.Buffer : undefined;
1801
+
1802
+ /* Built-in method references for those with the same name as other `lodash` methods. */
1803
+ var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
1804
+
1805
+ /**
1806
+ * Checks if `value` is a buffer.
1807
+ *
1808
+ * @static
1809
+ * @memberOf _
1810
+ * @since 4.3.0
1811
+ * @category Lang
1812
+ * @param {*} value The value to check.
1813
+ * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
1814
+ * @example
1815
+ *
1816
+ * _.isBuffer(new Buffer(2));
1817
+ * // => true
1818
+ *
1819
+ * _.isBuffer(new Uint8Array(2));
1820
+ * // => false
1821
+ */
1822
+ var isBuffer = nativeIsBuffer || stubFalse_1;
1823
+
1824
+ module.exports = isBuffer;
1825
+ });
1826
+
1827
+ /** Used as references for various `Number` constants. */
1828
+ var MAX_SAFE_INTEGER$1 = 9007199254740991;
1829
+
1830
+ /** Used to detect unsigned integer values. */
1831
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
1832
+
1833
+ /**
1834
+ * Checks if `value` is a valid array-like index.
1835
+ *
1836
+ * @private
1837
+ * @param {*} value The value to check.
1838
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
1839
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
1840
+ */
1841
+ function isIndex(value, length) {
1842
+ var type = typeof value;
1843
+ length = length == null ? MAX_SAFE_INTEGER$1 : length;
1844
+
1845
+ return !!length &&
1846
+ (type == 'number' ||
1847
+ (type != 'symbol' && reIsUint.test(value))) &&
1848
+ (value > -1 && value % 1 == 0 && value < length);
1849
+ }
1850
+
1851
+ var _isIndex = isIndex;
1852
+
1853
+ /** Used as references for various `Number` constants. */
1854
+ var MAX_SAFE_INTEGER = 9007199254740991;
1855
+
1856
+ /**
1857
+ * Checks if `value` is a valid array-like length.
1858
+ *
1859
+ * **Note:** This method is loosely based on
1860
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
1861
+ *
1862
+ * @static
1863
+ * @memberOf _
1864
+ * @since 4.0.0
1865
+ * @category Lang
1866
+ * @param {*} value The value to check.
1867
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
1868
+ * @example
1869
+ *
1870
+ * _.isLength(3);
1871
+ * // => true
1872
+ *
1873
+ * _.isLength(Number.MIN_VALUE);
1874
+ * // => false
1875
+ *
1876
+ * _.isLength(Infinity);
1877
+ * // => false
1878
+ *
1879
+ * _.isLength('3');
1880
+ * // => false
1881
+ */
1882
+ function isLength(value) {
1883
+ return typeof value == 'number' &&
1884
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
1885
+ }
1886
+
1887
+ var isLength_1 = isLength;
1888
+
1889
+ /** `Object#toString` result references. */
1890
+ var argsTag$1 = '[object Arguments]',
1891
+ arrayTag$1 = '[object Array]',
1892
+ boolTag = '[object Boolean]',
1893
+ dateTag = '[object Date]',
1894
+ errorTag = '[object Error]',
1895
+ funcTag = '[object Function]',
1896
+ mapTag$1 = '[object Map]',
1897
+ numberTag = '[object Number]',
1898
+ objectTag$2 = '[object Object]',
1899
+ regexpTag = '[object RegExp]',
1900
+ setTag$1 = '[object Set]',
1901
+ stringTag = '[object String]',
1902
+ weakMapTag$1 = '[object WeakMap]';
1903
+
1904
+ var arrayBufferTag = '[object ArrayBuffer]',
1905
+ dataViewTag$1 = '[object DataView]',
1906
+ float32Tag = '[object Float32Array]',
1907
+ float64Tag = '[object Float64Array]',
1908
+ int8Tag = '[object Int8Array]',
1909
+ int16Tag = '[object Int16Array]',
1910
+ int32Tag = '[object Int32Array]',
1911
+ uint8Tag = '[object Uint8Array]',
1912
+ uint8ClampedTag = '[object Uint8ClampedArray]',
1913
+ uint16Tag = '[object Uint16Array]',
1914
+ uint32Tag = '[object Uint32Array]';
1915
+
1916
+ /** Used to identify `toStringTag` values of typed arrays. */
1917
+ var typedArrayTags = {};
1918
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
1919
+ typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
1920
+ typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
1921
+ typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
1922
+ typedArrayTags[uint32Tag] = true;
1923
+ typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] =
1924
+ typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
1925
+ typedArrayTags[dataViewTag$1] = typedArrayTags[dateTag] =
1926
+ typedArrayTags[errorTag] = typedArrayTags[funcTag] =
1927
+ typedArrayTags[mapTag$1] = typedArrayTags[numberTag] =
1928
+ typedArrayTags[objectTag$2] = typedArrayTags[regexpTag] =
1929
+ typedArrayTags[setTag$1] = typedArrayTags[stringTag] =
1930
+ typedArrayTags[weakMapTag$1] = false;
1931
+
1932
+ /**
1933
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
1934
+ *
1935
+ * @private
1936
+ * @param {*} value The value to check.
1937
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1938
+ */
1939
+ function baseIsTypedArray(value) {
1940
+ return isObjectLike_1(value) &&
1941
+ isLength_1(value.length) && !!typedArrayTags[_baseGetTag(value)];
1942
+ }
1943
+
1944
+ var _baseIsTypedArray = baseIsTypedArray;
1945
+
1946
+ /**
1947
+ * The base implementation of `_.unary` without support for storing metadata.
1948
+ *
1949
+ * @private
1950
+ * @param {Function} func The function to cap arguments for.
1951
+ * @returns {Function} Returns the new capped function.
1952
+ */
1953
+ function baseUnary(func) {
1954
+ return function(value) {
1955
+ return func(value);
1956
+ };
1957
+ }
1958
+
1959
+ var _baseUnary = baseUnary;
1960
+
1961
+ var _nodeUtil = createCommonjsModule(function (module, exports) {
1962
+ /** Detect free variable `exports`. */
1963
+ var freeExports = exports && !exports.nodeType && exports;
1964
+
1965
+ /** Detect free variable `module`. */
1966
+ var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
1967
+
1968
+ /** Detect the popular CommonJS extension `module.exports`. */
1969
+ var moduleExports = freeModule && freeModule.exports === freeExports;
1970
+
1971
+ /** Detect free variable `process` from Node.js. */
1972
+ var freeProcess = moduleExports && _freeGlobal.process;
1973
+
1974
+ /** Used to access faster Node.js helpers. */
1975
+ var nodeUtil = (function() {
1976
+ try {
1977
+ // Use `util.types` for Node.js 10+.
1978
+ var types = freeModule && freeModule.require && freeModule.require('util').types;
1979
+
1980
+ if (types) {
1981
+ return types;
1982
+ }
1983
+
1984
+ // Legacy `process.binding('util')` for Node.js < 10.
1985
+ return freeProcess && freeProcess.binding && freeProcess.binding('util');
1986
+ } catch (e) {}
1987
+ }());
1988
+
1989
+ module.exports = nodeUtil;
1990
+ });
1991
+
1992
+ /* Node.js helper references. */
1993
+ var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray;
1994
+
1995
+ /**
1996
+ * Checks if `value` is classified as a typed array.
1997
+ *
1998
+ * @static
1999
+ * @memberOf _
2000
+ * @since 3.0.0
2001
+ * @category Lang
2002
+ * @param {*} value The value to check.
2003
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
2004
+ * @example
2005
+ *
2006
+ * _.isTypedArray(new Uint8Array);
2007
+ * // => true
2008
+ *
2009
+ * _.isTypedArray([]);
2010
+ * // => false
2011
+ */
2012
+ var isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
2013
+
2014
+ var isTypedArray_1 = isTypedArray;
2015
+
2016
+ /** Used for built-in method references. */
2017
+ var objectProto$4 = Object.prototype;
2018
+
2019
+ /** Used to check objects for own properties. */
2020
+ var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
2021
+
2022
+ /**
2023
+ * Creates an array of the enumerable property names of the array-like `value`.
2024
+ *
2025
+ * @private
2026
+ * @param {*} value The value to query.
2027
+ * @param {boolean} inherited Specify returning inherited property names.
2028
+ * @returns {Array} Returns the array of property names.
2029
+ */
2030
+ function arrayLikeKeys(value, inherited) {
2031
+ var isArr = isArray_1(value),
2032
+ isArg = !isArr && isArguments_1(value),
2033
+ isBuff = !isArr && !isArg && isBuffer_1(value),
2034
+ isType = !isArr && !isArg && !isBuff && isTypedArray_1(value),
2035
+ skipIndexes = isArr || isArg || isBuff || isType,
2036
+ result = skipIndexes ? _baseTimes(value.length, String) : [],
2037
+ length = result.length;
2038
+
2039
+ for (var key in value) {
2040
+ if ((inherited || hasOwnProperty$3.call(value, key)) &&
2041
+ !(skipIndexes && (
2042
+ // Safari 9 has enumerable `arguments.length` in strict mode.
2043
+ key == 'length' ||
2044
+ // Node.js 0.10 has enumerable non-index properties on buffers.
2045
+ (isBuff && (key == 'offset' || key == 'parent')) ||
2046
+ // PhantomJS 2 has enumerable non-index properties on typed arrays.
2047
+ (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
2048
+ // Skip index properties.
2049
+ _isIndex(key, length)
2050
+ ))) {
2051
+ result.push(key);
2052
+ }
2053
+ }
2054
+ return result;
2055
+ }
2056
+
2057
+ var _arrayLikeKeys = arrayLikeKeys;
2058
+
2059
+ /** Used for built-in method references. */
2060
+ var objectProto$3 = Object.prototype;
2061
+
2062
+ /**
2063
+ * Checks if `value` is likely a prototype object.
2064
+ *
2065
+ * @private
2066
+ * @param {*} value The value to check.
2067
+ * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
2068
+ */
2069
+ function isPrototype(value) {
2070
+ var Ctor = value && value.constructor,
2071
+ proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$3;
2072
+
2073
+ return value === proto;
2074
+ }
2075
+
2076
+ var _isPrototype = isPrototype;
2077
+
2078
+ /**
2079
+ * Creates a unary function that invokes `func` with its argument transformed.
2080
+ *
2081
+ * @private
2082
+ * @param {Function} func The function to wrap.
2083
+ * @param {Function} transform The argument transform.
2084
+ * @returns {Function} Returns the new function.
2085
+ */
2086
+ function overArg(func, transform) {
2087
+ return function(arg) {
2088
+ return func(transform(arg));
2089
+ };
2090
+ }
2091
+
2092
+ var _overArg = overArg;
2093
+
2094
+ /* Built-in method references for those with the same name as other `lodash` methods. */
2095
+ var nativeKeys = _overArg(Object.keys, Object);
2096
+
2097
+ var _nativeKeys = nativeKeys;
2098
+
2099
+ /** Used for built-in method references. */
2100
+ var objectProto$2 = Object.prototype;
2101
+
2102
+ /** Used to check objects for own properties. */
2103
+ var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
2104
+
2105
+ /**
2106
+ * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
2107
+ *
2108
+ * @private
2109
+ * @param {Object} object The object to query.
2110
+ * @returns {Array} Returns the array of property names.
2111
+ */
2112
+ function baseKeys(object) {
2113
+ if (!_isPrototype(object)) {
2114
+ return _nativeKeys(object);
2115
+ }
2116
+ var result = [];
2117
+ for (var key in Object(object)) {
2118
+ if (hasOwnProperty$2.call(object, key) && key != 'constructor') {
2119
+ result.push(key);
2120
+ }
2121
+ }
2122
+ return result;
2123
+ }
2124
+
2125
+ var _baseKeys = baseKeys;
2126
+
2127
+ /**
2128
+ * Checks if `value` is array-like. A value is considered array-like if it's
2129
+ * not a function and has a `value.length` that's an integer greater than or
2130
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
2131
+ *
2132
+ * @static
2133
+ * @memberOf _
2134
+ * @since 4.0.0
2135
+ * @category Lang
2136
+ * @param {*} value The value to check.
2137
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
2138
+ * @example
2139
+ *
2140
+ * _.isArrayLike([1, 2, 3]);
2141
+ * // => true
2142
+ *
2143
+ * _.isArrayLike(document.body.children);
2144
+ * // => true
2145
+ *
2146
+ * _.isArrayLike('abc');
2147
+ * // => true
2148
+ *
2149
+ * _.isArrayLike(_.noop);
2150
+ * // => false
2151
+ */
2152
+ function isArrayLike(value) {
2153
+ return value != null && isLength_1(value.length) && !isFunction_1(value);
2154
+ }
2155
+
2156
+ var isArrayLike_1 = isArrayLike;
2157
+
2158
+ /**
2159
+ * Creates an array of the own enumerable property names of `object`.
2160
+ *
2161
+ * **Note:** Non-object values are coerced to objects. See the
2162
+ * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
2163
+ * for more details.
2164
+ *
2165
+ * @static
2166
+ * @since 0.1.0
2167
+ * @memberOf _
2168
+ * @category Object
2169
+ * @param {Object} object The object to query.
2170
+ * @returns {Array} Returns the array of property names.
2171
+ * @example
2172
+ *
2173
+ * function Foo() {
2174
+ * this.a = 1;
2175
+ * this.b = 2;
2176
+ * }
2177
+ *
2178
+ * Foo.prototype.c = 3;
2179
+ *
2180
+ * _.keys(new Foo);
2181
+ * // => ['a', 'b'] (iteration order is not guaranteed)
2182
+ *
2183
+ * _.keys('hi');
2184
+ * // => ['0', '1']
2185
+ */
2186
+ function keys(object) {
2187
+ return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object);
2188
+ }
2189
+
2190
+ var keys_1 = keys;
2191
+
2192
+ /**
2193
+ * Creates an array of own enumerable property names and symbols of `object`.
2194
+ *
2195
+ * @private
2196
+ * @param {Object} object The object to query.
2197
+ * @returns {Array} Returns the array of property names and symbols.
2198
+ */
2199
+ function getAllKeys(object) {
2200
+ return _baseGetAllKeys(object, keys_1, _getSymbols);
2201
+ }
2202
+
2203
+ var _getAllKeys = getAllKeys;
2204
+
2205
+ /** Used to compose bitmasks for value comparisons. */
2206
+ var COMPARE_PARTIAL_FLAG$1 = 1;
2207
+
2208
+ /** Used for built-in method references. */
2209
+ var objectProto$1 = Object.prototype;
2210
+
2211
+ /** Used to check objects for own properties. */
2212
+ var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
2213
+
2214
+ /**
2215
+ * A specialized version of `baseIsEqualDeep` for objects with support for
2216
+ * partial deep comparisons.
2217
+ *
2218
+ * @private
2219
+ * @param {Object} object The object to compare.
2220
+ * @param {Object} other The other object to compare.
2221
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
2222
+ * @param {Function} customizer The function to customize comparisons.
2223
+ * @param {Function} equalFunc The function to determine equivalents of values.
2224
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
2225
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
2226
+ */
2227
+ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
2228
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG$1,
2229
+ objProps = _getAllKeys(object),
2230
+ objLength = objProps.length,
2231
+ othProps = _getAllKeys(other),
2232
+ othLength = othProps.length;
2233
+
2234
+ if (objLength != othLength && !isPartial) {
2235
+ return false;
2236
+ }
2237
+ var index = objLength;
2238
+ while (index--) {
2239
+ var key = objProps[index];
2240
+ if (!(isPartial ? key in other : hasOwnProperty$1.call(other, key))) {
2241
+ return false;
2242
+ }
2243
+ }
2244
+ // Check that cyclic values are equal.
2245
+ var objStacked = stack.get(object);
2246
+ var othStacked = stack.get(other);
2247
+ if (objStacked && othStacked) {
2248
+ return objStacked == other && othStacked == object;
2249
+ }
2250
+ var result = true;
2251
+ stack.set(object, other);
2252
+ stack.set(other, object);
2253
+
2254
+ var skipCtor = isPartial;
2255
+ while (++index < objLength) {
2256
+ key = objProps[index];
2257
+ var objValue = object[key],
2258
+ othValue = other[key];
2259
+
2260
+ if (customizer) {
2261
+ var compared = isPartial
2262
+ ? customizer(othValue, objValue, key, other, object, stack)
2263
+ : customizer(objValue, othValue, key, object, other, stack);
2264
+ }
2265
+ // Recursively compare objects (susceptible to call stack limits).
2266
+ if (!(compared === undefined
2267
+ ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
2268
+ : compared
2269
+ )) {
2270
+ result = false;
2271
+ break;
2272
+ }
2273
+ skipCtor || (skipCtor = key == 'constructor');
2274
+ }
2275
+ if (result && !skipCtor) {
2276
+ var objCtor = object.constructor,
2277
+ othCtor = other.constructor;
2278
+
2279
+ // Non `Object` object instances with different constructors are not equal.
2280
+ if (objCtor != othCtor &&
2281
+ ('constructor' in object && 'constructor' in other) &&
2282
+ !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
2283
+ typeof othCtor == 'function' && othCtor instanceof othCtor)) {
2284
+ result = false;
2285
+ }
2286
+ }
2287
+ stack['delete'](object);
2288
+ stack['delete'](other);
2289
+ return result;
2290
+ }
2291
+
2292
+ var _equalObjects = equalObjects;
2293
+
2294
+ /* Built-in method references that are verified to be native. */
2295
+ var DataView = _getNative(_root, 'DataView');
2296
+
2297
+ var _DataView = DataView;
2298
+
2299
+ /* Built-in method references that are verified to be native. */
2300
+ var Promise$1 = _getNative(_root, 'Promise');
2301
+
2302
+ var _Promise = Promise$1;
2303
+
2304
+ /* Built-in method references that are verified to be native. */
2305
+ var Set = _getNative(_root, 'Set');
2306
+
2307
+ var _Set = Set;
2308
+
2309
+ /* Built-in method references that are verified to be native. */
2310
+ var WeakMap = _getNative(_root, 'WeakMap');
2311
+
2312
+ var _WeakMap = WeakMap;
2313
+
2314
+ /** `Object#toString` result references. */
2315
+ var mapTag = '[object Map]',
2316
+ objectTag$1 = '[object Object]',
2317
+ promiseTag = '[object Promise]',
2318
+ setTag = '[object Set]',
2319
+ weakMapTag = '[object WeakMap]';
2320
+
2321
+ var dataViewTag = '[object DataView]';
2322
+
2323
+ /** Used to detect maps, sets, and weakmaps. */
2324
+ var dataViewCtorString = _toSource(_DataView),
2325
+ mapCtorString = _toSource(_Map),
2326
+ promiseCtorString = _toSource(_Promise),
2327
+ setCtorString = _toSource(_Set),
2328
+ weakMapCtorString = _toSource(_WeakMap);
2329
+
2330
+ /**
2331
+ * Gets the `toStringTag` of `value`.
2332
+ *
2333
+ * @private
2334
+ * @param {*} value The value to query.
2335
+ * @returns {string} Returns the `toStringTag`.
2336
+ */
2337
+ var getTag = _baseGetTag;
2338
+
2339
+ // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
2340
+ if ((_DataView && getTag(new _DataView(new ArrayBuffer(1))) != dataViewTag) ||
2341
+ (_Map && getTag(new _Map) != mapTag) ||
2342
+ (_Promise && getTag(_Promise.resolve()) != promiseTag) ||
2343
+ (_Set && getTag(new _Set) != setTag) ||
2344
+ (_WeakMap && getTag(new _WeakMap) != weakMapTag)) {
2345
+ getTag = function(value) {
2346
+ var result = _baseGetTag(value),
2347
+ Ctor = result == objectTag$1 ? value.constructor : undefined,
2348
+ ctorString = Ctor ? _toSource(Ctor) : '';
2349
+
2350
+ if (ctorString) {
2351
+ switch (ctorString) {
2352
+ case dataViewCtorString: return dataViewTag;
2353
+ case mapCtorString: return mapTag;
2354
+ case promiseCtorString: return promiseTag;
2355
+ case setCtorString: return setTag;
2356
+ case weakMapCtorString: return weakMapTag;
2357
+ }
2358
+ }
2359
+ return result;
2360
+ };
2361
+ }
2362
+
2363
+ var _getTag = getTag;
2364
+
2365
+ /** Used to compose bitmasks for value comparisons. */
2366
+ var COMPARE_PARTIAL_FLAG = 1;
2367
+
2368
+ /** `Object#toString` result references. */
2369
+ var argsTag = '[object Arguments]',
2370
+ arrayTag = '[object Array]',
2371
+ objectTag = '[object Object]';
2372
+
2373
+ /** Used for built-in method references. */
2374
+ var objectProto = Object.prototype;
2375
+
2376
+ /** Used to check objects for own properties. */
2377
+ var hasOwnProperty = objectProto.hasOwnProperty;
2378
+
2379
+ /**
2380
+ * A specialized version of `baseIsEqual` for arrays and objects which performs
2381
+ * deep comparisons and tracks traversed objects enabling objects with circular
2382
+ * references to be compared.
2383
+ *
2384
+ * @private
2385
+ * @param {Object} object The object to compare.
2386
+ * @param {Object} other The other object to compare.
2387
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
2388
+ * @param {Function} customizer The function to customize comparisons.
2389
+ * @param {Function} equalFunc The function to determine equivalents of values.
2390
+ * @param {Object} [stack] Tracks traversed `object` and `other` objects.
2391
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
2392
+ */
2393
+ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
2394
+ var objIsArr = isArray_1(object),
2395
+ othIsArr = isArray_1(other),
2396
+ objTag = objIsArr ? arrayTag : _getTag(object),
2397
+ othTag = othIsArr ? arrayTag : _getTag(other);
2398
+
2399
+ objTag = objTag == argsTag ? objectTag : objTag;
2400
+ othTag = othTag == argsTag ? objectTag : othTag;
2401
+
2402
+ var objIsObj = objTag == objectTag,
2403
+ othIsObj = othTag == objectTag,
2404
+ isSameTag = objTag == othTag;
2405
+
2406
+ if (isSameTag && isBuffer_1(object)) {
2407
+ if (!isBuffer_1(other)) {
2408
+ return false;
2409
+ }
2410
+ objIsArr = true;
2411
+ objIsObj = false;
2412
+ }
2413
+ if (isSameTag && !objIsObj) {
2414
+ stack || (stack = new _Stack);
2415
+ return (objIsArr || isTypedArray_1(object))
2416
+ ? _equalArrays(object, other, bitmask, customizer, equalFunc, stack)
2417
+ : _equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
2418
+ }
2419
+ if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
2420
+ var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
2421
+ othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
2422
+
2423
+ if (objIsWrapped || othIsWrapped) {
2424
+ var objUnwrapped = objIsWrapped ? object.value() : object,
2425
+ othUnwrapped = othIsWrapped ? other.value() : other;
2426
+
2427
+ stack || (stack = new _Stack);
2428
+ return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
2429
+ }
2430
+ }
2431
+ if (!isSameTag) {
2432
+ return false;
2433
+ }
2434
+ stack || (stack = new _Stack);
2435
+ return _equalObjects(object, other, bitmask, customizer, equalFunc, stack);
2436
+ }
2437
+
2438
+ var _baseIsEqualDeep = baseIsEqualDeep;
2439
+
2440
+ /**
2441
+ * The base implementation of `_.isEqual` which supports partial comparisons
2442
+ * and tracks traversed objects.
2443
+ *
2444
+ * @private
2445
+ * @param {*} value The value to compare.
2446
+ * @param {*} other The other value to compare.
2447
+ * @param {boolean} bitmask The bitmask flags.
2448
+ * 1 - Unordered comparison
2449
+ * 2 - Partial comparison
2450
+ * @param {Function} [customizer] The function to customize comparisons.
2451
+ * @param {Object} [stack] Tracks traversed `value` and `other` objects.
2452
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2453
+ */
2454
+ function baseIsEqual(value, other, bitmask, customizer, stack) {
2455
+ if (value === other) {
2456
+ return true;
2457
+ }
2458
+ if (value == null || other == null || (!isObjectLike_1(value) && !isObjectLike_1(other))) {
2459
+ return value !== value && other !== other;
2460
+ }
2461
+ return _baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
2462
+ }
2463
+
2464
+ var _baseIsEqual = baseIsEqual;
2465
+
2466
+ /**
2467
+ * Performs a deep comparison between two values to determine if they are
2468
+ * equivalent.
2469
+ *
2470
+ * **Note:** This method supports comparing arrays, array buffers, booleans,
2471
+ * date objects, error objects, maps, numbers, `Object` objects, regexes,
2472
+ * sets, strings, symbols, and typed arrays. `Object` objects are compared
2473
+ * by their own, not inherited, enumerable properties. Functions and DOM
2474
+ * nodes are compared by strict equality, i.e. `===`.
2475
+ *
2476
+ * @static
2477
+ * @memberOf _
2478
+ * @since 0.1.0
2479
+ * @category Lang
2480
+ * @param {*} value The value to compare.
2481
+ * @param {*} other The other value to compare.
2482
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2483
+ * @example
2484
+ *
2485
+ * var object = { 'a': 1 };
2486
+ * var other = { 'a': 1 };
2487
+ *
2488
+ * _.isEqual(object, other);
2489
+ * // => true
2490
+ *
2491
+ * object === other;
2492
+ * // => false
2493
+ */
2494
+ function isEqual(value, other) {
2495
+ return _baseIsEqual(value, other);
2496
+ }
2497
+
2498
+ var isEqual_1 = isEqual;
2499
+
2500
+ const _excluded$1 = ["placeholder", "signature", "url", "width", "height", "padding", "filename"];
2501
+ const PDFSign = withLocale(/*#__PURE__*/forwardRef((_ref, ref) => {
2502
+ let {
2503
+ placeholder,
2504
+ signature,
2505
+ url,
2506
+ width,
2507
+ height,
2508
+ padding,
2509
+ filename = 'signed-document.pdf'
2510
+ } = _ref,
2511
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
2512
+ const [location, setLocation] = useState({});
2513
+ const [pdfProps, setPdfProps] = useState(null);
2514
+ const {
2515
+ formatMessage
2516
+ } = useIntl();
2517
+ const pdfSignature = useMemo(() => {
2518
+ if (!pdfProps) {
2519
+ return null;
2520
+ }
2521
+ const {
2522
+ size,
2523
+ currentPage
2524
+ } = pdfProps;
2525
+ const scaleX = size.width / size.originalWidth;
2526
+ const scaleY = size.height / size.originalHeight;
2527
+ const pdfX = Math.round(location.size.x / scaleX);
2528
+ const pdfY = Math.round(size.originalHeight - location.size.y / scaleY);
2529
+ return {
2530
+ x: pdfX,
2531
+ y: pdfY - location.size.height,
2532
+ page: currentPage,
2533
+ pageWidth: size.originalWidth,
2534
+ pageHeight: size.originalHeight,
2535
+ width: location.size.width,
2536
+ height: location.size.height,
2537
+ signature,
2538
+ url
2539
+ };
2540
+ }, [pdfProps, location, signature, url]);
2541
+ const signPdf = useCallback(async () => {
2542
+ if (!pdfProps) {
2543
+ throw new Error(formatMessage({
2544
+ id: 'loadingError'
2545
+ }));
2546
+ }
2547
+ const {
2548
+ x,
2549
+ y,
2550
+ page,
2551
+ width,
2552
+ height,
2553
+ signature,
2554
+ url
2555
+ } = pdfSignature;
2556
+ const response = await window.fetch(url);
2557
+ const pdfBytes = await response.arrayBuffer();
2558
+ const pdfDoc = await PDFDocument.load(pdfBytes);
2559
+ const pdfPage = pdfDoc.getPage(page - 1);
2560
+ const signatureBytes = await window.fetch(signature).then(res => res.arrayBuffer());
2561
+ const signatureImageEmbed = await pdfDoc.embedPng(signatureBytes);
2562
+ pdfPage.drawImage(signatureImageEmbed, {
2563
+ x,
2564
+ y,
2565
+ width,
2566
+ height
2567
+ });
2568
+ const modifiedPdfBytes = await pdfDoc.save();
2569
+ return new window.File([modifiedPdfBytes], filename, {
2570
+ type: 'application/pdf'
2571
+ });
2572
+ }, [pdfSignature]);
2573
+ useImperativeHandle(ref, () => ({
2574
+ getLocation: () => location,
2575
+ setLocation: value => setLocation(value),
2576
+ getPdfSignature: () => pdfSignature,
2577
+ sign: () => signPdf()
2578
+ }));
2579
+ return /*#__PURE__*/jsx(PDFViewer, _extends({}, props, {
2580
+ url: url,
2581
+ children: ({
2582
+ size,
2583
+ currentPage
2584
+ }) => {
2585
+ setTimeout(() => {
2586
+ if (!isEqual_1({
2587
+ size,
2588
+ currentPage
2589
+ }, pdfProps)) {
2590
+ setPdfProps({
2591
+ size,
2592
+ currentPage
2593
+ });
2594
+ }
2595
+ }, 0);
2596
+ return /*#__PURE__*/jsx(LocationLayer, {
2597
+ stageWidth: size.width,
2598
+ stageHeight: size.height,
2599
+ width: width,
2600
+ height: height,
2601
+ padding: padding,
2602
+ placeholder: placeholder,
2603
+ signature: signature,
2604
+ value: location,
2605
+ onChange: setLocation
2606
+ });
2607
+ }
2608
+ }));
2609
+ }));
2610
+
2611
+ const _excluded = ["filename", "onSuccess"];
2612
+ const dataURLtoBlob = dataURL => {
2613
+ let arr = dataURL.split(',');
2614
+ // 注意base64的最后面中括号和引号是不转译的
2615
+ let _arr = arr[1].substring(0, arr[1].length - 2);
2616
+ let mime = arr[0].match(/:(.*?);/)[1],
2617
+ bstr = atob(_arr),
2618
+ n = bstr.length,
2619
+ u8arr = new Uint8Array(n);
2620
+ while (n--) {
2621
+ u8arr[n] = bstr.charCodeAt(n);
2622
+ }
2623
+ return new Blob([u8arr], {
2624
+ type: mime
2625
+ });
2626
+ };
2627
+ const Signature = withLocale(({
2628
+ onClose,
2629
+ onSuccess,
2630
+ filename,
2631
+ width,
2632
+ height
2633
+ }) => {
2634
+ const {
2635
+ formatMessage
2636
+ } = useIntl();
2637
+ const {
2638
+ message
2639
+ } = App.useApp();
2640
+ const signatureCanvasRef = useRef(null);
2641
+ return /*#__PURE__*/jsxs(Flex, {
2642
+ vertical: true,
2643
+ gap: 12,
2644
+ className: classnames(style['signature-modal-content'], 'signature-modal-content'),
2645
+ children: [/*#__PURE__*/jsx("div", {
2646
+ className: classnames(style['signature-container'], 'signature-container'),
2647
+ style: {
2648
+ width: '368px',
2649
+ height: `${Math.round(height * 368 / width)}px`
2650
+ },
2651
+ children: /*#__PURE__*/jsx(SignatureCanvas, {
2652
+ ref: signatureCanvasRef,
2653
+ canvasProps: {
2654
+ className: classnames(style['signature-canvas'], 'signature-canvas')
2655
+ }
2656
+ })
2657
+ }), /*#__PURE__*/jsxs(Flex, {
2658
+ justify: "flex-end",
2659
+ align: "center",
2660
+ gap: 10,
2661
+ children: [/*#__PURE__*/jsx(Button, {
2662
+ onClick: () => {
2663
+ onClose();
2664
+ },
2665
+ children: formatMessage({
2666
+ id: 'signatureCancelText'
2667
+ })
2668
+ }), /*#__PURE__*/jsx(Button, {
2669
+ type: "primary",
2670
+ onClick: () => {
2671
+ if (signatureCanvasRef.current.isEmpty()) {
2672
+ message.error(formatMessage({
2673
+ id: 'signatureEmptyError'
2674
+ }));
2675
+ return;
2676
+ }
2677
+ const file = new window.File([dataURLtoBlob(signatureCanvasRef.current.toDataURL('image/png'))], filename, {
2678
+ type: 'image/png'
2679
+ });
2680
+ onClose();
2681
+ onSuccess(file);
2682
+ },
2683
+ children: formatMessage({
2684
+ id: 'signatureConfirmText'
2685
+ })
2686
+ })]
2687
+ })]
2688
+ });
2689
+ });
2690
+ const Title = withLocale(() => {
2691
+ const {
2692
+ formatMessage
2693
+ } = useIntl();
2694
+ return /*#__PURE__*/jsx("span", {
2695
+ children: formatMessage({
2696
+ id: 'signatureDefaultTitle'
2697
+ })
2698
+ });
2699
+ });
2700
+ const useSignature = props => {
2701
+ const {
2702
+ width,
2703
+ height
2704
+ } = Object.assign({}, {
2705
+ width: 200,
2706
+ height: 50
2707
+ }, props);
2708
+ const {
2709
+ modal,
2710
+ message
2711
+ } = App.useApp();
2712
+ useRef(null);
2713
+ return props => {
2714
+ const _Object$assign = Object.assign({}, props),
2715
+ {
2716
+ filename = 'signature.png',
2717
+ onSuccess
2718
+ } = _Object$assign,
2719
+ modalProps = _objectWithoutPropertiesLoose(_Object$assign, _excluded);
2720
+ const modalApi = modal.info(Object.assign({}, {
2721
+ title: /*#__PURE__*/jsx(Title, {}),
2722
+ icon: null,
2723
+ footer: null,
2724
+ wrapClassName: style['signature-modal'],
2725
+ classNames: {
2726
+ content: style['signature-modal']
2727
+ }
2728
+ }, modalProps, {
2729
+ content: /*#__PURE__*/jsx(Signature, {
2730
+ width: width,
2731
+ height: height,
2732
+ filename: filename,
2733
+ onSuccess: onSuccess,
2734
+ onClose: () => {
2735
+ modalApi.destroy();
2736
+ }
2737
+ })
2738
+ }));
2739
+ return modalApi;
2740
+ };
2741
+ };
2742
+
2743
+ export { LocationLayer, PDFSign, PDFViewer, PDFSign as default, useSignature };
2744
+ //# sourceMappingURL=index.modern.js.map