pompelmi 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pompelmi.cjs +2340 -0
- package/dist/pompelmi.cjs.map +1 -0
- package/dist/pompelmi.esm.js +2326 -0
- package/dist/pompelmi.esm.js.map +1 -0
- package/dist/types/browser-index.d.ts +3 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/magic.d.ts +7 -0
- package/dist/types/node/scanDir.d.ts +30 -0
- package/dist/types/policy.d.ts +12 -0
- package/dist/types/presets.d.ts +7 -0
- package/dist/types/risk.d.ts +18 -0
- package/dist/types/scan/remote.d.ts +12 -0
- package/dist/types/scan.d.ts +12 -0
- package/dist/types/scanners/common-heuristics.d.ts +14 -0
- package/dist/types/scanners/zip-bomb-guard.d.ts +9 -0
- package/dist/types/scanners/zipTraversalGuard.d.ts +19 -0
- package/dist/types/stream.d.ts +10 -0
- package/dist/types/types.d.ts +48 -0
- package/dist/types/useFileScanner.d.ts +15 -0
- package/dist/types/validate.d.ts +7 -0
- package/dist/types/verdict.d.ts +2 -0
- package/dist/types/yara/browser.d.ts +7 -0
- package/dist/types/yara/index.d.ts +17 -0
- package/dist/types/yara/node.d.ts +2 -0
- package/dist/types/yara/remote.d.ts +10 -0
- package/dist/types/yara-bridge.d.ts +3 -0
- package/dist/types/zip.d.ts +13 -0
- package/package.json +1 -1
|
@@ -0,0 +1,2326 @@
|
|
|
1
|
+
function toScanFn(s) {
|
|
2
|
+
return (typeof s === "function" ? s : s.scan);
|
|
3
|
+
}
|
|
4
|
+
function composeScanners(...scanners) {
|
|
5
|
+
return async (input, ctx) => {
|
|
6
|
+
const all = [];
|
|
7
|
+
for (const s of scanners) {
|
|
8
|
+
try {
|
|
9
|
+
const out = await toScanFn(s)(input, ctx);
|
|
10
|
+
if (Array.isArray(out))
|
|
11
|
+
all.push(...out);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
// ignore individual scanner failures
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return all;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function createPresetScanner(_preset, _opts = {}) {
|
|
21
|
+
// TODO: wire to real preset registry
|
|
22
|
+
return async (_input, _ctx) => {
|
|
23
|
+
return [];
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Mappa veloce estensione -> mime (basic) */
|
|
28
|
+
function guessMimeByExt(name) {
|
|
29
|
+
if (!name)
|
|
30
|
+
return;
|
|
31
|
+
const ext = name.toLowerCase().split('.').pop();
|
|
32
|
+
switch (ext) {
|
|
33
|
+
case 'zip': return 'application/zip';
|
|
34
|
+
case 'png': return 'image/png';
|
|
35
|
+
case 'jpg':
|
|
36
|
+
case 'jpeg': return 'image/jpeg';
|
|
37
|
+
case 'pdf': return 'application/pdf';
|
|
38
|
+
case 'txt': return 'text/plain';
|
|
39
|
+
default: return;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Heuristica semplice per verdetto */
|
|
43
|
+
function computeVerdict(matches) {
|
|
44
|
+
if (!matches.length)
|
|
45
|
+
return 'clean';
|
|
46
|
+
// se la regola contiene 'zip_' lo marchiamo "suspicious"
|
|
47
|
+
const anyHigh = matches.some(m => (m.tags ?? []).includes('critical') || (m.tags ?? []).includes('high'));
|
|
48
|
+
return anyHigh ? 'malicious' : 'suspicious';
|
|
49
|
+
}
|
|
50
|
+
/** Converte i Match (heuristics) in YaraMatch-like per uniformare l'output */
|
|
51
|
+
function toYaraMatches(ms) {
|
|
52
|
+
return ms.map(m => ({
|
|
53
|
+
rule: m.rule,
|
|
54
|
+
namespace: 'heuristics',
|
|
55
|
+
tags: ['heuristics'].concat(m.severity ? [m.severity] : []),
|
|
56
|
+
meta: m.meta,
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
/** Scan di bytes (browser/node) usando preset (default: zip-basic) */
|
|
60
|
+
async function scanBytes(input, opts = {}) {
|
|
61
|
+
const t0 = Date.now();
|
|
62
|
+
opts.preset ?? 'zip-basic';
|
|
63
|
+
const ctx = {
|
|
64
|
+
...opts.ctx,
|
|
65
|
+
mimeType: opts.ctx?.mimeType ?? guessMimeByExt(opts.ctx?.filename),
|
|
66
|
+
size: opts.ctx?.size ?? input.byteLength,
|
|
67
|
+
};
|
|
68
|
+
const scanFn = createPresetScanner();
|
|
69
|
+
const matchesH = await (typeof scanFn === "function" ? scanFn : scanFn.scan)(input, ctx);
|
|
70
|
+
const matches = toYaraMatches(matchesH);
|
|
71
|
+
const verdict = computeVerdict(matches);
|
|
72
|
+
const durationMs = Date.now() - t0;
|
|
73
|
+
return {
|
|
74
|
+
ok: verdict === 'clean',
|
|
75
|
+
verdict,
|
|
76
|
+
matches,
|
|
77
|
+
reasons: matches.map(m => m.rule),
|
|
78
|
+
file: { name: ctx.filename, mimeType: ctx.mimeType, size: ctx.size },
|
|
79
|
+
durationMs,
|
|
80
|
+
engine: 'heuristics',
|
|
81
|
+
truncated: false,
|
|
82
|
+
timedOut: false,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** Scan di un file su disco (Node). Import dinamico per non vincolare il bundle browser. */
|
|
86
|
+
async function scanFile(filePath, opts = {}) {
|
|
87
|
+
const [{ readFile, stat }, path] = await Promise.all([
|
|
88
|
+
import('fs/promises'),
|
|
89
|
+
import('path'),
|
|
90
|
+
]);
|
|
91
|
+
const [buf, st] = await Promise.all([readFile(filePath), stat(filePath)]);
|
|
92
|
+
const ctx = {
|
|
93
|
+
filename: path.basename(filePath),
|
|
94
|
+
mimeType: guessMimeByExt(filePath),
|
|
95
|
+
size: st.size,
|
|
96
|
+
};
|
|
97
|
+
return scanBytes(new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength), { ...opts, ctx });
|
|
98
|
+
}
|
|
99
|
+
/** Scan multipli File (browser) usando scanBytes + preset di default */
|
|
100
|
+
async function scanFiles(files, opts = {}) {
|
|
101
|
+
const list = Array.from(files);
|
|
102
|
+
const out = [];
|
|
103
|
+
for (const f of list) {
|
|
104
|
+
const buf = new Uint8Array(await f.arrayBuffer());
|
|
105
|
+
const rep = await scanBytes(buf, {
|
|
106
|
+
...opts,
|
|
107
|
+
ctx: { filename: f.name, mimeType: f.type || guessMimeByExt(f.name), size: f.size },
|
|
108
|
+
});
|
|
109
|
+
out.push(rep);
|
|
110
|
+
}
|
|
111
|
+
return out;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Validates a File by MIME type and size (max 5 MB).
|
|
116
|
+
*/
|
|
117
|
+
function validateFile(file) {
|
|
118
|
+
const maxSize = 5 * 1024 * 1024;
|
|
119
|
+
const allowedTypes = ['text/plain', 'application/json', 'text/csv'];
|
|
120
|
+
if (!allowedTypes.includes(file.type)) {
|
|
121
|
+
return { valid: false, error: 'Unsupported file type' };
|
|
122
|
+
}
|
|
123
|
+
if (file.size > maxSize) {
|
|
124
|
+
return { valid: false, error: 'File too large (max 5 MB)' };
|
|
125
|
+
}
|
|
126
|
+
return { valid: true };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
var react = {exports: {}};
|
|
130
|
+
|
|
131
|
+
var react_production = {};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @license React
|
|
135
|
+
* react.production.js
|
|
136
|
+
*
|
|
137
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
138
|
+
*
|
|
139
|
+
* This source code is licensed under the MIT license found in the
|
|
140
|
+
* LICENSE file in the root directory of this source tree.
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
var hasRequiredReact_production;
|
|
144
|
+
|
|
145
|
+
function requireReact_production () {
|
|
146
|
+
if (hasRequiredReact_production) return react_production;
|
|
147
|
+
hasRequiredReact_production = 1;
|
|
148
|
+
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
|
149
|
+
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
|
|
150
|
+
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
|
|
151
|
+
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
|
|
152
|
+
REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
|
|
153
|
+
REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
|
|
154
|
+
REACT_CONTEXT_TYPE = Symbol.for("react.context"),
|
|
155
|
+
REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
|
|
156
|
+
REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
|
|
157
|
+
REACT_MEMO_TYPE = Symbol.for("react.memo"),
|
|
158
|
+
REACT_LAZY_TYPE = Symbol.for("react.lazy"),
|
|
159
|
+
REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
|
|
160
|
+
MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
|
161
|
+
function getIteratorFn(maybeIterable) {
|
|
162
|
+
if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
|
|
163
|
+
maybeIterable =
|
|
164
|
+
(MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) ||
|
|
165
|
+
maybeIterable["@@iterator"];
|
|
166
|
+
return "function" === typeof maybeIterable ? maybeIterable : null;
|
|
167
|
+
}
|
|
168
|
+
var ReactNoopUpdateQueue = {
|
|
169
|
+
isMounted: function () {
|
|
170
|
+
return false;
|
|
171
|
+
},
|
|
172
|
+
enqueueForceUpdate: function () {},
|
|
173
|
+
enqueueReplaceState: function () {},
|
|
174
|
+
enqueueSetState: function () {}
|
|
175
|
+
},
|
|
176
|
+
assign = Object.assign,
|
|
177
|
+
emptyObject = {};
|
|
178
|
+
function Component(props, context, updater) {
|
|
179
|
+
this.props = props;
|
|
180
|
+
this.context = context;
|
|
181
|
+
this.refs = emptyObject;
|
|
182
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
183
|
+
}
|
|
184
|
+
Component.prototype.isReactComponent = {};
|
|
185
|
+
Component.prototype.setState = function (partialState, callback) {
|
|
186
|
+
if (
|
|
187
|
+
"object" !== typeof partialState &&
|
|
188
|
+
"function" !== typeof partialState &&
|
|
189
|
+
null != partialState
|
|
190
|
+
)
|
|
191
|
+
throw Error(
|
|
192
|
+
"takes an object of state variables to update or a function which returns an object of state variables."
|
|
193
|
+
);
|
|
194
|
+
this.updater.enqueueSetState(this, partialState, callback, "setState");
|
|
195
|
+
};
|
|
196
|
+
Component.prototype.forceUpdate = function (callback) {
|
|
197
|
+
this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
|
|
198
|
+
};
|
|
199
|
+
function ComponentDummy() {}
|
|
200
|
+
ComponentDummy.prototype = Component.prototype;
|
|
201
|
+
function PureComponent(props, context, updater) {
|
|
202
|
+
this.props = props;
|
|
203
|
+
this.context = context;
|
|
204
|
+
this.refs = emptyObject;
|
|
205
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
206
|
+
}
|
|
207
|
+
var pureComponentPrototype = (PureComponent.prototype = new ComponentDummy());
|
|
208
|
+
pureComponentPrototype.constructor = PureComponent;
|
|
209
|
+
assign(pureComponentPrototype, Component.prototype);
|
|
210
|
+
pureComponentPrototype.isPureReactComponent = true;
|
|
211
|
+
var isArrayImpl = Array.isArray;
|
|
212
|
+
function noop() {}
|
|
213
|
+
var ReactSharedInternals = { H: null, A: null, T: null, S: null },
|
|
214
|
+
hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
215
|
+
function ReactElement(type, key, props) {
|
|
216
|
+
var refProp = props.ref;
|
|
217
|
+
return {
|
|
218
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
219
|
+
type: type,
|
|
220
|
+
key: key,
|
|
221
|
+
ref: void 0 !== refProp ? refProp : null,
|
|
222
|
+
props: props
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
function cloneAndReplaceKey(oldElement, newKey) {
|
|
226
|
+
return ReactElement(oldElement.type, newKey, oldElement.props);
|
|
227
|
+
}
|
|
228
|
+
function isValidElement(object) {
|
|
229
|
+
return (
|
|
230
|
+
"object" === typeof object &&
|
|
231
|
+
null !== object &&
|
|
232
|
+
object.$$typeof === REACT_ELEMENT_TYPE
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
function escape(key) {
|
|
236
|
+
var escaperLookup = { "=": "=0", ":": "=2" };
|
|
237
|
+
return (
|
|
238
|
+
"$" +
|
|
239
|
+
key.replace(/[=:]/g, function (match) {
|
|
240
|
+
return escaperLookup[match];
|
|
241
|
+
})
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
var userProvidedKeyEscapeRegex = /\/+/g;
|
|
245
|
+
function getElementKey(element, index) {
|
|
246
|
+
return "object" === typeof element && null !== element && null != element.key
|
|
247
|
+
? escape("" + element.key)
|
|
248
|
+
: index.toString(36);
|
|
249
|
+
}
|
|
250
|
+
function resolveThenable(thenable) {
|
|
251
|
+
switch (thenable.status) {
|
|
252
|
+
case "fulfilled":
|
|
253
|
+
return thenable.value;
|
|
254
|
+
case "rejected":
|
|
255
|
+
throw thenable.reason;
|
|
256
|
+
default:
|
|
257
|
+
switch (
|
|
258
|
+
("string" === typeof thenable.status
|
|
259
|
+
? thenable.then(noop, noop)
|
|
260
|
+
: ((thenable.status = "pending"),
|
|
261
|
+
thenable.then(
|
|
262
|
+
function (fulfilledValue) {
|
|
263
|
+
"pending" === thenable.status &&
|
|
264
|
+
((thenable.status = "fulfilled"),
|
|
265
|
+
(thenable.value = fulfilledValue));
|
|
266
|
+
},
|
|
267
|
+
function (error) {
|
|
268
|
+
"pending" === thenable.status &&
|
|
269
|
+
((thenable.status = "rejected"), (thenable.reason = error));
|
|
270
|
+
}
|
|
271
|
+
)),
|
|
272
|
+
thenable.status)
|
|
273
|
+
) {
|
|
274
|
+
case "fulfilled":
|
|
275
|
+
return thenable.value;
|
|
276
|
+
case "rejected":
|
|
277
|
+
throw thenable.reason;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
throw thenable;
|
|
281
|
+
}
|
|
282
|
+
function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
|
|
283
|
+
var type = typeof children;
|
|
284
|
+
if ("undefined" === type || "boolean" === type) children = null;
|
|
285
|
+
var invokeCallback = false;
|
|
286
|
+
if (null === children) invokeCallback = true;
|
|
287
|
+
else
|
|
288
|
+
switch (type) {
|
|
289
|
+
case "bigint":
|
|
290
|
+
case "string":
|
|
291
|
+
case "number":
|
|
292
|
+
invokeCallback = true;
|
|
293
|
+
break;
|
|
294
|
+
case "object":
|
|
295
|
+
switch (children.$$typeof) {
|
|
296
|
+
case REACT_ELEMENT_TYPE:
|
|
297
|
+
case REACT_PORTAL_TYPE:
|
|
298
|
+
invokeCallback = true;
|
|
299
|
+
break;
|
|
300
|
+
case REACT_LAZY_TYPE:
|
|
301
|
+
return (
|
|
302
|
+
(invokeCallback = children._init),
|
|
303
|
+
mapIntoArray(
|
|
304
|
+
invokeCallback(children._payload),
|
|
305
|
+
array,
|
|
306
|
+
escapedPrefix,
|
|
307
|
+
nameSoFar,
|
|
308
|
+
callback
|
|
309
|
+
)
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
if (invokeCallback)
|
|
314
|
+
return (
|
|
315
|
+
(callback = callback(children)),
|
|
316
|
+
(invokeCallback =
|
|
317
|
+
"" === nameSoFar ? "." + getElementKey(children, 0) : nameSoFar),
|
|
318
|
+
isArrayImpl(callback)
|
|
319
|
+
? ((escapedPrefix = ""),
|
|
320
|
+
null != invokeCallback &&
|
|
321
|
+
(escapedPrefix =
|
|
322
|
+
invokeCallback.replace(userProvidedKeyEscapeRegex, "$&/") + "/"),
|
|
323
|
+
mapIntoArray(callback, array, escapedPrefix, "", function (c) {
|
|
324
|
+
return c;
|
|
325
|
+
}))
|
|
326
|
+
: null != callback &&
|
|
327
|
+
(isValidElement(callback) &&
|
|
328
|
+
(callback = cloneAndReplaceKey(
|
|
329
|
+
callback,
|
|
330
|
+
escapedPrefix +
|
|
331
|
+
(null == callback.key ||
|
|
332
|
+
(children && children.key === callback.key)
|
|
333
|
+
? ""
|
|
334
|
+
: ("" + callback.key).replace(
|
|
335
|
+
userProvidedKeyEscapeRegex,
|
|
336
|
+
"$&/"
|
|
337
|
+
) + "/") +
|
|
338
|
+
invokeCallback
|
|
339
|
+
)),
|
|
340
|
+
array.push(callback)),
|
|
341
|
+
1
|
|
342
|
+
);
|
|
343
|
+
invokeCallback = 0;
|
|
344
|
+
var nextNamePrefix = "" === nameSoFar ? "." : nameSoFar + ":";
|
|
345
|
+
if (isArrayImpl(children))
|
|
346
|
+
for (var i = 0; i < children.length; i++)
|
|
347
|
+
(nameSoFar = children[i]),
|
|
348
|
+
(type = nextNamePrefix + getElementKey(nameSoFar, i)),
|
|
349
|
+
(invokeCallback += mapIntoArray(
|
|
350
|
+
nameSoFar,
|
|
351
|
+
array,
|
|
352
|
+
escapedPrefix,
|
|
353
|
+
type,
|
|
354
|
+
callback
|
|
355
|
+
));
|
|
356
|
+
else if (((i = getIteratorFn(children)), "function" === typeof i))
|
|
357
|
+
for (
|
|
358
|
+
children = i.call(children), i = 0;
|
|
359
|
+
!(nameSoFar = children.next()).done;
|
|
360
|
+
|
|
361
|
+
)
|
|
362
|
+
(nameSoFar = nameSoFar.value),
|
|
363
|
+
(type = nextNamePrefix + getElementKey(nameSoFar, i++)),
|
|
364
|
+
(invokeCallback += mapIntoArray(
|
|
365
|
+
nameSoFar,
|
|
366
|
+
array,
|
|
367
|
+
escapedPrefix,
|
|
368
|
+
type,
|
|
369
|
+
callback
|
|
370
|
+
));
|
|
371
|
+
else if ("object" === type) {
|
|
372
|
+
if ("function" === typeof children.then)
|
|
373
|
+
return mapIntoArray(
|
|
374
|
+
resolveThenable(children),
|
|
375
|
+
array,
|
|
376
|
+
escapedPrefix,
|
|
377
|
+
nameSoFar,
|
|
378
|
+
callback
|
|
379
|
+
);
|
|
380
|
+
array = String(children);
|
|
381
|
+
throw Error(
|
|
382
|
+
"Objects are not valid as a React child (found: " +
|
|
383
|
+
("[object Object]" === array
|
|
384
|
+
? "object with keys {" + Object.keys(children).join(", ") + "}"
|
|
385
|
+
: array) +
|
|
386
|
+
"). If you meant to render a collection of children, use an array instead."
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
return invokeCallback;
|
|
390
|
+
}
|
|
391
|
+
function mapChildren(children, func, context) {
|
|
392
|
+
if (null == children) return children;
|
|
393
|
+
var result = [],
|
|
394
|
+
count = 0;
|
|
395
|
+
mapIntoArray(children, result, "", "", function (child) {
|
|
396
|
+
return func.call(context, child, count++);
|
|
397
|
+
});
|
|
398
|
+
return result;
|
|
399
|
+
}
|
|
400
|
+
function lazyInitializer(payload) {
|
|
401
|
+
if (-1 === payload._status) {
|
|
402
|
+
var ctor = payload._result;
|
|
403
|
+
ctor = ctor();
|
|
404
|
+
ctor.then(
|
|
405
|
+
function (moduleObject) {
|
|
406
|
+
if (0 === payload._status || -1 === payload._status)
|
|
407
|
+
(payload._status = 1), (payload._result = moduleObject);
|
|
408
|
+
},
|
|
409
|
+
function (error) {
|
|
410
|
+
if (0 === payload._status || -1 === payload._status)
|
|
411
|
+
(payload._status = 2), (payload._result = error);
|
|
412
|
+
}
|
|
413
|
+
);
|
|
414
|
+
-1 === payload._status && ((payload._status = 0), (payload._result = ctor));
|
|
415
|
+
}
|
|
416
|
+
if (1 === payload._status) return payload._result.default;
|
|
417
|
+
throw payload._result;
|
|
418
|
+
}
|
|
419
|
+
var reportGlobalError =
|
|
420
|
+
"function" === typeof reportError
|
|
421
|
+
? reportError
|
|
422
|
+
: function (error) {
|
|
423
|
+
if (
|
|
424
|
+
"object" === typeof window &&
|
|
425
|
+
"function" === typeof window.ErrorEvent
|
|
426
|
+
) {
|
|
427
|
+
var event = new window.ErrorEvent("error", {
|
|
428
|
+
bubbles: true,
|
|
429
|
+
cancelable: true,
|
|
430
|
+
message:
|
|
431
|
+
"object" === typeof error &&
|
|
432
|
+
null !== error &&
|
|
433
|
+
"string" === typeof error.message
|
|
434
|
+
? String(error.message)
|
|
435
|
+
: String(error),
|
|
436
|
+
error: error
|
|
437
|
+
});
|
|
438
|
+
if (!window.dispatchEvent(event)) return;
|
|
439
|
+
} else if (
|
|
440
|
+
"object" === typeof process &&
|
|
441
|
+
"function" === typeof process.emit
|
|
442
|
+
) {
|
|
443
|
+
process.emit("uncaughtException", error);
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
console.error(error);
|
|
447
|
+
},
|
|
448
|
+
Children = {
|
|
449
|
+
map: mapChildren,
|
|
450
|
+
forEach: function (children, forEachFunc, forEachContext) {
|
|
451
|
+
mapChildren(
|
|
452
|
+
children,
|
|
453
|
+
function () {
|
|
454
|
+
forEachFunc.apply(this, arguments);
|
|
455
|
+
},
|
|
456
|
+
forEachContext
|
|
457
|
+
);
|
|
458
|
+
},
|
|
459
|
+
count: function (children) {
|
|
460
|
+
var n = 0;
|
|
461
|
+
mapChildren(children, function () {
|
|
462
|
+
n++;
|
|
463
|
+
});
|
|
464
|
+
return n;
|
|
465
|
+
},
|
|
466
|
+
toArray: function (children) {
|
|
467
|
+
return (
|
|
468
|
+
mapChildren(children, function (child) {
|
|
469
|
+
return child;
|
|
470
|
+
}) || []
|
|
471
|
+
);
|
|
472
|
+
},
|
|
473
|
+
only: function (children) {
|
|
474
|
+
if (!isValidElement(children))
|
|
475
|
+
throw Error(
|
|
476
|
+
"React.Children.only expected to receive a single React element child."
|
|
477
|
+
);
|
|
478
|
+
return children;
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
react_production.Activity = REACT_ACTIVITY_TYPE;
|
|
482
|
+
react_production.Children = Children;
|
|
483
|
+
react_production.Component = Component;
|
|
484
|
+
react_production.Fragment = REACT_FRAGMENT_TYPE;
|
|
485
|
+
react_production.Profiler = REACT_PROFILER_TYPE;
|
|
486
|
+
react_production.PureComponent = PureComponent;
|
|
487
|
+
react_production.StrictMode = REACT_STRICT_MODE_TYPE;
|
|
488
|
+
react_production.Suspense = REACT_SUSPENSE_TYPE;
|
|
489
|
+
react_production.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE =
|
|
490
|
+
ReactSharedInternals;
|
|
491
|
+
react_production.__COMPILER_RUNTIME = {
|
|
492
|
+
__proto__: null,
|
|
493
|
+
c: function (size) {
|
|
494
|
+
return ReactSharedInternals.H.useMemoCache(size);
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
react_production.cache = function (fn) {
|
|
498
|
+
return function () {
|
|
499
|
+
return fn.apply(null, arguments);
|
|
500
|
+
};
|
|
501
|
+
};
|
|
502
|
+
react_production.cacheSignal = function () {
|
|
503
|
+
return null;
|
|
504
|
+
};
|
|
505
|
+
react_production.cloneElement = function (element, config, children) {
|
|
506
|
+
if (null === element || void 0 === element)
|
|
507
|
+
throw Error(
|
|
508
|
+
"The argument must be a React element, but you passed " + element + "."
|
|
509
|
+
);
|
|
510
|
+
var props = assign({}, element.props),
|
|
511
|
+
key = element.key;
|
|
512
|
+
if (null != config)
|
|
513
|
+
for (propName in (void 0 !== config.key && (key = "" + config.key), config))
|
|
514
|
+
!hasOwnProperty.call(config, propName) ||
|
|
515
|
+
"key" === propName ||
|
|
516
|
+
"__self" === propName ||
|
|
517
|
+
"__source" === propName ||
|
|
518
|
+
("ref" === propName && void 0 === config.ref) ||
|
|
519
|
+
(props[propName] = config[propName]);
|
|
520
|
+
var propName = arguments.length - 2;
|
|
521
|
+
if (1 === propName) props.children = children;
|
|
522
|
+
else if (1 < propName) {
|
|
523
|
+
for (var childArray = Array(propName), i = 0; i < propName; i++)
|
|
524
|
+
childArray[i] = arguments[i + 2];
|
|
525
|
+
props.children = childArray;
|
|
526
|
+
}
|
|
527
|
+
return ReactElement(element.type, key, props);
|
|
528
|
+
};
|
|
529
|
+
react_production.createContext = function (defaultValue) {
|
|
530
|
+
defaultValue = {
|
|
531
|
+
$$typeof: REACT_CONTEXT_TYPE,
|
|
532
|
+
_currentValue: defaultValue,
|
|
533
|
+
_currentValue2: defaultValue,
|
|
534
|
+
_threadCount: 0,
|
|
535
|
+
Provider: null,
|
|
536
|
+
Consumer: null
|
|
537
|
+
};
|
|
538
|
+
defaultValue.Provider = defaultValue;
|
|
539
|
+
defaultValue.Consumer = {
|
|
540
|
+
$$typeof: REACT_CONSUMER_TYPE,
|
|
541
|
+
_context: defaultValue
|
|
542
|
+
};
|
|
543
|
+
return defaultValue;
|
|
544
|
+
};
|
|
545
|
+
react_production.createElement = function (type, config, children) {
|
|
546
|
+
var propName,
|
|
547
|
+
props = {},
|
|
548
|
+
key = null;
|
|
549
|
+
if (null != config)
|
|
550
|
+
for (propName in (void 0 !== config.key && (key = "" + config.key), config))
|
|
551
|
+
hasOwnProperty.call(config, propName) &&
|
|
552
|
+
"key" !== propName &&
|
|
553
|
+
"__self" !== propName &&
|
|
554
|
+
"__source" !== propName &&
|
|
555
|
+
(props[propName] = config[propName]);
|
|
556
|
+
var childrenLength = arguments.length - 2;
|
|
557
|
+
if (1 === childrenLength) props.children = children;
|
|
558
|
+
else if (1 < childrenLength) {
|
|
559
|
+
for (var childArray = Array(childrenLength), i = 0; i < childrenLength; i++)
|
|
560
|
+
childArray[i] = arguments[i + 2];
|
|
561
|
+
props.children = childArray;
|
|
562
|
+
}
|
|
563
|
+
if (type && type.defaultProps)
|
|
564
|
+
for (propName in ((childrenLength = type.defaultProps), childrenLength))
|
|
565
|
+
void 0 === props[propName] &&
|
|
566
|
+
(props[propName] = childrenLength[propName]);
|
|
567
|
+
return ReactElement(type, key, props);
|
|
568
|
+
};
|
|
569
|
+
react_production.createRef = function () {
|
|
570
|
+
return { current: null };
|
|
571
|
+
};
|
|
572
|
+
react_production.forwardRef = function (render) {
|
|
573
|
+
return { $$typeof: REACT_FORWARD_REF_TYPE, render: render };
|
|
574
|
+
};
|
|
575
|
+
react_production.isValidElement = isValidElement;
|
|
576
|
+
react_production.lazy = function (ctor) {
|
|
577
|
+
return {
|
|
578
|
+
$$typeof: REACT_LAZY_TYPE,
|
|
579
|
+
_payload: { _status: -1, _result: ctor },
|
|
580
|
+
_init: lazyInitializer
|
|
581
|
+
};
|
|
582
|
+
};
|
|
583
|
+
react_production.memo = function (type, compare) {
|
|
584
|
+
return {
|
|
585
|
+
$$typeof: REACT_MEMO_TYPE,
|
|
586
|
+
type: type,
|
|
587
|
+
compare: void 0 === compare ? null : compare
|
|
588
|
+
};
|
|
589
|
+
};
|
|
590
|
+
react_production.startTransition = function (scope) {
|
|
591
|
+
var prevTransition = ReactSharedInternals.T,
|
|
592
|
+
currentTransition = {};
|
|
593
|
+
ReactSharedInternals.T = currentTransition;
|
|
594
|
+
try {
|
|
595
|
+
var returnValue = scope(),
|
|
596
|
+
onStartTransitionFinish = ReactSharedInternals.S;
|
|
597
|
+
null !== onStartTransitionFinish &&
|
|
598
|
+
onStartTransitionFinish(currentTransition, returnValue);
|
|
599
|
+
"object" === typeof returnValue &&
|
|
600
|
+
null !== returnValue &&
|
|
601
|
+
"function" === typeof returnValue.then &&
|
|
602
|
+
returnValue.then(noop, reportGlobalError);
|
|
603
|
+
} catch (error) {
|
|
604
|
+
reportGlobalError(error);
|
|
605
|
+
} finally {
|
|
606
|
+
null !== prevTransition &&
|
|
607
|
+
null !== currentTransition.types &&
|
|
608
|
+
(prevTransition.types = currentTransition.types),
|
|
609
|
+
(ReactSharedInternals.T = prevTransition);
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
react_production.unstable_useCacheRefresh = function () {
|
|
613
|
+
return ReactSharedInternals.H.useCacheRefresh();
|
|
614
|
+
};
|
|
615
|
+
react_production.use = function (usable) {
|
|
616
|
+
return ReactSharedInternals.H.use(usable);
|
|
617
|
+
};
|
|
618
|
+
react_production.useActionState = function (action, initialState, permalink) {
|
|
619
|
+
return ReactSharedInternals.H.useActionState(action, initialState, permalink);
|
|
620
|
+
};
|
|
621
|
+
react_production.useCallback = function (callback, deps) {
|
|
622
|
+
return ReactSharedInternals.H.useCallback(callback, deps);
|
|
623
|
+
};
|
|
624
|
+
react_production.useContext = function (Context) {
|
|
625
|
+
return ReactSharedInternals.H.useContext(Context);
|
|
626
|
+
};
|
|
627
|
+
react_production.useDebugValue = function () {};
|
|
628
|
+
react_production.useDeferredValue = function (value, initialValue) {
|
|
629
|
+
return ReactSharedInternals.H.useDeferredValue(value, initialValue);
|
|
630
|
+
};
|
|
631
|
+
react_production.useEffect = function (create, deps) {
|
|
632
|
+
return ReactSharedInternals.H.useEffect(create, deps);
|
|
633
|
+
};
|
|
634
|
+
react_production.useEffectEvent = function (callback) {
|
|
635
|
+
return ReactSharedInternals.H.useEffectEvent(callback);
|
|
636
|
+
};
|
|
637
|
+
react_production.useId = function () {
|
|
638
|
+
return ReactSharedInternals.H.useId();
|
|
639
|
+
};
|
|
640
|
+
react_production.useImperativeHandle = function (ref, create, deps) {
|
|
641
|
+
return ReactSharedInternals.H.useImperativeHandle(ref, create, deps);
|
|
642
|
+
};
|
|
643
|
+
react_production.useInsertionEffect = function (create, deps) {
|
|
644
|
+
return ReactSharedInternals.H.useInsertionEffect(create, deps);
|
|
645
|
+
};
|
|
646
|
+
react_production.useLayoutEffect = function (create, deps) {
|
|
647
|
+
return ReactSharedInternals.H.useLayoutEffect(create, deps);
|
|
648
|
+
};
|
|
649
|
+
react_production.useMemo = function (create, deps) {
|
|
650
|
+
return ReactSharedInternals.H.useMemo(create, deps);
|
|
651
|
+
};
|
|
652
|
+
react_production.useOptimistic = function (passthrough, reducer) {
|
|
653
|
+
return ReactSharedInternals.H.useOptimistic(passthrough, reducer);
|
|
654
|
+
};
|
|
655
|
+
react_production.useReducer = function (reducer, initialArg, init) {
|
|
656
|
+
return ReactSharedInternals.H.useReducer(reducer, initialArg, init);
|
|
657
|
+
};
|
|
658
|
+
react_production.useRef = function (initialValue) {
|
|
659
|
+
return ReactSharedInternals.H.useRef(initialValue);
|
|
660
|
+
};
|
|
661
|
+
react_production.useState = function (initialState) {
|
|
662
|
+
return ReactSharedInternals.H.useState(initialState);
|
|
663
|
+
};
|
|
664
|
+
react_production.useSyncExternalStore = function (
|
|
665
|
+
subscribe,
|
|
666
|
+
getSnapshot,
|
|
667
|
+
getServerSnapshot
|
|
668
|
+
) {
|
|
669
|
+
return ReactSharedInternals.H.useSyncExternalStore(
|
|
670
|
+
subscribe,
|
|
671
|
+
getSnapshot,
|
|
672
|
+
getServerSnapshot
|
|
673
|
+
);
|
|
674
|
+
};
|
|
675
|
+
react_production.useTransition = function () {
|
|
676
|
+
return ReactSharedInternals.H.useTransition();
|
|
677
|
+
};
|
|
678
|
+
react_production.version = "19.2.0";
|
|
679
|
+
return react_production;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
var react_development = {exports: {}};
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* @license React
|
|
686
|
+
* react.development.js
|
|
687
|
+
*
|
|
688
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
689
|
+
*
|
|
690
|
+
* This source code is licensed under the MIT license found in the
|
|
691
|
+
* LICENSE file in the root directory of this source tree.
|
|
692
|
+
*/
|
|
693
|
+
react_development.exports;
|
|
694
|
+
|
|
695
|
+
var hasRequiredReact_development;
|
|
696
|
+
|
|
697
|
+
function requireReact_development () {
|
|
698
|
+
if (hasRequiredReact_development) return react_development.exports;
|
|
699
|
+
hasRequiredReact_development = 1;
|
|
700
|
+
(function (module, exports) {
|
|
701
|
+
"production" !== process.env.NODE_ENV &&
|
|
702
|
+
(function () {
|
|
703
|
+
function defineDeprecationWarning(methodName, info) {
|
|
704
|
+
Object.defineProperty(Component.prototype, methodName, {
|
|
705
|
+
get: function () {
|
|
706
|
+
console.warn(
|
|
707
|
+
"%s(...) is deprecated in plain JavaScript React classes. %s",
|
|
708
|
+
info[0],
|
|
709
|
+
info[1]
|
|
710
|
+
);
|
|
711
|
+
}
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
function getIteratorFn(maybeIterable) {
|
|
715
|
+
if (null === maybeIterable || "object" !== typeof maybeIterable)
|
|
716
|
+
return null;
|
|
717
|
+
maybeIterable =
|
|
718
|
+
(MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) ||
|
|
719
|
+
maybeIterable["@@iterator"];
|
|
720
|
+
return "function" === typeof maybeIterable ? maybeIterable : null;
|
|
721
|
+
}
|
|
722
|
+
function warnNoop(publicInstance, callerName) {
|
|
723
|
+
publicInstance =
|
|
724
|
+
((publicInstance = publicInstance.constructor) &&
|
|
725
|
+
(publicInstance.displayName || publicInstance.name)) ||
|
|
726
|
+
"ReactClass";
|
|
727
|
+
var warningKey = publicInstance + "." + callerName;
|
|
728
|
+
didWarnStateUpdateForUnmountedComponent[warningKey] ||
|
|
729
|
+
(console.error(
|
|
730
|
+
"Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",
|
|
731
|
+
callerName,
|
|
732
|
+
publicInstance
|
|
733
|
+
),
|
|
734
|
+
(didWarnStateUpdateForUnmountedComponent[warningKey] = true));
|
|
735
|
+
}
|
|
736
|
+
function Component(props, context, updater) {
|
|
737
|
+
this.props = props;
|
|
738
|
+
this.context = context;
|
|
739
|
+
this.refs = emptyObject;
|
|
740
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
741
|
+
}
|
|
742
|
+
function ComponentDummy() {}
|
|
743
|
+
function PureComponent(props, context, updater) {
|
|
744
|
+
this.props = props;
|
|
745
|
+
this.context = context;
|
|
746
|
+
this.refs = emptyObject;
|
|
747
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
748
|
+
}
|
|
749
|
+
function noop() {}
|
|
750
|
+
function testStringCoercion(value) {
|
|
751
|
+
return "" + value;
|
|
752
|
+
}
|
|
753
|
+
function checkKeyStringCoercion(value) {
|
|
754
|
+
try {
|
|
755
|
+
testStringCoercion(value);
|
|
756
|
+
var JSCompiler_inline_result = !1;
|
|
757
|
+
} catch (e) {
|
|
758
|
+
JSCompiler_inline_result = true;
|
|
759
|
+
}
|
|
760
|
+
if (JSCompiler_inline_result) {
|
|
761
|
+
JSCompiler_inline_result = console;
|
|
762
|
+
var JSCompiler_temp_const = JSCompiler_inline_result.error;
|
|
763
|
+
var JSCompiler_inline_result$jscomp$0 =
|
|
764
|
+
("function" === typeof Symbol &&
|
|
765
|
+
Symbol.toStringTag &&
|
|
766
|
+
value[Symbol.toStringTag]) ||
|
|
767
|
+
value.constructor.name ||
|
|
768
|
+
"Object";
|
|
769
|
+
JSCompiler_temp_const.call(
|
|
770
|
+
JSCompiler_inline_result,
|
|
771
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
772
|
+
JSCompiler_inline_result$jscomp$0
|
|
773
|
+
);
|
|
774
|
+
return testStringCoercion(value);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
function getComponentNameFromType(type) {
|
|
778
|
+
if (null == type) return null;
|
|
779
|
+
if ("function" === typeof type)
|
|
780
|
+
return type.$$typeof === REACT_CLIENT_REFERENCE
|
|
781
|
+
? null
|
|
782
|
+
: type.displayName || type.name || null;
|
|
783
|
+
if ("string" === typeof type) return type;
|
|
784
|
+
switch (type) {
|
|
785
|
+
case REACT_FRAGMENT_TYPE:
|
|
786
|
+
return "Fragment";
|
|
787
|
+
case REACT_PROFILER_TYPE:
|
|
788
|
+
return "Profiler";
|
|
789
|
+
case REACT_STRICT_MODE_TYPE:
|
|
790
|
+
return "StrictMode";
|
|
791
|
+
case REACT_SUSPENSE_TYPE:
|
|
792
|
+
return "Suspense";
|
|
793
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
794
|
+
return "SuspenseList";
|
|
795
|
+
case REACT_ACTIVITY_TYPE:
|
|
796
|
+
return "Activity";
|
|
797
|
+
}
|
|
798
|
+
if ("object" === typeof type)
|
|
799
|
+
switch (
|
|
800
|
+
("number" === typeof type.tag &&
|
|
801
|
+
console.error(
|
|
802
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
803
|
+
),
|
|
804
|
+
type.$$typeof)
|
|
805
|
+
) {
|
|
806
|
+
case REACT_PORTAL_TYPE:
|
|
807
|
+
return "Portal";
|
|
808
|
+
case REACT_CONTEXT_TYPE:
|
|
809
|
+
return type.displayName || "Context";
|
|
810
|
+
case REACT_CONSUMER_TYPE:
|
|
811
|
+
return (type._context.displayName || "Context") + ".Consumer";
|
|
812
|
+
case REACT_FORWARD_REF_TYPE:
|
|
813
|
+
var innerType = type.render;
|
|
814
|
+
type = type.displayName;
|
|
815
|
+
type ||
|
|
816
|
+
((type = innerType.displayName || innerType.name || ""),
|
|
817
|
+
(type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef"));
|
|
818
|
+
return type;
|
|
819
|
+
case REACT_MEMO_TYPE:
|
|
820
|
+
return (
|
|
821
|
+
(innerType = type.displayName || null),
|
|
822
|
+
null !== innerType
|
|
823
|
+
? innerType
|
|
824
|
+
: getComponentNameFromType(type.type) || "Memo"
|
|
825
|
+
);
|
|
826
|
+
case REACT_LAZY_TYPE:
|
|
827
|
+
innerType = type._payload;
|
|
828
|
+
type = type._init;
|
|
829
|
+
try {
|
|
830
|
+
return getComponentNameFromType(type(innerType));
|
|
831
|
+
} catch (x) {}
|
|
832
|
+
}
|
|
833
|
+
return null;
|
|
834
|
+
}
|
|
835
|
+
function getTaskName(type) {
|
|
836
|
+
if (type === REACT_FRAGMENT_TYPE) return "<>";
|
|
837
|
+
if (
|
|
838
|
+
"object" === typeof type &&
|
|
839
|
+
null !== type &&
|
|
840
|
+
type.$$typeof === REACT_LAZY_TYPE
|
|
841
|
+
)
|
|
842
|
+
return "<...>";
|
|
843
|
+
try {
|
|
844
|
+
var name = getComponentNameFromType(type);
|
|
845
|
+
return name ? "<" + name + ">" : "<...>";
|
|
846
|
+
} catch (x) {
|
|
847
|
+
return "<...>";
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
function getOwner() {
|
|
851
|
+
var dispatcher = ReactSharedInternals.A;
|
|
852
|
+
return null === dispatcher ? null : dispatcher.getOwner();
|
|
853
|
+
}
|
|
854
|
+
function UnknownOwner() {
|
|
855
|
+
return Error("react-stack-top-frame");
|
|
856
|
+
}
|
|
857
|
+
function hasValidKey(config) {
|
|
858
|
+
if (hasOwnProperty.call(config, "key")) {
|
|
859
|
+
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
|
860
|
+
if (getter && getter.isReactWarning) return false;
|
|
861
|
+
}
|
|
862
|
+
return void 0 !== config.key;
|
|
863
|
+
}
|
|
864
|
+
function defineKeyPropWarningGetter(props, displayName) {
|
|
865
|
+
function warnAboutAccessingKey() {
|
|
866
|
+
specialPropKeyWarningShown ||
|
|
867
|
+
((specialPropKeyWarningShown = true),
|
|
868
|
+
console.error(
|
|
869
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
870
|
+
displayName
|
|
871
|
+
));
|
|
872
|
+
}
|
|
873
|
+
warnAboutAccessingKey.isReactWarning = true;
|
|
874
|
+
Object.defineProperty(props, "key", {
|
|
875
|
+
get: warnAboutAccessingKey,
|
|
876
|
+
configurable: true
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
function elementRefGetterWithDeprecationWarning() {
|
|
880
|
+
var componentName = getComponentNameFromType(this.type);
|
|
881
|
+
didWarnAboutElementRef[componentName] ||
|
|
882
|
+
((didWarnAboutElementRef[componentName] = true),
|
|
883
|
+
console.error(
|
|
884
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
885
|
+
));
|
|
886
|
+
componentName = this.props.ref;
|
|
887
|
+
return void 0 !== componentName ? componentName : null;
|
|
888
|
+
}
|
|
889
|
+
function ReactElement(type, key, props, owner, debugStack, debugTask) {
|
|
890
|
+
var refProp = props.ref;
|
|
891
|
+
type = {
|
|
892
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
893
|
+
type: type,
|
|
894
|
+
key: key,
|
|
895
|
+
props: props,
|
|
896
|
+
_owner: owner
|
|
897
|
+
};
|
|
898
|
+
null !== (void 0 !== refProp ? refProp : null)
|
|
899
|
+
? Object.defineProperty(type, "ref", {
|
|
900
|
+
enumerable: false,
|
|
901
|
+
get: elementRefGetterWithDeprecationWarning
|
|
902
|
+
})
|
|
903
|
+
: Object.defineProperty(type, "ref", { enumerable: false, value: null });
|
|
904
|
+
type._store = {};
|
|
905
|
+
Object.defineProperty(type._store, "validated", {
|
|
906
|
+
configurable: false,
|
|
907
|
+
enumerable: false,
|
|
908
|
+
writable: true,
|
|
909
|
+
value: 0
|
|
910
|
+
});
|
|
911
|
+
Object.defineProperty(type, "_debugInfo", {
|
|
912
|
+
configurable: false,
|
|
913
|
+
enumerable: false,
|
|
914
|
+
writable: true,
|
|
915
|
+
value: null
|
|
916
|
+
});
|
|
917
|
+
Object.defineProperty(type, "_debugStack", {
|
|
918
|
+
configurable: false,
|
|
919
|
+
enumerable: false,
|
|
920
|
+
writable: true,
|
|
921
|
+
value: debugStack
|
|
922
|
+
});
|
|
923
|
+
Object.defineProperty(type, "_debugTask", {
|
|
924
|
+
configurable: false,
|
|
925
|
+
enumerable: false,
|
|
926
|
+
writable: true,
|
|
927
|
+
value: debugTask
|
|
928
|
+
});
|
|
929
|
+
Object.freeze && (Object.freeze(type.props), Object.freeze(type));
|
|
930
|
+
return type;
|
|
931
|
+
}
|
|
932
|
+
function cloneAndReplaceKey(oldElement, newKey) {
|
|
933
|
+
newKey = ReactElement(
|
|
934
|
+
oldElement.type,
|
|
935
|
+
newKey,
|
|
936
|
+
oldElement.props,
|
|
937
|
+
oldElement._owner,
|
|
938
|
+
oldElement._debugStack,
|
|
939
|
+
oldElement._debugTask
|
|
940
|
+
);
|
|
941
|
+
oldElement._store &&
|
|
942
|
+
(newKey._store.validated = oldElement._store.validated);
|
|
943
|
+
return newKey;
|
|
944
|
+
}
|
|
945
|
+
function validateChildKeys(node) {
|
|
946
|
+
isValidElement(node)
|
|
947
|
+
? node._store && (node._store.validated = 1)
|
|
948
|
+
: "object" === typeof node &&
|
|
949
|
+
null !== node &&
|
|
950
|
+
node.$$typeof === REACT_LAZY_TYPE &&
|
|
951
|
+
("fulfilled" === node._payload.status
|
|
952
|
+
? isValidElement(node._payload.value) &&
|
|
953
|
+
node._payload.value._store &&
|
|
954
|
+
(node._payload.value._store.validated = 1)
|
|
955
|
+
: node._store && (node._store.validated = 1));
|
|
956
|
+
}
|
|
957
|
+
function isValidElement(object) {
|
|
958
|
+
return (
|
|
959
|
+
"object" === typeof object &&
|
|
960
|
+
null !== object &&
|
|
961
|
+
object.$$typeof === REACT_ELEMENT_TYPE
|
|
962
|
+
);
|
|
963
|
+
}
|
|
964
|
+
function escape(key) {
|
|
965
|
+
var escaperLookup = { "=": "=0", ":": "=2" };
|
|
966
|
+
return (
|
|
967
|
+
"$" +
|
|
968
|
+
key.replace(/[=:]/g, function (match) {
|
|
969
|
+
return escaperLookup[match];
|
|
970
|
+
})
|
|
971
|
+
);
|
|
972
|
+
}
|
|
973
|
+
function getElementKey(element, index) {
|
|
974
|
+
return "object" === typeof element &&
|
|
975
|
+
null !== element &&
|
|
976
|
+
null != element.key
|
|
977
|
+
? (checkKeyStringCoercion(element.key), escape("" + element.key))
|
|
978
|
+
: index.toString(36);
|
|
979
|
+
}
|
|
980
|
+
function resolveThenable(thenable) {
|
|
981
|
+
switch (thenable.status) {
|
|
982
|
+
case "fulfilled":
|
|
983
|
+
return thenable.value;
|
|
984
|
+
case "rejected":
|
|
985
|
+
throw thenable.reason;
|
|
986
|
+
default:
|
|
987
|
+
switch (
|
|
988
|
+
("string" === typeof thenable.status
|
|
989
|
+
? thenable.then(noop, noop)
|
|
990
|
+
: ((thenable.status = "pending"),
|
|
991
|
+
thenable.then(
|
|
992
|
+
function (fulfilledValue) {
|
|
993
|
+
"pending" === thenable.status &&
|
|
994
|
+
((thenable.status = "fulfilled"),
|
|
995
|
+
(thenable.value = fulfilledValue));
|
|
996
|
+
},
|
|
997
|
+
function (error) {
|
|
998
|
+
"pending" === thenable.status &&
|
|
999
|
+
((thenable.status = "rejected"),
|
|
1000
|
+
(thenable.reason = error));
|
|
1001
|
+
}
|
|
1002
|
+
)),
|
|
1003
|
+
thenable.status)
|
|
1004
|
+
) {
|
|
1005
|
+
case "fulfilled":
|
|
1006
|
+
return thenable.value;
|
|
1007
|
+
case "rejected":
|
|
1008
|
+
throw thenable.reason;
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
throw thenable;
|
|
1012
|
+
}
|
|
1013
|
+
function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
|
|
1014
|
+
var type = typeof children;
|
|
1015
|
+
if ("undefined" === type || "boolean" === type) children = null;
|
|
1016
|
+
var invokeCallback = false;
|
|
1017
|
+
if (null === children) invokeCallback = true;
|
|
1018
|
+
else
|
|
1019
|
+
switch (type) {
|
|
1020
|
+
case "bigint":
|
|
1021
|
+
case "string":
|
|
1022
|
+
case "number":
|
|
1023
|
+
invokeCallback = true;
|
|
1024
|
+
break;
|
|
1025
|
+
case "object":
|
|
1026
|
+
switch (children.$$typeof) {
|
|
1027
|
+
case REACT_ELEMENT_TYPE:
|
|
1028
|
+
case REACT_PORTAL_TYPE:
|
|
1029
|
+
invokeCallback = true;
|
|
1030
|
+
break;
|
|
1031
|
+
case REACT_LAZY_TYPE:
|
|
1032
|
+
return (
|
|
1033
|
+
(invokeCallback = children._init),
|
|
1034
|
+
mapIntoArray(
|
|
1035
|
+
invokeCallback(children._payload),
|
|
1036
|
+
array,
|
|
1037
|
+
escapedPrefix,
|
|
1038
|
+
nameSoFar,
|
|
1039
|
+
callback
|
|
1040
|
+
)
|
|
1041
|
+
);
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
if (invokeCallback) {
|
|
1045
|
+
invokeCallback = children;
|
|
1046
|
+
callback = callback(invokeCallback);
|
|
1047
|
+
var childKey =
|
|
1048
|
+
"" === nameSoFar ? "." + getElementKey(invokeCallback, 0) : nameSoFar;
|
|
1049
|
+
isArrayImpl(callback)
|
|
1050
|
+
? ((escapedPrefix = ""),
|
|
1051
|
+
null != childKey &&
|
|
1052
|
+
(escapedPrefix =
|
|
1053
|
+
childKey.replace(userProvidedKeyEscapeRegex, "$&/") + "/"),
|
|
1054
|
+
mapIntoArray(callback, array, escapedPrefix, "", function (c) {
|
|
1055
|
+
return c;
|
|
1056
|
+
}))
|
|
1057
|
+
: null != callback &&
|
|
1058
|
+
(isValidElement(callback) &&
|
|
1059
|
+
(null != callback.key &&
|
|
1060
|
+
((invokeCallback && invokeCallback.key === callback.key) ||
|
|
1061
|
+
checkKeyStringCoercion(callback.key)),
|
|
1062
|
+
(escapedPrefix = cloneAndReplaceKey(
|
|
1063
|
+
callback,
|
|
1064
|
+
escapedPrefix +
|
|
1065
|
+
(null == callback.key ||
|
|
1066
|
+
(invokeCallback && invokeCallback.key === callback.key)
|
|
1067
|
+
? ""
|
|
1068
|
+
: ("" + callback.key).replace(
|
|
1069
|
+
userProvidedKeyEscapeRegex,
|
|
1070
|
+
"$&/"
|
|
1071
|
+
) + "/") +
|
|
1072
|
+
childKey
|
|
1073
|
+
)),
|
|
1074
|
+
"" !== nameSoFar &&
|
|
1075
|
+
null != invokeCallback &&
|
|
1076
|
+
isValidElement(invokeCallback) &&
|
|
1077
|
+
null == invokeCallback.key &&
|
|
1078
|
+
invokeCallback._store &&
|
|
1079
|
+
!invokeCallback._store.validated &&
|
|
1080
|
+
(escapedPrefix._store.validated = 2),
|
|
1081
|
+
(callback = escapedPrefix)),
|
|
1082
|
+
array.push(callback));
|
|
1083
|
+
return 1;
|
|
1084
|
+
}
|
|
1085
|
+
invokeCallback = 0;
|
|
1086
|
+
childKey = "" === nameSoFar ? "." : nameSoFar + ":";
|
|
1087
|
+
if (isArrayImpl(children))
|
|
1088
|
+
for (var i = 0; i < children.length; i++)
|
|
1089
|
+
(nameSoFar = children[i]),
|
|
1090
|
+
(type = childKey + getElementKey(nameSoFar, i)),
|
|
1091
|
+
(invokeCallback += mapIntoArray(
|
|
1092
|
+
nameSoFar,
|
|
1093
|
+
array,
|
|
1094
|
+
escapedPrefix,
|
|
1095
|
+
type,
|
|
1096
|
+
callback
|
|
1097
|
+
));
|
|
1098
|
+
else if (((i = getIteratorFn(children)), "function" === typeof i))
|
|
1099
|
+
for (
|
|
1100
|
+
i === children.entries &&
|
|
1101
|
+
(didWarnAboutMaps ||
|
|
1102
|
+
console.warn(
|
|
1103
|
+
"Using Maps as children is not supported. Use an array of keyed ReactElements instead."
|
|
1104
|
+
),
|
|
1105
|
+
(didWarnAboutMaps = true)),
|
|
1106
|
+
children = i.call(children),
|
|
1107
|
+
i = 0;
|
|
1108
|
+
!(nameSoFar = children.next()).done;
|
|
1109
|
+
|
|
1110
|
+
)
|
|
1111
|
+
(nameSoFar = nameSoFar.value),
|
|
1112
|
+
(type = childKey + getElementKey(nameSoFar, i++)),
|
|
1113
|
+
(invokeCallback += mapIntoArray(
|
|
1114
|
+
nameSoFar,
|
|
1115
|
+
array,
|
|
1116
|
+
escapedPrefix,
|
|
1117
|
+
type,
|
|
1118
|
+
callback
|
|
1119
|
+
));
|
|
1120
|
+
else if ("object" === type) {
|
|
1121
|
+
if ("function" === typeof children.then)
|
|
1122
|
+
return mapIntoArray(
|
|
1123
|
+
resolveThenable(children),
|
|
1124
|
+
array,
|
|
1125
|
+
escapedPrefix,
|
|
1126
|
+
nameSoFar,
|
|
1127
|
+
callback
|
|
1128
|
+
);
|
|
1129
|
+
array = String(children);
|
|
1130
|
+
throw Error(
|
|
1131
|
+
"Objects are not valid as a React child (found: " +
|
|
1132
|
+
("[object Object]" === array
|
|
1133
|
+
? "object with keys {" + Object.keys(children).join(", ") + "}"
|
|
1134
|
+
: array) +
|
|
1135
|
+
"). If you meant to render a collection of children, use an array instead."
|
|
1136
|
+
);
|
|
1137
|
+
}
|
|
1138
|
+
return invokeCallback;
|
|
1139
|
+
}
|
|
1140
|
+
function mapChildren(children, func, context) {
|
|
1141
|
+
if (null == children) return children;
|
|
1142
|
+
var result = [],
|
|
1143
|
+
count = 0;
|
|
1144
|
+
mapIntoArray(children, result, "", "", function (child) {
|
|
1145
|
+
return func.call(context, child, count++);
|
|
1146
|
+
});
|
|
1147
|
+
return result;
|
|
1148
|
+
}
|
|
1149
|
+
function lazyInitializer(payload) {
|
|
1150
|
+
if (-1 === payload._status) {
|
|
1151
|
+
var ioInfo = payload._ioInfo;
|
|
1152
|
+
null != ioInfo && (ioInfo.start = ioInfo.end = performance.now());
|
|
1153
|
+
ioInfo = payload._result;
|
|
1154
|
+
var thenable = ioInfo();
|
|
1155
|
+
thenable.then(
|
|
1156
|
+
function (moduleObject) {
|
|
1157
|
+
if (0 === payload._status || -1 === payload._status) {
|
|
1158
|
+
payload._status = 1;
|
|
1159
|
+
payload._result = moduleObject;
|
|
1160
|
+
var _ioInfo = payload._ioInfo;
|
|
1161
|
+
null != _ioInfo && (_ioInfo.end = performance.now());
|
|
1162
|
+
void 0 === thenable.status &&
|
|
1163
|
+
((thenable.status = "fulfilled"),
|
|
1164
|
+
(thenable.value = moduleObject));
|
|
1165
|
+
}
|
|
1166
|
+
},
|
|
1167
|
+
function (error) {
|
|
1168
|
+
if (0 === payload._status || -1 === payload._status) {
|
|
1169
|
+
payload._status = 2;
|
|
1170
|
+
payload._result = error;
|
|
1171
|
+
var _ioInfo2 = payload._ioInfo;
|
|
1172
|
+
null != _ioInfo2 && (_ioInfo2.end = performance.now());
|
|
1173
|
+
void 0 === thenable.status &&
|
|
1174
|
+
((thenable.status = "rejected"), (thenable.reason = error));
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
);
|
|
1178
|
+
ioInfo = payload._ioInfo;
|
|
1179
|
+
if (null != ioInfo) {
|
|
1180
|
+
ioInfo.value = thenable;
|
|
1181
|
+
var displayName = thenable.displayName;
|
|
1182
|
+
"string" === typeof displayName && (ioInfo.name = displayName);
|
|
1183
|
+
}
|
|
1184
|
+
-1 === payload._status &&
|
|
1185
|
+
((payload._status = 0), (payload._result = thenable));
|
|
1186
|
+
}
|
|
1187
|
+
if (1 === payload._status)
|
|
1188
|
+
return (
|
|
1189
|
+
(ioInfo = payload._result),
|
|
1190
|
+
void 0 === ioInfo &&
|
|
1191
|
+
console.error(
|
|
1192
|
+
"lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))\n\nDid you accidentally put curly braces around the import?",
|
|
1193
|
+
ioInfo
|
|
1194
|
+
),
|
|
1195
|
+
"default" in ioInfo ||
|
|
1196
|
+
console.error(
|
|
1197
|
+
"lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))",
|
|
1198
|
+
ioInfo
|
|
1199
|
+
),
|
|
1200
|
+
ioInfo.default
|
|
1201
|
+
);
|
|
1202
|
+
throw payload._result;
|
|
1203
|
+
}
|
|
1204
|
+
function resolveDispatcher() {
|
|
1205
|
+
var dispatcher = ReactSharedInternals.H;
|
|
1206
|
+
null === dispatcher &&
|
|
1207
|
+
console.error(
|
|
1208
|
+
"Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem."
|
|
1209
|
+
);
|
|
1210
|
+
return dispatcher;
|
|
1211
|
+
}
|
|
1212
|
+
function releaseAsyncTransition() {
|
|
1213
|
+
ReactSharedInternals.asyncTransitions--;
|
|
1214
|
+
}
|
|
1215
|
+
function enqueueTask(task) {
|
|
1216
|
+
if (null === enqueueTaskImpl)
|
|
1217
|
+
try {
|
|
1218
|
+
var requireString = ("require" + Math.random()).slice(0, 7);
|
|
1219
|
+
enqueueTaskImpl = (module && module[requireString]).call(
|
|
1220
|
+
module,
|
|
1221
|
+
"timers"
|
|
1222
|
+
).setImmediate;
|
|
1223
|
+
} catch (_err) {
|
|
1224
|
+
enqueueTaskImpl = function (callback) {
|
|
1225
|
+
false === didWarnAboutMessageChannel &&
|
|
1226
|
+
((didWarnAboutMessageChannel = true),
|
|
1227
|
+
"undefined" === typeof MessageChannel &&
|
|
1228
|
+
console.error(
|
|
1229
|
+
"This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."
|
|
1230
|
+
));
|
|
1231
|
+
var channel = new MessageChannel();
|
|
1232
|
+
channel.port1.onmessage = callback;
|
|
1233
|
+
channel.port2.postMessage(void 0);
|
|
1234
|
+
};
|
|
1235
|
+
}
|
|
1236
|
+
return enqueueTaskImpl(task);
|
|
1237
|
+
}
|
|
1238
|
+
function aggregateErrors(errors) {
|
|
1239
|
+
return 1 < errors.length && "function" === typeof AggregateError
|
|
1240
|
+
? new AggregateError(errors)
|
|
1241
|
+
: errors[0];
|
|
1242
|
+
}
|
|
1243
|
+
function popActScope(prevActQueue, prevActScopeDepth) {
|
|
1244
|
+
prevActScopeDepth !== actScopeDepth - 1 &&
|
|
1245
|
+
console.error(
|
|
1246
|
+
"You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "
|
|
1247
|
+
);
|
|
1248
|
+
actScopeDepth = prevActScopeDepth;
|
|
1249
|
+
}
|
|
1250
|
+
function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
|
|
1251
|
+
var queue = ReactSharedInternals.actQueue;
|
|
1252
|
+
if (null !== queue)
|
|
1253
|
+
if (0 !== queue.length)
|
|
1254
|
+
try {
|
|
1255
|
+
flushActQueue(queue);
|
|
1256
|
+
enqueueTask(function () {
|
|
1257
|
+
return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
|
|
1258
|
+
});
|
|
1259
|
+
return;
|
|
1260
|
+
} catch (error) {
|
|
1261
|
+
ReactSharedInternals.thrownErrors.push(error);
|
|
1262
|
+
}
|
|
1263
|
+
else ReactSharedInternals.actQueue = null;
|
|
1264
|
+
0 < ReactSharedInternals.thrownErrors.length
|
|
1265
|
+
? ((queue = aggregateErrors(ReactSharedInternals.thrownErrors)),
|
|
1266
|
+
(ReactSharedInternals.thrownErrors.length = 0),
|
|
1267
|
+
reject(queue))
|
|
1268
|
+
: resolve(returnValue);
|
|
1269
|
+
}
|
|
1270
|
+
function flushActQueue(queue) {
|
|
1271
|
+
if (!isFlushing) {
|
|
1272
|
+
isFlushing = true;
|
|
1273
|
+
var i = 0;
|
|
1274
|
+
try {
|
|
1275
|
+
for (; i < queue.length; i++) {
|
|
1276
|
+
var callback = queue[i];
|
|
1277
|
+
do {
|
|
1278
|
+
ReactSharedInternals.didUsePromise = !1;
|
|
1279
|
+
var continuation = callback(!1);
|
|
1280
|
+
if (null !== continuation) {
|
|
1281
|
+
if (ReactSharedInternals.didUsePromise) {
|
|
1282
|
+
queue[i] = callback;
|
|
1283
|
+
queue.splice(0, i);
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
callback = continuation;
|
|
1287
|
+
} else break;
|
|
1288
|
+
} while (1);
|
|
1289
|
+
}
|
|
1290
|
+
queue.length = 0;
|
|
1291
|
+
} catch (error) {
|
|
1292
|
+
queue.splice(0, i + 1), ReactSharedInternals.thrownErrors.push(error);
|
|
1293
|
+
} finally {
|
|
1294
|
+
isFlushing = false;
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
|
|
1299
|
+
"function" ===
|
|
1300
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart &&
|
|
1301
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
1302
|
+
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
|
1303
|
+
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
|
|
1304
|
+
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
|
|
1305
|
+
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
|
|
1306
|
+
REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
|
|
1307
|
+
REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
|
|
1308
|
+
REACT_CONTEXT_TYPE = Symbol.for("react.context"),
|
|
1309
|
+
REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
|
|
1310
|
+
REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
|
|
1311
|
+
REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
|
|
1312
|
+
REACT_MEMO_TYPE = Symbol.for("react.memo"),
|
|
1313
|
+
REACT_LAZY_TYPE = Symbol.for("react.lazy"),
|
|
1314
|
+
REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
|
|
1315
|
+
MAYBE_ITERATOR_SYMBOL = Symbol.iterator,
|
|
1316
|
+
didWarnStateUpdateForUnmountedComponent = {},
|
|
1317
|
+
ReactNoopUpdateQueue = {
|
|
1318
|
+
isMounted: function () {
|
|
1319
|
+
return false;
|
|
1320
|
+
},
|
|
1321
|
+
enqueueForceUpdate: function (publicInstance) {
|
|
1322
|
+
warnNoop(publicInstance, "forceUpdate");
|
|
1323
|
+
},
|
|
1324
|
+
enqueueReplaceState: function (publicInstance) {
|
|
1325
|
+
warnNoop(publicInstance, "replaceState");
|
|
1326
|
+
},
|
|
1327
|
+
enqueueSetState: function (publicInstance) {
|
|
1328
|
+
warnNoop(publicInstance, "setState");
|
|
1329
|
+
}
|
|
1330
|
+
},
|
|
1331
|
+
assign = Object.assign,
|
|
1332
|
+
emptyObject = {};
|
|
1333
|
+
Object.freeze(emptyObject);
|
|
1334
|
+
Component.prototype.isReactComponent = {};
|
|
1335
|
+
Component.prototype.setState = function (partialState, callback) {
|
|
1336
|
+
if (
|
|
1337
|
+
"object" !== typeof partialState &&
|
|
1338
|
+
"function" !== typeof partialState &&
|
|
1339
|
+
null != partialState
|
|
1340
|
+
)
|
|
1341
|
+
throw Error(
|
|
1342
|
+
"takes an object of state variables to update or a function which returns an object of state variables."
|
|
1343
|
+
);
|
|
1344
|
+
this.updater.enqueueSetState(this, partialState, callback, "setState");
|
|
1345
|
+
};
|
|
1346
|
+
Component.prototype.forceUpdate = function (callback) {
|
|
1347
|
+
this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
|
|
1348
|
+
};
|
|
1349
|
+
var deprecatedAPIs = {
|
|
1350
|
+
isMounted: [
|
|
1351
|
+
"isMounted",
|
|
1352
|
+
"Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."
|
|
1353
|
+
],
|
|
1354
|
+
replaceState: [
|
|
1355
|
+
"replaceState",
|
|
1356
|
+
"Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."
|
|
1357
|
+
]
|
|
1358
|
+
};
|
|
1359
|
+
for (fnName in deprecatedAPIs)
|
|
1360
|
+
deprecatedAPIs.hasOwnProperty(fnName) &&
|
|
1361
|
+
defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
|
|
1362
|
+
ComponentDummy.prototype = Component.prototype;
|
|
1363
|
+
deprecatedAPIs = PureComponent.prototype = new ComponentDummy();
|
|
1364
|
+
deprecatedAPIs.constructor = PureComponent;
|
|
1365
|
+
assign(deprecatedAPIs, Component.prototype);
|
|
1366
|
+
deprecatedAPIs.isPureReactComponent = true;
|
|
1367
|
+
var isArrayImpl = Array.isArray,
|
|
1368
|
+
REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
|
|
1369
|
+
ReactSharedInternals = {
|
|
1370
|
+
H: null,
|
|
1371
|
+
A: null,
|
|
1372
|
+
T: null,
|
|
1373
|
+
S: null,
|
|
1374
|
+
actQueue: null,
|
|
1375
|
+
asyncTransitions: 0,
|
|
1376
|
+
isBatchingLegacy: false,
|
|
1377
|
+
didScheduleLegacyUpdate: false,
|
|
1378
|
+
didUsePromise: false,
|
|
1379
|
+
thrownErrors: [],
|
|
1380
|
+
getCurrentStack: null,
|
|
1381
|
+
recentlyCreatedOwnerStacks: 0
|
|
1382
|
+
},
|
|
1383
|
+
hasOwnProperty = Object.prototype.hasOwnProperty,
|
|
1384
|
+
createTask = console.createTask
|
|
1385
|
+
? console.createTask
|
|
1386
|
+
: function () {
|
|
1387
|
+
return null;
|
|
1388
|
+
};
|
|
1389
|
+
deprecatedAPIs = {
|
|
1390
|
+
react_stack_bottom_frame: function (callStackForError) {
|
|
1391
|
+
return callStackForError();
|
|
1392
|
+
}
|
|
1393
|
+
};
|
|
1394
|
+
var specialPropKeyWarningShown, didWarnAboutOldJSXRuntime;
|
|
1395
|
+
var didWarnAboutElementRef = {};
|
|
1396
|
+
var unknownOwnerDebugStack = deprecatedAPIs.react_stack_bottom_frame.bind(
|
|
1397
|
+
deprecatedAPIs,
|
|
1398
|
+
UnknownOwner
|
|
1399
|
+
)();
|
|
1400
|
+
var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
|
|
1401
|
+
var didWarnAboutMaps = false,
|
|
1402
|
+
userProvidedKeyEscapeRegex = /\/+/g,
|
|
1403
|
+
reportGlobalError =
|
|
1404
|
+
"function" === typeof reportError
|
|
1405
|
+
? reportError
|
|
1406
|
+
: function (error) {
|
|
1407
|
+
if (
|
|
1408
|
+
"object" === typeof window &&
|
|
1409
|
+
"function" === typeof window.ErrorEvent
|
|
1410
|
+
) {
|
|
1411
|
+
var event = new window.ErrorEvent("error", {
|
|
1412
|
+
bubbles: true,
|
|
1413
|
+
cancelable: true,
|
|
1414
|
+
message:
|
|
1415
|
+
"object" === typeof error &&
|
|
1416
|
+
null !== error &&
|
|
1417
|
+
"string" === typeof error.message
|
|
1418
|
+
? String(error.message)
|
|
1419
|
+
: String(error),
|
|
1420
|
+
error: error
|
|
1421
|
+
});
|
|
1422
|
+
if (!window.dispatchEvent(event)) return;
|
|
1423
|
+
} else if (
|
|
1424
|
+
"object" === typeof process &&
|
|
1425
|
+
"function" === typeof process.emit
|
|
1426
|
+
) {
|
|
1427
|
+
process.emit("uncaughtException", error);
|
|
1428
|
+
return;
|
|
1429
|
+
}
|
|
1430
|
+
console.error(error);
|
|
1431
|
+
},
|
|
1432
|
+
didWarnAboutMessageChannel = false,
|
|
1433
|
+
enqueueTaskImpl = null,
|
|
1434
|
+
actScopeDepth = 0,
|
|
1435
|
+
didWarnNoAwaitAct = false,
|
|
1436
|
+
isFlushing = false,
|
|
1437
|
+
queueSeveralMicrotasks =
|
|
1438
|
+
"function" === typeof queueMicrotask
|
|
1439
|
+
? function (callback) {
|
|
1440
|
+
queueMicrotask(function () {
|
|
1441
|
+
return queueMicrotask(callback);
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1444
|
+
: enqueueTask;
|
|
1445
|
+
deprecatedAPIs = Object.freeze({
|
|
1446
|
+
__proto__: null,
|
|
1447
|
+
c: function (size) {
|
|
1448
|
+
return resolveDispatcher().useMemoCache(size);
|
|
1449
|
+
}
|
|
1450
|
+
});
|
|
1451
|
+
var fnName = {
|
|
1452
|
+
map: mapChildren,
|
|
1453
|
+
forEach: function (children, forEachFunc, forEachContext) {
|
|
1454
|
+
mapChildren(
|
|
1455
|
+
children,
|
|
1456
|
+
function () {
|
|
1457
|
+
forEachFunc.apply(this, arguments);
|
|
1458
|
+
},
|
|
1459
|
+
forEachContext
|
|
1460
|
+
);
|
|
1461
|
+
},
|
|
1462
|
+
count: function (children) {
|
|
1463
|
+
var n = 0;
|
|
1464
|
+
mapChildren(children, function () {
|
|
1465
|
+
n++;
|
|
1466
|
+
});
|
|
1467
|
+
return n;
|
|
1468
|
+
},
|
|
1469
|
+
toArray: function (children) {
|
|
1470
|
+
return (
|
|
1471
|
+
mapChildren(children, function (child) {
|
|
1472
|
+
return child;
|
|
1473
|
+
}) || []
|
|
1474
|
+
);
|
|
1475
|
+
},
|
|
1476
|
+
only: function (children) {
|
|
1477
|
+
if (!isValidElement(children))
|
|
1478
|
+
throw Error(
|
|
1479
|
+
"React.Children.only expected to receive a single React element child."
|
|
1480
|
+
);
|
|
1481
|
+
return children;
|
|
1482
|
+
}
|
|
1483
|
+
};
|
|
1484
|
+
exports.Activity = REACT_ACTIVITY_TYPE;
|
|
1485
|
+
exports.Children = fnName;
|
|
1486
|
+
exports.Component = Component;
|
|
1487
|
+
exports.Fragment = REACT_FRAGMENT_TYPE;
|
|
1488
|
+
exports.Profiler = REACT_PROFILER_TYPE;
|
|
1489
|
+
exports.PureComponent = PureComponent;
|
|
1490
|
+
exports.StrictMode = REACT_STRICT_MODE_TYPE;
|
|
1491
|
+
exports.Suspense = REACT_SUSPENSE_TYPE;
|
|
1492
|
+
exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE =
|
|
1493
|
+
ReactSharedInternals;
|
|
1494
|
+
exports.__COMPILER_RUNTIME = deprecatedAPIs;
|
|
1495
|
+
exports.act = function (callback) {
|
|
1496
|
+
var prevActQueue = ReactSharedInternals.actQueue,
|
|
1497
|
+
prevActScopeDepth = actScopeDepth;
|
|
1498
|
+
actScopeDepth++;
|
|
1499
|
+
var queue = (ReactSharedInternals.actQueue =
|
|
1500
|
+
null !== prevActQueue ? prevActQueue : []),
|
|
1501
|
+
didAwaitActCall = false;
|
|
1502
|
+
try {
|
|
1503
|
+
var result = callback();
|
|
1504
|
+
} catch (error) {
|
|
1505
|
+
ReactSharedInternals.thrownErrors.push(error);
|
|
1506
|
+
}
|
|
1507
|
+
if (0 < ReactSharedInternals.thrownErrors.length)
|
|
1508
|
+
throw (
|
|
1509
|
+
(popActScope(prevActQueue, prevActScopeDepth),
|
|
1510
|
+
(callback = aggregateErrors(ReactSharedInternals.thrownErrors)),
|
|
1511
|
+
(ReactSharedInternals.thrownErrors.length = 0),
|
|
1512
|
+
callback)
|
|
1513
|
+
);
|
|
1514
|
+
if (
|
|
1515
|
+
null !== result &&
|
|
1516
|
+
"object" === typeof result &&
|
|
1517
|
+
"function" === typeof result.then
|
|
1518
|
+
) {
|
|
1519
|
+
var thenable = result;
|
|
1520
|
+
queueSeveralMicrotasks(function () {
|
|
1521
|
+
didAwaitActCall ||
|
|
1522
|
+
didWarnNoAwaitAct ||
|
|
1523
|
+
((didWarnNoAwaitAct = true),
|
|
1524
|
+
console.error(
|
|
1525
|
+
"You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"
|
|
1526
|
+
));
|
|
1527
|
+
});
|
|
1528
|
+
return {
|
|
1529
|
+
then: function (resolve, reject) {
|
|
1530
|
+
didAwaitActCall = true;
|
|
1531
|
+
thenable.then(
|
|
1532
|
+
function (returnValue) {
|
|
1533
|
+
popActScope(prevActQueue, prevActScopeDepth);
|
|
1534
|
+
if (0 === prevActScopeDepth) {
|
|
1535
|
+
try {
|
|
1536
|
+
flushActQueue(queue),
|
|
1537
|
+
enqueueTask(function () {
|
|
1538
|
+
return recursivelyFlushAsyncActWork(
|
|
1539
|
+
returnValue,
|
|
1540
|
+
resolve,
|
|
1541
|
+
reject
|
|
1542
|
+
);
|
|
1543
|
+
});
|
|
1544
|
+
} catch (error$0) {
|
|
1545
|
+
ReactSharedInternals.thrownErrors.push(error$0);
|
|
1546
|
+
}
|
|
1547
|
+
if (0 < ReactSharedInternals.thrownErrors.length) {
|
|
1548
|
+
var _thrownError = aggregateErrors(
|
|
1549
|
+
ReactSharedInternals.thrownErrors
|
|
1550
|
+
);
|
|
1551
|
+
ReactSharedInternals.thrownErrors.length = 0;
|
|
1552
|
+
reject(_thrownError);
|
|
1553
|
+
}
|
|
1554
|
+
} else resolve(returnValue);
|
|
1555
|
+
},
|
|
1556
|
+
function (error) {
|
|
1557
|
+
popActScope(prevActQueue, prevActScopeDepth);
|
|
1558
|
+
0 < ReactSharedInternals.thrownErrors.length
|
|
1559
|
+
? ((error = aggregateErrors(
|
|
1560
|
+
ReactSharedInternals.thrownErrors
|
|
1561
|
+
)),
|
|
1562
|
+
(ReactSharedInternals.thrownErrors.length = 0),
|
|
1563
|
+
reject(error))
|
|
1564
|
+
: reject(error);
|
|
1565
|
+
}
|
|
1566
|
+
);
|
|
1567
|
+
}
|
|
1568
|
+
};
|
|
1569
|
+
}
|
|
1570
|
+
var returnValue$jscomp$0 = result;
|
|
1571
|
+
popActScope(prevActQueue, prevActScopeDepth);
|
|
1572
|
+
0 === prevActScopeDepth &&
|
|
1573
|
+
(flushActQueue(queue),
|
|
1574
|
+
0 !== queue.length &&
|
|
1575
|
+
queueSeveralMicrotasks(function () {
|
|
1576
|
+
didAwaitActCall ||
|
|
1577
|
+
didWarnNoAwaitAct ||
|
|
1578
|
+
((didWarnNoAwaitAct = true),
|
|
1579
|
+
console.error(
|
|
1580
|
+
"A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"
|
|
1581
|
+
));
|
|
1582
|
+
}),
|
|
1583
|
+
(ReactSharedInternals.actQueue = null));
|
|
1584
|
+
if (0 < ReactSharedInternals.thrownErrors.length)
|
|
1585
|
+
throw (
|
|
1586
|
+
((callback = aggregateErrors(ReactSharedInternals.thrownErrors)),
|
|
1587
|
+
(ReactSharedInternals.thrownErrors.length = 0),
|
|
1588
|
+
callback)
|
|
1589
|
+
);
|
|
1590
|
+
return {
|
|
1591
|
+
then: function (resolve, reject) {
|
|
1592
|
+
didAwaitActCall = true;
|
|
1593
|
+
0 === prevActScopeDepth
|
|
1594
|
+
? ((ReactSharedInternals.actQueue = queue),
|
|
1595
|
+
enqueueTask(function () {
|
|
1596
|
+
return recursivelyFlushAsyncActWork(
|
|
1597
|
+
returnValue$jscomp$0,
|
|
1598
|
+
resolve,
|
|
1599
|
+
reject
|
|
1600
|
+
);
|
|
1601
|
+
}))
|
|
1602
|
+
: resolve(returnValue$jscomp$0);
|
|
1603
|
+
}
|
|
1604
|
+
};
|
|
1605
|
+
};
|
|
1606
|
+
exports.cache = function (fn) {
|
|
1607
|
+
return function () {
|
|
1608
|
+
return fn.apply(null, arguments);
|
|
1609
|
+
};
|
|
1610
|
+
};
|
|
1611
|
+
exports.cacheSignal = function () {
|
|
1612
|
+
return null;
|
|
1613
|
+
};
|
|
1614
|
+
exports.captureOwnerStack = function () {
|
|
1615
|
+
var getCurrentStack = ReactSharedInternals.getCurrentStack;
|
|
1616
|
+
return null === getCurrentStack ? null : getCurrentStack();
|
|
1617
|
+
};
|
|
1618
|
+
exports.cloneElement = function (element, config, children) {
|
|
1619
|
+
if (null === element || void 0 === element)
|
|
1620
|
+
throw Error(
|
|
1621
|
+
"The argument must be a React element, but you passed " +
|
|
1622
|
+
element +
|
|
1623
|
+
"."
|
|
1624
|
+
);
|
|
1625
|
+
var props = assign({}, element.props),
|
|
1626
|
+
key = element.key,
|
|
1627
|
+
owner = element._owner;
|
|
1628
|
+
if (null != config) {
|
|
1629
|
+
var JSCompiler_inline_result;
|
|
1630
|
+
a: {
|
|
1631
|
+
if (
|
|
1632
|
+
hasOwnProperty.call(config, "ref") &&
|
|
1633
|
+
(JSCompiler_inline_result = Object.getOwnPropertyDescriptor(
|
|
1634
|
+
config,
|
|
1635
|
+
"ref"
|
|
1636
|
+
).get) &&
|
|
1637
|
+
JSCompiler_inline_result.isReactWarning
|
|
1638
|
+
) {
|
|
1639
|
+
JSCompiler_inline_result = false;
|
|
1640
|
+
break a;
|
|
1641
|
+
}
|
|
1642
|
+
JSCompiler_inline_result = void 0 !== config.ref;
|
|
1643
|
+
}
|
|
1644
|
+
JSCompiler_inline_result && (owner = getOwner());
|
|
1645
|
+
hasValidKey(config) &&
|
|
1646
|
+
(checkKeyStringCoercion(config.key), (key = "" + config.key));
|
|
1647
|
+
for (propName in config)
|
|
1648
|
+
!hasOwnProperty.call(config, propName) ||
|
|
1649
|
+
"key" === propName ||
|
|
1650
|
+
"__self" === propName ||
|
|
1651
|
+
"__source" === propName ||
|
|
1652
|
+
("ref" === propName && void 0 === config.ref) ||
|
|
1653
|
+
(props[propName] = config[propName]);
|
|
1654
|
+
}
|
|
1655
|
+
var propName = arguments.length - 2;
|
|
1656
|
+
if (1 === propName) props.children = children;
|
|
1657
|
+
else if (1 < propName) {
|
|
1658
|
+
JSCompiler_inline_result = Array(propName);
|
|
1659
|
+
for (var i = 0; i < propName; i++)
|
|
1660
|
+
JSCompiler_inline_result[i] = arguments[i + 2];
|
|
1661
|
+
props.children = JSCompiler_inline_result;
|
|
1662
|
+
}
|
|
1663
|
+
props = ReactElement(
|
|
1664
|
+
element.type,
|
|
1665
|
+
key,
|
|
1666
|
+
props,
|
|
1667
|
+
owner,
|
|
1668
|
+
element._debugStack,
|
|
1669
|
+
element._debugTask
|
|
1670
|
+
);
|
|
1671
|
+
for (key = 2; key < arguments.length; key++)
|
|
1672
|
+
validateChildKeys(arguments[key]);
|
|
1673
|
+
return props;
|
|
1674
|
+
};
|
|
1675
|
+
exports.createContext = function (defaultValue) {
|
|
1676
|
+
defaultValue = {
|
|
1677
|
+
$$typeof: REACT_CONTEXT_TYPE,
|
|
1678
|
+
_currentValue: defaultValue,
|
|
1679
|
+
_currentValue2: defaultValue,
|
|
1680
|
+
_threadCount: 0,
|
|
1681
|
+
Provider: null,
|
|
1682
|
+
Consumer: null
|
|
1683
|
+
};
|
|
1684
|
+
defaultValue.Provider = defaultValue;
|
|
1685
|
+
defaultValue.Consumer = {
|
|
1686
|
+
$$typeof: REACT_CONSUMER_TYPE,
|
|
1687
|
+
_context: defaultValue
|
|
1688
|
+
};
|
|
1689
|
+
defaultValue._currentRenderer = null;
|
|
1690
|
+
defaultValue._currentRenderer2 = null;
|
|
1691
|
+
return defaultValue;
|
|
1692
|
+
};
|
|
1693
|
+
exports.createElement = function (type, config, children) {
|
|
1694
|
+
for (var i = 2; i < arguments.length; i++)
|
|
1695
|
+
validateChildKeys(arguments[i]);
|
|
1696
|
+
i = {};
|
|
1697
|
+
var key = null;
|
|
1698
|
+
if (null != config)
|
|
1699
|
+
for (propName in (didWarnAboutOldJSXRuntime ||
|
|
1700
|
+
!("__self" in config) ||
|
|
1701
|
+
"key" in config ||
|
|
1702
|
+
((didWarnAboutOldJSXRuntime = true),
|
|
1703
|
+
console.warn(
|
|
1704
|
+
"Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform"
|
|
1705
|
+
)),
|
|
1706
|
+
hasValidKey(config) &&
|
|
1707
|
+
(checkKeyStringCoercion(config.key), (key = "" + config.key)),
|
|
1708
|
+
config))
|
|
1709
|
+
hasOwnProperty.call(config, propName) &&
|
|
1710
|
+
"key" !== propName &&
|
|
1711
|
+
"__self" !== propName &&
|
|
1712
|
+
"__source" !== propName &&
|
|
1713
|
+
(i[propName] = config[propName]);
|
|
1714
|
+
var childrenLength = arguments.length - 2;
|
|
1715
|
+
if (1 === childrenLength) i.children = children;
|
|
1716
|
+
else if (1 < childrenLength) {
|
|
1717
|
+
for (
|
|
1718
|
+
var childArray = Array(childrenLength), _i = 0;
|
|
1719
|
+
_i < childrenLength;
|
|
1720
|
+
_i++
|
|
1721
|
+
)
|
|
1722
|
+
childArray[_i] = arguments[_i + 2];
|
|
1723
|
+
Object.freeze && Object.freeze(childArray);
|
|
1724
|
+
i.children = childArray;
|
|
1725
|
+
}
|
|
1726
|
+
if (type && type.defaultProps)
|
|
1727
|
+
for (propName in ((childrenLength = type.defaultProps), childrenLength))
|
|
1728
|
+
void 0 === i[propName] && (i[propName] = childrenLength[propName]);
|
|
1729
|
+
key &&
|
|
1730
|
+
defineKeyPropWarningGetter(
|
|
1731
|
+
i,
|
|
1732
|
+
"function" === typeof type
|
|
1733
|
+
? type.displayName || type.name || "Unknown"
|
|
1734
|
+
: type
|
|
1735
|
+
);
|
|
1736
|
+
var propName = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
1737
|
+
return ReactElement(
|
|
1738
|
+
type,
|
|
1739
|
+
key,
|
|
1740
|
+
i,
|
|
1741
|
+
getOwner(),
|
|
1742
|
+
propName ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
|
|
1743
|
+
propName ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
1744
|
+
);
|
|
1745
|
+
};
|
|
1746
|
+
exports.createRef = function () {
|
|
1747
|
+
var refObject = { current: null };
|
|
1748
|
+
Object.seal(refObject);
|
|
1749
|
+
return refObject;
|
|
1750
|
+
};
|
|
1751
|
+
exports.forwardRef = function (render) {
|
|
1752
|
+
null != render && render.$$typeof === REACT_MEMO_TYPE
|
|
1753
|
+
? console.error(
|
|
1754
|
+
"forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."
|
|
1755
|
+
)
|
|
1756
|
+
: "function" !== typeof render
|
|
1757
|
+
? console.error(
|
|
1758
|
+
"forwardRef requires a render function but was given %s.",
|
|
1759
|
+
null === render ? "null" : typeof render
|
|
1760
|
+
)
|
|
1761
|
+
: 0 !== render.length &&
|
|
1762
|
+
2 !== render.length &&
|
|
1763
|
+
console.error(
|
|
1764
|
+
"forwardRef render functions accept exactly two parameters: props and ref. %s",
|
|
1765
|
+
1 === render.length
|
|
1766
|
+
? "Did you forget to use the ref parameter?"
|
|
1767
|
+
: "Any additional parameter will be undefined."
|
|
1768
|
+
);
|
|
1769
|
+
null != render &&
|
|
1770
|
+
null != render.defaultProps &&
|
|
1771
|
+
console.error(
|
|
1772
|
+
"forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?"
|
|
1773
|
+
);
|
|
1774
|
+
var elementType = { $$typeof: REACT_FORWARD_REF_TYPE, render: render },
|
|
1775
|
+
ownName;
|
|
1776
|
+
Object.defineProperty(elementType, "displayName", {
|
|
1777
|
+
enumerable: false,
|
|
1778
|
+
configurable: true,
|
|
1779
|
+
get: function () {
|
|
1780
|
+
return ownName;
|
|
1781
|
+
},
|
|
1782
|
+
set: function (name) {
|
|
1783
|
+
ownName = name;
|
|
1784
|
+
render.name ||
|
|
1785
|
+
render.displayName ||
|
|
1786
|
+
(Object.defineProperty(render, "name", { value: name }),
|
|
1787
|
+
(render.displayName = name));
|
|
1788
|
+
}
|
|
1789
|
+
});
|
|
1790
|
+
return elementType;
|
|
1791
|
+
};
|
|
1792
|
+
exports.isValidElement = isValidElement;
|
|
1793
|
+
exports.lazy = function (ctor) {
|
|
1794
|
+
ctor = { _status: -1, _result: ctor };
|
|
1795
|
+
var lazyType = {
|
|
1796
|
+
$$typeof: REACT_LAZY_TYPE,
|
|
1797
|
+
_payload: ctor,
|
|
1798
|
+
_init: lazyInitializer
|
|
1799
|
+
},
|
|
1800
|
+
ioInfo = {
|
|
1801
|
+
name: "lazy",
|
|
1802
|
+
start: -1,
|
|
1803
|
+
end: -1,
|
|
1804
|
+
value: null,
|
|
1805
|
+
owner: null,
|
|
1806
|
+
debugStack: Error("react-stack-top-frame"),
|
|
1807
|
+
debugTask: console.createTask ? console.createTask("lazy()") : null
|
|
1808
|
+
};
|
|
1809
|
+
ctor._ioInfo = ioInfo;
|
|
1810
|
+
lazyType._debugInfo = [{ awaited: ioInfo }];
|
|
1811
|
+
return lazyType;
|
|
1812
|
+
};
|
|
1813
|
+
exports.memo = function (type, compare) {
|
|
1814
|
+
null == type &&
|
|
1815
|
+
console.error(
|
|
1816
|
+
"memo: The first argument must be a component. Instead received: %s",
|
|
1817
|
+
null === type ? "null" : typeof type
|
|
1818
|
+
);
|
|
1819
|
+
compare = {
|
|
1820
|
+
$$typeof: REACT_MEMO_TYPE,
|
|
1821
|
+
type: type,
|
|
1822
|
+
compare: void 0 === compare ? null : compare
|
|
1823
|
+
};
|
|
1824
|
+
var ownName;
|
|
1825
|
+
Object.defineProperty(compare, "displayName", {
|
|
1826
|
+
enumerable: false,
|
|
1827
|
+
configurable: true,
|
|
1828
|
+
get: function () {
|
|
1829
|
+
return ownName;
|
|
1830
|
+
},
|
|
1831
|
+
set: function (name) {
|
|
1832
|
+
ownName = name;
|
|
1833
|
+
type.name ||
|
|
1834
|
+
type.displayName ||
|
|
1835
|
+
(Object.defineProperty(type, "name", { value: name }),
|
|
1836
|
+
(type.displayName = name));
|
|
1837
|
+
}
|
|
1838
|
+
});
|
|
1839
|
+
return compare;
|
|
1840
|
+
};
|
|
1841
|
+
exports.startTransition = function (scope) {
|
|
1842
|
+
var prevTransition = ReactSharedInternals.T,
|
|
1843
|
+
currentTransition = {};
|
|
1844
|
+
currentTransition._updatedFibers = new Set();
|
|
1845
|
+
ReactSharedInternals.T = currentTransition;
|
|
1846
|
+
try {
|
|
1847
|
+
var returnValue = scope(),
|
|
1848
|
+
onStartTransitionFinish = ReactSharedInternals.S;
|
|
1849
|
+
null !== onStartTransitionFinish &&
|
|
1850
|
+
onStartTransitionFinish(currentTransition, returnValue);
|
|
1851
|
+
"object" === typeof returnValue &&
|
|
1852
|
+
null !== returnValue &&
|
|
1853
|
+
"function" === typeof returnValue.then &&
|
|
1854
|
+
(ReactSharedInternals.asyncTransitions++,
|
|
1855
|
+
returnValue.then(releaseAsyncTransition, releaseAsyncTransition),
|
|
1856
|
+
returnValue.then(noop, reportGlobalError));
|
|
1857
|
+
} catch (error) {
|
|
1858
|
+
reportGlobalError(error);
|
|
1859
|
+
} finally {
|
|
1860
|
+
null === prevTransition &&
|
|
1861
|
+
currentTransition._updatedFibers &&
|
|
1862
|
+
((scope = currentTransition._updatedFibers.size),
|
|
1863
|
+
currentTransition._updatedFibers.clear(),
|
|
1864
|
+
10 < scope &&
|
|
1865
|
+
console.warn(
|
|
1866
|
+
"Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table."
|
|
1867
|
+
)),
|
|
1868
|
+
null !== prevTransition &&
|
|
1869
|
+
null !== currentTransition.types &&
|
|
1870
|
+
(null !== prevTransition.types &&
|
|
1871
|
+
prevTransition.types !== currentTransition.types &&
|
|
1872
|
+
console.error(
|
|
1873
|
+
"We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."
|
|
1874
|
+
),
|
|
1875
|
+
(prevTransition.types = currentTransition.types)),
|
|
1876
|
+
(ReactSharedInternals.T = prevTransition);
|
|
1877
|
+
}
|
|
1878
|
+
};
|
|
1879
|
+
exports.unstable_useCacheRefresh = function () {
|
|
1880
|
+
return resolveDispatcher().useCacheRefresh();
|
|
1881
|
+
};
|
|
1882
|
+
exports.use = function (usable) {
|
|
1883
|
+
return resolveDispatcher().use(usable);
|
|
1884
|
+
};
|
|
1885
|
+
exports.useActionState = function (action, initialState, permalink) {
|
|
1886
|
+
return resolveDispatcher().useActionState(
|
|
1887
|
+
action,
|
|
1888
|
+
initialState,
|
|
1889
|
+
permalink
|
|
1890
|
+
);
|
|
1891
|
+
};
|
|
1892
|
+
exports.useCallback = function (callback, deps) {
|
|
1893
|
+
return resolveDispatcher().useCallback(callback, deps);
|
|
1894
|
+
};
|
|
1895
|
+
exports.useContext = function (Context) {
|
|
1896
|
+
var dispatcher = resolveDispatcher();
|
|
1897
|
+
Context.$$typeof === REACT_CONSUMER_TYPE &&
|
|
1898
|
+
console.error(
|
|
1899
|
+
"Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"
|
|
1900
|
+
);
|
|
1901
|
+
return dispatcher.useContext(Context);
|
|
1902
|
+
};
|
|
1903
|
+
exports.useDebugValue = function (value, formatterFn) {
|
|
1904
|
+
return resolveDispatcher().useDebugValue(value, formatterFn);
|
|
1905
|
+
};
|
|
1906
|
+
exports.useDeferredValue = function (value, initialValue) {
|
|
1907
|
+
return resolveDispatcher().useDeferredValue(value, initialValue);
|
|
1908
|
+
};
|
|
1909
|
+
exports.useEffect = function (create, deps) {
|
|
1910
|
+
null == create &&
|
|
1911
|
+
console.warn(
|
|
1912
|
+
"React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
|
1913
|
+
);
|
|
1914
|
+
return resolveDispatcher().useEffect(create, deps);
|
|
1915
|
+
};
|
|
1916
|
+
exports.useEffectEvent = function (callback) {
|
|
1917
|
+
return resolveDispatcher().useEffectEvent(callback);
|
|
1918
|
+
};
|
|
1919
|
+
exports.useId = function () {
|
|
1920
|
+
return resolveDispatcher().useId();
|
|
1921
|
+
};
|
|
1922
|
+
exports.useImperativeHandle = function (ref, create, deps) {
|
|
1923
|
+
return resolveDispatcher().useImperativeHandle(ref, create, deps);
|
|
1924
|
+
};
|
|
1925
|
+
exports.useInsertionEffect = function (create, deps) {
|
|
1926
|
+
null == create &&
|
|
1927
|
+
console.warn(
|
|
1928
|
+
"React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
|
1929
|
+
);
|
|
1930
|
+
return resolveDispatcher().useInsertionEffect(create, deps);
|
|
1931
|
+
};
|
|
1932
|
+
exports.useLayoutEffect = function (create, deps) {
|
|
1933
|
+
null == create &&
|
|
1934
|
+
console.warn(
|
|
1935
|
+
"React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
|
1936
|
+
);
|
|
1937
|
+
return resolveDispatcher().useLayoutEffect(create, deps);
|
|
1938
|
+
};
|
|
1939
|
+
exports.useMemo = function (create, deps) {
|
|
1940
|
+
return resolveDispatcher().useMemo(create, deps);
|
|
1941
|
+
};
|
|
1942
|
+
exports.useOptimistic = function (passthrough, reducer) {
|
|
1943
|
+
return resolveDispatcher().useOptimistic(passthrough, reducer);
|
|
1944
|
+
};
|
|
1945
|
+
exports.useReducer = function (reducer, initialArg, init) {
|
|
1946
|
+
return resolveDispatcher().useReducer(reducer, initialArg, init);
|
|
1947
|
+
};
|
|
1948
|
+
exports.useRef = function (initialValue) {
|
|
1949
|
+
return resolveDispatcher().useRef(initialValue);
|
|
1950
|
+
};
|
|
1951
|
+
exports.useState = function (initialState) {
|
|
1952
|
+
return resolveDispatcher().useState(initialState);
|
|
1953
|
+
};
|
|
1954
|
+
exports.useSyncExternalStore = function (
|
|
1955
|
+
subscribe,
|
|
1956
|
+
getSnapshot,
|
|
1957
|
+
getServerSnapshot
|
|
1958
|
+
) {
|
|
1959
|
+
return resolveDispatcher().useSyncExternalStore(
|
|
1960
|
+
subscribe,
|
|
1961
|
+
getSnapshot,
|
|
1962
|
+
getServerSnapshot
|
|
1963
|
+
);
|
|
1964
|
+
};
|
|
1965
|
+
exports.useTransition = function () {
|
|
1966
|
+
return resolveDispatcher().useTransition();
|
|
1967
|
+
};
|
|
1968
|
+
exports.version = "19.2.0";
|
|
1969
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
|
|
1970
|
+
"function" ===
|
|
1971
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
|
|
1972
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
1973
|
+
})();
|
|
1974
|
+
} (react_development, react_development.exports));
|
|
1975
|
+
return react_development.exports;
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
var hasRequiredReact;
|
|
1979
|
+
|
|
1980
|
+
function requireReact () {
|
|
1981
|
+
if (hasRequiredReact) return react.exports;
|
|
1982
|
+
hasRequiredReact = 1;
|
|
1983
|
+
|
|
1984
|
+
if (process.env.NODE_ENV === 'production') {
|
|
1985
|
+
react.exports = requireReact_production();
|
|
1986
|
+
} else {
|
|
1987
|
+
react.exports = requireReact_development();
|
|
1988
|
+
}
|
|
1989
|
+
return react.exports;
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
var reactExports = requireReact();
|
|
1993
|
+
|
|
1994
|
+
/**
|
|
1995
|
+
* React Hook: handles <input type="file" onChange> with validation + scanning.
|
|
1996
|
+
*/
|
|
1997
|
+
function useFileScanner() {
|
|
1998
|
+
const [results, setResults] = reactExports.useState([]);
|
|
1999
|
+
const [errors, setErrors] = reactExports.useState([]);
|
|
2000
|
+
const onChange = reactExports.useCallback(async (e) => {
|
|
2001
|
+
const fileList = Array.from(e.target.files || []);
|
|
2002
|
+
const good = [];
|
|
2003
|
+
const bad = [];
|
|
2004
|
+
for (const file of fileList) {
|
|
2005
|
+
const { valid, error } = validateFile(file);
|
|
2006
|
+
if (valid)
|
|
2007
|
+
good.push(file);
|
|
2008
|
+
else
|
|
2009
|
+
bad.push({ file, error: error });
|
|
2010
|
+
}
|
|
2011
|
+
setErrors(bad);
|
|
2012
|
+
if (good.length) {
|
|
2013
|
+
const scanned = await scanFiles(good);
|
|
2014
|
+
setResults(scanned.map((r, i) => ({ file: good[i], report: r })));
|
|
2015
|
+
}
|
|
2016
|
+
else {
|
|
2017
|
+
setResults([]);
|
|
2018
|
+
}
|
|
2019
|
+
}, []);
|
|
2020
|
+
return { results, errors, onChange };
|
|
2021
|
+
}
|
|
2022
|
+
|
|
2023
|
+
async function createRemoteEngine(opts) {
|
|
2024
|
+
const { endpoint, headers = {}, rulesField = 'rules', fileField = 'file', mode = 'multipart', rulesAsBase64 = false, } = opts;
|
|
2025
|
+
const engine = {
|
|
2026
|
+
async compile(rulesSource) {
|
|
2027
|
+
return {
|
|
2028
|
+
async scan(data) {
|
|
2029
|
+
const fetchFn = globalThis.fetch;
|
|
2030
|
+
if (!fetchFn)
|
|
2031
|
+
throw new Error('[remote-yara] fetch non disponibile in questo ambiente');
|
|
2032
|
+
let res;
|
|
2033
|
+
if (mode === 'multipart') {
|
|
2034
|
+
const FormDataCtor = globalThis.FormData;
|
|
2035
|
+
const BlobCtor = globalThis.Blob;
|
|
2036
|
+
if (!FormDataCtor || !BlobCtor) {
|
|
2037
|
+
throw new Error('[remote-yara] FormData/Blob non disponibili (usa json-base64 oppure esegui in browser)');
|
|
2038
|
+
}
|
|
2039
|
+
const form = new FormDataCtor();
|
|
2040
|
+
form.set(rulesField, new BlobCtor([rulesSource], { type: 'text/plain' }), 'rules.yar');
|
|
2041
|
+
form.set(fileField, new BlobCtor([data], { type: 'application/octet-stream' }), 'sample.bin');
|
|
2042
|
+
res = await fetchFn(endpoint, { method: 'POST', body: form, headers });
|
|
2043
|
+
}
|
|
2044
|
+
else {
|
|
2045
|
+
const b64 = base64FromBytes(data);
|
|
2046
|
+
const payload = { [fileField]: b64 };
|
|
2047
|
+
if (rulesAsBase64) {
|
|
2048
|
+
payload['rulesB64'] = base64FromString(rulesSource);
|
|
2049
|
+
}
|
|
2050
|
+
else {
|
|
2051
|
+
payload[rulesField] = rulesSource;
|
|
2052
|
+
}
|
|
2053
|
+
res = await fetchFn(endpoint, {
|
|
2054
|
+
method: 'POST',
|
|
2055
|
+
headers: { 'Content-Type': 'application/json', ...headers },
|
|
2056
|
+
body: JSON.stringify(payload),
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
2059
|
+
if (!res.ok) {
|
|
2060
|
+
throw new Error(`[remote-yara] HTTP ${res.status} ${res.statusText}`);
|
|
2061
|
+
}
|
|
2062
|
+
const json = await res.json().catch(() => null);
|
|
2063
|
+
const arr = Array.isArray(json) ? json : (json?.matches ?? []);
|
|
2064
|
+
return (arr ?? []).map((m) => ({
|
|
2065
|
+
rule: m.rule ?? m.ruleIdentifier ?? 'unknown',
|
|
2066
|
+
tags: m.tags ?? [],
|
|
2067
|
+
}));
|
|
2068
|
+
},
|
|
2069
|
+
};
|
|
2070
|
+
},
|
|
2071
|
+
};
|
|
2072
|
+
return engine;
|
|
2073
|
+
}
|
|
2074
|
+
// Helpers
|
|
2075
|
+
function base64FromBytes(bytes) {
|
|
2076
|
+
// usa btoa se disponibile (browser); altrimenti fallback manuale
|
|
2077
|
+
const btoaFn = globalThis.btoa;
|
|
2078
|
+
let bin = '';
|
|
2079
|
+
for (let i = 0; i < bytes.byteLength; i++)
|
|
2080
|
+
bin += String.fromCharCode(bytes[i]);
|
|
2081
|
+
return btoaFn ? btoaFn(bin) : Buffer.from(bin, 'binary').toString('base64');
|
|
2082
|
+
}
|
|
2083
|
+
function base64FromString(s) {
|
|
2084
|
+
const btoaFn = globalThis.btoa;
|
|
2085
|
+
return btoaFn ? btoaFn(s) : Buffer.from(s, 'utf8').toString('base64');
|
|
2086
|
+
}
|
|
2087
|
+
|
|
2088
|
+
// src/scan/remote.ts
|
|
2089
|
+
/**
|
|
2090
|
+
* Scansiona una lista di File nel browser usando il motore remoto via HTTP.
|
|
2091
|
+
* Non richiede WASM né dipendenze native sul client.
|
|
2092
|
+
*/
|
|
2093
|
+
async function scanFilesWithRemoteYara(files, rulesSource, remote) {
|
|
2094
|
+
const engine = await createRemoteEngine(remote);
|
|
2095
|
+
const compiled = await engine.compile(rulesSource);
|
|
2096
|
+
const results = [];
|
|
2097
|
+
for (const file of files) {
|
|
2098
|
+
try {
|
|
2099
|
+
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
2100
|
+
const matches = await compiled.scan(bytes);
|
|
2101
|
+
results.push({ file, matches });
|
|
2102
|
+
}
|
|
2103
|
+
catch (err) {
|
|
2104
|
+
console.warn('[remote-yara] scan error for', file.name, err);
|
|
2105
|
+
results.push({ file, matches: [], error: String(err?.message ?? err) });
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
return results;
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2111
|
+
function mapMatchesToVerdict(matches = []) {
|
|
2112
|
+
if (!matches.length)
|
|
2113
|
+
return 'clean';
|
|
2114
|
+
const malHints = ['trojan', 'ransom', 'worm', 'spy', 'rootkit', 'keylog', 'botnet'];
|
|
2115
|
+
const tagSet = new Set(matches.flatMap(m => (m.tags ?? []).map(t => t.toLowerCase())));
|
|
2116
|
+
const nameHit = (r) => malHints.some(h => r.toLowerCase().includes(h));
|
|
2117
|
+
const isMal = matches.some(m => nameHit(m.rule)) || tagSet.has('malware') || tagSet.has('critical');
|
|
2118
|
+
return isMal ? 'malicious' : 'suspicious';
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
function hasAsciiToken(buf, token) {
|
|
2122
|
+
// Use latin1 so we can safely search binary
|
|
2123
|
+
return buf.indexOf(token, 0, 'latin1') !== -1;
|
|
2124
|
+
}
|
|
2125
|
+
function startsWith(buf, bytes) {
|
|
2126
|
+
if (buf.length < bytes.length)
|
|
2127
|
+
return false;
|
|
2128
|
+
for (let i = 0; i < bytes.length; i++)
|
|
2129
|
+
if (buf[i] !== bytes[i])
|
|
2130
|
+
return false;
|
|
2131
|
+
return true;
|
|
2132
|
+
}
|
|
2133
|
+
function isPDF(buf) {
|
|
2134
|
+
// %PDF-
|
|
2135
|
+
return startsWith(buf, [0x25, 0x50, 0x44, 0x46, 0x2d]);
|
|
2136
|
+
}
|
|
2137
|
+
function isOleCfb(buf) {
|
|
2138
|
+
// D0 CF 11 E0 A1 B1 1A E1
|
|
2139
|
+
const sig = [0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1];
|
|
2140
|
+
return startsWith(buf, sig);
|
|
2141
|
+
}
|
|
2142
|
+
function isZipLike$1(buf) {
|
|
2143
|
+
// PK\x03\x04
|
|
2144
|
+
return startsWith(buf, [0x50, 0x4b, 0x03, 0x04]);
|
|
2145
|
+
}
|
|
2146
|
+
function isPeExecutable(buf) {
|
|
2147
|
+
// "MZ"
|
|
2148
|
+
return startsWith(buf, [0x4d, 0x5a]);
|
|
2149
|
+
}
|
|
2150
|
+
/** OOXML macro hint via filename token in ZIP container */
|
|
2151
|
+
function hasOoxmlMacros(buf) {
|
|
2152
|
+
if (!isZipLike$1(buf))
|
|
2153
|
+
return false;
|
|
2154
|
+
return hasAsciiToken(buf, 'vbaProject.bin');
|
|
2155
|
+
}
|
|
2156
|
+
/** PDF risky features (/JavaScript, /OpenAction, /AA, /Launch) */
|
|
2157
|
+
function pdfRiskTokens(buf) {
|
|
2158
|
+
const tokens = ['/JavaScript', '/OpenAction', '/AA', '/Launch'];
|
|
2159
|
+
return tokens.filter(t => hasAsciiToken(buf, t));
|
|
2160
|
+
}
|
|
2161
|
+
const CommonHeuristicsScanner = {
|
|
2162
|
+
async scan(input) {
|
|
2163
|
+
const buf = Buffer.from(input);
|
|
2164
|
+
const matches = [];
|
|
2165
|
+
// Office macros (OLE / OOXML)
|
|
2166
|
+
if (isOleCfb(buf)) {
|
|
2167
|
+
matches.push({ rule: 'office_ole_container', severity: 'suspicious' });
|
|
2168
|
+
}
|
|
2169
|
+
if (hasOoxmlMacros(buf)) {
|
|
2170
|
+
matches.push({ rule: 'office_ooxml_macros', severity: 'suspicious' });
|
|
2171
|
+
}
|
|
2172
|
+
// PDF risky tokens
|
|
2173
|
+
if (isPDF(buf)) {
|
|
2174
|
+
const toks = pdfRiskTokens(buf);
|
|
2175
|
+
if (toks.length) {
|
|
2176
|
+
matches.push({
|
|
2177
|
+
rule: 'pdf_risky_actions',
|
|
2178
|
+
severity: 'suspicious',
|
|
2179
|
+
meta: { tokens: toks }
|
|
2180
|
+
});
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
// Executable header
|
|
2184
|
+
if (isPeExecutable(buf)) {
|
|
2185
|
+
matches.push({ rule: 'pe_executable_signature', severity: 'suspicious' });
|
|
2186
|
+
}
|
|
2187
|
+
return matches;
|
|
2188
|
+
}
|
|
2189
|
+
};
|
|
2190
|
+
|
|
2191
|
+
const SIG_CEN = 0x02014b50;
|
|
2192
|
+
const DEFAULTS = {
|
|
2193
|
+
maxEntries: 1000,
|
|
2194
|
+
maxTotalUncompressedBytes: 500 * 1024 * 1024,
|
|
2195
|
+
maxEntryNameLength: 255,
|
|
2196
|
+
maxCompressionRatio: 1000,
|
|
2197
|
+
eocdSearchWindow: 70000,
|
|
2198
|
+
};
|
|
2199
|
+
function r16(buf, off) {
|
|
2200
|
+
return buf.readUInt16LE(off);
|
|
2201
|
+
}
|
|
2202
|
+
function r32(buf, off) {
|
|
2203
|
+
return buf.readUInt32LE(off);
|
|
2204
|
+
}
|
|
2205
|
+
function isZipLike(buf) {
|
|
2206
|
+
// local file header at start is common
|
|
2207
|
+
return buf.length >= 4 && buf[0] === 0x50 && buf[1] === 0x4b && buf[2] === 0x03 && buf[3] === 0x04;
|
|
2208
|
+
}
|
|
2209
|
+
function lastIndexOfEOCD(buf, window) {
|
|
2210
|
+
const sig = Buffer.from([0x50, 0x4b, 0x05, 0x06]);
|
|
2211
|
+
const start = Math.max(0, buf.length - window);
|
|
2212
|
+
const idx = buf.lastIndexOf(sig, Math.min(buf.length - sig.length, buf.length - 1));
|
|
2213
|
+
return idx >= start ? idx : -1;
|
|
2214
|
+
}
|
|
2215
|
+
function hasTraversal(name) {
|
|
2216
|
+
return name.includes('../') || name.includes('..\\') || name.startsWith('/') || /^[A-Za-z]:/.test(name);
|
|
2217
|
+
}
|
|
2218
|
+
function createZipBombGuard(opts = {}) {
|
|
2219
|
+
const cfg = { ...DEFAULTS, ...opts };
|
|
2220
|
+
return {
|
|
2221
|
+
async scan(input) {
|
|
2222
|
+
const buf = Buffer.from(input);
|
|
2223
|
+
const matches = [];
|
|
2224
|
+
if (!isZipLike(buf))
|
|
2225
|
+
return matches;
|
|
2226
|
+
// Find EOCD near the end
|
|
2227
|
+
const eocdPos = lastIndexOfEOCD(buf, cfg.eocdSearchWindow);
|
|
2228
|
+
if (eocdPos < 0 || eocdPos + 22 > buf.length) {
|
|
2229
|
+
// ZIP but no EOCD — malformed or polyglot → suspicious
|
|
2230
|
+
matches.push({ rule: 'zip_eocd_not_found', severity: 'medium' });
|
|
2231
|
+
return matches;
|
|
2232
|
+
}
|
|
2233
|
+
const totalEntries = r16(buf, eocdPos + 10);
|
|
2234
|
+
const cdSize = r32(buf, eocdPos + 12);
|
|
2235
|
+
const cdOffset = r32(buf, eocdPos + 16);
|
|
2236
|
+
// Bounds check
|
|
2237
|
+
if (cdOffset + cdSize > buf.length) {
|
|
2238
|
+
matches.push({ rule: 'zip_cd_out_of_bounds', severity: 'medium' });
|
|
2239
|
+
return matches;
|
|
2240
|
+
}
|
|
2241
|
+
// Iterate central directory entries
|
|
2242
|
+
let ptr = cdOffset;
|
|
2243
|
+
let seen = 0;
|
|
2244
|
+
let sumComp = 0;
|
|
2245
|
+
let sumUnc = 0;
|
|
2246
|
+
while (ptr + 46 <= cdOffset + cdSize && seen < totalEntries) {
|
|
2247
|
+
const sig = r32(buf, ptr);
|
|
2248
|
+
if (sig !== SIG_CEN)
|
|
2249
|
+
break; // stop if structure breaks
|
|
2250
|
+
const compSize = r32(buf, ptr + 20);
|
|
2251
|
+
const uncSize = r32(buf, ptr + 24);
|
|
2252
|
+
const fnLen = r16(buf, ptr + 28);
|
|
2253
|
+
const exLen = r16(buf, ptr + 30);
|
|
2254
|
+
const cmLen = r16(buf, ptr + 32);
|
|
2255
|
+
const nameStart = ptr + 46;
|
|
2256
|
+
const nameEnd = nameStart + fnLen;
|
|
2257
|
+
if (nameEnd > buf.length)
|
|
2258
|
+
break;
|
|
2259
|
+
const name = buf.toString('utf8', nameStart, nameEnd);
|
|
2260
|
+
sumComp += compSize;
|
|
2261
|
+
sumUnc += uncSize;
|
|
2262
|
+
seen++;
|
|
2263
|
+
if (name.length > cfg.maxEntryNameLength) {
|
|
2264
|
+
matches.push({ rule: 'zip_entry_name_too_long', severity: 'medium', meta: { name, length: name.length } });
|
|
2265
|
+
}
|
|
2266
|
+
if (hasTraversal(name)) {
|
|
2267
|
+
matches.push({ rule: 'zip_path_traversal_entry', severity: 'medium', meta: { name } });
|
|
2268
|
+
}
|
|
2269
|
+
// move to next entry
|
|
2270
|
+
ptr = nameEnd + exLen + cmLen;
|
|
2271
|
+
}
|
|
2272
|
+
if (seen !== totalEntries) {
|
|
2273
|
+
// central dir truncated/odd, still report what we found
|
|
2274
|
+
matches.push({ rule: 'zip_cd_truncated', severity: 'medium', meta: { seen, totalEntries } });
|
|
2275
|
+
}
|
|
2276
|
+
// Heuristics thresholds
|
|
2277
|
+
if (seen > cfg.maxEntries) {
|
|
2278
|
+
matches.push({ rule: 'zip_too_many_entries', severity: 'medium', meta: { seen, limit: cfg.maxEntries } });
|
|
2279
|
+
}
|
|
2280
|
+
if (sumUnc > cfg.maxTotalUncompressedBytes) {
|
|
2281
|
+
matches.push({
|
|
2282
|
+
rule: 'zip_total_uncompressed_too_large',
|
|
2283
|
+
severity: 'medium',
|
|
2284
|
+
meta: { totalUncompressed: sumUnc, limit: cfg.maxTotalUncompressedBytes }
|
|
2285
|
+
});
|
|
2286
|
+
}
|
|
2287
|
+
if (sumComp === 0 && sumUnc > 0) {
|
|
2288
|
+
matches.push({ rule: 'zip_suspicious_ratio', severity: 'medium', meta: { ratio: Infinity } });
|
|
2289
|
+
}
|
|
2290
|
+
else if (sumComp > 0) {
|
|
2291
|
+
const ratio = sumUnc / Math.max(1, sumComp);
|
|
2292
|
+
if (ratio >= cfg.maxCompressionRatio) {
|
|
2293
|
+
matches.push({ rule: 'zip_suspicious_ratio', severity: 'medium', meta: { ratio, limit: cfg.maxCompressionRatio } });
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
return matches;
|
|
2297
|
+
}
|
|
2298
|
+
};
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
const MB = 1024 * 1024;
|
|
2302
|
+
const DEFAULT_POLICY = {
|
|
2303
|
+
includeExtensions: ['zip', 'png', 'jpg', 'jpeg', 'pdf'],
|
|
2304
|
+
allowedMimeTypes: ['application/zip', 'image/png', 'image/jpeg', 'application/pdf', 'text/plain'],
|
|
2305
|
+
maxFileSizeBytes: 20 * MB,
|
|
2306
|
+
timeoutMs: 5000,
|
|
2307
|
+
concurrency: 4,
|
|
2308
|
+
failClosed: true
|
|
2309
|
+
};
|
|
2310
|
+
function definePolicy(input = {}) {
|
|
2311
|
+
const p = { ...DEFAULT_POLICY, ...input };
|
|
2312
|
+
if (!Array.isArray(p.includeExtensions))
|
|
2313
|
+
throw new TypeError('includeExtensions must be string[]');
|
|
2314
|
+
if (!Array.isArray(p.allowedMimeTypes))
|
|
2315
|
+
throw new TypeError('allowedMimeTypes must be string[]');
|
|
2316
|
+
if (!(Number.isFinite(p.maxFileSizeBytes) && p.maxFileSizeBytes > 0))
|
|
2317
|
+
throw new TypeError('maxFileSizeBytes must be > 0');
|
|
2318
|
+
if (!(Number.isFinite(p.timeoutMs) && p.timeoutMs > 0))
|
|
2319
|
+
throw new TypeError('timeoutMs must be > 0');
|
|
2320
|
+
if (!(Number.isInteger(p.concurrency) && p.concurrency > 0))
|
|
2321
|
+
throw new TypeError('concurrency must be > 0');
|
|
2322
|
+
return p;
|
|
2323
|
+
}
|
|
2324
|
+
|
|
2325
|
+
export { CommonHeuristicsScanner, DEFAULT_POLICY, composeScanners, createPresetScanner, createZipBombGuard, definePolicy, mapMatchesToVerdict, scanBytes, scanFile, scanFiles, scanFilesWithRemoteYara, useFileScanner, validateFile };
|
|
2326
|
+
//# sourceMappingURL=pompelmi.esm.js.map
|