ezuikit-js 0.7.2 → 7.6.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.
Files changed (75) hide show
  1. package/demos/base-demo/ezuikit.js +287 -4434
  2. package/ezuikit.js +367 -2307
  3. package/package.json +1 -1
  4. package/demos/base-demo/ezuikit_static/v66/v1/css/theme.css +0 -121
  5. package/demos/base-demo/ezuikit_static/v66/v1/js/AudioRenderer.js +0 -225
  6. package/demos/base-demo/ezuikit_static/v66/v1/js/SuperRender_10.js +0 -395
  7. package/demos/base-demo/ezuikit_static/v66/v1/js/SystemTransform.js +0 -22
  8. package/demos/base-demo/ezuikit_static/v66/v1/js/SystemTransform.js.mem +0 -0
  9. package/demos/base-demo/ezuikit_static/v66/v1/js/jsPluginV1-1.0.0.min.js +0 -26
  10. package/demos/base-demo/ezuikit_static/v66/v1/js/playctrl/AudioRenderer.js +0 -225
  11. package/demos/base-demo/ezuikit_static/v66/v1/js/playctrl/DecodeWorker.js +0 -618
  12. package/demos/base-demo/ezuikit_static/v66/v1/js/playctrl/Decoder.js +0 -1
  13. package/demos/base-demo/ezuikit_static/v66/v1/js/playctrl/JSPlaySDKInterface.js +0 -2052
  14. package/demos/base-demo/ezuikit_static/v66/v1/js/playctrl/SuperRender_10.js +0 -396
  15. package/demos/base-demo/ezuikit_static/v66/v1/js/playctrl/SuperRender_20.js +0 -1
  16. package/demos/base-demo/ezuikit_static/v66/v1/js/transform/SystemTransform.js +0 -22
  17. package/demos/base-demo/ezuikit_static/v66/v1/js/transform/SystemTransform.js.mem +0 -0
  18. package/demos/base-demo/ezuikit_static/v66/v1/js/transform/systemTransform-worker.min.js +0 -1
  19. package/demos/base-demo/ezuikit_static/v66/v1/js/tts-v4.js +0 -346
  20. package/demos/base-demo/ezuikit_static/v66/v1/rec/datepicker.js +0 -1522
  21. package/demos/base-demo/ezuikit_static/v66/v1/rec/datepicker.min.css +0 -36
  22. package/demos/base-demo/ezuikit_static/v66/v1/rec/datepicker.zh-CN.js +0 -19
  23. package/demos/base-demo/ezuikit_static/v66/v1/rec/jquery.min.js +0 -2
  24. package/demos/base-demo/ezuikit_static/v66/v1/speed/speed.css +0 -144
  25. package/demos/base-demo/ezuikit_static/v66/v1/talk/adapeter.js +0 -5497
  26. package/demos/base-demo/ezuikit_static/v66/v1/talk/janus.js +0 -3507
  27. package/demos/base-demo/ezuikit_static/v66/v1/talk/tts-v4.js +0 -346
  28. package/demos/base-demo/ezuikit_static/v66/v2/css/theme.css +0 -121
  29. package/demos/base-demo/ezuikit_static/v66/v2/js/Decoder.js +0 -9198
  30. package/demos/base-demo/ezuikit_static/v66/v2/js/Decoder.wasm +0 -0
  31. package/demos/base-demo/ezuikit_static/v66/v2/js/jsPluginV2-2.0.1.min.js +0 -4662
  32. package/demos/base-demo/ezuikit_static/v66/v2/rec/datepicker.js +0 -1522
  33. package/demos/base-demo/ezuikit_static/v66/v2/rec/datepicker.min.css +0 -36
  34. package/demos/base-demo/ezuikit_static/v66/v2/rec/datepicker.zh-CN.js +0 -19
  35. package/demos/base-demo/ezuikit_static/v66/v2/rec/jquery.min.js +0 -2
  36. package/demos/base-demo/ezuikit_static/v66/v2/speed/speed.css +0 -144
  37. package/demos/base-demo/ezuikit_static/v66/v2/talk/adapeter.js +0 -5497
  38. package/demos/base-demo/ezuikit_static/v66/v2/talk/janus.js +0 -3507
  39. package/demos/base-demo/ezuikit_static/v66/v2/talk/tts-v4.js +0 -343
  40. package/ezuikit_static/v66/v1/css/theme.css +0 -121
  41. package/ezuikit_static/v66/v1/js/AudioRenderer.js +0 -225
  42. package/ezuikit_static/v66/v1/js/SuperRender_10.js +0 -395
  43. package/ezuikit_static/v66/v1/js/SystemTransform.js +0 -22
  44. package/ezuikit_static/v66/v1/js/SystemTransform.js.mem +0 -0
  45. package/ezuikit_static/v66/v1/js/jsPluginV1-1.0.0.min.js +0 -26
  46. package/ezuikit_static/v66/v1/js/playctrl/AudioRenderer.js +0 -225
  47. package/ezuikit_static/v66/v1/js/playctrl/DecodeWorker.js +0 -618
  48. package/ezuikit_static/v66/v1/js/playctrl/Decoder.js +0 -1
  49. package/ezuikit_static/v66/v1/js/playctrl/JSPlaySDKInterface.js +0 -2052
  50. package/ezuikit_static/v66/v1/js/playctrl/SuperRender_10.js +0 -396
  51. package/ezuikit_static/v66/v1/js/playctrl/SuperRender_20.js +0 -1
  52. package/ezuikit_static/v66/v1/js/transform/SystemTransform.js +0 -22
  53. package/ezuikit_static/v66/v1/js/transform/SystemTransform.js.mem +0 -0
  54. package/ezuikit_static/v66/v1/js/transform/systemTransform-worker.min.js +0 -1
  55. package/ezuikit_static/v66/v1/js/tts-v4.js +0 -346
  56. package/ezuikit_static/v66/v1/rec/datepicker.js +0 -1522
  57. package/ezuikit_static/v66/v1/rec/datepicker.min.css +0 -36
  58. package/ezuikit_static/v66/v1/rec/datepicker.zh-CN.js +0 -19
  59. package/ezuikit_static/v66/v1/rec/jquery.min.js +0 -2
  60. package/ezuikit_static/v66/v1/speed/speed.css +0 -144
  61. package/ezuikit_static/v66/v1/talk/adapeter.js +0 -5497
  62. package/ezuikit_static/v66/v1/talk/janus.js +0 -3507
  63. package/ezuikit_static/v66/v1/talk/tts-v4.js +0 -346
  64. package/ezuikit_static/v66/v2/css/theme.css +0 -121
  65. package/ezuikit_static/v66/v2/js/Decoder.js +0 -9198
  66. package/ezuikit_static/v66/v2/js/Decoder.wasm +0 -0
  67. package/ezuikit_static/v66/v2/js/jsPluginV2-2.0.1.min.js +0 -4662
  68. package/ezuikit_static/v66/v2/rec/datepicker.js +0 -1522
  69. package/ezuikit_static/v66/v2/rec/datepicker.min.css +0 -36
  70. package/ezuikit_static/v66/v2/rec/datepicker.zh-CN.js +0 -19
  71. package/ezuikit_static/v66/v2/rec/jquery.min.js +0 -2
  72. package/ezuikit_static/v66/v2/speed/speed.css +0 -144
  73. package/ezuikit_static/v66/v2/talk/adapeter.js +0 -5497
  74. package/ezuikit_static/v66/v2/talk/janus.js +0 -3507
  75. package/ezuikit_static/v66/v2/talk/tts-v4.js +0 -343
@@ -1,4662 +0,0 @@
1
- 'use strict';
2
-
3
- // eslint-disable-next-line no-extend-native
4
- Date.prototype.Format = function (fmt) {
5
- var o = {
6
- "M+": this.getMonth() + 1,
7
- "d+": this.getDate(),
8
- "h+": this.getHours(),
9
- "m+": this.getMinutes(),
10
- "s+": this.getSeconds(),
11
- "q+": Math.floor((this.getMonth() + 3) / 3),
12
- "S": this.getMilliseconds()
13
- };
14
- if (/(y+)/.test(fmt)) {
15
- fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
16
- }
17
- for (var k in o) {
18
- if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
19
- }
20
- return fmt;
21
- };
22
- const loadJSByBlobToHeader = (url, callback, isReady) => {
23
- if (isReady) {
24
- return;
25
- }
26
- fetch(url).then(response => response.text()).then(res => {
27
- var workBlob = new Blob([res]);
28
- const url = URL.createObjectURL(workBlob);
29
- var oJs = document.createElement("script");
30
- oJs.setAttribute("src", url);
31
- oJs.onload = () => callback();
32
- document.getElementsByTagName("head")[0].appendChild(oJs);
33
- });
34
- };
35
-
36
- (function webpackUniversalModuleDefinition(root, factory) {
37
- if (typeof exports === 'object' && typeof module === 'object') module.exports = factory();else if (typeof define === 'function' && define.amd) define([], factory);else {
38
- var a = factory();
39
- for (var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
40
- }
41
- })(window, function () {
42
- return (/******/function (modules) {
43
- // webpackBootstrap
44
- /******/ // The module cache
45
- /******/
46
- var installedModules = {};
47
- /******/
48
- /******/ // The require function
49
- /******/
50
- function __webpack_require__(moduleId) {
51
- /******/
52
- /******/ // Check if module is in cache
53
- /******/if (installedModules[moduleId]) {
54
- /******/return installedModules[moduleId].exports;
55
- /******/
56
- }
57
- /******/ // Create a new module (and put it into the cache)
58
- /******/
59
- var module = installedModules[moduleId] = {
60
- /******/i: moduleId,
61
- /******/l: false,
62
- /******/exports: {}
63
- /******/
64
- };
65
- /******/
66
- /******/ // Execute the module function
67
- /******/
68
- modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
69
- /******/
70
- /******/ // Flag the module as loaded
71
- /******/
72
- module.l = true;
73
- /******/
74
- /******/ // Return the exports of the module
75
- /******/
76
- return module.exports;
77
- /******/
78
- }
79
- /******/
80
- /******/
81
- /******/ // expose the modules object (__webpack_modules__)
82
- /******/
83
- __webpack_require__.m = modules;
84
- /******/
85
- /******/ // expose the module cache
86
- /******/
87
- __webpack_require__.c = installedModules;
88
- /******/
89
- /******/ // define getter function for harmony exports
90
- /******/
91
- __webpack_require__.d = function (exports, name, getter) {
92
- /******/if (!__webpack_require__.o(exports, name)) {
93
- /******/Object.defineProperty(exports, name, {
94
- enumerable: true,
95
- get: getter
96
- });
97
- /******/
98
- }
99
- /******/
100
- };
101
- /******/
102
- /******/ // define __esModule on exports
103
- /******/
104
- __webpack_require__.r = function (exports) {
105
- /******/if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
106
- /******/Object.defineProperty(exports, Symbol.toStringTag, {
107
- value: 'Module'
108
- });
109
- /******/
110
- }
111
- /******/
112
- Object.defineProperty(exports, '__esModule', {
113
- value: true
114
- });
115
- /******/
116
- };
117
- /******/
118
- /******/ // create a fake namespace object
119
- /******/ // mode & 1: value is a module id, require it
120
- /******/ // mode & 2: merge all properties of value into the ns
121
- /******/ // mode & 4: return value when already ns object
122
- /******/ // mode & 8|1: behave like require
123
- /******/
124
- __webpack_require__.t = function (value, mode) {
125
- /******/if (mode & 1) value = __webpack_require__(value);
126
- /******/
127
- if (mode & 8) return value;
128
- /******/
129
- if (mode & 4 && typeof value === 'object' && value && value.__esModule) return value;
130
- /******/
131
- var ns = Object.create(null);
132
- /******/
133
- __webpack_require__.r(ns);
134
- /******/
135
- Object.defineProperty(ns, 'default', {
136
- enumerable: true,
137
- value: value
138
- });
139
- /******/
140
- if (mode & 2 && typeof value != 'string') for (var key in value) __webpack_require__.d(ns, key, function (key) {
141
- return value[key];
142
- }.bind(null, key));
143
- /******/
144
- return ns;
145
- /******/
146
- };
147
- /******/
148
- /******/ // getDefaultExport function for compatibility with non-harmony modules
149
- /******/
150
- __webpack_require__.n = function (module) {
151
- /******/var getter = module && module.__esModule ? /******/function getDefault() {
152
- return module['default'];
153
- } : /******/function getModuleExports() {
154
- return module;
155
- };
156
- /******/
157
- __webpack_require__.d(getter, 'a', getter);
158
- /******/
159
- return getter;
160
- /******/
161
- };
162
- /******/
163
- /******/ // Object.prototype.hasOwnProperty.call
164
- /******/
165
- __webpack_require__.o = function (object, property) {
166
- return Object.prototype.hasOwnProperty.call(object, property);
167
- };
168
- /******/
169
- /******/ // __webpack_public_path__
170
- /******/
171
- __webpack_require__.p = "";
172
- /******/
173
- /******/
174
- /******/ // Load entry module and return exports
175
- /******/
176
- return __webpack_require__(__webpack_require__.s = 1);
177
- /******/
178
- }
179
- /************************************************************************/
180
- /******/([/* 0 */
181
- /***/function (module, exports) {
182
- var dbits;
183
- function BigInteger(a, b, c) {
184
- a != null && ("number" == typeof a ? this.fromNumber(a, b, c) : b == null && "string" != typeof a ? this.fromString(a, 256) : this.fromString(a, b));
185
- }
186
- function nbi() {
187
- return new BigInteger(null);
188
- }
189
- function am3(a, b, c, d, e, g) {
190
- var h = b & 16383;
191
- for (b >>= 14; --g >= 0;) {
192
- var f = this[a] & 16383,
193
- o = this[a++] >> 14,
194
- p = b * f + o * h,
195
- f = h * f + ((p & 16383) << 14) + c[d] + e,
196
- e = (f >> 28) + (p >> 14) + b * o;
197
- c[d++] = f & 268435455;
198
- }
199
- return e;
200
- }
201
- (BigInteger.prototype.am = am3, dbits = 28);
202
- BigInteger.prototype.DB = dbits;
203
- BigInteger.prototype.DM = (1 << dbits) - 1;
204
- BigInteger.prototype.DV = 1 << dbits;
205
- var BI_FP = 52;
206
- BigInteger.prototype.FV = Math.pow(2, BI_FP);
207
- BigInteger.prototype.F1 = BI_FP - dbits;
208
- BigInteger.prototype.F2 = 2 * dbits - BI_FP;
209
- var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz",
210
- BI_RC = [],
211
- rr,
212
- vv;
213
- rr = "0".charCodeAt(0);
214
- for (vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
215
- rr = "a".charCodeAt(0);
216
- for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
217
- rr = "A".charCodeAt(0);
218
- for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
219
- function int2char(a) {
220
- return BI_RM.charAt(a);
221
- }
222
- function intAt(a, b) {
223
- var c = BI_RC[a.charCodeAt(b)];
224
- return c == null ? -1 : c;
225
- }
226
- function bnpCopyTo(a) {
227
- for (var b = this.t - 1; b >= 0; --b) a[b] = this[b];
228
- a.t = this.t;
229
- a.s = this.s;
230
- }
231
- function bnpFromInt(a) {
232
- this.t = 1;
233
- this.s = a < 0 ? -1 : 0;
234
- a > 0 ? this[0] = a : a < -1 ? this[0] = a + DV : this.t = 0;
235
- }
236
- function nbv(a) {
237
- var b = nbi();
238
- b.fromInt(a);
239
- return b;
240
- }
241
- function bnpFromString(a, b) {
242
- var c;
243
- if (b == 16) c = 4;else if (b == 8) c = 3;else if (b == 256) c = 8;else if (b == 2) c = 1;else if (b == 32) c = 5;else if (b == 4) c = 2;else {
244
- this.fromRadix(a, b);
245
- return;
246
- }
247
- this.s = this.t = 0;
248
- for (var d = a.length, e = !1, g = 0; --d >= 0;) {
249
- var h = c == 8 ? a[d] & 255 : intAt(a, d);
250
- h < 0 ? a.charAt(d) == "-" && (e = !0) : (e = !1, g == 0 ? this[this.t++] = h : g + c > this.DB ? (this[this.t - 1] |= (h & (1 << this.DB - g) - 1) << g, this[this.t++] = h >> this.DB - g) : this[this.t - 1] |= h << g, g += c, g >= this.DB && (g -= this.DB));
251
- }
252
- if (c == 8 && (a[0] & 128) != 0) this.s = -1, g > 0 && (this[this.t - 1] |= (1 << this.DB - g) - 1 << g);
253
- this.clamp();
254
- e && BigInteger.ZERO.subTo(this, this);
255
- }
256
- function bnpClamp() {
257
- for (var a = this.s & this.DM; this.t > 0 && this[this.t - 1] == a;) --this.t;
258
- }
259
- function bnToString(a) {
260
- if (this.s < 0) return "-" + this.negate().toString(a);
261
- if (a == 16) a = 4;else if (a == 8) a = 3;else if (a == 2) a = 1;else if (a == 32) a = 5;else if (a == 64) a = 6;else if (a == 4) a = 2;else return this.toRadix(a);
262
- var b = (1 << a) - 1,
263
- c,
264
- d = !1,
265
- e = "",
266
- g = this.t,
267
- h = this.DB - g * this.DB % a;
268
- if (g-- > 0) {
269
- if (h < this.DB && (c = this[g] >> h) > 0) d = !0, e = int2char(c);
270
- for (; g >= 0;) h < a ? (c = (this[g] & (1 << h) - 1) << a - h, c |= this[--g] >> (h += this.DB - a)) : (c = this[g] >> (h -= a) & b, h <= 0 && (h += this.DB, --g)), c > 0 && (d = !0), d && (e += int2char(c));
271
- }
272
- return d ? e : "0";
273
- }
274
- function bnNegate() {
275
- var a = nbi();
276
- BigInteger.ZERO.subTo(this, a);
277
- return a;
278
- }
279
- function bnAbs() {
280
- return this.s < 0 ? this.negate() : this;
281
- }
282
- function bnCompareTo(a) {
283
- var b = this.s - a.s;
284
- if (b != 0) return b;
285
- var c = this.t,
286
- b = c - a.t;
287
- if (b != 0) return b;
288
- for (; --c >= 0;) if ((b = this[c] - a[c]) != 0) return b;
289
- return 0;
290
- }
291
- function nbits(a) {
292
- var b = 1,
293
- c;
294
- if ((c = a >>> 16) != 0) a = c, b += 16;
295
- if ((c = a >> 8) != 0) a = c, b += 8;
296
- if ((c = a >> 4) != 0) a = c, b += 4;
297
- if ((c = a >> 2) != 0) a = c, b += 2;
298
- a >> 1 != 0 && (b += 1);
299
- return b;
300
- }
301
- function bnBitLength() {
302
- return this.t <= 0 ? 0 : this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ this.s & this.DM);
303
- }
304
- function bnpDLShiftTo(a, b) {
305
- var c;
306
- for (c = this.t - 1; c >= 0; --c) b[c + a] = this[c];
307
- for (c = a - 1; c >= 0; --c) b[c] = 0;
308
- b.t = this.t + a;
309
- b.s = this.s;
310
- }
311
- function bnpDRShiftTo(a, b) {
312
- for (var c = a; c < this.t; ++c) b[c - a] = this[c];
313
- b.t = Math.max(this.t - a, 0);
314
- b.s = this.s;
315
- }
316
- function bnpLShiftTo(a, b) {
317
- var c = a % this.DB,
318
- d = this.DB - c,
319
- e = (1 << d) - 1,
320
- g = Math.floor(a / this.DB),
321
- h = this.s << c & this.DM,
322
- f;
323
- for (f = this.t - 1; f >= 0; --f) b[f + g + 1] = this[f] >> d | h, h = (this[f] & e) << c;
324
- for (f = g - 1; f >= 0; --f) b[f] = 0;
325
- b[g] = h;
326
- b.t = this.t + g + 1;
327
- b.s = this.s;
328
- b.clamp();
329
- }
330
- function bnpRShiftTo(a, b) {
331
- b.s = this.s;
332
- var c = Math.floor(a / this.DB);
333
- if (c >= this.t) b.t = 0;else {
334
- var d = a % this.DB,
335
- e = this.DB - d,
336
- g = (1 << d) - 1;
337
- b[0] = this[c] >> d;
338
- for (var h = c + 1; h < this.t; ++h) b[h - c - 1] |= (this[h] & g) << e, b[h - c] = this[h] >> d;
339
- d > 0 && (b[this.t - c - 1] |= (this.s & g) << e);
340
- b.t = this.t - c;
341
- b.clamp();
342
- }
343
- }
344
- function bnpSubTo(a, b) {
345
- for (var c = 0, d = 0, e = Math.min(a.t, this.t); c < e;) d += this[c] - a[c], b[c++] = d & this.DM, d >>= this.DB;
346
- if (a.t < this.t) {
347
- for (d -= a.s; c < this.t;) d += this[c], b[c++] = d & this.DM, d >>= this.DB;
348
- d += this.s;
349
- } else {
350
- for (d += this.s; c < a.t;) d -= a[c], b[c++] = d & this.DM, d >>= this.DB;
351
- d -= a.s;
352
- }
353
- b.s = d < 0 ? -1 : 0;
354
- d < -1 ? b[c++] = this.DV + d : d > 0 && (b[c++] = d);
355
- b.t = c;
356
- b.clamp();
357
- }
358
- function bnpMultiplyTo(a, b) {
359
- var c = this.abs(),
360
- d = a.abs(),
361
- e = c.t;
362
- for (b.t = e + d.t; --e >= 0;) b[e] = 0;
363
- for (e = 0; e < d.t; ++e) b[e + c.t] = c.am(0, d[e], b, e, 0, c.t);
364
- b.s = 0;
365
- b.clamp();
366
- this.s != a.s && BigInteger.ZERO.subTo(b, b);
367
- }
368
- function bnpSquareTo(a) {
369
- for (var b = this.abs(), c = a.t = 2 * b.t; --c >= 0;) a[c] = 0;
370
- for (c = 0; c < b.t - 1; ++c) {
371
- var d = b.am(c, b[c], a, 2 * c, 0, 1);
372
- if ((a[c + b.t] += b.am(c + 1, 2 * b[c], a, 2 * c + 1, d, b.t - c - 1)) >= b.DV) a[c + b.t] -= b.DV, a[c + b.t + 1] = 1;
373
- }
374
- a.t > 0 && (a[a.t - 1] += b.am(c, b[c], a, 2 * c, 0, 1));
375
- a.s = 0;
376
- a.clamp();
377
- }
378
- function bnpDivRemTo(a, b, c) {
379
- var d = a.abs();
380
- if (!(d.t <= 0)) {
381
- var e = this.abs();
382
- if (e.t < d.t) b != null && b.fromInt(0), c != null && this.copyTo(c);else {
383
- c == null && (c = nbi());
384
- var g = nbi(),
385
- h = this.s,
386
- a = a.s,
387
- f = this.DB - nbits(d[d.t - 1]);
388
- f > 0 ? (d.lShiftTo(f, g), e.lShiftTo(f, c)) : (d.copyTo(g), e.copyTo(c));
389
- d = g.t;
390
- e = g[d - 1];
391
- if (e != 0) {
392
- var o = e * (1 << this.F1) + (d > 1 ? g[d - 2] >> this.F2 : 0),
393
- p = this.FV / o,
394
- o = (1 << this.F1) / o,
395
- q = 1 << this.F2,
396
- n = c.t,
397
- k = n - d,
398
- j = b == null ? nbi() : b;
399
- g.dlShiftTo(k, j);
400
- c.compareTo(j) >= 0 && (c[c.t++] = 1, c.subTo(j, c));
401
- BigInteger.ONE.dlShiftTo(d, j);
402
- for (j.subTo(g, g); g.t < d;) g[g.t++] = 0;
403
- for (; --k >= 0;) {
404
- var l = c[--n] == e ? this.DM : Math.floor(c[n] * p + (c[n - 1] + q) * o);
405
- if ((c[n] += g.am(0, l, c, k, 0, d)) < l) {
406
- g.dlShiftTo(k, j);
407
- for (c.subTo(j, c); c[n] < --l;) c.subTo(j, c);
408
- }
409
- }
410
- b != null && (c.drShiftTo(d, b), h != a && BigInteger.ZERO.subTo(b, b));
411
- c.t = d;
412
- c.clamp();
413
- f > 0 && c.rShiftTo(f, c);
414
- h < 0 && BigInteger.ZERO.subTo(c, c);
415
- }
416
- }
417
- }
418
- }
419
- function bnMod(a) {
420
- var b = nbi();
421
- this.abs().divRemTo(a, null, b);
422
- this.s < 0 && b.compareTo(BigInteger.ZERO) > 0 && a.subTo(b, b);
423
- return b;
424
- }
425
- function Classic(a) {
426
- this.m = a;
427
- }
428
- function cConvert(a) {
429
- return a.s < 0 || a.compareTo(this.m) >= 0 ? a.mod(this.m) : a;
430
- }
431
- function cRevert(a) {
432
- return a;
433
- }
434
- function cReduce(a) {
435
- a.divRemTo(this.m, null, a);
436
- }
437
- function cMulTo(a, b, c) {
438
- a.multiplyTo(b, c);
439
- this.reduce(c);
440
- }
441
- function cSqrTo(a, b) {
442
- a.squareTo(b);
443
- this.reduce(b);
444
- }
445
- Classic.prototype.convert = cConvert;
446
- Classic.prototype.revert = cRevert;
447
- Classic.prototype.reduce = cReduce;
448
- Classic.prototype.mulTo = cMulTo;
449
- Classic.prototype.sqrTo = cSqrTo;
450
- function bnpInvDigit() {
451
- if (this.t < 1) return 0;
452
- var a = this[0];
453
- if ((a & 1) == 0) return 0;
454
- var b = a & 3,
455
- b = b * (2 - (a & 15) * b) & 15,
456
- b = b * (2 - (a & 255) * b) & 255,
457
- b = b * (2 - ((a & 65535) * b & 65535)) & 65535,
458
- b = b * (2 - a * b % this.DV) % this.DV;
459
- return b > 0 ? this.DV - b : -b;
460
- }
461
- function Montgomery(a) {
462
- this.m = a;
463
- this.mp = a.invDigit();
464
- this.mpl = this.mp & 32767;
465
- this.mph = this.mp >> 15;
466
- this.um = (1 << a.DB - 15) - 1;
467
- this.mt2 = 2 * a.t;
468
- }
469
- function montConvert(a) {
470
- var b = nbi();
471
- a.abs().dlShiftTo(this.m.t, b);
472
- b.divRemTo(this.m, null, b);
473
- a.s < 0 && b.compareTo(BigInteger.ZERO) > 0 && this.m.subTo(b, b);
474
- return b;
475
- }
476
- function montRevert(a) {
477
- var b = nbi();
478
- a.copyTo(b);
479
- this.reduce(b);
480
- return b;
481
- }
482
- function montReduce(a) {
483
- for (; a.t <= this.mt2;) a[a.t++] = 0;
484
- for (var b = 0; b < this.m.t; ++b) {
485
- var c = a[b] & 32767,
486
- d = c * this.mpl + ((c * this.mph + (a[b] >> 15) * this.mpl & this.um) << 15) & a.DM,
487
- c = b + this.m.t;
488
- for (a[c] += this.m.am(0, d, a, b, 0, this.m.t); a[c] >= a.DV;) a[c] -= a.DV, a[++c]++;
489
- }
490
- a.clamp();
491
- a.drShiftTo(this.m.t, a);
492
- a.compareTo(this.m) >= 0 && a.subTo(this.m, a);
493
- }
494
- function montSqrTo(a, b) {
495
- a.squareTo(b);
496
- this.reduce(b);
497
- }
498
- function montMulTo(a, b, c) {
499
- a.multiplyTo(b, c);
500
- this.reduce(c);
501
- }
502
- Montgomery.prototype.convert = montConvert;
503
- Montgomery.prototype.revert = montRevert;
504
- Montgomery.prototype.reduce = montReduce;
505
- Montgomery.prototype.mulTo = montMulTo;
506
- Montgomery.prototype.sqrTo = montSqrTo;
507
- function bnpIsEven() {
508
- return (this.t > 0 ? this[0] & 1 : this.s) == 0;
509
- }
510
- function bnpExp(a, b) {
511
- if (a > 4294967295 || a < 1) return BigInteger.ONE;
512
- var c = nbi(),
513
- d = nbi(),
514
- e = b.convert(this),
515
- g = nbits(a) - 1;
516
- for (e.copyTo(c); --g >= 0;) if (b.sqrTo(c, d), (a & 1 << g) > 0) b.mulTo(d, e, c);else var h = c,
517
- c = d,
518
- d = h;
519
- return b.revert(c);
520
- }
521
- function bnModPowInt(a, b) {
522
- var c;
523
- c = a < 256 || b.isEven() ? new Classic(b) : new Montgomery(b);
524
- return this.exp(a, c);
525
- }
526
- BigInteger.prototype.copyTo = bnpCopyTo;
527
- BigInteger.prototype.fromInt = bnpFromInt;
528
- BigInteger.prototype.fromString = bnpFromString;
529
- BigInteger.prototype.clamp = bnpClamp;
530
- BigInteger.prototype.dlShiftTo = bnpDLShiftTo;
531
- BigInteger.prototype.drShiftTo = bnpDRShiftTo;
532
- BigInteger.prototype.lShiftTo = bnpLShiftTo;
533
- BigInteger.prototype.rShiftTo = bnpRShiftTo;
534
- BigInteger.prototype.subTo = bnpSubTo;
535
- BigInteger.prototype.multiplyTo = bnpMultiplyTo;
536
- BigInteger.prototype.squareTo = bnpSquareTo;
537
- BigInteger.prototype.divRemTo = bnpDivRemTo;
538
- BigInteger.prototype.invDigit = bnpInvDigit;
539
- BigInteger.prototype.isEven = bnpIsEven;
540
- BigInteger.prototype.exp = bnpExp;
541
- BigInteger.prototype.toString = bnToString;
542
- BigInteger.prototype.negate = bnNegate;
543
- BigInteger.prototype.abs = bnAbs;
544
- BigInteger.prototype.compareTo = bnCompareTo;
545
- BigInteger.prototype.bitLength = bnBitLength;
546
- BigInteger.prototype.mod = bnMod;
547
- BigInteger.prototype.modPowInt = bnModPowInt;
548
- BigInteger.ZERO = nbv(0);
549
- BigInteger.ONE = nbv(1);
550
- function bnClone() {
551
- var a = nbi();
552
- this.copyTo(a);
553
- return a;
554
- }
555
- function bnIntValue() {
556
- if (this.s < 0) {
557
- if (this.t == 1) return this[0] - this.DV;else {
558
- if (this.t == 0) return -1;
559
- }
560
- } else if (this.t == 1) return this[0];else if (this.t == 0) return 0;
561
- return (this[1] & (1 << 32 - this.DB) - 1) << this.DB | this[0];
562
- }
563
- function bnByteValue() {
564
- return this.t == 0 ? this.s : this[0] << 24 >> 24;
565
- }
566
- function bnShortValue() {
567
- return this.t == 0 ? this.s : this[0] << 16 >> 16;
568
- }
569
- function bnpChunkSize(a) {
570
- return Math.floor(Math.LN2 * this.DB / Math.log(a));
571
- }
572
- function bnSigNum() {
573
- return this.s < 0 ? -1 : this.t <= 0 || this.t == 1 && this[0] <= 0 ? 0 : 1;
574
- }
575
- function bnpToRadix(a) {
576
- a == null && (a = 10);
577
- if (this.signum() == 0 || a < 2 || a > 36) return "0";
578
- var b = this.chunkSize(a),
579
- b = Math.pow(a, b),
580
- c = nbv(b),
581
- d = nbi(),
582
- e = nbi(),
583
- g = "";
584
- for (this.divRemTo(c, d, e); d.signum() > 0;) g = (b + e.intValue()).toString(a).substr(1) + g, d.divRemTo(c, d, e);
585
- return e.intValue().toString(a) + g;
586
- }
587
- function bnpFromRadix(a, b) {
588
- this.fromInt(0);
589
- b == null && (b = 10);
590
- for (var c = this.chunkSize(b), d = Math.pow(b, c), e = !1, g = 0, h = 0, f = 0; f < a.length; ++f) {
591
- var o = intAt(a, f);
592
- o < 0 ? a.charAt(f) == "-" && this.signum() == 0 && (e = !0) : (h = b * h + o, ++g >= c && (this.dMultiply(d), this.dAddOffset(h, 0), h = g = 0));
593
- }
594
- g > 0 && (this.dMultiply(Math.pow(b, g)), this.dAddOffset(h, 0));
595
- e && BigInteger.ZERO.subTo(this, this);
596
- }
597
- function bnpFromNumber(a, b, c) {
598
- if ("number" == typeof b) {
599
- if (a < 2) this.fromInt(1);else {
600
- this.fromNumber(a, c);
601
- this.testBit(a - 1) || this.bitwiseTo(BigInteger.ONE.shiftLeft(a - 1), op_or, this);
602
- for (this.isEven() && this.dAddOffset(1, 0); !this.isProbablePrime(b);) this.dAddOffset(2, 0), this.bitLength() > a && this.subTo(BigInteger.ONE.shiftLeft(a - 1), this);
603
- }
604
- } else {
605
- var c = [],
606
- d = a & 7;
607
- c.length = (a >> 3) + 1;
608
- b.nextBytes(c);
609
- d > 0 ? c[0] &= (1 << d) - 1 : c[0] = 0;
610
- this.fromString(c, 256);
611
- }
612
- }
613
- function bnToByteArray() {
614
- var a = this.t,
615
- b = [];
616
- b[0] = this.s;
617
- var c = this.DB - a * this.DB % 8,
618
- d,
619
- e = 0;
620
- if (a-- > 0) {
621
- if (c < this.DB && (d = this[a] >> c) != (this.s & this.DM) >> c) b[e++] = d | this.s << this.DB - c;
622
- for (; a >= 0;) if (c < 8 ? (d = (this[a] & (1 << c) - 1) << 8 - c, d |= this[--a] >> (c += this.DB - 8)) : (d = this[a] >> (c -= 8) & 255, c <= 0 && (c += this.DB, --a)), (d & 128) != 0 && (d |= -256), e == 0 && (this.s & 128) != (d & 128) && ++e, e > 0 || d != this.s) b[e++] = d;
623
- }
624
- return b;
625
- }
626
- function bnEquals(a) {
627
- return this.compareTo(a) == 0;
628
- }
629
- function bnMin(a) {
630
- return this.compareTo(a) < 0 ? this : a;
631
- }
632
- function bnMax(a) {
633
- return this.compareTo(a) > 0 ? this : a;
634
- }
635
- function bnpBitwiseTo(a, b, c) {
636
- var d,
637
- e,
638
- g = Math.min(a.t, this.t);
639
- for (d = 0; d < g; ++d) c[d] = b(this[d], a[d]);
640
- if (a.t < this.t) {
641
- e = a.s & this.DM;
642
- for (d = g; d < this.t; ++d) c[d] = b(this[d], e);
643
- c.t = this.t;
644
- } else {
645
- e = this.s & this.DM;
646
- for (d = g; d < a.t; ++d) c[d] = b(e, a[d]);
647
- c.t = a.t;
648
- }
649
- c.s = b(this.s, a.s);
650
- c.clamp();
651
- }
652
- function op_and(a, b) {
653
- return a & b;
654
- }
655
- function bnAnd(a) {
656
- var b = nbi();
657
- this.bitwiseTo(a, op_and, b);
658
- return b;
659
- }
660
- function op_or(a, b) {
661
- return a | b;
662
- }
663
- function bnOr(a) {
664
- var b = nbi();
665
- this.bitwiseTo(a, op_or, b);
666
- return b;
667
- }
668
- function op_xor(a, b) {
669
- return a ^ b;
670
- }
671
- function bnXor(a) {
672
- var b = nbi();
673
- this.bitwiseTo(a, op_xor, b);
674
- return b;
675
- }
676
- function op_andnot(a, b) {
677
- return a & ~b;
678
- }
679
- function bnAndNot(a) {
680
- var b = nbi();
681
- this.bitwiseTo(a, op_andnot, b);
682
- return b;
683
- }
684
- function bnNot() {
685
- for (var a = nbi(), b = 0; b < this.t; ++b) a[b] = this.DM & ~this[b];
686
- a.t = this.t;
687
- a.s = ~this.s;
688
- return a;
689
- }
690
- function bnShiftLeft(a) {
691
- var b = nbi();
692
- a < 0 ? this.rShiftTo(-a, b) : this.lShiftTo(a, b);
693
- return b;
694
- }
695
- function bnShiftRight(a) {
696
- var b = nbi();
697
- a < 0 ? this.lShiftTo(-a, b) : this.rShiftTo(a, b);
698
- return b;
699
- }
700
- function lbit(a) {
701
- if (a == 0) return -1;
702
- var b = 0;
703
- (a & 65535) == 0 && (a >>= 16, b += 16);
704
- (a & 255) == 0 && (a >>= 8, b += 8);
705
- (a & 15) == 0 && (a >>= 4, b += 4);
706
- (a & 3) == 0 && (a >>= 2, b += 2);
707
- (a & 1) == 0 && ++b;
708
- return b;
709
- }
710
- function bnGetLowestSetBit() {
711
- for (var a = 0; a < this.t; ++a) if (this[a] != 0) return a * this.DB + lbit(this[a]);
712
- return this.s < 0 ? this.t * this.DB : -1;
713
- }
714
- function cbit(a) {
715
- for (var b = 0; a != 0;) a &= a - 1, ++b;
716
- return b;
717
- }
718
- function bnBitCount() {
719
- for (var a = 0, b = this.s & this.DM, c = 0; c < this.t; ++c) a += cbit(this[c] ^ b);
720
- return a;
721
- }
722
- function bnTestBit(a) {
723
- var b = Math.floor(a / this.DB);
724
- return b >= this.t ? this.s != 0 : (this[b] & 1 << a % this.DB) != 0;
725
- }
726
- function bnpChangeBit(a, b) {
727
- var c = BigInteger.ONE.shiftLeft(a);
728
- this.bitwiseTo(c, b, c);
729
- return c;
730
- }
731
- function bnSetBit(a) {
732
- return this.changeBit(a, op_or);
733
- }
734
- function bnClearBit(a) {
735
- return this.changeBit(a, op_andnot);
736
- }
737
- function bnFlipBit(a) {
738
- return this.changeBit(a, op_xor);
739
- }
740
- function bnpAddTo(a, b) {
741
- for (var c = 0, d = 0, e = Math.min(a.t, this.t); c < e;) d += this[c] + a[c], b[c++] = d & this.DM, d >>= this.DB;
742
- if (a.t < this.t) {
743
- for (d += a.s; c < this.t;) d += this[c], b[c++] = d & this.DM, d >>= this.DB;
744
- d += this.s;
745
- } else {
746
- for (d += this.s; c < a.t;) d += a[c], b[c++] = d & this.DM, d >>= this.DB;
747
- d += a.s;
748
- }
749
- b.s = d < 0 ? -1 : 0;
750
- d > 0 ? b[c++] = d : d < -1 && (b[c++] = this.DV + d);
751
- b.t = c;
752
- b.clamp();
753
- }
754
- function bnAdd(a) {
755
- var b = nbi();
756
- this.addTo(a, b);
757
- return b;
758
- }
759
- function bnSubtract(a) {
760
- var b = nbi();
761
- this.subTo(a, b);
762
- return b;
763
- }
764
- function bnMultiply(a) {
765
- var b = nbi();
766
- this.multiplyTo(a, b);
767
- return b;
768
- }
769
- function bnSquare() {
770
- var a = nbi();
771
- this.squareTo(a);
772
- return a;
773
- }
774
- function bnDivide(a) {
775
- var b = nbi();
776
- this.divRemTo(a, b, null);
777
- return b;
778
- }
779
- function bnRemainder(a) {
780
- var b = nbi();
781
- this.divRemTo(a, null, b);
782
- return b;
783
- }
784
- function bnDivideAndRemainder(a) {
785
- var b = nbi(),
786
- c = nbi();
787
- this.divRemTo(a, b, c);
788
- return [b, c];
789
- }
790
- function bnpDMultiply(a) {
791
- this[this.t] = this.am(0, a - 1, this, 0, 0, this.t);
792
- ++this.t;
793
- this.clamp();
794
- }
795
- function bnpDAddOffset(a, b) {
796
- if (a != 0) {
797
- for (; this.t <= b;) this[this.t++] = 0;
798
- for (this[b] += a; this[b] >= this.DV;) this[b] -= this.DV, ++b >= this.t && (this[this.t++] = 0), ++this[b];
799
- }
800
- }
801
- function NullExp() {}
802
- function nNop(a) {
803
- return a;
804
- }
805
- function nMulTo(a, b, c) {
806
- a.multiplyTo(b, c);
807
- }
808
- function nSqrTo(a, b) {
809
- a.squareTo(b);
810
- }
811
- NullExp.prototype.convert = nNop;
812
- NullExp.prototype.revert = nNop;
813
- NullExp.prototype.mulTo = nMulTo;
814
- NullExp.prototype.sqrTo = nSqrTo;
815
- function bnPow(a) {
816
- return this.exp(a, new NullExp());
817
- }
818
- function bnpMultiplyLowerTo(a, b, c) {
819
- var d = Math.min(this.t + a.t, b);
820
- c.s = 0;
821
- for (c.t = d; d > 0;) c[--d] = 0;
822
- var e;
823
- for (e = c.t - this.t; d < e; ++d) c[d + this.t] = this.am(0, a[d], c, d, 0, this.t);
824
- for (e = Math.min(a.t, b); d < e; ++d) this.am(0, a[d], c, d, 0, b - d);
825
- c.clamp();
826
- }
827
- function bnpMultiplyUpperTo(a, b, c) {
828
- --b;
829
- var d = c.t = this.t + a.t - b;
830
- for (c.s = 0; --d >= 0;) c[d] = 0;
831
- for (d = Math.max(b - this.t, 0); d < a.t; ++d) c[this.t + d - b] = this.am(b - d, a[d], c, 0, 0, this.t + d - b);
832
- c.clamp();
833
- c.drShiftTo(1, c);
834
- }
835
- function Barrett(a) {
836
- this.r2 = nbi();
837
- this.q3 = nbi();
838
- BigInteger.ONE.dlShiftTo(2 * a.t, this.r2);
839
- this.mu = this.r2.divide(a);
840
- this.m = a;
841
- }
842
- function barrettConvert(a) {
843
- if (a.s < 0 || a.t > 2 * this.m.t) return a.mod(this.m);else if (a.compareTo(this.m) < 0) return a;else {
844
- var b = nbi();
845
- a.copyTo(b);
846
- this.reduce(b);
847
- return b;
848
- }
849
- }
850
- function barrettRevert(a) {
851
- return a;
852
- }
853
- function barrettReduce(a) {
854
- a.drShiftTo(this.m.t - 1, this.r2);
855
- if (a.t > this.m.t + 1) a.t = this.m.t + 1, a.clamp();
856
- this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3);
857
- for (this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2); a.compareTo(this.r2) < 0;) a.dAddOffset(1, this.m.t + 1);
858
- for (a.subTo(this.r2, a); a.compareTo(this.m) >= 0;) a.subTo(this.m, a);
859
- }
860
- function barrettSqrTo(a, b) {
861
- a.squareTo(b);
862
- this.reduce(b);
863
- }
864
- function barrettMulTo(a, b, c) {
865
- a.multiplyTo(b, c);
866
- this.reduce(c);
867
- }
868
- Barrett.prototype.convert = barrettConvert;
869
- Barrett.prototype.revert = barrettRevert;
870
- Barrett.prototype.reduce = barrettReduce;
871
- Barrett.prototype.mulTo = barrettMulTo;
872
- Barrett.prototype.sqrTo = barrettSqrTo;
873
- function bnModPow(a, b) {
874
- var c = a.bitLength(),
875
- d,
876
- e = nbv(1),
877
- g;
878
- if (c <= 0) return e;else d = c < 18 ? 1 : c < 48 ? 3 : c < 144 ? 4 : c < 768 ? 5 : 6;
879
- g = c < 8 ? new Classic(b) : b.isEven() ? new Barrett(b) : new Montgomery(b);
880
- var h = [],
881
- f = 3,
882
- o = d - 1,
883
- p = (1 << d) - 1;
884
- h[1] = g.convert(this);
885
- if (d > 1) {
886
- c = nbi();
887
- for (g.sqrTo(h[1], c); f <= p;) h[f] = nbi(), g.mulTo(c, h[f - 2], h[f]), f += 2;
888
- }
889
- for (var q = a.t - 1, n, k = !0, j = nbi(), c = nbits(a[q]) - 1; q >= 0;) {
890
- c >= o ? n = a[q] >> c - o & p : (n = (a[q] & (1 << c + 1) - 1) << o - c, q > 0 && (n |= a[q - 1] >> this.DB + c - o));
891
- for (f = d; (n & 1) == 0;) n >>= 1, --f;
892
- if ((c -= f) < 0) c += this.DB, --q;
893
- if (k) h[n].copyTo(e), k = !1;else {
894
- for (; f > 1;) g.sqrTo(e, j), g.sqrTo(j, e), f -= 2;
895
- f > 0 ? g.sqrTo(e, j) : (f = e, e = j, j = f);
896
- g.mulTo(j, h[n], e);
897
- }
898
- for (; q >= 0 && (a[q] & 1 << c) == 0;) g.sqrTo(e, j), f = e, e = j, j = f, --c < 0 && (c = this.DB - 1, --q);
899
- }
900
- return g.revert(e);
901
- }
902
- function bnGCD(a) {
903
- var b = this.s < 0 ? this.negate() : this.clone(),
904
- a = a.s < 0 ? a.negate() : a.clone();
905
- if (b.compareTo(a) < 0) var c = b,
906
- b = a,
907
- a = c;
908
- var c = b.getLowestSetBit(),
909
- d = a.getLowestSetBit();
910
- if (d < 0) return b;
911
- c < d && (d = c);
912
- d > 0 && (b.rShiftTo(d, b), a.rShiftTo(d, a));
913
- for (; b.signum() > 0;) (c = b.getLowestSetBit()) > 0 && b.rShiftTo(c, b), (c = a.getLowestSetBit()) > 0 && a.rShiftTo(c, a), b.compareTo(a) >= 0 ? (b.subTo(a, b), b.rShiftTo(1, b)) : (a.subTo(b, a), a.rShiftTo(1, a));
914
- d > 0 && a.lShiftTo(d, a);
915
- return a;
916
- }
917
- function bnpModInt(a) {
918
- if (a <= 0) return 0;
919
- var b = this.DV % a,
920
- c = this.s < 0 ? a - 1 : 0;
921
- if (this.t > 0) if (b == 0) c = this[0] % a;else for (var d = this.t - 1; d >= 0; --d) c = (b * c + this[d]) % a;
922
- return c;
923
- }
924
- function bnModInverse(a) {
925
- var b = a.isEven();
926
- if (this.isEven() && b || a.signum() == 0) return BigInteger.ZERO;
927
- for (var c = a.clone(), d = this.clone(), e = nbv(1), g = nbv(0), h = nbv(0), f = nbv(1); c.signum() != 0;) {
928
- for (; c.isEven();) {
929
- c.rShiftTo(1, c);
930
- if (b) {
931
- if (!e.isEven() || !g.isEven()) e.addTo(this, e), g.subTo(a, g);
932
- e.rShiftTo(1, e);
933
- } else g.isEven() || g.subTo(a, g);
934
- g.rShiftTo(1, g);
935
- }
936
- for (; d.isEven();) {
937
- d.rShiftTo(1, d);
938
- if (b) {
939
- if (!h.isEven() || !f.isEven()) h.addTo(this, h), f.subTo(a, f);
940
- h.rShiftTo(1, h);
941
- } else f.isEven() || f.subTo(a, f);
942
- f.rShiftTo(1, f);
943
- }
944
- c.compareTo(d) >= 0 ? (c.subTo(d, c), b && e.subTo(h, e), g.subTo(f, g)) : (d.subTo(c, d), b && h.subTo(e, h), f.subTo(g, f));
945
- }
946
- if (d.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;
947
- if (f.compareTo(a) >= 0) return f.subtract(a);
948
- if (f.signum() < 0) f.addTo(a, f);else return f;
949
- return f.signum() < 0 ? f.add(a) : f;
950
- }
951
- var lowprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997],
952
- lplim = 67108864 / lowprimes[lowprimes.length - 1];
953
- function bnIsProbablePrime(a) {
954
- var b,
955
- c = this.abs();
956
- if (c.t == 1 && c[0] <= lowprimes[lowprimes.length - 1]) {
957
- for (b = 0; b < lowprimes.length; ++b) if (c[0] == lowprimes[b]) return !0;
958
- return !1;
959
- }
960
- if (c.isEven()) return !1;
961
- for (b = 1; b < lowprimes.length;) {
962
- for (var d = lowprimes[b], e = b + 1; e < lowprimes.length && d < lplim;) d *= lowprimes[e++];
963
- for (d = c.modInt(d); b < e;) if (d % lowprimes[b++] == 0) return !1;
964
- }
965
- return c.millerRabin(a);
966
- }
967
- function bnpMillerRabin(a) {
968
- var b = this.subtract(BigInteger.ONE),
969
- c = b.getLowestSetBit();
970
- if (c <= 0) return !1;
971
- var d = b.shiftRight(c),
972
- a = a + 1 >> 1;
973
- if (a > lowprimes.length) a = lowprimes.length;
974
- for (var e = nbi(), g = 0; g < a; ++g) {
975
- e.fromInt(lowprimes[Math.floor(Math.random() * lowprimes.length)]);
976
- var h = e.modPow(d, this);
977
- if (h.compareTo(BigInteger.ONE) != 0 && h.compareTo(b) != 0) {
978
- for (var f = 1; f++ < c && h.compareTo(b) != 0;) if (h = h.modPowInt(2, this), h.compareTo(BigInteger.ONE) == 0) return !1;
979
- if (h.compareTo(b) != 0) return !1;
980
- }
981
- }
982
- return !0;
983
- }
984
- BigInteger.prototype.chunkSize = bnpChunkSize;
985
- BigInteger.prototype.toRadix = bnpToRadix;
986
- BigInteger.prototype.fromRadix = bnpFromRadix;
987
- BigInteger.prototype.fromNumber = bnpFromNumber;
988
- BigInteger.prototype.bitwiseTo = bnpBitwiseTo;
989
- BigInteger.prototype.changeBit = bnpChangeBit;
990
- BigInteger.prototype.addTo = bnpAddTo;
991
- BigInteger.prototype.dMultiply = bnpDMultiply;
992
- BigInteger.prototype.dAddOffset = bnpDAddOffset;
993
- BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo;
994
- BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo;
995
- BigInteger.prototype.modInt = bnpModInt;
996
- BigInteger.prototype.millerRabin = bnpMillerRabin;
997
- BigInteger.prototype.clone = bnClone;
998
- BigInteger.prototype.intValue = bnIntValue;
999
- BigInteger.prototype.byteValue = bnByteValue;
1000
- BigInteger.prototype.shortValue = bnShortValue;
1001
- BigInteger.prototype.signum = bnSigNum;
1002
- BigInteger.prototype.toByteArray = bnToByteArray;
1003
- BigInteger.prototype.equals = bnEquals;
1004
- BigInteger.prototype.min = bnMin;
1005
- BigInteger.prototype.max = bnMax;
1006
- BigInteger.prototype.and = bnAnd;
1007
- BigInteger.prototype.or = bnOr;
1008
- BigInteger.prototype.xor = bnXor;
1009
- BigInteger.prototype.andNot = bnAndNot;
1010
- BigInteger.prototype.not = bnNot;
1011
- BigInteger.prototype.shiftLeft = bnShiftLeft;
1012
- BigInteger.prototype.shiftRight = bnShiftRight;
1013
- BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit;
1014
- BigInteger.prototype.bitCount = bnBitCount;
1015
- BigInteger.prototype.testBit = bnTestBit;
1016
- BigInteger.prototype.setBit = bnSetBit;
1017
- BigInteger.prototype.clearBit = bnClearBit;
1018
- BigInteger.prototype.flipBit = bnFlipBit;
1019
- BigInteger.prototype.add = bnAdd;
1020
- BigInteger.prototype.subtract = bnSubtract;
1021
- BigInteger.prototype.multiply = bnMultiply;
1022
- BigInteger.prototype.divide = bnDivide;
1023
- BigInteger.prototype.remainder = bnRemainder;
1024
- BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder;
1025
- BigInteger.prototype.modPow = bnModPow;
1026
- BigInteger.prototype.modInverse = bnModInverse;
1027
- BigInteger.prototype.pow = bnPow;
1028
- BigInteger.prototype.gcd = bnGCD;
1029
- BigInteger.prototype.isProbablePrime = bnIsProbablePrime;
1030
- BigInteger.prototype.square = bnSquare;
1031
- (function (a, b, c, d, e, g, h) {
1032
- function f(a) {
1033
- var b,
1034
- d,
1035
- e = this,
1036
- g = a.length,
1037
- f = 0,
1038
- h = e.i = e.j = e.m = 0;
1039
- e.S = [];
1040
- e.c = [];
1041
- for (g || (a = [g++]); f < c;) e.S[f] = f++;
1042
- for (f = 0; f < c; f++) b = e.S[f], h = h + b + a[f % g] & c - 1, d = e.S[h], e.S[f] = d, e.S[h] = b;
1043
- e.g = function (a) {
1044
- var b = e.S,
1045
- d = e.i + 1 & c - 1,
1046
- g = b[d],
1047
- f = e.j + g & c - 1,
1048
- h = b[f];
1049
- b[d] = h;
1050
- b[f] = g;
1051
- for (var k = b[g + h & c - 1]; --a;) d = d + 1 & c - 1, g = b[d], f = f + g & c - 1, h = b[f], b[d] = h, b[f] = g, k = k * c + b[g + h & c - 1];
1052
- e.i = d;
1053
- e.j = f;
1054
- return k;
1055
- };
1056
- e.g(c);
1057
- }
1058
- function o(a, b, c, d, e) {
1059
- c = [];
1060
- e = typeof a;
1061
- if (b && e == "object") for (d in a) if (d.indexOf("S") < 5) try {
1062
- c.push(o(a[d], b - 1));
1063
- } catch (g) {}
1064
- return c.length ? c : a + (e != "string" ? "\x00" : "");
1065
- }
1066
- function p(a, b, d, e) {
1067
- a += "";
1068
- for (e = d = 0; e < a.length; e++) {
1069
- var g = b,
1070
- f = e & c - 1,
1071
- h = (d ^= b[e & c - 1] * 19) + a.charCodeAt(e);
1072
- g[f] = h & c - 1;
1073
- }
1074
- a = "";
1075
- for (e in b) a += String.fromCharCode(b[e]);
1076
- return a;
1077
- }
1078
- b.seedrandom = function (q, n) {
1079
- var k = [],
1080
- j,
1081
- q = p(o(n ? [q, a] : arguments.length ? q : [new Date().getTime(), a, window], 3), k);
1082
- j = new f(k);
1083
- p(j.S, a);
1084
- b.random = function () {
1085
- for (var a = j.g(d), b = h, f = 0; a < e;) a = (a + f) * c, b *= c, f = j.g(1);
1086
- for (; a >= g;) a /= 2, b /= 2, f >>>= 1;
1087
- return (a + f) / b;
1088
- };
1089
- return q;
1090
- };
1091
- h = b.pow(c, d);
1092
- e = b.pow(2, e);
1093
- g = e * 2;
1094
- p(b.random(), a);
1095
- })([], Math, 256, 6, 52);
1096
- function SeededRandom() {}
1097
- function SRnextBytes(a) {
1098
- var b;
1099
- for (b = 0; b < a.length; b++) a[b] = Math.floor(Math.random() * 256);
1100
- }
1101
- SeededRandom.prototype.nextBytes = SRnextBytes;
1102
- function Arcfour() {
1103
- this.j = this.i = 0;
1104
- this.S = [];
1105
- }
1106
- function ARC4init(a) {
1107
- var b, c, d;
1108
- for (b = 0; b < 256; ++b) this.S[b] = b;
1109
- for (b = c = 0; b < 256; ++b) c = c + this.S[b] + a[b % a.length] & 255, d = this.S[b], this.S[b] = this.S[c], this.S[c] = d;
1110
- this.j = this.i = 0;
1111
- }
1112
- function ARC4next() {
1113
- var a;
1114
- this.i = this.i + 1 & 255;
1115
- this.j = this.j + this.S[this.i] & 255;
1116
- a = this.S[this.i];
1117
- this.S[this.i] = this.S[this.j];
1118
- this.S[this.j] = a;
1119
- return this.S[a + this.S[this.i] & 255];
1120
- }
1121
- Arcfour.prototype.init = ARC4init;
1122
- Arcfour.prototype.next = ARC4next;
1123
- function prng_newstate() {
1124
- return new Arcfour();
1125
- }
1126
- var rng_psize = 256,
1127
- rng_state,
1128
- rng_pool,
1129
- rng_pptr;
1130
- function rng_seed_int(a) {
1131
- rng_pool[rng_pptr++] ^= a & 255;
1132
- rng_pool[rng_pptr++] ^= a >> 8 & 255;
1133
- rng_pool[rng_pptr++] ^= a >> 16 & 255;
1134
- rng_pool[rng_pptr++] ^= a >> 24 & 255;
1135
- rng_pptr >= rng_psize && (rng_pptr -= rng_psize);
1136
- }
1137
- function rng_seed_time() {
1138
- rng_seed_int(new Date().getTime());
1139
- }
1140
- if (rng_pool == null) {
1141
- rng_pool = [];
1142
- rng_pptr = 0;
1143
- var t;
1144
- for (; rng_pptr < rng_psize;) t = Math.floor(65536 * Math.random()), rng_pool[rng_pptr++] = t >>> 8, rng_pool[rng_pptr++] = t & 255;
1145
- rng_pptr = 0;
1146
- rng_seed_time();
1147
- }
1148
- function rng_get_byte() {
1149
- if (rng_state == null) {
1150
- rng_seed_time();
1151
- rng_state = prng_newstate();
1152
- rng_state.init(rng_pool);
1153
- for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr) rng_pool[rng_pptr] = 0;
1154
- rng_pptr = 0;
1155
- }
1156
- return rng_state.next();
1157
- }
1158
- function rng_get_bytes(a) {
1159
- var b;
1160
- for (b = 0; b < a.length; ++b) a[b] = rng_get_byte();
1161
- }
1162
- function SecureRandom() {}
1163
- SecureRandom.prototype.nextBytes = rng_get_bytes;
1164
- function SHA256(a) {
1165
- function b(a, b) {
1166
- var c = (a & 65535) + (b & 65535);
1167
- return (a >> 16) + (b >> 16) + (c >> 16) << 16 | c & 65535;
1168
- }
1169
- function c(a, b) {
1170
- return a >>> b | a << 32 - b;
1171
- }
1172
- a = function (a) {
1173
- for (var a = a.replace(/\r\n/g, "\n"), b = "", c = 0; c < a.length; c++) {
1174
- var h = a.charCodeAt(c);
1175
- h < 128 ? b += String.fromCharCode(h) : (h > 127 && h < 2048 ? b += String.fromCharCode(h >> 6 | 192) : (b += String.fromCharCode(h >> 12 | 224), b += String.fromCharCode(h >> 6 & 63 | 128)), b += String.fromCharCode(h & 63 | 128));
1176
- }
1177
- return b;
1178
- }(a);
1179
- return function (a) {
1180
- for (var b = "", c = 0; c < a.length * 4; c++) b += "0123456789abcdef".charAt(a[c >> 2] >> (3 - c % 4) * 8 + 4 & 15) + "0123456789abcdef".charAt(a[c >> 2] >> (3 - c % 4) * 8 & 15);
1181
- return b;
1182
- }(function (a, e) {
1183
- var g = [1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479, 3329325298],
1184
- h = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225],
1185
- f = Array(64),
1186
- o,
1187
- p,
1188
- q,
1189
- n,
1190
- k,
1191
- j,
1192
- l,
1193
- m,
1194
- s,
1195
- r,
1196
- u,
1197
- w;
1198
- a[e >> 5] |= 128 << 24 - e % 32;
1199
- a[(e + 64 >> 9 << 4) + 15] = e;
1200
- for (s = 0; s < a.length; s += 16) {
1201
- o = h[0];
1202
- p = h[1];
1203
- q = h[2];
1204
- n = h[3];
1205
- k = h[4];
1206
- j = h[5];
1207
- l = h[6];
1208
- m = h[7];
1209
- for (r = 0; r < 64; r++) f[r] = r < 16 ? a[r + s] : b(b(b(c(f[r - 2], 17) ^ c(f[r - 2], 19) ^ f[r - 2] >>> 10, f[r - 7]), c(f[r - 15], 7) ^ c(f[r - 15], 18) ^ f[r - 15] >>> 3), f[r - 16]), u = b(b(b(b(m, c(k, 6) ^ c(k, 11) ^ c(k, 25)), k & j ^ ~k & l), g[r]), f[r]), w = b(c(o, 2) ^ c(o, 13) ^ c(o, 22), o & p ^ o & q ^ p & q), m = l, l = j, j = k, k = b(n, u), n = q, q = p, p = o, o = b(u, w);
1210
- h[0] = b(o, h[0]);
1211
- h[1] = b(p, h[1]);
1212
- h[2] = b(q, h[2]);
1213
- h[3] = b(n, h[3]);
1214
- h[4] = b(k, h[4]);
1215
- h[5] = b(j, h[5]);
1216
- h[6] = b(l, h[6]);
1217
- h[7] = b(m, h[7]);
1218
- }
1219
- return h;
1220
- }(function (a) {
1221
- for (var b = [], c = 0; c < a.length * 8; c += 8) b[c >> 5] |= (a.charCodeAt(c / 8) & 255) << 24 - c % 32;
1222
- return b;
1223
- }(a), a.length * 8));
1224
- }
1225
- var sha256 = {
1226
- hex: function (a) {
1227
- return SHA256(a);
1228
- }
1229
- };
1230
- function SHA1(a) {
1231
- function b(a, b) {
1232
- return a << b | a >>> 32 - b;
1233
- }
1234
- function c(a) {
1235
- var b = "",
1236
- c,
1237
- d;
1238
- for (c = 7; c >= 0; c--) d = a >>> c * 4 & 15, b += d.toString(16);
1239
- return b;
1240
- }
1241
- var d,
1242
- e,
1243
- g = Array(80),
1244
- h = 1732584193,
1245
- f = 4023233417,
1246
- o = 2562383102,
1247
- p = 271733878,
1248
- q = 3285377520,
1249
- n,
1250
- k,
1251
- j,
1252
- l,
1253
- m,
1254
- a = function (a) {
1255
- for (var a = a.replace(/\r\n/g, "\n"), b = "", c = 0; c < a.length; c++) {
1256
- var d = a.charCodeAt(c);
1257
- d < 128 ? b += String.fromCharCode(d) : (d > 127 && d < 2048 ? b += String.fromCharCode(d >> 6 | 192) : (b += String.fromCharCode(d >> 12 | 224), b += String.fromCharCode(d >> 6 & 63 | 128)), b += String.fromCharCode(d & 63 | 128));
1258
- }
1259
- return b;
1260
- }(a);
1261
- n = a.length;
1262
- var s = [];
1263
- for (d = 0; d < n - 3; d += 4) e = a.charCodeAt(d) << 24 | a.charCodeAt(d + 1) << 16 | a.charCodeAt(d + 2) << 8 | a.charCodeAt(d + 3), s.push(e);
1264
- switch (n % 4) {
1265
- case 0:
1266
- d = 2147483648;
1267
- break;
1268
- case 1:
1269
- d = a.charCodeAt(n - 1) << 24 | 8388608;
1270
- break;
1271
- case 2:
1272
- d = a.charCodeAt(n - 2) << 24 | a.charCodeAt(n - 1) << 16 | 32768;
1273
- break;
1274
- case 3:
1275
- d = a.charCodeAt(n - 3) << 24 | a.charCodeAt(n - 2) << 16 | a.charCodeAt(n - 1) << 8 | 128;
1276
- }
1277
- for (s.push(d); s.length % 16 != 14;) s.push(0);
1278
- s.push(n >>> 29);
1279
- s.push(n << 3 & 4294967295);
1280
- for (a = 0; a < s.length; a += 16) {
1281
- for (d = 0; d < 16; d++) g[d] = s[a + d];
1282
- for (d = 16; d <= 79; d++) g[d] = b(g[d - 3] ^ g[d - 8] ^ g[d - 14] ^ g[d - 16], 1);
1283
- e = h;
1284
- n = f;
1285
- k = o;
1286
- j = p;
1287
- l = q;
1288
- for (d = 0; d <= 19; d++) m = b(e, 5) + (n & k | ~n & j) + l + g[d] + 1518500249 & 4294967295, l = j, j = k, k = b(n, 30), n = e, e = m;
1289
- for (d = 20; d <= 39; d++) m = b(e, 5) + (n ^ k ^ j) + l + g[d] + 1859775393 & 4294967295, l = j, j = k, k = b(n, 30), n = e, e = m;
1290
- for (d = 40; d <= 59; d++) m = b(e, 5) + (n & k | n & j | k & j) + l + g[d] + 2400959708 & 4294967295, l = j, j = k, k = b(n, 30), n = e, e = m;
1291
- for (d = 60; d <= 79; d++) m = b(e, 5) + (n ^ k ^ j) + l + g[d] + 3395469782 & 4294967295, l = j, j = k, k = b(n, 30), n = e, e = m;
1292
- h = h + e & 4294967295;
1293
- f = f + n & 4294967295;
1294
- o = o + k & 4294967295;
1295
- p = p + j & 4294967295;
1296
- q = q + l & 4294967295;
1297
- }
1298
- m = c(h) + c(f) + c(o) + c(p) + c(q);
1299
- return m.toLowerCase();
1300
- }
1301
- var sha1 = {
1302
- hex: function (a) {
1303
- return SHA1(a);
1304
- }
1305
- },
1306
- MD5 = function (a) {
1307
- function b(a, b) {
1308
- var c, d, e, f, g;
1309
- e = a & 2147483648;
1310
- f = b & 2147483648;
1311
- c = a & 1073741824;
1312
- d = b & 1073741824;
1313
- g = (a & 1073741823) + (b & 1073741823);
1314
- return c & d ? g ^ 2147483648 ^ e ^ f : c | d ? g & 1073741824 ? g ^ 3221225472 ^ e ^ f : g ^ 1073741824 ^ e ^ f : g ^ e ^ f;
1315
- }
1316
- function c(a, c, d, e, f, g, h) {
1317
- a = b(a, b(b(c & d | ~c & e, f), h));
1318
- return b(a << g | a >>> 32 - g, c);
1319
- }
1320
- function d(a, c, d, e, f, g, h) {
1321
- a = b(a, b(b(c & e | d & ~e, f), h));
1322
- return b(a << g | a >>> 32 - g, c);
1323
- }
1324
- function e(a, c, d, e, f, g, h) {
1325
- a = b(a, b(b(c ^ d ^ e, f), h));
1326
- return b(a << g | a >>> 32 - g, c);
1327
- }
1328
- function g(a, c, d, e, f, g, h) {
1329
- a = b(a, b(b(d ^ (c | ~e), f), h));
1330
- return b(a << g | a >>> 32 - g, c);
1331
- }
1332
- function h(a) {
1333
- var b = "",
1334
- c = "",
1335
- d;
1336
- for (d = 0; d <= 3; d++) c = a >>> d * 8 & 255, c = "0" + c.toString(16), b += c.substr(c.length - 2, 2);
1337
- return b;
1338
- }
1339
- var f = [],
1340
- o,
1341
- p,
1342
- q,
1343
- n,
1344
- k,
1345
- j,
1346
- l,
1347
- m,
1348
- a = function (a) {
1349
- for (var a = a.replace(/\r\n/g, "\n"), b = "", c = 0; c < a.length; c++) {
1350
- var d = a.charCodeAt(c);
1351
- d < 128 ? b += String.fromCharCode(d) : (d > 127 && d < 2048 ? b += String.fromCharCode(d >> 6 | 192) : (b += String.fromCharCode(d >> 12 | 224), b += String.fromCharCode(d >> 6 & 63 | 128)), b += String.fromCharCode(d & 63 | 128));
1352
- }
1353
- return b;
1354
- }(a),
1355
- f = function (a) {
1356
- var b,
1357
- c = a.length;
1358
- b = c + 8;
1359
- for (var d = ((b - b % 64) / 64 + 1) * 16, e = Array(d - 1), f = 0, g = 0; g < c;) b = (g - g % 4) / 4, f = g % 4 * 8, e[b] |= a.charCodeAt(g) << f, g++;
1360
- e[(g - g % 4) / 4] |= 128 << g % 4 * 8;
1361
- e[d - 2] = c << 3;
1362
- e[d - 1] = c >>> 29;
1363
- return e;
1364
- }(a);
1365
- k = 1732584193;
1366
- j = 4023233417;
1367
- l = 2562383102;
1368
- m = 271733878;
1369
- for (a = 0; a < f.length; a += 16) o = k, p = j, q = l, n = m, k = c(k, j, l, m, f[a + 0], 7, 3614090360), m = c(m, k, j, l, f[a + 1], 12, 3905402710), l = c(l, m, k, j, f[a + 2], 17, 606105819), j = c(j, l, m, k, f[a + 3], 22, 3250441966), k = c(k, j, l, m, f[a + 4], 7, 4118548399), m = c(m, k, j, l, f[a + 5], 12, 1200080426), l = c(l, m, k, j, f[a + 6], 17, 2821735955), j = c(j, l, m, k, f[a + 7], 22, 4249261313), k = c(k, j, l, m, f[a + 8], 7, 1770035416), m = c(m, k, j, l, f[a + 9], 12, 2336552879), l = c(l, m, k, j, f[a + 10], 17, 4294925233), j = c(j, l, m, k, f[a + 11], 22, 2304563134), k = c(k, j, l, m, f[a + 12], 7, 1804603682), m = c(m, k, j, l, f[a + 13], 12, 4254626195), l = c(l, m, k, j, f[a + 14], 17, 2792965006), j = c(j, l, m, k, f[a + 15], 22, 1236535329), k = d(k, j, l, m, f[a + 1], 5, 4129170786), m = d(m, k, j, l, f[a + 6], 9, 3225465664), l = d(l, m, k, j, f[a + 11], 14, 643717713), j = d(j, l, m, k, f[a + 0], 20, 3921069994), k = d(k, j, l, m, f[a + 5], 5, 3593408605), m = d(m, k, j, l, f[a + 10], 9, 38016083), l = d(l, m, k, j, f[a + 15], 14, 3634488961), j = d(j, l, m, k, f[a + 4], 20, 3889429448), k = d(k, j, l, m, f[a + 9], 5, 568446438), m = d(m, k, j, l, f[a + 14], 9, 3275163606), l = d(l, m, k, j, f[a + 3], 14, 4107603335), j = d(j, l, m, k, f[a + 8], 20, 1163531501), k = d(k, j, l, m, f[a + 13], 5, 2850285829), m = d(m, k, j, l, f[a + 2], 9, 4243563512), l = d(l, m, k, j, f[a + 7], 14, 1735328473), j = d(j, l, m, k, f[a + 12], 20, 2368359562), k = e(k, j, l, m, f[a + 5], 4, 4294588738), m = e(m, k, j, l, f[a + 8], 11, 2272392833), l = e(l, m, k, j, f[a + 11], 16, 1839030562), j = e(j, l, m, k, f[a + 14], 23, 4259657740), k = e(k, j, l, m, f[a + 1], 4, 2763975236), m = e(m, k, j, l, f[a + 4], 11, 1272893353), l = e(l, m, k, j, f[a + 7], 16, 4139469664), j = e(j, l, m, k, f[a + 10], 23, 3200236656), k = e(k, j, l, m, f[a + 13], 4, 681279174), m = e(m, k, j, l, f[a + 0], 11, 3936430074), l = e(l, m, k, j, f[a + 3], 16, 3572445317), j = e(j, l, m, k, f[a + 6], 23, 76029189), k = e(k, j, l, m, f[a + 9], 4, 3654602809), m = e(m, k, j, l, f[a + 12], 11, 3873151461), l = e(l, m, k, j, f[a + 15], 16, 530742520), j = e(j, l, m, k, f[a + 2], 23, 3299628645), k = g(k, j, l, m, f[a + 0], 6, 4096336452), m = g(m, k, j, l, f[a + 7], 10, 1126891415), l = g(l, m, k, j, f[a + 14], 15, 2878612391), j = g(j, l, m, k, f[a + 5], 21, 4237533241), k = g(k, j, l, m, f[a + 12], 6, 1700485571), m = g(m, k, j, l, f[a + 3], 10, 2399980690), l = g(l, m, k, j, f[a + 10], 15, 4293915773), j = g(j, l, m, k, f[a + 1], 21, 2240044497), k = g(k, j, l, m, f[a + 8], 6, 1873313359), m = g(m, k, j, l, f[a + 15], 10, 4264355552), l = g(l, m, k, j, f[a + 6], 15, 2734768916), j = g(j, l, m, k, f[a + 13], 21, 1309151649), k = g(k, j, l, m, f[a + 4], 6, 4149444226), m = g(m, k, j, l, f[a + 11], 10, 3174756917), l = g(l, m, k, j, f[a + 2], 15, 718787259), j = g(j, l, m, k, f[a + 9], 21, 3951481745), k = b(k, o), j = b(j, p), l = b(l, q), m = b(m, n);
1370
- return (h(k) + h(j) + h(l) + h(m)).toLowerCase();
1371
- };
1372
- function parseBigInt(a, b) {
1373
- return new BigInteger(a, b);
1374
- }
1375
- function pkcs1pad2(a, b) {
1376
- if (b < a.length + 11) throw "Message too long for RSA (n=" + b + ", l=" + a.length + ")";
1377
- for (var c = [], d = a.length - 1; d >= 0 && b > 0;) {
1378
- var e = a.charCodeAt(d--);
1379
- e < 128 ? c[--b] = e : e > 127 && e < 2048 ? (c[--b] = e & 63 | 128, c[--b] = e >> 6 | 192) : (c[--b] = e & 63 | 128, c[--b] = e >> 6 & 63 | 128, c[--b] = e >> 12 | 224);
1380
- }
1381
- c[--b] = 0;
1382
- d = new SecureRandom();
1383
- for (e = []; b > 2;) {
1384
- for (e[0] = 0; e[0] == 0;) d.nextBytes(e);
1385
- c[--b] = e[0];
1386
- }
1387
- c[--b] = 2;
1388
- c[--b] = 0;
1389
- return new BigInteger(c);
1390
- }
1391
- function RSAKey() {
1392
- this.n = null;
1393
- this.e = 0;
1394
- this.coeff = this.dmq1 = this.dmp1 = this.q = this.p = this.d = null;
1395
- }
1396
- function RSASetPublic(a, b) {
1397
- a != null && b != null && a.length > 0 && b.length > 0 ? (this.n = parseBigInt(a, 16), this.e = parseInt(b, 16)) : alert("Invalid RSA public key");
1398
- }
1399
- function RSADoPublic(a) {
1400
- return a.modPowInt(this.e, this.n);
1401
- }
1402
- function RSAEncrypt(a) {
1403
- a = pkcs1pad2(a, this.n.bitLength() + 7 >> 3);
1404
- if (a == null) return null;
1405
- a = this.doPublic(a);
1406
- if (a == null) return null;
1407
- a = a.toString(16);
1408
- return (a.length & 1) == 0 ? a : "0" + a;
1409
- }
1410
- RSAKey.prototype.doPublic = RSADoPublic;
1411
- RSAKey.prototype.setPublic = RSASetPublic;
1412
- RSAKey.prototype.encrypt = RSAEncrypt;
1413
- function pkcs1unpad2(a, b) {
1414
- for (var c = a.toByteArray(), d = 0; d < c.length && c[d] == 0;) ++d;
1415
- if (c.length - d != b - 1 || c[d] != 2) return null;
1416
- for (++d; c[d] != 0;) if (++d >= c.length) return null;
1417
- for (var e = ""; ++d < c.length;) {
1418
- var g = c[d] & 255;
1419
- g < 128 ? e += String.fromCharCode(g) : g > 191 && g < 224 ? (e += String.fromCharCode((g & 31) << 6 | c[d + 1] & 63), ++d) : (e += String.fromCharCode((g & 15) << 12 | (c[d + 1] & 63) << 6 | c[d + 2] & 63), d += 2);
1420
- }
1421
- return e;
1422
- }
1423
- function RSASetPrivate(a, b, c) {
1424
- a != null && b != null && a.length > 0 && b.length > 0 ? (this.n = parseBigInt(a, 16), this.e = parseInt(b, 16), this.d = parseBigInt(c, 16)) : alert("Invalid RSA private key");
1425
- }
1426
- function RSASetPrivateEx(a, b, c, d, e, g, h, f) {
1427
- a != null && b != null && a.length > 0 && b.length > 0 ? (this.n = parseBigInt(a, 16), this.e = parseInt(b, 16), this.d = parseBigInt(c, 16), this.p = parseBigInt(d, 16), this.q = parseBigInt(e, 16), this.dmp1 = parseBigInt(g, 16), this.dmq1 = parseBigInt(h, 16), this.coeff = parseBigInt(f, 16)) : alert("Invalid RSA private key");
1428
- }
1429
- function RSAGenerate(a, b) {
1430
- var c = new SeededRandom(),
1431
- d = a >> 1;
1432
- this.e = parseInt(b, 16);
1433
- for (var e = new BigInteger(b, 16);;) {
1434
- for (;;) if (this.p = new BigInteger(a - d, 1, c), this.p.subtract(BigInteger.ONE).gcd(e).compareTo(BigInteger.ONE) == 0 && this.p.isProbablePrime(10)) break;
1435
- for (;;) if (this.q = new BigInteger(d, 1, c), this.q.subtract(BigInteger.ONE).gcd(e).compareTo(BigInteger.ONE) == 0 && this.q.isProbablePrime(10)) break;
1436
- if (this.p.compareTo(this.q) <= 0) {
1437
- var g = this.p;
1438
- this.p = this.q;
1439
- this.q = g;
1440
- }
1441
- var g = this.p.subtract(BigInteger.ONE),
1442
- h = this.q.subtract(BigInteger.ONE),
1443
- f = g.multiply(h);
1444
- if (f.gcd(e).compareTo(BigInteger.ONE) == 0) {
1445
- this.n = this.p.multiply(this.q);
1446
- this.d = e.modInverse(f);
1447
- this.dmp1 = this.d.mod(g);
1448
- this.dmq1 = this.d.mod(h);
1449
- this.coeff = this.q.modInverse(this.p);
1450
- break;
1451
- }
1452
- }
1453
- }
1454
- function RSADoPrivate(a) {
1455
- if (this.p == null || this.q == null) return a.modPow(this.d, this.n);
1456
- for (var b = a.mod(this.p).modPow(this.dmp1, this.p), a = a.mod(this.q).modPow(this.dmq1, this.q); b.compareTo(a) < 0;) b = b.add(this.p);
1457
- return b.subtract(a).multiply(this.coeff).mod(this.p).multiply(this.q).add(a);
1458
- }
1459
- function RSADecrypt(a) {
1460
- a = this.doPrivate(parseBigInt(a, 16));
1461
- return a == null ? null : pkcs1unpad2(a, this.n.bitLength() + 7 >> 3);
1462
- }
1463
- RSAKey.prototype.doPrivate = RSADoPrivate;
1464
- RSAKey.prototype.setPrivate = RSASetPrivate;
1465
- RSAKey.prototype.setPrivateEx = RSASetPrivateEx;
1466
- RSAKey.prototype.generate = RSAGenerate;
1467
- RSAKey.prototype.decrypt = RSADecrypt;
1468
- var _RSASIGN_DIHEAD = [];
1469
- _RSASIGN_DIHEAD.sha1 = "3021300906052b0e03021a05000414";
1470
- _RSASIGN_DIHEAD.sha256 = "3031300d060960864801650304020105000420";
1471
- var _RSASIGN_HASHHEXFUNC = [];
1472
- _RSASIGN_HASHHEXFUNC.sha1 = sha1.hex;
1473
- _RSASIGN_HASHHEXFUNC.sha256 = sha256.hex;
1474
- function _rsasign_getHexPaddedDigestInfoForString(a, b, c) {
1475
- b /= 4;
1476
- for (var a = (0, _RSASIGN_HASHHEXFUNC[c])(a), c = "00" + _RSASIGN_DIHEAD[c] + a, a = "", b = b - 4 - c.length, d = 0; d < b; d += 2) a += "ff";
1477
- return sPaddedMessageHex = "0001" + a + c;
1478
- }
1479
- function _rsasign_signString(a, b) {
1480
- var c = _rsasign_getHexPaddedDigestInfoForString(a, this.n.bitLength(), b);
1481
- return this.doPrivate(parseBigInt(c, 16)).toString(16);
1482
- }
1483
- function _rsasign_signStringWithSHA1(a) {
1484
- a = _rsasign_getHexPaddedDigestInfoForString(a, this.n.bitLength(), "sha1");
1485
- return this.doPrivate(parseBigInt(a, 16)).toString(16);
1486
- }
1487
- function _rsasign_signStringWithSHA256(a) {
1488
- a = _rsasign_getHexPaddedDigestInfoForString(a, this.n.bitLength(), "sha256");
1489
- return this.doPrivate(parseBigInt(a, 16)).toString(16);
1490
- }
1491
- function _rsasign_getDecryptSignatureBI(a, b, c) {
1492
- var d = new RSAKey();
1493
- d.setPublic(b, c);
1494
- return d.doPublic(a);
1495
- }
1496
- function _rsasign_getHexDigestInfoFromSig(a, b, c) {
1497
- return _rsasign_getDecryptSignatureBI(a, b, c).toString(16).replace(/^1f+00/, "");
1498
- }
1499
- function _rsasign_getAlgNameAndHashFromHexDisgestInfo(a) {
1500
- for (var b in _RSASIGN_DIHEAD) {
1501
- var c = _RSASIGN_DIHEAD[b],
1502
- d = c.length;
1503
- if (a.substring(0, d) == c) return [b, a.substring(d)];
1504
- }
1505
- return [];
1506
- }
1507
- function _rsasign_verifySignatureWithArgs(a, b, c, d) {
1508
- b = _rsasign_getHexDigestInfoFromSig(b, c, d);
1509
- c = _rsasign_getAlgNameAndHashFromHexDisgestInfo(b);
1510
- if (c.length == 0) return !1;
1511
- b = c[1];
1512
- a = (0, _RSASIGN_HASHHEXFUNC[c[0]])(a);
1513
- return b == a;
1514
- }
1515
- function _rsasign_verifyHexSignatureForMessage(a, b) {
1516
- var c = parseBigInt(a, 16);
1517
- return _rsasign_verifySignatureWithArgs(b, c, this.n.toString(16), this.e.toString(16));
1518
- }
1519
- function _rsasign_verifyString(a, b) {
1520
- var b = b.replace(/[ \n]+/g, ""),
1521
- c = this.doPublic(parseBigInt(b, 16)).toString(16).replace(/^1f+00/, ""),
1522
- d = _rsasign_getAlgNameAndHashFromHexDisgestInfo(c);
1523
- if (d.length == 0) return !1;
1524
- c = d[1];
1525
- d = (0, _RSASIGN_HASHHEXFUNC[d[0]])(a);
1526
- return c == d;
1527
- }
1528
- RSAKey.prototype.signString = _rsasign_signString;
1529
- RSAKey.prototype.signStringWithSHA1 = _rsasign_signStringWithSHA1;
1530
- RSAKey.prototype.signStringWithSHA256 = _rsasign_signStringWithSHA256;
1531
- RSAKey.prototype.verifyString = _rsasign_verifyString;
1532
- RSAKey.prototype.verifyHexSignatureForMessage = _rsasign_verifyHexSignatureForMessage;
1533
- var aes = function () {
1534
- var a = {
1535
- Sbox: [99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118, 202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192, 183, 253, 147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113, 216, 49, 21, 4, 199, 35, 195, 24, 150, 5, 154, 7, 18, 128, 226, 235, 39, 178, 117, 9, 131, 44, 26, 27, 110, 90, 160, 82, 59, 214, 179, 41, 227, 47, 132, 83, 209, 0, 237, 32, 252, 177, 91, 106, 203, 190, 57, 74, 76, 88, 207, 208, 239, 170, 251, 67, 77, 51, 133, 69, 249, 2, 127, 80, 60, 159, 168, 81, 163, 64, 143, 146, 157, 56, 245, 188, 182, 218, 33, 16, 255, 243, 210, 205, 12, 19, 236, 95, 151, 68, 23, 196, 167, 126, 61, 100, 93, 25, 115, 96, 129, 79, 220, 34, 42, 144, 136, 70, 238, 184, 20, 222, 94, 11, 219, 224, 50, 58, 10, 73, 6, 36, 92, 194, 211, 172, 98, 145, 149, 228, 121, 231, 200, 55, 109, 141, 213, 78, 169, 108, 86, 244, 234, 101, 122, 174, 8, 186, 120, 37, 46, 28, 166, 180, 198, 232, 221, 116, 31, 75, 189, 139, 138, 112, 62, 181, 102, 72, 3, 246, 14, 97, 53, 87, 185, 134, 193, 29, 158, 225, 248, 152, 17, 105, 217, 142, 148, 155, 30, 135, 233, 206, 85, 40, 223, 140, 161, 137, 13, 191, 230, 66, 104, 65, 153, 45, 15, 176, 84, 187, 22],
1536
- ShiftRowTab: [0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, 1, 6, 11]
1537
- };
1538
- a.Init = function () {
1539
- a.Sbox_Inv = Array(256);
1540
- for (var b = 0; b < 256; b++) a.Sbox_Inv[a.Sbox[b]] = b;
1541
- a.ShiftRowTab_Inv = Array(16);
1542
- for (b = 0; b < 16; b++) a.ShiftRowTab_Inv[a.ShiftRowTab[b]] = b;
1543
- a.xtime = Array(256);
1544
- for (b = 0; b < 128; b++) a.xtime[b] = b << 1, a.xtime[128 + b] = b << 1 ^ 27;
1545
- };
1546
- a.Done = function () {
1547
- delete a.Sbox_Inv;
1548
- delete a.ShiftRowTab_Inv;
1549
- delete a.xtime;
1550
- };
1551
- a.ExpandKey = function (b) {
1552
- var c = b.length,
1553
- d,
1554
- e = 1;
1555
- switch (c) {
1556
- case 16:
1557
- d = 176;
1558
- break;
1559
- case 24:
1560
- d = 208;
1561
- break;
1562
- case 32:
1563
- d = 240;
1564
- break;
1565
- default:
1566
- alert("my.ExpandKey: Only key lengths of 16, 24 or 32 bytes allowed!");
1567
- }
1568
- for (var g = c; g < d; g += 4) {
1569
- var h = b.slice(g - 4, g);
1570
- if (g % c == 0) {
1571
- if (h = [a.Sbox[h[1]] ^ e, a.Sbox[h[2]], a.Sbox[h[3]], a.Sbox[h[0]]], (e <<= 1) >= 256) e ^= 283;
1572
- } else c > 24 && g % c == 16 && (h = [a.Sbox[h[0]], a.Sbox[h[1]], a.Sbox[h[2]], a.Sbox[h[3]]]);
1573
- for (var f = 0; f < 4; f++) b[g + f] = b[g + f - c] ^ h[f];
1574
- }
1575
- };
1576
- a.Encrypt = function (b, c) {
1577
- var d = c.length;
1578
- a.AddRoundKey(b, c.slice(0, 16));
1579
- for (var e = 16; e < d - 16; e += 16) a.SubBytes(b, a.Sbox), a.ShiftRows(b, a.ShiftRowTab), a.MixColumns(b), a.AddRoundKey(b, c.slice(e, e + 16));
1580
- a.SubBytes(b, a.Sbox);
1581
- a.ShiftRows(b, a.ShiftRowTab);
1582
- a.AddRoundKey(b, c.slice(e, d));
1583
- };
1584
- a.Decrypt = function (b, c) {
1585
- var d = c.length;
1586
- a.AddRoundKey(b, c.slice(d - 16, d));
1587
- a.ShiftRows(b, a.ShiftRowTab_Inv);
1588
- a.SubBytes(b, a.Sbox_Inv);
1589
- for (d -= 32; d >= 16; d -= 16) a.AddRoundKey(b, c.slice(d, d + 16)), a.MixColumns_Inv(b), a.ShiftRows(b, a.ShiftRowTab_Inv), a.SubBytes(b, a.Sbox_Inv);
1590
- a.AddRoundKey(b, c.slice(0, 16));
1591
- };
1592
- a.SubBytes = function (a, c) {
1593
- for (var d = 0; d < 16; d++) a[d] = c[a[d]];
1594
- };
1595
- a.AddRoundKey = function (a, c) {
1596
- for (var d = 0; d < 16; d++) a[d] ^= c[d];
1597
- };
1598
- a.ShiftRows = function (a, c) {
1599
- for (var d = [].concat(a), e = 0; e < 16; e++) a[e] = d[c[e]];
1600
- };
1601
- a.MixColumns = function (b) {
1602
- for (var c = 0; c < 16; c += 4) {
1603
- var d = b[c + 0],
1604
- e = b[c + 1],
1605
- g = b[c + 2],
1606
- h = b[c + 3],
1607
- f = d ^ e ^ g ^ h;
1608
- b[c + 0] ^= f ^ a.xtime[d ^ e];
1609
- b[c + 1] ^= f ^ a.xtime[e ^ g];
1610
- b[c + 2] ^= f ^ a.xtime[g ^ h];
1611
- b[c + 3] ^= f ^ a.xtime[h ^ d];
1612
- }
1613
- };
1614
- a.MixColumns_Inv = function (b) {
1615
- for (var c = 0; c < 16; c += 4) {
1616
- var d = b[c + 0],
1617
- e = b[c + 1],
1618
- g = b[c + 2],
1619
- h = b[c + 3],
1620
- f = d ^ e ^ g ^ h,
1621
- o = a.xtime[f],
1622
- p = a.xtime[a.xtime[o ^ d ^ g]] ^ f;
1623
- f ^= a.xtime[a.xtime[o ^ e ^ h]];
1624
- b[c + 0] ^= p ^ a.xtime[d ^ e];
1625
- b[c + 1] ^= f ^ a.xtime[e ^ g];
1626
- b[c + 2] ^= p ^ a.xtime[g ^ h];
1627
- b[c + 3] ^= f ^ a.xtime[h ^ d];
1628
- }
1629
- };
1630
- return a;
1631
- }(),
1632
- cryptico = function () {
1633
- var a = {};
1634
- aes.Init();
1635
- a.b256to64 = function (a) {
1636
- var c,
1637
- d,
1638
- e,
1639
- g = "",
1640
- f = 0,
1641
- o = a.length;
1642
- for (e = 0; e < o; e++) d = a.charCodeAt(e), f == 0 ? (g += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d >> 2 & 63), c = (d & 3) << 4) : f == 1 ? (g += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c | d >> 4 & 15), c = (d & 15) << 2) : f == 2 && (g += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c | d >> 6 & 3), g += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d & 63)), f += 1, f == 3 && (f = 0);
1643
- f > 0 && (g += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c), g += "=");
1644
- f == 1 && (g += "=");
1645
- return g;
1646
- };
1647
- a.b64to256 = function (a) {
1648
- var c,
1649
- d,
1650
- e = "",
1651
- g = 0,
1652
- h = 0,
1653
- f = a.length;
1654
- for (d = 0; d < f; d++) c = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(d)), c >= 0 && (g && (e += String.fromCharCode(h | c >> 6 - g & 255)), g = g + 2 & 7, h = c << g & 255);
1655
- return e;
1656
- };
1657
- a.b16to64 = function (a) {
1658
- var c,
1659
- d,
1660
- e = "";
1661
- a.length % 2 == 1 && (a = "0" + a);
1662
- for (c = 0; c + 3 <= a.length; c += 3) d = parseInt(a.substring(c, c + 3), 16), e += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d >> 6) + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d & 63);
1663
- c + 1 == a.length ? (d = parseInt(a.substring(c, c + 1), 16), e += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d << 2)) : c + 2 == a.length && (d = parseInt(a.substring(c, c + 2), 16), e += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d >> 2) + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt((d & 3) << 4));
1664
- for (; (e.length & 3) > 0;) e += "=";
1665
- return e;
1666
- };
1667
- a.b64to16 = function (a) {
1668
- var c = "",
1669
- d,
1670
- e = 0,
1671
- g;
1672
- for (d = 0; d < a.length; ++d) {
1673
- if (a.charAt(d) == "=") break;
1674
- v = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(d));
1675
- v < 0 || (e == 0 ? (c += int2char(v >> 2), g = v & 3, e = 1) : e == 1 ? (c += int2char(g << 2 | v >> 4), g = v & 15, e = 2) : e == 2 ? (c += int2char(g), c += int2char(v >> 2), g = v & 3, e = 3) : (c += int2char(g << 2 | v >> 4), c += int2char(v & 15), e = 0));
1676
- }
1677
- e == 1 && (c += int2char(g << 2));
1678
- return c;
1679
- };
1680
- a.string2bytes = function (a) {
1681
- for (var c = [], d = 0; d < a.length; d++) c.push(a.charCodeAt(d));
1682
- return c;
1683
- };
1684
- a.bytes2string = function (a) {
1685
- for (var c = "", d = 0; d < a.length; d++) c += String.fromCharCode(a[d]);
1686
- return c;
1687
- };
1688
- a.blockXOR = function (a, c) {
1689
- for (var d = Array(16), e = 0; e < 16; e++) d[e] = a[e] ^ c[e];
1690
- return d;
1691
- };
1692
- a.blockIV = function () {
1693
- var a = new SecureRandom(),
1694
- c = Array(16);
1695
- a.nextBytes(c);
1696
- return c;
1697
- };
1698
- a.pad16 = function (a) {
1699
- var c = a.slice(0),
1700
- d = (16 - a.length % 16) % 16;
1701
- for (i = a.length; i < a.length + d; i++) c.push(0);
1702
- return c;
1703
- };
1704
- a.depad = function (a) {
1705
- for (a = a.slice(0); a[a.length - 1] == 0;) a = a.slice(0, a.length - 1);
1706
- return a;
1707
- };
1708
- a.encryptAESCBC = function (b, c) {
1709
- var d = c.slice(0);
1710
- aes.ExpandKey(d);
1711
- for (var e = a.string2bytes(b), e = a.pad16(e), g = a.blockIV(), h = 0; h < e.length / 16; h++) {
1712
- var f = e.slice(h * 16, h * 16 + 16),
1713
- o = g.slice(h * 16, h * 16 + 16),
1714
- f = a.blockXOR(o, f);
1715
- aes.Encrypt(f, d);
1716
- g = g.concat(f);
1717
- }
1718
- d = a.bytes2string(g);
1719
- return a.b256to64(d);
1720
- };
1721
- a.decryptAESCBC = function (b, c) {
1722
- var d = c.slice(0);
1723
- aes.ExpandKey(d);
1724
- for (var b = a.b64to256(b), e = a.string2bytes(b), g = [], h = 1; h < e.length / 16; h++) {
1725
- var f = e.slice(h * 16, h * 16 + 16),
1726
- o = e.slice((h - 1) * 16, (h - 1) * 16 + 16);
1727
- aes.Decrypt(f, d);
1728
- f = a.blockXOR(o, f);
1729
- g = g.concat(f);
1730
- }
1731
- g = a.depad(g);
1732
- return a.bytes2string(g);
1733
- };
1734
- a.wrap60 = function (a) {
1735
- for (var c = "", d = 0; d < a.length; d++) d % 60 == 0 && d != 0 && (c += "\n"), c += a[d];
1736
- return c;
1737
- };
1738
- a.generateAESKey = function () {
1739
- var a = Array(16);
1740
- new SecureRandom().nextBytes(a);
1741
- return a;
1742
- };
1743
- a.generateRSAKey = function (a, c) {
1744
- Math.seedrandom(sha256.hex(a));
1745
- var d = new RSAKey();
1746
- d.generate(c, "10001");
1747
- return d;
1748
- };
1749
- a.publicKeyString = function (b) {
1750
- return pubkey = b.n.toString(16);
1751
- };
1752
- a.publicKeyID = function (a) {
1753
- return MD5(a);
1754
- };
1755
- a.publicKeyFromString = function (b) {
1756
- var b = b.split("|")[0],
1757
- c = new RSAKey();
1758
- c.setPublic(b, "10001");
1759
- return c;
1760
- };
1761
- a.encrypt = function (b, c, d) {
1762
- var e = "";
1763
- try {
1764
- var h = a.publicKeyFromString(c);
1765
- e += h.encrypt(b) + "?";
1766
- } catch (f) {
1767
- return {
1768
- status: "Invalid public key"
1769
- };
1770
- }
1771
- return {
1772
- status: "success",
1773
- cipher: e
1774
- };
1775
- };
1776
- a.decrypt = function (b, c) {
1777
- var d = b.split("?"),
1778
- e = c.decrypt(d[0]);
1779
- return {
1780
- status: "success",
1781
- plaintext: e,
1782
- signature: "unsigned"
1783
- };
1784
- };
1785
- return a;
1786
- }();
1787
- module.exports = cryptico;
1788
-
1789
- /***/
1790
- }, /* 1 */
1791
- /***/function (module, exports, __webpack_require__) {
1792
- module.exports = __webpack_require__(2);
1793
-
1794
- /***/
1795
- }, /* 2 */
1796
- /***/function (module, __webpack_exports__, __webpack_require__) {
1797
-
1798
- // ESM COMPAT FLAG
1799
- __webpack_require__.r(__webpack_exports__);
1800
-
1801
- // EXPORTS
1802
- __webpack_require__.d(__webpack_exports__, "StreamClient", function () {
1803
- return (/* binding */StreamClient
1804
- );
1805
- });
1806
-
1807
- // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js
1808
- // Unique ID creation requires a high quality random # generator. In the browser we therefore
1809
- // require the crypto API and do not support built-in fallback to lower quality random number
1810
- // generators (like Math.random()).
1811
- var getRandomValues;
1812
- var rnds8 = new Uint8Array(16);
1813
- function rng() {
1814
- // lazy load so that environments that need to polyfill have a chance to do so
1815
- if (!getRandomValues) {
1816
- // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
1817
- // find the complete implementation of crypto (msCrypto) on IE11.
1818
- getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
1819
- if (!getRandomValues) {
1820
- throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
1821
- }
1822
- }
1823
- return getRandomValues(rnds8);
1824
- }
1825
- // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/regex.js
1826
- /* harmony default export */
1827
- var regex = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
1828
- // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/validate.js
1829
-
1830
- function validate(uuid) {
1831
- return typeof uuid === 'string' && regex.test(uuid);
1832
- }
1833
-
1834
- /* harmony default export */
1835
- var esm_browser_validate = validate;
1836
- // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js
1837
-
1838
- /**
1839
- * Convert array of 16 byte values to UUID string format of the form:
1840
- * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
1841
- */
1842
-
1843
- var byteToHex = [];
1844
- for (var stringify_i = 0; stringify_i < 256; ++stringify_i) {
1845
- byteToHex.push((stringify_i + 0x100).toString(16).substr(1));
1846
- }
1847
- function stringify(arr) {
1848
- var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
1849
- // Note: Be careful editing this code! It's been tuned for performance
1850
- // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
1851
- var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
1852
- // of the following:
1853
- // - One or more input array values don't map to a hex octet (leading to
1854
- // "undefined" in the uuid)
1855
- // - Invalid input values for the RFC `version` or `variant` fields
1856
-
1857
- if (!esm_browser_validate(uuid)) {
1858
- throw TypeError('Stringified UUID is invalid');
1859
- }
1860
- return uuid;
1861
- }
1862
-
1863
- /* harmony default export */
1864
- var esm_browser_stringify = stringify;
1865
- // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js
1866
-
1867
- function v4(options, buf, offset) {
1868
- options = options || {};
1869
- var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
1870
-
1871
- rnds[6] = rnds[6] & 0x0f | 0x40;
1872
- rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
1873
-
1874
- if (buf) {
1875
- offset = offset || 0;
1876
- for (var i = 0; i < 16; ++i) {
1877
- buf[offset + i] = rnds[i];
1878
- }
1879
- return buf;
1880
- }
1881
- return esm_browser_stringify(rnds);
1882
- }
1883
-
1884
- /* harmony default export */
1885
- var esm_browser_v4 = v4;
1886
- // CONCATENATED MODULE: ./directDeviceCustom.js
1887
- /**
1888
- * @synopsis 定制设备取流
1889
- *
1890
- * @note [ADD][2017-07-28]新建 by fengzhongjian
1891
- *
1892
- */
1893
- let DirectDeviceCustom = function () {
1894
- class DeviceDirect {
1895
- constructor() {}
1896
- //to do
1897
-
1898
- //创建取流客户端对象
1899
- createClientObject(oWebsocket, szId, iCurChannel, iCurStream) {
1900
- return {
1901
- socket: oWebsocket,
1902
- id: szId,
1903
- iCurChannel: iCurChannel,
1904
- iCurStream: iCurStream,
1905
- resolve: null,
1906
- reject: null
1907
- };
1908
- }
1909
- //零通道预览
1910
- zeroPlayCmd(iCurChannel, iCurStream) {
1911
- let aCmd = [0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, iCurChannel + 1, 0x00, 0x00, 0x00, iCurStream, 0x00, 0x00, 0x04, 0x00];
1912
- return new Uint8Array(aCmd);
1913
- }
1914
- //普通通道预览
1915
- playCmd(iCurChannel, iCurStream) {
1916
- let aCmd = [0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, iCurChannel, 0x00, 0x00, 0x00, iCurStream, 0x00, 0x00, 0x04, 0x00];
1917
- return new Uint8Array(aCmd);
1918
- }
1919
- //回放
1920
- playbackCmd(szStartTime, szStopTime, iCurChannel, iCurStream) {
1921
- let szStartDayMonthYear = szStartTime.split("T")[0];
1922
- let szStartHourMinSec = szStartTime.split("T")[1];
1923
- let szStartYear = "0" + parseInt(szStartDayMonthYear.substring(0, 4), 10).toString(16);
1924
- let iStartMonth = parseInt(szStartDayMonthYear.substring(4, 6), 10);
1925
- let iStartDay = parseInt(szStartDayMonthYear.substring(6), 10);
1926
- let iStartHour = parseInt(szStartHourMinSec.substring(0, 2), 10);
1927
- let iStartMin = parseInt(szStartHourMinSec.substring(2, 4), 10);
1928
- let iStartSec = parseInt(szStartHourMinSec.substring(4, 6), 10);
1929
- let szStopDayMonthYear = szStopTime.split("T")[0];
1930
- let szStopHourMinSec = szStopTime.split("T")[1];
1931
- let szStopYear = "0" + parseInt(szStopDayMonthYear.substring(0, 4), 10).toString(16);
1932
- let iStopMonth = parseInt(szStopDayMonthYear.substring(4, 6), 10);
1933
- //let iStopDay = parseInt(szStopDayMonthYear.substring(6), 10);
1934
- let iStopHour = parseInt(szStopHourMinSec.substring(0, 2), 10);
1935
- let iStopMin = parseInt(szStopHourMinSec.substring(2, 4), 10);
1936
- let iStopSec = parseInt(szStopHourMinSec.substring(4, 6), 10);
1937
- let aCmd = [/*header*/0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*channel*/0x00, 0x00, 0x00, iCurChannel, /*start time*/0x00, 0x00, parseInt(szStartYear.substring(0, 2), 16), parseInt(szStartYear.substring(2, 4), 16), 0x00, 0x00, 0x00, iStartMonth, 0x00, 0x00, 0x00, iStartDay, 0x00, 0x00, 0x00, iStartHour, 0x00, 0x00, 0x00, iStartMin, 0x00, 0x00, 0x00, iStartSec, /*end time*/0x00, 0x00, parseInt(szStopYear.substring(0, 2), 16), parseInt(szStopYear.substring(2, 4), 16), 0x00, 0x00, 0x00, iStopMonth, 0x00, 0x00, 0x00, iStartDay, 0x00, 0x00, 0x00, iStopHour, 0x00, 0x00, 0x00, iStopMin, 0x00, 0x00, 0x00, iStopSec, /*是否抽帧*/0x00, /*是否下载*/0x00, /*录像卷类型 0普通卷,1存档卷*/0x00, /*存档卷号*/0x00, /*存档卷上的录像文件索引*/0x00, 0x00, 0x00, 0x00, /*码流类型 0主码流,1子码流,2三码流*/iCurStream, /*保留字*/0x00, 0x00, 0x00];
1938
- return new Uint8Array(aCmd);
1939
- }
1940
- //回放速率
1941
- playRateCmd(iRate) {
1942
- let szHex = (parseInt(iRate, 10) >>> 0).toString(16).toLocaleUpperCase().toString(16);
1943
- for (let j = szHex.length; j < 8; j++) {
1944
- //对字符串进行补0,筹齐8位
1945
- szHex = "0" + szHex;
1946
- }
1947
- let aRate = [0, 0, 0, 0]; //4字节16机制表示
1948
- for (let j = 0, iLenRate = szHex.length; j < iLenRate; j = j + 2) {
1949
- aRate[Math.floor(j / 2)] = parseInt(szHex.substring(j, j + 2), 16);
1950
- }
1951
- let aCmd = [/*header*/0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, aRate[0], aRate[1], aRate[2], aRate[3]];
1952
- return new Uint8Array(aCmd);
1953
- }
1954
- //回放暂停
1955
- pauseCmd() {
1956
- let aCmd = [/*header*/0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
1957
- return new Uint8Array(aCmd);
1958
- }
1959
- //恢复命令
1960
- resumeCmd() {
1961
- let aCmd = [/*header*/0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
1962
- return new Uint8Array(aCmd);
1963
- }
1964
- }
1965
- return DeviceDirect;
1966
- }();
1967
-
1968
- // CONCATENATED MODULE: ./directDevice.js
1969
- /**
1970
- * @synopsis 直连设备取流
1971
- *
1972
- * @note [ADD][2017-07-28]新建 by fengzhongjian
1973
- *
1974
- */
1975
- const ERROR_STREAM_UNKNOWN = 3001; //未知取流错误
1976
- const ERROR_STREAM_LIMIT = 3002; //资源上限
1977
- const ERROR_BAD_AUTH = 3003; //认证失败
1978
-
1979
- let DirectDevice = function () {
1980
- class DeviceDirect {
1981
- constructor() {}
1982
- //to do
1983
-
1984
- //创建取流客户端对象
1985
- createClientObject(oWebsocket, szId, szPlayURL) {
1986
- return {
1987
- socket: oWebsocket,
1988
- id: szId,
1989
- playURL: szPlayURL,
1990
- resolve: null,
1991
- reject: null
1992
- };
1993
- }
1994
- //从sdp信息获取媒体头
1995
- getMediaFromSdp(szSdp) {
1996
- let iMediaIndex = szSdp.indexOf("MEDIAINFO=") + 10;
1997
- let szMediaInfo = szSdp.slice(iMediaIndex, iMediaIndex + 80);
1998
- let aMediaInfo = [];
1999
- for (let i = 0, iLen = szMediaInfo.length / 2; i < iLen; i++) {
2000
- aMediaInfo[i] = parseInt(szMediaInfo.slice(i * 2, i * 2 + 2), 16);
2001
- }
2002
- return new Uint8Array(aMediaInfo);
2003
- }
2004
- //普通通道预览
2005
- playCmd(szPlayURL) {
2006
- let oCmd = {
2007
- sequence: 0,
2008
- cmd: 'realplay',
2009
- url: szPlayURL
2010
- };
2011
- return JSON.stringify(oCmd);
2012
- }
2013
- //回放
2014
- playbackCmd(szStartTime, szStopTime, szPlayURL) {
2015
- let oCmd = {
2016
- sequence: 0,
2017
- cmd: 'playback',
2018
- url: szPlayURL,
2019
- startTime: szStartTime,
2020
- endTime: szStopTime
2021
- };
2022
- return JSON.stringify(oCmd);
2023
- }
2024
- //回放速率
2025
- playRateCmd(iRate) {
2026
- let oCmd = {
2027
- sequence: 0,
2028
- cmd: "changespeed",
2029
- speed: iRate
2030
- };
2031
- return JSON.stringify(oCmd);
2032
- }
2033
- //回放暂停
2034
- pauseCmd() {
2035
- let oCmd = {
2036
- sequence: 0,
2037
- cmd: "pause"
2038
- };
2039
- return JSON.stringify(oCmd);
2040
- }
2041
- //恢复命令
2042
- resumeCmd() {
2043
- let oCmd = {
2044
- sequence: 0,
2045
- cmd: "resume"
2046
- };
2047
- return JSON.stringify(oCmd);
2048
- }
2049
- //获取取流错误
2050
- getError(oError) {
2051
- let iErrorNum = ERROR_STREAM_UNKNOWN;
2052
- if (oError) {
2053
- if (parseInt(oError.statusCode, 10) === 6 && oError.subStatusCode === "streamLimit") {
2054
- iErrorNum = ERROR_STREAM_LIMIT;
2055
- } else if (parseInt(oError.statusCode, 10) === 4 && oError.subStatusCode === "badAuthorization") {
2056
- iErrorNum = ERROR_BAD_AUTH;
2057
- }
2058
- }
2059
- return {
2060
- iErrorNum: iErrorNum,
2061
- oError: oError
2062
- };
2063
- }
2064
- }
2065
- return DeviceDirect;
2066
- }();
2067
-
2068
- // EXTERNAL MODULE: ./tool/cryptico.js
2069
- var cryptico = __webpack_require__(0);
2070
- var cryptico_default = /*#__PURE__*/__webpack_require__.n(cryptico);
2071
-
2072
- // CONCATENATED MODULE: ./tool/aes.js
2073
- /*
2074
- CryptoJS v3.1.2
2075
- code.google.com/p/crypto-js
2076
- (c) 2009-2013 by Jeff Mott. All rights reserved.
2077
- code.google.com/p/crypto-js/wiki/License
2078
- */
2079
- var CryptoJS = CryptoJS || function (u, p) {
2080
- var d = {},
2081
- l = d.lib = {},
2082
- s = function () {},
2083
- t = l.Base = {
2084
- extend: function (a) {
2085
- s.prototype = this;
2086
- var c = new s();
2087
- a && c.mixIn(a);
2088
- c.hasOwnProperty("init") || (c.init = function () {
2089
- c.$super.init.apply(this, arguments);
2090
- });
2091
- c.init.prototype = c;
2092
- c.$super = this;
2093
- return c;
2094
- },
2095
- create: function () {
2096
- var a = this.extend();
2097
- a.init.apply(a, arguments);
2098
- return a;
2099
- },
2100
- init: function () {},
2101
- mixIn: function (a) {
2102
- for (var c in a) a.hasOwnProperty(c) && (this[c] = a[c]);
2103
- a.hasOwnProperty("toString") && (this.toString = a.toString);
2104
- },
2105
- clone: function () {
2106
- return this.init.prototype.extend(this);
2107
- }
2108
- },
2109
- r = l.WordArray = t.extend({
2110
- init: function (a, c) {
2111
- a = this.words = a || [];
2112
- this.sigBytes = c != p ? c : 4 * a.length;
2113
- },
2114
- toString: function (a) {
2115
- return (a || v).stringify(this);
2116
- },
2117
- concat: function (a) {
2118
- var c = this.words,
2119
- e = a.words,
2120
- j = this.sigBytes;
2121
- a = a.sigBytes;
2122
- this.clamp();
2123
- if (j % 4) for (var k = 0; k < a; k++) c[j + k >>> 2] |= (e[k >>> 2] >>> 24 - 8 * (k % 4) & 255) << 24 - 8 * ((j + k) % 4);else if (65535 < e.length) for (k = 0; k < a; k += 4) c[j + k >>> 2] = e[k >>> 2];else c.push.apply(c, e);
2124
- this.sigBytes += a;
2125
- return this;
2126
- },
2127
- clamp: function () {
2128
- var a = this.words,
2129
- c = this.sigBytes;
2130
- a[c >>> 2] &= 4294967295 << 32 - 8 * (c % 4);
2131
- a.length = u.ceil(c / 4);
2132
- },
2133
- clone: function () {
2134
- var a = t.clone.call(this);
2135
- a.words = this.words.slice(0);
2136
- return a;
2137
- },
2138
- random: function (a) {
2139
- for (var c = [], e = 0; e < a; e += 4) c.push(4294967296 * u.random() | 0);
2140
- return new r.init(c, a);
2141
- }
2142
- }),
2143
- w = d.enc = {},
2144
- v = w.Hex = {
2145
- stringify: function (a) {
2146
- var c = a.words;
2147
- a = a.sigBytes;
2148
- for (var e = [], j = 0; j < a; j++) {
2149
- var k = c[j >>> 2] >>> 24 - 8 * (j % 4) & 255;
2150
- e.push((k >>> 4).toString(16));
2151
- e.push((k & 15).toString(16));
2152
- }
2153
- return e.join("");
2154
- },
2155
- parse: function (a) {
2156
- for (var c = a.length, e = [], j = 0; j < c; j += 2) e[j >>> 3] |= parseInt(a.substr(j, 2), 16) << 24 - 4 * (j % 8);
2157
- return new r.init(e, c / 2);
2158
- }
2159
- },
2160
- b = w.Latin1 = {
2161
- stringify: function (a) {
2162
- var c = a.words;
2163
- a = a.sigBytes;
2164
- for (var e = [], j = 0; j < a; j++) e.push(String.fromCharCode(c[j >>> 2] >>> 24 - 8 * (j % 4) & 255));
2165
- return e.join("");
2166
- },
2167
- parse: function (a) {
2168
- for (var c = a.length, e = [], j = 0; j < c; j++) e[j >>> 2] |= (a.charCodeAt(j) & 255) << 24 - 8 * (j % 4);
2169
- return new r.init(e, c);
2170
- }
2171
- },
2172
- x = w.Utf8 = {
2173
- stringify: function (a) {
2174
- try {
2175
- return decodeURIComponent(escape(b.stringify(a)));
2176
- } catch (c) {
2177
- throw Error("Malformed UTF-8 data");
2178
- }
2179
- },
2180
- parse: function (a) {
2181
- return b.parse(unescape(encodeURIComponent(a)));
2182
- }
2183
- },
2184
- q = l.BufferedBlockAlgorithm = t.extend({
2185
- reset: function () {
2186
- this._data = new r.init();
2187
- this._nDataBytes = 0;
2188
- },
2189
- _append: function (a) {
2190
- "string" == typeof a && (a = x.parse(a));
2191
- this._data.concat(a);
2192
- this._nDataBytes += a.sigBytes;
2193
- },
2194
- _process: function (a) {
2195
- var c = this._data,
2196
- e = c.words,
2197
- j = c.sigBytes,
2198
- k = this.blockSize,
2199
- b = j / (4 * k),
2200
- b = a ? u.ceil(b) : u.max((b | 0) - this._minBufferSize, 0);
2201
- a = b * k;
2202
- j = u.min(4 * a, j);
2203
- if (a) {
2204
- for (var q = 0; q < a; q += k) this._doProcessBlock(e, q);
2205
- q = e.splice(0, a);
2206
- c.sigBytes -= j;
2207
- }
2208
- return new r.init(q, j);
2209
- },
2210
- clone: function () {
2211
- var a = t.clone.call(this);
2212
- a._data = this._data.clone();
2213
- return a;
2214
- },
2215
- _minBufferSize: 0
2216
- });
2217
- l.Hasher = q.extend({
2218
- cfg: t.extend(),
2219
- init: function (a) {
2220
- this.cfg = this.cfg.extend(a);
2221
- this.reset();
2222
- },
2223
- reset: function () {
2224
- q.reset.call(this);
2225
- this._doReset();
2226
- },
2227
- update: function (a) {
2228
- this._append(a);
2229
- this._process();
2230
- return this;
2231
- },
2232
- finalize: function (a) {
2233
- a && this._append(a);
2234
- return this._doFinalize();
2235
- },
2236
- blockSize: 16,
2237
- _createHelper: function (a) {
2238
- return function (b, e) {
2239
- return new a.init(e).finalize(b);
2240
- };
2241
- },
2242
- _createHmacHelper: function (a) {
2243
- return function (b, e) {
2244
- return new n.HMAC.init(a, e).finalize(b);
2245
- };
2246
- }
2247
- });
2248
- var n = d.algo = {};
2249
- return d;
2250
- }(Math);
2251
- (function () {
2252
- var u = CryptoJS,
2253
- p = u.lib.WordArray;
2254
- u.enc.Base64 = {
2255
- stringify: function (d) {
2256
- var l = d.words,
2257
- p = d.sigBytes,
2258
- t = this._map;
2259
- d.clamp();
2260
- d = [];
2261
- for (var r = 0; r < p; r += 3) for (var w = (l[r >>> 2] >>> 24 - 8 * (r % 4) & 255) << 16 | (l[r + 1 >>> 2] >>> 24 - 8 * ((r + 1) % 4) & 255) << 8 | l[r + 2 >>> 2] >>> 24 - 8 * ((r + 2) % 4) & 255, v = 0; 4 > v && r + 0.75 * v < p; v++) d.push(t.charAt(w >>> 6 * (3 - v) & 63));
2262
- if (l = t.charAt(64)) for (; d.length % 4;) d.push(l);
2263
- return d.join("");
2264
- },
2265
- parse: function (d) {
2266
- var l = d.length,
2267
- s = this._map,
2268
- t = s.charAt(64);
2269
- t && (t = d.indexOf(t), -1 != t && (l = t));
2270
- for (var t = [], r = 0, w = 0; w < l; w++) if (w % 4) {
2271
- var v = s.indexOf(d.charAt(w - 1)) << 2 * (w % 4),
2272
- b = s.indexOf(d.charAt(w)) >>> 6 - 2 * (w % 4);
2273
- t[r >>> 2] |= (v | b) << 24 - 8 * (r % 4);
2274
- r++;
2275
- }
2276
- return p.create(t, r);
2277
- },
2278
- _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
2279
- };
2280
- })();
2281
- (function (u) {
2282
- function p(b, n, a, c, e, j, k) {
2283
- b = b + (n & a | ~n & c) + e + k;
2284
- return (b << j | b >>> 32 - j) + n;
2285
- }
2286
- function d(b, n, a, c, e, j, k) {
2287
- b = b + (n & c | a & ~c) + e + k;
2288
- return (b << j | b >>> 32 - j) + n;
2289
- }
2290
- function l(b, n, a, c, e, j, k) {
2291
- b = b + (n ^ a ^ c) + e + k;
2292
- return (b << j | b >>> 32 - j) + n;
2293
- }
2294
- function s(b, n, a, c, e, j, k) {
2295
- b = b + (a ^ (n | ~c)) + e + k;
2296
- return (b << j | b >>> 32 - j) + n;
2297
- }
2298
- for (var t = CryptoJS, r = t.lib, w = r.WordArray, v = r.Hasher, r = t.algo, b = [], x = 0; 64 > x; x++) b[x] = 4294967296 * u.abs(u.sin(x + 1)) | 0;
2299
- r = r.MD5 = v.extend({
2300
- _doReset: function () {
2301
- this._hash = new w.init([1732584193, 4023233417, 2562383102, 271733878]);
2302
- },
2303
- _doProcessBlock: function (q, n) {
2304
- for (var a = 0; 16 > a; a++) {
2305
- var c = n + a,
2306
- e = q[c];
2307
- q[c] = (e << 8 | e >>> 24) & 16711935 | (e << 24 | e >>> 8) & 4278255360;
2308
- }
2309
- var a = this._hash.words,
2310
- c = q[n + 0],
2311
- e = q[n + 1],
2312
- j = q[n + 2],
2313
- k = q[n + 3],
2314
- z = q[n + 4],
2315
- r = q[n + 5],
2316
- t = q[n + 6],
2317
- w = q[n + 7],
2318
- v = q[n + 8],
2319
- A = q[n + 9],
2320
- B = q[n + 10],
2321
- C = q[n + 11],
2322
- u = q[n + 12],
2323
- D = q[n + 13],
2324
- E = q[n + 14],
2325
- x = q[n + 15],
2326
- f = a[0],
2327
- m = a[1],
2328
- g = a[2],
2329
- h = a[3],
2330
- f = p(f, m, g, h, c, 7, b[0]),
2331
- h = p(h, f, m, g, e, 12, b[1]),
2332
- g = p(g, h, f, m, j, 17, b[2]),
2333
- m = p(m, g, h, f, k, 22, b[3]),
2334
- f = p(f, m, g, h, z, 7, b[4]),
2335
- h = p(h, f, m, g, r, 12, b[5]),
2336
- g = p(g, h, f, m, t, 17, b[6]),
2337
- m = p(m, g, h, f, w, 22, b[7]),
2338
- f = p(f, m, g, h, v, 7, b[8]),
2339
- h = p(h, f, m, g, A, 12, b[9]),
2340
- g = p(g, h, f, m, B, 17, b[10]),
2341
- m = p(m, g, h, f, C, 22, b[11]),
2342
- f = p(f, m, g, h, u, 7, b[12]),
2343
- h = p(h, f, m, g, D, 12, b[13]),
2344
- g = p(g, h, f, m, E, 17, b[14]),
2345
- m = p(m, g, h, f, x, 22, b[15]),
2346
- f = d(f, m, g, h, e, 5, b[16]),
2347
- h = d(h, f, m, g, t, 9, b[17]),
2348
- g = d(g, h, f, m, C, 14, b[18]),
2349
- m = d(m, g, h, f, c, 20, b[19]),
2350
- f = d(f, m, g, h, r, 5, b[20]),
2351
- h = d(h, f, m, g, B, 9, b[21]),
2352
- g = d(g, h, f, m, x, 14, b[22]),
2353
- m = d(m, g, h, f, z, 20, b[23]),
2354
- f = d(f, m, g, h, A, 5, b[24]),
2355
- h = d(h, f, m, g, E, 9, b[25]),
2356
- g = d(g, h, f, m, k, 14, b[26]),
2357
- m = d(m, g, h, f, v, 20, b[27]),
2358
- f = d(f, m, g, h, D, 5, b[28]),
2359
- h = d(h, f, m, g, j, 9, b[29]),
2360
- g = d(g, h, f, m, w, 14, b[30]),
2361
- m = d(m, g, h, f, u, 20, b[31]),
2362
- f = l(f, m, g, h, r, 4, b[32]),
2363
- h = l(h, f, m, g, v, 11, b[33]),
2364
- g = l(g, h, f, m, C, 16, b[34]),
2365
- m = l(m, g, h, f, E, 23, b[35]),
2366
- f = l(f, m, g, h, e, 4, b[36]),
2367
- h = l(h, f, m, g, z, 11, b[37]),
2368
- g = l(g, h, f, m, w, 16, b[38]),
2369
- m = l(m, g, h, f, B, 23, b[39]),
2370
- f = l(f, m, g, h, D, 4, b[40]),
2371
- h = l(h, f, m, g, c, 11, b[41]),
2372
- g = l(g, h, f, m, k, 16, b[42]),
2373
- m = l(m, g, h, f, t, 23, b[43]),
2374
- f = l(f, m, g, h, A, 4, b[44]),
2375
- h = l(h, f, m, g, u, 11, b[45]),
2376
- g = l(g, h, f, m, x, 16, b[46]),
2377
- m = l(m, g, h, f, j, 23, b[47]),
2378
- f = s(f, m, g, h, c, 6, b[48]),
2379
- h = s(h, f, m, g, w, 10, b[49]),
2380
- g = s(g, h, f, m, E, 15, b[50]),
2381
- m = s(m, g, h, f, r, 21, b[51]),
2382
- f = s(f, m, g, h, u, 6, b[52]),
2383
- h = s(h, f, m, g, k, 10, b[53]),
2384
- g = s(g, h, f, m, B, 15, b[54]),
2385
- m = s(m, g, h, f, e, 21, b[55]),
2386
- f = s(f, m, g, h, v, 6, b[56]),
2387
- h = s(h, f, m, g, x, 10, b[57]),
2388
- g = s(g, h, f, m, t, 15, b[58]),
2389
- m = s(m, g, h, f, D, 21, b[59]),
2390
- f = s(f, m, g, h, z, 6, b[60]),
2391
- h = s(h, f, m, g, C, 10, b[61]),
2392
- g = s(g, h, f, m, j, 15, b[62]),
2393
- m = s(m, g, h, f, A, 21, b[63]);
2394
- a[0] = a[0] + f | 0;
2395
- a[1] = a[1] + m | 0;
2396
- a[2] = a[2] + g | 0;
2397
- a[3] = a[3] + h | 0;
2398
- },
2399
- _doFinalize: function () {
2400
- var b = this._data,
2401
- n = b.words,
2402
- a = 8 * this._nDataBytes,
2403
- c = 8 * b.sigBytes;
2404
- n[c >>> 5] |= 128 << 24 - c % 32;
2405
- var e = u.floor(a / 4294967296);
2406
- n[(c + 64 >>> 9 << 4) + 15] = (e << 8 | e >>> 24) & 16711935 | (e << 24 | e >>> 8) & 4278255360;
2407
- n[(c + 64 >>> 9 << 4) + 14] = (a << 8 | a >>> 24) & 16711935 | (a << 24 | a >>> 8) & 4278255360;
2408
- b.sigBytes = 4 * (n.length + 1);
2409
- this._process();
2410
- b = this._hash;
2411
- n = b.words;
2412
- for (a = 0; 4 > a; a++) c = n[a], n[a] = (c << 8 | c >>> 24) & 16711935 | (c << 24 | c >>> 8) & 4278255360;
2413
- return b;
2414
- },
2415
- clone: function () {
2416
- var b = v.clone.call(this);
2417
- b._hash = this._hash.clone();
2418
- return b;
2419
- }
2420
- });
2421
- t.MD5 = v._createHelper(r);
2422
- t.HmacMD5 = v._createHmacHelper(r);
2423
- })(Math);
2424
- (function () {
2425
- var u = CryptoJS,
2426
- p = u.lib,
2427
- d = p.Base,
2428
- l = p.WordArray,
2429
- p = u.algo,
2430
- s = p.EvpKDF = d.extend({
2431
- cfg: d.extend({
2432
- keySize: 4,
2433
- hasher: p.MD5,
2434
- iterations: 1
2435
- }),
2436
- init: function (d) {
2437
- this.cfg = this.cfg.extend(d);
2438
- },
2439
- compute: function (d, r) {
2440
- for (var p = this.cfg, s = p.hasher.create(), b = l.create(), u = b.words, q = p.keySize, p = p.iterations; u.length < q;) {
2441
- n && s.update(n);
2442
- var n = s.update(d).finalize(r);
2443
- s.reset();
2444
- for (var a = 1; a < p; a++) n = s.finalize(n), s.reset();
2445
- b.concat(n);
2446
- }
2447
- b.sigBytes = 4 * q;
2448
- return b;
2449
- }
2450
- });
2451
- u.EvpKDF = function (d, l, p) {
2452
- return s.create(p).compute(d, l);
2453
- };
2454
- })();
2455
- CryptoJS.lib.Cipher || function (u) {
2456
- var p = CryptoJS,
2457
- d = p.lib,
2458
- l = d.Base,
2459
- s = d.WordArray,
2460
- t = d.BufferedBlockAlgorithm,
2461
- r = p.enc.Base64,
2462
- w = p.algo.EvpKDF,
2463
- v = d.Cipher = t.extend({
2464
- cfg: l.extend(),
2465
- createEncryptor: function (e, a) {
2466
- return this.create(this._ENC_XFORM_MODE, e, a);
2467
- },
2468
- createDecryptor: function (e, a) {
2469
- return this.create(this._DEC_XFORM_MODE, e, a);
2470
- },
2471
- init: function (e, a, b) {
2472
- this.cfg = this.cfg.extend(b);
2473
- this._xformMode = e;
2474
- this._key = a;
2475
- this.reset();
2476
- },
2477
- reset: function () {
2478
- t.reset.call(this);
2479
- this._doReset();
2480
- },
2481
- process: function (e) {
2482
- this._append(e);
2483
- return this._process();
2484
- },
2485
- finalize: function (e) {
2486
- e && this._append(e);
2487
- return this._doFinalize();
2488
- },
2489
- keySize: 4,
2490
- ivSize: 4,
2491
- _ENC_XFORM_MODE: 1,
2492
- _DEC_XFORM_MODE: 2,
2493
- _createHelper: function (e) {
2494
- return {
2495
- encrypt: function (b, k, d) {
2496
- return ("string" == typeof k ? c : a).encrypt(e, b, k, d);
2497
- },
2498
- decrypt: function (b, k, d) {
2499
- return ("string" == typeof k ? c : a).decrypt(e, b, k, d);
2500
- }
2501
- };
2502
- }
2503
- });
2504
- d.StreamCipher = v.extend({
2505
- _doFinalize: function () {
2506
- return this._process(!0);
2507
- },
2508
- blockSize: 1
2509
- });
2510
- var b = p.mode = {},
2511
- x = function (e, a, b) {
2512
- var c = this._iv;
2513
- c ? this._iv = u : c = this._prevBlock;
2514
- for (var d = 0; d < b; d++) e[a + d] ^= c[d];
2515
- },
2516
- q = (d.BlockCipherMode = l.extend({
2517
- createEncryptor: function (e, a) {
2518
- return this.Encryptor.create(e, a);
2519
- },
2520
- createDecryptor: function (e, a) {
2521
- return this.Decryptor.create(e, a);
2522
- },
2523
- init: function (e, a) {
2524
- this._cipher = e;
2525
- this._iv = a;
2526
- }
2527
- })).extend();
2528
- q.Encryptor = q.extend({
2529
- processBlock: function (e, a) {
2530
- var b = this._cipher,
2531
- c = b.blockSize;
2532
- x.call(this, e, a, c);
2533
- b.encryptBlock(e, a);
2534
- this._prevBlock = e.slice(a, a + c);
2535
- }
2536
- });
2537
- q.Decryptor = q.extend({
2538
- processBlock: function (e, a) {
2539
- var b = this._cipher,
2540
- c = b.blockSize,
2541
- d = e.slice(a, a + c);
2542
- b.decryptBlock(e, a);
2543
- x.call(this, e, a, c);
2544
- this._prevBlock = d;
2545
- }
2546
- });
2547
- b = b.CBC = q;
2548
- q = (p.pad = {}).Pkcs7 = {
2549
- pad: function (a, b) {
2550
- for (var c = 4 * b, c = c - a.sigBytes % c, d = c << 24 | c << 16 | c << 8 | c, l = [], n = 0; n < c; n += 4) l.push(d);
2551
- c = s.create(l, c);
2552
- a.concat(c);
2553
- },
2554
- unpad: function (a) {
2555
- a.sigBytes -= a.words[a.sigBytes - 1 >>> 2] & 255;
2556
- }
2557
- };
2558
- d.BlockCipher = v.extend({
2559
- cfg: v.cfg.extend({
2560
- mode: b,
2561
- padding: q
2562
- }),
2563
- reset: function () {
2564
- v.reset.call(this);
2565
- var a = this.cfg,
2566
- b = a.iv,
2567
- a = a.mode;
2568
- if (this._xformMode == this._ENC_XFORM_MODE) var c = a.createEncryptor;else c = a.createDecryptor, this._minBufferSize = 1;
2569
- this._mode = c.call(a, this, b && b.words);
2570
- },
2571
- _doProcessBlock: function (a, b) {
2572
- this._mode.processBlock(a, b);
2573
- },
2574
- _doFinalize: function () {
2575
- var a = this.cfg.padding;
2576
- if (this._xformMode == this._ENC_XFORM_MODE) {
2577
- a.pad(this._data, this.blockSize);
2578
- var b = this._process(!0);
2579
- } else b = this._process(!0), a.unpad(b);
2580
- return b;
2581
- },
2582
- blockSize: 4
2583
- });
2584
- var n = d.CipherParams = l.extend({
2585
- init: function (a) {
2586
- this.mixIn(a);
2587
- },
2588
- toString: function (a) {
2589
- return (a || this.formatter).stringify(this);
2590
- }
2591
- }),
2592
- b = (p.format = {}).OpenSSL = {
2593
- stringify: function (a) {
2594
- var b = a.ciphertext;
2595
- a = a.salt;
2596
- return (a ? s.create([1398893684, 1701076831]).concat(a).concat(b) : b).toString(r);
2597
- },
2598
- parse: function (a) {
2599
- a = r.parse(a);
2600
- var b = a.words;
2601
- if (1398893684 == b[0] && 1701076831 == b[1]) {
2602
- var c = s.create(b.slice(2, 4));
2603
- b.splice(0, 4);
2604
- a.sigBytes -= 16;
2605
- }
2606
- return n.create({
2607
- ciphertext: a,
2608
- salt: c
2609
- });
2610
- }
2611
- },
2612
- a = d.SerializableCipher = l.extend({
2613
- cfg: l.extend({
2614
- format: b
2615
- }),
2616
- encrypt: function (a, b, c, d) {
2617
- d = this.cfg.extend(d);
2618
- var l = a.createEncryptor(c, d);
2619
- b = l.finalize(b);
2620
- l = l.cfg;
2621
- return n.create({
2622
- ciphertext: b,
2623
- key: c,
2624
- iv: l.iv,
2625
- algorithm: a,
2626
- mode: l.mode,
2627
- padding: l.padding,
2628
- blockSize: a.blockSize,
2629
- formatter: d.format
2630
- });
2631
- },
2632
- decrypt: function (a, b, c, d) {
2633
- d = this.cfg.extend(d);
2634
- b = this._parse(b, d.format);
2635
- return a.createDecryptor(c, d).finalize(b.ciphertext);
2636
- },
2637
- _parse: function (a, b) {
2638
- return "string" == typeof a ? b.parse(a, this) : a;
2639
- }
2640
- }),
2641
- p = (p.kdf = {}).OpenSSL = {
2642
- execute: function (a, b, c, d) {
2643
- d || (d = s.random(8));
2644
- a = w.create({
2645
- keySize: b + c
2646
- }).compute(a, d);
2647
- c = s.create(a.words.slice(b), 4 * c);
2648
- a.sigBytes = 4 * b;
2649
- return n.create({
2650
- key: a,
2651
- iv: c,
2652
- salt: d
2653
- });
2654
- }
2655
- },
2656
- c = d.PasswordBasedCipher = a.extend({
2657
- cfg: a.cfg.extend({
2658
- kdf: p
2659
- }),
2660
- encrypt: function (b, c, d, l) {
2661
- l = this.cfg.extend(l);
2662
- d = l.kdf.execute(d, b.keySize, b.ivSize);
2663
- l.iv = d.iv;
2664
- b = a.encrypt.call(this, b, c, d.key, l);
2665
- b.mixIn(d);
2666
- return b;
2667
- },
2668
- decrypt: function (b, c, d, l) {
2669
- l = this.cfg.extend(l);
2670
- c = this._parse(c, l.format);
2671
- d = l.kdf.execute(d, b.keySize, b.ivSize, c.salt);
2672
- l.iv = d.iv;
2673
- return a.decrypt.call(this, b, c, d.key, l);
2674
- }
2675
- });
2676
- }();
2677
- (function () {
2678
- for (var u = CryptoJS, p = u.lib.BlockCipher, d = u.algo, l = [], s = [], t = [], r = [], w = [], v = [], b = [], x = [], q = [], n = [], a = [], c = 0; 256 > c; c++) a[c] = 128 > c ? c << 1 : c << 1 ^ 283;
2679
- for (var e = 0, j = 0, c = 0; 256 > c; c++) {
2680
- var k = j ^ j << 1 ^ j << 2 ^ j << 3 ^ j << 4,
2681
- k = k >>> 8 ^ k & 255 ^ 99;
2682
- l[e] = k;
2683
- s[k] = e;
2684
- var z = a[e],
2685
- F = a[z],
2686
- G = a[F],
2687
- y = 257 * a[k] ^ 16843008 * k;
2688
- t[e] = y << 24 | y >>> 8;
2689
- r[e] = y << 16 | y >>> 16;
2690
- w[e] = y << 8 | y >>> 24;
2691
- v[e] = y;
2692
- y = 16843009 * G ^ 65537 * F ^ 257 * z ^ 16843008 * e;
2693
- b[k] = y << 24 | y >>> 8;
2694
- x[k] = y << 16 | y >>> 16;
2695
- q[k] = y << 8 | y >>> 24;
2696
- n[k] = y;
2697
- e ? (e = z ^ a[a[a[G ^ z]]], j ^= a[a[j]]) : e = j = 1;
2698
- }
2699
- var H = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54],
2700
- d = d.AES = p.extend({
2701
- _doReset: function () {
2702
- for (var a = this._key, c = a.words, d = a.sigBytes / 4, a = 4 * ((this._nRounds = d + 6) + 1), e = this._keySchedule = [], j = 0; j < a; j++) if (j < d) e[j] = c[j];else {
2703
- var k = e[j - 1];
2704
- j % d ? 6 < d && 4 == j % d && (k = l[k >>> 24] << 24 | l[k >>> 16 & 255] << 16 | l[k >>> 8 & 255] << 8 | l[k & 255]) : (k = k << 8 | k >>> 24, k = l[k >>> 24] << 24 | l[k >>> 16 & 255] << 16 | l[k >>> 8 & 255] << 8 | l[k & 255], k ^= H[j / d | 0] << 24);
2705
- e[j] = e[j - d] ^ k;
2706
- }
2707
- c = this._invKeySchedule = [];
2708
- for (d = 0; d < a; d++) j = a - d, k = d % 4 ? e[j] : e[j - 4], c[d] = 4 > d || 4 >= j ? k : b[l[k >>> 24]] ^ x[l[k >>> 16 & 255]] ^ q[l[k >>> 8 & 255]] ^ n[l[k & 255]];
2709
- },
2710
- encryptBlock: function (a, b) {
2711
- this._doCryptBlock(a, b, this._keySchedule, t, r, w, v, l);
2712
- },
2713
- decryptBlock: function (a, c) {
2714
- var d = a[c + 1];
2715
- a[c + 1] = a[c + 3];
2716
- a[c + 3] = d;
2717
- this._doCryptBlock(a, c, this._invKeySchedule, b, x, q, n, s);
2718
- d = a[c + 1];
2719
- a[c + 1] = a[c + 3];
2720
- a[c + 3] = d;
2721
- },
2722
- _doCryptBlock: function (a, b, c, d, e, j, l, f) {
2723
- for (var m = this._nRounds, g = a[b] ^ c[0], h = a[b + 1] ^ c[1], k = a[b + 2] ^ c[2], n = a[b + 3] ^ c[3], p = 4, r = 1; r < m; r++) var q = d[g >>> 24] ^ e[h >>> 16 & 255] ^ j[k >>> 8 & 255] ^ l[n & 255] ^ c[p++], s = d[h >>> 24] ^ e[k >>> 16 & 255] ^ j[n >>> 8 & 255] ^ l[g & 255] ^ c[p++], t = d[k >>> 24] ^ e[n >>> 16 & 255] ^ j[g >>> 8 & 255] ^ l[h & 255] ^ c[p++], n = d[n >>> 24] ^ e[g >>> 16 & 255] ^ j[h >>> 8 & 255] ^ l[k & 255] ^ c[p++], g = q, h = s, k = t;
2724
- q = (f[g >>> 24] << 24 | f[h >>> 16 & 255] << 16 | f[k >>> 8 & 255] << 8 | f[n & 255]) ^ c[p++];
2725
- s = (f[h >>> 24] << 24 | f[k >>> 16 & 255] << 16 | f[n >>> 8 & 255] << 8 | f[g & 255]) ^ c[p++];
2726
- t = (f[k >>> 24] << 24 | f[n >>> 16 & 255] << 16 | f[g >>> 8 & 255] << 8 | f[h & 255]) ^ c[p++];
2727
- n = (f[n >>> 24] << 24 | f[g >>> 16 & 255] << 16 | f[h >>> 8 & 255] << 8 | f[k & 255]) ^ c[p++];
2728
- a[b] = q;
2729
- a[b + 1] = s;
2730
- a[b + 2] = t;
2731
- a[b + 3] = n;
2732
- },
2733
- keySize: 8
2734
- });
2735
- u.AES = p._createHelper(d);
2736
- })();
2737
- /* harmony default export */
2738
- var aes = CryptoJS;
2739
- // CONCATENATED MODULE: ./liveMedia.js
2740
- /**
2741
- * @synopsis 流媒体取流
2742
- *
2743
- * @note [ADD][2017-07-28]新建 by fengzhongjian
2744
- *
2745
- */
2746
-
2747
- let LiveMedia = function () {
2748
- class MediaLive {
2749
- constructor() {}
2750
- //to do
2751
-
2752
- //创建取流客户端对象
2753
- createClientObject(oWebsocket, szId, szPKD, szRand, oParams) {
2754
- let key = aes.AES.encrypt(new Date().getTime().toString(), aes.enc.Hex.parse("1234567891234567123456789123456712345678912345671234567891234567"), {
2755
- mode: aes.mode.CBC,
2756
- iv: aes.enc.Hex.parse("12345678912345671234567891234567"),
2757
- padding: aes.pad.Pkcs7
2758
- }).ciphertext.toString();
2759
- if (key.length < 64) {
2760
- key = key + key;
2761
- }
2762
- let iv = aes.AES.encrypt(new Date().getTime().toString(), aes.enc.Hex.parse("12345678912345671234567891234567"), {
2763
- mode: aes.mode.CBC,
2764
- iv: aes.enc.Hex.parse("12345678912345671234567891234567"),
2765
- padding: aes.pad.Pkcs7
2766
- }).ciphertext.toString();
2767
- return {
2768
- socket: oWebsocket,
2769
- id: szId,
2770
- PKD: szPKD,
2771
- rand: szRand,
2772
- playURL: oParams.playURL || "",
2773
- auth: oParams.auth || "",
2774
- token: oParams.token || "",
2775
- key: key,
2776
- iv: iv,
2777
- resolve: null,
2778
- reject: null
2779
- };
2780
- }
2781
- //预览命令
2782
- playCmd(oWebsocket) {
2783
- let oCmd = {
2784
- sequence: 0,
2785
- cmd: 'realplay',
2786
- url: oWebsocket.playURL,
2787
- key: cryptico_default.a.encrypt(oWebsocket.iv + ":" + oWebsocket.key, oWebsocket.PKD).cipher.split("?")[0],
2788
- authorization: aes.AES.encrypt(oWebsocket.rand + ":" + oWebsocket.auth, aes.enc.Hex.parse(oWebsocket.key), {
2789
- mode: aes.mode.CBC,
2790
- iv: aes.enc.Hex.parse(oWebsocket.iv),
2791
- padding: aes.pad.Pkcs7
2792
- }).ciphertext.toString(),
2793
- token: aes.AES.encrypt(oWebsocket.token, aes.enc.Hex.parse(oWebsocket.key), {
2794
- mode: aes.mode.CBC,
2795
- iv: aes.enc.Hex.parse(oWebsocket.iv),
2796
- padding: aes.pad.Pkcs7
2797
- }).ciphertext.toString()
2798
- };
2799
- return JSON.stringify(oCmd);
2800
- }
2801
- //回放
2802
- playbackCmd(oWebsocket, szStartTime, szStopTime) {
2803
- let oCmd = {
2804
- sequence: 0,
2805
- cmd: 'playback',
2806
- url: oWebsocket.playURL,
2807
- key: cryptico_default.a.encrypt(oWebsocket.iv + ":" + oWebsocket.key, oWebsocket.PKD).cipher.split("?")[0],
2808
- authorization: aes.AES.encrypt(oWebsocket.rand + ":" + oWebsocket.auth, aes.enc.Hex.parse(oWebsocket.key), {
2809
- mode: aes.mode.CBC,
2810
- iv: aes.enc.Hex.parse(oWebsocket.iv),
2811
- padding: aes.pad.Pkcs7
2812
- }).ciphertext.toString(),
2813
- token: aes.AES.encrypt(oWebsocket.token, aes.enc.Hex.parse(oWebsocket.key), {
2814
- mode: aes.mode.CBC,
2815
- iv: aes.enc.Hex.parse(oWebsocket.iv),
2816
- padding: aes.pad.Pkcs7
2817
- }).ciphertext.toString(),
2818
- startTime: szStartTime,
2819
- endTime: szStopTime
2820
- };
2821
- return JSON.stringify(oCmd);
2822
- }
2823
- //定位回放
2824
- seekCmd(szStartTime, szStopTime) {
2825
- let oCmd = {
2826
- sequence: 0,
2827
- cmd: "seek",
2828
- startTime: szStartTime,
2829
- endTime: szStopTime
2830
- };
2831
- return JSON.stringify(oCmd);
2832
- }
2833
- }
2834
- return MediaLive;
2835
- }();
2836
-
2837
- // CONCATENATED MODULE: ./localService.js
2838
- /**
2839
- * @synopsis 本地服务取流
2840
- *
2841
- * @note [ADD][2017-07-28]新建 by fengzhongjian
2842
- *
2843
- */
2844
- let LocalService = function () {
2845
- class LocalServer {
2846
- constructor() {}
2847
- //to do
2848
-
2849
- //创建取流客户端对象
2850
- createClientObject(oWebsocket, szId, szPlayURL, oParams) {
2851
- return {
2852
- socket: oWebsocket,
2853
- id: szId,
2854
- playURL: szPlayURL,
2855
- deviceSerial: oParams.deviceSerial || "",
2856
- verificationCode: oParams.verificationCode || "",
2857
- resolve: null,
2858
- reject: null
2859
- };
2860
- }
2861
- //普通通道预览
2862
- playCmd(oWebsocket) {
2863
- let oCmd = {
2864
- sequence: 0,
2865
- cmd: 'realplay',
2866
- deviceSerial: oWebsocket.deviceSerial,
2867
- verificationCode: oWebsocket.verificationCode,
2868
- url: oWebsocket.playURL
2869
- };
2870
- return JSON.stringify(oCmd);
2871
- }
2872
- //回放
2873
- playbackCmd(oWebsocket, szStartTime, szStopTime) {
2874
- let oCmd = {
2875
- sequence: 0,
2876
- cmd: 'playback',
2877
- deviceSerial: oWebsocket.deviceSerial,
2878
- verificationCode: oWebsocket.verificationCode,
2879
- url: oWebsocket.playURL,
2880
- startTime: szStartTime,
2881
- endTime: szStopTime
2882
- };
2883
- return JSON.stringify(oCmd);
2884
- }
2885
- }
2886
- return LocalServer;
2887
- }();
2888
-
2889
- // CONCATENATED MODULE: ./streamClient.js
2890
-
2891
- //定制设备直连取流
2892
- //设备直连取流
2893
- //流媒体取流
2894
- //本地服务取流
2895
-
2896
- /**
2897
- * @synopsis 取流类
2898
- *
2899
- * @note [ADD][2017-01-03]新建 by fengzhongjian
2900
- *
2901
- */
2902
- let StreamClient = function () {
2903
- const WEBSOCKET = Symbol("WEBSOCKET");
2904
- const GETINDEX = Symbol("GETINDEX");
2905
- const PROTOCOLVERSION = Symbol("PROTOCOLVERSION");
2906
- const CIPHERSUITES = Symbol("CIPHERSUITES");
2907
- let oDirectDeviceCustom = new DirectDeviceCustom(); //定制设备直连取流
2908
- let oDirectDevice = new DirectDevice(); //设备直连取流
2909
- let oLiveMedia = new LiveMedia(); //流媒体取流
2910
- let oLocalService = new LocalService(); //本地服务取流
2911
-
2912
- class WebsocketClient {
2913
- constructor() {
2914
- this[PROTOCOLVERSION] = "0.1"; //协议版本
2915
- this[CIPHERSUITES] = 0; //秘钥套件
2916
- this[WEBSOCKET] = []; //websocket对象列表
2917
- this.ERRORS = {//错误码
2918
- };
2919
- //openstream后保存当前通道号和当前码流类型
2920
- this[GETINDEX] = function (id) {
2921
- let iIndex = -1;
2922
- for (let i = 0, iLen = this[WEBSOCKET].length; i < iLen; i++) {
2923
- if (this[WEBSOCKET][i].id === id) {
2924
- iIndex = i;
2925
- break;
2926
- }
2927
- }
2928
- return iIndex;
2929
- };
2930
- }
2931
- /**
2932
- * @synopsis 开流, 此时设备的流还没有发出来
2933
- * @param {string} szUrl 取流路径,如ws://hostname:port/channel
2934
- * @param {object} oParams 取流需要涉及的相关参数
2935
- * @param {function} cbMessage 消息回调函数
2936
- * @param {function} cbClose 失败回调
2937
- * @returns {objcet} 返回Promise对象
2938
- */
2939
- openStream(szUrl, oParams, cbMessage, cbClose) {
2940
- let bIpv6 = false;
2941
- if (szUrl.indexOf("[") > -1) {
2942
- bIpv6 = true;
2943
- }
2944
- let that = this;
2945
- let aUrl = szUrl.split("://"); //szUrl格式为ws://ip:port/channel/stream或wss://ip:port/channel/stream
2946
- let szProtocol = aUrl[0];
2947
- let szHostname = "";
2948
- let iPort = 7681;
2949
- let iCurChannel = 1;
2950
- let iCurStream = 0;
2951
- let bWebSocketVideoCtrlProxy = false; //判断是否是开发包代理模式
2952
- if (bIpv6) {
2953
- szHostname = aUrl[1].split("]:")[0] + "]";
2954
- iPort = Math.floor(aUrl[1].split("]:")[1].split("/")[0]);
2955
- iCurChannel = Math.floor(aUrl[1].split("]:")[1].split("/")[1] / 100); //通道号
2956
- iCurStream = Math.floor(aUrl[1].split("]:")[1].split("/")[1] % 100) - 1; //码流类型
2957
- } else {
2958
- szHostname = aUrl[1].split(":")[0];
2959
- iPort = Math.floor(aUrl[1].split(":")[1].split("/")[0]);
2960
- iCurChannel = Math.floor(aUrl[1].split(":")[1].split("/")[1] / 100); //通道号
2961
- iCurStream = Math.floor(aUrl[1].split(":")[1].split("/")[1] % 100) - 1; //码流类型
2962
- let szProxyFlag = aUrl[1].split(":")[1].split("/")[2];
2963
- if (szProxyFlag !== "" && szProxyFlag === "webSocketVideoCtrlProxy") {
2964
- bWebSocketVideoCtrlProxy = true;
2965
- }
2966
- }
2967
- if (iCurChannel === 0) {
2968
- //表示零通道
2969
- iCurStream = 0;
2970
- }
2971
- oParams = oParams || {};
2972
- let szAuthType = "&sessionID=";
2973
- if (oParams.token && !oParams.playURL) {
2974
- //流媒体的token和配套token属性名一样,需要区分
2975
- szAuthType = "&token=";
2976
- }
2977
- let szSessionID = oParams.sessionID || oParams.session || (oParams.playURL ? "" : oParams.token) || "";
2978
- let oWebsocket = new window.WebSocket(szProtocol + "://" + szHostname + ":" + iPort + (oParams.mode ? "/" + oParams.mode : "") + (bWebSocketVideoCtrlProxy ? "/webSocketVideoCtrlProxy" : "") + "?version=" + that[PROTOCOLVERSION] + "&cipherSuites=" + that[CIPHERSUITES] + szAuthType + szSessionID + (oParams.proxy ? "&proxy=" + oParams.proxy : ""));
2979
- oWebsocket.binaryType = "arraybuffer";
2980
- let szId = esm_browser_v4(); //取流uuid,由于区分每条取流连接
2981
- let iDataIndex = -1;
2982
- let promise = new Promise(function (resolve, reject) {
2983
- oWebsocket.onopen = function () {
2984
- if (!oParams.playURL && !oParams.sessionID && !oParams.deviceSerial && !oParams.token) {
2985
- //定制设备取流,open就表示成功,因为没有命令码返回
2986
- that[WEBSOCKET].push(oDirectDeviceCustom.createClientObject(oWebsocket, szId, iCurChannel, iCurStream));
2987
- resolve(szId);
2988
- }
2989
- /*let aTest = [73, 77, 75, 72, 1, 2, 0, 0, 4, 0, 0, 1, 16, 113, 1, 16, 64, 31, 0, 0, 0, 250, 0, 0, 129, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
2990
- cbMessage({
2991
- bHead: true,
2992
- buf: aTest
2993
- });*/ //写死head,本地架websokcet服务时使用
2994
- };
2995
-
2996
- oWebsocket.onmessage = function (e) {
2997
- if (typeof e.data === "string") {
2998
- let oJSON = JSON.parse(e.data);
2999
- let iWebsocketIndex = that[GETINDEX](szId);
3000
- if (oJSON && oJSON.version && oJSON.cipherSuite) {
3001
- //建立websocket连接成功返回
3002
- that[PROTOCOLVERSION] = oJSON.version;
3003
- that[CIPHERSUITES] = parseInt(oJSON.cipherSuite, 10);
3004
- if (oJSON && oJSON.PKD && oJSON.rand) {
3005
- that[WEBSOCKET].push(oLiveMedia.createClientObject(oWebsocket, szId, oJSON.PKD, oJSON.rand, oParams)); //流媒体
3006
- } else {
3007
- let szPlayURL = "live://" + szHostname + ":" + iPort + "/" + iCurChannel + "/" + iCurStream;
3008
- if (that[CIPHERSUITES] === -1) {
3009
- that[WEBSOCKET].push(oLocalService.createClientObject(oWebsocket, szId, szPlayURL, oParams)); //本地服务
3010
- } else {
3011
- that[WEBSOCKET].push(oDirectDevice.createClientObject(oWebsocket, szId, szPlayURL)); //基线设备
3012
- }
3013
- }
3014
-
3015
- resolve(szId);
3016
- return;
3017
- }
3018
- if (oJSON && oJSON.sdp) {
3019
- let aSadpHeadBuf = oDirectDevice.getMediaFromSdp(oJSON.sdp); //获取媒体头
3020
- cbMessage({
3021
- bHead: true,
3022
- buf: aSadpHeadBuf
3023
- });
3024
- }
3025
- if (oJSON && oJSON.cmd) {
3026
- if (oJSON.cmd === "end") {
3027
- cbMessage({
3028
- type: "exception",
3029
- cmd: oJSON.cmd
3030
- }); //回放结束
3031
- }
3032
- }
3033
-
3034
- if (oJSON && oJSON.statusString) {
3035
- if (oJSON.statusString.toLowerCase() === "ok") {
3036
- if (that[WEBSOCKET][iWebsocketIndex].resolve) {
3037
- that[WEBSOCKET][iWebsocketIndex].resolve(oJSON);
3038
- }
3039
- }
3040
- if (oJSON.statusString.toLowerCase() !== "ok") {
3041
- let oError = oDirectDevice.getError(oJSON);
3042
- if (iWebsocketIndex > -1) {
3043
- //建立连接即返回错误,此时iWebsocketIndex为-1
3044
- if (that[WEBSOCKET][iWebsocketIndex].reject) {
3045
- that[WEBSOCKET][iWebsocketIndex].reject(oError);
3046
- }
3047
- } else {
3048
- reject(oError);
3049
- }
3050
- }
3051
- }
3052
- if (oJSON && oJSON.errorCode) {
3053
- //推流异常时返回异常信息
3054
- cbMessage(oJSON);
3055
- }
3056
- } else {
3057
- let dataObj = {};
3058
- let dataBuf = new Uint8Array(e.data);
3059
- iDataIndex++;
3060
- if (dataBuf.byteLength === 64 || dataBuf.byteLength === 40) {
3061
- //媒体头包含在第一个64字节的数据包中
3062
- let iMediaHeadIndex = -1; //回放和预览媒体头位置不一致,需要动态查询媒体头位置
3063
- let iLen = dataBuf.byteLength;
3064
- for (let i = 0; i < iLen; i++) {
3065
- if (dataBuf[i] === 73 && dataBuf[i + 1] === 77 && dataBuf[i + 2] === 75 && dataBuf[i + 3] === 72) {
3066
- iMediaHeadIndex = i;
3067
- break;
3068
- }
3069
- }
3070
- if (iMediaHeadIndex !== -1) {
3071
- let aHeadBuf = dataBuf.slice(iMediaHeadIndex, iMediaHeadIndex + 40);
3072
- dataObj = {
3073
- bHead: true,
3074
- buf: aHeadBuf
3075
- };
3076
- } else {
3077
- dataObj = {
3078
- bHead: false,
3079
- buf: dataBuf
3080
- };
3081
- }
3082
- cbMessage(dataObj);
3083
- } else {
3084
- if (iDataIndex > 0) {
3085
- dataObj = {
3086
- bHead: false,
3087
- buf: dataBuf
3088
- };
3089
- cbMessage(dataObj);
3090
- }
3091
- }
3092
- dataBuf = null;
3093
- dataObj = null;
3094
- e = null;
3095
- }
3096
- };
3097
- oWebsocket.onclose = function () {
3098
- for (let i = 0, iLen = that[WEBSOCKET].length; i < iLen; i++) {
3099
- if (that[WEBSOCKET][i].id === szId) {
3100
- that[WEBSOCKET][i].resolve(); //关闭连接后触发该事件表示关闭成功
3101
- that[WEBSOCKET].splice(i, 1);
3102
- setTimeout(function () {
3103
- cbClose();
3104
- }, 200); //延时触发停止成功回调,保证停止成功
3105
-
3106
- break;
3107
- }
3108
- }
3109
- reject(); //建立websocket连接时就触发onclose
3110
- };
3111
- });
3112
-
3113
- return promise;
3114
- }
3115
- /**
3116
- * @synopsis 开始取流
3117
- *
3118
- * @param {string} id websocket id,在openStream的时候生成
3119
- @param {string} szStartTime 开始时间
3120
- @param {string} szStopTime 结束时间
3121
- * @param {function} cbMessage 码流回调函数
3122
- *
3123
- * @returns {object} 返回Promise对象
3124
- */
3125
- startPlay(id, szStartTime, szStopTime) {
3126
- let that = this;
3127
- let iWebsocketIndex = this[GETINDEX](id);
3128
- if (szStartTime && szStopTime && that[PROTOCOLVERSION] === "0.1") {
3129
- szStartTime = szStartTime.replace(/-/g, "").replace(/:/g, "");
3130
- szStopTime = szStopTime.replace(/-/g, "").replace(/:/g, "");
3131
- }
3132
- let promise = new Promise(function (resolve, reject) {
3133
- if (iWebsocketIndex > -1) {
3134
- that[WEBSOCKET][iWebsocketIndex].resolve = resolve;
3135
- that[WEBSOCKET][iWebsocketIndex].reject = reject;
3136
- let uIntCmd = null;
3137
- if (!szStartTime || !szStopTime) {
3138
- //预览
3139
- if (that[WEBSOCKET][iWebsocketIndex].iCurChannel === 0 && that[PROTOCOLVERSION] === "0.1") {
3140
- //零通道预览
3141
- uIntCmd = oDirectDeviceCustom.zeroPlayCmd(that[WEBSOCKET][iWebsocketIndex].iCurChannel, that[WEBSOCKET][iWebsocketIndex].iCurStream);
3142
- } else {
3143
- //普通预览
3144
- if (that[PROTOCOLVERSION] !== "0.1") {
3145
- if (that[CIPHERSUITES] === 0) {
3146
- uIntCmd = oLiveMedia.playCmd(that[WEBSOCKET][iWebsocketIndex]); //流媒体预览
3147
- } else if (that[CIPHERSUITES] === 1) {
3148
- uIntCmd = oDirectDevice.playCmd(that[WEBSOCKET][iWebsocketIndex].playURL); //基线普通预览
3149
- } else if (that[CIPHERSUITES] === -1) {
3150
- uIntCmd = oLocalService.playCmd(that[WEBSOCKET][iWebsocketIndex]); //本地服务预览
3151
- }
3152
- } else {
3153
- uIntCmd = oDirectDeviceCustom.playCmd(that[WEBSOCKET][iWebsocketIndex].iCurChannel, that[WEBSOCKET][iWebsocketIndex].iCurStream); //定制普通预览
3154
- }
3155
- }
3156
- } else {
3157
- //回放
3158
- if (that[PROTOCOLVERSION] !== "0.1") {
3159
- if (that[CIPHERSUITES] === 0) {
3160
- uIntCmd = oLiveMedia.playbackCmd(that[WEBSOCKET][iWebsocketIndex], szStartTime, szStopTime); //流媒体回放
3161
- } else if (that[CIPHERSUITES] === 1) {
3162
- uIntCmd = oDirectDevice.playbackCmd(szStartTime, szStopTime, that[WEBSOCKET][iWebsocketIndex].playURL); //基线设备回放
3163
- } else if (that[CIPHERSUITES] === -1) {
3164
- uIntCmd = oLocalService.playbackCmd(that[WEBSOCKET][iWebsocketIndex], szStartTime, szStopTime); //本地服务回放
3165
- }
3166
- } else {
3167
- //定制设备回放
3168
- uIntCmd = oDirectDeviceCustom.playbackCmd(szStartTime, szStopTime, that[WEBSOCKET][iWebsocketIndex].iCurChannel, that[WEBSOCKET][iWebsocketIndex].iCurStream);
3169
- }
3170
- }
3171
- that[WEBSOCKET][iWebsocketIndex].socket.send(uIntCmd);
3172
- if (that[PROTOCOLVERSION] === "0.1") {
3173
- //定制协议没有返回码,发送后直接认为发送成功
3174
- resolve();
3175
- }
3176
- } else {
3177
- if (that[PROTOCOLVERSION] === "0.1") {
3178
- //定制协议没有返回码,发送后直接认为发送成功
3179
- reject();
3180
- }
3181
- }
3182
- });
3183
- return promise;
3184
- }
3185
- singleFrame() {}
3186
- //do something
3187
-
3188
- /**
3189
- * @synopsis 设置倍率
3190
- *
3191
- * @param {string} id websocket id在openStream的时候生成
3192
- @param {number} iRate 播放倍率
3193
- *
3194
- * @returns {object} Promise
3195
- */
3196
- setPlayRate(id, iRate) {
3197
- let that = this;
3198
- let promise = new Promise(function (resolve, reject) {
3199
- for (let i = 0, iLen = that[WEBSOCKET].length; i < iLen; i++) {
3200
- if (that[WEBSOCKET][i].id === id) {
3201
- if (that[PROTOCOLVERSION] === "0.1") {
3202
- let uIntCmd = oDirectDeviceCustom.playRateCmd(iRate); //定制协议快慢放
3203
- that[WEBSOCKET][i].socket.send(uIntCmd);
3204
- resolve(); //定制协议没有返回码,发送后直接认为发送成功
3205
- break;
3206
- } else {
3207
- that[WEBSOCKET][i].resolve = resolve;
3208
- that[WEBSOCKET][i].reject = reject;
3209
- let szCmd = oDirectDevice.playRateCmd(iRate); //标准协议快慢放
3210
- that[WEBSOCKET][i].socket.send(szCmd);
3211
- }
3212
- }
3213
- }
3214
- });
3215
- return promise;
3216
- }
3217
- /**
3218
- * @synopsis 定位回放
3219
- *
3220
- * @param {string} id websocket id在openStream的时候生成
3221
- @param {string} szStartTime 开始时间
3222
- @param {string} szStopTime 结束时间
3223
- *
3224
- * @returns {object} Promise
3225
- */
3226
- seek(id, szStartTime, szStopTime) {
3227
- let that = this;
3228
- let promise = new Promise(function (resolve, reject) {
3229
- for (let i = 0, iLen = that[WEBSOCKET].length; i < iLen; i++) {
3230
- if (that[WEBSOCKET][i].id === id) {
3231
- that[WEBSOCKET][i].resolve = resolve;
3232
- that[WEBSOCKET][i].reject = reject;
3233
- let szCmd = oLiveMedia.seekCmd(szStartTime, szStopTime);
3234
- that[WEBSOCKET][i].socket.send(szCmd);
3235
- }
3236
- }
3237
- });
3238
- return promise;
3239
- }
3240
- /**
3241
- * @synopsis 暂停取流
3242
- *
3243
- * @param {string} id websocket id,在openStream的时候生成
3244
- *
3245
- * @returns {object} 返回Promise对象
3246
- */
3247
- pause(id) {
3248
- let that = this;
3249
- let promise = new Promise(function (resolve, reject) {
3250
- for (let i = 0, iLen = that[WEBSOCKET].length; i < iLen; i++) {
3251
- if (that[WEBSOCKET][i].id === id) {
3252
- if (that[PROTOCOLVERSION] === "0.1") {
3253
- let uIntCmd = oDirectDeviceCustom.pauseCmd(); //定制协议暂停
3254
- that[WEBSOCKET][i].socket.send(uIntCmd);
3255
- resolve(); //定制协议没有返回码,发送后直接认为发送成功
3256
- break;
3257
- } else {
3258
- that[WEBSOCKET][i].resolve = resolve;
3259
- that[WEBSOCKET][i].reject = reject;
3260
- let szCmd = oDirectDevice.pauseCmd(); //标准协议暂停
3261
- that[WEBSOCKET][i].socket.send(szCmd);
3262
- }
3263
- }
3264
- }
3265
- });
3266
- return promise;
3267
- }
3268
- /**
3269
- * @synopsis 透传协议
3270
- *
3271
- * @param {string} id websocket id,在openStream的时候生成
3272
- * @param {string} szCmd, 透传的命令码
3273
- *
3274
- * @returns {object} 返回Promise对象
3275
- */
3276
- transmission(id, szCmd) {
3277
- let that = this;
3278
- let promise = new Promise(function (resolve, reject) {
3279
- for (let i = 0, iLen = that[WEBSOCKET].length; i < iLen; i++) {
3280
- if (that[WEBSOCKET][i].id === id) {
3281
- that[WEBSOCKET][i].resolve = resolve;
3282
- that[WEBSOCKET][i].reject = reject;
3283
- that[WEBSOCKET][i].socket.send(szCmd);
3284
- }
3285
- }
3286
- });
3287
- return promise;
3288
- }
3289
- /**
3290
- * @synopsis 恢复取流
3291
- *
3292
- * @param {string} id websocket id,在openStream的时候生成
3293
- *
3294
- * @returns {object} 返回Promise对象
3295
- */
3296
- resume(id) {
3297
- let that = this;
3298
- let promise = new Promise(function (resolve, reject) {
3299
- for (let i = 0, iLen = that[WEBSOCKET].length; i < iLen; i++) {
3300
- if (that[WEBSOCKET][i].id === id) {
3301
- if (that[PROTOCOLVERSION] === "0.1") {
3302
- let uIntCmd = oDirectDeviceCustom.resumeCmd(); //定制协议恢复
3303
- that[WEBSOCKET][i].socket.send(uIntCmd);
3304
- resolve(); //定制协议没有返回码,发送后直接认为发送成功
3305
- break;
3306
- } else {
3307
- that[WEBSOCKET][i].resolve = resolve;
3308
- that[WEBSOCKET][i].reject = reject;
3309
- let szCmd = oDirectDevice.resumeCmd(); //定制协议恢复
3310
- that[WEBSOCKET][i].socket.send(szCmd);
3311
- }
3312
- }
3313
- }
3314
- });
3315
- return promise;
3316
- }
3317
- /**
3318
- * @synopsis 停止取流
3319
- *
3320
- * @param {string} id websocket id,在openStream的时候生成
3321
- *
3322
- * @returns {object} 返回Promise对象
3323
- */
3324
- stop(id) {
3325
- let that = this;
3326
- let promise = new Promise(function (resolve, reject) {
3327
- if (!id) {
3328
- reject();
3329
- } else {
3330
- let iIndex = -1;
3331
- for (let i = 0, iLen = that[WEBSOCKET].length; i < iLen; i++) {
3332
- if (that[WEBSOCKET][i].id === id) {
3333
- iIndex = i;
3334
- that[WEBSOCKET][i].resolve = resolve; //onclose中处理,判断是否停止成功
3335
- that[WEBSOCKET][i].socket.close(1000, "CLOSE");
3336
- break;
3337
- }
3338
- }
3339
- if (iIndex === -1) {
3340
- reject();
3341
- }
3342
- }
3343
- });
3344
- return promise;
3345
- }
3346
- /**
3347
- * @synopsis 停止所有通道取流
3348
- *
3349
- * @returns {object} 返回Promise对象
3350
- */
3351
- stopAll() {
3352
- let that = this;
3353
- let promise = new Promise(function (resolve, reject) {
3354
- for (let i = 0, iLen = that[WEBSOCKET].length; i < iLen; i++) {
3355
- that[WEBSOCKET][i].socket.close(1000, "CLOSE");
3356
- }
3357
- console.log("停止所有流");
3358
- resolve();
3359
- });
3360
- return promise;
3361
- }
3362
- }
3363
- return WebsocketClient;
3364
- }();
3365
-
3366
- /***/
3367
- }
3368
- /******/])
3369
- );
3370
- });
3371
-
3372
- !function (e, t) {
3373
- if ("object" == typeof exports && "object" == typeof module) module.exports = t();else if ("function" == typeof define && define.amd) define([], t);else {
3374
- var n = t();
3375
- for (var r in n) ("object" == typeof exports ? exports : e)[r] = n[r];
3376
- }
3377
- }(window, function () {
3378
- return function (e) {
3379
- var t = {};
3380
- function n(r) {
3381
- if (t[r]) return t[r].exports;
3382
- var a = t[r] = {
3383
- i: r,
3384
- l: !1,
3385
- exports: {}
3386
- };
3387
- return e[r].call(a.exports, a, a.exports, n), a.l = !0, a.exports;
3388
- }
3389
- return n.m = e, n.c = t, n.d = function (e, t, r) {
3390
- n.o(e, t) || Object.defineProperty(e, t, {
3391
- enumerable: !0,
3392
- get: r
3393
- });
3394
- }, n.r = function (e) {
3395
- "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, {
3396
- value: "Module"
3397
- }), Object.defineProperty(e, "__esModule", {
3398
- value: !0
3399
- });
3400
- }, n.t = function (e, t) {
3401
- if (1 & t && (e = n(e)), 8 & t) return e;
3402
- if (4 & t && "object" == typeof e && e && e.__esModule) return e;
3403
- var r = Object.create(null);
3404
- if (n.r(r), Object.defineProperty(r, "default", {
3405
- enumerable: !0,
3406
- value: e
3407
- }), 2 & t && "string" != typeof e) for (var a in e) n.d(r, a, function (t) {
3408
- return e[t];
3409
- }.bind(null, a));
3410
- return r;
3411
- }, n.n = function (e) {
3412
- var t = e && e.__esModule ? function () {
3413
- return e.default;
3414
- } : function () {
3415
- return e;
3416
- };
3417
- return n.d(t, "a", t), t;
3418
- }, n.o = function (e, t) {
3419
- return Object.prototype.hasOwnProperty.call(e, t);
3420
- }, n.p = "", n(n.s = 0);
3421
- }([function (e, t, n) {
3422
-
3423
- var r;
3424
- n.r(t), n.d(t, "StorageManager", function () {
3425
- return y;
3426
- });
3427
- var a = new Uint8Array(16);
3428
- function i() {
3429
- if (!r && !(r = "undefined" != typeof crypto && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || "undefined" != typeof msCrypto && "function" == typeof msCrypto.getRandomValues && msCrypto.getRandomValues.bind(msCrypto))) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
3430
- return r(a);
3431
- }
3432
- var o = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
3433
- for (var s = function (e) {
3434
- return "string" == typeof e && o.test(e);
3435
- }, u = [], f = 0; f < 256; ++f) u.push((f + 256).toString(16).substr(1));
3436
- var l = function (e) {
3437
- var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0,
3438
- n = (u[e[t + 0]] + u[e[t + 1]] + u[e[t + 2]] + u[e[t + 3]] + "-" + u[e[t + 4]] + u[e[t + 5]] + "-" + u[e[t + 6]] + u[e[t + 7]] + "-" + u[e[t + 8]] + u[e[t + 9]] + "-" + u[e[t + 10]] + u[e[t + 11]] + u[e[t + 12]] + u[e[t + 13]] + u[e[t + 14]] + u[e[t + 15]]).toLowerCase();
3439
- if (!s(n)) throw TypeError("Stringified UUID is invalid");
3440
- return n;
3441
- };
3442
- var d = function (e, t, n) {
3443
- var r = (e = e || {}).random || (e.rng || i)();
3444
- if (r[6] = 15 & r[6] | 64, r[8] = 63 & r[8] | 128, t) {
3445
- n = n || 0;
3446
- for (var a = 0; a < 16; ++a) t[n + a] = r[a];
3447
- return t;
3448
- }
3449
- return l(r);
3450
- };
3451
- let c = new class {
3452
- constructor() {
3453
- this._keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
3454
- }
3455
- $(e) {
3456
- var t = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
3457
- n = /^(?:\s*(<[\w\W]+>)[^>]*|.([\w-]*))$/;
3458
- if (t.test(e)) {
3459
- var r = t.exec(e);
3460
- return document.getElementById(r[2]);
3461
- }
3462
- if (n.test(e)) {
3463
- for (var a = n.exec(e), i = document.getElementsByTagName("*"), o = [], s = 0, u = i.length; s < u; s++) i[s].className.match(new RegExp("(\\s|^)" + a[2] + "(\\s|$)")) && o.push(i[s]);
3464
- return o;
3465
- }
3466
- }
3467
- dateFormat(e, t) {
3468
- var n = {
3469
- "M+": e.getMonth() + 1,
3470
- "d+": e.getDate(),
3471
- "h+": e.getHours(),
3472
- "m+": e.getMinutes(),
3473
- "s+": e.getSeconds(),
3474
- "q+": Math.floor((e.getMonth() + 3) / 3),
3475
- S: e.getMilliseconds()
3476
- };
3477
- for (var r in /(y+)/.test(t) && (t = t.replace(RegExp.$1, (e.getFullYear() + "").substr(4 - RegExp.$1.length))), n) new RegExp("(" + r + ")").test(t) && (t = t.replace(RegExp.$1, 1 === RegExp.$1.length ? n[r] : ("00" + n[r]).substr(("" + n[r]).length)));
3478
- return t;
3479
- }
3480
- downloadFile(e, t) {
3481
- let n = e;
3482
- e instanceof Blob || e instanceof File || (n = new Blob([e]));
3483
- var r = window.URL.createObjectURL(n),
3484
- a = window.document.createElement("a");
3485
- a.href = r, a.download = t;
3486
- var i = document.createEvent("MouseEvents");
3487
- i.initEvent("click", !0, !0), a.dispatchEvent(i);
3488
- }
3489
- createxmlDoc() {
3490
- for (var e, t = ["MSXML2.DOMDocument", "MSXML2.DOMDocument.5.0", "MSXML2.DOMDocument.4.0", "MSXML2.DOMDocument.3.0", "Microsoft.XmlDom"], n = 0, r = t.length; n < r; n++) try {
3491
- e = new ActiveXObject(t[n]);
3492
- break;
3493
- } catch (t) {
3494
- e = document.implementation.createDocument("", "", null);
3495
- break;
3496
- }
3497
- return e.async = "false", e;
3498
- }
3499
- parseXmlFromStr(e) {
3500
- if (null === e || "" === e) return null;
3501
- var t = this.createxmlDoc();
3502
- "Netscape" === navigator.appName || "Opera" === navigator.appName ? t = new DOMParser().parseFromString(e, "text/xml") : t.loadXML(e);
3503
- return t;
3504
- }
3505
- encode(e) {
3506
- var t,
3507
- n,
3508
- r,
3509
- a,
3510
- i,
3511
- o,
3512
- s,
3513
- u = "",
3514
- f = 0;
3515
- for (e = this._utf8_encode(e); f < e.length;) a = (t = e.charCodeAt(f++)) >> 2, i = (3 & t) << 4 | (n = e.charCodeAt(f++)) >> 4, o = (15 & n) << 2 | (r = e.charCodeAt(f++)) >> 6, s = 63 & r, isNaN(n) ? o = s = 64 : isNaN(r) && (s = 64), u = u + this._keyStr.charAt(a) + this._keyStr.charAt(i) + this._keyStr.charAt(o) + this._keyStr.charAt(s);
3516
- return u;
3517
- }
3518
- decode(e) {
3519
- var t,
3520
- n,
3521
- r,
3522
- a,
3523
- i,
3524
- o,
3525
- s = "",
3526
- u = 0;
3527
- for (e = e.replace(/[^A-Za-z0-9+/=]/g, ""); u < e.length;) t = this._keyStr.indexOf(e.charAt(u++)) << 2 | (a = this._keyStr.indexOf(e.charAt(u++))) >> 4, n = (15 & a) << 4 | (i = this._keyStr.indexOf(e.charAt(u++))) >> 2, r = (3 & i) << 6 | (o = this._keyStr.indexOf(e.charAt(u++))), s += String.fromCharCode(t), 64 !== i && (s += String.fromCharCode(n)), 64 !== o && (s += String.fromCharCode(r));
3528
- return s = this._utf8_decode(s);
3529
- }
3530
- _utf8_encode(e) {
3531
- e = e.replace(/\r\n/g, "\n");
3532
- for (var t = "", n = 0; n < e.length; n++) {
3533
- var r = e.charCodeAt(n);
3534
- r < 128 ? t += String.fromCharCode(r) : r > 127 && r < 2048 ? (t += String.fromCharCode(r >> 6 | 192), t += String.fromCharCode(63 & r | 128)) : (t += String.fromCharCode(r >> 12 | 224), t += String.fromCharCode(r >> 6 & 63 | 128), t += String.fromCharCode(63 & r | 128));
3535
- }
3536
- return t;
3537
- }
3538
- _utf8_decode(e) {
3539
- for (var t = "", n = 0, r = 0, a = 0; n < e.length;) if ((r = e.charCodeAt(n)) < 128) t += String.fromCharCode(r), n++;else if (r > 191 && r < 224) a = e.charCodeAt(n + 1), t += String.fromCharCode((31 & r) << 6 | 63 & a), n += 2;else {
3540
- a = e.charCodeAt(n + 1);
3541
- var i = e.charCodeAt(n + 2);
3542
- t += String.fromCharCode((15 & r) << 12 | (63 & a) << 6 | 63 & i), n += 3;
3543
- }
3544
- return t;
3545
- }
3546
- isFirefox() {
3547
- var e = !1,
3548
- t = navigator.userAgent.toLowerCase(),
3549
- n = "";
3550
- return t.match(/firefox\/([\d.]+)/) && (n = t.match(/firefox\/([\d.]+)/)[1], parseInt(n.split(".")[0], 10) > -1 && (e = !0)), e;
3551
- }
3552
- isSafari() {
3553
- var e = !1,
3554
- t = navigator.userAgent.toLowerCase(),
3555
- n = "";
3556
- return t.match(/version\/([\d.]+).safari./) && (n = t.match(/version\/([\d.]+).safari./)[1], parseInt(n.split(".")[0], 10) > -1 && (e = !0)), e;
3557
- }
3558
- isEdge() {
3559
- return navigator.userAgent.toLowerCase().indexOf("edge") > -1;
3560
- }
3561
- isIOS() {
3562
- return !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
3563
- }
3564
- }();
3565
- var h = (e = "https://open.ys7.com/assets/ezuikit_v3.6") => `(function() {\n const RECORDRTP = 0; //录制一份未经过转封装的码流原始数据,用于定位问题\n self.Module = { memoryInitializerRequest: loadMemInitFile(), TOTAL_MEMORY: 128*1024*1024 };\n importScripts = (function (globalEval) {\n var xhr = new XMLHttpRequest;\n return function importScripts() {\n var\n args = Array.prototype.slice.call(arguments)\n , len = args.length\n , i = 0\n , meta\n , data\n , content\n ;\n for (; i < len; i++) {\n if (args[i].substr(0, 5).toLowerCase() === "data:") {\n data = args[i];\n content = data.indexOf(",");\n meta = data.substr(5, content).toLowerCase();\n data = decodeURIComponent(data.substr(content + 1));\n if (/;s*base64s*[;,]/.test(meta)) {\n data = atob(data);\n }\n if (/;s*charset=[uU][tT][fF]-?8s*[;,]/.test(meta)) {\n data = decodeURIComponent(escape(data));\n }\n } else {\n xhr.open("GET", args[i], false);\n xhr.send(null);\n data = xhr.responseText;\n }\n globalEval(data);\n }\n };\n }(eval));\n importScripts('${e}/js/transform/SystemTransform.js');\n\n Module.postRun.push(function() {\n postMessage({type: "loaded"});\n });\n\n onmessage = function (e) {\n var data = e.data;\n\n if ("create" === data.type) {\n var iHeadLen = data.len;\n var pHead = Module._malloc(iHeadLen);\n\n var aData = Module.HEAPU8.subarray(pHead, pHead + iHeadLen);\n aData.set(new Uint8Array(data.buf));\n\n var iTransType = data.packType;//目标格式 RTP->PS\n if (RECORDRTP) {\n postMessage({type: "created"});\n postMessage({type: "outputData", buf: data.buf, dType: 1}, [data.buf]);\n } else {\n var iRet = Module._ST_Create(pHead, iHeadLen, iTransType);\n if (iRet != 0) {\n console.log("_ST_Create failed!");\n } else {\n Module._ST_Start();\n postMessage({type: "created"});\n }\n }\n\n } else if ("inputData" === data.type) {\n if (RECORDRTP) {\n var aFileData = new Uint8Array(data.buf); // 拷贝一份\n var iBufferLen = aFileData.length;\n var szBufferLen = iBufferLen.toString(16);\n if (szBufferLen.length === 1) {\n szBufferLen = "000" + szBufferLen;\n } else if (szBufferLen.length === 2) {\n szBufferLen = "00" + szBufferLen;\n } else if (szBufferLen.length === 3) {\n szBufferLen = "0" + szBufferLen;\n }\n var aData = [0, 0, parseInt(szBufferLen.substring(0, 2), 16), parseInt(szBufferLen.substring(2, 4), 16)];\n for(var iIndex = 0, iDataLength = aFileData.length; iIndex < iDataLength; iIndex++) {\n aData[iIndex + 4] = aFileData[iIndex]\n }\n var dataUint8 = new Uint8Array(aData);\n postMessage({type: "outputData", buf: dataUint8.buffer, dType: 2}, [dataUint8.buffer]);\n } else {\n var iDataLen = data.len;\n var pData = Module._malloc(iDataLen);\n\n var aData = Module.HEAPU8.subarray(pData, pData + iDataLen);\n aData.set(new Uint8Array(data.buf));\n\n var iRet = Module._ST_InputData(0, pData, iDataLen);\n if (iRet != 0) {\n //console.log("_ST_InputData failed!");// 一开始会有一些失败,但是不影响后面的文件存储\n }\n\n Module._free(pData);\n }\n } else if ("release" === data.type) {\n Module._ST_Stop();\n Module._ST_Release();\n\n close();\n }\n };\n\n function loadMemInitFile() {\n var req = new XMLHttpRequest();\n req.open('GET', '${e}/js/transform/SystemTransform.js.mem');\n req.responseType = 'arraybuffer';\n req.send();\n\n return req;\n }\n})();`;
3566
- window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem, window.URL = window.URL || window.webkitURL;
3567
- class p {
3568
- constructor(e, t, n, r) {
3569
- this.szUUID = e, this.szFileName = t, this.iStreamType = n, this.szPath = "", this.bStart = !1, this.aStreamList = [], this.options = r;
3570
- }
3571
- init() {
3572
- var e = this;
3573
- 0 === this.iStreamType ? this.szPath = "Web/RecordFiles/" : 1 === this.iStreamType && (this.szPath = "Web/PlaybackFiles/"), this.szPath += this.getDateDir();
3574
- var t = e.szPath.split("/");
3575
- return new Promise(function (n) {
3576
- window.requestFileSystem(window.TEMPORARY, e.options.iFileSize, function (r) {
3577
- e.createDir(r.root, t, function () {
3578
- n();
3579
- });
3580
- }, e.errorHandler);
3581
- });
3582
- }
3583
- getDateDir() {
3584
- return c.dateFormat(new Date(), "yyyy-MM-dd");
3585
- }
3586
- createDir(e, t, n) {
3587
- var r = this;
3588
- t.length ? e.getDirectory(t[0], {
3589
- create: !0
3590
- }, function (e) {
3591
- r.createDir(e, t.slice(1), n);
3592
- }, r.errorHandler) : n();
3593
- }
3594
- errorHandler() {}
3595
- writeFileHeader(e) {
3596
- var t = this;
3597
- window.requestFileSystem(window.TEMPORARY, t.options.iFileSize, function (n) {
3598
- n.root.getFile(t.szPath + "/" + t.szFileName, {
3599
- create: !0
3600
- }, function (n) {
3601
- n.createWriter(function (n) {
3602
- n.onwriteend = function () {
3603
- t.bStart = !0, t.writeFile(n);
3604
- }, n.onerror = function () {}, n.seek(n.length);
3605
- var r = new Blob([e]);
3606
- n.write(r);
3607
- }, t.errorHandler);
3608
- }, t.errorHandler);
3609
- }, t.errorHandler);
3610
- }
3611
- writeFileContent(e) {
3612
- this.aStreamList.push(e);
3613
- }
3614
- writeFile(e) {
3615
- var t = this;
3616
- if (this.bStart) if (this.aStreamList.length > 0) {
3617
- var n = this.aStreamList.shift();
3618
- if (e.seek(e.length), e.length >= this.options.iFileSize) return void (this.options.cbEventHandler && this.options.cbEventHandler(3001, this.szUUID));
3619
- var r = new Blob([n]);
3620
- e.write(r);
3621
- } else setTimeout(function () {
3622
- t.writeFile(e);
3623
- }, 1e3);
3624
- }
3625
- stopWriteFile() {
3626
- var e = this;
3627
- return this.bStart = !1, this.aStreamList.length = 0, new Promise(function (t) {
3628
- window.requestFileSystem(window.TEMPORARY, e.options.iFileSize, function (n) {
3629
- n.root.getFile(e.szPath + "/" + e.szFileName, {
3630
- create: !1
3631
- }, function (e) {
3632
- e.file(function (e) {
3633
- t(), c.downloadFile(e, e.name);
3634
- });
3635
- }, e.errorHandler);
3636
- }, e.errorHandler);
3637
- });
3638
- }
3639
- }
3640
- class m {
3641
- constructor(e, t, n, r, a, i, o, s) {
3642
- this.szBasePath = e, this.szUUID = t, this.szFileName = n, this.aHeadBuf = new Uint8Array(r), this.iPackType = a, this.iStreamType = i, this.oWorker = null, this.oFileSystem = null, this.options = o, this.bHead = !0, this.staticPath = s;
3643
- }
3644
- init() {
3645
- var e = this;
3646
- return new Promise(function (t, n) {
3647
- e.initFileSystem().then(function () {
3648
- e.initWorker().then(function () {
3649
- t(e.szUUID);
3650
- }, function (e) {
3651
- n(e);
3652
- });
3653
- }, function (e) {
3654
- n(e);
3655
- });
3656
- });
3657
- }
3658
- initFileSystem() {
3659
- var e = this;
3660
- return this.oFileSystem = new p(this.szUUID, this.szFileName, this.iStreamType, this.options), new Promise(function (t, n) {
3661
- e.oFileSystem.init().then(function () {
3662
- t();
3663
- }, function (e) {
3664
- n(e);
3665
- });
3666
- });
3667
- }
3668
- initWorker() {
3669
- var e = this;
3670
- return new Promise(function (t) {
3671
- var n = new Blob([h(e.staticPath)]);
3672
- const r = URL.createObjectURL(n);
3673
- e.oWorker = new Worker(r), e.oWorker.onmessage = function (n) {
3674
- var r = n.data;
3675
- let a = e.iPackType;
3676
- if (1 === e.options.iPackage && (a = 12), "loaded" === r.type) e.oWorker.postMessage({
3677
- type: "create",
3678
- buf: e.aHeadBuf.buffer,
3679
- len: 40,
3680
- packType: a
3681
- }, [e.aHeadBuf.buffer]);else if ("created" === r.type) t();else if ("outputData" === r.type) {
3682
- var i = new Uint8Array(r.buf);
3683
- 1 === e.options.iPackage ? e.bHead ? (e.oFileSystem.writeFileHeader(i), e.bHead = !1) : e.oFileSystem.writeFileContent(i) : 1 === r.dType ? e.oFileSystem.writeFileHeader(i) : e.oFileSystem.writeFileContent(i);
3684
- }
3685
- };
3686
- });
3687
- }
3688
- inputData(e) {
3689
- if (this.oWorker) {
3690
- var t = new Uint8Array(e);
3691
- this.oWorker.postMessage({
3692
- type: "inputData",
3693
- buf: t.buffer,
3694
- len: t.length
3695
- }, [t.buffer]);
3696
- }
3697
- }
3698
- stopRecord() {
3699
- var e = this;
3700
- return new Promise(function (t, n) {
3701
- e.oWorker ? e.oWorker.postMessage({
3702
- type: "release"
3703
- }) : n(), e.oFileSystem ? e.oFileSystem.stopWriteFile().then(function () {
3704
- e.bHead = !0, t();
3705
- }, function () {
3706
- n();
3707
- }) : n();
3708
- });
3709
- }
3710
- }
3711
- var g,
3712
- y = (g = Symbol("STORAGELIST"), class {
3713
- constructor(e, t, n) {
3714
- this.szBasePath = e, this[g] = {}, this.options = {
3715
- iFileSize: 1073741824
3716
- }, Object.assign(this.options, t), "string" == typeof t.staticPath && (this.staticPath = t.staticPath);
3717
- }
3718
- startRecord(e, t, n, r, a) {
3719
- var i = this,
3720
- o = d(),
3721
- s = Object.assign({}, this.options, a),
3722
- u = new m(this.szBasePath, o, e, t, n, r, s, this.staticPath);
3723
- return new Promise(function (e, t) {
3724
- u.init().then(function (t) {
3725
- i[g][t] = u, e(t);
3726
- }, function (e) {
3727
- t(e);
3728
- });
3729
- });
3730
- }
3731
- inputData(e, t) {
3732
- var n = this[g][e];
3733
- n && n.inputData(t);
3734
- }
3735
- stopRecord(e) {
3736
- var t = this;
3737
- return new Promise(function (n, r) {
3738
- var a = t[g][e];
3739
- a ? a.stopRecord().then(function () {
3740
- delete t[g][e], n();
3741
- }, function () {
3742
- r();
3743
- }) : r();
3744
- });
3745
- }
3746
- });
3747
- }]);
3748
- });
3749
-
3750
- //const SR_DE_FISH_PLANET = 0x11; ///< 应用于小行星
3751
- //const SR_DE_FISH_ARCSPHERE_HORIZONTAL_WALL = 0x12; ///< 应用于水平壁装弧面鱼眼显示
3752
- //const SR_DE_FISH_ARCSPHERE_VERTICAL_WALL = 0x13; ///< 应用于垂直壁装弧面鱼眼显示
3753
- //const SR_DE_FISH_ANIMATION_SWITCH_CEILING = 0x14; ///< 应用于顶装矫正方式动画切换显示
3754
- //const SR_DE_FISH_ANIMATION_SWITCH_FLOOR = 0x15; ///< 应用于底装矫正方式动画切换显示
3755
- //const SR_DE_PANORAMA_SPHERE = 0x16; ///< 应用于全景球面展示
3756
- //const SR_DE_PANORAMA_PLANET = 0x17; ///< 应用于全景小行星展示
3757
- //宽、高
3758
- var nWidth = 0;
3759
- var nHeight = 0;
3760
- // 录制
3761
- // var aHead = [];
3762
- function downloadFile(oData, szName) {
3763
- console.log("oData", oData);
3764
- let oBlob = oData;
3765
- if (!(oData instanceof Blob || oData instanceof File)) {
3766
- oBlob = new Blob([oData]);
3767
- }
3768
- let szFileUrl = window.URL.createObjectURL(oBlob);
3769
- let oLink = window.document.createElement("a");
3770
- oLink.href = szFileUrl;
3771
- oLink.download = szName;
3772
- let oClick = document.createEvent("MouseEvents");
3773
- oClick.initEvent("click", true, true);
3774
- oLink.dispatchEvent(oClick);
3775
- }
3776
- // 字母字符串转byte数组
3777
- function stringToBytes(str) {
3778
- let ch,
3779
- st,
3780
- re = [];
3781
- for (let i = 0; i < str.length; i++) {
3782
- ch = str.charCodeAt(i); // get char
3783
- st = []; // set up "stack"
3784
- do {
3785
- st.push(ch & 0xFF); // push byte to stack
3786
- ch = ch >> 8; // shift value down by 1 byte
3787
- } while (ch);
3788
- // add stack contents to result
3789
- // done because chars have "wrong" endianness
3790
- re = re.concat(st.reverse());
3791
- }
3792
- // return an array of bytes
3793
- return re;
3794
- }
3795
- class JSPluginV2 {
3796
- constructor(props) {
3797
- this.oStreamClient = new StreamClient();
3798
- this.oStorageManager = new StorageManager("./transform", {
3799
- staticPath: "https://open.ys7.com/assets/ezuikit_v4.0"
3800
- });
3801
- this.aHead = [];
3802
- this.pCanvasData = null;
3803
- this.bPlaySound = -1;
3804
- this.szStorageUUID = '';
3805
- this.szStreamUUID = '';
3806
- this.g_port = 0;
3807
- this.szId = props.szId;
3808
- this.iWidth = props.iWidth;
3809
- this.iHeight = props.iHeight;
3810
- this.iRate = 1;
3811
- this.decoderVersion = '2.0';
3812
- this.staticPath = props.staticPath || "https://open.ys7.com/assets/ezuikit_v5.0";
3813
- this.bPause = false;
3814
- this.bPlay = false;
3815
- this.bInit = false;
3816
- this.portAvailable = true; // 端口可用状态,可以用来判断播放停止状态。
3817
- //this.staticPath = "http://localhost:9090";
3818
- document.getElementById(props.szId).style = `display:inline-block;width:${props.iWidth}px;height:${props.iHeight}px;background:#000000;background-size:100% 100%;vertical-align:top;`;
3819
- this.JS_Init();
3820
- }
3821
- JS_Init() {
3822
- if (window.initIng) {
3823
- //多个实例同时初始化,判断已有实例正在加载
3824
- return;
3825
- }
3826
- window.initIng = true;
3827
- var that = this;
3828
- if (this.bPlay) {
3829
- return false;
3830
- }
3831
- const promise = new Promise((resolve, reject) => {
3832
- if (window.JSPlayerModuleLoaded) {
3833
- // 实例已经加载过,不需要再次加载
3834
- that.bInit = true;
3835
- resolve();
3836
- }
3837
- loadJSByBlobToHeader(`${that.staticPath}/js/Decoder.js`, () => {
3838
- window.JSPlayerModule({
3839
- staticPath: that.staticPath
3840
- }).then(instance => {
3841
- window.Module = instance;
3842
- that.Module = instance;
3843
- that.bInit = true;
3844
- window.JSPlayerModuleLoaded = true;
3845
- resolve();
3846
- });
3847
- }, that.bInit);
3848
- });
3849
- return promise;
3850
- }
3851
- PlayM4_openStream(ng_port, fileHead) {
3852
- var Module = window.Module;
3853
- let pInputData = Module._malloc(40);
3854
- if (pInputData === null) {
3855
- return RETURN_ERROR;
3856
- }
3857
- let inputData = new Uint8Array(fileHead.buffer);
3858
- Module.writeArrayToMemory(inputData, pInputData);
3859
- let resO = Module._JSPlayM4_OpenStream(ng_port, pInputData, 40, 2 * 1024 * 1024);
3860
- inputData = null;
3861
- if (pInputData !== null) {
3862
- Module._free(pInputData);
3863
- pInputData = null;
3864
- }
3865
- console.log("3.打开流 resO:" + resO);
3866
- }
3867
- //执行播放方法
3868
- _doPlay(szUrl, oParams, iWndNum, szStartTime, szStopTime) {
3869
- const Module = window.Module;
3870
- // if(this.bPlay || this.bPlayIng) {
3871
- // return false;
3872
- // }
3873
- this.bPlayIng = true;
3874
- var _this = this;
3875
- _this.playURL = oParams.playURL;
3876
- _this.szUrl = szUrl;
3877
- // 创建canvas
3878
- if (!document.getElementById(_this.szId + '-player')) {
3879
- let canvasList = document.getElementById(_this.szId);
3880
- let canvas = document.createElement('canvas');
3881
- canvasList.appendChild(canvas);
3882
- canvas.width = _this.iWidth;
3883
- canvas.height = _this.iHeight;
3884
- canvas.id = _this.szId + '-player';
3885
- //canvas.style.backgroundColor = '#000000';
3886
- } else {
3887
- let canvasList = document.getElementById(this.szId);
3888
- let oldcanv = document.getElementById(this.szId + '-player');
3889
- // oldcanv.id = this.szId + '-player-tmp';
3890
- oldcanv.style = "position: absolute;";
3891
- canvasList.removeChild(oldcanv);
3892
- let canvas = document.createElement('canvas');
3893
- canvas.width = _this.iWidth;
3894
- canvas.height = _this.iHeight;
3895
- canvas.id = _this.szId + '-player';
3896
- //canvas.style.backgroundColor = '#000000';
3897
- canvasList.appendChild(canvas);
3898
- }
3899
- let promise = new Promise((resolve, reject) => {
3900
- // 先停止所有流
3901
- this.oStreamClient.stopAll();
3902
- //获取端口号
3903
- _this.g_port = Module._JSPlayM4_GetPort();
3904
- console.log("1.获取播放库端口号 g_port:" + _this.g_port);
3905
- // 端口已经使用,设置为不可用状态
3906
- this.portAvailable = false;
3907
-
3908
- //xuehb 开始取流 4
3909
- if (_this.EventCallback && _this.EventCallback.openStreamCallback) {
3910
- console.log('开始取流-----v2');
3911
- _this.EventCallback.openStreamCallback();
3912
- }
3913
- _this.oStreamClient.openStream(szUrl, oParams, data => {
3914
- if (data.errorCode && data.errorCode != '1') {
3915
- //推流异常时触发errorHandler
3916
- if (_this.EventCallback && _this.EventCallback.pluginErrorHandler) {
3917
- _this.EventCallback.pluginErrorHandler(iWndNum, data.errorCode, data);
3918
- }
3919
- }
3920
- if (data.bHead) {
3921
- //判断是否开启预览,用于初始化播放库,回放跳片段是会返回媒体头,不能只判断是否为媒体头
3922
- //xuehb 完成取流返回流头 5
3923
- if (_this.EventCallback && _this.EventCallback.getStreamHeaderCallback) {
3924
- console.log('完成取流返回流头');
3925
- _this.EventCallback.getStreamHeaderCallback();
3926
- }
3927
- _this.PlayM4_openStream(_this.g_port, data.buf);
3928
- _this.aHead = new Uint8Array(data.buf);
3929
- _this.pCanvasData = Module._malloc(128); //通过emscripten分配C/C++中的堆内存
3930
- if (_this.pCanvasData === null) {
3931
- return;
3932
- }
3933
- //let bufData = stringToBytes (`#${this.szId}-player1`);
3934
- let bufData = stringToBytes(`#${_this.szId}-player`);
3935
- ////方法一:
3936
- let aKeyData = Module.HEAPU8.subarray(_this.pCanvasData, _this.pCanvasData + 128); //堆内存绑定到视图对象
3937
- let u8aTemp = new Uint8Array(128);
3938
- aKeyData.set(u8aTemp, 0);
3939
- aKeyData.set(new Uint8Array(bufData)); // 数据写入到emscripten分配的内存中去
3940
- aKeyData = null;
3941
- let resP = Module._JSPlayM4_Play(_this.g_port, _this.pCanvasData); //pCanvasString或pCanvasData
3942
- console.log("4.开始播放 resP:" + resP);
3943
- try {
3944
- const getQueryString = (name, url) => {
3945
- const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
3946
- const r = url.match(reg);
3947
- if (r != null) {
3948
- return unescape(r[2]);
3949
- }
3950
- return null;
3951
- };
3952
- const date = getQueryString('begin', oParams.playURL);
3953
- const year = parseInt(date.slice(0, 4));
3954
- const month = parseInt(date.slice(4, 6));
3955
- const day = parseInt(date.slice(6, 8));
3956
- const hour = parseInt(date.slice(9, 11));
3957
- const min = parseInt(date.slice(11, 13));
3958
- const second = parseInt(date.slice(13, 15)) + 3;
3959
- const setRes = Module._JSPlayM4_SetGlobalBaseTime(_this.g_port, year, month, day, hour, min, second, 0);
3960
- console.log('设置OSD时间: ', _this.g_port, year + ':' + month + ':' + day + ':' + hour + ':' + min + ':' + second + ':' + 0);
3961
- console.log('设置OSD时间res:', setRes);
3962
- } catch (error) {
3963
- console.log('_JSPlayM4_SetGlobalBaseTime:', error);
3964
- }
3965
- _this.bPlay = true;
3966
- _this.bPlayIng = false;
3967
- // 设置一系列回调
3968
- let resFCB = Module._JSPlayM4_SetFrameInfoCallBack(_this.g_port, 1); //帧信息回调
3969
- if (resFCB != 1) {
3970
- let resFrameInfoError = Module._JSPlayM4_GetLastError(_this.g_port);
3971
- console.log("resFrameInfoError:" + resFrameInfoError);
3972
- }
3973
- Module._JSPlayM4_RenderPrivateData(0, 1, 0);
3974
- Module._JSPlayM4_RenderPrivateData(0, 2, 0);
3975
- Module._JSPlayM4_RenderPrivateData(0, 4, 0);
3976
- Module._JSPlayM4_RenderPrivateData(0, 16, 0);
3977
- this.firstFlag = true;
3978
- this.firstGetData = true;
3979
- resolve(resP);
3980
- } else {
3981
- if (this.firstGetData) {
3982
- // 第一次获取数据
3983
- this.firstGetData = false;
3984
-
3985
- //xuehb 返回视频流(首次) 6
3986
- if (_this.EventCallback && _this.EventCallback.getVideoStreamCallback) {
3987
- _this.EventCallback.getVideoStreamCallback();
3988
- }
3989
- }
3990
- if (this.firstFlag) {
3991
- let oFrameInfo = Module._JSPlayM4_GetFrameInfo(this.g_port);
3992
- var nWidth = Module.HEAP32[oFrameInfo + 12 >> 2];
3993
- var nHeight = Module.HEAP32[oFrameInfo + 16 >> 2];
3994
- if (nWidth) {
3995
- //xuehb 首屏展示 7
3996
- if (_this.EventCallback && _this.EventCallback.appearFirstFrameCallback) {
3997
- console.log('出现首帧画面(播放成功)------多线程');
3998
- _this.EventCallback.appearFirstFrameCallback();
3999
- }
4000
- //xuehb 平均成功取流的出流耗时 8
4001
- if (_this.EventCallback && _this.EventCallback.averageStreamSuccessCallback) {
4002
- _this.EventCallback.averageStreamSuccessCallback();
4003
- }
4004
- console.log("首帧展示", nWidth, nHeight);
4005
- this.firstFlag = false;
4006
- if (document.getElementById(this.szId + '-player-tmp')) {
4007
- document.getElementById(this.szId + '-player-tmp').parentNode.removeChild(document.getElementById(this.szId + '-player-tmp'));
4008
- }
4009
- }
4010
- }
4011
- let aBuffer = new Uint8Array(data.buf); //拷贝一份数据进行使
4012
- let pInputData1 = Module._malloc(aBuffer.length);
4013
- if (pInputData1 === null) {
4014
- console.log("inputdata malloc failed!!!");
4015
- return -1;
4016
- }
4017
- Module.writeArrayToMemory(aBuffer, pInputData1);
4018
- // 解密-end
4019
- //console.log("resSetSecretKey:"+resS);
4020
- // 监听数据错误
4021
- if (data.statusString) {
4022
- if (_this.EventCallback && _this.EventCallback.pluginErrorHandler) {
4023
- _this.EventCallback.pluginErrorHandler(_this.g_port, 1001, data);
4024
- }
4025
- } else if (data.type && data.type === "exception") {
4026
- if (_this.EventCallback && _this.EventCallback.pluginErrorHandler) {
4027
- _this.EventCallback.pluginErrorHandler(_this.g_port, 1002, data);
4028
- }
4029
- }
4030
- Module._JSPlayM4_InputData(_this.g_port, pInputData1, aBuffer.length);
4031
- if (pInputData1 !== null) {
4032
- // console.log('释放内存')
4033
- Module._free(pInputData1);
4034
- pInputData1 = null;
4035
- }
4036
- aBuffer = null;
4037
- }
4038
- // 录制
4039
- if (_this.szStorageUUID) {
4040
- _this.oStorageManager.inputData(_this.szStorageUUID, data.buf);
4041
- }
4042
- // data = null;
4043
- }, function () {
4044
- if (_this.bPlay) {
4045
- if (_this.EventCallback && _this.EventCallback.pluginErrorHandler) {
4046
- _this.EventCallback.pluginErrorHandler(iWndNum, 1003);
4047
- }
4048
- }
4049
- _this.bPlayIng = false;
4050
- reject();
4051
- }).then(id => {
4052
- //websocket onopen事件触发
4053
- _this.szStreamUUID = id;
4054
- _this.oStreamClient.startPlay(id).then(() => {
4055
- let resSSOM = Module._JSPlayM4_SetStreamOpenMode(_this.g_port, 1);
4056
- console.log("2.设置流模式 resSSOM:" + resSSOM);
4057
- }).catch(err => {
4058
- console.log("err", err);
4059
- _this._doRelease();
4060
- _this.bPlayIng = false;
4061
- reject(err.oError);
4062
- });
4063
- }, function (oError) {
4064
- //websocekt 未进入onopen
4065
- _this.bPlayIng = false;
4066
- _this._doRelease();
4067
- reject(oError);
4068
- });
4069
- });
4070
- return promise;
4071
- }
4072
- /**
4073
- *
4074
- * @param {*} szUrl "示例:wss://jsdecoder-aeye.hwwt2.com:443"
4075
- * @param {*} oParams "示例: {playURL: "/live?dev=F99467170&chn=9&stream=1&ssn=ot.9oovv27v00lck3ft0krfw61n8ugr4j5b-1ao1cqq1fm-1od8d0d-h1lnhi0w0&auth=1&biz=4&cln=100"}"
4076
- * @param {*} iWndNum
4077
- * @param {*} szStartTime
4078
- * @param {*} szStopTime
4079
- * @returns
4080
- */
4081
- JS_Play(szUrl = "", oParams = {
4082
- playURL: ""
4083
- }, iWndNum, szStartTime, szStopTime) {
4084
- return new Promise((resolve, reject) => {
4085
- let loadWasmTimer = setInterval(() => {
4086
- if (window.JSPlayerModuleLoaded) {
4087
- clearInterval(loadWasmTimer);
4088
- this._doPlay(szUrl, oParams, iWndNum, szStartTime, szStopTime).then(data => {
4089
- resolve(data);
4090
- }).catch(err => {
4091
- reject(err);
4092
- });
4093
- }
4094
- }, 50);
4095
- });
4096
- }
4097
- JS_SetSecretKey(iWndNum, secretKey) {
4098
- const {
4099
- g_port
4100
- } = this;
4101
- const {
4102
- Module
4103
- } = window;
4104
- // 字母字符串转byte数组
4105
- function stringToBytes(str) {
4106
- let ch,
4107
- st,
4108
- re = [];
4109
- for (let i = 0; i < str.length; i++) {
4110
- ch = str.charCodeAt(i); // get char
4111
- st = []; // set up "stack"
4112
- do {
4113
- st.push(ch & 0xFF); // push byte to stack
4114
- ch = ch >> 8; // shift value down by 1 byte
4115
- } while (ch);
4116
- // add stack contents to result
4117
- // done because chars have "wrong" endianness
4118
- re = re.concat(st.reverse());
4119
- }
4120
- // return an array of bytes
4121
- return re;
4122
- }
4123
- let pKeyData = Module._malloc(128);
4124
- if (pKeyData === null) {
4125
- return;
4126
- }
4127
- let bufData = stringToBytes(secretKey);
4128
- let aKeyData = Module.HEAPU8.subarray(pKeyData, pKeyData + 128);
4129
- aKeyData.set(new Uint8Array(bufData));
4130
- let resS = Module._JSPlayM4_SetSecretKey(g_port, 1, pKeyData, 128);
4131
- if (pKeyData !== null) {
4132
- Module._free(pKeyData);
4133
- pKeyData = null;
4134
- }
4135
- console.log("resSetSecretKey:" + resS);
4136
- }
4137
- JS_OpenSound() {
4138
- var {
4139
- Module
4140
- } = window;
4141
- let resPS = Module._JSPlayM4_PlaySound(this.g_port);
4142
- console.log("resPS", resPS);
4143
- if (resPS === 1) {
4144
- this.bPlaySound = 1;
4145
- }
4146
- return resPS;
4147
- }
4148
- JS_CloseSound() {
4149
- var {
4150
- Module
4151
- } = window;
4152
- let resPS = Module._JSPlayM4_StopSound(this.g_port);
4153
- console.log("resPS", resPS);
4154
- if (resPS === 1) {
4155
- this.bPlaySound = -1;
4156
- }
4157
- return resPS;
4158
- }
4159
- JS_StartSave(g_port, fileName = `${new Date().getTime()}`) {
4160
- // this.szStorageUUID = `11111111`;
4161
- this.oStorageManager.startRecord(`${fileName}.mp4`, this.aHead, 2, 0, {
4162
- cbEventHandler: function (iErrorType) {
4163
- console.log("录制错误", iErrorType);
4164
- },
4165
- iPackage: 0
4166
- }).then(szUUID => {
4167
- this.szStorageUUID = szUUID;
4168
- //resolve();
4169
- }, function () {
4170
- //reject();
4171
- });
4172
- }
4173
- JS_StopSave() {
4174
- this.oStorageManager.stopRecord(this.szStorageUUID).then(() => {
4175
- this.szStorageUUID = ""; //关闭录像 删除存储ID
4176
- }, function (iError) {
4177
- console.log("iError", iError);
4178
- });
4179
- }
4180
- _JSPlayM4_GetFrameInfo() {
4181
- const {
4182
- Module
4183
- } = window;
4184
- let oFrameInfo = Module._JSPlayM4_GetFrameInfo(this.g_port);
4185
- Module.HEAP32[oFrameInfo >> 2];
4186
- Module.HEAP32[oFrameInfo + 4 >> 2];
4187
- Module.HEAP32[oFrameInfo + 8 >> 2];
4188
- let width = Module.HEAP32[oFrameInfo + 12 >> 2];
4189
- let height = Module.HEAP32[oFrameInfo + 16 >> 2];
4190
- console.log("width:" + width + ",height:" + height);
4191
- Module.HEAP32[oFrameInfo + 20 >> 2];
4192
- let year = Module.HEAP16[oFrameInfo + 60 >> 1];
4193
- let month = Module.HEAP16[oFrameInfo + 62 >> 1];
4194
- Module.HEAP16[oFrameInfo + 64 >> 1];
4195
- let day = Module.HEAP16[oFrameInfo + 66 >> 1];
4196
- let hour = Module.HEAP16[oFrameInfo + 68 >> 1];
4197
- let minute = Module.HEAP16[oFrameInfo + 70 >> 1];
4198
- let second = Module.HEAP16[oFrameInfo + 72 >> 1];
4199
- let milliseconds = Module.HEAP16[oFrameInfo + 74 >> 1];
4200
- console.log("OSD时间:" + year + "-" + month + "-" + day + "-" + hour + "-" + minute + "-" + second + "-" + milliseconds);
4201
- return {
4202
- width,
4203
- height,
4204
- year,
4205
- month,
4206
- day,
4207
- hour,
4208
- minute,
4209
- second
4210
- };
4211
- }
4212
- JS_SetFrameInfoCallBack(value) {
4213
- const {
4214
- Module
4215
- } = window;
4216
- let resFCB = Module._JSPlayM4_SetFrameInfoCallBack(this.g_port, value); //帧信息回调
4217
- if (resFCB != 1) {
4218
- let resFrameInfoError = Module._JSPlayM4_GetLastError(this.g_port);
4219
- console.log("resFrameInfoError:" + resFrameInfoError);
4220
- }
4221
- console.log("resFCB:" + resFCB);
4222
- }
4223
- JS_CapturePicture(iWind, fileName = `${new Date().getTime()}.jpeg`, type, callback, isDownload) {
4224
- const {
4225
- g_port
4226
- } = this;
4227
- const {
4228
- Module
4229
- } = window;
4230
- //未播放,暂停状态且有缓冲数据
4231
- if (!this.bPlay && this.bPause && this.tmpCapturePictureData) {
4232
- doCapturePicture(this.tmpCapturePictureData);
4233
- return;
4234
- }
4235
- let oFrameInfo = Module._JSPlayM4_GetFrameInfo(g_port);
4236
- Module.HEAP32[oFrameInfo >> 2];
4237
- let width = Module.HEAP32[oFrameInfo + 12 >> 2];
4238
- let height = Module.HEAP32[oFrameInfo + 16 >> 2];
4239
- nWidth = width;
4240
- nHeight = height;
4241
- if (nWidth && nHeight) {
4242
- // 分配Jpeg空间
4243
- let nJpegSize = nWidth * nHeight * 4 + 60;
4244
- let pJpegData = Module._malloc(nJpegSize);
4245
- let pJpegSize = Module._malloc(4);
4246
- if (pJpegData === null) {
4247
- return;
4248
- }
4249
- Module._JSPlayM4_GetJPEG(g_port, pJpegData, nJpegSize, pJpegSize); //buffer,buffer大小,Jpeg大小
4250
- // 获取Jpeg图片大小
4251
- let nJpegDataSize = Module.getValue(pJpegSize, "i32");
4252
- console.log("JPEGSIZE:" + nJpegDataSize);
4253
- // 获取Jpeg图片数据
4254
- let aJpegData = new Uint8Array(nJpegDataSize);
4255
- aJpegData.set(Module.HEAPU8.subarray(pJpegData, pJpegData + nJpegDataSize));
4256
- doCapturePicture(aJpegData);
4257
- aJpegData = null;
4258
- if (pJpegData != null) {
4259
- Module._free(pJpegData);
4260
- pJpegData = null;
4261
- }
4262
- if (pJpegSize != null) {
4263
- Module._free(pJpegSize);
4264
- pJpegSize = null;
4265
- }
4266
- }
4267
- function doCapturePicture(aJpegData) {
4268
- if (fileName.indexOf(".jpeg") === -1) {
4269
- fileName += '.jpeg';
4270
- }
4271
- if (!callback) {
4272
- downloadFile(aJpegData, fileName);
4273
- } else {
4274
- const arrayBufferToBase64Img = buffer => {
4275
- const arr = new Uint8Array(buffer);
4276
- var str = "";
4277
- for (let i = 0; i < arr.length; i++) {
4278
- str += String.fromCharCode(arr[i]);
4279
- }
4280
- return `data:image/jpeg;base64,${window.btoa(str)}`;
4281
- };
4282
- callback({
4283
- fileName: fileName,
4284
- fileUint8Array: aJpegData,
4285
- base64: arrayBufferToBase64Img(aJpegData)
4286
- });
4287
- }
4288
- }
4289
- }
4290
- JS_GetOSDTime() {
4291
- const {
4292
- g_port
4293
- } = this;
4294
- const {
4295
- Module
4296
- } = window;
4297
- const promise = new Promise((resolve, reject) => {
4298
- let oFrameInfo = Module._JSPlayM4_GetFrameInfo(g_port);
4299
- let year = Module.HEAP16[oFrameInfo + 60 >> 1];
4300
- let month = Module.HEAP16[oFrameInfo + 62 >> 1];
4301
- let day = Module.HEAP16[oFrameInfo + 66 >> 1];
4302
- let hour = Module.HEAP16[oFrameInfo + 68 >> 1];
4303
- let minute = Module.HEAP16[oFrameInfo + 70 >> 1];
4304
- let second = Module.HEAP16[oFrameInfo + 72 >> 1];
4305
- var time = new Date(`${year}-${month}-${day} ${hour}:${minute}:${second}`).getTime() / 1000;
4306
- resolve(time);
4307
- });
4308
- return promise;
4309
- }
4310
- JS_Resize(width, height) {
4311
- const {
4312
- g_port
4313
- } = this;
4314
- const {
4315
- Module
4316
- } = window;
4317
- console.log("width:" + width + ",height:" + height);
4318
- let resSet = Module._JSPlayM4_SetCanvasSize(g_port, width, height);
4319
- this.iWidth = width;
4320
- this.iHeight = height;
4321
- document.getElementById(this.szId).style.height = height + "px";
4322
- document.getElementById(this.szId).style.width = width + "px";
4323
- let oldcanv = document.getElementById(this.szId + '-player');
4324
- if (oldcanv) {
4325
- oldcanv.style.height = height + "px";
4326
- oldcanv.style.width = width + "px";
4327
- }
4328
- console.log("resSet:" + resSet);
4329
- }
4330
- _doRelease() {
4331
- const {
4332
- g_port,
4333
- szStreamUUID
4334
- } = this;
4335
- const {
4336
- Module
4337
- } = window;
4338
- let resCS = Module._JSPlayM4_CloseStream(g_port);
4339
- let resFP = Module._JSPlayM4_FreePort(g_port);
4340
- if (resFP === 1) {
4341
- // 端口是否已经被释放,设置为可用状态。
4342
- this.portAvailable = true;
4343
- }
4344
- console.log("doRelease", resCS, resFP);
4345
- if (this.pCanvasData !== null) {
4346
- Module._free(this.pCanvasData);
4347
- this.pCanvasData = null;
4348
- }
4349
- // this.pCanvasString = null;
4350
- // this.pCanvasString = null;
4351
- console.log("stop end");
4352
- this.bPlay = false;
4353
- this.bPlayIng = false;
4354
- }
4355
- JS_Stop() {
4356
- const {
4357
- g_port,
4358
- szStreamUUID
4359
- } = this;
4360
- const {
4361
- Module
4362
- } = window; //销毁canvas资源
4363
-
4364
- let canvasList = document.getElementById(this.szId);
4365
- let oldcanv = document.getElementById(this.szId + '-player');
4366
- if (oldcanv) {
4367
- canvasList.removeChild(oldcanv);
4368
- }
4369
- if (this.szStorageUUID) {
4370
- this.JS_StopSave();
4371
- }
4372
- // 暂停缓存截图数据 start
4373
-
4374
- const callback = data => {
4375
- if (data.fileUint8Array) {
4376
- this.tmpCapturePictureData = data.fileUint8Array;
4377
- }
4378
- };
4379
- const arrayBufferToBase64Img = buffer => {
4380
- const arr = new Uint8Array(buffer);
4381
- var str = "";
4382
- for (let i = 0; i < arr.length; i++) {
4383
- str += String.fromCharCode(arr[i]);
4384
- }
4385
- return `data:image/jpeg;base64,${window.btoa(str)}`;
4386
- };
4387
- this.JS_CapturePicture(0, `${new Date().getTime()}`, "JPEG", callback, true); // 保留最后一帧
4388
- if (this.tmpCapturePictureData && this.tmpCapturePictureData.length > 0) {
4389
- canvasList.style.backgroundImage = `url(${arrayBufferToBase64Img(this.tmpCapturePictureData)})`;
4390
- } // 暂停缓存截图数据 end
4391
-
4392
- const promise = new Promise((resolve, reject) => {
4393
- if (this.portAvailable) {
4394
- // 当前端口可用,不需要执行停止
4395
- console.log("当前端口可用,不需要执行停止");
4396
- return resolve({});
4397
- }
4398
- var stopStreamPromise = this.oStreamClient.stopAll(szStreamUUID);
4399
- stopStreamPromise.then(data => {
4400
- console.log("防抖 停止取流成功");
4401
- let resS = Module._JSPlayM4_Stop(g_port);
4402
- if (resS == 1) {
4403
- this._doRelease();
4404
- resolve({
4405
- resS
4406
- });
4407
- } else {
4408
- var jsPluginErrorCode = Module._JSPlayM4_GetLastError(g_port);
4409
- if (jsPluginErrorCode == 35) {
4410
- let timer10 = setInterval(() => {
4411
- if (!resS) {
4412
- resS = Module._JSPlayM4_Stop(g_port);
4413
- if (resS == 1) {
4414
- this._doRelease();
4415
- resolve({
4416
- resS
4417
- });
4418
- } else {
4419
- jsPluginErrorCode = Module._JSPlayM4_GetLastError(g_port);
4420
- console.log("stop error ", jsPluginErrorCode); // 停止失败,持续停止
4421
- }
4422
- } else {
4423
- clearInterval(timer10);
4424
- }
4425
- }, 50);
4426
- } else {
4427
- console.log("stop - other error, still resolve", jsPluginErrorCode, resS);
4428
- this._doRelease();
4429
- resolve({
4430
- resS,
4431
- jsPluginErrorCode
4432
- });
4433
- }
4434
- }
4435
- }).catch(err => {
4436
- console.log("停止取流失败_jsPluginErrorCode", err);
4437
- this._doRelease();
4438
- var jsPluginErrorCode = Module._JSPlayM4_GetLastError(g_port);
4439
- console.log("停止取流失败_jsPluginErrorCode", g_port, jsPluginErrorCode);
4440
- resolve({
4441
- jsPluginErrorCode
4442
- });
4443
- });
4444
- });
4445
- return promise;
4446
- }
4447
- JS_DestroyWorker() {
4448
- const {
4449
- Module
4450
- } = window;
4451
- //buffer清空
4452
- //bodyData.splice(0,bodyData.length);
4453
- // aVideoYUVBuffer.splice(0, aVideoYUVBuffer.length);
4454
- // aAudioPCMBuffer.splice(0, aAudioPCMBuffer.length);
4455
- // aPsBuffer.splice(0, aPsBuffer.length);
4456
- //销毁canvas资源
4457
- let canvasList = document.getElementById(this.szId);
4458
- let oldcanv = document.getElementById(this.szId + '-player');
4459
- if (oldcanv) {
4460
- canvasList.removeChild(oldcanv);
4461
- }
4462
- if (this.pCanvasData !== null) {
4463
- Module._free(this.pCanvasData);
4464
- this.pCanvasData = null;
4465
- }
4466
- this.pCanvasString = null;
4467
- console.log("stop end");
4468
- }
4469
- JS_Fast(iWind, next) {
4470
- var nextRate = this.iRate;
4471
- if (next) {
4472
- switch (next) {
4473
- case 1:
4474
- case 2:
4475
- case 4:
4476
- nextRate = next;
4477
- break;
4478
- case 3:
4479
- nextRate = 0.5;
4480
- break;
4481
- default:
4482
- nextRate = this.iRate;
4483
- break;
4484
- }
4485
- } else {
4486
- switch (this.iRate) {
4487
- case 1:
4488
- nextRate = 2;
4489
- break;
4490
- case 2:
4491
- nextRate = 4;
4492
- break;
4493
- default:
4494
- nextRate = this.iRate;
4495
- break;
4496
- }
4497
- }
4498
- this.oStreamClient.setPlayRate(this.szStreamUUID, nextRate);
4499
- this.iRate = nextRate;
4500
- console.log("开启倍速播放,多线程倍速,全解", nextRate);
4501
- if (nextRate == 4) {
4502
- // 用户启动4倍速,执行8线程解码。
4503
- let SetDecodeThreadNumRes = window.Module._JSPlayM4_SetDecodeThreadNum(this.g_port, 8);
4504
- console.log("SetDecodeThreadNumRes", SetDecodeThreadNumRes);
4505
- }
4506
- let res = window.Module._JSPlayM4_Fast(this.g_port);
4507
- console.log("res", res);
4508
- // if(nextRate < 2) {
4509
- // this.Module._JSPlayM4_SetDecodeFrameType(this.g_port,0)
4510
- // } else {
4511
- // this.Module._JSPlayM4_SetDecodeFrameType(this.g_port,1);
4512
- // // this.Module._JSPlayM4_SetIFrameDecInterval(this.g_port,0);
4513
- // }
4514
- }
4515
-
4516
- JS_Slow() {
4517
- var nextRate = this.iRate;
4518
- switch (this.iRate) {
4519
- case 2:
4520
- nextRate = 1;
4521
- break;
4522
- case 4:
4523
- nextRate = 2;
4524
- break;
4525
- default:
4526
- nextRate = this.iRate;
4527
- break;
4528
- }
4529
- this.oStreamClient.setPlayRate(this.szStreamUUID, nextRate);
4530
- this.iRate = nextRate;
4531
- console.log("开启倍速播放", nextRate);
4532
- }
4533
- JS_Speed(nextRate) {
4534
- this.oStreamClient.setPlayRate(this.szStreamUUID, nextRate);
4535
- window.Module._JSPlayM4_SetDecodeFrameType(1);
4536
- const fastRes = window.Module._JSPlayM4_Fast(this.g_port);
4537
- this.iRate = nextRate;
4538
- console.log("开启倍速播放", nextRate);
4539
- console.log("开启倍速播放res:", fastRes);
4540
- }
4541
- JS_Seek(iWndNum, szStartTime, szStopTime) {
4542
- let oPromise = new Promise((resolve, reject) => {
4543
- var res = window.Module._JSPlayM4_ResetBuffer(this.g_port, 1);
4544
- console.log("seek 清理缓存", res);
4545
- this.oStreamClient.seek(this.szStreamUUID, szStartTime, szStopTime).then(function () {
4546
- resolve();
4547
- }, function (oError) {
4548
- reject(oError);
4549
- });
4550
- });
4551
- return oPromise;
4552
- }
4553
- JSPlayM4_SetPrintLogFlag() {
4554
- let resDR = window.Module._JSPlayM4_SetPrintLogFlag(this.g_port, 2);
4555
- console.log("LogValue:" + 2 + ",resDR:" + resDR);
4556
- }
4557
- _JSPlayM4_SetDisplayRegion(left, right, top, bottom) {
4558
- new Promise((resolve, reject) => {
4559
- let resDR = window.Module._JSPlayM4_SetDisplayRegion(this.g_port, this.szId, left, right, top, bottom);
4560
- resolve({
4561
- code: 0,
4562
- data: resDR
4563
- });
4564
- });
4565
- }
4566
- /**
4567
- * @synopsis 暂停
4568
- *
4569
- * @param {number} iWndNum 窗口号
4570
- *
4571
- * @returns {none} 无
4572
- */
4573
- JS_Pause(iWndNum) {
4574
- if (!this.bPlay) {
4575
- console.log("当前不是播放状态,无法暂停");
4576
- return new Promise((resolve, reject) => {
4577
- reject({
4578
- code: 0,
4579
- msg: "当前不是播放状态,不需要暂停"
4580
- });
4581
- });
4582
- }
4583
- // 暂停缓存截图数据 start
4584
- const callback = data => {
4585
- if (data.fileUint8Array) {
4586
- this.tmpCapturePictureData = data.fileUint8Array;
4587
- }
4588
- };
4589
- this.JS_CapturePicture(0, `${new Date().getTime()}`, "JPEG", callback, true);
4590
- // 暂停缓存截图数据 end
4591
-
4592
- if (this.playURL.indexOf("playback") !== -1) {
4593
- //回放暂停
4594
- // 如果为回放,需要记录暂停时间
4595
- var pauseTimeFrame = this._JSPlayM4_GetFrameInfo(this.g_port);
4596
- console.log("开始暂停");
4597
- var pauseTime = `${pauseTimeFrame.year}` + (pauseTimeFrame.month > 9 ? pauseTimeFrame.month : `0${pauseTimeFrame.month}`) + (pauseTimeFrame.day > 9 ? pauseTimeFrame.day : `0${pauseTimeFrame.day}`) + (pauseTimeFrame.hour > 9 ? pauseTimeFrame.hour : `0${pauseTimeFrame.hour}`) + (pauseTimeFrame.minute > 9 ? pauseTimeFrame.minute : `0${pauseTimeFrame.minute}`) + (pauseTimeFrame.second > 9 ? pauseTimeFrame.second : `0${pauseTimeFrame.second}`);
4598
- if (pauseTime.length === 14) {
4599
- // 符合yyyymmddhhmmss后赋值
4600
- this.bPauseTime = pauseTime;
4601
- }
4602
- }
4603
- this.JS_GetOSDTime() //记录暂停的OSD时间
4604
- .then(data => {
4605
- var pauseDate = new Date(data * 1000);
4606
- this.bPauseDate = pauseDate.valueOf();
4607
- });
4608
- const promise = new Promise((resolve, reject) => {
4609
- this.JS_Stop().then(() => {
4610
- this.bPlay = false; // 停止后暂停状态需要复原
4611
- this.bPause = true;
4612
- resolve({
4613
- code: 1,
4614
- msg: "暂停成功"
4615
- });
4616
- }).catch(err => {
4617
- reject({
4618
- code: 0,
4619
- msg: "暂停失败"
4620
- });
4621
- console.log("err", err);
4622
- });
4623
- });
4624
- return promise;
4625
- }
4626
-
4627
- /**
4628
- * @synopsis 恢复
4629
- *
4630
- * @param {number} iWndNum 窗口号
4631
- *
4632
- * @returns {none} 无
4633
- */
4634
- JS_Resume(resumeTime) {
4635
- const promise = new Promise((resolve, reject) => {
4636
- if (resumeTime) {
4637
- if (this.bPauseTime) {
4638
- this.bPauseTime = this.bPauseTime.slice(0, 14 - resumeTime.length) + resumeTime;
4639
- } else {
4640
- this.bPauseTime = resumeTime;
4641
- }
4642
- }
4643
- if (this.playURL.indexOf("playback") !== -1) {
4644
- this.playURL = this.playURL.replace(/begin=[0-9]{8}T[0-9]{6}Z/gi, `begin=${this.bPauseTime.slice(0, 8)}T${this.bPauseTime.slice(8, 14)}Z`);
4645
- }
4646
- console.log('this.bPauseDate:', this.bPauseDate);
4647
- if (this.playURL.indexOf("cloudplayback") !== -1) {
4648
- this.playURL = this.playURL.replace(/"startTime":[0-9]{13}/gi, `"startTime":${this.bPauseDate}`);
4649
- }
4650
- this.bPause = false;
4651
- this.JS_Play(this.szUrl, {
4652
- playURL: this.playURL
4653
- }).then(data => {
4654
- resolve(data);
4655
- }).catch(err => {
4656
- reject(err);
4657
- });
4658
- });
4659
- return promise;
4660
- }
4661
- }
4662
- window.JSPluginV2 = JSPluginV2;