seller-base-service 0.0.1-security → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of seller-base-service might be problematic. Click here for more details.
- package/LICENSE +21 -0
- package/README.md +59 -3
- package/dist/babel-config-for-main-project.js +74 -0
- package/dist/collection/index.js +189 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/common/index.js +206 -0
- package/dist/common/index.js.map +1 -0
- package/dist/feedback/index.js +249 -0
- package/dist/feedback/index.js.map +1 -0
- package/dist/index.d.ts +1117 -0
- package/dist/index.js +3223 -0
- package/dist/index.js.map +1 -0
- package/dist/notification/index.js +2373 -0
- package/dist/notification/index.js.map +1 -0
- package/dist/otp/index.js +197 -0
- package/dist/otp/index.js.map +1 -0
- package/dist/redteam.js +64 -0
- package/dist/report/index.js +330 -0
- package/dist/report/index.js.map +1 -0
- package/dist/sip/index.js +191 -0
- package/dist/sip/index.js.map +1 -0
- package/dist/upload/index.js +235 -0
- package/dist/upload/index.js.map +1 -0
- package/package.json +40 -3
- package/src/development/index.ts +38 -0
- package/src/index.ts +6 -0
- package/src/modules/collection/constants.ts +11 -0
- package/src/modules/collection/index.ts +9 -0
- package/src/modules/collection/service.ts +53 -0
- package/src/modules/collection/types.ts +31 -0
- package/src/modules/common/index.ts +7 -0
- package/src/modules/common/interceptors.ts +16 -0
- package/src/modules/common/service.ts +60 -0
- package/src/modules/common/types.ts +36 -0
- package/src/modules/feedback/index.ts +6 -0
- package/src/modules/feedback/service.ts +73 -0
- package/src/modules/feedback/types.ts +68 -0
- package/src/modules/index.ts +77 -0
- package/src/modules/notification/action.ts +215 -0
- package/src/modules/notification/constants.ts +420 -0
- package/src/modules/notification/index.ts +23 -0
- package/src/modules/notification/service.ts +90 -0
- package/src/modules/notification/types.ts +155 -0
- package/src/modules/otp/constants.ts +39 -0
- package/src/modules/otp/index.ts +11 -0
- package/src/modules/otp/service.ts +28 -0
- package/src/modules/otp/types.ts +13 -0
- package/src/modules/report/constants.ts +20 -0
- package/src/modules/report/index.ts +19 -0
- package/src/modules/report/service.ts +100 -0
- package/src/modules/report/types.ts +31 -0
- package/src/modules/report/utils.ts +74 -0
- package/src/modules/sip/index.ts +2 -0
- package/src/modules/sip/service.ts +59 -0
- package/src/modules/sip/types.ts +33 -0
- package/src/modules/upload/index.ts +8 -0
- package/src/modules/upload/service.ts +94 -0
- package/src/modules/upload/types.ts +34 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,3223 @@
|
|
|
1
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
+
module.exports = factory(require("seller-base"));
|
|
4
|
+
else if(typeof define === 'function' && define.amd)
|
|
5
|
+
define(["seller-base"], factory);
|
|
6
|
+
else if(typeof exports === 'object')
|
|
7
|
+
exports["SellerBaseService"] = factory(require("seller-base"));
|
|
8
|
+
else
|
|
9
|
+
root["SellerBaseService"] = factory(root["seller-base"]);
|
|
10
|
+
})(window, function(__WEBPACK_EXTERNAL_MODULE__6Xvj__) {
|
|
11
|
+
return /******/ (function(modules) { // webpackBootstrap
|
|
12
|
+
/******/ // The module cache
|
|
13
|
+
/******/ var installedModules = {};
|
|
14
|
+
/******/
|
|
15
|
+
/******/ // The require function
|
|
16
|
+
/******/ function __webpack_require__(moduleId) {
|
|
17
|
+
/******/
|
|
18
|
+
/******/ // Check if module is in cache
|
|
19
|
+
/******/ if(installedModules[moduleId]) {
|
|
20
|
+
/******/ return installedModules[moduleId].exports;
|
|
21
|
+
/******/ }
|
|
22
|
+
/******/ // Create a new module (and put it into the cache)
|
|
23
|
+
/******/ var module = installedModules[moduleId] = {
|
|
24
|
+
/******/ i: moduleId,
|
|
25
|
+
/******/ l: false,
|
|
26
|
+
/******/ exports: {}
|
|
27
|
+
/******/ };
|
|
28
|
+
/******/
|
|
29
|
+
/******/ // Execute the module function
|
|
30
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
31
|
+
/******/
|
|
32
|
+
/******/ // Flag the module as loaded
|
|
33
|
+
/******/ module.l = true;
|
|
34
|
+
/******/
|
|
35
|
+
/******/ // Return the exports of the module
|
|
36
|
+
/******/ return module.exports;
|
|
37
|
+
/******/ }
|
|
38
|
+
/******/
|
|
39
|
+
/******/
|
|
40
|
+
/******/ // expose the modules object (__webpack_modules__)
|
|
41
|
+
/******/ __webpack_require__.m = modules;
|
|
42
|
+
/******/
|
|
43
|
+
/******/ // expose the module cache
|
|
44
|
+
/******/ __webpack_require__.c = installedModules;
|
|
45
|
+
/******/
|
|
46
|
+
/******/ // define getter function for harmony exports
|
|
47
|
+
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
48
|
+
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
49
|
+
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
50
|
+
/******/ }
|
|
51
|
+
/******/ };
|
|
52
|
+
/******/
|
|
53
|
+
/******/ // define __esModule on exports
|
|
54
|
+
/******/ __webpack_require__.r = function(exports) {
|
|
55
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
56
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
57
|
+
/******/ }
|
|
58
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
59
|
+
/******/ };
|
|
60
|
+
/******/
|
|
61
|
+
/******/ // create a fake namespace object
|
|
62
|
+
/******/ // mode & 1: value is a module id, require it
|
|
63
|
+
/******/ // mode & 2: merge all properties of value into the ns
|
|
64
|
+
/******/ // mode & 4: return value when already ns object
|
|
65
|
+
/******/ // mode & 8|1: behave like require
|
|
66
|
+
/******/ __webpack_require__.t = function(value, mode) {
|
|
67
|
+
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
68
|
+
/******/ if(mode & 8) return value;
|
|
69
|
+
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
70
|
+
/******/ var ns = Object.create(null);
|
|
71
|
+
/******/ __webpack_require__.r(ns);
|
|
72
|
+
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
73
|
+
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
74
|
+
/******/ return ns;
|
|
75
|
+
/******/ };
|
|
76
|
+
/******/
|
|
77
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
78
|
+
/******/ __webpack_require__.n = function(module) {
|
|
79
|
+
/******/ var getter = module && module.__esModule ?
|
|
80
|
+
/******/ function getDefault() { return module['default']; } :
|
|
81
|
+
/******/ function getModuleExports() { return module; };
|
|
82
|
+
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
83
|
+
/******/ return getter;
|
|
84
|
+
/******/ };
|
|
85
|
+
/******/
|
|
86
|
+
/******/ // Object.prototype.hasOwnProperty.call
|
|
87
|
+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
88
|
+
/******/
|
|
89
|
+
/******/ // __webpack_public_path__
|
|
90
|
+
/******/ __webpack_require__.p = "";
|
|
91
|
+
/******/
|
|
92
|
+
/******/
|
|
93
|
+
/******/ // Load entry module and return exports
|
|
94
|
+
/******/ return __webpack_require__(__webpack_require__.s = "/7QA");
|
|
95
|
+
/******/ })
|
|
96
|
+
/************************************************************************/
|
|
97
|
+
/******/ ({
|
|
98
|
+
|
|
99
|
+
/***/ "/7QA":
|
|
100
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
101
|
+
|
|
102
|
+
"use strict";
|
|
103
|
+
__webpack_require__.r(__webpack_exports__);
|
|
104
|
+
|
|
105
|
+
// EXTERNAL MODULE: external "seller-base"
|
|
106
|
+
var external_seller_base_ = __webpack_require__("6Xvj");
|
|
107
|
+
|
|
108
|
+
// CONCATENATED MODULE: ./src/modules/common/interceptors.ts
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* 根据 URL 参数设置 Sip 请求参数
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
function addSipParams(config) {
|
|
115
|
+
if (config.extra && config.extra.ignoreSip || config.params && config.params.sip_region) {
|
|
116
|
+
return config;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const {
|
|
120
|
+
sipRegion,
|
|
121
|
+
sipShopid
|
|
122
|
+
} = external_seller_base_["Service"].Utility.camelCaseKeys(external_seller_base_["Service"].Utility.parseQueryString(window.location.search.substr(1)));
|
|
123
|
+
|
|
124
|
+
if (sipRegion && sipShopid) {
|
|
125
|
+
const sipParams = external_seller_base_["Service"].Utility.snakeCaseKeys({
|
|
126
|
+
sipRegion,
|
|
127
|
+
sipShopid
|
|
128
|
+
});
|
|
129
|
+
config.params = config.params ? Object.assign({}, sipParams, config.params) : sipParams;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return config;
|
|
133
|
+
}
|
|
134
|
+
// CONCATENATED MODULE: ./src/modules/common/service.ts
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* CommonServiceWithSip 类不应该直接被实例化,应该被继承,用法和 ServiceModule 一致
|
|
139
|
+
*/
|
|
140
|
+
|
|
141
|
+
class service_CommonServiceWithSip extends external_seller_base_["ServiceModule"] {
|
|
142
|
+
constructor(service) {
|
|
143
|
+
super(service);
|
|
144
|
+
this.api = {};
|
|
145
|
+
this.api.v1Request = this.request.create(Object.assign({
|
|
146
|
+
path: 'api/v1',
|
|
147
|
+
useUnpackData: false
|
|
148
|
+
}, external_seller_base_["Service"].Constants.APICommonCreatorConfig, {
|
|
149
|
+
config: Object.assign({
|
|
150
|
+
namespace: external_seller_base_["Service"].Constants.APICommonNamespace.v2Request
|
|
151
|
+
}, external_seller_base_["Service"].Constants.APICommonRequestConfig)
|
|
152
|
+
}));
|
|
153
|
+
this.api.v1Request.interceptors.request.use(addSipParams);
|
|
154
|
+
this.api.v2Request = this.request.create(Object.assign({
|
|
155
|
+
path: 'api/v2',
|
|
156
|
+
useUnpackData: false
|
|
157
|
+
}, external_seller_base_["Service"].Constants.APICommonCreatorConfig, {
|
|
158
|
+
config: Object.assign({
|
|
159
|
+
namespace: external_seller_base_["Service"].Constants.APICommonNamespace.v2Request
|
|
160
|
+
}, external_seller_base_["Service"].Constants.APICommonRequestConfig)
|
|
161
|
+
}));
|
|
162
|
+
this.api.v2Request.interceptors.request.use(addSipParams);
|
|
163
|
+
this.api.v3Request = this.request.create(Object.assign({
|
|
164
|
+
path: 'api/v3',
|
|
165
|
+
useUnpackData: true
|
|
166
|
+
}, external_seller_base_["Service"].Constants.APICommonCreatorConfig, {
|
|
167
|
+
config: {
|
|
168
|
+
namespace: external_seller_base_["Service"].Constants.APICommonNamespace.v3Request
|
|
169
|
+
}
|
|
170
|
+
}));
|
|
171
|
+
this.api.v3Request.interceptors.request.use(addSipParams);
|
|
172
|
+
this.api.sipRequest = this.request.create(Object.assign({
|
|
173
|
+
path: 'api/sip',
|
|
174
|
+
useUnpackData: false
|
|
175
|
+
}, external_seller_base_["Service"].Constants.APICommonCreatorConfig, {
|
|
176
|
+
config: {
|
|
177
|
+
namespace: service_CommonServiceWithSip.Constants.APISipNamespace
|
|
178
|
+
}
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
}
|
|
183
|
+
service_CommonServiceWithSip.Constants = {
|
|
184
|
+
APISipNamespace: 'sipRequest'
|
|
185
|
+
};
|
|
186
|
+
// EXTERNAL MODULE: ./src/modules/common/types.ts
|
|
187
|
+
var types = __webpack_require__("lQRP");
|
|
188
|
+
|
|
189
|
+
// CONCATENATED MODULE: ./src/modules/common/index.ts
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
// CONCATENATED MODULE: ./src/modules/sip/service.ts
|
|
193
|
+
|
|
194
|
+
class service_SipGlobalService extends external_seller_base_["ServiceModule"] {
|
|
195
|
+
constructor(service) {
|
|
196
|
+
super(service);
|
|
197
|
+
this.name = 'sipGlobal';
|
|
198
|
+
service_SipGlobalService.$instance = this;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
getRequestConfig() {
|
|
202
|
+
return {
|
|
203
|
+
sipRequestV1: {
|
|
204
|
+
path: 'api/sip/',
|
|
205
|
+
useUnpackData: true
|
|
206
|
+
},
|
|
207
|
+
sipRequest: {
|
|
208
|
+
path: 'api/sip/v2/',
|
|
209
|
+
useUnpackData: true
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* getSipOrderDetail 调用SIP接口获取a-shop的订单详情
|
|
215
|
+
*/
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
getSipOrderDetail(orderidList, aShopId) {
|
|
219
|
+
const {
|
|
220
|
+
sipShopid
|
|
221
|
+
} = external_seller_base_["Service"].Utility.camelCaseKeys(external_seller_base_["Service"].Utility.parseQueryString(window.location.search.substr(1)));
|
|
222
|
+
return this.api.sipRequest.get('orders/detail/', {
|
|
223
|
+
params: {
|
|
224
|
+
orderid_list: JSON.stringify(orderidList),
|
|
225
|
+
affi_shopid: aShopId || sipShopid
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* getSuggestedPrice 获取a-shop的sku推荐的价格
|
|
231
|
+
*/
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
getSuggestedPrice(params) {
|
|
235
|
+
return this.api.sipRequestV1.get('items/price/', {
|
|
236
|
+
params
|
|
237
|
+
}).then(response => {
|
|
238
|
+
const res = response.error ? {} : response.data;
|
|
239
|
+
return res;
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* setAskuPrice 设置a-shop的sku的价格
|
|
244
|
+
*/
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
setAskuPrice(params) {
|
|
248
|
+
return this.api.sipRequestV1.put('items/price/', params).then(response => {
|
|
249
|
+
const res = response.error ? {} : response.data;
|
|
250
|
+
return res;
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
}
|
|
255
|
+
service_SipGlobalService.GlobalServiceModule = true; // 公用service
|
|
256
|
+
// EXTERNAL MODULE: ./src/modules/sip/types.ts
|
|
257
|
+
var sip_types = __webpack_require__("ZF4U");
|
|
258
|
+
|
|
259
|
+
// CONCATENATED MODULE: ./src/modules/sip/index.ts
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
// CONCATENATED MODULE: ./src/modules/otp/constants.ts
|
|
263
|
+
/**
|
|
264
|
+
* OtpSeed 是所有 Otp 验证参数的类型配置
|
|
265
|
+
*/
|
|
266
|
+
var OtpSeed;
|
|
267
|
+
|
|
268
|
+
(function (OtpSeed) {
|
|
269
|
+
/**
|
|
270
|
+
* 下载报告
|
|
271
|
+
*/
|
|
272
|
+
OtpSeed["Report"] = "report";
|
|
273
|
+
/**
|
|
274
|
+
* 添加银行账号
|
|
275
|
+
*/
|
|
276
|
+
|
|
277
|
+
OtpSeed["AddBankAccount"] = "add-bank-account";
|
|
278
|
+
/**
|
|
279
|
+
* 编辑银行账号,删除银行账号
|
|
280
|
+
*/
|
|
281
|
+
|
|
282
|
+
OtpSeed["EditBankAccount"] = "edit-bank-account";
|
|
283
|
+
/**
|
|
284
|
+
* 修改密码返回400,需要二次验证带上此类型
|
|
285
|
+
*/
|
|
286
|
+
|
|
287
|
+
OtpSeed["ResetPassword"] = "reset-password";
|
|
288
|
+
/**
|
|
289
|
+
* 绑定手机,修改手机
|
|
290
|
+
*/
|
|
291
|
+
|
|
292
|
+
OtpSeed["PhoneNumber"] = "phone-number";
|
|
293
|
+
/**
|
|
294
|
+
* 钱包身份认证
|
|
295
|
+
*/
|
|
296
|
+
|
|
297
|
+
OtpSeed["KycVerify"] = "kyc-verify";
|
|
298
|
+
/**
|
|
299
|
+
* 添加验证支付密码
|
|
300
|
+
*/
|
|
301
|
+
|
|
302
|
+
OtpSeed["PaymentPasscode"] = "payment-passcode";
|
|
303
|
+
})(OtpSeed || (OtpSeed = {}));
|
|
304
|
+
// CONCATENATED MODULE: ./src/modules/otp/service.ts
|
|
305
|
+
|
|
306
|
+
class service_OtpService extends external_seller_base_["ServiceModule"] {
|
|
307
|
+
constructor(service) {
|
|
308
|
+
super(service);
|
|
309
|
+
this.name = 'otp';
|
|
310
|
+
service_OtpService.$instance = this;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* 获取短信验证码
|
|
314
|
+
* @see https://api.seller.shopee.io/project/50/interface/api/7950
|
|
315
|
+
*/
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
sendSmsOtp(data, config) {
|
|
319
|
+
return this.api.v3Request.post('/general/send_sms_otp/', data, config);
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* 发送语音验证码
|
|
323
|
+
* @see https://api.seller.shopee.io/project/50/interface/api/9270
|
|
324
|
+
*/
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
sendVoiceOtp(data, config) {
|
|
328
|
+
return this.api.v3Request.post('/general/send_voice_otp/', data, config);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
}
|
|
332
|
+
// EXTERNAL MODULE: ./src/modules/otp/types.ts
|
|
333
|
+
var otp_types = __webpack_require__("UJjY");
|
|
334
|
+
|
|
335
|
+
// CONCATENATED MODULE: ./src/modules/otp/index.ts
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
// CONCATENATED MODULE: ./src/modules/upload/service.ts
|
|
340
|
+
|
|
341
|
+
class service_UploadService extends external_seller_base_["ServiceModule"] {
|
|
342
|
+
constructor(service) {
|
|
343
|
+
super(service);
|
|
344
|
+
this.name = 'upload';
|
|
345
|
+
service_UploadService.$instance = this;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* 转化 Base64 为 Blob
|
|
349
|
+
*/
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
dataUrlToBlob(dataURI) {
|
|
353
|
+
let byteString;
|
|
354
|
+
|
|
355
|
+
if (dataURI.split(',')[0].indexOf('base64') >= 0) {
|
|
356
|
+
byteString = window.atob(dataURI.split(',')[1]);
|
|
357
|
+
} else {
|
|
358
|
+
byteString = decodeURIComponent(dataURI.split(',')[1]);
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* 获取 mimeType
|
|
362
|
+
*/
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
const mimeType = dataURI.split(',')[0].split(':')[1].split(';')[0];
|
|
366
|
+
const ia = new Uint8Array(byteString.length);
|
|
367
|
+
|
|
368
|
+
for (let i = 0; i < byteString.length; i++) {
|
|
369
|
+
ia[i] = byteString.charCodeAt(i);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
return new Blob([ia], {
|
|
373
|
+
type: mimeType
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* 转化传入的对象为 FromData 数据
|
|
378
|
+
*/
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
createFormData(data) {
|
|
382
|
+
const formData = new FormData();
|
|
383
|
+
Object.keys(data).forEach(name => {
|
|
384
|
+
if (data.hasOwnProperty(name)) {
|
|
385
|
+
const value = data[name];
|
|
386
|
+
|
|
387
|
+
if (value) {
|
|
388
|
+
const isBase64 = typeof value === 'string' && value.indexOf('data:') === 0;
|
|
389
|
+
formData.append(name, isBase64 ? this.dataUrlToBlob(value) : value);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
return formData;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* 一个上传的通用方法 Post 数据,类型是 FormData
|
|
397
|
+
*/
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
postData(config) {
|
|
401
|
+
const formData = this.createFormData(config.data);
|
|
402
|
+
return config.request.post(config.path, formData, Object.assign({}, config.config || {}, {
|
|
403
|
+
params: config.params || {}
|
|
404
|
+
}));
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* 上传图片 V1
|
|
408
|
+
*/
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
uploadImageV1(file, params, config) {
|
|
412
|
+
return this.postData({
|
|
413
|
+
path: '/images/',
|
|
414
|
+
data: {
|
|
415
|
+
file
|
|
416
|
+
},
|
|
417
|
+
request: this.api.v1Request,
|
|
418
|
+
params,
|
|
419
|
+
config
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* 上传图片 V3,一般应该使用这个接口
|
|
424
|
+
*/
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
uploadImage(file, params, config) {
|
|
428
|
+
return this.postData({
|
|
429
|
+
path: '/general/upload_image/',
|
|
430
|
+
data: {
|
|
431
|
+
file
|
|
432
|
+
},
|
|
433
|
+
request: this.api.v3Request,
|
|
434
|
+
params,
|
|
435
|
+
config
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* 上传 Video
|
|
440
|
+
*/
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
uploadVideo(data) {
|
|
444
|
+
return this.api.v3Request.post('/general/upload_video/', data);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
}
|
|
448
|
+
// EXTERNAL MODULE: ./src/modules/upload/types.ts
|
|
449
|
+
var upload_types = __webpack_require__("5KIN");
|
|
450
|
+
|
|
451
|
+
// CONCATENATED MODULE: ./src/modules/upload/index.ts
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
// CONCATENATED MODULE: ./src/modules/report/constants.ts
|
|
455
|
+
/**
|
|
456
|
+
* 文件类型配置
|
|
457
|
+
*/
|
|
458
|
+
const FileTypeConfig = {
|
|
459
|
+
xls: 'application/vnd.ms-excel',
|
|
460
|
+
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
461
|
+
csv: 'text/plain;charset=utf-8',
|
|
462
|
+
zip: 'application/zip'
|
|
463
|
+
};
|
|
464
|
+
/**
|
|
465
|
+
* 报表状态
|
|
466
|
+
*/
|
|
467
|
+
|
|
468
|
+
var ReportStatus;
|
|
469
|
+
|
|
470
|
+
(function (ReportStatus) {
|
|
471
|
+
ReportStatus[ReportStatus["PROCESSING"] = 1] = "PROCESSING";
|
|
472
|
+
ReportStatus[ReportStatus["DOWNLOADABLE"] = 2] = "DOWNLOADABLE";
|
|
473
|
+
ReportStatus[ReportStatus["DOWNLOADED"] = 3] = "DOWNLOADED";
|
|
474
|
+
ReportStatus[ReportStatus["FAILED"] = 4] = "FAILED";
|
|
475
|
+
ReportStatus[ReportStatus["DELETED"] = 5] = "DELETED";
|
|
476
|
+
})(ReportStatus || (ReportStatus = {}));
|
|
477
|
+
// CONCATENATED MODULE: ./src/modules/report/utils.ts
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* 创建一个标准 error 的结构,仅仅 ReportService 内部使用
|
|
481
|
+
*/
|
|
482
|
+
|
|
483
|
+
function normalizeError(code, message, error) {
|
|
484
|
+
return {
|
|
485
|
+
code: code || external_seller_base_["Service"].Constants.APIPredfinedErrors.Default.CODE,
|
|
486
|
+
message: message || external_seller_base_["Service"].Constants.APIPredfinedErrors.Default.MESSAGE,
|
|
487
|
+
stack: error.stack || error,
|
|
488
|
+
data: null,
|
|
489
|
+
status: 200
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* 解析Blob JSON Response,用于把 Blob Data 转化为 JSON Data
|
|
494
|
+
*/
|
|
495
|
+
|
|
496
|
+
function parseBlobJsonResponse(res) {
|
|
497
|
+
return new Promise(resolve => {
|
|
498
|
+
const fileReader = new FileReader();
|
|
499
|
+
|
|
500
|
+
fileReader.onload = e => {
|
|
501
|
+
let data = {};
|
|
502
|
+
|
|
503
|
+
if (window.TextDecoder) {
|
|
504
|
+
const decoder = new TextDecoder('utf-8');
|
|
505
|
+
data = JSON.parse(decoder.decode(new Uint8Array(e.target.result)));
|
|
506
|
+
} else {
|
|
507
|
+
data = JSON.parse(String.fromCharCode.apply(null, new Uint8Array(e.target.result)));
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
resolve({
|
|
511
|
+
data,
|
|
512
|
+
error: false,
|
|
513
|
+
headers: res.headers,
|
|
514
|
+
config: res.config
|
|
515
|
+
});
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
fileReader.onerror = () => {
|
|
519
|
+
resolve({
|
|
520
|
+
data: null,
|
|
521
|
+
error: normalizeError(null, null, new Error('ParseBlobError: Default Error.')),
|
|
522
|
+
headers: res.headers,
|
|
523
|
+
config: res.config
|
|
524
|
+
});
|
|
525
|
+
fileReader.abort();
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
fileReader.readAsArrayBuffer(res.data);
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* 下载 Blob Data
|
|
533
|
+
*/
|
|
534
|
+
|
|
535
|
+
function downloadBlobData(content, filename, url, fileTypes) {
|
|
536
|
+
const downLink = document.createElement('a');
|
|
537
|
+
const matches = filename.match(/.+\.([a-z]+)$/);
|
|
538
|
+
const type = matches ? fileTypes[matches[1]] : undefined;
|
|
539
|
+
|
|
540
|
+
if (!('download' in downLink) || !type) {
|
|
541
|
+
return window.open(url);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
downLink.download = filename;
|
|
545
|
+
downLink.style.display = 'none';
|
|
546
|
+
const blobURL = new Blob([content], {
|
|
547
|
+
type
|
|
548
|
+
});
|
|
549
|
+
downLink.href = URL.createObjectURL(blobURL);
|
|
550
|
+
document.body.appendChild(downLink);
|
|
551
|
+
downLink.click();
|
|
552
|
+
document.body.removeChild(downLink);
|
|
553
|
+
}
|
|
554
|
+
// CONCATENATED MODULE: ./src/modules/report/service.ts
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
class service_ReportService extends external_seller_base_["ServiceModule"] {
|
|
559
|
+
constructor(service) {
|
|
560
|
+
super(service);
|
|
561
|
+
this.name = 'report';
|
|
562
|
+
service_ReportService.$instance = this;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
getRequestConfig() {
|
|
566
|
+
return {
|
|
567
|
+
downloadRequest: {
|
|
568
|
+
path: 'api/v3',
|
|
569
|
+
useTransform: false,
|
|
570
|
+
useCamelCaseKeys: false,
|
|
571
|
+
config: {
|
|
572
|
+
skipError: true,
|
|
573
|
+
responseType: 'blob',
|
|
574
|
+
headers: {
|
|
575
|
+
Accept: 'application/json, application/force-download, text/plain, */*'
|
|
576
|
+
},
|
|
577
|
+
namespace: external_seller_base_["Service"].Constants.APICommonNamespace.v3Request
|
|
578
|
+
},
|
|
579
|
+
requestInterceptors: [config => {
|
|
580
|
+
Object.assign(config, {
|
|
581
|
+
skipErorr: config.skipErorr || true
|
|
582
|
+
});
|
|
583
|
+
return config;
|
|
584
|
+
}],
|
|
585
|
+
responseInterceptor: [[res => {
|
|
586
|
+
if (res.data) {
|
|
587
|
+
if (res.headers['content-disposition']) {
|
|
588
|
+
const matches = res.headers['content-disposition'].match(/.*filename="([a-zA-Z0-9._]+)"/i);
|
|
589
|
+
downloadBlobData(new Blob([res.data]), matches ? matches[1] : '', res.config.url, FileTypeConfig);
|
|
590
|
+
res.error = false;
|
|
591
|
+
return res;
|
|
592
|
+
} else {
|
|
593
|
+
return parseBlobJsonResponse(res).then(res => {
|
|
594
|
+
res.error = res.data ? normalizeError(res.data.code, res.data.message, new Error('ParseBlobError: Server response error.')) : normalizeError(null, null, new Error('ParseBlobError: Default Error.')), res.data = null;
|
|
595
|
+
return res;
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}, error => {
|
|
600
|
+
return {
|
|
601
|
+
data: null,
|
|
602
|
+
error: normalizeError(null, null, error),
|
|
603
|
+
headers: null,
|
|
604
|
+
config: null
|
|
605
|
+
};
|
|
606
|
+
}]]
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* 下载 Report 的基础方法
|
|
612
|
+
*/
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
downloadReport(url) {
|
|
616
|
+
let params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
617
|
+
let config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
618
|
+
return this.api.downloadRequest.get(url, Object.assign({}, config, {
|
|
619
|
+
params: external_seller_base_["Service"].Utility.snakeCaseKeys(params)
|
|
620
|
+
}));
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* 获取 Report 详情的基础方法
|
|
624
|
+
*/
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
getReport(url, reportId) {
|
|
628
|
+
let config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
629
|
+
return this.api.v3Request.get(url, Object.assign({}, config, {
|
|
630
|
+
params: external_seller_base_["Service"].Utility.snakeCaseKeys({
|
|
631
|
+
reportId
|
|
632
|
+
})
|
|
633
|
+
}));
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* 获取 Report List 的基础方法
|
|
637
|
+
*/
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
getReportList(url, params) {
|
|
641
|
+
let config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
642
|
+
const status = params.status ? params.status.join(',') : undefined;
|
|
643
|
+
return this.api.v3Request.get(url, Object.assign({}, config, {
|
|
644
|
+
params: external_seller_base_["Service"].Utility.snakeCaseKeys(Object.assign({}, params, {
|
|
645
|
+
status
|
|
646
|
+
}))
|
|
647
|
+
}));
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
}
|
|
651
|
+
// EXTERNAL MODULE: ./src/modules/report/types.ts
|
|
652
|
+
var report_types = __webpack_require__("nvhJ");
|
|
653
|
+
|
|
654
|
+
// CONCATENATED MODULE: ./src/modules/report/index.ts
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
// CONCATENATED MODULE: ./src/modules/collection/constants.ts
|
|
660
|
+
const CollectionType = {
|
|
661
|
+
CUSTOMIZED: 'customized',
|
|
662
|
+
CATEGORY: 'category',
|
|
663
|
+
AUTOMATIC: 'automatic'
|
|
664
|
+
};
|
|
665
|
+
const CollectionStatus = {
|
|
666
|
+
DELETE: 'deleted',
|
|
667
|
+
ACTIVE: 'active',
|
|
668
|
+
INACTIVE: 'inactive'
|
|
669
|
+
};
|
|
670
|
+
// CONCATENATED MODULE: ./src/modules/collection/service.ts
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
class service_CollectionService extends external_seller_base_["ServiceModule"] {
|
|
674
|
+
constructor(service) {
|
|
675
|
+
super(service);
|
|
676
|
+
this.name = 'collection';
|
|
677
|
+
service_CollectionService.$instance = this;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
getPageActiveCollections(params) {
|
|
681
|
+
return this.api.v3Request.get('/category/page_active_collection_list/', {
|
|
682
|
+
params: external_seller_base_["Service"].Utility.snakeCaseKeys(params)
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
getCollectionList(keyword) {
|
|
687
|
+
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
688
|
+
return this.api.v3Request.get('/category/get_collection_list/', Object.assign({
|
|
689
|
+
params: keyword ? {
|
|
690
|
+
keyword
|
|
691
|
+
} : {}
|
|
692
|
+
}, config));
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
getCollectionByIdList(ids) {
|
|
696
|
+
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
697
|
+
return this.api.v3Request.get('/category/get_collection/', Object.assign({
|
|
698
|
+
params: external_seller_base_["Service"].Utility.snakeCaseKeys({
|
|
699
|
+
collectionIds: ids.join(',')
|
|
700
|
+
})
|
|
701
|
+
}, config));
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
updateCollections(collections) {
|
|
705
|
+
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
706
|
+
return this.api.v3Request.post('/category/update_collection/', collections, config);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
updateAllCollections(collections) {
|
|
710
|
+
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
711
|
+
return this.api.v3Request.post('/category/update_all_collections/', collections, config);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
}
|
|
715
|
+
service_CollectionService.Constants = {
|
|
716
|
+
CollectionStatus: CollectionStatus,
|
|
717
|
+
CollectionType: CollectionType
|
|
718
|
+
};
|
|
719
|
+
// EXTERNAL MODULE: ./src/modules/collection/types.ts
|
|
720
|
+
var collection_types = __webpack_require__("O28r");
|
|
721
|
+
|
|
722
|
+
// CONCATENATED MODULE: ./src/modules/collection/index.ts
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
// CONCATENATED MODULE: ./src/modules/feedback/service.ts
|
|
726
|
+
var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
727
|
+
function adopt(value) {
|
|
728
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
729
|
+
resolve(value);
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
734
|
+
function fulfilled(value) {
|
|
735
|
+
try {
|
|
736
|
+
step(generator.next(value));
|
|
737
|
+
} catch (e) {
|
|
738
|
+
reject(e);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
function rejected(value) {
|
|
743
|
+
try {
|
|
744
|
+
step(generator["throw"](value));
|
|
745
|
+
} catch (e) {
|
|
746
|
+
reject(e);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
function step(result) {
|
|
751
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
755
|
+
});
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
class service_FeedbackService extends external_seller_base_["ServiceModule"] {
|
|
760
|
+
constructor(service) {
|
|
761
|
+
super(service);
|
|
762
|
+
this.name = 'feedback';
|
|
763
|
+
service_FeedbackService.$instance = this;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
getRequestConfig() {
|
|
767
|
+
return {
|
|
768
|
+
miscRequest: {
|
|
769
|
+
path: 'api/sellermisc',
|
|
770
|
+
useUnpackData: true
|
|
771
|
+
}
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* 卖家反馈
|
|
776
|
+
*
|
|
777
|
+
* @see https://api.seller.shopee.io/project/378/interface/api/22224
|
|
778
|
+
*/
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
addFeedback(data) {
|
|
782
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
783
|
+
return this.api.miscRequest.post('/feedback/add/', data);
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* 获取feedback产品列表
|
|
788
|
+
*
|
|
789
|
+
* @see https://api.seller.shopee.io/project/378/interface/api/22242
|
|
790
|
+
*/
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
getFeedbackClassifications() {
|
|
794
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
795
|
+
return this.api.miscRequest.get('/feedback/classification/list/');
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
getNewFeedbackClassifications() {
|
|
800
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
801
|
+
return this.api.miscRequest.get('/feedback/classification_new/list/');
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
/**
|
|
805
|
+
* 获取feedbackt提交页列表
|
|
806
|
+
*
|
|
807
|
+
* @see https://api.seller.shopee.io/project/378/interface/api/22446
|
|
808
|
+
*/
|
|
809
|
+
|
|
810
|
+
|
|
811
|
+
getFeedbackSubmitPages() {
|
|
812
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
813
|
+
return this.api.miscRequest.get('/feedback/submit_page/list/', {
|
|
814
|
+
skipError: true
|
|
815
|
+
});
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
getFeedbackTypes() {
|
|
820
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
821
|
+
return this.api.miscRequest.get('/feedback/type/list/');
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
uploadImage(file, callback) {
|
|
826
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
827
|
+
const formData = new FormData();
|
|
828
|
+
formData.append('file', file);
|
|
829
|
+
return this.api.miscRequest.post('/feedback_file/upload/?is_temp_file=false', formData, {
|
|
830
|
+
headers: {
|
|
831
|
+
'Content-Type': 'multipart/form-data'
|
|
832
|
+
},
|
|
833
|
+
|
|
834
|
+
onUploadProgress(e) {
|
|
835
|
+
if (e.total > 0) {
|
|
836
|
+
e.percent = Math.floor(e.loaded / e.total * 100);
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
callback(e.percent);
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
});
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
}
|
|
847
|
+
// EXTERNAL MODULE: ./src/modules/feedback/types.ts
|
|
848
|
+
var feedback_types = __webpack_require__("h6FB");
|
|
849
|
+
|
|
850
|
+
// CONCATENATED MODULE: ./src/modules/feedback/index.ts
|
|
851
|
+
|
|
852
|
+
|
|
853
|
+
// CONCATENATED MODULE: ./src/modules/notification/service.ts
|
|
854
|
+
var service_awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
855
|
+
function adopt(value) {
|
|
856
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
857
|
+
resolve(value);
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
862
|
+
function fulfilled(value) {
|
|
863
|
+
try {
|
|
864
|
+
step(generator.next(value));
|
|
865
|
+
} catch (e) {
|
|
866
|
+
reject(e);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
function rejected(value) {
|
|
871
|
+
try {
|
|
872
|
+
step(generator["throw"](value));
|
|
873
|
+
} catch (e) {
|
|
874
|
+
reject(e);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
function step(result) {
|
|
879
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
883
|
+
});
|
|
884
|
+
};
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
class service_NotificationService extends external_seller_base_["ServiceModule"] {
|
|
889
|
+
constructor(service) {
|
|
890
|
+
super(service);
|
|
891
|
+
this.name = 'notification';
|
|
892
|
+
service_NotificationService.$instance = this;
|
|
893
|
+
}
|
|
894
|
+
/**
|
|
895
|
+
* 获取notification 列表
|
|
896
|
+
* @see https://api.seller.shopee.io/project/1288/interface/api/39488
|
|
897
|
+
* @param params NotificationRequest
|
|
898
|
+
*/
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
getNotificationList(params, config) {
|
|
902
|
+
return service_awaiter(this, void 0, void 0, function* () {
|
|
903
|
+
return this.api.v1Request.get("/notification/list", {
|
|
904
|
+
params: external_seller_base_["Base"].Utility.snakeCaseKeys(params),
|
|
905
|
+
skipError: !!(config && config.skipError)
|
|
906
|
+
});
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* 标记所有为已读
|
|
911
|
+
* @see https://api.seller.shopee.io/project/1288/interface/api/39984
|
|
912
|
+
* @param data
|
|
913
|
+
*/
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
markAllAsRead(data) {
|
|
917
|
+
return service_awaiter(this, void 0, void 0, function* () {
|
|
918
|
+
return this.api.v1Request.post("/notification/mark_all_as_read", data);
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* 更新notification状态
|
|
923
|
+
* @see https://api.seller.shopee.io/project/1288/interface/api/39504
|
|
924
|
+
* @param data updateList: UpdateNotificationList[]
|
|
925
|
+
*/
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
updateNotificationStatus(data) {
|
|
929
|
+
return service_awaiter(this, void 0, void 0, function* () {
|
|
930
|
+
return this.api.v1Request.post("/notification/status", data);
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* 获取notification未读消息,包括下面folder
|
|
935
|
+
* @see https://api.seller.shopee.io/project/1288/interface/api/39496
|
|
936
|
+
* @param params NotificationCountsRequest
|
|
937
|
+
*/
|
|
938
|
+
|
|
939
|
+
|
|
940
|
+
getNotificationCounts(params, config) {
|
|
941
|
+
return this.api.v1Request.get("/notification/count", {
|
|
942
|
+
skipError: config.skipError,
|
|
943
|
+
params
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* 拉取最新notification未读消息数量
|
|
948
|
+
* @see https://api.seller.shopee.io/project/1288/interface/api/39992
|
|
949
|
+
*/
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
pullNotificationStatus() {
|
|
953
|
+
return this.api.v1Request.get("/notification/poll_status", {
|
|
954
|
+
skipError: true
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* 获取group信息
|
|
959
|
+
* @see https://api.seller.shopee.io/project/1288/interface/api/40000
|
|
960
|
+
* @param params: NotificationGroupRequest
|
|
961
|
+
*/
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
getNotificationGroup(params) {
|
|
965
|
+
return this.api.v1Request.get("/notification/group", {
|
|
966
|
+
params: external_seller_base_["Base"].Utility.snakeCaseKeys(params)
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* 获取有权限的folder信息
|
|
971
|
+
* @see https://api.seller.shopee.io/project/1288/interface/api/42018
|
|
972
|
+
*/
|
|
973
|
+
|
|
974
|
+
|
|
975
|
+
getFolders(config) {
|
|
976
|
+
return this.api.v1Request.get("/notification/folder", {
|
|
977
|
+
skipError: config.skipError
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
}
|
|
982
|
+
// CONCATENATED MODULE: ./src/modules/notification/types.ts
|
|
983
|
+
var Status;
|
|
984
|
+
|
|
985
|
+
(function (Status) {
|
|
986
|
+
Status[Status["UNREAD"] = 1] = "UNREAD";
|
|
987
|
+
Status[Status["READ"] = 2] = "READ";
|
|
988
|
+
Status[Status["DELETE"] = 3] = "DELETE";
|
|
989
|
+
})(Status || (Status = {}));
|
|
990
|
+
// CONCATENATED MODULE: ./src/modules/notification/constants.ts
|
|
991
|
+
const FoldersConfig = [{
|
|
992
|
+
to: '/portal/notification/',
|
|
993
|
+
folderKey: undefined,
|
|
994
|
+
type: null,
|
|
995
|
+
category: null,
|
|
996
|
+
transifyKey: 'sp_pc_notification_label_all_notification',
|
|
997
|
+
trackKey: 'all_notifications',
|
|
998
|
+
trackImpressionKey: 'all_notifications'
|
|
999
|
+
}, {
|
|
1000
|
+
to: '/portal/notification/order-updates/',
|
|
1001
|
+
folderKey: 'order-updates',
|
|
1002
|
+
type: 1,
|
|
1003
|
+
category: [17, 26],
|
|
1004
|
+
transifyKey: 'sp_pc_notification_label_order_updates',
|
|
1005
|
+
trackKey: 'order_updates',
|
|
1006
|
+
trackImpressionKey: 'order_updates'
|
|
1007
|
+
}, {
|
|
1008
|
+
to: '/portal/notification/rating-updates/',
|
|
1009
|
+
folderKey: 'rating-updates',
|
|
1010
|
+
type: 2,
|
|
1011
|
+
category: 18,
|
|
1012
|
+
transifyKey: 'sp_pc_notification_label_rating_updates',
|
|
1013
|
+
trackKey: 'rating',
|
|
1014
|
+
trackImpressionKey: 'rating'
|
|
1015
|
+
}, {
|
|
1016
|
+
to: '/portal/notification/return-refund/',
|
|
1017
|
+
folderKey: 'return-refund',
|
|
1018
|
+
type: 3,
|
|
1019
|
+
category: 19,
|
|
1020
|
+
transifyKey: 'sp_pc_notification_label_return_and_refund_updates',
|
|
1021
|
+
trackKey: 'return_refund',
|
|
1022
|
+
trackImpressionKey: 'return_refund'
|
|
1023
|
+
}, {
|
|
1024
|
+
to: '/portal/notification/listing-updates/',
|
|
1025
|
+
folderKey: 'listing-updates',
|
|
1026
|
+
type: 4,
|
|
1027
|
+
category: [20, 27],
|
|
1028
|
+
transifyKey: 'sp_pc_notification_label_listing_updates',
|
|
1029
|
+
trackKey: 'listing',
|
|
1030
|
+
trackImpressionKey: 'listing'
|
|
1031
|
+
}, {
|
|
1032
|
+
to: '/portal/notification/sbs-updates/',
|
|
1033
|
+
folderKey: 'sbs-updates',
|
|
1034
|
+
type: 9,
|
|
1035
|
+
category: [15, 16],
|
|
1036
|
+
transifyKey: 'sp_pc_notification_label_sbs_updates',
|
|
1037
|
+
trackKey: 'sbs_updates',
|
|
1038
|
+
trackImpressionKey: 'sbs_updates'
|
|
1039
|
+
}, {
|
|
1040
|
+
to: '/portal/notification/wallet-updates/',
|
|
1041
|
+
folderKey: 'wallet-updates',
|
|
1042
|
+
type: 5,
|
|
1043
|
+
category: [21, 28],
|
|
1044
|
+
transifyKey: 'sp_pc_notification_label_wallet_updates',
|
|
1045
|
+
trackKey: 'seller_wallet',
|
|
1046
|
+
trackImpressionKey: 'seller_wallet'
|
|
1047
|
+
}, {
|
|
1048
|
+
to: '/portal/notification/marketing-center/',
|
|
1049
|
+
folderKey: 'marketing-center',
|
|
1050
|
+
type: 6,
|
|
1051
|
+
category: [9, 14, 22],
|
|
1052
|
+
transifyKey: 'sp_pc_notification_label_marketing_centre_updates',
|
|
1053
|
+
trackKey: 'marketing_center',
|
|
1054
|
+
trackImpressionKey: 'marketing_center'
|
|
1055
|
+
}, {
|
|
1056
|
+
to: '/portal/notification/performance/',
|
|
1057
|
+
folderKey: 'performance',
|
|
1058
|
+
type: 7,
|
|
1059
|
+
category: [23, 29],
|
|
1060
|
+
transifyKey: 'sp_pc_notification_label_performance_updates',
|
|
1061
|
+
trackKey: 'perfomrance',
|
|
1062
|
+
trackImpressionKey: 'perfomrance'
|
|
1063
|
+
}, {
|
|
1064
|
+
to: '/portal/notification/shopee-updates/',
|
|
1065
|
+
folderKey: 'shopee-updates',
|
|
1066
|
+
type: 8,
|
|
1067
|
+
category: [6, 24, 30, 31],
|
|
1068
|
+
transifyKey: 'sp_pc_notification_label_shopee_updates',
|
|
1069
|
+
trackKey: 'shopee_updates',
|
|
1070
|
+
trackImpressionKey: 'shopee_updates'
|
|
1071
|
+
}];
|
|
1072
|
+
const ActionTypes = {
|
|
1073
|
+
NEW_ORDER: 1,
|
|
1074
|
+
OUT_STOCK: 2,
|
|
1075
|
+
DUP_LOGIN: 3,
|
|
1076
|
+
INVALID_ITEM: 4,
|
|
1077
|
+
ORDER_PAID: 5,
|
|
1078
|
+
ORDER_COMPLETE: 7,
|
|
1079
|
+
CHAT_MSG: 8,
|
|
1080
|
+
NEW_ACTIVITY: 11,
|
|
1081
|
+
OFFER_STATUS: 12,
|
|
1082
|
+
NEW_ITEM: 14,
|
|
1083
|
+
ORDER_CANCEL: 15,
|
|
1084
|
+
BAN_ITEM: 16,
|
|
1085
|
+
ACCOUNT_BAN: 17,
|
|
1086
|
+
CHECKOUT_PAID: 18,
|
|
1087
|
+
RETURN_UPDATE: 19,
|
|
1088
|
+
CHECKOUT_CANCEL: 20,
|
|
1089
|
+
CHECKOUT_UPDATE: 21,
|
|
1090
|
+
ORDER_UPDATE: 22,
|
|
1091
|
+
EMAIL_VERIFIED: 23,
|
|
1092
|
+
ORDER_TOSHIP: 24,
|
|
1093
|
+
ORDER_TORECEIVE: 25,
|
|
1094
|
+
CHECKOUT_TOSHIP: 26,
|
|
1095
|
+
USERINFO_UPDATEED: 27,
|
|
1096
|
+
NEW_FEED: 28,
|
|
1097
|
+
SHOPINFO_UPDATED: 29,
|
|
1098
|
+
OUT_STOCK_VARIATION: 30,
|
|
1099
|
+
ACCOUNT_FROZEN: 31,
|
|
1100
|
+
ACCOUNT_UNFROZEN: 32,
|
|
1101
|
+
CHAT_UPDATE: 33,
|
|
1102
|
+
CART_UPDATE: 34,
|
|
1103
|
+
CHAT_CLEARED: 35,
|
|
1104
|
+
ACTION_REQUIRE_REMOVED: 36,
|
|
1105
|
+
CHAT_UNREAD: 37,
|
|
1106
|
+
// System Message notifications
|
|
1107
|
+
ACTION_SYSTEM_MESSAGE: 99,
|
|
1108
|
+
SELLER_PAY_CONFIRM: 100,
|
|
1109
|
+
BUYER_UNDERPAY: 101,
|
|
1110
|
+
BUYER_PAYER_VERI_FAIL: 102,
|
|
1111
|
+
BUYER_CHECKOUT_CANCEL_UNDERPAY: 103,
|
|
1112
|
+
SELLER_ORDER_CANCEL_NOPAY: 104,
|
|
1113
|
+
BUYER_CHECKOUT_CANCEL_PAY_VERI_FAIL: 105,
|
|
1114
|
+
BUYER_ORDER_CANCEL_NOPAY: 106,
|
|
1115
|
+
BUYER_BEFORE_ESCROW_RELEASE: 107,
|
|
1116
|
+
SELLER_ESCROW_EXTEND: 108,
|
|
1117
|
+
BUYER_ORDER_CONFIRM_REMINDER: 109,
|
|
1118
|
+
BUYER_ORDER_CANCEL_BANK: 110,
|
|
1119
|
+
BUYER_ORDER_CANCEL_CARD: 111,
|
|
1120
|
+
BUYER_REFUND_BANK: 112,
|
|
1121
|
+
BUYER_REFUND_CARD: 113,
|
|
1122
|
+
SELLER_RETURN_REQUEST: 114,
|
|
1123
|
+
SELLER_BEFORE_RELEASE_REFUND: 115,
|
|
1124
|
+
BUYER_DISPUTE: 116,
|
|
1125
|
+
NEED_PROOF: 117,
|
|
1126
|
+
SELLER_MEDIATION_RESULT: 118,
|
|
1127
|
+
BUYER_OVERPAID_BANK: 119,
|
|
1128
|
+
BUYER_NONRECEIPT_DISPUTE: 120,
|
|
1129
|
+
SELLER_BANK_INFO: 121,
|
|
1130
|
+
BUYER_REFUND_CREATED_BANK: 122,
|
|
1131
|
+
SELLER_ORDER_CANCEL_BY_BUYER: 123,
|
|
1132
|
+
BUYER_ORDER_SHIPPED: 124,
|
|
1133
|
+
BUYER_REFUND_CREATED_CARD: 125,
|
|
1134
|
+
SELLER_BANK_INFO_REMINDER: 126,
|
|
1135
|
+
BUYER_BANK_INFO_REMINDER: 127,
|
|
1136
|
+
BUYER_RETURN_APPROVED: 128,
|
|
1137
|
+
BUYER_PAY_CONFIRM: 129,
|
|
1138
|
+
BUYER_UNDERPAY_REMINDER: 130,
|
|
1139
|
+
BUYER_NOPAY_REMINDER: 131,
|
|
1140
|
+
SELLER_NEW_ORDER_ESCROW: 132,
|
|
1141
|
+
SELLER_NEW_ORDER_OFFLINE: 133,
|
|
1142
|
+
BUYER_BANNED_ITEM: 134,
|
|
1143
|
+
BUYER_BEFORE_ESCROW_RELEASE_EXTEND: 135,
|
|
1144
|
+
ORDER_COMPLETE_BANK: 136,
|
|
1145
|
+
ORDER_COMPLETE_NO_BANK: 137,
|
|
1146
|
+
SELLER_BANKINFO_REJECTED: 138,
|
|
1147
|
+
BUYER_BANKINFO_REJECTED: 139,
|
|
1148
|
+
SELLER_NONRECEIPT_RETURN_REQUEST: 140,
|
|
1149
|
+
BUYER_NONRECEIPT_RETURN_REQUEST: 141,
|
|
1150
|
+
BUYER_MEDIATION_RESULT: 142,
|
|
1151
|
+
BUYER_NOTRECEIVE_RETUERN_DISPUTE: 143,
|
|
1152
|
+
SELLER_NOTRECEIVE_RETUERN_DISPUTE: 144,
|
|
1153
|
+
BUYER_REFUND_CREATED_BT: 145,
|
|
1154
|
+
SELLER_ORDER_COMPLETE_OFFLINE: 146,
|
|
1155
|
+
PROMO_CODE_GENERATED: 147,
|
|
1156
|
+
CUSTOMIZED_ACTION: 148,
|
|
1157
|
+
USER_BANKINFO_REJECTED: 149,
|
|
1158
|
+
ORDER_CHANGE_OFFLINE_TO_ESCROW: 150,
|
|
1159
|
+
CUSTOMIZED_ACTION_PURE: 151,
|
|
1160
|
+
CUSTOMIZED_PUSHNOTI_PURE: 152,
|
|
1161
|
+
// add for logistics
|
|
1162
|
+
SELLER_NEW_ORDER_COD: 153,
|
|
1163
|
+
ORDER_CHANGE_OFFLINE_TO_COD: 154,
|
|
1164
|
+
BUYER_ORDER_COD_APPROVE: 155,
|
|
1165
|
+
SELLER_ORDER_COD_APPROVE: 156,
|
|
1166
|
+
BUYER_ORDER_COD_REJECT: 157,
|
|
1167
|
+
SELLER_ORDER_COD_REJECT: 158,
|
|
1168
|
+
BUYER_REJECT_COD_DELIVERY: 159,
|
|
1169
|
+
BUYER_ORDER_CANCEL_COD: 160,
|
|
1170
|
+
LOGISTICS_CONFIRMED_DELIVERY_BUYER: 161,
|
|
1171
|
+
LOGISTICS_CONFIRMED_DELIVERY_SELLER: 162,
|
|
1172
|
+
PICKUP_DEADLINE: 163,
|
|
1173
|
+
SELLER_ORDER_CANCEL_PICKUP_FAILED: 164,
|
|
1174
|
+
SELLER_REJECT_COD_DELIVERY: 165,
|
|
1175
|
+
BUYER_REJECT_NOCOD_DELIVERY: 166,
|
|
1176
|
+
SELLER_REJECT_NOCOD_DELIVERY: 167,
|
|
1177
|
+
PICKUP_REMINDER: 168,
|
|
1178
|
+
PICKUP_24HOURS: 169,
|
|
1179
|
+
PICKUP_THEDAY: 170,
|
|
1180
|
+
PICKUP_RETRY_BEFOREDEADLINE: 171,
|
|
1181
|
+
SHIPOUT_24HOUR: 172,
|
|
1182
|
+
SHIPOUT_DEADLINE: 173,
|
|
1183
|
+
BUYER_SHIPPINGFEE_REVISED: 174,
|
|
1184
|
+
BUYER_PICKUP_SUCCEED: 175,
|
|
1185
|
+
BUYER_ORDER_COD_CANCEL_PICKUP_FAILED: 176,
|
|
1186
|
+
BUYER_ORDER_NOCOD_CANCEL_PICKUP_FAILED: 177,
|
|
1187
|
+
PICKUP_ARRANGED: 178,
|
|
1188
|
+
SELLER_ORDER_CANCEL_ARRANGEPICKUP_FAIL: 179,
|
|
1189
|
+
BUYER_ORDER_CANCEL_ARRANGEPICKUP_FAIL: 180,
|
|
1190
|
+
SELLER_ARRANGEPICKUP_EXT_REMINDER: 181,
|
|
1191
|
+
SELLER_ARRANGEPICKUP_DEADLINE_REMINDER: 182,
|
|
1192
|
+
SHOP_DESCRIPTION_BANNED: 183,
|
|
1193
|
+
SHOP_COVERS_BANNED: 184,
|
|
1194
|
+
SELLER_INACTIVE_FIRST: 185,
|
|
1195
|
+
SELLER_INACTIVE_SECOND: 186,
|
|
1196
|
+
SELLER_PICKUP_COUNTER_CLOSE: 187,
|
|
1197
|
+
BUYER_TW711_DELIVERED_COUNTER: 188,
|
|
1198
|
+
SELLER_PAY_NOBANK_CONFIRM: 189,
|
|
1199
|
+
BUYER_TW711_DELIVERED_REMINDER: 190,
|
|
1200
|
+
SELLER_TW_COLLECT_NOBUYER: 191,
|
|
1201
|
+
BUYER_FM_DELIVERED_COUNTER: 192,
|
|
1202
|
+
SELLER_ORDER_CANCEL_AFTER_ESCROW: 193,
|
|
1203
|
+
BUYER_ORDER_CANCEL_AFTER_ESCROW: 194,
|
|
1204
|
+
BUYER_INDO_JOBRESUBMIT_WAYBILL: 195,
|
|
1205
|
+
SELLER_RESELECT_COUNTER_COMPLETED: 196,
|
|
1206
|
+
SELLER_DELIVERY_CODE_EXPIRED: 197,
|
|
1207
|
+
BUYER_DELIVERY_DELAYED_VOUCHER: 198,
|
|
1208
|
+
BUYER_RETURN_APPROVED_CARD: 199,
|
|
1209
|
+
CRM_SELLER_INACTIVE_SEVEN: 401,
|
|
1210
|
+
CRM_SELLER_INACTIVE_ELEVEN: 402,
|
|
1211
|
+
CRM_SELLER_INACTIVE_FORTEEN: 403,
|
|
1212
|
+
CRM_CHAT_REMINDER: 404,
|
|
1213
|
+
CRM_OFFER_REMINDER: 405,
|
|
1214
|
+
CRM_ORDER_REMINDER: 406,
|
|
1215
|
+
CRM_ORDER_COD_REMINDER: 407,
|
|
1216
|
+
BUYER_ORDER_CANCEL_NO_BANK: 408,
|
|
1217
|
+
BUYER_RETURN_APPROVED_NO_BA: 409,
|
|
1218
|
+
BUYER_COD_BANNED: 410,
|
|
1219
|
+
BUYER_COD_RELEASED: 411,
|
|
1220
|
+
SELLER_TW_TO_SHIP: 412,
|
|
1221
|
+
SELLER_TW_TO_DROP: 413,
|
|
1222
|
+
BUYER_ORDER_CANCEL_BY_BUYER: 414,
|
|
1223
|
+
SMART_GROUP_MESSAGE: 415,
|
|
1224
|
+
SELLER_ORDER_COMPLETE_RATING: 416,
|
|
1225
|
+
BUYER_ORDER_COMPLETE_RATING: 417,
|
|
1226
|
+
SELLER_RATING_3DAY: 418,
|
|
1227
|
+
BUYER_RATING_3DAY: 419,
|
|
1228
|
+
SELLER_RATING_BUYER_RATED: 420,
|
|
1229
|
+
BUYER_RATING_SELLER_RATED: 421,
|
|
1230
|
+
SELLER_VIEW_BOTH_RATED: 422,
|
|
1231
|
+
SELLER_VIEW_BUYER_RATED: 432,
|
|
1232
|
+
SELLER_VIEW_BUYER_CHANGED: 433,
|
|
1233
|
+
SELLER_CONFIRM_AUTO_REFUND: 434,
|
|
1234
|
+
SELLER_BE_CANCELORDER_REMINDER: 435,
|
|
1235
|
+
BUYER_REFUND_PAYOUT_CARD: 436,
|
|
1236
|
+
LOGISTICS_DELIVERY_FAILED_BUYER: 437,
|
|
1237
|
+
SELLER_RETURN_PICKUPCOUNTER_CLOSE: 438,
|
|
1238
|
+
SELLER_BE_AUTO_CANCEL: 439,
|
|
1239
|
+
DISPUTE_RATING_SUCC: 440,
|
|
1240
|
+
RATING_DISPUTED: 441,
|
|
1241
|
+
CRM_BUYER_CART: 442,
|
|
1242
|
+
CRM_BUYER_CART_STOCK: 443,
|
|
1243
|
+
CRM_BUYER_CART_DISCOUNT: 444,
|
|
1244
|
+
SELLER_FIRST_LISTING_TW: 445,
|
|
1245
|
+
HM_SELLER_ARRANGE_PICKUP: 446,
|
|
1246
|
+
HM_ORDER_AUTO_CANCEL: 447,
|
|
1247
|
+
HM_SELLER_REMINDER_TO_SHIP: 448,
|
|
1248
|
+
SELLER_ESCROW_RELEASED_ID_DAYS: 449,
|
|
1249
|
+
BUYER_PUSH_SELLER_SO_COD: 450,
|
|
1250
|
+
BUYER_PUSH_SELLER_SO_NONCOD: 451,
|
|
1251
|
+
BUYER_CAN_CANCEL_REMINDER_NONCOD: 452,
|
|
1252
|
+
BUYER_CAN_CANCEL_REMINDER_COD: 453,
|
|
1253
|
+
SELLER_RETURN_RESELECT_TW_711: 741,
|
|
1254
|
+
// trigger email & sms
|
|
1255
|
+
BUYER_OFFER_DECLINE: 200,
|
|
1256
|
+
BUYER_OFFER_ACCEPT: 201,
|
|
1257
|
+
SELLER_OFFER_NEW: 202,
|
|
1258
|
+
BUYER_PAY_CONFIRM_CARD: 203,
|
|
1259
|
+
BUYER_RETURN_REQUEST: 204,
|
|
1260
|
+
BUYER_PAY_CONFIRM_BANK: 206,
|
|
1261
|
+
ACCOUNT_DELETE: 207,
|
|
1262
|
+
PASSWORD_CHANGED: 208,
|
|
1263
|
+
BUYER_PAY_CHOOSE_BANK: 209,
|
|
1264
|
+
SELLER_ESCROW_RELEASED: 210,
|
|
1265
|
+
SELLER_OFFER_CANCEL: 211,
|
|
1266
|
+
SELLER_DISPUTE: 212,
|
|
1267
|
+
SELLER_NONRECEIPT_DISPUTE: 213,
|
|
1268
|
+
SELLER_ORDER_CANCEL: 214,
|
|
1269
|
+
SELLER_CONFIRM_RETURN: 215,
|
|
1270
|
+
SELLER_CANCEL_RETURN: 216,
|
|
1271
|
+
BUYER_PAY_CONFIRM_OFFLINE: 217,
|
|
1272
|
+
SELLER_FIRST_LISTING: 218,
|
|
1273
|
+
SELLER_PAY_CONFIRM_OFFLINE: 219,
|
|
1274
|
+
WEB_REGISTRATION: 220,
|
|
1275
|
+
SELLER_CONTACT_LOGISTICS_TW: 221,
|
|
1276
|
+
SELLER_ESCROW_RELEASED_ID: 222,
|
|
1277
|
+
ACTIVITY_FOLLOW_YOU: 300,
|
|
1278
|
+
ACTIVITY_AT_YOU_IN_COMMENT: 301,
|
|
1279
|
+
ACTIVITY_COMMENT_YOUR_ITEM: 302,
|
|
1280
|
+
ACTIVITY_CONTACT_REGISTERED: 303,
|
|
1281
|
+
ACTIVITY_ITEM_RATED: 304,
|
|
1282
|
+
ACTIVITY_CUSTOMIZED_ACTIVITY: 305,
|
|
1283
|
+
ACTIVITY_AT_YOU_IN_FEED_CMT: 306,
|
|
1284
|
+
ACTIVITY_COMMENT_YOUR_FEED: 307,
|
|
1285
|
+
// ACTIVITY_S_VIEW_BOTH_RATED: 308,
|
|
1286
|
+
ACTIVITY_B_VIEW_BOTH_RATED: 309,
|
|
1287
|
+
// ACTIVITY_S_VIEW_BUYER_RATED: 310,
|
|
1288
|
+
ACTIVITY_B_VIEW_SELLER_RATED: 311,
|
|
1289
|
+
// ACTIVITY_S_VIEW_BUYER_CHANGED: 312,
|
|
1290
|
+
ACTIVITY_B_VIEW_SELLER_CHANGED: 313,
|
|
1291
|
+
SELLER_PENALTY_POINT: 551,
|
|
1292
|
+
SELLER_PENALTY_TIER: 552,
|
|
1293
|
+
SELLER_PENALTY_POINT_REMOVE: 554,
|
|
1294
|
+
SELLER_BUYERCANCEL_REQUESTED: 520,
|
|
1295
|
+
SELLER_BUYERCANCEL_WITHDRAW: 521,
|
|
1296
|
+
SELLER_BUYERCANCEL_ACCEPT: 522,
|
|
1297
|
+
SHOP_FLASHSALE_CANCELLED: 1027,
|
|
1298
|
+
SHOP_FLASHSALE_PRODUCT_PROMOTED: 1028,
|
|
1299
|
+
SHOP_FLASHSALE_PRODUCT_REJECTED: 1029,
|
|
1300
|
+
SHOP_FLASHSALE_SHOP_REJECTED: 1030,
|
|
1301
|
+
SHOP_FLASHSALE_CANCELLED_SG: 1037,
|
|
1302
|
+
SHOP_FLASHSALE_PRODUCT_PROMOTED_SG: 1038,
|
|
1303
|
+
SHOP_FLASHSALE_PRODUCT_REJECTED_SG: 1039,
|
|
1304
|
+
SHOP_FLASHSALE_SHOP_REJECTED_SG: 1040,
|
|
1305
|
+
SHOP_FLASHSALE_CANCELLED_MY: 1041,
|
|
1306
|
+
SHOP_FLASHSALE_PRODUCT_PROMOTED_MY: 1042,
|
|
1307
|
+
SHOP_FLASHSALE_PRODUCT_REJECTED_MY: 1043,
|
|
1308
|
+
SHOP_FLASHSALE_SHOP_REJECTED_MY: 1044,
|
|
1309
|
+
BUYER_MEDIATION_RESULT_DRC: 1118,
|
|
1310
|
+
SELLER_MEDIATION_RESULT_DRC: 1119
|
|
1311
|
+
};
|
|
1312
|
+
const ActionRedirectTypes = {
|
|
1313
|
+
REDIRECT_NONE: 0,
|
|
1314
|
+
REDIRECT_ORDERS_DETAIL: 1,
|
|
1315
|
+
REDIRECT_MY_PRODUCTS: 2,
|
|
1316
|
+
REDIRECT_MY_INCOME: 3,
|
|
1317
|
+
REDIRECT_ORDERS_RETURNREFUND: 4,
|
|
1318
|
+
REDIRECT_ORDERS_CANCEL: 5,
|
|
1319
|
+
REDIRECT_OUTOF_STOCK: 6,
|
|
1320
|
+
// REDIRECT_REFUND_SELLERCANCEL: 7,
|
|
1321
|
+
REDIRECT_PURE_REFUND: 8,
|
|
1322
|
+
REDIRECT_NEW_WEB_PAGE: 10,
|
|
1323
|
+
REDIRECT_UPLOAD_RECEIPT_PAGE: 11,
|
|
1324
|
+
REDIRECT_SHOPING_CART: 12,
|
|
1325
|
+
REDIRECT_BUNCH_ORDERS_DETAIL: 13,
|
|
1326
|
+
// REDIRECT_BUY_PAGE: 14,
|
|
1327
|
+
// REDIRECT_CHAT_PAGE: 15,
|
|
1328
|
+
REDIRECT_ORDER_CHAT_PAGE: 16,
|
|
1329
|
+
// REDIRECT_PRODUCT_OFFER_CHAT_PAGE: 17,
|
|
1330
|
+
REDIRECT_RELATED_PRODUCT_PAGE: 18,
|
|
1331
|
+
REDIRECT_CREDIT_CARD_PAYMENT_PAGE: 19,
|
|
1332
|
+
REDIRECT_MY_WALLET: 20,
|
|
1333
|
+
REDIRECT_EDIT_SHOP_PROFILE: 21,
|
|
1334
|
+
REDIRECT_APP_PATH: 22,
|
|
1335
|
+
REDIRECT_MY_ACCOUNT: 23
|
|
1336
|
+
};
|
|
1337
|
+
const AppPath = {
|
|
1338
|
+
CHAT_LIST: 'chatList',
|
|
1339
|
+
MY_ACCOUNT: 'myAccount',
|
|
1340
|
+
EDIT_PROFILE: 'editProfile',
|
|
1341
|
+
SOCIAL_ACCOUNT: 'socialAccount',
|
|
1342
|
+
SETTINGS: 'settings',
|
|
1343
|
+
HOME_FEEDS: 'homeFeed',
|
|
1344
|
+
HOME: 'home',
|
|
1345
|
+
CHAT: 'chat',
|
|
1346
|
+
INCOME: 'income',
|
|
1347
|
+
SELLER_ASSISTANT: 'sellerAssistant',
|
|
1348
|
+
NOTIFICATION: 'notification',
|
|
1349
|
+
PENALTY: 'penalty'
|
|
1350
|
+
};
|
|
1351
|
+
const RedirectTypePreferred = [ActionRedirectTypes.REDIRECT_APP_PATH, ActionRedirectTypes.REDIRECT_BUNCH_ORDERS_DETAIL, ActionRedirectTypes.REDIRECT_PURE_REFUND];
|
|
1352
|
+
const ActionCategory = {
|
|
1353
|
+
ORDER_UPDATES: [17, 26],
|
|
1354
|
+
RATING: 18,
|
|
1355
|
+
RETURN_AND_REFUND: 19,
|
|
1356
|
+
LISTING_UPDATES: [20, 27],
|
|
1357
|
+
SBS_UPDATES: [15, 16],
|
|
1358
|
+
SELLER_WALLET: [21, 28],
|
|
1359
|
+
MARKETING_CENTER: [9, 14, 22],
|
|
1360
|
+
PERFORMANCE: [23, 29],
|
|
1361
|
+
SHOPEE_UPDATES: [6, 24, 30, 31]
|
|
1362
|
+
};
|
|
1363
|
+
const FoldersType = {
|
|
1364
|
+
ORDER_UPDATES: 1,
|
|
1365
|
+
RATING: 2,
|
|
1366
|
+
RETURN_AND_REFUND: 3,
|
|
1367
|
+
LISTING_UPDATES: 4,
|
|
1368
|
+
SELLER_WALLET: 5,
|
|
1369
|
+
MARKETING_CENTER: 6,
|
|
1370
|
+
PERFORMANCE: 7,
|
|
1371
|
+
SHOPEE_UPDATES: 8,
|
|
1372
|
+
SBS_UPDATES: 9
|
|
1373
|
+
};
|
|
1374
|
+
var NotiEventNames;
|
|
1375
|
+
|
|
1376
|
+
(function (NotiEventNames) {
|
|
1377
|
+
NotiEventNames["MarkAllHeaderNotiAsRead"] = "HeaderMarkAllAsRead";
|
|
1378
|
+
NotiEventNames["MarkAllNotiAsRead"] = "NotiMarkAllAsRead";
|
|
1379
|
+
NotiEventNames["MarkNotiAsRead"] = "MarkNotiAsRead";
|
|
1380
|
+
NotiEventNames["MarkHeaderNotiAsRead"] = "MarkHeaderNotiAsRead";
|
|
1381
|
+
NotiEventNames["NotiCountsChange"] = "NotiCountsChange";
|
|
1382
|
+
NotiEventNames["HeaderNotiCountsChange"] = "HeaderNotiCountsChange";
|
|
1383
|
+
})(NotiEventNames || (NotiEventNames = {}));
|
|
1384
|
+
// EXTERNAL MODULE: ./node_modules/big-integer/BigInteger.js
|
|
1385
|
+
var BigInteger = __webpack_require__("dAlA");
|
|
1386
|
+
var BigInteger_default = /*#__PURE__*/__webpack_require__.n(BigInteger);
|
|
1387
|
+
|
|
1388
|
+
// CONCATENATED MODULE: ./src/modules/notification/action.ts
|
|
1389
|
+
|
|
1390
|
+
|
|
1391
|
+
|
|
1392
|
+
function replaceUrl(url, action) {
|
|
1393
|
+
return url.replace('${PC_MALL_ORIGIN}', external_seller_base_["Base"].$instance.environment.pcMallOrigin).replace('${SELLER_ORIGIN}', external_seller_base_["Base"].$instance.environment.sellerOrigin).replace('${MALL_ORIGIN}', external_seller_base_["Base"].$instance.environment.mallOrigin).replace('${CHECKOUT_ID}', "".concat(action.idInfo.checkoutId)).replace('${ITEM_ID}', "".concat(action.idInfo.itemId)).replace('${BUYER_USER_ID}', "".concat(action.idInfo.userid)).replace('${ORDER_ID}', "".concat(action.idInfo.orderId)).replace('${SHOP_ID}', "".concat(action.idInfo.shopid)).replace('${RETURN_ID || REFUND_ID}', "".concat(action.idInfo.returnId || action.idInfo.refundId));
|
|
1394
|
+
}
|
|
1395
|
+
function clickable(action) {
|
|
1396
|
+
if (!!action.pcRedirectUrl) {
|
|
1397
|
+
return true;
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
const redirectType = action.actionRedirectType;
|
|
1401
|
+
|
|
1402
|
+
if (redirectType === ActionRedirectTypes.REDIRECT_NEW_WEB_PAGE) {
|
|
1403
|
+
// special case: penalty redirection
|
|
1404
|
+
if ([ActionTypes.SELLER_PENALTY_POINT, ActionTypes.SELLER_PENALTY_TIER, ActionTypes.SELLER_PENALTY_POINT_REMOVE].includes(action.actionType)) {
|
|
1405
|
+
return clickableByActionType(action);
|
|
1406
|
+
} // special case: bridge_cmd redirection
|
|
1407
|
+
|
|
1408
|
+
|
|
1409
|
+
if (action.actionRedirectUrl && !action.actionRedirectUrl.includes('bridge_cmd')) {
|
|
1410
|
+
return true;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
return clickableByActionType(action);
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
if (RedirectTypePreferred.includes(redirectType)) {
|
|
1417
|
+
return clickableByRedirectType(action);
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
let ret = clickableByActionType(action);
|
|
1421
|
+
|
|
1422
|
+
if (ret === false) {
|
|
1423
|
+
ret = clickableByRedirectType(action);
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
return ret;
|
|
1427
|
+
}
|
|
1428
|
+
function clickableByActionType(action) {
|
|
1429
|
+
if (action.actionTypeRedirectUrl) {
|
|
1430
|
+
return true;
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
if (Object.values(ActionTypes).includes(action.actionType)) {
|
|
1434
|
+
return;
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
return false;
|
|
1438
|
+
}
|
|
1439
|
+
function clickableByRedirectType(action) {
|
|
1440
|
+
if (action.actionRedirectType === ActionRedirectTypes.REDIRECT_ORDER_CHAT_PAGE || action.redirectActionTypeRedirectUrl) {
|
|
1441
|
+
return true;
|
|
1442
|
+
} else if (action.actionRedirectType === ActionRedirectTypes.REDIRECT_APP_PATH) {
|
|
1443
|
+
return clickableByAppPath(action);
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
function clickableByAppPath(action) {
|
|
1447
|
+
if (action.actionAppPath === AppPath.CHAT || action.appPathRedirectUrl) {
|
|
1448
|
+
return true;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
return false;
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
const getRedirectURL = url => {
|
|
1455
|
+
const isCB = external_seller_base_["Base"].$instance.environment.isCBSC || external_seller_base_["Base"].$instance.environment.isMainland;
|
|
1456
|
+
|
|
1457
|
+
if (!isCB) {
|
|
1458
|
+
return url;
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
try {
|
|
1462
|
+
const urlObject = new URL(url);
|
|
1463
|
+
const env = '(test|uat|staging|live-test|test-stable)?\\.?';
|
|
1464
|
+
|
|
1465
|
+
if (new RegExp("^mall\\.".concat(env, "shopee\\.")).test(urlObject.hostname)) {
|
|
1466
|
+
urlObject.hostname = new URL(external_seller_base_["Base"].$instance.environment.mallOrigin).hostname;
|
|
1467
|
+
} else if (new RegExp("^".concat(env, "shopee\\.")).test(urlObject.hostname)) {
|
|
1468
|
+
urlObject.hostname = new URL(external_seller_base_["Base"].$instance.environment.sellerOrigin).hostname;
|
|
1469
|
+
} else if (new RegExp("^(seller|banhang)\\.".concat(env, "shopee\\.")).test(urlObject.hostname)) {
|
|
1470
|
+
urlObject.hostname = new URL(external_seller_base_["Base"].$instance.environment.pcMallOrigin).hostname;
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
return urlObject.toString();
|
|
1474
|
+
} catch (e) {
|
|
1475
|
+
console.error('getRedirectURL', e);
|
|
1476
|
+
return url;
|
|
1477
|
+
}
|
|
1478
|
+
};
|
|
1479
|
+
|
|
1480
|
+
function redirect(action, chatProxyService) {
|
|
1481
|
+
if (!!action.pcRedirectUrl) {
|
|
1482
|
+
const url = getRedirectURL(action.pcRedirectUrl);
|
|
1483
|
+
window.open(url);
|
|
1484
|
+
return;
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
const redirectType = action.actionRedirectType;
|
|
1488
|
+
|
|
1489
|
+
if (redirectType === ActionRedirectTypes.REDIRECT_NEW_WEB_PAGE) {
|
|
1490
|
+
// special case: penalty redirection
|
|
1491
|
+
if ([ActionTypes.SELLER_PENALTY_POINT, ActionTypes.SELLER_PENALTY_TIER, ActionTypes.SELLER_PENALTY_POINT_REMOVE].includes(action.actionType)) {
|
|
1492
|
+
redirectByActionType(action);
|
|
1493
|
+
return;
|
|
1494
|
+
} // special case: bridge_cmd redirection
|
|
1495
|
+
|
|
1496
|
+
|
|
1497
|
+
if (action.actionRedirectUrl && !action.actionRedirectUrl.includes('bridge_cmd')) {
|
|
1498
|
+
const url = getRedirectURL(action.actionRedirectUrl);
|
|
1499
|
+
window.open(url);
|
|
1500
|
+
return;
|
|
1501
|
+
} else {
|
|
1502
|
+
if (action.actionTypeRedirectUrl) {
|
|
1503
|
+
window.open(replaceUrl(action.actionTypeRedirectUrl, action));
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
return;
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
if (RedirectTypePreferred.includes(action.actionRedirectType)) {
|
|
1511
|
+
return redirectByRedirectType(action, chatProxyService);
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
const ret = redirectByActionType(action);
|
|
1515
|
+
|
|
1516
|
+
if (ret === false) {
|
|
1517
|
+
redirectByRedirectType(action, chatProxyService);
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
function redirectByActionType(action) {
|
|
1522
|
+
if (action.actionTypeRedirectUrl) {
|
|
1523
|
+
return window.open(replaceUrl(action.actionTypeRedirectUrl, action));
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
if (Object.values(ActionTypes).includes(action.actionType)) {
|
|
1527
|
+
return;
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
return false;
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
function redirectByRedirectType(action, chatProxyService) {
|
|
1534
|
+
const {
|
|
1535
|
+
orderId,
|
|
1536
|
+
shopid,
|
|
1537
|
+
buyerId
|
|
1538
|
+
} = action.idInfo;
|
|
1539
|
+
|
|
1540
|
+
if (action.actionRedirectType === ActionRedirectTypes.REDIRECT_ORDER_CHAT_PAGE) {
|
|
1541
|
+
chatProxyService.startChatWithOrder(shopid, buyerId, orderId);
|
|
1542
|
+
} else if (action.actionRedirectType === ActionRedirectTypes.REDIRECT_APP_PATH) {
|
|
1543
|
+
redirectByAppPath(action, chatProxyService);
|
|
1544
|
+
} else if (action.redirectActionTypeRedirectUrl) {
|
|
1545
|
+
window.open(replaceUrl(action.redirectActionTypeRedirectUrl, action));
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
function redirectByAppPath(action, chatProxyService) {
|
|
1550
|
+
if (action.actionAppPath === AppPath.CHAT) {
|
|
1551
|
+
const {
|
|
1552
|
+
shopid,
|
|
1553
|
+
userid,
|
|
1554
|
+
buyerId,
|
|
1555
|
+
orderId
|
|
1556
|
+
} = action.idInfo;
|
|
1557
|
+
chatProxyService.startChatWithOrder(shopid, userid || buyerId, orderId);
|
|
1558
|
+
} else if (action.appPathRedirectUrl) {
|
|
1559
|
+
window.open(replaceUrl(action.appPathRedirectUrl, action));
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
function compileAction(action) {
|
|
1564
|
+
return {
|
|
1565
|
+
id: action.actionId,
|
|
1566
|
+
title: action.title,
|
|
1567
|
+
content: action.content,
|
|
1568
|
+
images: action.images,
|
|
1569
|
+
groupId: action.groupId,
|
|
1570
|
+
groupCount: action.groupCount,
|
|
1571
|
+
status: action.status,
|
|
1572
|
+
type: action.type,
|
|
1573
|
+
clickable: !!clickable(action),
|
|
1574
|
+
idInfo: action.idInfo,
|
|
1575
|
+
actionCate: action.actionCate,
|
|
1576
|
+
actionType: action.actionType,
|
|
1577
|
+
traceId: action.traceId,
|
|
1578
|
+
timestamp: action.timestamp,
|
|
1579
|
+
actionRedirectType: action.actionRedirectType,
|
|
1580
|
+
actionRedirectUrl: action.actionRedirectUrl,
|
|
1581
|
+
actionTypeRedirectUrl: action.actionTypeRedirectUrl,
|
|
1582
|
+
appPathRedirectUrl: action.appPathRedirectUrl,
|
|
1583
|
+
redirectActionTypeRedirectUrl: action.redirectActionTypeRedirectUrl,
|
|
1584
|
+
pcRedirectUrl: action.pcRedirectUrl,
|
|
1585
|
+
actionAppPath: action.actionAppPath,
|
|
1586
|
+
|
|
1587
|
+
action(action, chatProxyService) {
|
|
1588
|
+
if (!ActionCategory.MARKETING_CENTER.includes(action.actionCate) || action.actionRedirectUrl) {
|
|
1589
|
+
return redirect(action, chatProxyService);
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1595
|
+
function getMaxActionId(notificationList) {
|
|
1596
|
+
const actionIds = notificationList.map(item => BigInteger_default()(item.id));
|
|
1597
|
+
return actionIds.reduce((prev, next) => {
|
|
1598
|
+
if (prev.compareTo(next) < 0) {
|
|
1599
|
+
return next;
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
return prev;
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1605
|
+
// CONCATENATED MODULE: ./src/modules/notification/index.ts
|
|
1606
|
+
|
|
1607
|
+
|
|
1608
|
+
|
|
1609
|
+
|
|
1610
|
+
// CONCATENATED MODULE: ./src/modules/index.ts
|
|
1611
|
+
|
|
1612
|
+
|
|
1613
|
+
|
|
1614
|
+
|
|
1615
|
+
|
|
1616
|
+
|
|
1617
|
+
|
|
1618
|
+
|
|
1619
|
+
// CONCATENATED MODULE: ./src/index.ts
|
|
1620
|
+
/* concated harmony reexport CommonServiceWithSip */__webpack_require__.d(__webpack_exports__, "CommonServiceWithSip", function() { return service_CommonServiceWithSip; });
|
|
1621
|
+
/* concated harmony reexport CommonListResponse */__webpack_require__.d(__webpack_exports__, "CommonListResponse", function() { return types["CommonListResponse"]; });
|
|
1622
|
+
/* concated harmony reexport BatchI */__webpack_require__.d(__webpack_exports__, "BatchI", function() { return types["BatchI"]; });
|
|
1623
|
+
/* concated harmony reexport SipGlobalService */__webpack_require__.d(__webpack_exports__, "SipGlobalService", function() { return service_SipGlobalService; });
|
|
1624
|
+
/* concated harmony reexport SipOrder */__webpack_require__.d(__webpack_exports__, "SipOrder", function() { return sip_types["SipOrder"]; });
|
|
1625
|
+
/* concated harmony reexport SipOrderItem */__webpack_require__.d(__webpack_exports__, "SipOrderItem", function() { return sip_types["SipOrderItem"]; });
|
|
1626
|
+
/* concated harmony reexport SipOrderResponse */__webpack_require__.d(__webpack_exports__, "SipOrderResponse", function() { return sip_types["SipOrderResponse"]; });
|
|
1627
|
+
/* concated harmony reexport OtpService */__webpack_require__.d(__webpack_exports__, "OtpService", function() { return service_OtpService; });
|
|
1628
|
+
/* concated harmony reexport OtpSeed */__webpack_require__.d(__webpack_exports__, "OtpSeed", function() { return OtpSeed; });
|
|
1629
|
+
/* concated harmony reexport OtpVerifyData */__webpack_require__.d(__webpack_exports__, "OtpVerifyData", function() { return otp_types["OtpVerifyData"]; });
|
|
1630
|
+
/* concated harmony reexport UploadService */__webpack_require__.d(__webpack_exports__, "UploadService", function() { return service_UploadService; });
|
|
1631
|
+
/* concated harmony reexport UploadOptions */__webpack_require__.d(__webpack_exports__, "UploadOptions", function() { return upload_types["UploadOptions"]; });
|
|
1632
|
+
/* concated harmony reexport UploadVideoData */__webpack_require__.d(__webpack_exports__, "UploadVideoData", function() { return upload_types["UploadVideoData"]; });
|
|
1633
|
+
/* concated harmony reexport ReportService */__webpack_require__.d(__webpack_exports__, "ReportService", function() { return service_ReportService; });
|
|
1634
|
+
/* concated harmony reexport FileTypeConfig */__webpack_require__.d(__webpack_exports__, "FileTypeConfig", function() { return FileTypeConfig; });
|
|
1635
|
+
/* concated harmony reexport ReportStatus */__webpack_require__.d(__webpack_exports__, "ReportStatus", function() { return ReportStatus; });
|
|
1636
|
+
/* concated harmony reexport downloadBlobData */__webpack_require__.d(__webpack_exports__, "downloadBlobData", function() { return downloadBlobData; });
|
|
1637
|
+
/* concated harmony reexport parseBlobJsonResponse */__webpack_require__.d(__webpack_exports__, "parseBlobJsonResponse", function() { return parseBlobJsonResponse; });
|
|
1638
|
+
/* concated harmony reexport Report */__webpack_require__.d(__webpack_exports__, "Report", function() { return report_types["Report"]; });
|
|
1639
|
+
/* concated harmony reexport ReportListParams */__webpack_require__.d(__webpack_exports__, "ReportListParams", function() { return report_types["ReportListParams"]; });
|
|
1640
|
+
/* concated harmony reexport ReportListResponse */__webpack_require__.d(__webpack_exports__, "ReportListResponse", function() { return report_types["ReportListResponse"]; });
|
|
1641
|
+
/* concated harmony reexport CollectionService */__webpack_require__.d(__webpack_exports__, "CollectionService", function() { return service_CollectionService; });
|
|
1642
|
+
/* concated harmony reexport Collection */__webpack_require__.d(__webpack_exports__, "Collection", function() { return collection_types["Collection"]; });
|
|
1643
|
+
/* concated harmony reexport PageActiveCollectionsParams */__webpack_require__.d(__webpack_exports__, "PageActiveCollectionsParams", function() { return collection_types["PageActiveCollectionsParams"]; });
|
|
1644
|
+
/* concated harmony reexport PageActiveCollectionsResponse */__webpack_require__.d(__webpack_exports__, "PageActiveCollectionsResponse", function() { return collection_types["PageActiveCollectionsResponse"]; });
|
|
1645
|
+
/* concated harmony reexport CollectionListResponse */__webpack_require__.d(__webpack_exports__, "CollectionListResponse", function() { return collection_types["CollectionListResponse"]; });
|
|
1646
|
+
/* concated harmony reexport CollectionUpdateData */__webpack_require__.d(__webpack_exports__, "CollectionUpdateData", function() { return collection_types["CollectionUpdateData"]; });
|
|
1647
|
+
/* concated harmony reexport FeedbackService */__webpack_require__.d(__webpack_exports__, "FeedbackService", function() { return service_FeedbackService; });
|
|
1648
|
+
/* concated harmony reexport Feedback */__webpack_require__.d(__webpack_exports__, "Feedback", function() { return feedback_types["Feedback"]; });
|
|
1649
|
+
/* concated harmony reexport FeedbackClassification */__webpack_require__.d(__webpack_exports__, "FeedbackClassification", function() { return feedback_types["FeedbackClassification"]; });
|
|
1650
|
+
/* concated harmony reexport FeedbackSubmitPage */__webpack_require__.d(__webpack_exports__, "FeedbackSubmitPage", function() { return feedback_types["FeedbackSubmitPage"]; });
|
|
1651
|
+
/* concated harmony reexport NotificationService */__webpack_require__.d(__webpack_exports__, "NotificationService", function() { return service_NotificationService; });
|
|
1652
|
+
/* concated harmony reexport CompiledNotification */__webpack_require__.d(__webpack_exports__, "CompiledNotification", function() { return /* Cannot get final name for export "CompiledNotification" in "./src/modules/notification/types.ts" (known exports: Status, known reexports: ) */ undefined; });
|
|
1653
|
+
/* concated harmony reexport Notification */__webpack_require__.d(__webpack_exports__, "Notification", function() { return /* Cannot get final name for export "Notification" in "./src/modules/notification/types.ts" (known exports: Status, known reexports: ) */ undefined; });
|
|
1654
|
+
/* concated harmony reexport Counts */__webpack_require__.d(__webpack_exports__, "Counts", function() { return /* Cannot get final name for export "Counts" in "./src/modules/notification/types.ts" (known exports: Status, known reexports: ) */ undefined; });
|
|
1655
|
+
/* concated harmony reexport Status */__webpack_require__.d(__webpack_exports__, "Status", function() { return Status; });
|
|
1656
|
+
/* concated harmony reexport NotificationGroupRequest */__webpack_require__.d(__webpack_exports__, "NotificationGroupRequest", function() { return /* Cannot get final name for export "NotificationGroupRequest" in "./src/modules/notification/types.ts" (known exports: Status, known reexports: ) */ undefined; });
|
|
1657
|
+
/* concated harmony reexport UpdateNotificationList */__webpack_require__.d(__webpack_exports__, "UpdateNotificationList", function() { return /* Cannot get final name for export "UpdateNotificationList" in "./src/modules/notification/types.ts" (known exports: Status, known reexports: ) */ undefined; });
|
|
1658
|
+
/* concated harmony reexport NotificationRequest */__webpack_require__.d(__webpack_exports__, "NotificationRequest", function() { return /* Cannot get final name for export "NotificationRequest" in "./src/modules/notification/types.ts" (known exports: Status, known reexports: ) */ undefined; });
|
|
1659
|
+
/* concated harmony reexport TrackData */__webpack_require__.d(__webpack_exports__, "TrackData", function() { return /* Cannot get final name for export "TrackData" in "./src/modules/notification/types.ts" (known exports: Status, known reexports: ) */ undefined; });
|
|
1660
|
+
/* concated harmony reexport FoldersConfig */__webpack_require__.d(__webpack_exports__, "FoldersConfig", function() { return FoldersConfig; });
|
|
1661
|
+
/* concated harmony reexport ActionCategory */__webpack_require__.d(__webpack_exports__, "ActionCategory", function() { return ActionCategory; });
|
|
1662
|
+
/* concated harmony reexport FoldersType */__webpack_require__.d(__webpack_exports__, "FoldersType", function() { return FoldersType; });
|
|
1663
|
+
/* concated harmony reexport compileAction */__webpack_require__.d(__webpack_exports__, "compileAction", function() { return compileAction; });
|
|
1664
|
+
/* concated harmony reexport getMaxActionId */__webpack_require__.d(__webpack_exports__, "getMaxActionId", function() { return getMaxActionId; });
|
|
1665
|
+
/* concated harmony reexport NotiEventNames */__webpack_require__.d(__webpack_exports__, "NotiEventNames", function() { return NotiEventNames; });
|
|
1666
|
+
/**
|
|
1667
|
+
* 仅仅用于类型检查
|
|
1668
|
+
*/
|
|
1669
|
+
|
|
1670
|
+
|
|
1671
|
+
|
|
1672
|
+
/***/ }),
|
|
1673
|
+
|
|
1674
|
+
/***/ "5KIN":
|
|
1675
|
+
/***/ (function(module, exports) {
|
|
1676
|
+
|
|
1677
|
+
|
|
1678
|
+
|
|
1679
|
+
/***/ }),
|
|
1680
|
+
|
|
1681
|
+
/***/ "6Xvj":
|
|
1682
|
+
/***/ (function(module, exports) {
|
|
1683
|
+
|
|
1684
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__6Xvj__;
|
|
1685
|
+
|
|
1686
|
+
/***/ }),
|
|
1687
|
+
|
|
1688
|
+
/***/ "O28r":
|
|
1689
|
+
/***/ (function(module, exports) {
|
|
1690
|
+
|
|
1691
|
+
|
|
1692
|
+
|
|
1693
|
+
/***/ }),
|
|
1694
|
+
|
|
1695
|
+
/***/ "UJjY":
|
|
1696
|
+
/***/ (function(module, exports) {
|
|
1697
|
+
|
|
1698
|
+
|
|
1699
|
+
|
|
1700
|
+
/***/ }),
|
|
1701
|
+
|
|
1702
|
+
/***/ "ZF4U":
|
|
1703
|
+
/***/ (function(module, exports) {
|
|
1704
|
+
|
|
1705
|
+
|
|
1706
|
+
|
|
1707
|
+
/***/ }),
|
|
1708
|
+
|
|
1709
|
+
/***/ "dAlA":
|
|
1710
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
1711
|
+
|
|
1712
|
+
/* WEBPACK VAR INJECTION */(function(module) {var __WEBPACK_AMD_DEFINE_RESULT__;var bigInt = (function (undefined) {
|
|
1713
|
+
"use strict";
|
|
1714
|
+
|
|
1715
|
+
var BASE = 1e7,
|
|
1716
|
+
LOG_BASE = 7,
|
|
1717
|
+
MAX_INT = 9007199254740992,
|
|
1718
|
+
MAX_INT_ARR = smallToArray(MAX_INT),
|
|
1719
|
+
DEFAULT_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
1720
|
+
|
|
1721
|
+
var supportsNativeBigInt = typeof BigInt === "function";
|
|
1722
|
+
|
|
1723
|
+
function Integer(v, radix, alphabet, caseSensitive) {
|
|
1724
|
+
if (typeof v === "undefined") return Integer[0];
|
|
1725
|
+
if (typeof radix !== "undefined") return +radix === 10 && !alphabet ? parseValue(v) : parseBase(v, radix, alphabet, caseSensitive);
|
|
1726
|
+
return parseValue(v);
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
function BigInteger(value, sign) {
|
|
1730
|
+
this.value = value;
|
|
1731
|
+
this.sign = sign;
|
|
1732
|
+
this.isSmall = false;
|
|
1733
|
+
}
|
|
1734
|
+
BigInteger.prototype = Object.create(Integer.prototype);
|
|
1735
|
+
|
|
1736
|
+
function SmallInteger(value) {
|
|
1737
|
+
this.value = value;
|
|
1738
|
+
this.sign = value < 0;
|
|
1739
|
+
this.isSmall = true;
|
|
1740
|
+
}
|
|
1741
|
+
SmallInteger.prototype = Object.create(Integer.prototype);
|
|
1742
|
+
|
|
1743
|
+
function NativeBigInt(value) {
|
|
1744
|
+
this.value = value;
|
|
1745
|
+
}
|
|
1746
|
+
NativeBigInt.prototype = Object.create(Integer.prototype);
|
|
1747
|
+
|
|
1748
|
+
function isPrecise(n) {
|
|
1749
|
+
return -MAX_INT < n && n < MAX_INT;
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
function smallToArray(n) { // For performance reasons doesn't reference BASE, need to change this function if BASE changes
|
|
1753
|
+
if (n < 1e7)
|
|
1754
|
+
return [n];
|
|
1755
|
+
if (n < 1e14)
|
|
1756
|
+
return [n % 1e7, Math.floor(n / 1e7)];
|
|
1757
|
+
return [n % 1e7, Math.floor(n / 1e7) % 1e7, Math.floor(n / 1e14)];
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
function arrayToSmall(arr) { // If BASE changes this function may need to change
|
|
1761
|
+
trim(arr);
|
|
1762
|
+
var length = arr.length;
|
|
1763
|
+
if (length < 4 && compareAbs(arr, MAX_INT_ARR) < 0) {
|
|
1764
|
+
switch (length) {
|
|
1765
|
+
case 0: return 0;
|
|
1766
|
+
case 1: return arr[0];
|
|
1767
|
+
case 2: return arr[0] + arr[1] * BASE;
|
|
1768
|
+
default: return arr[0] + (arr[1] + arr[2] * BASE) * BASE;
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
return arr;
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
function trim(v) {
|
|
1775
|
+
var i = v.length;
|
|
1776
|
+
while (v[--i] === 0);
|
|
1777
|
+
v.length = i + 1;
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
function createArray(length) { // function shamelessly stolen from Yaffle's library https://github.com/Yaffle/BigInteger
|
|
1781
|
+
var x = new Array(length);
|
|
1782
|
+
var i = -1;
|
|
1783
|
+
while (++i < length) {
|
|
1784
|
+
x[i] = 0;
|
|
1785
|
+
}
|
|
1786
|
+
return x;
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
function truncate(n) {
|
|
1790
|
+
if (n > 0) return Math.floor(n);
|
|
1791
|
+
return Math.ceil(n);
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
function add(a, b) { // assumes a and b are arrays with a.length >= b.length
|
|
1795
|
+
var l_a = a.length,
|
|
1796
|
+
l_b = b.length,
|
|
1797
|
+
r = new Array(l_a),
|
|
1798
|
+
carry = 0,
|
|
1799
|
+
base = BASE,
|
|
1800
|
+
sum, i;
|
|
1801
|
+
for (i = 0; i < l_b; i++) {
|
|
1802
|
+
sum = a[i] + b[i] + carry;
|
|
1803
|
+
carry = sum >= base ? 1 : 0;
|
|
1804
|
+
r[i] = sum - carry * base;
|
|
1805
|
+
}
|
|
1806
|
+
while (i < l_a) {
|
|
1807
|
+
sum = a[i] + carry;
|
|
1808
|
+
carry = sum === base ? 1 : 0;
|
|
1809
|
+
r[i++] = sum - carry * base;
|
|
1810
|
+
}
|
|
1811
|
+
if (carry > 0) r.push(carry);
|
|
1812
|
+
return r;
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
function addAny(a, b) {
|
|
1816
|
+
if (a.length >= b.length) return add(a, b);
|
|
1817
|
+
return add(b, a);
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
function addSmall(a, carry) { // assumes a is array, carry is number with 0 <= carry < MAX_INT
|
|
1821
|
+
var l = a.length,
|
|
1822
|
+
r = new Array(l),
|
|
1823
|
+
base = BASE,
|
|
1824
|
+
sum, i;
|
|
1825
|
+
for (i = 0; i < l; i++) {
|
|
1826
|
+
sum = a[i] - base + carry;
|
|
1827
|
+
carry = Math.floor(sum / base);
|
|
1828
|
+
r[i] = sum - carry * base;
|
|
1829
|
+
carry += 1;
|
|
1830
|
+
}
|
|
1831
|
+
while (carry > 0) {
|
|
1832
|
+
r[i++] = carry % base;
|
|
1833
|
+
carry = Math.floor(carry / base);
|
|
1834
|
+
}
|
|
1835
|
+
return r;
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
BigInteger.prototype.add = function (v) {
|
|
1839
|
+
var n = parseValue(v);
|
|
1840
|
+
if (this.sign !== n.sign) {
|
|
1841
|
+
return this.subtract(n.negate());
|
|
1842
|
+
}
|
|
1843
|
+
var a = this.value, b = n.value;
|
|
1844
|
+
if (n.isSmall) {
|
|
1845
|
+
return new BigInteger(addSmall(a, Math.abs(b)), this.sign);
|
|
1846
|
+
}
|
|
1847
|
+
return new BigInteger(addAny(a, b), this.sign);
|
|
1848
|
+
};
|
|
1849
|
+
BigInteger.prototype.plus = BigInteger.prototype.add;
|
|
1850
|
+
|
|
1851
|
+
SmallInteger.prototype.add = function (v) {
|
|
1852
|
+
var n = parseValue(v);
|
|
1853
|
+
var a = this.value;
|
|
1854
|
+
if (a < 0 !== n.sign) {
|
|
1855
|
+
return this.subtract(n.negate());
|
|
1856
|
+
}
|
|
1857
|
+
var b = n.value;
|
|
1858
|
+
if (n.isSmall) {
|
|
1859
|
+
if (isPrecise(a + b)) return new SmallInteger(a + b);
|
|
1860
|
+
b = smallToArray(Math.abs(b));
|
|
1861
|
+
}
|
|
1862
|
+
return new BigInteger(addSmall(b, Math.abs(a)), a < 0);
|
|
1863
|
+
};
|
|
1864
|
+
SmallInteger.prototype.plus = SmallInteger.prototype.add;
|
|
1865
|
+
|
|
1866
|
+
NativeBigInt.prototype.add = function (v) {
|
|
1867
|
+
return new NativeBigInt(this.value + parseValue(v).value);
|
|
1868
|
+
}
|
|
1869
|
+
NativeBigInt.prototype.plus = NativeBigInt.prototype.add;
|
|
1870
|
+
|
|
1871
|
+
function subtract(a, b) { // assumes a and b are arrays with a >= b
|
|
1872
|
+
var a_l = a.length,
|
|
1873
|
+
b_l = b.length,
|
|
1874
|
+
r = new Array(a_l),
|
|
1875
|
+
borrow = 0,
|
|
1876
|
+
base = BASE,
|
|
1877
|
+
i, difference;
|
|
1878
|
+
for (i = 0; i < b_l; i++) {
|
|
1879
|
+
difference = a[i] - borrow - b[i];
|
|
1880
|
+
if (difference < 0) {
|
|
1881
|
+
difference += base;
|
|
1882
|
+
borrow = 1;
|
|
1883
|
+
} else borrow = 0;
|
|
1884
|
+
r[i] = difference;
|
|
1885
|
+
}
|
|
1886
|
+
for (i = b_l; i < a_l; i++) {
|
|
1887
|
+
difference = a[i] - borrow;
|
|
1888
|
+
if (difference < 0) difference += base;
|
|
1889
|
+
else {
|
|
1890
|
+
r[i++] = difference;
|
|
1891
|
+
break;
|
|
1892
|
+
}
|
|
1893
|
+
r[i] = difference;
|
|
1894
|
+
}
|
|
1895
|
+
for (; i < a_l; i++) {
|
|
1896
|
+
r[i] = a[i];
|
|
1897
|
+
}
|
|
1898
|
+
trim(r);
|
|
1899
|
+
return r;
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
function subtractAny(a, b, sign) {
|
|
1903
|
+
var value;
|
|
1904
|
+
if (compareAbs(a, b) >= 0) {
|
|
1905
|
+
value = subtract(a, b);
|
|
1906
|
+
} else {
|
|
1907
|
+
value = subtract(b, a);
|
|
1908
|
+
sign = !sign;
|
|
1909
|
+
}
|
|
1910
|
+
value = arrayToSmall(value);
|
|
1911
|
+
if (typeof value === "number") {
|
|
1912
|
+
if (sign) value = -value;
|
|
1913
|
+
return new SmallInteger(value);
|
|
1914
|
+
}
|
|
1915
|
+
return new BigInteger(value, sign);
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
function subtractSmall(a, b, sign) { // assumes a is array, b is number with 0 <= b < MAX_INT
|
|
1919
|
+
var l = a.length,
|
|
1920
|
+
r = new Array(l),
|
|
1921
|
+
carry = -b,
|
|
1922
|
+
base = BASE,
|
|
1923
|
+
i, difference;
|
|
1924
|
+
for (i = 0; i < l; i++) {
|
|
1925
|
+
difference = a[i] + carry;
|
|
1926
|
+
carry = Math.floor(difference / base);
|
|
1927
|
+
difference %= base;
|
|
1928
|
+
r[i] = difference < 0 ? difference + base : difference;
|
|
1929
|
+
}
|
|
1930
|
+
r = arrayToSmall(r);
|
|
1931
|
+
if (typeof r === "number") {
|
|
1932
|
+
if (sign) r = -r;
|
|
1933
|
+
return new SmallInteger(r);
|
|
1934
|
+
} return new BigInteger(r, sign);
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
BigInteger.prototype.subtract = function (v) {
|
|
1938
|
+
var n = parseValue(v);
|
|
1939
|
+
if (this.sign !== n.sign) {
|
|
1940
|
+
return this.add(n.negate());
|
|
1941
|
+
}
|
|
1942
|
+
var a = this.value, b = n.value;
|
|
1943
|
+
if (n.isSmall)
|
|
1944
|
+
return subtractSmall(a, Math.abs(b), this.sign);
|
|
1945
|
+
return subtractAny(a, b, this.sign);
|
|
1946
|
+
};
|
|
1947
|
+
BigInteger.prototype.minus = BigInteger.prototype.subtract;
|
|
1948
|
+
|
|
1949
|
+
SmallInteger.prototype.subtract = function (v) {
|
|
1950
|
+
var n = parseValue(v);
|
|
1951
|
+
var a = this.value;
|
|
1952
|
+
if (a < 0 !== n.sign) {
|
|
1953
|
+
return this.add(n.negate());
|
|
1954
|
+
}
|
|
1955
|
+
var b = n.value;
|
|
1956
|
+
if (n.isSmall) {
|
|
1957
|
+
return new SmallInteger(a - b);
|
|
1958
|
+
}
|
|
1959
|
+
return subtractSmall(b, Math.abs(a), a >= 0);
|
|
1960
|
+
};
|
|
1961
|
+
SmallInteger.prototype.minus = SmallInteger.prototype.subtract;
|
|
1962
|
+
|
|
1963
|
+
NativeBigInt.prototype.subtract = function (v) {
|
|
1964
|
+
return new NativeBigInt(this.value - parseValue(v).value);
|
|
1965
|
+
}
|
|
1966
|
+
NativeBigInt.prototype.minus = NativeBigInt.prototype.subtract;
|
|
1967
|
+
|
|
1968
|
+
BigInteger.prototype.negate = function () {
|
|
1969
|
+
return new BigInteger(this.value, !this.sign);
|
|
1970
|
+
};
|
|
1971
|
+
SmallInteger.prototype.negate = function () {
|
|
1972
|
+
var sign = this.sign;
|
|
1973
|
+
var small = new SmallInteger(-this.value);
|
|
1974
|
+
small.sign = !sign;
|
|
1975
|
+
return small;
|
|
1976
|
+
};
|
|
1977
|
+
NativeBigInt.prototype.negate = function () {
|
|
1978
|
+
return new NativeBigInt(-this.value);
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
BigInteger.prototype.abs = function () {
|
|
1982
|
+
return new BigInteger(this.value, false);
|
|
1983
|
+
};
|
|
1984
|
+
SmallInteger.prototype.abs = function () {
|
|
1985
|
+
return new SmallInteger(Math.abs(this.value));
|
|
1986
|
+
};
|
|
1987
|
+
NativeBigInt.prototype.abs = function () {
|
|
1988
|
+
return new NativeBigInt(this.value >= 0 ? this.value : -this.value);
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
|
|
1992
|
+
function multiplyLong(a, b) {
|
|
1993
|
+
var a_l = a.length,
|
|
1994
|
+
b_l = b.length,
|
|
1995
|
+
l = a_l + b_l,
|
|
1996
|
+
r = createArray(l),
|
|
1997
|
+
base = BASE,
|
|
1998
|
+
product, carry, i, a_i, b_j;
|
|
1999
|
+
for (i = 0; i < a_l; ++i) {
|
|
2000
|
+
a_i = a[i];
|
|
2001
|
+
for (var j = 0; j < b_l; ++j) {
|
|
2002
|
+
b_j = b[j];
|
|
2003
|
+
product = a_i * b_j + r[i + j];
|
|
2004
|
+
carry = Math.floor(product / base);
|
|
2005
|
+
r[i + j] = product - carry * base;
|
|
2006
|
+
r[i + j + 1] += carry;
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
trim(r);
|
|
2010
|
+
return r;
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
function multiplySmall(a, b) { // assumes a is array, b is number with |b| < BASE
|
|
2014
|
+
var l = a.length,
|
|
2015
|
+
r = new Array(l),
|
|
2016
|
+
base = BASE,
|
|
2017
|
+
carry = 0,
|
|
2018
|
+
product, i;
|
|
2019
|
+
for (i = 0; i < l; i++) {
|
|
2020
|
+
product = a[i] * b + carry;
|
|
2021
|
+
carry = Math.floor(product / base);
|
|
2022
|
+
r[i] = product - carry * base;
|
|
2023
|
+
}
|
|
2024
|
+
while (carry > 0) {
|
|
2025
|
+
r[i++] = carry % base;
|
|
2026
|
+
carry = Math.floor(carry / base);
|
|
2027
|
+
}
|
|
2028
|
+
return r;
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
function shiftLeft(x, n) {
|
|
2032
|
+
var r = [];
|
|
2033
|
+
while (n-- > 0) r.push(0);
|
|
2034
|
+
return r.concat(x);
|
|
2035
|
+
}
|
|
2036
|
+
|
|
2037
|
+
function multiplyKaratsuba(x, y) {
|
|
2038
|
+
var n = Math.max(x.length, y.length);
|
|
2039
|
+
|
|
2040
|
+
if (n <= 30) return multiplyLong(x, y);
|
|
2041
|
+
n = Math.ceil(n / 2);
|
|
2042
|
+
|
|
2043
|
+
var b = x.slice(n),
|
|
2044
|
+
a = x.slice(0, n),
|
|
2045
|
+
d = y.slice(n),
|
|
2046
|
+
c = y.slice(0, n);
|
|
2047
|
+
|
|
2048
|
+
var ac = multiplyKaratsuba(a, c),
|
|
2049
|
+
bd = multiplyKaratsuba(b, d),
|
|
2050
|
+
abcd = multiplyKaratsuba(addAny(a, b), addAny(c, d));
|
|
2051
|
+
|
|
2052
|
+
var product = addAny(addAny(ac, shiftLeft(subtract(subtract(abcd, ac), bd), n)), shiftLeft(bd, 2 * n));
|
|
2053
|
+
trim(product);
|
|
2054
|
+
return product;
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
// The following function is derived from a surface fit of a graph plotting the performance difference
|
|
2058
|
+
// between long multiplication and karatsuba multiplication versus the lengths of the two arrays.
|
|
2059
|
+
function useKaratsuba(l1, l2) {
|
|
2060
|
+
return -0.012 * l1 - 0.012 * l2 + 0.000015 * l1 * l2 > 0;
|
|
2061
|
+
}
|
|
2062
|
+
|
|
2063
|
+
BigInteger.prototype.multiply = function (v) {
|
|
2064
|
+
var n = parseValue(v),
|
|
2065
|
+
a = this.value, b = n.value,
|
|
2066
|
+
sign = this.sign !== n.sign,
|
|
2067
|
+
abs;
|
|
2068
|
+
if (n.isSmall) {
|
|
2069
|
+
if (b === 0) return Integer[0];
|
|
2070
|
+
if (b === 1) return this;
|
|
2071
|
+
if (b === -1) return this.negate();
|
|
2072
|
+
abs = Math.abs(b);
|
|
2073
|
+
if (abs < BASE) {
|
|
2074
|
+
return new BigInteger(multiplySmall(a, abs), sign);
|
|
2075
|
+
}
|
|
2076
|
+
b = smallToArray(abs);
|
|
2077
|
+
}
|
|
2078
|
+
if (useKaratsuba(a.length, b.length)) // Karatsuba is only faster for certain array sizes
|
|
2079
|
+
return new BigInteger(multiplyKaratsuba(a, b), sign);
|
|
2080
|
+
return new BigInteger(multiplyLong(a, b), sign);
|
|
2081
|
+
};
|
|
2082
|
+
|
|
2083
|
+
BigInteger.prototype.times = BigInteger.prototype.multiply;
|
|
2084
|
+
|
|
2085
|
+
function multiplySmallAndArray(a, b, sign) { // a >= 0
|
|
2086
|
+
if (a < BASE) {
|
|
2087
|
+
return new BigInteger(multiplySmall(b, a), sign);
|
|
2088
|
+
}
|
|
2089
|
+
return new BigInteger(multiplyLong(b, smallToArray(a)), sign);
|
|
2090
|
+
}
|
|
2091
|
+
SmallInteger.prototype._multiplyBySmall = function (a) {
|
|
2092
|
+
if (isPrecise(a.value * this.value)) {
|
|
2093
|
+
return new SmallInteger(a.value * this.value);
|
|
2094
|
+
}
|
|
2095
|
+
return multiplySmallAndArray(Math.abs(a.value), smallToArray(Math.abs(this.value)), this.sign !== a.sign);
|
|
2096
|
+
};
|
|
2097
|
+
BigInteger.prototype._multiplyBySmall = function (a) {
|
|
2098
|
+
if (a.value === 0) return Integer[0];
|
|
2099
|
+
if (a.value === 1) return this;
|
|
2100
|
+
if (a.value === -1) return this.negate();
|
|
2101
|
+
return multiplySmallAndArray(Math.abs(a.value), this.value, this.sign !== a.sign);
|
|
2102
|
+
};
|
|
2103
|
+
SmallInteger.prototype.multiply = function (v) {
|
|
2104
|
+
return parseValue(v)._multiplyBySmall(this);
|
|
2105
|
+
};
|
|
2106
|
+
SmallInteger.prototype.times = SmallInteger.prototype.multiply;
|
|
2107
|
+
|
|
2108
|
+
NativeBigInt.prototype.multiply = function (v) {
|
|
2109
|
+
return new NativeBigInt(this.value * parseValue(v).value);
|
|
2110
|
+
}
|
|
2111
|
+
NativeBigInt.prototype.times = NativeBigInt.prototype.multiply;
|
|
2112
|
+
|
|
2113
|
+
function square(a) {
|
|
2114
|
+
//console.assert(2 * BASE * BASE < MAX_INT);
|
|
2115
|
+
var l = a.length,
|
|
2116
|
+
r = createArray(l + l),
|
|
2117
|
+
base = BASE,
|
|
2118
|
+
product, carry, i, a_i, a_j;
|
|
2119
|
+
for (i = 0; i < l; i++) {
|
|
2120
|
+
a_i = a[i];
|
|
2121
|
+
carry = 0 - a_i * a_i;
|
|
2122
|
+
for (var j = i; j < l; j++) {
|
|
2123
|
+
a_j = a[j];
|
|
2124
|
+
product = 2 * (a_i * a_j) + r[i + j] + carry;
|
|
2125
|
+
carry = Math.floor(product / base);
|
|
2126
|
+
r[i + j] = product - carry * base;
|
|
2127
|
+
}
|
|
2128
|
+
r[i + l] = carry;
|
|
2129
|
+
}
|
|
2130
|
+
trim(r);
|
|
2131
|
+
return r;
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2134
|
+
BigInteger.prototype.square = function () {
|
|
2135
|
+
return new BigInteger(square(this.value), false);
|
|
2136
|
+
};
|
|
2137
|
+
|
|
2138
|
+
SmallInteger.prototype.square = function () {
|
|
2139
|
+
var value = this.value * this.value;
|
|
2140
|
+
if (isPrecise(value)) return new SmallInteger(value);
|
|
2141
|
+
return new BigInteger(square(smallToArray(Math.abs(this.value))), false);
|
|
2142
|
+
};
|
|
2143
|
+
|
|
2144
|
+
NativeBigInt.prototype.square = function (v) {
|
|
2145
|
+
return new NativeBigInt(this.value * this.value);
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2148
|
+
function divMod1(a, b) { // Left over from previous version. Performs faster than divMod2 on smaller input sizes.
|
|
2149
|
+
var a_l = a.length,
|
|
2150
|
+
b_l = b.length,
|
|
2151
|
+
base = BASE,
|
|
2152
|
+
result = createArray(b.length),
|
|
2153
|
+
divisorMostSignificantDigit = b[b_l - 1],
|
|
2154
|
+
// normalization
|
|
2155
|
+
lambda = Math.ceil(base / (2 * divisorMostSignificantDigit)),
|
|
2156
|
+
remainder = multiplySmall(a, lambda),
|
|
2157
|
+
divisor = multiplySmall(b, lambda),
|
|
2158
|
+
quotientDigit, shift, carry, borrow, i, l, q;
|
|
2159
|
+
if (remainder.length <= a_l) remainder.push(0);
|
|
2160
|
+
divisor.push(0);
|
|
2161
|
+
divisorMostSignificantDigit = divisor[b_l - 1];
|
|
2162
|
+
for (shift = a_l - b_l; shift >= 0; shift--) {
|
|
2163
|
+
quotientDigit = base - 1;
|
|
2164
|
+
if (remainder[shift + b_l] !== divisorMostSignificantDigit) {
|
|
2165
|
+
quotientDigit = Math.floor((remainder[shift + b_l] * base + remainder[shift + b_l - 1]) / divisorMostSignificantDigit);
|
|
2166
|
+
}
|
|
2167
|
+
// quotientDigit <= base - 1
|
|
2168
|
+
carry = 0;
|
|
2169
|
+
borrow = 0;
|
|
2170
|
+
l = divisor.length;
|
|
2171
|
+
for (i = 0; i < l; i++) {
|
|
2172
|
+
carry += quotientDigit * divisor[i];
|
|
2173
|
+
q = Math.floor(carry / base);
|
|
2174
|
+
borrow += remainder[shift + i] - (carry - q * base);
|
|
2175
|
+
carry = q;
|
|
2176
|
+
if (borrow < 0) {
|
|
2177
|
+
remainder[shift + i] = borrow + base;
|
|
2178
|
+
borrow = -1;
|
|
2179
|
+
} else {
|
|
2180
|
+
remainder[shift + i] = borrow;
|
|
2181
|
+
borrow = 0;
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
while (borrow !== 0) {
|
|
2185
|
+
quotientDigit -= 1;
|
|
2186
|
+
carry = 0;
|
|
2187
|
+
for (i = 0; i < l; i++) {
|
|
2188
|
+
carry += remainder[shift + i] - base + divisor[i];
|
|
2189
|
+
if (carry < 0) {
|
|
2190
|
+
remainder[shift + i] = carry + base;
|
|
2191
|
+
carry = 0;
|
|
2192
|
+
} else {
|
|
2193
|
+
remainder[shift + i] = carry;
|
|
2194
|
+
carry = 1;
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
borrow += carry;
|
|
2198
|
+
}
|
|
2199
|
+
result[shift] = quotientDigit;
|
|
2200
|
+
}
|
|
2201
|
+
// denormalization
|
|
2202
|
+
remainder = divModSmall(remainder, lambda)[0];
|
|
2203
|
+
return [arrayToSmall(result), arrayToSmall(remainder)];
|
|
2204
|
+
}
|
|
2205
|
+
|
|
2206
|
+
function divMod2(a, b) { // Implementation idea shamelessly stolen from Silent Matt's library http://silentmatt.com/biginteger/
|
|
2207
|
+
// Performs faster than divMod1 on larger input sizes.
|
|
2208
|
+
var a_l = a.length,
|
|
2209
|
+
b_l = b.length,
|
|
2210
|
+
result = [],
|
|
2211
|
+
part = [],
|
|
2212
|
+
base = BASE,
|
|
2213
|
+
guess, xlen, highx, highy, check;
|
|
2214
|
+
while (a_l) {
|
|
2215
|
+
part.unshift(a[--a_l]);
|
|
2216
|
+
trim(part);
|
|
2217
|
+
if (compareAbs(part, b) < 0) {
|
|
2218
|
+
result.push(0);
|
|
2219
|
+
continue;
|
|
2220
|
+
}
|
|
2221
|
+
xlen = part.length;
|
|
2222
|
+
highx = part[xlen - 1] * base + part[xlen - 2];
|
|
2223
|
+
highy = b[b_l - 1] * base + b[b_l - 2];
|
|
2224
|
+
if (xlen > b_l) {
|
|
2225
|
+
highx = (highx + 1) * base;
|
|
2226
|
+
}
|
|
2227
|
+
guess = Math.ceil(highx / highy);
|
|
2228
|
+
do {
|
|
2229
|
+
check = multiplySmall(b, guess);
|
|
2230
|
+
if (compareAbs(check, part) <= 0) break;
|
|
2231
|
+
guess--;
|
|
2232
|
+
} while (guess);
|
|
2233
|
+
result.push(guess);
|
|
2234
|
+
part = subtract(part, check);
|
|
2235
|
+
}
|
|
2236
|
+
result.reverse();
|
|
2237
|
+
return [arrayToSmall(result), arrayToSmall(part)];
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
function divModSmall(value, lambda) {
|
|
2241
|
+
var length = value.length,
|
|
2242
|
+
quotient = createArray(length),
|
|
2243
|
+
base = BASE,
|
|
2244
|
+
i, q, remainder, divisor;
|
|
2245
|
+
remainder = 0;
|
|
2246
|
+
for (i = length - 1; i >= 0; --i) {
|
|
2247
|
+
divisor = remainder * base + value[i];
|
|
2248
|
+
q = truncate(divisor / lambda);
|
|
2249
|
+
remainder = divisor - q * lambda;
|
|
2250
|
+
quotient[i] = q | 0;
|
|
2251
|
+
}
|
|
2252
|
+
return [quotient, remainder | 0];
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
function divModAny(self, v) {
|
|
2256
|
+
var value, n = parseValue(v);
|
|
2257
|
+
if (supportsNativeBigInt) {
|
|
2258
|
+
return [new NativeBigInt(self.value / n.value), new NativeBigInt(self.value % n.value)];
|
|
2259
|
+
}
|
|
2260
|
+
var a = self.value, b = n.value;
|
|
2261
|
+
var quotient;
|
|
2262
|
+
if (b === 0) throw new Error("Cannot divide by zero");
|
|
2263
|
+
if (self.isSmall) {
|
|
2264
|
+
if (n.isSmall) {
|
|
2265
|
+
return [new SmallInteger(truncate(a / b)), new SmallInteger(a % b)];
|
|
2266
|
+
}
|
|
2267
|
+
return [Integer[0], self];
|
|
2268
|
+
}
|
|
2269
|
+
if (n.isSmall) {
|
|
2270
|
+
if (b === 1) return [self, Integer[0]];
|
|
2271
|
+
if (b == -1) return [self.negate(), Integer[0]];
|
|
2272
|
+
var abs = Math.abs(b);
|
|
2273
|
+
if (abs < BASE) {
|
|
2274
|
+
value = divModSmall(a, abs);
|
|
2275
|
+
quotient = arrayToSmall(value[0]);
|
|
2276
|
+
var remainder = value[1];
|
|
2277
|
+
if (self.sign) remainder = -remainder;
|
|
2278
|
+
if (typeof quotient === "number") {
|
|
2279
|
+
if (self.sign !== n.sign) quotient = -quotient;
|
|
2280
|
+
return [new SmallInteger(quotient), new SmallInteger(remainder)];
|
|
2281
|
+
}
|
|
2282
|
+
return [new BigInteger(quotient, self.sign !== n.sign), new SmallInteger(remainder)];
|
|
2283
|
+
}
|
|
2284
|
+
b = smallToArray(abs);
|
|
2285
|
+
}
|
|
2286
|
+
var comparison = compareAbs(a, b);
|
|
2287
|
+
if (comparison === -1) return [Integer[0], self];
|
|
2288
|
+
if (comparison === 0) return [Integer[self.sign === n.sign ? 1 : -1], Integer[0]];
|
|
2289
|
+
|
|
2290
|
+
// divMod1 is faster on smaller input sizes
|
|
2291
|
+
if (a.length + b.length <= 200)
|
|
2292
|
+
value = divMod1(a, b);
|
|
2293
|
+
else value = divMod2(a, b);
|
|
2294
|
+
|
|
2295
|
+
quotient = value[0];
|
|
2296
|
+
var qSign = self.sign !== n.sign,
|
|
2297
|
+
mod = value[1],
|
|
2298
|
+
mSign = self.sign;
|
|
2299
|
+
if (typeof quotient === "number") {
|
|
2300
|
+
if (qSign) quotient = -quotient;
|
|
2301
|
+
quotient = new SmallInteger(quotient);
|
|
2302
|
+
} else quotient = new BigInteger(quotient, qSign);
|
|
2303
|
+
if (typeof mod === "number") {
|
|
2304
|
+
if (mSign) mod = -mod;
|
|
2305
|
+
mod = new SmallInteger(mod);
|
|
2306
|
+
} else mod = new BigInteger(mod, mSign);
|
|
2307
|
+
return [quotient, mod];
|
|
2308
|
+
}
|
|
2309
|
+
|
|
2310
|
+
BigInteger.prototype.divmod = function (v) {
|
|
2311
|
+
var result = divModAny(this, v);
|
|
2312
|
+
return {
|
|
2313
|
+
quotient: result[0],
|
|
2314
|
+
remainder: result[1]
|
|
2315
|
+
};
|
|
2316
|
+
};
|
|
2317
|
+
NativeBigInt.prototype.divmod = SmallInteger.prototype.divmod = BigInteger.prototype.divmod;
|
|
2318
|
+
|
|
2319
|
+
|
|
2320
|
+
BigInteger.prototype.divide = function (v) {
|
|
2321
|
+
return divModAny(this, v)[0];
|
|
2322
|
+
};
|
|
2323
|
+
NativeBigInt.prototype.over = NativeBigInt.prototype.divide = function (v) {
|
|
2324
|
+
return new NativeBigInt(this.value / parseValue(v).value);
|
|
2325
|
+
};
|
|
2326
|
+
SmallInteger.prototype.over = SmallInteger.prototype.divide = BigInteger.prototype.over = BigInteger.prototype.divide;
|
|
2327
|
+
|
|
2328
|
+
BigInteger.prototype.mod = function (v) {
|
|
2329
|
+
return divModAny(this, v)[1];
|
|
2330
|
+
};
|
|
2331
|
+
NativeBigInt.prototype.mod = NativeBigInt.prototype.remainder = function (v) {
|
|
2332
|
+
return new NativeBigInt(this.value % parseValue(v).value);
|
|
2333
|
+
};
|
|
2334
|
+
SmallInteger.prototype.remainder = SmallInteger.prototype.mod = BigInteger.prototype.remainder = BigInteger.prototype.mod;
|
|
2335
|
+
|
|
2336
|
+
BigInteger.prototype.pow = function (v) {
|
|
2337
|
+
var n = parseValue(v),
|
|
2338
|
+
a = this.value,
|
|
2339
|
+
b = n.value,
|
|
2340
|
+
value, x, y;
|
|
2341
|
+
if (b === 0) return Integer[1];
|
|
2342
|
+
if (a === 0) return Integer[0];
|
|
2343
|
+
if (a === 1) return Integer[1];
|
|
2344
|
+
if (a === -1) return n.isEven() ? Integer[1] : Integer[-1];
|
|
2345
|
+
if (n.sign) {
|
|
2346
|
+
return Integer[0];
|
|
2347
|
+
}
|
|
2348
|
+
if (!n.isSmall) throw new Error("The exponent " + n.toString() + " is too large.");
|
|
2349
|
+
if (this.isSmall) {
|
|
2350
|
+
if (isPrecise(value = Math.pow(a, b)))
|
|
2351
|
+
return new SmallInteger(truncate(value));
|
|
2352
|
+
}
|
|
2353
|
+
x = this;
|
|
2354
|
+
y = Integer[1];
|
|
2355
|
+
while (true) {
|
|
2356
|
+
if (b & 1 === 1) {
|
|
2357
|
+
y = y.times(x);
|
|
2358
|
+
--b;
|
|
2359
|
+
}
|
|
2360
|
+
if (b === 0) break;
|
|
2361
|
+
b /= 2;
|
|
2362
|
+
x = x.square();
|
|
2363
|
+
}
|
|
2364
|
+
return y;
|
|
2365
|
+
};
|
|
2366
|
+
SmallInteger.prototype.pow = BigInteger.prototype.pow;
|
|
2367
|
+
|
|
2368
|
+
NativeBigInt.prototype.pow = function (v) {
|
|
2369
|
+
var n = parseValue(v);
|
|
2370
|
+
var a = this.value, b = n.value;
|
|
2371
|
+
var _0 = BigInt(0), _1 = BigInt(1), _2 = BigInt(2);
|
|
2372
|
+
if (b === _0) return Integer[1];
|
|
2373
|
+
if (a === _0) return Integer[0];
|
|
2374
|
+
if (a === _1) return Integer[1];
|
|
2375
|
+
if (a === BigInt(-1)) return n.isEven() ? Integer[1] : Integer[-1];
|
|
2376
|
+
if (n.isNegative()) return new NativeBigInt(_0);
|
|
2377
|
+
var x = this;
|
|
2378
|
+
var y = Integer[1];
|
|
2379
|
+
while (true) {
|
|
2380
|
+
if ((b & _1) === _1) {
|
|
2381
|
+
y = y.times(x);
|
|
2382
|
+
--b;
|
|
2383
|
+
}
|
|
2384
|
+
if (b === _0) break;
|
|
2385
|
+
b /= _2;
|
|
2386
|
+
x = x.square();
|
|
2387
|
+
}
|
|
2388
|
+
return y;
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2391
|
+
BigInteger.prototype.modPow = function (exp, mod) {
|
|
2392
|
+
exp = parseValue(exp);
|
|
2393
|
+
mod = parseValue(mod);
|
|
2394
|
+
if (mod.isZero()) throw new Error("Cannot take modPow with modulus 0");
|
|
2395
|
+
var r = Integer[1],
|
|
2396
|
+
base = this.mod(mod);
|
|
2397
|
+
if (exp.isNegative()) {
|
|
2398
|
+
exp = exp.multiply(Integer[-1]);
|
|
2399
|
+
base = base.modInv(mod);
|
|
2400
|
+
}
|
|
2401
|
+
while (exp.isPositive()) {
|
|
2402
|
+
if (base.isZero()) return Integer[0];
|
|
2403
|
+
if (exp.isOdd()) r = r.multiply(base).mod(mod);
|
|
2404
|
+
exp = exp.divide(2);
|
|
2405
|
+
base = base.square().mod(mod);
|
|
2406
|
+
}
|
|
2407
|
+
return r;
|
|
2408
|
+
};
|
|
2409
|
+
NativeBigInt.prototype.modPow = SmallInteger.prototype.modPow = BigInteger.prototype.modPow;
|
|
2410
|
+
|
|
2411
|
+
function compareAbs(a, b) {
|
|
2412
|
+
if (a.length !== b.length) {
|
|
2413
|
+
return a.length > b.length ? 1 : -1;
|
|
2414
|
+
}
|
|
2415
|
+
for (var i = a.length - 1; i >= 0; i--) {
|
|
2416
|
+
if (a[i] !== b[i]) return a[i] > b[i] ? 1 : -1;
|
|
2417
|
+
}
|
|
2418
|
+
return 0;
|
|
2419
|
+
}
|
|
2420
|
+
|
|
2421
|
+
BigInteger.prototype.compareAbs = function (v) {
|
|
2422
|
+
var n = parseValue(v),
|
|
2423
|
+
a = this.value,
|
|
2424
|
+
b = n.value;
|
|
2425
|
+
if (n.isSmall) return 1;
|
|
2426
|
+
return compareAbs(a, b);
|
|
2427
|
+
};
|
|
2428
|
+
SmallInteger.prototype.compareAbs = function (v) {
|
|
2429
|
+
var n = parseValue(v),
|
|
2430
|
+
a = Math.abs(this.value),
|
|
2431
|
+
b = n.value;
|
|
2432
|
+
if (n.isSmall) {
|
|
2433
|
+
b = Math.abs(b);
|
|
2434
|
+
return a === b ? 0 : a > b ? 1 : -1;
|
|
2435
|
+
}
|
|
2436
|
+
return -1;
|
|
2437
|
+
};
|
|
2438
|
+
NativeBigInt.prototype.compareAbs = function (v) {
|
|
2439
|
+
var a = this.value;
|
|
2440
|
+
var b = parseValue(v).value;
|
|
2441
|
+
a = a >= 0 ? a : -a;
|
|
2442
|
+
b = b >= 0 ? b : -b;
|
|
2443
|
+
return a === b ? 0 : a > b ? 1 : -1;
|
|
2444
|
+
}
|
|
2445
|
+
|
|
2446
|
+
BigInteger.prototype.compare = function (v) {
|
|
2447
|
+
// See discussion about comparison with Infinity:
|
|
2448
|
+
// https://github.com/peterolson/BigInteger.js/issues/61
|
|
2449
|
+
if (v === Infinity) {
|
|
2450
|
+
return -1;
|
|
2451
|
+
}
|
|
2452
|
+
if (v === -Infinity) {
|
|
2453
|
+
return 1;
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
var n = parseValue(v),
|
|
2457
|
+
a = this.value,
|
|
2458
|
+
b = n.value;
|
|
2459
|
+
if (this.sign !== n.sign) {
|
|
2460
|
+
return n.sign ? 1 : -1;
|
|
2461
|
+
}
|
|
2462
|
+
if (n.isSmall) {
|
|
2463
|
+
return this.sign ? -1 : 1;
|
|
2464
|
+
}
|
|
2465
|
+
return compareAbs(a, b) * (this.sign ? -1 : 1);
|
|
2466
|
+
};
|
|
2467
|
+
BigInteger.prototype.compareTo = BigInteger.prototype.compare;
|
|
2468
|
+
|
|
2469
|
+
SmallInteger.prototype.compare = function (v) {
|
|
2470
|
+
if (v === Infinity) {
|
|
2471
|
+
return -1;
|
|
2472
|
+
}
|
|
2473
|
+
if (v === -Infinity) {
|
|
2474
|
+
return 1;
|
|
2475
|
+
}
|
|
2476
|
+
|
|
2477
|
+
var n = parseValue(v),
|
|
2478
|
+
a = this.value,
|
|
2479
|
+
b = n.value;
|
|
2480
|
+
if (n.isSmall) {
|
|
2481
|
+
return a == b ? 0 : a > b ? 1 : -1;
|
|
2482
|
+
}
|
|
2483
|
+
if (a < 0 !== n.sign) {
|
|
2484
|
+
return a < 0 ? -1 : 1;
|
|
2485
|
+
}
|
|
2486
|
+
return a < 0 ? 1 : -1;
|
|
2487
|
+
};
|
|
2488
|
+
SmallInteger.prototype.compareTo = SmallInteger.prototype.compare;
|
|
2489
|
+
|
|
2490
|
+
NativeBigInt.prototype.compare = function (v) {
|
|
2491
|
+
if (v === Infinity) {
|
|
2492
|
+
return -1;
|
|
2493
|
+
}
|
|
2494
|
+
if (v === -Infinity) {
|
|
2495
|
+
return 1;
|
|
2496
|
+
}
|
|
2497
|
+
var a = this.value;
|
|
2498
|
+
var b = parseValue(v).value;
|
|
2499
|
+
return a === b ? 0 : a > b ? 1 : -1;
|
|
2500
|
+
}
|
|
2501
|
+
NativeBigInt.prototype.compareTo = NativeBigInt.prototype.compare;
|
|
2502
|
+
|
|
2503
|
+
BigInteger.prototype.equals = function (v) {
|
|
2504
|
+
return this.compare(v) === 0;
|
|
2505
|
+
};
|
|
2506
|
+
NativeBigInt.prototype.eq = NativeBigInt.prototype.equals = SmallInteger.prototype.eq = SmallInteger.prototype.equals = BigInteger.prototype.eq = BigInteger.prototype.equals;
|
|
2507
|
+
|
|
2508
|
+
BigInteger.prototype.notEquals = function (v) {
|
|
2509
|
+
return this.compare(v) !== 0;
|
|
2510
|
+
};
|
|
2511
|
+
NativeBigInt.prototype.neq = NativeBigInt.prototype.notEquals = SmallInteger.prototype.neq = SmallInteger.prototype.notEquals = BigInteger.prototype.neq = BigInteger.prototype.notEquals;
|
|
2512
|
+
|
|
2513
|
+
BigInteger.prototype.greater = function (v) {
|
|
2514
|
+
return this.compare(v) > 0;
|
|
2515
|
+
};
|
|
2516
|
+
NativeBigInt.prototype.gt = NativeBigInt.prototype.greater = SmallInteger.prototype.gt = SmallInteger.prototype.greater = BigInteger.prototype.gt = BigInteger.prototype.greater;
|
|
2517
|
+
|
|
2518
|
+
BigInteger.prototype.lesser = function (v) {
|
|
2519
|
+
return this.compare(v) < 0;
|
|
2520
|
+
};
|
|
2521
|
+
NativeBigInt.prototype.lt = NativeBigInt.prototype.lesser = SmallInteger.prototype.lt = SmallInteger.prototype.lesser = BigInteger.prototype.lt = BigInteger.prototype.lesser;
|
|
2522
|
+
|
|
2523
|
+
BigInteger.prototype.greaterOrEquals = function (v) {
|
|
2524
|
+
return this.compare(v) >= 0;
|
|
2525
|
+
};
|
|
2526
|
+
NativeBigInt.prototype.geq = NativeBigInt.prototype.greaterOrEquals = SmallInteger.prototype.geq = SmallInteger.prototype.greaterOrEquals = BigInteger.prototype.geq = BigInteger.prototype.greaterOrEquals;
|
|
2527
|
+
|
|
2528
|
+
BigInteger.prototype.lesserOrEquals = function (v) {
|
|
2529
|
+
return this.compare(v) <= 0;
|
|
2530
|
+
};
|
|
2531
|
+
NativeBigInt.prototype.leq = NativeBigInt.prototype.lesserOrEquals = SmallInteger.prototype.leq = SmallInteger.prototype.lesserOrEquals = BigInteger.prototype.leq = BigInteger.prototype.lesserOrEquals;
|
|
2532
|
+
|
|
2533
|
+
BigInteger.prototype.isEven = function () {
|
|
2534
|
+
return (this.value[0] & 1) === 0;
|
|
2535
|
+
};
|
|
2536
|
+
SmallInteger.prototype.isEven = function () {
|
|
2537
|
+
return (this.value & 1) === 0;
|
|
2538
|
+
};
|
|
2539
|
+
NativeBigInt.prototype.isEven = function () {
|
|
2540
|
+
return (this.value & BigInt(1)) === BigInt(0);
|
|
2541
|
+
}
|
|
2542
|
+
|
|
2543
|
+
BigInteger.prototype.isOdd = function () {
|
|
2544
|
+
return (this.value[0] & 1) === 1;
|
|
2545
|
+
};
|
|
2546
|
+
SmallInteger.prototype.isOdd = function () {
|
|
2547
|
+
return (this.value & 1) === 1;
|
|
2548
|
+
};
|
|
2549
|
+
NativeBigInt.prototype.isOdd = function () {
|
|
2550
|
+
return (this.value & BigInt(1)) === BigInt(1);
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
BigInteger.prototype.isPositive = function () {
|
|
2554
|
+
return !this.sign;
|
|
2555
|
+
};
|
|
2556
|
+
SmallInteger.prototype.isPositive = function () {
|
|
2557
|
+
return this.value > 0;
|
|
2558
|
+
};
|
|
2559
|
+
NativeBigInt.prototype.isPositive = SmallInteger.prototype.isPositive;
|
|
2560
|
+
|
|
2561
|
+
BigInteger.prototype.isNegative = function () {
|
|
2562
|
+
return this.sign;
|
|
2563
|
+
};
|
|
2564
|
+
SmallInteger.prototype.isNegative = function () {
|
|
2565
|
+
return this.value < 0;
|
|
2566
|
+
};
|
|
2567
|
+
NativeBigInt.prototype.isNegative = SmallInteger.prototype.isNegative;
|
|
2568
|
+
|
|
2569
|
+
BigInteger.prototype.isUnit = function () {
|
|
2570
|
+
return false;
|
|
2571
|
+
};
|
|
2572
|
+
SmallInteger.prototype.isUnit = function () {
|
|
2573
|
+
return Math.abs(this.value) === 1;
|
|
2574
|
+
};
|
|
2575
|
+
NativeBigInt.prototype.isUnit = function () {
|
|
2576
|
+
return this.abs().value === BigInt(1);
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
BigInteger.prototype.isZero = function () {
|
|
2580
|
+
return false;
|
|
2581
|
+
};
|
|
2582
|
+
SmallInteger.prototype.isZero = function () {
|
|
2583
|
+
return this.value === 0;
|
|
2584
|
+
};
|
|
2585
|
+
NativeBigInt.prototype.isZero = function () {
|
|
2586
|
+
return this.value === BigInt(0);
|
|
2587
|
+
}
|
|
2588
|
+
|
|
2589
|
+
BigInteger.prototype.isDivisibleBy = function (v) {
|
|
2590
|
+
var n = parseValue(v);
|
|
2591
|
+
if (n.isZero()) return false;
|
|
2592
|
+
if (n.isUnit()) return true;
|
|
2593
|
+
if (n.compareAbs(2) === 0) return this.isEven();
|
|
2594
|
+
return this.mod(n).isZero();
|
|
2595
|
+
};
|
|
2596
|
+
NativeBigInt.prototype.isDivisibleBy = SmallInteger.prototype.isDivisibleBy = BigInteger.prototype.isDivisibleBy;
|
|
2597
|
+
|
|
2598
|
+
function isBasicPrime(v) {
|
|
2599
|
+
var n = v.abs();
|
|
2600
|
+
if (n.isUnit()) return false;
|
|
2601
|
+
if (n.equals(2) || n.equals(3) || n.equals(5)) return true;
|
|
2602
|
+
if (n.isEven() || n.isDivisibleBy(3) || n.isDivisibleBy(5)) return false;
|
|
2603
|
+
if (n.lesser(49)) return true;
|
|
2604
|
+
// we don't know if it's prime: let the other functions figure it out
|
|
2605
|
+
}
|
|
2606
|
+
|
|
2607
|
+
function millerRabinTest(n, a) {
|
|
2608
|
+
var nPrev = n.prev(),
|
|
2609
|
+
b = nPrev,
|
|
2610
|
+
r = 0,
|
|
2611
|
+
d, t, i, x;
|
|
2612
|
+
while (b.isEven()) b = b.divide(2), r++;
|
|
2613
|
+
next: for (i = 0; i < a.length; i++) {
|
|
2614
|
+
if (n.lesser(a[i])) continue;
|
|
2615
|
+
x = bigInt(a[i]).modPow(b, n);
|
|
2616
|
+
if (x.isUnit() || x.equals(nPrev)) continue;
|
|
2617
|
+
for (d = r - 1; d != 0; d--) {
|
|
2618
|
+
x = x.square().mod(n);
|
|
2619
|
+
if (x.isUnit()) return false;
|
|
2620
|
+
if (x.equals(nPrev)) continue next;
|
|
2621
|
+
}
|
|
2622
|
+
return false;
|
|
2623
|
+
}
|
|
2624
|
+
return true;
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
// Set "strict" to true to force GRH-supported lower bound of 2*log(N)^2
|
|
2628
|
+
BigInteger.prototype.isPrime = function (strict) {
|
|
2629
|
+
var isPrime = isBasicPrime(this);
|
|
2630
|
+
if (isPrime !== undefined) return isPrime;
|
|
2631
|
+
var n = this.abs();
|
|
2632
|
+
var bits = n.bitLength();
|
|
2633
|
+
if (bits <= 64)
|
|
2634
|
+
return millerRabinTest(n, [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]);
|
|
2635
|
+
var logN = Math.log(2) * bits.toJSNumber();
|
|
2636
|
+
var t = Math.ceil((strict === true) ? (2 * Math.pow(logN, 2)) : logN);
|
|
2637
|
+
for (var a = [], i = 0; i < t; i++) {
|
|
2638
|
+
a.push(bigInt(i + 2));
|
|
2639
|
+
}
|
|
2640
|
+
return millerRabinTest(n, a);
|
|
2641
|
+
};
|
|
2642
|
+
NativeBigInt.prototype.isPrime = SmallInteger.prototype.isPrime = BigInteger.prototype.isPrime;
|
|
2643
|
+
|
|
2644
|
+
BigInteger.prototype.isProbablePrime = function (iterations, rng) {
|
|
2645
|
+
var isPrime = isBasicPrime(this);
|
|
2646
|
+
if (isPrime !== undefined) return isPrime;
|
|
2647
|
+
var n = this.abs();
|
|
2648
|
+
var t = iterations === undefined ? 5 : iterations;
|
|
2649
|
+
for (var a = [], i = 0; i < t; i++) {
|
|
2650
|
+
a.push(bigInt.randBetween(2, n.minus(2), rng));
|
|
2651
|
+
}
|
|
2652
|
+
return millerRabinTest(n, a);
|
|
2653
|
+
};
|
|
2654
|
+
NativeBigInt.prototype.isProbablePrime = SmallInteger.prototype.isProbablePrime = BigInteger.prototype.isProbablePrime;
|
|
2655
|
+
|
|
2656
|
+
BigInteger.prototype.modInv = function (n) {
|
|
2657
|
+
var t = bigInt.zero, newT = bigInt.one, r = parseValue(n), newR = this.abs(), q, lastT, lastR;
|
|
2658
|
+
while (!newR.isZero()) {
|
|
2659
|
+
q = r.divide(newR);
|
|
2660
|
+
lastT = t;
|
|
2661
|
+
lastR = r;
|
|
2662
|
+
t = newT;
|
|
2663
|
+
r = newR;
|
|
2664
|
+
newT = lastT.subtract(q.multiply(newT));
|
|
2665
|
+
newR = lastR.subtract(q.multiply(newR));
|
|
2666
|
+
}
|
|
2667
|
+
if (!r.isUnit()) throw new Error(this.toString() + " and " + n.toString() + " are not co-prime");
|
|
2668
|
+
if (t.compare(0) === -1) {
|
|
2669
|
+
t = t.add(n);
|
|
2670
|
+
}
|
|
2671
|
+
if (this.isNegative()) {
|
|
2672
|
+
return t.negate();
|
|
2673
|
+
}
|
|
2674
|
+
return t;
|
|
2675
|
+
};
|
|
2676
|
+
|
|
2677
|
+
NativeBigInt.prototype.modInv = SmallInteger.prototype.modInv = BigInteger.prototype.modInv;
|
|
2678
|
+
|
|
2679
|
+
BigInteger.prototype.next = function () {
|
|
2680
|
+
var value = this.value;
|
|
2681
|
+
if (this.sign) {
|
|
2682
|
+
return subtractSmall(value, 1, this.sign);
|
|
2683
|
+
}
|
|
2684
|
+
return new BigInteger(addSmall(value, 1), this.sign);
|
|
2685
|
+
};
|
|
2686
|
+
SmallInteger.prototype.next = function () {
|
|
2687
|
+
var value = this.value;
|
|
2688
|
+
if (value + 1 < MAX_INT) return new SmallInteger(value + 1);
|
|
2689
|
+
return new BigInteger(MAX_INT_ARR, false);
|
|
2690
|
+
};
|
|
2691
|
+
NativeBigInt.prototype.next = function () {
|
|
2692
|
+
return new NativeBigInt(this.value + BigInt(1));
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
BigInteger.prototype.prev = function () {
|
|
2696
|
+
var value = this.value;
|
|
2697
|
+
if (this.sign) {
|
|
2698
|
+
return new BigInteger(addSmall(value, 1), true);
|
|
2699
|
+
}
|
|
2700
|
+
return subtractSmall(value, 1, this.sign);
|
|
2701
|
+
};
|
|
2702
|
+
SmallInteger.prototype.prev = function () {
|
|
2703
|
+
var value = this.value;
|
|
2704
|
+
if (value - 1 > -MAX_INT) return new SmallInteger(value - 1);
|
|
2705
|
+
return new BigInteger(MAX_INT_ARR, true);
|
|
2706
|
+
};
|
|
2707
|
+
NativeBigInt.prototype.prev = function () {
|
|
2708
|
+
return new NativeBigInt(this.value - BigInt(1));
|
|
2709
|
+
}
|
|
2710
|
+
|
|
2711
|
+
var powersOfTwo = [1];
|
|
2712
|
+
while (2 * powersOfTwo[powersOfTwo.length - 1] <= BASE) powersOfTwo.push(2 * powersOfTwo[powersOfTwo.length - 1]);
|
|
2713
|
+
var powers2Length = powersOfTwo.length, highestPower2 = powersOfTwo[powers2Length - 1];
|
|
2714
|
+
|
|
2715
|
+
function shift_isSmall(n) {
|
|
2716
|
+
return Math.abs(n) <= BASE;
|
|
2717
|
+
}
|
|
2718
|
+
|
|
2719
|
+
BigInteger.prototype.shiftLeft = function (v) {
|
|
2720
|
+
var n = parseValue(v).toJSNumber();
|
|
2721
|
+
if (!shift_isSmall(n)) {
|
|
2722
|
+
throw new Error(String(n) + " is too large for shifting.");
|
|
2723
|
+
}
|
|
2724
|
+
if (n < 0) return this.shiftRight(-n);
|
|
2725
|
+
var result = this;
|
|
2726
|
+
if (result.isZero()) return result;
|
|
2727
|
+
while (n >= powers2Length) {
|
|
2728
|
+
result = result.multiply(highestPower2);
|
|
2729
|
+
n -= powers2Length - 1;
|
|
2730
|
+
}
|
|
2731
|
+
return result.multiply(powersOfTwo[n]);
|
|
2732
|
+
};
|
|
2733
|
+
NativeBigInt.prototype.shiftLeft = SmallInteger.prototype.shiftLeft = BigInteger.prototype.shiftLeft;
|
|
2734
|
+
|
|
2735
|
+
BigInteger.prototype.shiftRight = function (v) {
|
|
2736
|
+
var remQuo;
|
|
2737
|
+
var n = parseValue(v).toJSNumber();
|
|
2738
|
+
if (!shift_isSmall(n)) {
|
|
2739
|
+
throw new Error(String(n) + " is too large for shifting.");
|
|
2740
|
+
}
|
|
2741
|
+
if (n < 0) return this.shiftLeft(-n);
|
|
2742
|
+
var result = this;
|
|
2743
|
+
while (n >= powers2Length) {
|
|
2744
|
+
if (result.isZero() || (result.isNegative() && result.isUnit())) return result;
|
|
2745
|
+
remQuo = divModAny(result, highestPower2);
|
|
2746
|
+
result = remQuo[1].isNegative() ? remQuo[0].prev() : remQuo[0];
|
|
2747
|
+
n -= powers2Length - 1;
|
|
2748
|
+
}
|
|
2749
|
+
remQuo = divModAny(result, powersOfTwo[n]);
|
|
2750
|
+
return remQuo[1].isNegative() ? remQuo[0].prev() : remQuo[0];
|
|
2751
|
+
};
|
|
2752
|
+
NativeBigInt.prototype.shiftRight = SmallInteger.prototype.shiftRight = BigInteger.prototype.shiftRight;
|
|
2753
|
+
|
|
2754
|
+
function bitwise(x, y, fn) {
|
|
2755
|
+
y = parseValue(y);
|
|
2756
|
+
var xSign = x.isNegative(), ySign = y.isNegative();
|
|
2757
|
+
var xRem = xSign ? x.not() : x,
|
|
2758
|
+
yRem = ySign ? y.not() : y;
|
|
2759
|
+
var xDigit = 0, yDigit = 0;
|
|
2760
|
+
var xDivMod = null, yDivMod = null;
|
|
2761
|
+
var result = [];
|
|
2762
|
+
while (!xRem.isZero() || !yRem.isZero()) {
|
|
2763
|
+
xDivMod = divModAny(xRem, highestPower2);
|
|
2764
|
+
xDigit = xDivMod[1].toJSNumber();
|
|
2765
|
+
if (xSign) {
|
|
2766
|
+
xDigit = highestPower2 - 1 - xDigit; // two's complement for negative numbers
|
|
2767
|
+
}
|
|
2768
|
+
|
|
2769
|
+
yDivMod = divModAny(yRem, highestPower2);
|
|
2770
|
+
yDigit = yDivMod[1].toJSNumber();
|
|
2771
|
+
if (ySign) {
|
|
2772
|
+
yDigit = highestPower2 - 1 - yDigit; // two's complement for negative numbers
|
|
2773
|
+
}
|
|
2774
|
+
|
|
2775
|
+
xRem = xDivMod[0];
|
|
2776
|
+
yRem = yDivMod[0];
|
|
2777
|
+
result.push(fn(xDigit, yDigit));
|
|
2778
|
+
}
|
|
2779
|
+
var sum = fn(xSign ? 1 : 0, ySign ? 1 : 0) !== 0 ? bigInt(-1) : bigInt(0);
|
|
2780
|
+
for (var i = result.length - 1; i >= 0; i -= 1) {
|
|
2781
|
+
sum = sum.multiply(highestPower2).add(bigInt(result[i]));
|
|
2782
|
+
}
|
|
2783
|
+
return sum;
|
|
2784
|
+
}
|
|
2785
|
+
|
|
2786
|
+
BigInteger.prototype.not = function () {
|
|
2787
|
+
return this.negate().prev();
|
|
2788
|
+
};
|
|
2789
|
+
NativeBigInt.prototype.not = SmallInteger.prototype.not = BigInteger.prototype.not;
|
|
2790
|
+
|
|
2791
|
+
BigInteger.prototype.and = function (n) {
|
|
2792
|
+
return bitwise(this, n, function (a, b) { return a & b; });
|
|
2793
|
+
};
|
|
2794
|
+
NativeBigInt.prototype.and = SmallInteger.prototype.and = BigInteger.prototype.and;
|
|
2795
|
+
|
|
2796
|
+
BigInteger.prototype.or = function (n) {
|
|
2797
|
+
return bitwise(this, n, function (a, b) { return a | b; });
|
|
2798
|
+
};
|
|
2799
|
+
NativeBigInt.prototype.or = SmallInteger.prototype.or = BigInteger.prototype.or;
|
|
2800
|
+
|
|
2801
|
+
BigInteger.prototype.xor = function (n) {
|
|
2802
|
+
return bitwise(this, n, function (a, b) { return a ^ b; });
|
|
2803
|
+
};
|
|
2804
|
+
NativeBigInt.prototype.xor = SmallInteger.prototype.xor = BigInteger.prototype.xor;
|
|
2805
|
+
|
|
2806
|
+
var LOBMASK_I = 1 << 30, LOBMASK_BI = (BASE & -BASE) * (BASE & -BASE) | LOBMASK_I;
|
|
2807
|
+
function roughLOB(n) { // get lowestOneBit (rough)
|
|
2808
|
+
// SmallInteger: return Min(lowestOneBit(n), 1 << 30)
|
|
2809
|
+
// BigInteger: return Min(lowestOneBit(n), 1 << 14) [BASE=1e7]
|
|
2810
|
+
var v = n.value,
|
|
2811
|
+
x = typeof v === "number" ? v | LOBMASK_I :
|
|
2812
|
+
typeof v === "bigint" ? v | BigInt(LOBMASK_I) :
|
|
2813
|
+
v[0] + v[1] * BASE | LOBMASK_BI;
|
|
2814
|
+
return x & -x;
|
|
2815
|
+
}
|
|
2816
|
+
|
|
2817
|
+
function integerLogarithm(value, base) {
|
|
2818
|
+
if (base.compareTo(value) <= 0) {
|
|
2819
|
+
var tmp = integerLogarithm(value, base.square(base));
|
|
2820
|
+
var p = tmp.p;
|
|
2821
|
+
var e = tmp.e;
|
|
2822
|
+
var t = p.multiply(base);
|
|
2823
|
+
return t.compareTo(value) <= 0 ? { p: t, e: e * 2 + 1 } : { p: p, e: e * 2 };
|
|
2824
|
+
}
|
|
2825
|
+
return { p: bigInt(1), e: 0 };
|
|
2826
|
+
}
|
|
2827
|
+
|
|
2828
|
+
BigInteger.prototype.bitLength = function () {
|
|
2829
|
+
var n = this;
|
|
2830
|
+
if (n.compareTo(bigInt(0)) < 0) {
|
|
2831
|
+
n = n.negate().subtract(bigInt(1));
|
|
2832
|
+
}
|
|
2833
|
+
if (n.compareTo(bigInt(0)) === 0) {
|
|
2834
|
+
return bigInt(0);
|
|
2835
|
+
}
|
|
2836
|
+
return bigInt(integerLogarithm(n, bigInt(2)).e).add(bigInt(1));
|
|
2837
|
+
}
|
|
2838
|
+
NativeBigInt.prototype.bitLength = SmallInteger.prototype.bitLength = BigInteger.prototype.bitLength;
|
|
2839
|
+
|
|
2840
|
+
function max(a, b) {
|
|
2841
|
+
a = parseValue(a);
|
|
2842
|
+
b = parseValue(b);
|
|
2843
|
+
return a.greater(b) ? a : b;
|
|
2844
|
+
}
|
|
2845
|
+
function min(a, b) {
|
|
2846
|
+
a = parseValue(a);
|
|
2847
|
+
b = parseValue(b);
|
|
2848
|
+
return a.lesser(b) ? a : b;
|
|
2849
|
+
}
|
|
2850
|
+
function gcd(a, b) {
|
|
2851
|
+
a = parseValue(a).abs();
|
|
2852
|
+
b = parseValue(b).abs();
|
|
2853
|
+
if (a.equals(b)) return a;
|
|
2854
|
+
if (a.isZero()) return b;
|
|
2855
|
+
if (b.isZero()) return a;
|
|
2856
|
+
var c = Integer[1], d, t;
|
|
2857
|
+
while (a.isEven() && b.isEven()) {
|
|
2858
|
+
d = min(roughLOB(a), roughLOB(b));
|
|
2859
|
+
a = a.divide(d);
|
|
2860
|
+
b = b.divide(d);
|
|
2861
|
+
c = c.multiply(d);
|
|
2862
|
+
}
|
|
2863
|
+
while (a.isEven()) {
|
|
2864
|
+
a = a.divide(roughLOB(a));
|
|
2865
|
+
}
|
|
2866
|
+
do {
|
|
2867
|
+
while (b.isEven()) {
|
|
2868
|
+
b = b.divide(roughLOB(b));
|
|
2869
|
+
}
|
|
2870
|
+
if (a.greater(b)) {
|
|
2871
|
+
t = b; b = a; a = t;
|
|
2872
|
+
}
|
|
2873
|
+
b = b.subtract(a);
|
|
2874
|
+
} while (!b.isZero());
|
|
2875
|
+
return c.isUnit() ? a : a.multiply(c);
|
|
2876
|
+
}
|
|
2877
|
+
function lcm(a, b) {
|
|
2878
|
+
a = parseValue(a).abs();
|
|
2879
|
+
b = parseValue(b).abs();
|
|
2880
|
+
return a.divide(gcd(a, b)).multiply(b);
|
|
2881
|
+
}
|
|
2882
|
+
function randBetween(a, b, rng) {
|
|
2883
|
+
a = parseValue(a);
|
|
2884
|
+
b = parseValue(b);
|
|
2885
|
+
var usedRNG = rng || Math.random;
|
|
2886
|
+
var low = min(a, b), high = max(a, b);
|
|
2887
|
+
var range = high.subtract(low).add(1);
|
|
2888
|
+
if (range.isSmall) return low.add(Math.floor(usedRNG() * range));
|
|
2889
|
+
var digits = toBase(range, BASE).value;
|
|
2890
|
+
var result = [], restricted = true;
|
|
2891
|
+
for (var i = 0; i < digits.length; i++) {
|
|
2892
|
+
var top = restricted ? digits[i] : BASE;
|
|
2893
|
+
var digit = truncate(usedRNG() * top);
|
|
2894
|
+
result.push(digit);
|
|
2895
|
+
if (digit < top) restricted = false;
|
|
2896
|
+
}
|
|
2897
|
+
return low.add(Integer.fromArray(result, BASE, false));
|
|
2898
|
+
}
|
|
2899
|
+
|
|
2900
|
+
var parseBase = function (text, base, alphabet, caseSensitive) {
|
|
2901
|
+
alphabet = alphabet || DEFAULT_ALPHABET;
|
|
2902
|
+
text = String(text);
|
|
2903
|
+
if (!caseSensitive) {
|
|
2904
|
+
text = text.toLowerCase();
|
|
2905
|
+
alphabet = alphabet.toLowerCase();
|
|
2906
|
+
}
|
|
2907
|
+
var length = text.length;
|
|
2908
|
+
var i;
|
|
2909
|
+
var absBase = Math.abs(base);
|
|
2910
|
+
var alphabetValues = {};
|
|
2911
|
+
for (i = 0; i < alphabet.length; i++) {
|
|
2912
|
+
alphabetValues[alphabet[i]] = i;
|
|
2913
|
+
}
|
|
2914
|
+
for (i = 0; i < length; i++) {
|
|
2915
|
+
var c = text[i];
|
|
2916
|
+
if (c === "-") continue;
|
|
2917
|
+
if (c in alphabetValues) {
|
|
2918
|
+
if (alphabetValues[c] >= absBase) {
|
|
2919
|
+
if (c === "1" && absBase === 1) continue;
|
|
2920
|
+
throw new Error(c + " is not a valid digit in base " + base + ".");
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2923
|
+
}
|
|
2924
|
+
base = parseValue(base);
|
|
2925
|
+
var digits = [];
|
|
2926
|
+
var isNegative = text[0] === "-";
|
|
2927
|
+
for (i = isNegative ? 1 : 0; i < text.length; i++) {
|
|
2928
|
+
var c = text[i];
|
|
2929
|
+
if (c in alphabetValues) digits.push(parseValue(alphabetValues[c]));
|
|
2930
|
+
else if (c === "<") {
|
|
2931
|
+
var start = i;
|
|
2932
|
+
do { i++; } while (text[i] !== ">" && i < text.length);
|
|
2933
|
+
digits.push(parseValue(text.slice(start + 1, i)));
|
|
2934
|
+
}
|
|
2935
|
+
else throw new Error(c + " is not a valid character");
|
|
2936
|
+
}
|
|
2937
|
+
return parseBaseFromArray(digits, base, isNegative);
|
|
2938
|
+
};
|
|
2939
|
+
|
|
2940
|
+
function parseBaseFromArray(digits, base, isNegative) {
|
|
2941
|
+
var val = Integer[0], pow = Integer[1], i;
|
|
2942
|
+
for (i = digits.length - 1; i >= 0; i--) {
|
|
2943
|
+
val = val.add(digits[i].times(pow));
|
|
2944
|
+
pow = pow.times(base);
|
|
2945
|
+
}
|
|
2946
|
+
return isNegative ? val.negate() : val;
|
|
2947
|
+
}
|
|
2948
|
+
|
|
2949
|
+
function stringify(digit, alphabet) {
|
|
2950
|
+
alphabet = alphabet || DEFAULT_ALPHABET;
|
|
2951
|
+
if (digit < alphabet.length) {
|
|
2952
|
+
return alphabet[digit];
|
|
2953
|
+
}
|
|
2954
|
+
return "<" + digit + ">";
|
|
2955
|
+
}
|
|
2956
|
+
|
|
2957
|
+
function toBase(n, base) {
|
|
2958
|
+
base = bigInt(base);
|
|
2959
|
+
if (base.isZero()) {
|
|
2960
|
+
if (n.isZero()) return { value: [0], isNegative: false };
|
|
2961
|
+
throw new Error("Cannot convert nonzero numbers to base 0.");
|
|
2962
|
+
}
|
|
2963
|
+
if (base.equals(-1)) {
|
|
2964
|
+
if (n.isZero()) return { value: [0], isNegative: false };
|
|
2965
|
+
if (n.isNegative())
|
|
2966
|
+
return {
|
|
2967
|
+
value: [].concat.apply([], Array.apply(null, Array(-n.toJSNumber()))
|
|
2968
|
+
.map(Array.prototype.valueOf, [1, 0])
|
|
2969
|
+
),
|
|
2970
|
+
isNegative: false
|
|
2971
|
+
};
|
|
2972
|
+
|
|
2973
|
+
var arr = Array.apply(null, Array(n.toJSNumber() - 1))
|
|
2974
|
+
.map(Array.prototype.valueOf, [0, 1]);
|
|
2975
|
+
arr.unshift([1]);
|
|
2976
|
+
return {
|
|
2977
|
+
value: [].concat.apply([], arr),
|
|
2978
|
+
isNegative: false
|
|
2979
|
+
};
|
|
2980
|
+
}
|
|
2981
|
+
|
|
2982
|
+
var neg = false;
|
|
2983
|
+
if (n.isNegative() && base.isPositive()) {
|
|
2984
|
+
neg = true;
|
|
2985
|
+
n = n.abs();
|
|
2986
|
+
}
|
|
2987
|
+
if (base.isUnit()) {
|
|
2988
|
+
if (n.isZero()) return { value: [0], isNegative: false };
|
|
2989
|
+
|
|
2990
|
+
return {
|
|
2991
|
+
value: Array.apply(null, Array(n.toJSNumber()))
|
|
2992
|
+
.map(Number.prototype.valueOf, 1),
|
|
2993
|
+
isNegative: neg
|
|
2994
|
+
};
|
|
2995
|
+
}
|
|
2996
|
+
var out = [];
|
|
2997
|
+
var left = n, divmod;
|
|
2998
|
+
while (left.isNegative() || left.compareAbs(base) >= 0) {
|
|
2999
|
+
divmod = left.divmod(base);
|
|
3000
|
+
left = divmod.quotient;
|
|
3001
|
+
var digit = divmod.remainder;
|
|
3002
|
+
if (digit.isNegative()) {
|
|
3003
|
+
digit = base.minus(digit).abs();
|
|
3004
|
+
left = left.next();
|
|
3005
|
+
}
|
|
3006
|
+
out.push(digit.toJSNumber());
|
|
3007
|
+
}
|
|
3008
|
+
out.push(left.toJSNumber());
|
|
3009
|
+
return { value: out.reverse(), isNegative: neg };
|
|
3010
|
+
}
|
|
3011
|
+
|
|
3012
|
+
function toBaseString(n, base, alphabet) {
|
|
3013
|
+
var arr = toBase(n, base);
|
|
3014
|
+
return (arr.isNegative ? "-" : "") + arr.value.map(function (x) {
|
|
3015
|
+
return stringify(x, alphabet);
|
|
3016
|
+
}).join('');
|
|
3017
|
+
}
|
|
3018
|
+
|
|
3019
|
+
BigInteger.prototype.toArray = function (radix) {
|
|
3020
|
+
return toBase(this, radix);
|
|
3021
|
+
};
|
|
3022
|
+
|
|
3023
|
+
SmallInteger.prototype.toArray = function (radix) {
|
|
3024
|
+
return toBase(this, radix);
|
|
3025
|
+
};
|
|
3026
|
+
|
|
3027
|
+
NativeBigInt.prototype.toArray = function (radix) {
|
|
3028
|
+
return toBase(this, radix);
|
|
3029
|
+
};
|
|
3030
|
+
|
|
3031
|
+
BigInteger.prototype.toString = function (radix, alphabet) {
|
|
3032
|
+
if (radix === undefined) radix = 10;
|
|
3033
|
+
if (radix !== 10) return toBaseString(this, radix, alphabet);
|
|
3034
|
+
var v = this.value, l = v.length, str = String(v[--l]), zeros = "0000000", digit;
|
|
3035
|
+
while (--l >= 0) {
|
|
3036
|
+
digit = String(v[l]);
|
|
3037
|
+
str += zeros.slice(digit.length) + digit;
|
|
3038
|
+
}
|
|
3039
|
+
var sign = this.sign ? "-" : "";
|
|
3040
|
+
return sign + str;
|
|
3041
|
+
};
|
|
3042
|
+
|
|
3043
|
+
SmallInteger.prototype.toString = function (radix, alphabet) {
|
|
3044
|
+
if (radix === undefined) radix = 10;
|
|
3045
|
+
if (radix != 10) return toBaseString(this, radix, alphabet);
|
|
3046
|
+
return String(this.value);
|
|
3047
|
+
};
|
|
3048
|
+
|
|
3049
|
+
NativeBigInt.prototype.toString = SmallInteger.prototype.toString;
|
|
3050
|
+
|
|
3051
|
+
NativeBigInt.prototype.toJSON = BigInteger.prototype.toJSON = SmallInteger.prototype.toJSON = function () { return this.toString(); }
|
|
3052
|
+
|
|
3053
|
+
BigInteger.prototype.valueOf = function () {
|
|
3054
|
+
return parseInt(this.toString(), 10);
|
|
3055
|
+
};
|
|
3056
|
+
BigInteger.prototype.toJSNumber = BigInteger.prototype.valueOf;
|
|
3057
|
+
|
|
3058
|
+
SmallInteger.prototype.valueOf = function () {
|
|
3059
|
+
return this.value;
|
|
3060
|
+
};
|
|
3061
|
+
SmallInteger.prototype.toJSNumber = SmallInteger.prototype.valueOf;
|
|
3062
|
+
NativeBigInt.prototype.valueOf = NativeBigInt.prototype.toJSNumber = function () {
|
|
3063
|
+
return parseInt(this.toString(), 10);
|
|
3064
|
+
}
|
|
3065
|
+
|
|
3066
|
+
function parseStringValue(v) {
|
|
3067
|
+
if (isPrecise(+v)) {
|
|
3068
|
+
var x = +v;
|
|
3069
|
+
if (x === truncate(x))
|
|
3070
|
+
return supportsNativeBigInt ? new NativeBigInt(BigInt(x)) : new SmallInteger(x);
|
|
3071
|
+
throw new Error("Invalid integer: " + v);
|
|
3072
|
+
}
|
|
3073
|
+
var sign = v[0] === "-";
|
|
3074
|
+
if (sign) v = v.slice(1);
|
|
3075
|
+
var split = v.split(/e/i);
|
|
3076
|
+
if (split.length > 2) throw new Error("Invalid integer: " + split.join("e"));
|
|
3077
|
+
if (split.length === 2) {
|
|
3078
|
+
var exp = split[1];
|
|
3079
|
+
if (exp[0] === "+") exp = exp.slice(1);
|
|
3080
|
+
exp = +exp;
|
|
3081
|
+
if (exp !== truncate(exp) || !isPrecise(exp)) throw new Error("Invalid integer: " + exp + " is not a valid exponent.");
|
|
3082
|
+
var text = split[0];
|
|
3083
|
+
var decimalPlace = text.indexOf(".");
|
|
3084
|
+
if (decimalPlace >= 0) {
|
|
3085
|
+
exp -= text.length - decimalPlace - 1;
|
|
3086
|
+
text = text.slice(0, decimalPlace) + text.slice(decimalPlace + 1);
|
|
3087
|
+
}
|
|
3088
|
+
if (exp < 0) throw new Error("Cannot include negative exponent part for integers");
|
|
3089
|
+
text += (new Array(exp + 1)).join("0");
|
|
3090
|
+
v = text;
|
|
3091
|
+
}
|
|
3092
|
+
var isValid = /^([0-9][0-9]*)$/.test(v);
|
|
3093
|
+
if (!isValid) throw new Error("Invalid integer: " + v);
|
|
3094
|
+
if (supportsNativeBigInt) {
|
|
3095
|
+
return new NativeBigInt(BigInt(sign ? "-" + v : v));
|
|
3096
|
+
}
|
|
3097
|
+
var r = [], max = v.length, l = LOG_BASE, min = max - l;
|
|
3098
|
+
while (max > 0) {
|
|
3099
|
+
r.push(+v.slice(min, max));
|
|
3100
|
+
min -= l;
|
|
3101
|
+
if (min < 0) min = 0;
|
|
3102
|
+
max -= l;
|
|
3103
|
+
}
|
|
3104
|
+
trim(r);
|
|
3105
|
+
return new BigInteger(r, sign);
|
|
3106
|
+
}
|
|
3107
|
+
|
|
3108
|
+
function parseNumberValue(v) {
|
|
3109
|
+
if (supportsNativeBigInt) {
|
|
3110
|
+
return new NativeBigInt(BigInt(v));
|
|
3111
|
+
}
|
|
3112
|
+
if (isPrecise(v)) {
|
|
3113
|
+
if (v !== truncate(v)) throw new Error(v + " is not an integer.");
|
|
3114
|
+
return new SmallInteger(v);
|
|
3115
|
+
}
|
|
3116
|
+
return parseStringValue(v.toString());
|
|
3117
|
+
}
|
|
3118
|
+
|
|
3119
|
+
function parseValue(v) {
|
|
3120
|
+
if (typeof v === "number") {
|
|
3121
|
+
return parseNumberValue(v);
|
|
3122
|
+
}
|
|
3123
|
+
if (typeof v === "string") {
|
|
3124
|
+
return parseStringValue(v);
|
|
3125
|
+
}
|
|
3126
|
+
if (typeof v === "bigint") {
|
|
3127
|
+
return new NativeBigInt(v);
|
|
3128
|
+
}
|
|
3129
|
+
return v;
|
|
3130
|
+
}
|
|
3131
|
+
// Pre-define numbers in range [-999,999]
|
|
3132
|
+
for (var i = 0; i < 1000; i++) {
|
|
3133
|
+
Integer[i] = parseValue(i);
|
|
3134
|
+
if (i > 0) Integer[-i] = parseValue(-i);
|
|
3135
|
+
}
|
|
3136
|
+
// Backwards compatibility
|
|
3137
|
+
Integer.one = Integer[1];
|
|
3138
|
+
Integer.zero = Integer[0];
|
|
3139
|
+
Integer.minusOne = Integer[-1];
|
|
3140
|
+
Integer.max = max;
|
|
3141
|
+
Integer.min = min;
|
|
3142
|
+
Integer.gcd = gcd;
|
|
3143
|
+
Integer.lcm = lcm;
|
|
3144
|
+
Integer.isInstance = function (x) { return x instanceof BigInteger || x instanceof SmallInteger || x instanceof NativeBigInt; };
|
|
3145
|
+
Integer.randBetween = randBetween;
|
|
3146
|
+
|
|
3147
|
+
Integer.fromArray = function (digits, base, isNegative) {
|
|
3148
|
+
return parseBaseFromArray(digits.map(parseValue), parseValue(base || 10), isNegative);
|
|
3149
|
+
};
|
|
3150
|
+
|
|
3151
|
+
return Integer;
|
|
3152
|
+
})();
|
|
3153
|
+
|
|
3154
|
+
// Node.js check
|
|
3155
|
+
if ( true && module.hasOwnProperty("exports")) {
|
|
3156
|
+
module.exports = bigInt;
|
|
3157
|
+
}
|
|
3158
|
+
|
|
3159
|
+
//amd check
|
|
3160
|
+
if (true) {
|
|
3161
|
+
!(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {
|
|
3162
|
+
return bigInt;
|
|
3163
|
+
}).call(exports, __webpack_require__, exports, module),
|
|
3164
|
+
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
|
3165
|
+
}
|
|
3166
|
+
|
|
3167
|
+
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__("uAlt")(module)))
|
|
3168
|
+
|
|
3169
|
+
/***/ }),
|
|
3170
|
+
|
|
3171
|
+
/***/ "h6FB":
|
|
3172
|
+
/***/ (function(module, exports) {
|
|
3173
|
+
|
|
3174
|
+
|
|
3175
|
+
|
|
3176
|
+
/***/ }),
|
|
3177
|
+
|
|
3178
|
+
/***/ "lQRP":
|
|
3179
|
+
/***/ (function(module, exports) {
|
|
3180
|
+
|
|
3181
|
+
|
|
3182
|
+
|
|
3183
|
+
/***/ }),
|
|
3184
|
+
|
|
3185
|
+
/***/ "nvhJ":
|
|
3186
|
+
/***/ (function(module, exports) {
|
|
3187
|
+
|
|
3188
|
+
|
|
3189
|
+
|
|
3190
|
+
/***/ }),
|
|
3191
|
+
|
|
3192
|
+
/***/ "uAlt":
|
|
3193
|
+
/***/ (function(module, exports) {
|
|
3194
|
+
|
|
3195
|
+
module.exports = function(module) {
|
|
3196
|
+
if (!module.webpackPolyfill) {
|
|
3197
|
+
module.deprecate = function() {};
|
|
3198
|
+
module.paths = [];
|
|
3199
|
+
// module.parent = undefined by default
|
|
3200
|
+
if (!module.children) module.children = [];
|
|
3201
|
+
Object.defineProperty(module, "loaded", {
|
|
3202
|
+
enumerable: true,
|
|
3203
|
+
get: function() {
|
|
3204
|
+
return module.l;
|
|
3205
|
+
}
|
|
3206
|
+
});
|
|
3207
|
+
Object.defineProperty(module, "id", {
|
|
3208
|
+
enumerable: true,
|
|
3209
|
+
get: function() {
|
|
3210
|
+
return module.i;
|
|
3211
|
+
}
|
|
3212
|
+
});
|
|
3213
|
+
module.webpackPolyfill = 1;
|
|
3214
|
+
}
|
|
3215
|
+
return module;
|
|
3216
|
+
};
|
|
3217
|
+
|
|
3218
|
+
|
|
3219
|
+
/***/ })
|
|
3220
|
+
|
|
3221
|
+
/******/ });
|
|
3222
|
+
});
|
|
3223
|
+
//# sourceMappingURL=index.js.map
|