@doenet/assignment-viewer 0.1.0-alpha-10
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/LICENSE +661 -0
- package/README.md +3 -0
- package/dist/favicon.ico +0 -0
- package/dist/index.js +4222 -0
- package/package.json +66 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,4222 @@
|
|
|
1
|
+
import React, { useState, useRef, useMemo, useEffect, useReducer, useCallback, Component } from "react";
|
|
2
|
+
import { DoenetViewer } from "@doenet/doenetml-iframe";
|
|
3
|
+
function getDefaultExportFromCjs(x) {
|
|
4
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
5
|
+
}
|
|
6
|
+
function getAugmentedNamespace(n) {
|
|
7
|
+
if (Object.prototype.hasOwnProperty.call(n, "__esModule")) return n;
|
|
8
|
+
var f = n.default;
|
|
9
|
+
if (typeof f == "function") {
|
|
10
|
+
var a = function a2() {
|
|
11
|
+
var isInstance = false;
|
|
12
|
+
try {
|
|
13
|
+
isInstance = this instanceof a2;
|
|
14
|
+
} catch {
|
|
15
|
+
}
|
|
16
|
+
if (isInstance) {
|
|
17
|
+
return Reflect.construct(f, arguments, this.constructor);
|
|
18
|
+
}
|
|
19
|
+
return f.apply(this, arguments);
|
|
20
|
+
};
|
|
21
|
+
a.prototype = f.prototype;
|
|
22
|
+
} else a = {};
|
|
23
|
+
Object.defineProperty(a, "__esModule", { value: true });
|
|
24
|
+
Object.keys(n).forEach(function(k) {
|
|
25
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
26
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function() {
|
|
29
|
+
return n[k];
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
return a;
|
|
34
|
+
}
|
|
35
|
+
var jsxRuntime = { exports: {} };
|
|
36
|
+
var reactJsxRuntime_production = {};
|
|
37
|
+
var hasRequiredReactJsxRuntime_production;
|
|
38
|
+
function requireReactJsxRuntime_production() {
|
|
39
|
+
if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
|
|
40
|
+
hasRequiredReactJsxRuntime_production = 1;
|
|
41
|
+
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
42
|
+
function jsxProd(type, config, maybeKey) {
|
|
43
|
+
var key = null;
|
|
44
|
+
void 0 !== maybeKey && (key = "" + maybeKey);
|
|
45
|
+
void 0 !== config.key && (key = "" + config.key);
|
|
46
|
+
if ("key" in config) {
|
|
47
|
+
maybeKey = {};
|
|
48
|
+
for (var propName in config)
|
|
49
|
+
"key" !== propName && (maybeKey[propName] = config[propName]);
|
|
50
|
+
} else maybeKey = config;
|
|
51
|
+
config = maybeKey.ref;
|
|
52
|
+
return {
|
|
53
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
54
|
+
type,
|
|
55
|
+
key,
|
|
56
|
+
ref: void 0 !== config ? config : null,
|
|
57
|
+
props: maybeKey
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
|
|
61
|
+
reactJsxRuntime_production.jsx = jsxProd;
|
|
62
|
+
reactJsxRuntime_production.jsxs = jsxProd;
|
|
63
|
+
return reactJsxRuntime_production;
|
|
64
|
+
}
|
|
65
|
+
var reactJsxRuntime_development = {};
|
|
66
|
+
var hasRequiredReactJsxRuntime_development;
|
|
67
|
+
function requireReactJsxRuntime_development() {
|
|
68
|
+
if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
|
|
69
|
+
hasRequiredReactJsxRuntime_development = 1;
|
|
70
|
+
"production" !== process.env.NODE_ENV && function() {
|
|
71
|
+
function getComponentNameFromType(type) {
|
|
72
|
+
if (null == type) return null;
|
|
73
|
+
if ("function" === typeof type)
|
|
74
|
+
return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
|
|
75
|
+
if ("string" === typeof type) return type;
|
|
76
|
+
switch (type) {
|
|
77
|
+
case REACT_FRAGMENT_TYPE:
|
|
78
|
+
return "Fragment";
|
|
79
|
+
case REACT_PROFILER_TYPE:
|
|
80
|
+
return "Profiler";
|
|
81
|
+
case REACT_STRICT_MODE_TYPE:
|
|
82
|
+
return "StrictMode";
|
|
83
|
+
case REACT_SUSPENSE_TYPE:
|
|
84
|
+
return "Suspense";
|
|
85
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
86
|
+
return "SuspenseList";
|
|
87
|
+
case REACT_ACTIVITY_TYPE:
|
|
88
|
+
return "Activity";
|
|
89
|
+
}
|
|
90
|
+
if ("object" === typeof type)
|
|
91
|
+
switch ("number" === typeof type.tag && console.error(
|
|
92
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
93
|
+
), type.$$typeof) {
|
|
94
|
+
case REACT_PORTAL_TYPE:
|
|
95
|
+
return "Portal";
|
|
96
|
+
case REACT_CONTEXT_TYPE:
|
|
97
|
+
return type.displayName || "Context";
|
|
98
|
+
case REACT_CONSUMER_TYPE:
|
|
99
|
+
return (type._context.displayName || "Context") + ".Consumer";
|
|
100
|
+
case REACT_FORWARD_REF_TYPE:
|
|
101
|
+
var innerType = type.render;
|
|
102
|
+
type = type.displayName;
|
|
103
|
+
type || (type = innerType.displayName || innerType.name || "", type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef");
|
|
104
|
+
return type;
|
|
105
|
+
case REACT_MEMO_TYPE:
|
|
106
|
+
return innerType = type.displayName || null, null !== innerType ? innerType : getComponentNameFromType(type.type) || "Memo";
|
|
107
|
+
case REACT_LAZY_TYPE:
|
|
108
|
+
innerType = type._payload;
|
|
109
|
+
type = type._init;
|
|
110
|
+
try {
|
|
111
|
+
return getComponentNameFromType(type(innerType));
|
|
112
|
+
} catch (x) {
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
function testStringCoercion(value) {
|
|
118
|
+
return "" + value;
|
|
119
|
+
}
|
|
120
|
+
function checkKeyStringCoercion(value) {
|
|
121
|
+
try {
|
|
122
|
+
testStringCoercion(value);
|
|
123
|
+
var JSCompiler_inline_result = false;
|
|
124
|
+
} catch (e) {
|
|
125
|
+
JSCompiler_inline_result = true;
|
|
126
|
+
}
|
|
127
|
+
if (JSCompiler_inline_result) {
|
|
128
|
+
JSCompiler_inline_result = console;
|
|
129
|
+
var JSCompiler_temp_const = JSCompiler_inline_result.error;
|
|
130
|
+
var JSCompiler_inline_result$jscomp$0 = "function" === typeof Symbol && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
|
|
131
|
+
JSCompiler_temp_const.call(
|
|
132
|
+
JSCompiler_inline_result,
|
|
133
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
134
|
+
JSCompiler_inline_result$jscomp$0
|
|
135
|
+
);
|
|
136
|
+
return testStringCoercion(value);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function getTaskName(type) {
|
|
140
|
+
if (type === REACT_FRAGMENT_TYPE) return "<>";
|
|
141
|
+
if ("object" === typeof type && null !== type && type.$$typeof === REACT_LAZY_TYPE)
|
|
142
|
+
return "<...>";
|
|
143
|
+
try {
|
|
144
|
+
var name = getComponentNameFromType(type);
|
|
145
|
+
return name ? "<" + name + ">" : "<...>";
|
|
146
|
+
} catch (x) {
|
|
147
|
+
return "<...>";
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function getOwner() {
|
|
151
|
+
var dispatcher = ReactSharedInternals.A;
|
|
152
|
+
return null === dispatcher ? null : dispatcher.getOwner();
|
|
153
|
+
}
|
|
154
|
+
function UnknownOwner() {
|
|
155
|
+
return Error("react-stack-top-frame");
|
|
156
|
+
}
|
|
157
|
+
function hasValidKey(config) {
|
|
158
|
+
if (hasOwnProperty.call(config, "key")) {
|
|
159
|
+
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
|
160
|
+
if (getter && getter.isReactWarning) return false;
|
|
161
|
+
}
|
|
162
|
+
return void 0 !== config.key;
|
|
163
|
+
}
|
|
164
|
+
function defineKeyPropWarningGetter(props, displayName) {
|
|
165
|
+
function warnAboutAccessingKey() {
|
|
166
|
+
specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error(
|
|
167
|
+
"%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)",
|
|
168
|
+
displayName
|
|
169
|
+
));
|
|
170
|
+
}
|
|
171
|
+
warnAboutAccessingKey.isReactWarning = true;
|
|
172
|
+
Object.defineProperty(props, "key", {
|
|
173
|
+
get: warnAboutAccessingKey,
|
|
174
|
+
configurable: true
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
function elementRefGetterWithDeprecationWarning() {
|
|
178
|
+
var componentName = getComponentNameFromType(this.type);
|
|
179
|
+
didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error(
|
|
180
|
+
"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."
|
|
181
|
+
));
|
|
182
|
+
componentName = this.props.ref;
|
|
183
|
+
return void 0 !== componentName ? componentName : null;
|
|
184
|
+
}
|
|
185
|
+
function ReactElement(type, key, props, owner, debugStack, debugTask) {
|
|
186
|
+
var refProp = props.ref;
|
|
187
|
+
type = {
|
|
188
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
189
|
+
type,
|
|
190
|
+
key,
|
|
191
|
+
props,
|
|
192
|
+
_owner: owner
|
|
193
|
+
};
|
|
194
|
+
null !== (void 0 !== refProp ? refProp : null) ? Object.defineProperty(type, "ref", {
|
|
195
|
+
enumerable: false,
|
|
196
|
+
get: elementRefGetterWithDeprecationWarning
|
|
197
|
+
}) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
|
|
198
|
+
type._store = {};
|
|
199
|
+
Object.defineProperty(type._store, "validated", {
|
|
200
|
+
configurable: false,
|
|
201
|
+
enumerable: false,
|
|
202
|
+
writable: true,
|
|
203
|
+
value: 0
|
|
204
|
+
});
|
|
205
|
+
Object.defineProperty(type, "_debugInfo", {
|
|
206
|
+
configurable: false,
|
|
207
|
+
enumerable: false,
|
|
208
|
+
writable: true,
|
|
209
|
+
value: null
|
|
210
|
+
});
|
|
211
|
+
Object.defineProperty(type, "_debugStack", {
|
|
212
|
+
configurable: false,
|
|
213
|
+
enumerable: false,
|
|
214
|
+
writable: true,
|
|
215
|
+
value: debugStack
|
|
216
|
+
});
|
|
217
|
+
Object.defineProperty(type, "_debugTask", {
|
|
218
|
+
configurable: false,
|
|
219
|
+
enumerable: false,
|
|
220
|
+
writable: true,
|
|
221
|
+
value: debugTask
|
|
222
|
+
});
|
|
223
|
+
Object.freeze && (Object.freeze(type.props), Object.freeze(type));
|
|
224
|
+
return type;
|
|
225
|
+
}
|
|
226
|
+
function jsxDEVImpl(type, config, maybeKey, isStaticChildren, debugStack, debugTask) {
|
|
227
|
+
var children = config.children;
|
|
228
|
+
if (void 0 !== children)
|
|
229
|
+
if (isStaticChildren)
|
|
230
|
+
if (isArrayImpl(children)) {
|
|
231
|
+
for (isStaticChildren = 0; isStaticChildren < children.length; isStaticChildren++)
|
|
232
|
+
validateChildKeys(children[isStaticChildren]);
|
|
233
|
+
Object.freeze && Object.freeze(children);
|
|
234
|
+
} else
|
|
235
|
+
console.error(
|
|
236
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
237
|
+
);
|
|
238
|
+
else validateChildKeys(children);
|
|
239
|
+
if (hasOwnProperty.call(config, "key")) {
|
|
240
|
+
children = getComponentNameFromType(type);
|
|
241
|
+
var keys = Object.keys(config).filter(function(k) {
|
|
242
|
+
return "key" !== k;
|
|
243
|
+
});
|
|
244
|
+
isStaticChildren = 0 < keys.length ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
245
|
+
didWarnAboutKeySpread[children + isStaticChildren] || (keys = 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
246
|
+
'A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',
|
|
247
|
+
isStaticChildren,
|
|
248
|
+
children,
|
|
249
|
+
keys,
|
|
250
|
+
children
|
|
251
|
+
), didWarnAboutKeySpread[children + isStaticChildren] = true);
|
|
252
|
+
}
|
|
253
|
+
children = null;
|
|
254
|
+
void 0 !== maybeKey && (checkKeyStringCoercion(maybeKey), children = "" + maybeKey);
|
|
255
|
+
hasValidKey(config) && (checkKeyStringCoercion(config.key), children = "" + config.key);
|
|
256
|
+
if ("key" in config) {
|
|
257
|
+
maybeKey = {};
|
|
258
|
+
for (var propName in config)
|
|
259
|
+
"key" !== propName && (maybeKey[propName] = config[propName]);
|
|
260
|
+
} else maybeKey = config;
|
|
261
|
+
children && defineKeyPropWarningGetter(
|
|
262
|
+
maybeKey,
|
|
263
|
+
"function" === typeof type ? type.displayName || type.name || "Unknown" : type
|
|
264
|
+
);
|
|
265
|
+
return ReactElement(
|
|
266
|
+
type,
|
|
267
|
+
children,
|
|
268
|
+
maybeKey,
|
|
269
|
+
getOwner(),
|
|
270
|
+
debugStack,
|
|
271
|
+
debugTask
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
function validateChildKeys(node) {
|
|
275
|
+
isValidElement(node) ? node._store && (node._store.validated = 1) : "object" === typeof node && null !== node && node.$$typeof === REACT_LAZY_TYPE && ("fulfilled" === node._payload.status ? isValidElement(node._payload.value) && node._payload.value._store && (node._payload.value._store.validated = 1) : node._store && (node._store.validated = 1));
|
|
276
|
+
}
|
|
277
|
+
function isValidElement(object) {
|
|
278
|
+
return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
279
|
+
}
|
|
280
|
+
var React$1 = React, REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = Symbol.for("react.activity"), REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), ReactSharedInternals = React$1.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, hasOwnProperty = Object.prototype.hasOwnProperty, isArrayImpl = Array.isArray, createTask = console.createTask ? console.createTask : function() {
|
|
281
|
+
return null;
|
|
282
|
+
};
|
|
283
|
+
React$1 = {
|
|
284
|
+
react_stack_bottom_frame: function(callStackForError) {
|
|
285
|
+
return callStackForError();
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
var specialPropKeyWarningShown;
|
|
289
|
+
var didWarnAboutElementRef = {};
|
|
290
|
+
var unknownOwnerDebugStack = React$1.react_stack_bottom_frame.bind(
|
|
291
|
+
React$1,
|
|
292
|
+
UnknownOwner
|
|
293
|
+
)();
|
|
294
|
+
var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
|
|
295
|
+
var didWarnAboutKeySpread = {};
|
|
296
|
+
reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
|
|
297
|
+
reactJsxRuntime_development.jsx = function(type, config, maybeKey) {
|
|
298
|
+
var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
299
|
+
return jsxDEVImpl(
|
|
300
|
+
type,
|
|
301
|
+
config,
|
|
302
|
+
maybeKey,
|
|
303
|
+
false,
|
|
304
|
+
trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
|
|
305
|
+
trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
306
|
+
);
|
|
307
|
+
};
|
|
308
|
+
reactJsxRuntime_development.jsxs = function(type, config, maybeKey) {
|
|
309
|
+
var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
310
|
+
return jsxDEVImpl(
|
|
311
|
+
type,
|
|
312
|
+
config,
|
|
313
|
+
maybeKey,
|
|
314
|
+
true,
|
|
315
|
+
trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
|
|
316
|
+
trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
317
|
+
);
|
|
318
|
+
};
|
|
319
|
+
}();
|
|
320
|
+
return reactJsxRuntime_development;
|
|
321
|
+
}
|
|
322
|
+
var hasRequiredJsxRuntime;
|
|
323
|
+
function requireJsxRuntime() {
|
|
324
|
+
if (hasRequiredJsxRuntime) return jsxRuntime.exports;
|
|
325
|
+
hasRequiredJsxRuntime = 1;
|
|
326
|
+
if (process.env.NODE_ENV === "production") {
|
|
327
|
+
jsxRuntime.exports = requireReactJsxRuntime_production();
|
|
328
|
+
} else {
|
|
329
|
+
jsxRuntime.exports = requireReactJsxRuntime_development();
|
|
330
|
+
}
|
|
331
|
+
return jsxRuntime.exports;
|
|
332
|
+
}
|
|
333
|
+
var jsxRuntimeExports = requireJsxRuntime();
|
|
334
|
+
var alea$1 = { exports: {} };
|
|
335
|
+
var alea = alea$1.exports;
|
|
336
|
+
var hasRequiredAlea;
|
|
337
|
+
function requireAlea() {
|
|
338
|
+
if (hasRequiredAlea) return alea$1.exports;
|
|
339
|
+
hasRequiredAlea = 1;
|
|
340
|
+
(function(module) {
|
|
341
|
+
(function(global, module2, define) {
|
|
342
|
+
function Alea(seed) {
|
|
343
|
+
var me = this, mash = Mash();
|
|
344
|
+
me.next = function() {
|
|
345
|
+
var t = 2091639 * me.s0 + me.c * 23283064365386963e-26;
|
|
346
|
+
me.s0 = me.s1;
|
|
347
|
+
me.s1 = me.s2;
|
|
348
|
+
return me.s2 = t - (me.c = t | 0);
|
|
349
|
+
};
|
|
350
|
+
me.c = 1;
|
|
351
|
+
me.s0 = mash(" ");
|
|
352
|
+
me.s1 = mash(" ");
|
|
353
|
+
me.s2 = mash(" ");
|
|
354
|
+
me.s0 -= mash(seed);
|
|
355
|
+
if (me.s0 < 0) {
|
|
356
|
+
me.s0 += 1;
|
|
357
|
+
}
|
|
358
|
+
me.s1 -= mash(seed);
|
|
359
|
+
if (me.s1 < 0) {
|
|
360
|
+
me.s1 += 1;
|
|
361
|
+
}
|
|
362
|
+
me.s2 -= mash(seed);
|
|
363
|
+
if (me.s2 < 0) {
|
|
364
|
+
me.s2 += 1;
|
|
365
|
+
}
|
|
366
|
+
mash = null;
|
|
367
|
+
}
|
|
368
|
+
function copy(f, t) {
|
|
369
|
+
t.c = f.c;
|
|
370
|
+
t.s0 = f.s0;
|
|
371
|
+
t.s1 = f.s1;
|
|
372
|
+
t.s2 = f.s2;
|
|
373
|
+
return t;
|
|
374
|
+
}
|
|
375
|
+
function impl(seed, opts) {
|
|
376
|
+
var xg = new Alea(seed), state = opts && opts.state, prng = xg.next;
|
|
377
|
+
prng.int32 = function() {
|
|
378
|
+
return xg.next() * 4294967296 | 0;
|
|
379
|
+
};
|
|
380
|
+
prng.double = function() {
|
|
381
|
+
return prng() + (prng() * 2097152 | 0) * 11102230246251565e-32;
|
|
382
|
+
};
|
|
383
|
+
prng.quick = prng;
|
|
384
|
+
if (state) {
|
|
385
|
+
if (typeof state == "object") copy(state, xg);
|
|
386
|
+
prng.state = function() {
|
|
387
|
+
return copy(xg, {});
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
return prng;
|
|
391
|
+
}
|
|
392
|
+
function Mash() {
|
|
393
|
+
var n = 4022871197;
|
|
394
|
+
var mash = function(data) {
|
|
395
|
+
data = String(data);
|
|
396
|
+
for (var i = 0; i < data.length; i++) {
|
|
397
|
+
n += data.charCodeAt(i);
|
|
398
|
+
var h = 0.02519603282416938 * n;
|
|
399
|
+
n = h >>> 0;
|
|
400
|
+
h -= n;
|
|
401
|
+
h *= n;
|
|
402
|
+
n = h >>> 0;
|
|
403
|
+
h -= n;
|
|
404
|
+
n += h * 4294967296;
|
|
405
|
+
}
|
|
406
|
+
return (n >>> 0) * 23283064365386963e-26;
|
|
407
|
+
};
|
|
408
|
+
return mash;
|
|
409
|
+
}
|
|
410
|
+
if (module2 && module2.exports) {
|
|
411
|
+
module2.exports = impl;
|
|
412
|
+
} else {
|
|
413
|
+
this.alea = impl;
|
|
414
|
+
}
|
|
415
|
+
})(
|
|
416
|
+
alea,
|
|
417
|
+
module
|
|
418
|
+
);
|
|
419
|
+
})(alea$1);
|
|
420
|
+
return alea$1.exports;
|
|
421
|
+
}
|
|
422
|
+
var xor128$1 = { exports: {} };
|
|
423
|
+
var xor128 = xor128$1.exports;
|
|
424
|
+
var hasRequiredXor128;
|
|
425
|
+
function requireXor128() {
|
|
426
|
+
if (hasRequiredXor128) return xor128$1.exports;
|
|
427
|
+
hasRequiredXor128 = 1;
|
|
428
|
+
(function(module) {
|
|
429
|
+
(function(global, module2, define) {
|
|
430
|
+
function XorGen(seed) {
|
|
431
|
+
var me = this, strseed = "";
|
|
432
|
+
me.x = 0;
|
|
433
|
+
me.y = 0;
|
|
434
|
+
me.z = 0;
|
|
435
|
+
me.w = 0;
|
|
436
|
+
me.next = function() {
|
|
437
|
+
var t = me.x ^ me.x << 11;
|
|
438
|
+
me.x = me.y;
|
|
439
|
+
me.y = me.z;
|
|
440
|
+
me.z = me.w;
|
|
441
|
+
return me.w ^= me.w >>> 19 ^ t ^ t >>> 8;
|
|
442
|
+
};
|
|
443
|
+
if (seed === (seed | 0)) {
|
|
444
|
+
me.x = seed;
|
|
445
|
+
} else {
|
|
446
|
+
strseed += seed;
|
|
447
|
+
}
|
|
448
|
+
for (var k = 0; k < strseed.length + 64; k++) {
|
|
449
|
+
me.x ^= strseed.charCodeAt(k) | 0;
|
|
450
|
+
me.next();
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
function copy(f, t) {
|
|
454
|
+
t.x = f.x;
|
|
455
|
+
t.y = f.y;
|
|
456
|
+
t.z = f.z;
|
|
457
|
+
t.w = f.w;
|
|
458
|
+
return t;
|
|
459
|
+
}
|
|
460
|
+
function impl(seed, opts) {
|
|
461
|
+
var xg = new XorGen(seed), state = opts && opts.state, prng = function() {
|
|
462
|
+
return (xg.next() >>> 0) / 4294967296;
|
|
463
|
+
};
|
|
464
|
+
prng.double = function() {
|
|
465
|
+
do {
|
|
466
|
+
var top = xg.next() >>> 11, bot = (xg.next() >>> 0) / 4294967296, result = (top + bot) / (1 << 21);
|
|
467
|
+
} while (result === 0);
|
|
468
|
+
return result;
|
|
469
|
+
};
|
|
470
|
+
prng.int32 = xg.next;
|
|
471
|
+
prng.quick = prng;
|
|
472
|
+
if (state) {
|
|
473
|
+
if (typeof state == "object") copy(state, xg);
|
|
474
|
+
prng.state = function() {
|
|
475
|
+
return copy(xg, {});
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
return prng;
|
|
479
|
+
}
|
|
480
|
+
if (module2 && module2.exports) {
|
|
481
|
+
module2.exports = impl;
|
|
482
|
+
} else {
|
|
483
|
+
this.xor128 = impl;
|
|
484
|
+
}
|
|
485
|
+
})(
|
|
486
|
+
xor128,
|
|
487
|
+
module
|
|
488
|
+
);
|
|
489
|
+
})(xor128$1);
|
|
490
|
+
return xor128$1.exports;
|
|
491
|
+
}
|
|
492
|
+
var xorwow$1 = { exports: {} };
|
|
493
|
+
var xorwow = xorwow$1.exports;
|
|
494
|
+
var hasRequiredXorwow;
|
|
495
|
+
function requireXorwow() {
|
|
496
|
+
if (hasRequiredXorwow) return xorwow$1.exports;
|
|
497
|
+
hasRequiredXorwow = 1;
|
|
498
|
+
(function(module) {
|
|
499
|
+
(function(global, module2, define) {
|
|
500
|
+
function XorGen(seed) {
|
|
501
|
+
var me = this, strseed = "";
|
|
502
|
+
me.next = function() {
|
|
503
|
+
var t = me.x ^ me.x >>> 2;
|
|
504
|
+
me.x = me.y;
|
|
505
|
+
me.y = me.z;
|
|
506
|
+
me.z = me.w;
|
|
507
|
+
me.w = me.v;
|
|
508
|
+
return (me.d = me.d + 362437 | 0) + (me.v = me.v ^ me.v << 4 ^ (t ^ t << 1)) | 0;
|
|
509
|
+
};
|
|
510
|
+
me.x = 0;
|
|
511
|
+
me.y = 0;
|
|
512
|
+
me.z = 0;
|
|
513
|
+
me.w = 0;
|
|
514
|
+
me.v = 0;
|
|
515
|
+
if (seed === (seed | 0)) {
|
|
516
|
+
me.x = seed;
|
|
517
|
+
} else {
|
|
518
|
+
strseed += seed;
|
|
519
|
+
}
|
|
520
|
+
for (var k = 0; k < strseed.length + 64; k++) {
|
|
521
|
+
me.x ^= strseed.charCodeAt(k) | 0;
|
|
522
|
+
if (k == strseed.length) {
|
|
523
|
+
me.d = me.x << 10 ^ me.x >>> 4;
|
|
524
|
+
}
|
|
525
|
+
me.next();
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
function copy(f, t) {
|
|
529
|
+
t.x = f.x;
|
|
530
|
+
t.y = f.y;
|
|
531
|
+
t.z = f.z;
|
|
532
|
+
t.w = f.w;
|
|
533
|
+
t.v = f.v;
|
|
534
|
+
t.d = f.d;
|
|
535
|
+
return t;
|
|
536
|
+
}
|
|
537
|
+
function impl(seed, opts) {
|
|
538
|
+
var xg = new XorGen(seed), state = opts && opts.state, prng = function() {
|
|
539
|
+
return (xg.next() >>> 0) / 4294967296;
|
|
540
|
+
};
|
|
541
|
+
prng.double = function() {
|
|
542
|
+
do {
|
|
543
|
+
var top = xg.next() >>> 11, bot = (xg.next() >>> 0) / 4294967296, result = (top + bot) / (1 << 21);
|
|
544
|
+
} while (result === 0);
|
|
545
|
+
return result;
|
|
546
|
+
};
|
|
547
|
+
prng.int32 = xg.next;
|
|
548
|
+
prng.quick = prng;
|
|
549
|
+
if (state) {
|
|
550
|
+
if (typeof state == "object") copy(state, xg);
|
|
551
|
+
prng.state = function() {
|
|
552
|
+
return copy(xg, {});
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
return prng;
|
|
556
|
+
}
|
|
557
|
+
if (module2 && module2.exports) {
|
|
558
|
+
module2.exports = impl;
|
|
559
|
+
} else {
|
|
560
|
+
this.xorwow = impl;
|
|
561
|
+
}
|
|
562
|
+
})(
|
|
563
|
+
xorwow,
|
|
564
|
+
module
|
|
565
|
+
);
|
|
566
|
+
})(xorwow$1);
|
|
567
|
+
return xorwow$1.exports;
|
|
568
|
+
}
|
|
569
|
+
var xorshift7$1 = { exports: {} };
|
|
570
|
+
var xorshift7 = xorshift7$1.exports;
|
|
571
|
+
var hasRequiredXorshift7;
|
|
572
|
+
function requireXorshift7() {
|
|
573
|
+
if (hasRequiredXorshift7) return xorshift7$1.exports;
|
|
574
|
+
hasRequiredXorshift7 = 1;
|
|
575
|
+
(function(module) {
|
|
576
|
+
(function(global, module2, define) {
|
|
577
|
+
function XorGen(seed) {
|
|
578
|
+
var me = this;
|
|
579
|
+
me.next = function() {
|
|
580
|
+
var X = me.x, i = me.i, t, v;
|
|
581
|
+
t = X[i];
|
|
582
|
+
t ^= t >>> 7;
|
|
583
|
+
v = t ^ t << 24;
|
|
584
|
+
t = X[i + 1 & 7];
|
|
585
|
+
v ^= t ^ t >>> 10;
|
|
586
|
+
t = X[i + 3 & 7];
|
|
587
|
+
v ^= t ^ t >>> 3;
|
|
588
|
+
t = X[i + 4 & 7];
|
|
589
|
+
v ^= t ^ t << 7;
|
|
590
|
+
t = X[i + 7 & 7];
|
|
591
|
+
t = t ^ t << 13;
|
|
592
|
+
v ^= t ^ t << 9;
|
|
593
|
+
X[i] = v;
|
|
594
|
+
me.i = i + 1 & 7;
|
|
595
|
+
return v;
|
|
596
|
+
};
|
|
597
|
+
function init(me2, seed2) {
|
|
598
|
+
var j, X = [];
|
|
599
|
+
if (seed2 === (seed2 | 0)) {
|
|
600
|
+
X[0] = seed2;
|
|
601
|
+
} else {
|
|
602
|
+
seed2 = "" + seed2;
|
|
603
|
+
for (j = 0; j < seed2.length; ++j) {
|
|
604
|
+
X[j & 7] = X[j & 7] << 15 ^ seed2.charCodeAt(j) + X[j + 1 & 7] << 13;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
while (X.length < 8) X.push(0);
|
|
608
|
+
for (j = 0; j < 8 && X[j] === 0; ++j) ;
|
|
609
|
+
if (j == 8) X[7] = -1;
|
|
610
|
+
else X[j];
|
|
611
|
+
me2.x = X;
|
|
612
|
+
me2.i = 0;
|
|
613
|
+
for (j = 256; j > 0; --j) {
|
|
614
|
+
me2.next();
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
init(me, seed);
|
|
618
|
+
}
|
|
619
|
+
function copy(f, t) {
|
|
620
|
+
t.x = f.x.slice();
|
|
621
|
+
t.i = f.i;
|
|
622
|
+
return t;
|
|
623
|
+
}
|
|
624
|
+
function impl(seed, opts) {
|
|
625
|
+
if (seed == null) seed = +/* @__PURE__ */ new Date();
|
|
626
|
+
var xg = new XorGen(seed), state = opts && opts.state, prng = function() {
|
|
627
|
+
return (xg.next() >>> 0) / 4294967296;
|
|
628
|
+
};
|
|
629
|
+
prng.double = function() {
|
|
630
|
+
do {
|
|
631
|
+
var top = xg.next() >>> 11, bot = (xg.next() >>> 0) / 4294967296, result = (top + bot) / (1 << 21);
|
|
632
|
+
} while (result === 0);
|
|
633
|
+
return result;
|
|
634
|
+
};
|
|
635
|
+
prng.int32 = xg.next;
|
|
636
|
+
prng.quick = prng;
|
|
637
|
+
if (state) {
|
|
638
|
+
if (state.x) copy(state, xg);
|
|
639
|
+
prng.state = function() {
|
|
640
|
+
return copy(xg, {});
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
return prng;
|
|
644
|
+
}
|
|
645
|
+
if (module2 && module2.exports) {
|
|
646
|
+
module2.exports = impl;
|
|
647
|
+
} else {
|
|
648
|
+
this.xorshift7 = impl;
|
|
649
|
+
}
|
|
650
|
+
})(
|
|
651
|
+
xorshift7,
|
|
652
|
+
module
|
|
653
|
+
);
|
|
654
|
+
})(xorshift7$1);
|
|
655
|
+
return xorshift7$1.exports;
|
|
656
|
+
}
|
|
657
|
+
var xor4096$1 = { exports: {} };
|
|
658
|
+
var xor4096 = xor4096$1.exports;
|
|
659
|
+
var hasRequiredXor4096;
|
|
660
|
+
function requireXor4096() {
|
|
661
|
+
if (hasRequiredXor4096) return xor4096$1.exports;
|
|
662
|
+
hasRequiredXor4096 = 1;
|
|
663
|
+
(function(module) {
|
|
664
|
+
(function(global, module2, define) {
|
|
665
|
+
function XorGen(seed) {
|
|
666
|
+
var me = this;
|
|
667
|
+
me.next = function() {
|
|
668
|
+
var w = me.w, X = me.X, i = me.i, t, v;
|
|
669
|
+
me.w = w = w + 1640531527 | 0;
|
|
670
|
+
v = X[i + 34 & 127];
|
|
671
|
+
t = X[i = i + 1 & 127];
|
|
672
|
+
v ^= v << 13;
|
|
673
|
+
t ^= t << 17;
|
|
674
|
+
v ^= v >>> 15;
|
|
675
|
+
t ^= t >>> 12;
|
|
676
|
+
v = X[i] = v ^ t;
|
|
677
|
+
me.i = i;
|
|
678
|
+
return v + (w ^ w >>> 16) | 0;
|
|
679
|
+
};
|
|
680
|
+
function init(me2, seed2) {
|
|
681
|
+
var t, v, i, j, w, X = [], limit = 128;
|
|
682
|
+
if (seed2 === (seed2 | 0)) {
|
|
683
|
+
v = seed2;
|
|
684
|
+
seed2 = null;
|
|
685
|
+
} else {
|
|
686
|
+
seed2 = seed2 + "\0";
|
|
687
|
+
v = 0;
|
|
688
|
+
limit = Math.max(limit, seed2.length);
|
|
689
|
+
}
|
|
690
|
+
for (i = 0, j = -32; j < limit; ++j) {
|
|
691
|
+
if (seed2) v ^= seed2.charCodeAt((j + 32) % seed2.length);
|
|
692
|
+
if (j === 0) w = v;
|
|
693
|
+
v ^= v << 10;
|
|
694
|
+
v ^= v >>> 15;
|
|
695
|
+
v ^= v << 4;
|
|
696
|
+
v ^= v >>> 13;
|
|
697
|
+
if (j >= 0) {
|
|
698
|
+
w = w + 1640531527 | 0;
|
|
699
|
+
t = X[j & 127] ^= v + w;
|
|
700
|
+
i = 0 == t ? i + 1 : 0;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
if (i >= 128) {
|
|
704
|
+
X[(seed2 && seed2.length || 0) & 127] = -1;
|
|
705
|
+
}
|
|
706
|
+
i = 127;
|
|
707
|
+
for (j = 4 * 128; j > 0; --j) {
|
|
708
|
+
v = X[i + 34 & 127];
|
|
709
|
+
t = X[i = i + 1 & 127];
|
|
710
|
+
v ^= v << 13;
|
|
711
|
+
t ^= t << 17;
|
|
712
|
+
v ^= v >>> 15;
|
|
713
|
+
t ^= t >>> 12;
|
|
714
|
+
X[i] = v ^ t;
|
|
715
|
+
}
|
|
716
|
+
me2.w = w;
|
|
717
|
+
me2.X = X;
|
|
718
|
+
me2.i = i;
|
|
719
|
+
}
|
|
720
|
+
init(me, seed);
|
|
721
|
+
}
|
|
722
|
+
function copy(f, t) {
|
|
723
|
+
t.i = f.i;
|
|
724
|
+
t.w = f.w;
|
|
725
|
+
t.X = f.X.slice();
|
|
726
|
+
return t;
|
|
727
|
+
}
|
|
728
|
+
function impl(seed, opts) {
|
|
729
|
+
if (seed == null) seed = +/* @__PURE__ */ new Date();
|
|
730
|
+
var xg = new XorGen(seed), state = opts && opts.state, prng = function() {
|
|
731
|
+
return (xg.next() >>> 0) / 4294967296;
|
|
732
|
+
};
|
|
733
|
+
prng.double = function() {
|
|
734
|
+
do {
|
|
735
|
+
var top = xg.next() >>> 11, bot = (xg.next() >>> 0) / 4294967296, result = (top + bot) / (1 << 21);
|
|
736
|
+
} while (result === 0);
|
|
737
|
+
return result;
|
|
738
|
+
};
|
|
739
|
+
prng.int32 = xg.next;
|
|
740
|
+
prng.quick = prng;
|
|
741
|
+
if (state) {
|
|
742
|
+
if (state.X) copy(state, xg);
|
|
743
|
+
prng.state = function() {
|
|
744
|
+
return copy(xg, {});
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
return prng;
|
|
748
|
+
}
|
|
749
|
+
if (module2 && module2.exports) {
|
|
750
|
+
module2.exports = impl;
|
|
751
|
+
} else {
|
|
752
|
+
this.xor4096 = impl;
|
|
753
|
+
}
|
|
754
|
+
})(
|
|
755
|
+
xor4096,
|
|
756
|
+
// window object or global
|
|
757
|
+
module
|
|
758
|
+
);
|
|
759
|
+
})(xor4096$1);
|
|
760
|
+
return xor4096$1.exports;
|
|
761
|
+
}
|
|
762
|
+
var tychei$1 = { exports: {} };
|
|
763
|
+
var tychei = tychei$1.exports;
|
|
764
|
+
var hasRequiredTychei;
|
|
765
|
+
function requireTychei() {
|
|
766
|
+
if (hasRequiredTychei) return tychei$1.exports;
|
|
767
|
+
hasRequiredTychei = 1;
|
|
768
|
+
(function(module) {
|
|
769
|
+
(function(global, module2, define) {
|
|
770
|
+
function XorGen(seed) {
|
|
771
|
+
var me = this, strseed = "";
|
|
772
|
+
me.next = function() {
|
|
773
|
+
var b = me.b, c = me.c, d = me.d, a = me.a;
|
|
774
|
+
b = b << 25 ^ b >>> 7 ^ c;
|
|
775
|
+
c = c - d | 0;
|
|
776
|
+
d = d << 24 ^ d >>> 8 ^ a;
|
|
777
|
+
a = a - b | 0;
|
|
778
|
+
me.b = b = b << 20 ^ b >>> 12 ^ c;
|
|
779
|
+
me.c = c = c - d | 0;
|
|
780
|
+
me.d = d << 16 ^ c >>> 16 ^ a;
|
|
781
|
+
return me.a = a - b | 0;
|
|
782
|
+
};
|
|
783
|
+
me.a = 0;
|
|
784
|
+
me.b = 0;
|
|
785
|
+
me.c = 2654435769 | 0;
|
|
786
|
+
me.d = 1367130551;
|
|
787
|
+
if (seed === Math.floor(seed)) {
|
|
788
|
+
me.a = seed / 4294967296 | 0;
|
|
789
|
+
me.b = seed | 0;
|
|
790
|
+
} else {
|
|
791
|
+
strseed += seed;
|
|
792
|
+
}
|
|
793
|
+
for (var k = 0; k < strseed.length + 20; k++) {
|
|
794
|
+
me.b ^= strseed.charCodeAt(k) | 0;
|
|
795
|
+
me.next();
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
function copy(f, t) {
|
|
799
|
+
t.a = f.a;
|
|
800
|
+
t.b = f.b;
|
|
801
|
+
t.c = f.c;
|
|
802
|
+
t.d = f.d;
|
|
803
|
+
return t;
|
|
804
|
+
}
|
|
805
|
+
function impl(seed, opts) {
|
|
806
|
+
var xg = new XorGen(seed), state = opts && opts.state, prng = function() {
|
|
807
|
+
return (xg.next() >>> 0) / 4294967296;
|
|
808
|
+
};
|
|
809
|
+
prng.double = function() {
|
|
810
|
+
do {
|
|
811
|
+
var top = xg.next() >>> 11, bot = (xg.next() >>> 0) / 4294967296, result = (top + bot) / (1 << 21);
|
|
812
|
+
} while (result === 0);
|
|
813
|
+
return result;
|
|
814
|
+
};
|
|
815
|
+
prng.int32 = xg.next;
|
|
816
|
+
prng.quick = prng;
|
|
817
|
+
if (state) {
|
|
818
|
+
if (typeof state == "object") copy(state, xg);
|
|
819
|
+
prng.state = function() {
|
|
820
|
+
return copy(xg, {});
|
|
821
|
+
};
|
|
822
|
+
}
|
|
823
|
+
return prng;
|
|
824
|
+
}
|
|
825
|
+
if (module2 && module2.exports) {
|
|
826
|
+
module2.exports = impl;
|
|
827
|
+
} else {
|
|
828
|
+
this.tychei = impl;
|
|
829
|
+
}
|
|
830
|
+
})(
|
|
831
|
+
tychei,
|
|
832
|
+
module
|
|
833
|
+
);
|
|
834
|
+
})(tychei$1);
|
|
835
|
+
return tychei$1.exports;
|
|
836
|
+
}
|
|
837
|
+
var seedrandom$3 = { exports: {} };
|
|
838
|
+
const __viteBrowserExternal = {};
|
|
839
|
+
const __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
840
|
+
__proto__: null,
|
|
841
|
+
default: __viteBrowserExternal
|
|
842
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
843
|
+
const require$$0 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
|
|
844
|
+
var seedrandom$2 = seedrandom$3.exports;
|
|
845
|
+
var hasRequiredSeedrandom$1;
|
|
846
|
+
function requireSeedrandom$1() {
|
|
847
|
+
if (hasRequiredSeedrandom$1) return seedrandom$3.exports;
|
|
848
|
+
hasRequiredSeedrandom$1 = 1;
|
|
849
|
+
(function(module) {
|
|
850
|
+
(function(global, pool, math) {
|
|
851
|
+
var width = 256, chunks = 6, digits = 52, rngname = "random", startdenom = math.pow(width, chunks), significance = math.pow(2, digits), overflow = significance * 2, mask = width - 1, nodecrypto;
|
|
852
|
+
function seedrandom2(seed, options, callback) {
|
|
853
|
+
var key = [];
|
|
854
|
+
options = options == true ? { entropy: true } : options || {};
|
|
855
|
+
var shortseed = mixkey(flatten(
|
|
856
|
+
options.entropy ? [seed, tostring(pool)] : seed == null ? autoseed() : seed,
|
|
857
|
+
3
|
|
858
|
+
), key);
|
|
859
|
+
var arc4 = new ARC4(key);
|
|
860
|
+
var prng = function() {
|
|
861
|
+
var n = arc4.g(chunks), d = startdenom, x = 0;
|
|
862
|
+
while (n < significance) {
|
|
863
|
+
n = (n + x) * width;
|
|
864
|
+
d *= width;
|
|
865
|
+
x = arc4.g(1);
|
|
866
|
+
}
|
|
867
|
+
while (n >= overflow) {
|
|
868
|
+
n /= 2;
|
|
869
|
+
d /= 2;
|
|
870
|
+
x >>>= 1;
|
|
871
|
+
}
|
|
872
|
+
return (n + x) / d;
|
|
873
|
+
};
|
|
874
|
+
prng.int32 = function() {
|
|
875
|
+
return arc4.g(4) | 0;
|
|
876
|
+
};
|
|
877
|
+
prng.quick = function() {
|
|
878
|
+
return arc4.g(4) / 4294967296;
|
|
879
|
+
};
|
|
880
|
+
prng.double = prng;
|
|
881
|
+
mixkey(tostring(arc4.S), pool);
|
|
882
|
+
return (options.pass || callback || function(prng2, seed2, is_math_call, state) {
|
|
883
|
+
if (state) {
|
|
884
|
+
if (state.S) {
|
|
885
|
+
copy(state, arc4);
|
|
886
|
+
}
|
|
887
|
+
prng2.state = function() {
|
|
888
|
+
return copy(arc4, {});
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
if (is_math_call) {
|
|
892
|
+
math[rngname] = prng2;
|
|
893
|
+
return seed2;
|
|
894
|
+
} else return prng2;
|
|
895
|
+
})(
|
|
896
|
+
prng,
|
|
897
|
+
shortseed,
|
|
898
|
+
"global" in options ? options.global : this == math,
|
|
899
|
+
options.state
|
|
900
|
+
);
|
|
901
|
+
}
|
|
902
|
+
function ARC4(key) {
|
|
903
|
+
var t, keylen = key.length, me = this, i = 0, j = me.i = me.j = 0, s = me.S = [];
|
|
904
|
+
if (!keylen) {
|
|
905
|
+
key = [keylen++];
|
|
906
|
+
}
|
|
907
|
+
while (i < width) {
|
|
908
|
+
s[i] = i++;
|
|
909
|
+
}
|
|
910
|
+
for (i = 0; i < width; i++) {
|
|
911
|
+
s[i] = s[j = mask & j + key[i % keylen] + (t = s[i])];
|
|
912
|
+
s[j] = t;
|
|
913
|
+
}
|
|
914
|
+
(me.g = function(count) {
|
|
915
|
+
var t2, r = 0, i2 = me.i, j2 = me.j, s2 = me.S;
|
|
916
|
+
while (count--) {
|
|
917
|
+
t2 = s2[i2 = mask & i2 + 1];
|
|
918
|
+
r = r * width + s2[mask & (s2[i2] = s2[j2 = mask & j2 + t2]) + (s2[j2] = t2)];
|
|
919
|
+
}
|
|
920
|
+
me.i = i2;
|
|
921
|
+
me.j = j2;
|
|
922
|
+
return r;
|
|
923
|
+
})(width);
|
|
924
|
+
}
|
|
925
|
+
function copy(f, t) {
|
|
926
|
+
t.i = f.i;
|
|
927
|
+
t.j = f.j;
|
|
928
|
+
t.S = f.S.slice();
|
|
929
|
+
return t;
|
|
930
|
+
}
|
|
931
|
+
function flatten(obj, depth) {
|
|
932
|
+
var result = [], typ = typeof obj, prop;
|
|
933
|
+
if (depth && typ == "object") {
|
|
934
|
+
for (prop in obj) {
|
|
935
|
+
try {
|
|
936
|
+
result.push(flatten(obj[prop], depth - 1));
|
|
937
|
+
} catch (e) {
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
return result.length ? result : typ == "string" ? obj : obj + "\0";
|
|
942
|
+
}
|
|
943
|
+
function mixkey(seed, key) {
|
|
944
|
+
var stringseed = seed + "", smear, j = 0;
|
|
945
|
+
while (j < stringseed.length) {
|
|
946
|
+
key[mask & j] = mask & (smear ^= key[mask & j] * 19) + stringseed.charCodeAt(j++);
|
|
947
|
+
}
|
|
948
|
+
return tostring(key);
|
|
949
|
+
}
|
|
950
|
+
function autoseed() {
|
|
951
|
+
try {
|
|
952
|
+
var out;
|
|
953
|
+
if (nodecrypto && (out = nodecrypto.randomBytes)) {
|
|
954
|
+
out = out(width);
|
|
955
|
+
} else {
|
|
956
|
+
out = new Uint8Array(width);
|
|
957
|
+
(global.crypto || global.msCrypto).getRandomValues(out);
|
|
958
|
+
}
|
|
959
|
+
return tostring(out);
|
|
960
|
+
} catch (e) {
|
|
961
|
+
var browser = global.navigator, plugins = browser && browser.plugins;
|
|
962
|
+
return [+/* @__PURE__ */ new Date(), global, plugins, global.screen, tostring(pool)];
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
function tostring(a) {
|
|
966
|
+
return String.fromCharCode.apply(0, a);
|
|
967
|
+
}
|
|
968
|
+
mixkey(math.random(), pool);
|
|
969
|
+
if (module.exports) {
|
|
970
|
+
module.exports = seedrandom2;
|
|
971
|
+
try {
|
|
972
|
+
nodecrypto = require$$0;
|
|
973
|
+
} catch (ex) {
|
|
974
|
+
}
|
|
975
|
+
} else {
|
|
976
|
+
math["seed" + rngname] = seedrandom2;
|
|
977
|
+
}
|
|
978
|
+
})(
|
|
979
|
+
// global: `self` in browsers (including strict mode and web workers),
|
|
980
|
+
// otherwise `this` in Node and other environments
|
|
981
|
+
typeof self !== "undefined" ? self : seedrandom$2,
|
|
982
|
+
[],
|
|
983
|
+
// pool: entropy pool starts empty
|
|
984
|
+
Math
|
|
985
|
+
// math: package containing random, pow, and seedrandom
|
|
986
|
+
);
|
|
987
|
+
})(seedrandom$3);
|
|
988
|
+
return seedrandom$3.exports;
|
|
989
|
+
}
|
|
990
|
+
var seedrandom$1;
|
|
991
|
+
var hasRequiredSeedrandom;
|
|
992
|
+
function requireSeedrandom() {
|
|
993
|
+
if (hasRequiredSeedrandom) return seedrandom$1;
|
|
994
|
+
hasRequiredSeedrandom = 1;
|
|
995
|
+
var alea2 = requireAlea();
|
|
996
|
+
var xor1282 = requireXor128();
|
|
997
|
+
var xorwow2 = requireXorwow();
|
|
998
|
+
var xorshift72 = requireXorshift7();
|
|
999
|
+
var xor40962 = requireXor4096();
|
|
1000
|
+
var tychei2 = requireTychei();
|
|
1001
|
+
var sr = requireSeedrandom$1();
|
|
1002
|
+
sr.alea = alea2;
|
|
1003
|
+
sr.xor128 = xor1282;
|
|
1004
|
+
sr.xorwow = xorwow2;
|
|
1005
|
+
sr.xorshift7 = xorshift72;
|
|
1006
|
+
sr.xor4096 = xor40962;
|
|
1007
|
+
sr.tychei = tychei2;
|
|
1008
|
+
seedrandom$1 = sr;
|
|
1009
|
+
return seedrandom$1;
|
|
1010
|
+
}
|
|
1011
|
+
var seedrandomExports = requireSeedrandom();
|
|
1012
|
+
const seedrandom = /* @__PURE__ */ getDefaultExportFromCjs(seedrandomExports);
|
|
1013
|
+
const rngClass$3 = seedrandom.alea;
|
|
1014
|
+
function isSingleDocSource(obj) {
|
|
1015
|
+
const typedObj = obj;
|
|
1016
|
+
return (
|
|
1017
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1018
|
+
typedObj !== null && typeof typedObj === "object" && // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1019
|
+
typedObj.type === "singleDoc" && typeof typedObj.id === "string" && typeof typedObj.isDescription === "boolean" && typeof typedObj.doenetML === "string" && typeof typedObj.version === "string"
|
|
1020
|
+
);
|
|
1021
|
+
}
|
|
1022
|
+
function isSingleDocStateNoSource(obj) {
|
|
1023
|
+
const typedObj = obj;
|
|
1024
|
+
return (
|
|
1025
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1026
|
+
typedObj !== null && typeof typedObj === "object" && // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1027
|
+
typedObj.type === "singleDoc" && typeof typedObj.id === "string" && (typedObj.parentId === null || typeof typedObj.parentId === "string") && typeof typedObj.initialVariant === "number" && typeof typedObj.creditAchieved === "number" && typeof typedObj.attemptNumber === "number" && typeof typedObj.currentVariant === "number" && Array.isArray(typedObj.previousVariants) && typedObj.previousVariants.every((x) => typeof x === "number") && typeof typedObj.initialQuestionCounter === "number" && (typedObj.restrictToVariantSlice === void 0 || isRestrictToVariantSlice(typedObj.restrictToVariantSlice))
|
|
1028
|
+
);
|
|
1029
|
+
}
|
|
1030
|
+
function initializeSingleDocState({
|
|
1031
|
+
source,
|
|
1032
|
+
variant,
|
|
1033
|
+
parentId,
|
|
1034
|
+
restrictToVariantSlice
|
|
1035
|
+
}) {
|
|
1036
|
+
const extendedId = source.id + (restrictToVariantSlice === void 0 ? "" : "|" + restrictToVariantSlice.idx.toString());
|
|
1037
|
+
return {
|
|
1038
|
+
type: "singleDoc",
|
|
1039
|
+
id: extendedId,
|
|
1040
|
+
parentId,
|
|
1041
|
+
source,
|
|
1042
|
+
initialVariant: variant,
|
|
1043
|
+
creditAchieved: 0,
|
|
1044
|
+
attemptNumber: 0,
|
|
1045
|
+
currentVariant: 0,
|
|
1046
|
+
previousVariants: [],
|
|
1047
|
+
initialQuestionCounter: 0,
|
|
1048
|
+
doenetStateIdx: null,
|
|
1049
|
+
restrictToVariantSlice
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
1052
|
+
function generateNewSingleDocAttempt({
|
|
1053
|
+
state,
|
|
1054
|
+
numActivityVariants,
|
|
1055
|
+
initialQuestionCounter,
|
|
1056
|
+
parentAttempt
|
|
1057
|
+
}) {
|
|
1058
|
+
const previousVariants = state.previousVariants;
|
|
1059
|
+
const numVariants = calcNumVariantsFromState(state, numActivityVariants);
|
|
1060
|
+
const numPrevVariants = previousVariants.length;
|
|
1061
|
+
const numVariantsToExclude = numPrevVariants % numVariants;
|
|
1062
|
+
const numVariantOptions = numVariants - numVariantsToExclude;
|
|
1063
|
+
const variantsToExclude = previousVariants.slice(numPrevVariants - numVariantsToExclude, numPrevVariants).sort((a, b) => a - b);
|
|
1064
|
+
const rngSeed = state.initialVariant.toString() + "|" + state.id.toString() + "|" + state.attemptNumber.toString() + "|" + parentAttempt.toString();
|
|
1065
|
+
const rng = rngClass$3(rngSeed);
|
|
1066
|
+
let selectedVariant = Math.floor(rng() * numVariantOptions) + 1;
|
|
1067
|
+
for (const excludedVariant of variantsToExclude) {
|
|
1068
|
+
if (selectedVariant >= excludedVariant) {
|
|
1069
|
+
selectedVariant++;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
if (state.restrictToVariantSlice) {
|
|
1073
|
+
selectedVariant = (selectedVariant - 1) * state.restrictToVariantSlice.numSlices + state.restrictToVariantSlice.idx;
|
|
1074
|
+
}
|
|
1075
|
+
const finalQuestionCounter = initialQuestionCounter + (state.source.isDescription ? 0 : 1);
|
|
1076
|
+
const newState = {
|
|
1077
|
+
...state,
|
|
1078
|
+
creditAchieved: 0,
|
|
1079
|
+
attemptNumber: state.attemptNumber + 1,
|
|
1080
|
+
currentVariant: selectedVariant,
|
|
1081
|
+
previousVariants: [...state.previousVariants, selectedVariant],
|
|
1082
|
+
doenetStateIdx: null,
|
|
1083
|
+
initialQuestionCounter
|
|
1084
|
+
};
|
|
1085
|
+
return { finalQuestionCounter, state: newState };
|
|
1086
|
+
}
|
|
1087
|
+
function extractSingleDocItemCredit(activityState, nPrevInShuffleOrder = 0) {
|
|
1088
|
+
if (activityState.source.isDescription) {
|
|
1089
|
+
return [];
|
|
1090
|
+
} else {
|
|
1091
|
+
return [
|
|
1092
|
+
{
|
|
1093
|
+
id: activityState.id,
|
|
1094
|
+
score: activityState.creditAchieved,
|
|
1095
|
+
docId: activityState.id,
|
|
1096
|
+
shuffledOrder: nPrevInShuffleOrder + 1,
|
|
1097
|
+
variant: activityState.currentVariant
|
|
1098
|
+
}
|
|
1099
|
+
];
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
function pruneSingleDocStateForSave(activityState) {
|
|
1103
|
+
const { source: _source, ...newState } = { ...activityState };
|
|
1104
|
+
return newState;
|
|
1105
|
+
}
|
|
1106
|
+
function addSourceToSingleDocState(activityState, source) {
|
|
1107
|
+
return { ...activityState, source };
|
|
1108
|
+
}
|
|
1109
|
+
const rngClass$2 = seedrandom.alea;
|
|
1110
|
+
function isSelectSource(obj) {
|
|
1111
|
+
const typedObj = obj;
|
|
1112
|
+
return (
|
|
1113
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1114
|
+
typedObj !== null && typeof typedObj === "object" && // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1115
|
+
typedObj.type === "select" && typeof typedObj.id === "string" && typeof typedObj.numToSelect === "number" && typeof typedObj.selectByVariant === "boolean" && Array.isArray(typedObj.items) && typedObj.items.every(isActivitySource)
|
|
1116
|
+
);
|
|
1117
|
+
}
|
|
1118
|
+
function isSelectStateNoSource(obj) {
|
|
1119
|
+
const typedObj = obj;
|
|
1120
|
+
return (
|
|
1121
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1122
|
+
typedObj !== null && typeof typedObj === "object" && // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1123
|
+
typedObj.type === "select" && typeof typedObj.id === "string" && (typedObj.parentId === null || typeof typedObj.parentId === "string") && typeof typedObj.initialVariant === "number" && typeof typedObj.creditAchieved === "number" && Array.isArray(typedObj.allChildren) && typedObj.allChildren.every(isActivityStateNoSource) && typeof typedObj.attemptNumber === "number" && Array.isArray(typedObj.selectedChildren) && typedObj.selectedChildren.every(isActivityStateNoSource) && Array.isArray(typedObj.previousSelections) && typedObj.previousSelections.every((x) => typeof x === "string") && typeof typedObj.initialQuestionCounter === "number" && (typedObj.restrictToVariantSlice === void 0 || isRestrictToVariantSlice(typedObj.restrictToVariantSlice))
|
|
1124
|
+
);
|
|
1125
|
+
}
|
|
1126
|
+
function initializeSelectState({
|
|
1127
|
+
source,
|
|
1128
|
+
variant,
|
|
1129
|
+
parentId,
|
|
1130
|
+
numActivityVariants,
|
|
1131
|
+
restrictToVariantSlice
|
|
1132
|
+
}) {
|
|
1133
|
+
const rngSeed = variant.toString() + "|" + source.id.toString();
|
|
1134
|
+
const rng = rngClass$2(rngSeed);
|
|
1135
|
+
const childStates = [];
|
|
1136
|
+
const extendedId = source.id + (restrictToVariantSlice === void 0 ? "" : "|" + restrictToVariantSlice.idx.toString());
|
|
1137
|
+
if (restrictToVariantSlice !== void 0) {
|
|
1138
|
+
throw Error(
|
|
1139
|
+
"A select inside a select-multiple has not yet been implemented."
|
|
1140
|
+
);
|
|
1141
|
+
}
|
|
1142
|
+
if (source.numToSelect === 1 || !source.selectByVariant) {
|
|
1143
|
+
for (const activitySource of source.items) {
|
|
1144
|
+
const childVariant = Math.floor(rng() * 1e6);
|
|
1145
|
+
childStates.push(
|
|
1146
|
+
initializeActivityState({
|
|
1147
|
+
source: activitySource,
|
|
1148
|
+
variant: childVariant,
|
|
1149
|
+
parentId: extendedId,
|
|
1150
|
+
numActivityVariants
|
|
1151
|
+
})
|
|
1152
|
+
);
|
|
1153
|
+
}
|
|
1154
|
+
} else {
|
|
1155
|
+
for (const activitySource of source.items) {
|
|
1156
|
+
const childVariant = Math.floor(rng() * 1e6) + 1;
|
|
1157
|
+
const numVariants = calcNumVariants(
|
|
1158
|
+
activitySource,
|
|
1159
|
+
numActivityVariants
|
|
1160
|
+
);
|
|
1161
|
+
for (let idx = 1; idx <= numVariants; idx++) {
|
|
1162
|
+
childStates.push(
|
|
1163
|
+
initializeActivityState({
|
|
1164
|
+
source: activitySource,
|
|
1165
|
+
variant: childVariant,
|
|
1166
|
+
parentId: extendedId,
|
|
1167
|
+
numActivityVariants,
|
|
1168
|
+
// If `numVariants` is actually the number of variants,
|
|
1169
|
+
// this restrictions creates a slice of just one variant.
|
|
1170
|
+
// Otherwise, the slice may still contain multiple variants,
|
|
1171
|
+
// but they at least will not overlap with other slices.
|
|
1172
|
+
restrictToVariantSlice: { idx, numSlices: numVariants }
|
|
1173
|
+
})
|
|
1174
|
+
);
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
return {
|
|
1179
|
+
type: "select",
|
|
1180
|
+
id: extendedId,
|
|
1181
|
+
parentId,
|
|
1182
|
+
source,
|
|
1183
|
+
initialVariant: variant,
|
|
1184
|
+
creditAchieved: 0,
|
|
1185
|
+
allChildren: childStates,
|
|
1186
|
+
attemptNumber: 0,
|
|
1187
|
+
selectedChildren: [],
|
|
1188
|
+
previousSelections: [],
|
|
1189
|
+
initialQuestionCounter: 0,
|
|
1190
|
+
restrictToVariantSlice
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
function generateNewSelectAttempt({
|
|
1194
|
+
state,
|
|
1195
|
+
numActivityVariants,
|
|
1196
|
+
initialQuestionCounter,
|
|
1197
|
+
parentAttempt
|
|
1198
|
+
}) {
|
|
1199
|
+
const source = state.source;
|
|
1200
|
+
const numToSelect = source.numToSelect;
|
|
1201
|
+
const numChildren = state.allChildren.length;
|
|
1202
|
+
if (numChildren === 0) {
|
|
1203
|
+
return { finalQuestionCounter: initialQuestionCounter, state };
|
|
1204
|
+
}
|
|
1205
|
+
const numVariantsPerChild = state.allChildren.map(
|
|
1206
|
+
(a) => calcNumVariantsFromState(a, numActivityVariants)
|
|
1207
|
+
);
|
|
1208
|
+
const totalNumOptions = source.selectByVariant ? numVariantsPerChild.reduce((a, c) => a + c) : numChildren;
|
|
1209
|
+
if (numToSelect > totalNumOptions) {
|
|
1210
|
+
if (source.selectByVariant) {
|
|
1211
|
+
throw Error(
|
|
1212
|
+
`For a select activity, "number to select" is ${numToSelect.toString()}, which is larger than the number of available variants (${totalNumOptions.toString()}).`
|
|
1213
|
+
);
|
|
1214
|
+
} else {
|
|
1215
|
+
const totalNumChildVariants = numVariantsPerChild.reduce(
|
|
1216
|
+
(a, c) => a + c
|
|
1217
|
+
);
|
|
1218
|
+
if (numToSelect > totalNumChildVariants) {
|
|
1219
|
+
throw Error(
|
|
1220
|
+
`For a select activity, "number to select" is ${numToSelect.toString()}, which is larger than the number of available activities (${totalNumOptions.toString()}).`
|
|
1221
|
+
);
|
|
1222
|
+
} else {
|
|
1223
|
+
throw Error(
|
|
1224
|
+
`For a select activity, "number to select" is ${numToSelect.toString()}, which is larger than the number of available activities (${totalNumOptions.toString()}). (Turning on "select by variant" will add enough options for the select activity to function.)`
|
|
1225
|
+
);
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
const childIdToIdx = {};
|
|
1230
|
+
for (const [idx, child] of state.allChildren.entries()) {
|
|
1231
|
+
childIdToIdx[child.id] = idx;
|
|
1232
|
+
}
|
|
1233
|
+
const numPrevSelected = numToSelect * state.attemptNumber;
|
|
1234
|
+
const numInGroup = numPrevSelected % totalNumOptions;
|
|
1235
|
+
const numLeftInGroup = totalNumOptions - numInGroup;
|
|
1236
|
+
const childCountsInGroup = Array(numChildren).fill(0);
|
|
1237
|
+
for (const childId of [...state.previousSelections].reverse().slice(0, numInGroup)) {
|
|
1238
|
+
childCountsInGroup[childIdToIdx[childId]]++;
|
|
1239
|
+
}
|
|
1240
|
+
const childOptionsLeft = childCountsInGroup.flatMap((cnt, idx) => {
|
|
1241
|
+
if (source.selectByVariant) {
|
|
1242
|
+
return Array(numVariantsPerChild[idx] - cnt).fill(idx);
|
|
1243
|
+
} else {
|
|
1244
|
+
if (cnt) {
|
|
1245
|
+
return [];
|
|
1246
|
+
} else {
|
|
1247
|
+
return [idx];
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
});
|
|
1251
|
+
if (childOptionsLeft.length !== numLeftInGroup) {
|
|
1252
|
+
throw Error("we did something wrong");
|
|
1253
|
+
}
|
|
1254
|
+
const rngSeed = state.initialVariant.toString() + "|" + state.id.toString() + "|" + state.attemptNumber.toString() + "|" + parentAttempt.toString();
|
|
1255
|
+
const rng = rngClass$2(rngSeed);
|
|
1256
|
+
const childrenChosen = [];
|
|
1257
|
+
for (let i = 0; i < Math.min(numToSelect, numLeftInGroup); i++) {
|
|
1258
|
+
const idx = Math.floor(rng() * childOptionsLeft.length);
|
|
1259
|
+
const newChildInd = childOptionsLeft.splice(idx, 1)[0];
|
|
1260
|
+
childrenChosen.push(newChildInd);
|
|
1261
|
+
}
|
|
1262
|
+
if (numToSelect > numLeftInGroup) {
|
|
1263
|
+
const nextChildOptions = childCountsInGroup.flatMap((cnt, idx) => {
|
|
1264
|
+
if (source.selectByVariant) {
|
|
1265
|
+
return Array(cnt).fill(idx);
|
|
1266
|
+
} else {
|
|
1267
|
+
if (cnt) {
|
|
1268
|
+
return [idx];
|
|
1269
|
+
} else {
|
|
1270
|
+
return [];
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
});
|
|
1274
|
+
for (let i = 0; i < numToSelect - numLeftInGroup; i++) {
|
|
1275
|
+
const idx = Math.floor(rng() * nextChildOptions.length);
|
|
1276
|
+
const newChildInd = nextChildOptions.splice(idx, 1)[0];
|
|
1277
|
+
childrenChosen.push(newChildInd);
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
const newActivityStates = [];
|
|
1281
|
+
const newActivityOptionStates = [...state.allChildren];
|
|
1282
|
+
let questionCounter = initialQuestionCounter;
|
|
1283
|
+
for (const childIdx of childrenChosen) {
|
|
1284
|
+
const { finalQuestionCounter: endCounter, state: newState2 } = generateNewActivityAttempt({
|
|
1285
|
+
state: newActivityOptionStates[childIdx],
|
|
1286
|
+
numActivityVariants,
|
|
1287
|
+
initialQuestionCounter: questionCounter,
|
|
1288
|
+
parentAttempt: state.attemptNumber + 1
|
|
1289
|
+
});
|
|
1290
|
+
questionCounter = endCounter;
|
|
1291
|
+
newActivityOptionStates[childIdx] = newState2;
|
|
1292
|
+
newActivityStates.push(newState2);
|
|
1293
|
+
}
|
|
1294
|
+
const newState = {
|
|
1295
|
+
...state,
|
|
1296
|
+
creditAchieved: 0,
|
|
1297
|
+
allChildren: newActivityOptionStates,
|
|
1298
|
+
attemptNumber: state.attemptNumber + 1,
|
|
1299
|
+
selectedChildren: newActivityStates,
|
|
1300
|
+
previousSelections: [
|
|
1301
|
+
...state.previousSelections,
|
|
1302
|
+
...newActivityStates.map((s) => s.id)
|
|
1303
|
+
],
|
|
1304
|
+
initialQuestionCounter
|
|
1305
|
+
};
|
|
1306
|
+
return { finalQuestionCounter: questionCounter, state: newState };
|
|
1307
|
+
}
|
|
1308
|
+
function generateNewSingleDocAttemptForMultiSelect({
|
|
1309
|
+
state,
|
|
1310
|
+
numActivityVariants,
|
|
1311
|
+
initialQuestionCounter,
|
|
1312
|
+
parentAttempt,
|
|
1313
|
+
childId
|
|
1314
|
+
}) {
|
|
1315
|
+
const source = state.source;
|
|
1316
|
+
const numToSelect = source.numToSelect;
|
|
1317
|
+
if (numToSelect === 1 || state.attemptNumber === 0) {
|
|
1318
|
+
throw Error(
|
|
1319
|
+
"no reason to call when selecting just one item or for first attempt"
|
|
1320
|
+
);
|
|
1321
|
+
}
|
|
1322
|
+
const numChildren = state.allChildren.length;
|
|
1323
|
+
const childIdToIdx = {};
|
|
1324
|
+
for (const [idx, child] of state.allChildren.entries()) {
|
|
1325
|
+
childIdToIdx[child.id] = idx;
|
|
1326
|
+
}
|
|
1327
|
+
const otherSelectedIds = state.selectedChildren.filter((a) => a.id !== childId).map((a) => a.id);
|
|
1328
|
+
if (otherSelectedIds.length !== numToSelect - 1) {
|
|
1329
|
+
throw Error("We made a miscalculation");
|
|
1330
|
+
}
|
|
1331
|
+
const idOptions = state.allChildren.map((s) => s.id).filter((id) => !otherSelectedIds.includes(id));
|
|
1332
|
+
const numOptions = idOptions.length;
|
|
1333
|
+
const prevSelectionOfOptions = state.previousSelections.filter(
|
|
1334
|
+
(id) => !otherSelectedIds.includes(id)
|
|
1335
|
+
);
|
|
1336
|
+
const numPrevSelections = prevSelectionOfOptions.length;
|
|
1337
|
+
const numInGroup = numPrevSelections % numOptions;
|
|
1338
|
+
const additionalExcludes = prevSelectionOfOptions.slice(
|
|
1339
|
+
numPrevSelections - numInGroup,
|
|
1340
|
+
numPrevSelections
|
|
1341
|
+
);
|
|
1342
|
+
const idxOfAllExcluded = [...otherSelectedIds, ...additionalExcludes].map((id) => childIdToIdx[id]).sort((a, b) => a - b);
|
|
1343
|
+
const slotNum = state.selectedChildren.map((a) => a.id).indexOf(childId);
|
|
1344
|
+
const rngSeed = state.initialVariant.toString() + "|" + state.id.toString() + "|" + state.attemptNumber.toString() + "|" + parentAttempt.toString();
|
|
1345
|
+
const rng = rngClass$2(rngSeed);
|
|
1346
|
+
let selectedIdx = Math.floor(
|
|
1347
|
+
rng() * (numChildren - idxOfAllExcluded.length)
|
|
1348
|
+
);
|
|
1349
|
+
for (const excludedIdx of idxOfAllExcluded) {
|
|
1350
|
+
if (selectedIdx >= excludedIdx) {
|
|
1351
|
+
selectedIdx++;
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
const newActivityStates = [...state.selectedChildren];
|
|
1355
|
+
const newActivityOptionStates = [...state.allChildren];
|
|
1356
|
+
const { finalQuestionCounter, state: newChildState } = generateNewActivityAttempt({
|
|
1357
|
+
state: newActivityOptionStates[selectedIdx],
|
|
1358
|
+
numActivityVariants,
|
|
1359
|
+
initialQuestionCounter,
|
|
1360
|
+
parentAttempt: state.attemptNumber + 1
|
|
1361
|
+
});
|
|
1362
|
+
newActivityOptionStates[selectedIdx] = newChildState;
|
|
1363
|
+
newActivityStates[slotNum] = newChildState;
|
|
1364
|
+
const latestOtherCreditAchieved = state.selectedChildren.filter((_, i) => i != slotNum).map((a) => a.creditAchieved);
|
|
1365
|
+
const creditAchieved = latestOtherCreditAchieved.reduce((a, c) => a + c, 0) / state.selectedChildren.length;
|
|
1366
|
+
const newState = {
|
|
1367
|
+
...state,
|
|
1368
|
+
allChildren: newActivityOptionStates,
|
|
1369
|
+
selectedChildren: newActivityStates,
|
|
1370
|
+
creditAchieved,
|
|
1371
|
+
previousSelections: [...state.previousSelections, newChildState.id],
|
|
1372
|
+
initialQuestionCounter
|
|
1373
|
+
};
|
|
1374
|
+
return { finalQuestionCounter, state: newState };
|
|
1375
|
+
}
|
|
1376
|
+
function extractSelectItemCredit(activityState, nPrevInShuffleOrder = 0) {
|
|
1377
|
+
if (activityState.attemptNumber === 0) {
|
|
1378
|
+
const nChildren = activityState.allChildren.length;
|
|
1379
|
+
if (nChildren === 0) {
|
|
1380
|
+
return [];
|
|
1381
|
+
}
|
|
1382
|
+
const results = [];
|
|
1383
|
+
let nPrev = nPrevInShuffleOrder;
|
|
1384
|
+
for (let i = 0; i < activityState.source.numToSelect; i++) {
|
|
1385
|
+
const childState = activityState.allChildren[i % nChildren];
|
|
1386
|
+
const next = extractActivityItemCredit(childState, nPrev);
|
|
1387
|
+
nPrev += next.length;
|
|
1388
|
+
results.push(...next);
|
|
1389
|
+
}
|
|
1390
|
+
return results;
|
|
1391
|
+
}
|
|
1392
|
+
if (activityState.source.numToSelect === 1 && activityState.allChildren.every((child) => child.type === "singleDoc")) {
|
|
1393
|
+
return [
|
|
1394
|
+
{
|
|
1395
|
+
id: activityState.id,
|
|
1396
|
+
score: activityState.creditAchieved,
|
|
1397
|
+
docId: activityState.selectedChildren[0].id,
|
|
1398
|
+
shuffledOrder: nPrevInShuffleOrder + 1,
|
|
1399
|
+
variant: activityState.selectedChildren[0].currentVariant
|
|
1400
|
+
}
|
|
1401
|
+
];
|
|
1402
|
+
} else {
|
|
1403
|
+
let nPrev = nPrevInShuffleOrder;
|
|
1404
|
+
return activityState.selectedChildren.flatMap((state) => {
|
|
1405
|
+
const next = extractActivityItemCredit(state, nPrev);
|
|
1406
|
+
nPrev += next.length;
|
|
1407
|
+
return next;
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
function pruneSelectStateForSave(activityState) {
|
|
1412
|
+
const { source: _source, ...newState } = { ...activityState };
|
|
1413
|
+
const allChildren = newState.allChildren.map(
|
|
1414
|
+
(child) => pruneActivityStateForSave(child)
|
|
1415
|
+
);
|
|
1416
|
+
const selectedChildren = newState.selectedChildren.map(
|
|
1417
|
+
(child) => pruneActivityStateForSave(child)
|
|
1418
|
+
);
|
|
1419
|
+
return { ...newState, allChildren, selectedChildren };
|
|
1420
|
+
}
|
|
1421
|
+
function addSourceToSelectState(activityState, source) {
|
|
1422
|
+
const allChildren = activityState.allChildren.map((child) => {
|
|
1423
|
+
const idx = source.items.findIndex(
|
|
1424
|
+
(src) => src.id === extractSourceId(child.id)
|
|
1425
|
+
);
|
|
1426
|
+
return addSourceToActivityState(child, source.items[idx]);
|
|
1427
|
+
});
|
|
1428
|
+
const selectedChildren = activityState.selectedChildren.map((child) => {
|
|
1429
|
+
const idx = source.items.findIndex(
|
|
1430
|
+
(src) => src.id === extractSourceId(child.id)
|
|
1431
|
+
);
|
|
1432
|
+
return addSourceToActivityState(child, source.items[idx]);
|
|
1433
|
+
});
|
|
1434
|
+
return {
|
|
1435
|
+
...activityState,
|
|
1436
|
+
source,
|
|
1437
|
+
allChildren,
|
|
1438
|
+
selectedChildren
|
|
1439
|
+
};
|
|
1440
|
+
}
|
|
1441
|
+
function calcNumVariantsSelect(source, numActivityVariants) {
|
|
1442
|
+
const numVariantsTot = source.items.reduce(
|
|
1443
|
+
(a, c) => a + calcNumVariants(c, numActivityVariants),
|
|
1444
|
+
0
|
|
1445
|
+
);
|
|
1446
|
+
return Math.floor(numVariantsTot / source.numToSelect);
|
|
1447
|
+
}
|
|
1448
|
+
function getNumItemsInSelect(source) {
|
|
1449
|
+
if (source.items.length === 0) {
|
|
1450
|
+
return 0;
|
|
1451
|
+
}
|
|
1452
|
+
const numDocumentsPerItem = getNumItems(source.items[0]);
|
|
1453
|
+
if (source.items.length > 1) {
|
|
1454
|
+
for (const item of source.items.slice(1)) {
|
|
1455
|
+
if (getNumItems(item) !== numDocumentsPerItem) {
|
|
1456
|
+
throw Error(
|
|
1457
|
+
"The case where a select has options with different numbers of documents is not implemented"
|
|
1458
|
+
);
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
return source.numToSelect * numDocumentsPerItem;
|
|
1463
|
+
}
|
|
1464
|
+
const rngClass$1 = seedrandom.alea;
|
|
1465
|
+
function isSequenceSource(obj) {
|
|
1466
|
+
const typedObj = obj;
|
|
1467
|
+
return (
|
|
1468
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1469
|
+
typedObj !== null && typeof typedObj === "object" && // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1470
|
+
typedObj.type === "sequence" && typeof typedObj.id === "string" && Array.isArray(typedObj.items) && typedObj.items.every(isActivitySource) && typeof typedObj.shuffle === "boolean" && (typedObj.creditWeights === void 0 || Array.isArray(typedObj.creditWeights) && typedObj.creditWeights.every(
|
|
1471
|
+
(weight) => typeof weight === "number"
|
|
1472
|
+
))
|
|
1473
|
+
);
|
|
1474
|
+
}
|
|
1475
|
+
function isSequenceStateNoSource(obj) {
|
|
1476
|
+
const typedObj = obj;
|
|
1477
|
+
return (
|
|
1478
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1479
|
+
typedObj !== null && typeof typedObj === "object" && // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1480
|
+
typedObj.type === "sequence" && typeof typedObj.id === "string" && (typedObj.parentId === null || typeof typedObj.parentId === "string") && typeof typedObj.initialVariant === "number" && typeof typedObj.creditAchieved === "number" && Array.isArray(typedObj.allChildren) && typedObj.allChildren.every(isActivityStateNoSource) && typeof typedObj.attemptNumber === "number" && Array.isArray(typedObj.orderedChildren) && typedObj.orderedChildren.every(isActivityStateNoSource) && (typedObj.restrictToVariantSlice === void 0 || isRestrictToVariantSlice(typedObj.restrictToVariantSlice))
|
|
1481
|
+
);
|
|
1482
|
+
}
|
|
1483
|
+
function initializeSequenceState({
|
|
1484
|
+
source,
|
|
1485
|
+
variant,
|
|
1486
|
+
parentId,
|
|
1487
|
+
numActivityVariants,
|
|
1488
|
+
restrictToVariantSlice
|
|
1489
|
+
}) {
|
|
1490
|
+
const rngSeed = variant.toString() + "|" + source.id.toString();
|
|
1491
|
+
const rng = rngClass$1(rngSeed);
|
|
1492
|
+
const extendedId = source.id + (restrictToVariantSlice === void 0 ? "" : "|" + restrictToVariantSlice.idx.toString());
|
|
1493
|
+
const childStates = source.items.map((activitySource) => {
|
|
1494
|
+
const childVariant = Math.floor(rng() * 1e6);
|
|
1495
|
+
return initializeActivityState({
|
|
1496
|
+
source: activitySource,
|
|
1497
|
+
variant: childVariant,
|
|
1498
|
+
parentId: extendedId,
|
|
1499
|
+
numActivityVariants,
|
|
1500
|
+
restrictToVariantSlice
|
|
1501
|
+
});
|
|
1502
|
+
});
|
|
1503
|
+
return {
|
|
1504
|
+
type: "sequence",
|
|
1505
|
+
id: extendedId,
|
|
1506
|
+
parentId,
|
|
1507
|
+
source,
|
|
1508
|
+
initialVariant: variant,
|
|
1509
|
+
creditAchieved: 0,
|
|
1510
|
+
allChildren: childStates,
|
|
1511
|
+
attemptNumber: 0,
|
|
1512
|
+
orderedChildren: [],
|
|
1513
|
+
restrictToVariantSlice
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
function generateNewSequenceAttempt({
|
|
1517
|
+
state,
|
|
1518
|
+
numActivityVariants,
|
|
1519
|
+
initialQuestionCounter,
|
|
1520
|
+
parentAttempt
|
|
1521
|
+
}) {
|
|
1522
|
+
const source = state.source;
|
|
1523
|
+
const childOrder = state.allChildren.map((state2) => state2.id);
|
|
1524
|
+
if (source.shuffle) {
|
|
1525
|
+
let shuffle_ids = function(arr, startInd2, numItems) {
|
|
1526
|
+
for (let i = numItems - 1; i > 0; i--) {
|
|
1527
|
+
const j = Math.floor(rng() * (i + 1));
|
|
1528
|
+
[arr[startInd2 + i], arr[startInd2 + j]] = [
|
|
1529
|
+
arr[startInd2 + j],
|
|
1530
|
+
arr[startInd2 + i]
|
|
1531
|
+
];
|
|
1532
|
+
}
|
|
1533
|
+
};
|
|
1534
|
+
const rngSeed = state.initialVariant.toString() + "|" + state.id.toString() + "|" + state.attemptNumber.toString() + "|" + parentAttempt.toString();
|
|
1535
|
+
const rng = rngClass$1(rngSeed);
|
|
1536
|
+
let startInd = 0;
|
|
1537
|
+
while (startInd < state.allChildren.length) {
|
|
1538
|
+
while (state.allChildren[startInd]?.type === "singleDoc" && state.allChildren[startInd].source.isDescription) {
|
|
1539
|
+
startInd++;
|
|
1540
|
+
}
|
|
1541
|
+
if (startInd >= state.allChildren.length) {
|
|
1542
|
+
break;
|
|
1543
|
+
}
|
|
1544
|
+
let numItems = 1;
|
|
1545
|
+
while (state.allChildren[startInd + numItems] && (state.allChildren[startInd + numItems].type !== "singleDoc" || !state.allChildren[startInd + numItems].source.isDescription)) {
|
|
1546
|
+
numItems++;
|
|
1547
|
+
}
|
|
1548
|
+
if (numItems > 1) {
|
|
1549
|
+
shuffle_ids(childOrder, startInd, numItems);
|
|
1550
|
+
}
|
|
1551
|
+
startInd += numItems;
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
const orderedChildStates = [];
|
|
1555
|
+
const unorderedChildStates = [...state.allChildren];
|
|
1556
|
+
let questionCounter = initialQuestionCounter;
|
|
1557
|
+
for (const childId of childOrder) {
|
|
1558
|
+
const childIdx = state.allChildren.findIndex(
|
|
1559
|
+
(child) => child.id === childId
|
|
1560
|
+
);
|
|
1561
|
+
const originalState = state.allChildren[childIdx];
|
|
1562
|
+
const { finalQuestionCounter: endCounter, state: newState2 } = generateNewActivityAttempt({
|
|
1563
|
+
state: originalState,
|
|
1564
|
+
numActivityVariants,
|
|
1565
|
+
initialQuestionCounter: questionCounter,
|
|
1566
|
+
parentAttempt: state.attemptNumber + 1
|
|
1567
|
+
});
|
|
1568
|
+
questionCounter = endCounter;
|
|
1569
|
+
orderedChildStates.push(newState2);
|
|
1570
|
+
unorderedChildStates[childIdx] = newState2;
|
|
1571
|
+
}
|
|
1572
|
+
const newState = {
|
|
1573
|
+
...state,
|
|
1574
|
+
creditAchieved: 0,
|
|
1575
|
+
allChildren: unorderedChildStates,
|
|
1576
|
+
attemptNumber: state.attemptNumber + 1,
|
|
1577
|
+
orderedChildren: orderedChildStates
|
|
1578
|
+
};
|
|
1579
|
+
return { finalQuestionCounter: questionCounter, state: newState };
|
|
1580
|
+
}
|
|
1581
|
+
function extractSequenceItemCredit(activityState, nPrevInShuffleOrder = 0) {
|
|
1582
|
+
if (activityState.attemptNumber === 0) {
|
|
1583
|
+
let nPrev = nPrevInShuffleOrder;
|
|
1584
|
+
return activityState.allChildren.flatMap((state) => {
|
|
1585
|
+
const next = extractActivityItemCredit(state, nPrev);
|
|
1586
|
+
nPrev += next.length;
|
|
1587
|
+
return next;
|
|
1588
|
+
});
|
|
1589
|
+
} else {
|
|
1590
|
+
let nPrev = nPrevInShuffleOrder;
|
|
1591
|
+
const inShuffledOrder = activityState.orderedChildren.map((state) => {
|
|
1592
|
+
const next = extractActivityItemCredit(state, nPrev);
|
|
1593
|
+
nPrev += next.length;
|
|
1594
|
+
return { childId: state.id, items: next };
|
|
1595
|
+
});
|
|
1596
|
+
const inOriginalOrder = activityState.allChildren.flatMap((state) => {
|
|
1597
|
+
const childResults = inShuffledOrder.find(
|
|
1598
|
+
(obj) => obj.childId === state.id
|
|
1599
|
+
);
|
|
1600
|
+
if (!childResults) {
|
|
1601
|
+
throw Error("Unreachable");
|
|
1602
|
+
}
|
|
1603
|
+
return childResults.items;
|
|
1604
|
+
});
|
|
1605
|
+
return inOriginalOrder;
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
function pruneSequenceStateForSave(activityState) {
|
|
1609
|
+
const { source: _source, ...newState } = { ...activityState };
|
|
1610
|
+
const allChildren = newState.allChildren.map(
|
|
1611
|
+
(child) => pruneActivityStateForSave(child)
|
|
1612
|
+
);
|
|
1613
|
+
const orderedChildren = newState.orderedChildren.map(
|
|
1614
|
+
(child) => pruneActivityStateForSave(child)
|
|
1615
|
+
);
|
|
1616
|
+
return { ...newState, allChildren, orderedChildren };
|
|
1617
|
+
}
|
|
1618
|
+
function addSourceToSequenceState(activityState, source) {
|
|
1619
|
+
const allChildren = activityState.allChildren.map((child) => {
|
|
1620
|
+
const idx = source.items.findIndex(
|
|
1621
|
+
(src) => src.id === extractSourceId(child.id)
|
|
1622
|
+
);
|
|
1623
|
+
return addSourceToActivityState(child, source.items[idx]);
|
|
1624
|
+
});
|
|
1625
|
+
const orderedChildren = activityState.orderedChildren.map((child) => {
|
|
1626
|
+
const idx = source.items.findIndex(
|
|
1627
|
+
(src) => src.id === extractSourceId(child.id)
|
|
1628
|
+
);
|
|
1629
|
+
return addSourceToActivityState(child, source.items[idx]);
|
|
1630
|
+
});
|
|
1631
|
+
return {
|
|
1632
|
+
...activityState,
|
|
1633
|
+
source,
|
|
1634
|
+
allChildren,
|
|
1635
|
+
orderedChildren
|
|
1636
|
+
};
|
|
1637
|
+
}
|
|
1638
|
+
function calcNumVariantsSequence(source, numActivityVariants) {
|
|
1639
|
+
if (source.items.length === 0) {
|
|
1640
|
+
return 0;
|
|
1641
|
+
}
|
|
1642
|
+
let numVariants = Infinity;
|
|
1643
|
+
for (const item of source.items) {
|
|
1644
|
+
numVariants = Math.min(
|
|
1645
|
+
numVariants,
|
|
1646
|
+
calcNumVariants(item, numActivityVariants)
|
|
1647
|
+
);
|
|
1648
|
+
}
|
|
1649
|
+
return numVariants;
|
|
1650
|
+
}
|
|
1651
|
+
function getNumItemsInSequence(source) {
|
|
1652
|
+
const numDocumentsForEachItem = source.items.map(getNumItems);
|
|
1653
|
+
const totalNumDocuments = numDocumentsForEachItem.reduce(
|
|
1654
|
+
(a, c) => a + c,
|
|
1655
|
+
0
|
|
1656
|
+
);
|
|
1657
|
+
return totalNumDocuments;
|
|
1658
|
+
}
|
|
1659
|
+
function commonjsRequire(path) {
|
|
1660
|
+
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
1661
|
+
}
|
|
1662
|
+
var object_hash = { exports: {} };
|
|
1663
|
+
var hasRequiredObject_hash;
|
|
1664
|
+
function requireObject_hash() {
|
|
1665
|
+
if (hasRequiredObject_hash) return object_hash.exports;
|
|
1666
|
+
hasRequiredObject_hash = 1;
|
|
1667
|
+
(function(module, exports) {
|
|
1668
|
+
!function(e) {
|
|
1669
|
+
module.exports = e();
|
|
1670
|
+
}(function() {
|
|
1671
|
+
return function r(o, i, u) {
|
|
1672
|
+
function s(n, e2) {
|
|
1673
|
+
if (!i[n]) {
|
|
1674
|
+
if (!o[n]) {
|
|
1675
|
+
var t = "function" == typeof commonjsRequire && commonjsRequire;
|
|
1676
|
+
if (!e2 && t) return t(n, true);
|
|
1677
|
+
if (a) return a(n, true);
|
|
1678
|
+
throw new Error("Cannot find module '" + n + "'");
|
|
1679
|
+
}
|
|
1680
|
+
e2 = i[n] = { exports: {} };
|
|
1681
|
+
o[n][0].call(e2.exports, function(e3) {
|
|
1682
|
+
var t2 = o[n][1][e3];
|
|
1683
|
+
return s(t2 || e3);
|
|
1684
|
+
}, e2, e2.exports, r, o, i, u);
|
|
1685
|
+
}
|
|
1686
|
+
return i[n].exports;
|
|
1687
|
+
}
|
|
1688
|
+
for (var a = "function" == typeof commonjsRequire && commonjsRequire, e = 0; e < u.length; e++) s(u[e]);
|
|
1689
|
+
return s;
|
|
1690
|
+
}({ 1: [function(w, b, m) {
|
|
1691
|
+
!(function(e, n, s, c, d, h, p, g, y) {
|
|
1692
|
+
var r = w("crypto");
|
|
1693
|
+
function t(e2, t2) {
|
|
1694
|
+
t2 = u(e2, t2);
|
|
1695
|
+
var n2;
|
|
1696
|
+
return void 0 === (n2 = "passthrough" !== t2.algorithm ? r.createHash(t2.algorithm) : new l()).write && (n2.write = n2.update, n2.end = n2.update), f(t2, n2).dispatch(e2), n2.update || n2.end(""), n2.digest ? n2.digest("buffer" === t2.encoding ? void 0 : t2.encoding) : (e2 = n2.read(), "buffer" !== t2.encoding ? e2.toString(t2.encoding) : e2);
|
|
1697
|
+
}
|
|
1698
|
+
(m = b.exports = t).sha1 = function(e2) {
|
|
1699
|
+
return t(e2);
|
|
1700
|
+
}, m.keys = function(e2) {
|
|
1701
|
+
return t(e2, { excludeValues: true, algorithm: "sha1", encoding: "hex" });
|
|
1702
|
+
}, m.MD5 = function(e2) {
|
|
1703
|
+
return t(e2, { algorithm: "md5", encoding: "hex" });
|
|
1704
|
+
}, m.keysMD5 = function(e2) {
|
|
1705
|
+
return t(e2, { algorithm: "md5", encoding: "hex", excludeValues: true });
|
|
1706
|
+
};
|
|
1707
|
+
var o = r.getHashes ? r.getHashes().slice() : ["sha1", "md5"], i = (o.push("passthrough"), ["buffer", "hex", "binary", "base64"]);
|
|
1708
|
+
function u(e2, t2) {
|
|
1709
|
+
var n2 = {};
|
|
1710
|
+
if (n2.algorithm = (t2 = t2 || {}).algorithm || "sha1", n2.encoding = t2.encoding || "hex", n2.excludeValues = !!t2.excludeValues, n2.algorithm = n2.algorithm.toLowerCase(), n2.encoding = n2.encoding.toLowerCase(), n2.ignoreUnknown = true === t2.ignoreUnknown, n2.respectType = false !== t2.respectType, n2.respectFunctionNames = false !== t2.respectFunctionNames, n2.respectFunctionProperties = false !== t2.respectFunctionProperties, n2.unorderedArrays = true === t2.unorderedArrays, n2.unorderedSets = false !== t2.unorderedSets, n2.unorderedObjects = false !== t2.unorderedObjects, n2.replacer = t2.replacer || void 0, n2.excludeKeys = t2.excludeKeys || void 0, void 0 === e2) throw new Error("Object argument required.");
|
|
1711
|
+
for (var r2 = 0; r2 < o.length; ++r2) o[r2].toLowerCase() === n2.algorithm.toLowerCase() && (n2.algorithm = o[r2]);
|
|
1712
|
+
if (-1 === o.indexOf(n2.algorithm)) throw new Error('Algorithm "' + n2.algorithm + '" not supported. supported values: ' + o.join(", "));
|
|
1713
|
+
if (-1 === i.indexOf(n2.encoding) && "passthrough" !== n2.algorithm) throw new Error('Encoding "' + n2.encoding + '" not supported. supported values: ' + i.join(", "));
|
|
1714
|
+
return n2;
|
|
1715
|
+
}
|
|
1716
|
+
function a(e2) {
|
|
1717
|
+
if ("function" == typeof e2) return null != /^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(e2));
|
|
1718
|
+
}
|
|
1719
|
+
function f(o2, t2, i2) {
|
|
1720
|
+
i2 = i2 || [];
|
|
1721
|
+
function u2(e2) {
|
|
1722
|
+
return t2.update ? t2.update(e2, "utf8") : t2.write(e2, "utf8");
|
|
1723
|
+
}
|
|
1724
|
+
return { dispatch: function(e2) {
|
|
1725
|
+
return this["_" + (null === (e2 = o2.replacer ? o2.replacer(e2) : e2) ? "null" : typeof e2)](e2);
|
|
1726
|
+
}, _object: function(t3) {
|
|
1727
|
+
var n2, e2 = Object.prototype.toString.call(t3), r2 = /\[object (.*)\]/i.exec(e2);
|
|
1728
|
+
r2 = (r2 = r2 ? r2[1] : "unknown:[" + e2 + "]").toLowerCase();
|
|
1729
|
+
if (0 <= (e2 = i2.indexOf(t3))) return this.dispatch("[CIRCULAR:" + e2 + "]");
|
|
1730
|
+
if (i2.push(t3), void 0 !== s && s.isBuffer && s.isBuffer(t3)) return u2("buffer:"), u2(t3);
|
|
1731
|
+
if ("object" === r2 || "function" === r2 || "asyncfunction" === r2) return e2 = Object.keys(t3), o2.unorderedObjects && (e2 = e2.sort()), false === o2.respectType || a(t3) || e2.splice(0, 0, "prototype", "__proto__", "constructor"), o2.excludeKeys && (e2 = e2.filter(function(e3) {
|
|
1732
|
+
return !o2.excludeKeys(e3);
|
|
1733
|
+
})), u2("object:" + e2.length + ":"), n2 = this, e2.forEach(function(e3) {
|
|
1734
|
+
n2.dispatch(e3), u2(":"), o2.excludeValues || n2.dispatch(t3[e3]), u2(",");
|
|
1735
|
+
});
|
|
1736
|
+
if (!this["_" + r2]) {
|
|
1737
|
+
if (o2.ignoreUnknown) return u2("[" + r2 + "]");
|
|
1738
|
+
throw new Error('Unknown object type "' + r2 + '"');
|
|
1739
|
+
}
|
|
1740
|
+
this["_" + r2](t3);
|
|
1741
|
+
}, _array: function(e2, t3) {
|
|
1742
|
+
t3 = void 0 !== t3 ? t3 : false !== o2.unorderedArrays;
|
|
1743
|
+
var n2 = this;
|
|
1744
|
+
if (u2("array:" + e2.length + ":"), !t3 || e2.length <= 1) return e2.forEach(function(e3) {
|
|
1745
|
+
return n2.dispatch(e3);
|
|
1746
|
+
});
|
|
1747
|
+
var r2 = [], t3 = e2.map(function(e3) {
|
|
1748
|
+
var t4 = new l(), n3 = i2.slice();
|
|
1749
|
+
return f(o2, t4, n3).dispatch(e3), r2 = r2.concat(n3.slice(i2.length)), t4.read().toString();
|
|
1750
|
+
});
|
|
1751
|
+
return i2 = i2.concat(r2), t3.sort(), this._array(t3, false);
|
|
1752
|
+
}, _date: function(e2) {
|
|
1753
|
+
return u2("date:" + e2.toJSON());
|
|
1754
|
+
}, _symbol: function(e2) {
|
|
1755
|
+
return u2("symbol:" + e2.toString());
|
|
1756
|
+
}, _error: function(e2) {
|
|
1757
|
+
return u2("error:" + e2.toString());
|
|
1758
|
+
}, _boolean: function(e2) {
|
|
1759
|
+
return u2("bool:" + e2.toString());
|
|
1760
|
+
}, _string: function(e2) {
|
|
1761
|
+
u2("string:" + e2.length + ":"), u2(e2.toString());
|
|
1762
|
+
}, _function: function(e2) {
|
|
1763
|
+
u2("fn:"), a(e2) ? this.dispatch("[native]") : this.dispatch(e2.toString()), false !== o2.respectFunctionNames && this.dispatch("function-name:" + String(e2.name)), o2.respectFunctionProperties && this._object(e2);
|
|
1764
|
+
}, _number: function(e2) {
|
|
1765
|
+
return u2("number:" + e2.toString());
|
|
1766
|
+
}, _xml: function(e2) {
|
|
1767
|
+
return u2("xml:" + e2.toString());
|
|
1768
|
+
}, _null: function() {
|
|
1769
|
+
return u2("Null");
|
|
1770
|
+
}, _undefined: function() {
|
|
1771
|
+
return u2("Undefined");
|
|
1772
|
+
}, _regexp: function(e2) {
|
|
1773
|
+
return u2("regex:" + e2.toString());
|
|
1774
|
+
}, _uint8array: function(e2) {
|
|
1775
|
+
return u2("uint8array:"), this.dispatch(Array.prototype.slice.call(e2));
|
|
1776
|
+
}, _uint8clampedarray: function(e2) {
|
|
1777
|
+
return u2("uint8clampedarray:"), this.dispatch(Array.prototype.slice.call(e2));
|
|
1778
|
+
}, _int8array: function(e2) {
|
|
1779
|
+
return u2("int8array:"), this.dispatch(Array.prototype.slice.call(e2));
|
|
1780
|
+
}, _uint16array: function(e2) {
|
|
1781
|
+
return u2("uint16array:"), this.dispatch(Array.prototype.slice.call(e2));
|
|
1782
|
+
}, _int16array: function(e2) {
|
|
1783
|
+
return u2("int16array:"), this.dispatch(Array.prototype.slice.call(e2));
|
|
1784
|
+
}, _uint32array: function(e2) {
|
|
1785
|
+
return u2("uint32array:"), this.dispatch(Array.prototype.slice.call(e2));
|
|
1786
|
+
}, _int32array: function(e2) {
|
|
1787
|
+
return u2("int32array:"), this.dispatch(Array.prototype.slice.call(e2));
|
|
1788
|
+
}, _float32array: function(e2) {
|
|
1789
|
+
return u2("float32array:"), this.dispatch(Array.prototype.slice.call(e2));
|
|
1790
|
+
}, _float64array: function(e2) {
|
|
1791
|
+
return u2("float64array:"), this.dispatch(Array.prototype.slice.call(e2));
|
|
1792
|
+
}, _arraybuffer: function(e2) {
|
|
1793
|
+
return u2("arraybuffer:"), this.dispatch(new Uint8Array(e2));
|
|
1794
|
+
}, _url: function(e2) {
|
|
1795
|
+
return u2("url:" + e2.toString());
|
|
1796
|
+
}, _map: function(e2) {
|
|
1797
|
+
u2("map:");
|
|
1798
|
+
e2 = Array.from(e2);
|
|
1799
|
+
return this._array(e2, false !== o2.unorderedSets);
|
|
1800
|
+
}, _set: function(e2) {
|
|
1801
|
+
u2("set:");
|
|
1802
|
+
e2 = Array.from(e2);
|
|
1803
|
+
return this._array(e2, false !== o2.unorderedSets);
|
|
1804
|
+
}, _file: function(e2) {
|
|
1805
|
+
return u2("file:"), this.dispatch([e2.name, e2.size, e2.type, e2.lastModfied]);
|
|
1806
|
+
}, _blob: function() {
|
|
1807
|
+
if (o2.ignoreUnknown) return u2("[blob]");
|
|
1808
|
+
throw Error('Hashing Blob objects is currently not supported\n(see https://github.com/puleos/object-hash/issues/26)\nUse "options.replacer" or "options.ignoreUnknown"\n');
|
|
1809
|
+
}, _domwindow: function() {
|
|
1810
|
+
return u2("domwindow");
|
|
1811
|
+
}, _bigint: function(e2) {
|
|
1812
|
+
return u2("bigint:" + e2.toString());
|
|
1813
|
+
}, _process: function() {
|
|
1814
|
+
return u2("process");
|
|
1815
|
+
}, _timer: function() {
|
|
1816
|
+
return u2("timer");
|
|
1817
|
+
}, _pipe: function() {
|
|
1818
|
+
return u2("pipe");
|
|
1819
|
+
}, _tcp: function() {
|
|
1820
|
+
return u2("tcp");
|
|
1821
|
+
}, _udp: function() {
|
|
1822
|
+
return u2("udp");
|
|
1823
|
+
}, _tty: function() {
|
|
1824
|
+
return u2("tty");
|
|
1825
|
+
}, _statwatcher: function() {
|
|
1826
|
+
return u2("statwatcher");
|
|
1827
|
+
}, _securecontext: function() {
|
|
1828
|
+
return u2("securecontext");
|
|
1829
|
+
}, _connection: function() {
|
|
1830
|
+
return u2("connection");
|
|
1831
|
+
}, _zlib: function() {
|
|
1832
|
+
return u2("zlib");
|
|
1833
|
+
}, _context: function() {
|
|
1834
|
+
return u2("context");
|
|
1835
|
+
}, _nodescript: function() {
|
|
1836
|
+
return u2("nodescript");
|
|
1837
|
+
}, _httpparser: function() {
|
|
1838
|
+
return u2("httpparser");
|
|
1839
|
+
}, _dataview: function() {
|
|
1840
|
+
return u2("dataview");
|
|
1841
|
+
}, _signal: function() {
|
|
1842
|
+
return u2("signal");
|
|
1843
|
+
}, _fsevent: function() {
|
|
1844
|
+
return u2("fsevent");
|
|
1845
|
+
}, _tlswrap: function() {
|
|
1846
|
+
return u2("tlswrap");
|
|
1847
|
+
} };
|
|
1848
|
+
}
|
|
1849
|
+
function l() {
|
|
1850
|
+
return { buf: "", write: function(e2) {
|
|
1851
|
+
this.buf += e2;
|
|
1852
|
+
}, end: function(e2) {
|
|
1853
|
+
this.buf += e2;
|
|
1854
|
+
}, read: function() {
|
|
1855
|
+
return this.buf;
|
|
1856
|
+
} };
|
|
1857
|
+
}
|
|
1858
|
+
m.writeToStream = function(e2, t2, n2) {
|
|
1859
|
+
return void 0 === n2 && (n2 = t2, t2 = {}), f(t2 = u(e2, t2), n2).dispatch(e2);
|
|
1860
|
+
};
|
|
1861
|
+
}).call(this, w("lYpoI2"), "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}, w("buffer").Buffer, arguments[3], arguments[4], arguments[5], arguments[6], "/fake_9a5aa49d.js", "/");
|
|
1862
|
+
}, { buffer: 3, crypto: 5, lYpoI2: 11 }], 2: [function(e, t, f) {
|
|
1863
|
+
!(function(e2, t2, n, r, o, i, u, s, a) {
|
|
1864
|
+
!function(e3) {
|
|
1865
|
+
var a2 = "undefined" != typeof Uint8Array ? Uint8Array : Array, t3 = "+".charCodeAt(0), n2 = "/".charCodeAt(0), r2 = "0".charCodeAt(0), o2 = "a".charCodeAt(0), i2 = "A".charCodeAt(0), u2 = "-".charCodeAt(0), s2 = "_".charCodeAt(0);
|
|
1866
|
+
function f2(e4) {
|
|
1867
|
+
e4 = e4.charCodeAt(0);
|
|
1868
|
+
return e4 === t3 || e4 === u2 ? 62 : e4 === n2 || e4 === s2 ? 63 : e4 < r2 ? -1 : e4 < r2 + 10 ? e4 - r2 + 26 + 26 : e4 < i2 + 26 ? e4 - i2 : e4 < o2 + 26 ? e4 - o2 + 26 : void 0;
|
|
1869
|
+
}
|
|
1870
|
+
e3.toByteArray = function(e4) {
|
|
1871
|
+
var t4, n3;
|
|
1872
|
+
if (0 < e4.length % 4) throw new Error("Invalid string. Length must be a multiple of 4");
|
|
1873
|
+
var r3 = e4.length, r3 = "=" === e4.charAt(r3 - 2) ? 2 : "=" === e4.charAt(r3 - 1) ? 1 : 0, o3 = new a2(3 * e4.length / 4 - r3), i3 = 0 < r3 ? e4.length - 4 : e4.length, u3 = 0;
|
|
1874
|
+
function s3(e5) {
|
|
1875
|
+
o3[u3++] = e5;
|
|
1876
|
+
}
|
|
1877
|
+
for (t4 = 0; t4 < i3; t4 += 4, 0) s3((16711680 & (n3 = f2(e4.charAt(t4)) << 18 | f2(e4.charAt(t4 + 1)) << 12 | f2(e4.charAt(t4 + 2)) << 6 | f2(e4.charAt(t4 + 3)))) >> 16), s3((65280 & n3) >> 8), s3(255 & n3);
|
|
1878
|
+
return 2 == r3 ? s3(255 & (n3 = f2(e4.charAt(t4)) << 2 | f2(e4.charAt(t4 + 1)) >> 4)) : 1 == r3 && (s3((n3 = f2(e4.charAt(t4)) << 10 | f2(e4.charAt(t4 + 1)) << 4 | f2(e4.charAt(t4 + 2)) >> 2) >> 8 & 255), s3(255 & n3)), o3;
|
|
1879
|
+
}, e3.fromByteArray = function(e4) {
|
|
1880
|
+
var t4, n3, r3, o3, i3 = e4.length % 3, u3 = "";
|
|
1881
|
+
function s3(e5) {
|
|
1882
|
+
return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e5);
|
|
1883
|
+
}
|
|
1884
|
+
for (t4 = 0, r3 = e4.length - i3; t4 < r3; t4 += 3) n3 = (e4[t4] << 16) + (e4[t4 + 1] << 8) + e4[t4 + 2], u3 += s3((o3 = n3) >> 18 & 63) + s3(o3 >> 12 & 63) + s3(o3 >> 6 & 63) + s3(63 & o3);
|
|
1885
|
+
switch (i3) {
|
|
1886
|
+
case 1:
|
|
1887
|
+
u3 = (u3 += s3((n3 = e4[e4.length - 1]) >> 2)) + s3(n3 << 4 & 63) + "==";
|
|
1888
|
+
break;
|
|
1889
|
+
case 2:
|
|
1890
|
+
u3 = (u3 = (u3 += s3((n3 = (e4[e4.length - 2] << 8) + e4[e4.length - 1]) >> 10)) + s3(n3 >> 4 & 63)) + s3(n3 << 2 & 63) + "=";
|
|
1891
|
+
}
|
|
1892
|
+
return u3;
|
|
1893
|
+
};
|
|
1894
|
+
}(void 0 === f ? this.base64js = {} : f);
|
|
1895
|
+
}).call(this, e("lYpoI2"), "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}, e("buffer").Buffer, arguments[3], arguments[4], arguments[5], arguments[6], "/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js", "/node_modules/gulp-browserify/node_modules/base64-js/lib");
|
|
1896
|
+
}, { buffer: 3, lYpoI2: 11 }], 3: [function(O, e, H) {
|
|
1897
|
+
!(function(e2, n, f, r, h, p, g, y, w) {
|
|
1898
|
+
var a = O("base64-js"), i = O("ieee754");
|
|
1899
|
+
function f(e3, t2, n2) {
|
|
1900
|
+
if (!(this instanceof f)) return new f(e3, t2, n2);
|
|
1901
|
+
var r2, o2, i2, u2, s2 = typeof e3;
|
|
1902
|
+
if ("base64" === t2 && "string" == s2) for (e3 = (u2 = e3).trim ? u2.trim() : u2.replace(/^\s+|\s+$/g, ""); e3.length % 4 != 0; ) e3 += "=";
|
|
1903
|
+
if ("number" == s2) r2 = j(e3);
|
|
1904
|
+
else if ("string" == s2) r2 = f.byteLength(e3, t2);
|
|
1905
|
+
else {
|
|
1906
|
+
if ("object" != s2) throw new Error("First argument needs to be a number, array or string.");
|
|
1907
|
+
r2 = j(e3.length);
|
|
1908
|
+
}
|
|
1909
|
+
if (f._useTypedArrays ? o2 = f._augment(new Uint8Array(r2)) : ((o2 = this).length = r2, o2._isBuffer = true), f._useTypedArrays && "number" == typeof e3.byteLength) o2._set(e3);
|
|
1910
|
+
else if (C(u2 = e3) || f.isBuffer(u2) || u2 && "object" == typeof u2 && "number" == typeof u2.length) for (i2 = 0; i2 < r2; i2++) f.isBuffer(e3) ? o2[i2] = e3.readUInt8(i2) : o2[i2] = e3[i2];
|
|
1911
|
+
else if ("string" == s2) o2.write(e3, 0, t2);
|
|
1912
|
+
else if ("number" == s2 && !f._useTypedArrays && !n2) for (i2 = 0; i2 < r2; i2++) o2[i2] = 0;
|
|
1913
|
+
return o2;
|
|
1914
|
+
}
|
|
1915
|
+
function b(e3, t2, n2, r2) {
|
|
1916
|
+
return f._charsWritten = c(function(e4) {
|
|
1917
|
+
for (var t3 = [], n3 = 0; n3 < e4.length; n3++) t3.push(255 & e4.charCodeAt(n3));
|
|
1918
|
+
return t3;
|
|
1919
|
+
}(t2), e3, n2, r2);
|
|
1920
|
+
}
|
|
1921
|
+
function m(e3, t2, n2, r2) {
|
|
1922
|
+
return f._charsWritten = c(function(e4) {
|
|
1923
|
+
for (var t3, n3, r3 = [], o2 = 0; o2 < e4.length; o2++) n3 = e4.charCodeAt(o2), t3 = n3 >> 8, n3 = n3 % 256, r3.push(n3), r3.push(t3);
|
|
1924
|
+
return r3;
|
|
1925
|
+
}(t2), e3, n2, r2);
|
|
1926
|
+
}
|
|
1927
|
+
function v(e3, t2, n2) {
|
|
1928
|
+
var r2 = "";
|
|
1929
|
+
n2 = Math.min(e3.length, n2);
|
|
1930
|
+
for (var o2 = t2; o2 < n2; o2++) r2 += String.fromCharCode(e3[o2]);
|
|
1931
|
+
return r2;
|
|
1932
|
+
}
|
|
1933
|
+
function o(e3, t2, n2, r2) {
|
|
1934
|
+
r2 || (d("boolean" == typeof n2, "missing or invalid endian"), d(null != t2, "missing offset"), d(t2 + 1 < e3.length, "Trying to read beyond buffer length"));
|
|
1935
|
+
var o2, r2 = e3.length;
|
|
1936
|
+
if (!(r2 <= t2)) return n2 ? (o2 = e3[t2], t2 + 1 < r2 && (o2 |= e3[t2 + 1] << 8)) : (o2 = e3[t2] << 8, t2 + 1 < r2 && (o2 |= e3[t2 + 1])), o2;
|
|
1937
|
+
}
|
|
1938
|
+
function u(e3, t2, n2, r2) {
|
|
1939
|
+
r2 || (d("boolean" == typeof n2, "missing or invalid endian"), d(null != t2, "missing offset"), d(t2 + 3 < e3.length, "Trying to read beyond buffer length"));
|
|
1940
|
+
var o2, r2 = e3.length;
|
|
1941
|
+
if (!(r2 <= t2)) return n2 ? (t2 + 2 < r2 && (o2 = e3[t2 + 2] << 16), t2 + 1 < r2 && (o2 |= e3[t2 + 1] << 8), o2 |= e3[t2], t2 + 3 < r2 && (o2 += e3[t2 + 3] << 24 >>> 0)) : (t2 + 1 < r2 && (o2 = e3[t2 + 1] << 16), t2 + 2 < r2 && (o2 |= e3[t2 + 2] << 8), t2 + 3 < r2 && (o2 |= e3[t2 + 3]), o2 += e3[t2] << 24 >>> 0), o2;
|
|
1942
|
+
}
|
|
1943
|
+
function _(e3, t2, n2, r2) {
|
|
1944
|
+
if (r2 || (d("boolean" == typeof n2, "missing or invalid endian"), d(null != t2, "missing offset"), d(t2 + 1 < e3.length, "Trying to read beyond buffer length")), !(e3.length <= t2)) return r2 = o(e3, t2, n2, true), 32768 & r2 ? -1 * (65535 - r2 + 1) : r2;
|
|
1945
|
+
}
|
|
1946
|
+
function E(e3, t2, n2, r2) {
|
|
1947
|
+
if (r2 || (d("boolean" == typeof n2, "missing or invalid endian"), d(null != t2, "missing offset"), d(t2 + 3 < e3.length, "Trying to read beyond buffer length")), !(e3.length <= t2)) return r2 = u(e3, t2, n2, true), 2147483648 & r2 ? -1 * (4294967295 - r2 + 1) : r2;
|
|
1948
|
+
}
|
|
1949
|
+
function I(e3, t2, n2, r2) {
|
|
1950
|
+
return r2 || (d("boolean" == typeof n2, "missing or invalid endian"), d(t2 + 3 < e3.length, "Trying to read beyond buffer length")), i.read(e3, t2, n2, 23, 4);
|
|
1951
|
+
}
|
|
1952
|
+
function A(e3, t2, n2, r2) {
|
|
1953
|
+
return r2 || (d("boolean" == typeof n2, "missing or invalid endian"), d(t2 + 7 < e3.length, "Trying to read beyond buffer length")), i.read(e3, t2, n2, 52, 8);
|
|
1954
|
+
}
|
|
1955
|
+
function s(e3, t2, n2, r2, o2) {
|
|
1956
|
+
o2 || (d(null != t2, "missing value"), d("boolean" == typeof r2, "missing or invalid endian"), d(null != n2, "missing offset"), d(n2 + 1 < e3.length, "trying to write beyond buffer length"), Y(t2, 65535));
|
|
1957
|
+
o2 = e3.length;
|
|
1958
|
+
if (!(o2 <= n2)) for (var i2 = 0, u2 = Math.min(o2 - n2, 2); i2 < u2; i2++) e3[n2 + i2] = (t2 & 255 << 8 * (r2 ? i2 : 1 - i2)) >>> 8 * (r2 ? i2 : 1 - i2);
|
|
1959
|
+
}
|
|
1960
|
+
function l(e3, t2, n2, r2, o2) {
|
|
1961
|
+
o2 || (d(null != t2, "missing value"), d("boolean" == typeof r2, "missing or invalid endian"), d(null != n2, "missing offset"), d(n2 + 3 < e3.length, "trying to write beyond buffer length"), Y(t2, 4294967295));
|
|
1962
|
+
o2 = e3.length;
|
|
1963
|
+
if (!(o2 <= n2)) for (var i2 = 0, u2 = Math.min(o2 - n2, 4); i2 < u2; i2++) e3[n2 + i2] = t2 >>> 8 * (r2 ? i2 : 3 - i2) & 255;
|
|
1964
|
+
}
|
|
1965
|
+
function B(e3, t2, n2, r2, o2) {
|
|
1966
|
+
o2 || (d(null != t2, "missing value"), d("boolean" == typeof r2, "missing or invalid endian"), d(null != n2, "missing offset"), d(n2 + 1 < e3.length, "Trying to write beyond buffer length"), F(t2, 32767, -32768)), e3.length <= n2 || s(e3, 0 <= t2 ? t2 : 65535 + t2 + 1, n2, r2, o2);
|
|
1967
|
+
}
|
|
1968
|
+
function L(e3, t2, n2, r2, o2) {
|
|
1969
|
+
o2 || (d(null != t2, "missing value"), d("boolean" == typeof r2, "missing or invalid endian"), d(null != n2, "missing offset"), d(n2 + 3 < e3.length, "Trying to write beyond buffer length"), F(t2, 2147483647, -2147483648)), e3.length <= n2 || l(e3, 0 <= t2 ? t2 : 4294967295 + t2 + 1, n2, r2, o2);
|
|
1970
|
+
}
|
|
1971
|
+
function U(e3, t2, n2, r2, o2) {
|
|
1972
|
+
o2 || (d(null != t2, "missing value"), d("boolean" == typeof r2, "missing or invalid endian"), d(null != n2, "missing offset"), d(n2 + 3 < e3.length, "Trying to write beyond buffer length"), D(t2, 34028234663852886e22, -34028234663852886e22)), e3.length <= n2 || i.write(e3, t2, n2, r2, 23, 4);
|
|
1973
|
+
}
|
|
1974
|
+
function x(e3, t2, n2, r2, o2) {
|
|
1975
|
+
o2 || (d(null != t2, "missing value"), d("boolean" == typeof r2, "missing or invalid endian"), d(null != n2, "missing offset"), d(n2 + 7 < e3.length, "Trying to write beyond buffer length"), D(t2, 17976931348623157e292, -17976931348623157e292)), e3.length <= n2 || i.write(e3, t2, n2, r2, 52, 8);
|
|
1976
|
+
}
|
|
1977
|
+
H.Buffer = f, H.SlowBuffer = f, H.INSPECT_MAX_BYTES = 50, f.poolSize = 8192, f._useTypedArrays = function() {
|
|
1978
|
+
try {
|
|
1979
|
+
var e3 = new ArrayBuffer(0), t2 = new Uint8Array(e3);
|
|
1980
|
+
return t2.foo = function() {
|
|
1981
|
+
return 42;
|
|
1982
|
+
}, 42 === t2.foo() && "function" == typeof t2.subarray;
|
|
1983
|
+
} catch (e4) {
|
|
1984
|
+
return false;
|
|
1985
|
+
}
|
|
1986
|
+
}(), f.isEncoding = function(e3) {
|
|
1987
|
+
switch (String(e3).toLowerCase()) {
|
|
1988
|
+
case "hex":
|
|
1989
|
+
case "utf8":
|
|
1990
|
+
case "utf-8":
|
|
1991
|
+
case "ascii":
|
|
1992
|
+
case "binary":
|
|
1993
|
+
case "base64":
|
|
1994
|
+
case "raw":
|
|
1995
|
+
case "ucs2":
|
|
1996
|
+
case "ucs-2":
|
|
1997
|
+
case "utf16le":
|
|
1998
|
+
case "utf-16le":
|
|
1999
|
+
return true;
|
|
2000
|
+
default:
|
|
2001
|
+
return false;
|
|
2002
|
+
}
|
|
2003
|
+
}, f.isBuffer = function(e3) {
|
|
2004
|
+
return !(null == e3 || !e3._isBuffer);
|
|
2005
|
+
}, f.byteLength = function(e3, t2) {
|
|
2006
|
+
var n2;
|
|
2007
|
+
switch (e3 += "", t2 || "utf8") {
|
|
2008
|
+
case "hex":
|
|
2009
|
+
n2 = e3.length / 2;
|
|
2010
|
+
break;
|
|
2011
|
+
case "utf8":
|
|
2012
|
+
case "utf-8":
|
|
2013
|
+
n2 = T(e3).length;
|
|
2014
|
+
break;
|
|
2015
|
+
case "ascii":
|
|
2016
|
+
case "binary":
|
|
2017
|
+
case "raw":
|
|
2018
|
+
n2 = e3.length;
|
|
2019
|
+
break;
|
|
2020
|
+
case "base64":
|
|
2021
|
+
n2 = M(e3).length;
|
|
2022
|
+
break;
|
|
2023
|
+
case "ucs2":
|
|
2024
|
+
case "ucs-2":
|
|
2025
|
+
case "utf16le":
|
|
2026
|
+
case "utf-16le":
|
|
2027
|
+
n2 = 2 * e3.length;
|
|
2028
|
+
break;
|
|
2029
|
+
default:
|
|
2030
|
+
throw new Error("Unknown encoding");
|
|
2031
|
+
}
|
|
2032
|
+
return n2;
|
|
2033
|
+
}, f.concat = function(e3, t2) {
|
|
2034
|
+
if (d(C(e3), "Usage: Buffer.concat(list, [totalLength])\nlist should be an Array."), 0 === e3.length) return new f(0);
|
|
2035
|
+
if (1 === e3.length) return e3[0];
|
|
2036
|
+
if ("number" != typeof t2) for (o2 = t2 = 0; o2 < e3.length; o2++) t2 += e3[o2].length;
|
|
2037
|
+
for (var n2 = new f(t2), r2 = 0, o2 = 0; o2 < e3.length; o2++) {
|
|
2038
|
+
var i2 = e3[o2];
|
|
2039
|
+
i2.copy(n2, r2), r2 += i2.length;
|
|
2040
|
+
}
|
|
2041
|
+
return n2;
|
|
2042
|
+
}, f.prototype.write = function(e3, t2, n2, r2) {
|
|
2043
|
+
isFinite(t2) ? isFinite(n2) || (r2 = n2, n2 = void 0) : (a2 = r2, r2 = t2, t2 = n2, n2 = a2), t2 = Number(t2) || 0;
|
|
2044
|
+
var o2, i2, u2, s2, a2 = this.length - t2;
|
|
2045
|
+
switch ((!n2 || a2 < (n2 = Number(n2))) && (n2 = a2), r2 = String(r2 || "utf8").toLowerCase()) {
|
|
2046
|
+
case "hex":
|
|
2047
|
+
o2 = function(e4, t3, n3, r3) {
|
|
2048
|
+
n3 = Number(n3) || 0;
|
|
2049
|
+
var o3 = e4.length - n3;
|
|
2050
|
+
(!r3 || o3 < (r3 = Number(r3))) && (r3 = o3), d((o3 = t3.length) % 2 == 0, "Invalid hex string"), o3 / 2 < r3 && (r3 = o3 / 2);
|
|
2051
|
+
for (var i3 = 0; i3 < r3; i3++) {
|
|
2052
|
+
var u3 = parseInt(t3.substr(2 * i3, 2), 16);
|
|
2053
|
+
d(!isNaN(u3), "Invalid hex string"), e4[n3 + i3] = u3;
|
|
2054
|
+
}
|
|
2055
|
+
return f._charsWritten = 2 * i3, i3;
|
|
2056
|
+
}(this, e3, t2, n2);
|
|
2057
|
+
break;
|
|
2058
|
+
case "utf8":
|
|
2059
|
+
case "utf-8":
|
|
2060
|
+
i2 = this, u2 = t2, s2 = n2, o2 = f._charsWritten = c(T(e3), i2, u2, s2);
|
|
2061
|
+
break;
|
|
2062
|
+
case "ascii":
|
|
2063
|
+
case "binary":
|
|
2064
|
+
o2 = b(this, e3, t2, n2);
|
|
2065
|
+
break;
|
|
2066
|
+
case "base64":
|
|
2067
|
+
i2 = this, u2 = t2, s2 = n2, o2 = f._charsWritten = c(M(e3), i2, u2, s2);
|
|
2068
|
+
break;
|
|
2069
|
+
case "ucs2":
|
|
2070
|
+
case "ucs-2":
|
|
2071
|
+
case "utf16le":
|
|
2072
|
+
case "utf-16le":
|
|
2073
|
+
o2 = m(this, e3, t2, n2);
|
|
2074
|
+
break;
|
|
2075
|
+
default:
|
|
2076
|
+
throw new Error("Unknown encoding");
|
|
2077
|
+
}
|
|
2078
|
+
return o2;
|
|
2079
|
+
}, f.prototype.toString = function(e3, t2, n2) {
|
|
2080
|
+
var r2, o2, i2, u2, s2 = this;
|
|
2081
|
+
if (e3 = String(e3 || "utf8").toLowerCase(), t2 = Number(t2) || 0, (n2 = void 0 !== n2 ? Number(n2) : s2.length) === t2) return "";
|
|
2082
|
+
switch (e3) {
|
|
2083
|
+
case "hex":
|
|
2084
|
+
r2 = function(e4, t3, n3) {
|
|
2085
|
+
var r3 = e4.length;
|
|
2086
|
+
(!t3 || t3 < 0) && (t3 = 0);
|
|
2087
|
+
(!n3 || n3 < 0 || r3 < n3) && (n3 = r3);
|
|
2088
|
+
for (var o3 = "", i3 = t3; i3 < n3; i3++) o3 += k(e4[i3]);
|
|
2089
|
+
return o3;
|
|
2090
|
+
}(s2, t2, n2);
|
|
2091
|
+
break;
|
|
2092
|
+
case "utf8":
|
|
2093
|
+
case "utf-8":
|
|
2094
|
+
r2 = function(e4, t3, n3) {
|
|
2095
|
+
var r3 = "", o3 = "";
|
|
2096
|
+
n3 = Math.min(e4.length, n3);
|
|
2097
|
+
for (var i3 = t3; i3 < n3; i3++) e4[i3] <= 127 ? (r3 += N(o3) + String.fromCharCode(e4[i3]), o3 = "") : o3 += "%" + e4[i3].toString(16);
|
|
2098
|
+
return r3 + N(o3);
|
|
2099
|
+
}(s2, t2, n2);
|
|
2100
|
+
break;
|
|
2101
|
+
case "ascii":
|
|
2102
|
+
case "binary":
|
|
2103
|
+
r2 = v(s2, t2, n2);
|
|
2104
|
+
break;
|
|
2105
|
+
case "base64":
|
|
2106
|
+
o2 = s2, u2 = n2, r2 = 0 === (i2 = t2) && u2 === o2.length ? a.fromByteArray(o2) : a.fromByteArray(o2.slice(i2, u2));
|
|
2107
|
+
break;
|
|
2108
|
+
case "ucs2":
|
|
2109
|
+
case "ucs-2":
|
|
2110
|
+
case "utf16le":
|
|
2111
|
+
case "utf-16le":
|
|
2112
|
+
r2 = function(e4, t3, n3) {
|
|
2113
|
+
for (var r3 = e4.slice(t3, n3), o3 = "", i3 = 0; i3 < r3.length; i3 += 2) o3 += String.fromCharCode(r3[i3] + 256 * r3[i3 + 1]);
|
|
2114
|
+
return o3;
|
|
2115
|
+
}(s2, t2, n2);
|
|
2116
|
+
break;
|
|
2117
|
+
default:
|
|
2118
|
+
throw new Error("Unknown encoding");
|
|
2119
|
+
}
|
|
2120
|
+
return r2;
|
|
2121
|
+
}, f.prototype.toJSON = function() {
|
|
2122
|
+
return { type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0) };
|
|
2123
|
+
}, f.prototype.copy = function(e3, t2, n2, r2) {
|
|
2124
|
+
if (t2 = t2 || 0, (r2 = r2 || 0 === r2 ? r2 : this.length) !== (n2 = n2 || 0) && 0 !== e3.length && 0 !== this.length) {
|
|
2125
|
+
d(n2 <= r2, "sourceEnd < sourceStart"), d(0 <= t2 && t2 < e3.length, "targetStart out of bounds"), d(0 <= n2 && n2 < this.length, "sourceStart out of bounds"), d(0 <= r2 && r2 <= this.length, "sourceEnd out of bounds"), r2 > this.length && (r2 = this.length);
|
|
2126
|
+
var o2 = (r2 = e3.length - t2 < r2 - n2 ? e3.length - t2 + n2 : r2) - n2;
|
|
2127
|
+
if (o2 < 100 || !f._useTypedArrays) for (var i2 = 0; i2 < o2; i2++) e3[i2 + t2] = this[i2 + n2];
|
|
2128
|
+
else e3._set(this.subarray(n2, n2 + o2), t2);
|
|
2129
|
+
}
|
|
2130
|
+
}, f.prototype.slice = function(e3, t2) {
|
|
2131
|
+
var n2 = this.length;
|
|
2132
|
+
if (e3 = S(e3, n2, 0), t2 = S(t2, n2, n2), f._useTypedArrays) return f._augment(this.subarray(e3, t2));
|
|
2133
|
+
for (var r2 = t2 - e3, o2 = new f(r2, void 0, true), i2 = 0; i2 < r2; i2++) o2[i2] = this[i2 + e3];
|
|
2134
|
+
return o2;
|
|
2135
|
+
}, f.prototype.get = function(e3) {
|
|
2136
|
+
return console.log(".get() is deprecated. Access using array indexes instead."), this.readUInt8(e3);
|
|
2137
|
+
}, f.prototype.set = function(e3, t2) {
|
|
2138
|
+
return console.log(".set() is deprecated. Access using array indexes instead."), this.writeUInt8(e3, t2);
|
|
2139
|
+
}, f.prototype.readUInt8 = function(e3, t2) {
|
|
2140
|
+
if (t2 || (d(null != e3, "missing offset"), d(e3 < this.length, "Trying to read beyond buffer length")), !(e3 >= this.length)) return this[e3];
|
|
2141
|
+
}, f.prototype.readUInt16LE = function(e3, t2) {
|
|
2142
|
+
return o(this, e3, true, t2);
|
|
2143
|
+
}, f.prototype.readUInt16BE = function(e3, t2) {
|
|
2144
|
+
return o(this, e3, false, t2);
|
|
2145
|
+
}, f.prototype.readUInt32LE = function(e3, t2) {
|
|
2146
|
+
return u(this, e3, true, t2);
|
|
2147
|
+
}, f.prototype.readUInt32BE = function(e3, t2) {
|
|
2148
|
+
return u(this, e3, false, t2);
|
|
2149
|
+
}, f.prototype.readInt8 = function(e3, t2) {
|
|
2150
|
+
if (t2 || (d(null != e3, "missing offset"), d(e3 < this.length, "Trying to read beyond buffer length")), !(e3 >= this.length)) return 128 & this[e3] ? -1 * (255 - this[e3] + 1) : this[e3];
|
|
2151
|
+
}, f.prototype.readInt16LE = function(e3, t2) {
|
|
2152
|
+
return _(this, e3, true, t2);
|
|
2153
|
+
}, f.prototype.readInt16BE = function(e3, t2) {
|
|
2154
|
+
return _(this, e3, false, t2);
|
|
2155
|
+
}, f.prototype.readInt32LE = function(e3, t2) {
|
|
2156
|
+
return E(this, e3, true, t2);
|
|
2157
|
+
}, f.prototype.readInt32BE = function(e3, t2) {
|
|
2158
|
+
return E(this, e3, false, t2);
|
|
2159
|
+
}, f.prototype.readFloatLE = function(e3, t2) {
|
|
2160
|
+
return I(this, e3, true, t2);
|
|
2161
|
+
}, f.prototype.readFloatBE = function(e3, t2) {
|
|
2162
|
+
return I(this, e3, false, t2);
|
|
2163
|
+
}, f.prototype.readDoubleLE = function(e3, t2) {
|
|
2164
|
+
return A(this, e3, true, t2);
|
|
2165
|
+
}, f.prototype.readDoubleBE = function(e3, t2) {
|
|
2166
|
+
return A(this, e3, false, t2);
|
|
2167
|
+
}, f.prototype.writeUInt8 = function(e3, t2, n2) {
|
|
2168
|
+
n2 || (d(null != e3, "missing value"), d(null != t2, "missing offset"), d(t2 < this.length, "trying to write beyond buffer length"), Y(e3, 255)), t2 >= this.length || (this[t2] = e3);
|
|
2169
|
+
}, f.prototype.writeUInt16LE = function(e3, t2, n2) {
|
|
2170
|
+
s(this, e3, t2, true, n2);
|
|
2171
|
+
}, f.prototype.writeUInt16BE = function(e3, t2, n2) {
|
|
2172
|
+
s(this, e3, t2, false, n2);
|
|
2173
|
+
}, f.prototype.writeUInt32LE = function(e3, t2, n2) {
|
|
2174
|
+
l(this, e3, t2, true, n2);
|
|
2175
|
+
}, f.prototype.writeUInt32BE = function(e3, t2, n2) {
|
|
2176
|
+
l(this, e3, t2, false, n2);
|
|
2177
|
+
}, f.prototype.writeInt8 = function(e3, t2, n2) {
|
|
2178
|
+
n2 || (d(null != e3, "missing value"), d(null != t2, "missing offset"), d(t2 < this.length, "Trying to write beyond buffer length"), F(e3, 127, -128)), t2 >= this.length || (0 <= e3 ? this.writeUInt8(e3, t2, n2) : this.writeUInt8(255 + e3 + 1, t2, n2));
|
|
2179
|
+
}, f.prototype.writeInt16LE = function(e3, t2, n2) {
|
|
2180
|
+
B(this, e3, t2, true, n2);
|
|
2181
|
+
}, f.prototype.writeInt16BE = function(e3, t2, n2) {
|
|
2182
|
+
B(this, e3, t2, false, n2);
|
|
2183
|
+
}, f.prototype.writeInt32LE = function(e3, t2, n2) {
|
|
2184
|
+
L(this, e3, t2, true, n2);
|
|
2185
|
+
}, f.prototype.writeInt32BE = function(e3, t2, n2) {
|
|
2186
|
+
L(this, e3, t2, false, n2);
|
|
2187
|
+
}, f.prototype.writeFloatLE = function(e3, t2, n2) {
|
|
2188
|
+
U(this, e3, t2, true, n2);
|
|
2189
|
+
}, f.prototype.writeFloatBE = function(e3, t2, n2) {
|
|
2190
|
+
U(this, e3, t2, false, n2);
|
|
2191
|
+
}, f.prototype.writeDoubleLE = function(e3, t2, n2) {
|
|
2192
|
+
x(this, e3, t2, true, n2);
|
|
2193
|
+
}, f.prototype.writeDoubleBE = function(e3, t2, n2) {
|
|
2194
|
+
x(this, e3, t2, false, n2);
|
|
2195
|
+
}, f.prototype.fill = function(e3, t2, n2) {
|
|
2196
|
+
if (t2 = t2 || 0, n2 = n2 || this.length, d("number" == typeof (e3 = "string" == typeof (e3 = e3 || 0) ? e3.charCodeAt(0) : e3) && !isNaN(e3), "value is not a number"), d(t2 <= n2, "end < start"), n2 !== t2 && 0 !== this.length) {
|
|
2197
|
+
d(0 <= t2 && t2 < this.length, "start out of bounds"), d(0 <= n2 && n2 <= this.length, "end out of bounds");
|
|
2198
|
+
for (var r2 = t2; r2 < n2; r2++) this[r2] = e3;
|
|
2199
|
+
}
|
|
2200
|
+
}, f.prototype.inspect = function() {
|
|
2201
|
+
for (var e3 = [], t2 = this.length, n2 = 0; n2 < t2; n2++) if (e3[n2] = k(this[n2]), n2 === H.INSPECT_MAX_BYTES) {
|
|
2202
|
+
e3[n2 + 1] = "...";
|
|
2203
|
+
break;
|
|
2204
|
+
}
|
|
2205
|
+
return "<Buffer " + e3.join(" ") + ">";
|
|
2206
|
+
}, f.prototype.toArrayBuffer = function() {
|
|
2207
|
+
if ("undefined" == typeof Uint8Array) throw new Error("Buffer.toArrayBuffer not supported in this browser");
|
|
2208
|
+
if (f._useTypedArrays) return new f(this).buffer;
|
|
2209
|
+
for (var e3 = new Uint8Array(this.length), t2 = 0, n2 = e3.length; t2 < n2; t2 += 1) e3[t2] = this[t2];
|
|
2210
|
+
return e3.buffer;
|
|
2211
|
+
};
|
|
2212
|
+
var t = f.prototype;
|
|
2213
|
+
function S(e3, t2, n2) {
|
|
2214
|
+
return "number" != typeof e3 ? n2 : t2 <= (e3 = ~~e3) ? t2 : 0 <= e3 || 0 <= (e3 += t2) ? e3 : 0;
|
|
2215
|
+
}
|
|
2216
|
+
function j(e3) {
|
|
2217
|
+
return (e3 = ~~Math.ceil(+e3)) < 0 ? 0 : e3;
|
|
2218
|
+
}
|
|
2219
|
+
function C(e3) {
|
|
2220
|
+
return (Array.isArray || function(e4) {
|
|
2221
|
+
return "[object Array]" === Object.prototype.toString.call(e4);
|
|
2222
|
+
})(e3);
|
|
2223
|
+
}
|
|
2224
|
+
function k(e3) {
|
|
2225
|
+
return e3 < 16 ? "0" + e3.toString(16) : e3.toString(16);
|
|
2226
|
+
}
|
|
2227
|
+
function T(e3) {
|
|
2228
|
+
for (var t2 = [], n2 = 0; n2 < e3.length; n2++) {
|
|
2229
|
+
var r2 = e3.charCodeAt(n2);
|
|
2230
|
+
if (r2 <= 127) t2.push(e3.charCodeAt(n2));
|
|
2231
|
+
else for (var o2 = n2, i2 = (55296 <= r2 && r2 <= 57343 && n2++, encodeURIComponent(e3.slice(o2, n2 + 1)).substr(1).split("%")), u2 = 0; u2 < i2.length; u2++) t2.push(parseInt(i2[u2], 16));
|
|
2232
|
+
}
|
|
2233
|
+
return t2;
|
|
2234
|
+
}
|
|
2235
|
+
function M(e3) {
|
|
2236
|
+
return a.toByteArray(e3);
|
|
2237
|
+
}
|
|
2238
|
+
function c(e3, t2, n2, r2) {
|
|
2239
|
+
for (var o2 = 0; o2 < r2 && !(o2 + n2 >= t2.length || o2 >= e3.length); o2++) t2[o2 + n2] = e3[o2];
|
|
2240
|
+
return o2;
|
|
2241
|
+
}
|
|
2242
|
+
function N(e3) {
|
|
2243
|
+
try {
|
|
2244
|
+
return decodeURIComponent(e3);
|
|
2245
|
+
} catch (e4) {
|
|
2246
|
+
return String.fromCharCode(65533);
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
function Y(e3, t2) {
|
|
2250
|
+
d("number" == typeof e3, "cannot write a non-number as a number"), d(0 <= e3, "specified a negative value for writing an unsigned value"), d(e3 <= t2, "value is larger than maximum value for type"), d(Math.floor(e3) === e3, "value has a fractional component");
|
|
2251
|
+
}
|
|
2252
|
+
function F(e3, t2, n2) {
|
|
2253
|
+
d("number" == typeof e3, "cannot write a non-number as a number"), d(e3 <= t2, "value larger than maximum allowed value"), d(n2 <= e3, "value smaller than minimum allowed value"), d(Math.floor(e3) === e3, "value has a fractional component");
|
|
2254
|
+
}
|
|
2255
|
+
function D(e3, t2, n2) {
|
|
2256
|
+
d("number" == typeof e3, "cannot write a non-number as a number"), d(e3 <= t2, "value larger than maximum allowed value"), d(n2 <= e3, "value smaller than minimum allowed value");
|
|
2257
|
+
}
|
|
2258
|
+
function d(e3, t2) {
|
|
2259
|
+
if (!e3) throw new Error(t2 || "Failed assertion");
|
|
2260
|
+
}
|
|
2261
|
+
f._augment = function(e3) {
|
|
2262
|
+
return e3._isBuffer = true, e3._get = e3.get, e3._set = e3.set, e3.get = t.get, e3.set = t.set, e3.write = t.write, e3.toString = t.toString, e3.toLocaleString = t.toString, e3.toJSON = t.toJSON, e3.copy = t.copy, e3.slice = t.slice, e3.readUInt8 = t.readUInt8, e3.readUInt16LE = t.readUInt16LE, e3.readUInt16BE = t.readUInt16BE, e3.readUInt32LE = t.readUInt32LE, e3.readUInt32BE = t.readUInt32BE, e3.readInt8 = t.readInt8, e3.readInt16LE = t.readInt16LE, e3.readInt16BE = t.readInt16BE, e3.readInt32LE = t.readInt32LE, e3.readInt32BE = t.readInt32BE, e3.readFloatLE = t.readFloatLE, e3.readFloatBE = t.readFloatBE, e3.readDoubleLE = t.readDoubleLE, e3.readDoubleBE = t.readDoubleBE, e3.writeUInt8 = t.writeUInt8, e3.writeUInt16LE = t.writeUInt16LE, e3.writeUInt16BE = t.writeUInt16BE, e3.writeUInt32LE = t.writeUInt32LE, e3.writeUInt32BE = t.writeUInt32BE, e3.writeInt8 = t.writeInt8, e3.writeInt16LE = t.writeInt16LE, e3.writeInt16BE = t.writeInt16BE, e3.writeInt32LE = t.writeInt32LE, e3.writeInt32BE = t.writeInt32BE, e3.writeFloatLE = t.writeFloatLE, e3.writeFloatBE = t.writeFloatBE, e3.writeDoubleLE = t.writeDoubleLE, e3.writeDoubleBE = t.writeDoubleBE, e3.fill = t.fill, e3.inspect = t.inspect, e3.toArrayBuffer = t.toArrayBuffer, e3;
|
|
2263
|
+
};
|
|
2264
|
+
}).call(this, O("lYpoI2"), "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}, O("buffer").Buffer, arguments[3], arguments[4], arguments[5], arguments[6], "/node_modules/gulp-browserify/node_modules/buffer/index.js", "/node_modules/gulp-browserify/node_modules/buffer");
|
|
2265
|
+
}, { "base64-js": 2, buffer: 3, ieee754: 10, lYpoI2: 11 }], 4: [function(c, d, e) {
|
|
2266
|
+
!(function(e2, t, a, n, r, o, i, u, s) {
|
|
2267
|
+
var a = c("buffer").Buffer, f = 4, l = new a(f);
|
|
2268
|
+
l.fill(0);
|
|
2269
|
+
d.exports = { hash: function(e3, t2, n2, r2) {
|
|
2270
|
+
for (var o2 = t2(function(e4, t3) {
|
|
2271
|
+
e4.length % f != 0 && (n3 = e4.length + (f - e4.length % f), e4 = a.concat([e4, l], n3));
|
|
2272
|
+
for (var n3, r3 = [], o3 = t3 ? e4.readInt32BE : e4.readInt32LE, i3 = 0; i3 < e4.length; i3 += f) r3.push(o3.call(e4, i3));
|
|
2273
|
+
return r3;
|
|
2274
|
+
}(e3 = a.isBuffer(e3) ? e3 : new a(e3), r2), 8 * e3.length), t2 = r2, i2 = new a(n2), u2 = t2 ? i2.writeInt32BE : i2.writeInt32LE, s2 = 0; s2 < o2.length; s2++) u2.call(i2, o2[s2], 4 * s2, true);
|
|
2275
|
+
return i2;
|
|
2276
|
+
} };
|
|
2277
|
+
}).call(this, c("lYpoI2"), "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}, c("buffer").Buffer, arguments[3], arguments[4], arguments[5], arguments[6], "/node_modules/gulp-browserify/node_modules/crypto-browserify/helpers.js", "/node_modules/gulp-browserify/node_modules/crypto-browserify");
|
|
2278
|
+
}, { buffer: 3, lYpoI2: 11 }], 5: [function(v, e, _) {
|
|
2279
|
+
!(function(l, c, u, d, h, p, g, y, w) {
|
|
2280
|
+
var u = v("buffer").Buffer, e2 = v("./sha"), t = v("./sha256"), n = v("./rng"), b = { sha1: e2, sha256: t, md5: v("./md5") }, s = 64, a = new u(s);
|
|
2281
|
+
function r(e3, n2) {
|
|
2282
|
+
var r2 = b[e3 = e3 || "sha1"], o2 = [];
|
|
2283
|
+
return r2 || i("algorithm:", e3, "is not yet supported"), { update: function(e4) {
|
|
2284
|
+
return u.isBuffer(e4) || (e4 = new u(e4)), o2.push(e4), e4.length, this;
|
|
2285
|
+
}, digest: function(e4) {
|
|
2286
|
+
var t2 = u.concat(o2), t2 = n2 ? function(e5, t3, n3) {
|
|
2287
|
+
u.isBuffer(t3) || (t3 = new u(t3)), u.isBuffer(n3) || (n3 = new u(n3)), t3.length > s ? t3 = e5(t3) : t3.length < s && (t3 = u.concat([t3, a], s));
|
|
2288
|
+
for (var r3 = new u(s), o3 = new u(s), i2 = 0; i2 < s; i2++) r3[i2] = 54 ^ t3[i2], o3[i2] = 92 ^ t3[i2];
|
|
2289
|
+
return n3 = e5(u.concat([r3, n3])), e5(u.concat([o3, n3]));
|
|
2290
|
+
}(r2, n2, t2) : r2(t2);
|
|
2291
|
+
return o2 = null, e4 ? t2.toString(e4) : t2;
|
|
2292
|
+
} };
|
|
2293
|
+
}
|
|
2294
|
+
function i() {
|
|
2295
|
+
var e3 = [].slice.call(arguments).join(" ");
|
|
2296
|
+
throw new Error([e3, "we accept pull requests", "http://github.com/dominictarr/crypto-browserify"].join("\n"));
|
|
2297
|
+
}
|
|
2298
|
+
a.fill(0), _.createHash = function(e3) {
|
|
2299
|
+
return r(e3);
|
|
2300
|
+
}, _.createHmac = r, _.randomBytes = function(e3, t2) {
|
|
2301
|
+
if (!t2 || !t2.call) return new u(n(e3));
|
|
2302
|
+
try {
|
|
2303
|
+
t2.call(this, void 0, new u(n(e3)));
|
|
2304
|
+
} catch (e4) {
|
|
2305
|
+
t2(e4);
|
|
2306
|
+
}
|
|
2307
|
+
};
|
|
2308
|
+
var o, f = ["createCredentials", "createCipher", "createCipheriv", "createDecipher", "createDecipheriv", "createSign", "createVerify", "createDiffieHellman", "pbkdf2"], m = function(e3) {
|
|
2309
|
+
_[e3] = function() {
|
|
2310
|
+
i("sorry,", e3, "is not implemented yet");
|
|
2311
|
+
};
|
|
2312
|
+
};
|
|
2313
|
+
for (o in f) m(f[o]);
|
|
2314
|
+
}).call(this, v("lYpoI2"), "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}, v("buffer").Buffer, arguments[3], arguments[4], arguments[5], arguments[6], "/node_modules/gulp-browserify/node_modules/crypto-browserify/index.js", "/node_modules/gulp-browserify/node_modules/crypto-browserify");
|
|
2315
|
+
}, { "./md5": 6, "./rng": 7, "./sha": 8, "./sha256": 9, buffer: 3, lYpoI2: 11 }], 6: [function(w, b, e) {
|
|
2316
|
+
!(function(e2, r, o, i, u, a, f, l, y) {
|
|
2317
|
+
var t = w("./helpers");
|
|
2318
|
+
function n(e3, t2) {
|
|
2319
|
+
e3[t2 >> 5] |= 128 << t2 % 32, e3[14 + (t2 + 64 >>> 9 << 4)] = t2;
|
|
2320
|
+
for (var n2 = 1732584193, r2 = -271733879, o2 = -1732584194, i2 = 271733878, u2 = 0; u2 < e3.length; u2 += 16) {
|
|
2321
|
+
var s2 = n2, a2 = r2, f2 = o2, l2 = i2, n2 = c(n2, r2, o2, i2, e3[u2 + 0], 7, -680876936), i2 = c(i2, n2, r2, o2, e3[u2 + 1], 12, -389564586), o2 = c(o2, i2, n2, r2, e3[u2 + 2], 17, 606105819), r2 = c(r2, o2, i2, n2, e3[u2 + 3], 22, -1044525330);
|
|
2322
|
+
n2 = c(n2, r2, o2, i2, e3[u2 + 4], 7, -176418897), i2 = c(i2, n2, r2, o2, e3[u2 + 5], 12, 1200080426), o2 = c(o2, i2, n2, r2, e3[u2 + 6], 17, -1473231341), r2 = c(r2, o2, i2, n2, e3[u2 + 7], 22, -45705983), n2 = c(n2, r2, o2, i2, e3[u2 + 8], 7, 1770035416), i2 = c(i2, n2, r2, o2, e3[u2 + 9], 12, -1958414417), o2 = c(o2, i2, n2, r2, e3[u2 + 10], 17, -42063), r2 = c(r2, o2, i2, n2, e3[u2 + 11], 22, -1990404162), n2 = c(n2, r2, o2, i2, e3[u2 + 12], 7, 1804603682), i2 = c(i2, n2, r2, o2, e3[u2 + 13], 12, -40341101), o2 = c(o2, i2, n2, r2, e3[u2 + 14], 17, -1502002290), n2 = d(n2, r2 = c(r2, o2, i2, n2, e3[u2 + 15], 22, 1236535329), o2, i2, e3[u2 + 1], 5, -165796510), i2 = d(i2, n2, r2, o2, e3[u2 + 6], 9, -1069501632), o2 = d(o2, i2, n2, r2, e3[u2 + 11], 14, 643717713), r2 = d(r2, o2, i2, n2, e3[u2 + 0], 20, -373897302), n2 = d(n2, r2, o2, i2, e3[u2 + 5], 5, -701558691), i2 = d(i2, n2, r2, o2, e3[u2 + 10], 9, 38016083), o2 = d(o2, i2, n2, r2, e3[u2 + 15], 14, -660478335), r2 = d(r2, o2, i2, n2, e3[u2 + 4], 20, -405537848), n2 = d(n2, r2, o2, i2, e3[u2 + 9], 5, 568446438), i2 = d(i2, n2, r2, o2, e3[u2 + 14], 9, -1019803690), o2 = d(o2, i2, n2, r2, e3[u2 + 3], 14, -187363961), r2 = d(r2, o2, i2, n2, e3[u2 + 8], 20, 1163531501), n2 = d(n2, r2, o2, i2, e3[u2 + 13], 5, -1444681467), i2 = d(i2, n2, r2, o2, e3[u2 + 2], 9, -51403784), o2 = d(o2, i2, n2, r2, e3[u2 + 7], 14, 1735328473), n2 = h(n2, r2 = d(r2, o2, i2, n2, e3[u2 + 12], 20, -1926607734), o2, i2, e3[u2 + 5], 4, -378558), i2 = h(i2, n2, r2, o2, e3[u2 + 8], 11, -2022574463), o2 = h(o2, i2, n2, r2, e3[u2 + 11], 16, 1839030562), r2 = h(r2, o2, i2, n2, e3[u2 + 14], 23, -35309556), n2 = h(n2, r2, o2, i2, e3[u2 + 1], 4, -1530992060), i2 = h(i2, n2, r2, o2, e3[u2 + 4], 11, 1272893353), o2 = h(o2, i2, n2, r2, e3[u2 + 7], 16, -155497632), r2 = h(r2, o2, i2, n2, e3[u2 + 10], 23, -1094730640), n2 = h(n2, r2, o2, i2, e3[u2 + 13], 4, 681279174), i2 = h(i2, n2, r2, o2, e3[u2 + 0], 11, -358537222), o2 = h(o2, i2, n2, r2, e3[u2 + 3], 16, -722521979), r2 = h(r2, o2, i2, n2, e3[u2 + 6], 23, 76029189), n2 = h(n2, r2, o2, i2, e3[u2 + 9], 4, -640364487), i2 = h(i2, n2, r2, o2, e3[u2 + 12], 11, -421815835), o2 = h(o2, i2, n2, r2, e3[u2 + 15], 16, 530742520), n2 = p(n2, r2 = h(r2, o2, i2, n2, e3[u2 + 2], 23, -995338651), o2, i2, e3[u2 + 0], 6, -198630844), i2 = p(i2, n2, r2, o2, e3[u2 + 7], 10, 1126891415), o2 = p(o2, i2, n2, r2, e3[u2 + 14], 15, -1416354905), r2 = p(r2, o2, i2, n2, e3[u2 + 5], 21, -57434055), n2 = p(n2, r2, o2, i2, e3[u2 + 12], 6, 1700485571), i2 = p(i2, n2, r2, o2, e3[u2 + 3], 10, -1894986606), o2 = p(o2, i2, n2, r2, e3[u2 + 10], 15, -1051523), r2 = p(r2, o2, i2, n2, e3[u2 + 1], 21, -2054922799), n2 = p(n2, r2, o2, i2, e3[u2 + 8], 6, 1873313359), i2 = p(i2, n2, r2, o2, e3[u2 + 15], 10, -30611744), o2 = p(o2, i2, n2, r2, e3[u2 + 6], 15, -1560198380), r2 = p(r2, o2, i2, n2, e3[u2 + 13], 21, 1309151649), n2 = p(n2, r2, o2, i2, e3[u2 + 4], 6, -145523070), i2 = p(i2, n2, r2, o2, e3[u2 + 11], 10, -1120210379), o2 = p(o2, i2, n2, r2, e3[u2 + 2], 15, 718787259), r2 = p(r2, o2, i2, n2, e3[u2 + 9], 21, -343485551), n2 = g(n2, s2), r2 = g(r2, a2), o2 = g(o2, f2), i2 = g(i2, l2);
|
|
2323
|
+
}
|
|
2324
|
+
return Array(n2, r2, o2, i2);
|
|
2325
|
+
}
|
|
2326
|
+
function s(e3, t2, n2, r2, o2, i2) {
|
|
2327
|
+
return g((t2 = g(g(t2, e3), g(r2, i2))) << o2 | t2 >>> 32 - o2, n2);
|
|
2328
|
+
}
|
|
2329
|
+
function c(e3, t2, n2, r2, o2, i2, u2) {
|
|
2330
|
+
return s(t2 & n2 | ~t2 & r2, e3, t2, o2, i2, u2);
|
|
2331
|
+
}
|
|
2332
|
+
function d(e3, t2, n2, r2, o2, i2, u2) {
|
|
2333
|
+
return s(t2 & r2 | n2 & ~r2, e3, t2, o2, i2, u2);
|
|
2334
|
+
}
|
|
2335
|
+
function h(e3, t2, n2, r2, o2, i2, u2) {
|
|
2336
|
+
return s(t2 ^ n2 ^ r2, e3, t2, o2, i2, u2);
|
|
2337
|
+
}
|
|
2338
|
+
function p(e3, t2, n2, r2, o2, i2, u2) {
|
|
2339
|
+
return s(n2 ^ (t2 | ~r2), e3, t2, o2, i2, u2);
|
|
2340
|
+
}
|
|
2341
|
+
function g(e3, t2) {
|
|
2342
|
+
var n2 = (65535 & e3) + (65535 & t2);
|
|
2343
|
+
return (e3 >> 16) + (t2 >> 16) + (n2 >> 16) << 16 | 65535 & n2;
|
|
2344
|
+
}
|
|
2345
|
+
b.exports = function(e3) {
|
|
2346
|
+
return t.hash(e3, n, 16);
|
|
2347
|
+
};
|
|
2348
|
+
}).call(this, w("lYpoI2"), "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}, w("buffer").Buffer, arguments[3], arguments[4], arguments[5], arguments[6], "/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js", "/node_modules/gulp-browserify/node_modules/crypto-browserify");
|
|
2349
|
+
}, { "./helpers": 4, buffer: 3, lYpoI2: 11 }], 7: [function(e, l, t) {
|
|
2350
|
+
!(function(e2, t2, n, r, o, i, u, s, f) {
|
|
2351
|
+
l.exports = function(e3) {
|
|
2352
|
+
for (var t3, n2 = new Array(e3), r2 = 0; r2 < e3; r2++) 0 == (3 & r2) && (t3 = 4294967296 * Math.random()), n2[r2] = t3 >>> ((3 & r2) << 3) & 255;
|
|
2353
|
+
return n2;
|
|
2354
|
+
};
|
|
2355
|
+
}).call(this, e("lYpoI2"), "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}, e("buffer").Buffer, arguments[3], arguments[4], arguments[5], arguments[6], "/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js", "/node_modules/gulp-browserify/node_modules/crypto-browserify");
|
|
2356
|
+
}, { buffer: 3, lYpoI2: 11 }], 8: [function(c, d, e) {
|
|
2357
|
+
!(function(e2, t, n, r, o, s, a, f, l) {
|
|
2358
|
+
var i = c("./helpers");
|
|
2359
|
+
function u(l2, c2) {
|
|
2360
|
+
l2[c2 >> 5] |= 128 << 24 - c2 % 32, l2[15 + (c2 + 64 >> 9 << 4)] = c2;
|
|
2361
|
+
for (var e3, t2, n2, r2 = Array(80), o2 = 1732584193, i2 = -271733879, u2 = -1732584194, s2 = 271733878, d2 = -1009589776, h = 0; h < l2.length; h += 16) {
|
|
2362
|
+
for (var p = o2, g = i2, y = u2, w = s2, b = d2, a2 = 0; a2 < 80; a2++) {
|
|
2363
|
+
r2[a2] = a2 < 16 ? l2[h + a2] : v(r2[a2 - 3] ^ r2[a2 - 8] ^ r2[a2 - 14] ^ r2[a2 - 16], 1);
|
|
2364
|
+
var f2 = m(m(v(o2, 5), (f2 = i2, t2 = u2, n2 = s2, (e3 = a2) < 20 ? f2 & t2 | ~f2 & n2 : !(e3 < 40) && e3 < 60 ? f2 & t2 | f2 & n2 | t2 & n2 : f2 ^ t2 ^ n2)), m(m(d2, r2[a2]), (e3 = a2) < 20 ? 1518500249 : e3 < 40 ? 1859775393 : e3 < 60 ? -1894007588 : -899497514)), d2 = s2, s2 = u2, u2 = v(i2, 30), i2 = o2, o2 = f2;
|
|
2365
|
+
}
|
|
2366
|
+
o2 = m(o2, p), i2 = m(i2, g), u2 = m(u2, y), s2 = m(s2, w), d2 = m(d2, b);
|
|
2367
|
+
}
|
|
2368
|
+
return Array(o2, i2, u2, s2, d2);
|
|
2369
|
+
}
|
|
2370
|
+
function m(e3, t2) {
|
|
2371
|
+
var n2 = (65535 & e3) + (65535 & t2);
|
|
2372
|
+
return (e3 >> 16) + (t2 >> 16) + (n2 >> 16) << 16 | 65535 & n2;
|
|
2373
|
+
}
|
|
2374
|
+
function v(e3, t2) {
|
|
2375
|
+
return e3 << t2 | e3 >>> 32 - t2;
|
|
2376
|
+
}
|
|
2377
|
+
d.exports = function(e3) {
|
|
2378
|
+
return i.hash(e3, u, 20, true);
|
|
2379
|
+
};
|
|
2380
|
+
}).call(this, c("lYpoI2"), "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}, c("buffer").Buffer, arguments[3], arguments[4], arguments[5], arguments[6], "/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js", "/node_modules/gulp-browserify/node_modules/crypto-browserify");
|
|
2381
|
+
}, { "./helpers": 4, buffer: 3, lYpoI2: 11 }], 9: [function(c, d, e) {
|
|
2382
|
+
!(function(e2, t, n, r, u, s, a, f, l) {
|
|
2383
|
+
function b(e3, t2) {
|
|
2384
|
+
var n2 = (65535 & e3) + (65535 & t2);
|
|
2385
|
+
return (e3 >> 16) + (t2 >> 16) + (n2 >> 16) << 16 | 65535 & n2;
|
|
2386
|
+
}
|
|
2387
|
+
function o(e3, l2) {
|
|
2388
|
+
var c2, d2 = new Array(1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479, 3329325298), t2 = new Array(1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225), n2 = new Array(64);
|
|
2389
|
+
e3[l2 >> 5] |= 128 << 24 - l2 % 32, e3[15 + (l2 + 64 >> 9 << 4)] = l2;
|
|
2390
|
+
for (var r2, o2, h = 0; h < e3.length; h += 16) {
|
|
2391
|
+
for (var i2 = t2[0], u2 = t2[1], s2 = t2[2], p = t2[3], a2 = t2[4], g = t2[5], y = t2[6], w = t2[7], f2 = 0; f2 < 64; f2++) n2[f2] = f2 < 16 ? e3[f2 + h] : b(b(b((o2 = n2[f2 - 2], m(o2, 17) ^ m(o2, 19) ^ v(o2, 10)), n2[f2 - 7]), (o2 = n2[f2 - 15], m(o2, 7) ^ m(o2, 18) ^ v(o2, 3))), n2[f2 - 16]), c2 = b(b(b(b(w, m(o2 = a2, 6) ^ m(o2, 11) ^ m(o2, 25)), a2 & g ^ ~a2 & y), d2[f2]), n2[f2]), r2 = b(m(r2 = i2, 2) ^ m(r2, 13) ^ m(r2, 22), i2 & u2 ^ i2 & s2 ^ u2 & s2), w = y, y = g, g = a2, a2 = b(p, c2), p = s2, s2 = u2, u2 = i2, i2 = b(c2, r2);
|
|
2392
|
+
t2[0] = b(i2, t2[0]), t2[1] = b(u2, t2[1]), t2[2] = b(s2, t2[2]), t2[3] = b(p, t2[3]), t2[4] = b(a2, t2[4]), t2[5] = b(g, t2[5]), t2[6] = b(y, t2[6]), t2[7] = b(w, t2[7]);
|
|
2393
|
+
}
|
|
2394
|
+
return t2;
|
|
2395
|
+
}
|
|
2396
|
+
var i = c("./helpers"), m = function(e3, t2) {
|
|
2397
|
+
return e3 >>> t2 | e3 << 32 - t2;
|
|
2398
|
+
}, v = function(e3, t2) {
|
|
2399
|
+
return e3 >>> t2;
|
|
2400
|
+
};
|
|
2401
|
+
d.exports = function(e3) {
|
|
2402
|
+
return i.hash(e3, o, 32, true);
|
|
2403
|
+
};
|
|
2404
|
+
}).call(this, c("lYpoI2"), "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}, c("buffer").Buffer, arguments[3], arguments[4], arguments[5], arguments[6], "/node_modules/gulp-browserify/node_modules/crypto-browserify/sha256.js", "/node_modules/gulp-browserify/node_modules/crypto-browserify");
|
|
2405
|
+
}, { "./helpers": 4, buffer: 3, lYpoI2: 11 }], 10: [function(e, t, f) {
|
|
2406
|
+
!(function(e2, t2, n, r, o, i, u, s, a) {
|
|
2407
|
+
f.read = function(e3, t3, n2, r2, o2) {
|
|
2408
|
+
var i2, u2, l = 8 * o2 - r2 - 1, c = (1 << l) - 1, d = c >> 1, s2 = -7, a2 = n2 ? o2 - 1 : 0, f2 = n2 ? -1 : 1, o2 = e3[t3 + a2];
|
|
2409
|
+
for (a2 += f2, i2 = o2 & (1 << -s2) - 1, o2 >>= -s2, s2 += l; 0 < s2; i2 = 256 * i2 + e3[t3 + a2], a2 += f2, s2 -= 8) ;
|
|
2410
|
+
for (u2 = i2 & (1 << -s2) - 1, i2 >>= -s2, s2 += r2; 0 < s2; u2 = 256 * u2 + e3[t3 + a2], a2 += f2, s2 -= 8) ;
|
|
2411
|
+
if (0 === i2) i2 = 1 - d;
|
|
2412
|
+
else {
|
|
2413
|
+
if (i2 === c) return u2 ? NaN : 1 / 0 * (o2 ? -1 : 1);
|
|
2414
|
+
u2 += Math.pow(2, r2), i2 -= d;
|
|
2415
|
+
}
|
|
2416
|
+
return (o2 ? -1 : 1) * u2 * Math.pow(2, i2 - r2);
|
|
2417
|
+
}, f.write = function(e3, t3, l, n2, r2, c) {
|
|
2418
|
+
var o2, i2, u2 = 8 * c - r2 - 1, s2 = (1 << u2) - 1, a2 = s2 >> 1, d = 23 === r2 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, f2 = n2 ? 0 : c - 1, h = n2 ? 1 : -1, c = t3 < 0 || 0 === t3 && 1 / t3 < 0 ? 1 : 0;
|
|
2419
|
+
for (t3 = Math.abs(t3), isNaN(t3) || t3 === 1 / 0 ? (i2 = isNaN(t3) ? 1 : 0, o2 = s2) : (o2 = Math.floor(Math.log(t3) / Math.LN2), t3 * (n2 = Math.pow(2, -o2)) < 1 && (o2--, n2 *= 2), 2 <= (t3 += 1 <= o2 + a2 ? d / n2 : d * Math.pow(2, 1 - a2)) * n2 && (o2++, n2 /= 2), s2 <= o2 + a2 ? (i2 = 0, o2 = s2) : 1 <= o2 + a2 ? (i2 = (t3 * n2 - 1) * Math.pow(2, r2), o2 += a2) : (i2 = t3 * Math.pow(2, a2 - 1) * Math.pow(2, r2), o2 = 0)); 8 <= r2; e3[l + f2] = 255 & i2, f2 += h, i2 /= 256, r2 -= 8) ;
|
|
2420
|
+
for (o2 = o2 << r2 | i2, u2 += r2; 0 < u2; e3[l + f2] = 255 & o2, f2 += h, o2 /= 256, u2 -= 8) ;
|
|
2421
|
+
e3[l + f2 - h] |= 128 * c;
|
|
2422
|
+
};
|
|
2423
|
+
}).call(this, e("lYpoI2"), "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}, e("buffer").Buffer, arguments[3], arguments[4], arguments[5], arguments[6], "/node_modules/gulp-browserify/node_modules/ieee754/index.js", "/node_modules/gulp-browserify/node_modules/ieee754");
|
|
2424
|
+
}, { buffer: 3, lYpoI2: 11 }], 11: [function(e, h, t) {
|
|
2425
|
+
!(function(e2, t2, n, r, o, f, l, c, d) {
|
|
2426
|
+
var i, u, s;
|
|
2427
|
+
function a() {
|
|
2428
|
+
}
|
|
2429
|
+
(e2 = h.exports = {}).nextTick = (u = "undefined" != typeof window && window.setImmediate, s = "undefined" != typeof window && window.postMessage && window.addEventListener, u ? function(e3) {
|
|
2430
|
+
return window.setImmediate(e3);
|
|
2431
|
+
} : s ? (i = [], window.addEventListener("message", function(e3) {
|
|
2432
|
+
var t3 = e3.source;
|
|
2433
|
+
t3 !== window && null !== t3 || "process-tick" !== e3.data || (e3.stopPropagation(), 0 < i.length && i.shift()());
|
|
2434
|
+
}, true), function(e3) {
|
|
2435
|
+
i.push(e3), window.postMessage("process-tick", "*");
|
|
2436
|
+
}) : function(e3) {
|
|
2437
|
+
setTimeout(e3, 0);
|
|
2438
|
+
}), e2.title = "browser", e2.browser = true, e2.env = {}, e2.argv = [], e2.on = a, e2.addListener = a, e2.once = a, e2.off = a, e2.removeListener = a, e2.removeAllListeners = a, e2.emit = a, e2.binding = function(e3) {
|
|
2439
|
+
throw new Error("process.binding is not supported");
|
|
2440
|
+
}, e2.cwd = function() {
|
|
2441
|
+
return "/";
|
|
2442
|
+
}, e2.chdir = function(e3) {
|
|
2443
|
+
throw new Error("process.chdir is not supported");
|
|
2444
|
+
};
|
|
2445
|
+
}).call(this, e("lYpoI2"), "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}, e("buffer").Buffer, arguments[3], arguments[4], arguments[5], arguments[6], "/node_modules/gulp-browserify/node_modules/process/browser.js", "/node_modules/gulp-browserify/node_modules/process");
|
|
2446
|
+
}, { buffer: 3, lYpoI2: 11 }] }, {}, [1])(1);
|
|
2447
|
+
});
|
|
2448
|
+
})(object_hash);
|
|
2449
|
+
return object_hash.exports;
|
|
2450
|
+
}
|
|
2451
|
+
var object_hashExports = requireObject_hash();
|
|
2452
|
+
const hash = /* @__PURE__ */ getDefaultExportFromCjs(object_hashExports);
|
|
2453
|
+
function isActivitySource(obj) {
|
|
2454
|
+
return isSingleDocSource(obj) || isSelectSource(obj) || isSequenceSource(obj);
|
|
2455
|
+
}
|
|
2456
|
+
function isActivityStateNoSource(obj) {
|
|
2457
|
+
return isSingleDocStateNoSource(obj) || isSelectStateNoSource(obj) || isSequenceStateNoSource(obj);
|
|
2458
|
+
}
|
|
2459
|
+
function isExportedActivityState(obj) {
|
|
2460
|
+
const typedObj = obj;
|
|
2461
|
+
return (
|
|
2462
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
2463
|
+
typedObj !== null && typeof typedObj === "object" && isActivityStateNoSource(typedObj.activityState) && Array.isArray(typedObj.doenetStates) && Array.isArray(typedObj.itemAttemptNumbers) && typedObj.itemAttemptNumbers.every(
|
|
2464
|
+
(x) => Number.isInteger(x) && x > 0
|
|
2465
|
+
) && typeof typedObj.sourceHash === "string"
|
|
2466
|
+
);
|
|
2467
|
+
}
|
|
2468
|
+
function initializeActivityState({
|
|
2469
|
+
source,
|
|
2470
|
+
variant,
|
|
2471
|
+
parentId,
|
|
2472
|
+
numActivityVariants,
|
|
2473
|
+
restrictToVariantSlice
|
|
2474
|
+
}) {
|
|
2475
|
+
switch (source.type) {
|
|
2476
|
+
case "singleDoc": {
|
|
2477
|
+
return initializeSingleDocState({
|
|
2478
|
+
source,
|
|
2479
|
+
variant,
|
|
2480
|
+
parentId,
|
|
2481
|
+
restrictToVariantSlice
|
|
2482
|
+
});
|
|
2483
|
+
}
|
|
2484
|
+
case "select": {
|
|
2485
|
+
return initializeSelectState({
|
|
2486
|
+
source,
|
|
2487
|
+
variant,
|
|
2488
|
+
parentId,
|
|
2489
|
+
numActivityVariants,
|
|
2490
|
+
restrictToVariantSlice
|
|
2491
|
+
});
|
|
2492
|
+
}
|
|
2493
|
+
case "sequence": {
|
|
2494
|
+
return initializeSequenceState({
|
|
2495
|
+
source,
|
|
2496
|
+
variant,
|
|
2497
|
+
parentId,
|
|
2498
|
+
numActivityVariants,
|
|
2499
|
+
restrictToVariantSlice
|
|
2500
|
+
});
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
throw Error("Invalid activity type");
|
|
2504
|
+
}
|
|
2505
|
+
function initializeActivityAndDoenetState({
|
|
2506
|
+
source,
|
|
2507
|
+
variant,
|
|
2508
|
+
parentId,
|
|
2509
|
+
numActivityVariants,
|
|
2510
|
+
restrictToVariantSlice
|
|
2511
|
+
}) {
|
|
2512
|
+
const activityState = initializeActivityState({
|
|
2513
|
+
source,
|
|
2514
|
+
variant,
|
|
2515
|
+
parentId,
|
|
2516
|
+
numActivityVariants,
|
|
2517
|
+
restrictToVariantSlice
|
|
2518
|
+
});
|
|
2519
|
+
const numItems = getNumItems(source);
|
|
2520
|
+
const itemAttemptNumbers = Array(numItems).fill(1);
|
|
2521
|
+
return { activityState, doenetStates: [], itemAttemptNumbers };
|
|
2522
|
+
}
|
|
2523
|
+
function generateNewActivityAttempt({
|
|
2524
|
+
state,
|
|
2525
|
+
numActivityVariants,
|
|
2526
|
+
initialQuestionCounter,
|
|
2527
|
+
parentAttempt
|
|
2528
|
+
}) {
|
|
2529
|
+
switch (state.type) {
|
|
2530
|
+
case "singleDoc": {
|
|
2531
|
+
return generateNewSingleDocAttempt({
|
|
2532
|
+
state,
|
|
2533
|
+
numActivityVariants,
|
|
2534
|
+
initialQuestionCounter,
|
|
2535
|
+
parentAttempt
|
|
2536
|
+
});
|
|
2537
|
+
}
|
|
2538
|
+
case "select": {
|
|
2539
|
+
return generateNewSelectAttempt({
|
|
2540
|
+
state,
|
|
2541
|
+
numActivityVariants,
|
|
2542
|
+
initialQuestionCounter,
|
|
2543
|
+
parentAttempt
|
|
2544
|
+
});
|
|
2545
|
+
}
|
|
2546
|
+
case "sequence": {
|
|
2547
|
+
return generateNewSequenceAttempt({
|
|
2548
|
+
state,
|
|
2549
|
+
numActivityVariants,
|
|
2550
|
+
initialQuestionCounter,
|
|
2551
|
+
parentAttempt
|
|
2552
|
+
});
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
throw Error("Invalid activity type");
|
|
2556
|
+
}
|
|
2557
|
+
function generateNewSingleDocSubAttempt({
|
|
2558
|
+
singleDocId,
|
|
2559
|
+
state,
|
|
2560
|
+
numActivityVariants,
|
|
2561
|
+
initialQuestionCounter
|
|
2562
|
+
}) {
|
|
2563
|
+
if (singleDocId === state.id) {
|
|
2564
|
+
throw Error(
|
|
2565
|
+
"Should not call generateSingleDocSubActivityAttempt on entire activity"
|
|
2566
|
+
);
|
|
2567
|
+
}
|
|
2568
|
+
const allStates = gatherStates(state);
|
|
2569
|
+
const singleDocActivityState = allStates[singleDocId];
|
|
2570
|
+
if (singleDocActivityState.type !== "singleDoc") {
|
|
2571
|
+
throw Error(
|
|
2572
|
+
"generateNewSingleDocSubAttempt implemented only for single documents"
|
|
2573
|
+
);
|
|
2574
|
+
}
|
|
2575
|
+
if (singleDocActivityState.parentId === null) {
|
|
2576
|
+
throw Error("Lower lever should have parent");
|
|
2577
|
+
}
|
|
2578
|
+
const parentState = allStates[singleDocActivityState.parentId];
|
|
2579
|
+
if (parentState.type === "select" && parentState.allChildren.every((child) => child.type === "singleDoc")) {
|
|
2580
|
+
const grandParentAttempt = parentState.parentId ? allStates[parentState.parentId].attemptNumber : 1;
|
|
2581
|
+
let newParentState;
|
|
2582
|
+
if (parentState.source.numToSelect > 1) {
|
|
2583
|
+
({ state: newParentState } = generateNewSingleDocAttemptForMultiSelect({
|
|
2584
|
+
state: parentState,
|
|
2585
|
+
numActivityVariants,
|
|
2586
|
+
initialQuestionCounter,
|
|
2587
|
+
parentAttempt: grandParentAttempt,
|
|
2588
|
+
childId: singleDocId
|
|
2589
|
+
}));
|
|
2590
|
+
} else {
|
|
2591
|
+
({ state: newParentState } = generateNewActivityAttempt({
|
|
2592
|
+
state: parentState,
|
|
2593
|
+
numActivityVariants,
|
|
2594
|
+
initialQuestionCounter,
|
|
2595
|
+
parentAttempt: grandParentAttempt
|
|
2596
|
+
}));
|
|
2597
|
+
}
|
|
2598
|
+
allStates[parentState.id] = newParentState;
|
|
2599
|
+
return propagateStateChangeToRoot({
|
|
2600
|
+
allStates,
|
|
2601
|
+
id: parentState.id
|
|
2602
|
+
});
|
|
2603
|
+
} else {
|
|
2604
|
+
const { state: newSubActivityState } = generateNewActivityAttempt({
|
|
2605
|
+
state: allStates[singleDocId],
|
|
2606
|
+
numActivityVariants,
|
|
2607
|
+
initialQuestionCounter,
|
|
2608
|
+
parentAttempt: parentState.attemptNumber
|
|
2609
|
+
});
|
|
2610
|
+
allStates[singleDocId] = newSubActivityState;
|
|
2611
|
+
return propagateStateChangeToRoot({
|
|
2612
|
+
allStates,
|
|
2613
|
+
id: singleDocId
|
|
2614
|
+
});
|
|
2615
|
+
}
|
|
2616
|
+
}
|
|
2617
|
+
function extractActivityItemCredit(activityState, nPrevInShuffleOrder = 0) {
|
|
2618
|
+
switch (activityState.type) {
|
|
2619
|
+
case "singleDoc": {
|
|
2620
|
+
return extractSingleDocItemCredit(
|
|
2621
|
+
activityState,
|
|
2622
|
+
nPrevInShuffleOrder
|
|
2623
|
+
);
|
|
2624
|
+
}
|
|
2625
|
+
case "select": {
|
|
2626
|
+
return extractSelectItemCredit(activityState, nPrevInShuffleOrder);
|
|
2627
|
+
}
|
|
2628
|
+
case "sequence": {
|
|
2629
|
+
return extractSequenceItemCredit(
|
|
2630
|
+
activityState,
|
|
2631
|
+
nPrevInShuffleOrder
|
|
2632
|
+
);
|
|
2633
|
+
}
|
|
2634
|
+
}
|
|
2635
|
+
}
|
|
2636
|
+
function pruneActivityStateForSave(activityState) {
|
|
2637
|
+
switch (activityState.type) {
|
|
2638
|
+
case "singleDoc": {
|
|
2639
|
+
return pruneSingleDocStateForSave(activityState);
|
|
2640
|
+
}
|
|
2641
|
+
case "select": {
|
|
2642
|
+
return pruneSelectStateForSave(activityState);
|
|
2643
|
+
}
|
|
2644
|
+
case "sequence": {
|
|
2645
|
+
return pruneSequenceStateForSave(activityState);
|
|
2646
|
+
}
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
function addSourceToActivityState(activityState, source) {
|
|
2650
|
+
switch (activityState.type) {
|
|
2651
|
+
case "singleDoc": {
|
|
2652
|
+
if (isSingleDocSource(source)) {
|
|
2653
|
+
return addSourceToSingleDocState(activityState, source);
|
|
2654
|
+
} else {
|
|
2655
|
+
throw Error("Source didn't match state");
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
case "select": {
|
|
2659
|
+
if (isSelectSource(source)) {
|
|
2660
|
+
return addSourceToSelectState(activityState, source);
|
|
2661
|
+
} else {
|
|
2662
|
+
throw Error("Source didn't make state");
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
case "sequence": {
|
|
2666
|
+
if (isSequenceSource(source)) {
|
|
2667
|
+
return addSourceToSequenceState(activityState, source);
|
|
2668
|
+
} else {
|
|
2669
|
+
throw Error("Source didn't match state");
|
|
2670
|
+
}
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2673
|
+
}
|
|
2674
|
+
function extractSourceId(compositeId) {
|
|
2675
|
+
return compositeId.split("|")[0];
|
|
2676
|
+
}
|
|
2677
|
+
function getItemSequence(state) {
|
|
2678
|
+
if (state.type === "singleDoc") {
|
|
2679
|
+
return [state.id];
|
|
2680
|
+
} else {
|
|
2681
|
+
const numAttempts = state.attemptNumber;
|
|
2682
|
+
if (numAttempts === 0) {
|
|
2683
|
+
if (state.allChildren.length === 0) {
|
|
2684
|
+
return [];
|
|
2685
|
+
} else {
|
|
2686
|
+
const prelimResult = state.allChildren.flatMap(
|
|
2687
|
+
(a) => getItemSequence(a)
|
|
2688
|
+
);
|
|
2689
|
+
if (state.type === "sequence") {
|
|
2690
|
+
return prelimResult;
|
|
2691
|
+
} else {
|
|
2692
|
+
return prelimResult.slice(0, state.source.numToSelect);
|
|
2693
|
+
}
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
if (state.type === "sequence") {
|
|
2697
|
+
return state.orderedChildren.flatMap((a) => getItemSequence(a));
|
|
2698
|
+
} else {
|
|
2699
|
+
return state.selectedChildren.flatMap((a) => getItemSequence(a));
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2702
|
+
}
|
|
2703
|
+
function calcNumVariants(source, numActivityVariants) {
|
|
2704
|
+
switch (source.type) {
|
|
2705
|
+
case "singleDoc": {
|
|
2706
|
+
return numActivityVariants[source.id];
|
|
2707
|
+
}
|
|
2708
|
+
case "select": {
|
|
2709
|
+
return calcNumVariantsSelect(source, numActivityVariants);
|
|
2710
|
+
}
|
|
2711
|
+
case "sequence": {
|
|
2712
|
+
return calcNumVariantsSequence(source, numActivityVariants);
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2715
|
+
}
|
|
2716
|
+
function calcNumVariantsFromState(state, numActivityVariants) {
|
|
2717
|
+
let numVariants = calcNumVariants(state.source, numActivityVariants);
|
|
2718
|
+
if (state.restrictToVariantSlice) {
|
|
2719
|
+
numVariants = Math.ceil(
|
|
2720
|
+
(numVariants - state.restrictToVariantSlice.idx + 1) / state.restrictToVariantSlice.numSlices
|
|
2721
|
+
);
|
|
2722
|
+
}
|
|
2723
|
+
return numVariants;
|
|
2724
|
+
}
|
|
2725
|
+
function getNumItems(source) {
|
|
2726
|
+
switch (source.type) {
|
|
2727
|
+
case "singleDoc": {
|
|
2728
|
+
return 1;
|
|
2729
|
+
}
|
|
2730
|
+
case "select": {
|
|
2731
|
+
return getNumItemsInSelect(source);
|
|
2732
|
+
}
|
|
2733
|
+
case "sequence": {
|
|
2734
|
+
return getNumItemsInSequence(source);
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2737
|
+
throw Error("Invalid activity type");
|
|
2738
|
+
}
|
|
2739
|
+
function validateIds(source) {
|
|
2740
|
+
if (source.id.includes("|")) {
|
|
2741
|
+
throw Error(`Id "${source.id}" contains a "|".`);
|
|
2742
|
+
}
|
|
2743
|
+
const idsFound = [source.id];
|
|
2744
|
+
if (source.type !== "singleDoc") {
|
|
2745
|
+
for (const item of source.items) {
|
|
2746
|
+
idsFound.push(...validateIds(item));
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
if ([...new Set(idsFound)].length !== idsFound.length) {
|
|
2750
|
+
throw Error("Duplicate ids encountered in source");
|
|
2751
|
+
}
|
|
2752
|
+
return idsFound;
|
|
2753
|
+
}
|
|
2754
|
+
function gatherDocumentStructure(source) {
|
|
2755
|
+
if (source.type === "singleDoc") {
|
|
2756
|
+
return {
|
|
2757
|
+
numActivityVariants: { [source.id]: source.numVariants ?? 1 }
|
|
2758
|
+
};
|
|
2759
|
+
} else {
|
|
2760
|
+
const numActivityVariants = {};
|
|
2761
|
+
for (const item of source.items) {
|
|
2762
|
+
const res = gatherDocumentStructure(item);
|
|
2763
|
+
Object.assign(numActivityVariants, res.numActivityVariants);
|
|
2764
|
+
}
|
|
2765
|
+
return { numActivityVariants };
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2768
|
+
function validateStateAndSource(state, source) {
|
|
2769
|
+
if (!isExportedActivityState(state) || !isActivitySource(source)) {
|
|
2770
|
+
return false;
|
|
2771
|
+
}
|
|
2772
|
+
const sourceHash = createSourceHash(source);
|
|
2773
|
+
return state.sourceHash === sourceHash;
|
|
2774
|
+
}
|
|
2775
|
+
function gatherStates(state) {
|
|
2776
|
+
const allStates = {
|
|
2777
|
+
[state.id]: state
|
|
2778
|
+
};
|
|
2779
|
+
if (state.type !== "singleDoc") {
|
|
2780
|
+
for (const child of state.allChildren) {
|
|
2781
|
+
Object.assign(allStates, gatherStates(child));
|
|
2782
|
+
}
|
|
2783
|
+
}
|
|
2784
|
+
return allStates;
|
|
2785
|
+
}
|
|
2786
|
+
function propagateStateChangeToRoot({
|
|
2787
|
+
allStates,
|
|
2788
|
+
id
|
|
2789
|
+
}) {
|
|
2790
|
+
const activityState = allStates[id];
|
|
2791
|
+
if (activityState.parentId === null) {
|
|
2792
|
+
return activityState;
|
|
2793
|
+
}
|
|
2794
|
+
const newParentState = allStates[activityState.parentId] = {
|
|
2795
|
+
...allStates[activityState.parentId]
|
|
2796
|
+
};
|
|
2797
|
+
if (newParentState.type === "singleDoc") {
|
|
2798
|
+
throw Error("Single doc activity cannot be a parent");
|
|
2799
|
+
}
|
|
2800
|
+
const childIdx = newParentState.allChildren.map((child) => child.id).indexOf(id);
|
|
2801
|
+
if (childIdx === -1) {
|
|
2802
|
+
throw Error("Something went wrong as parent didn't have child.");
|
|
2803
|
+
} else {
|
|
2804
|
+
newParentState.allChildren = [...newParentState.allChildren];
|
|
2805
|
+
newParentState.allChildren[childIdx] = activityState;
|
|
2806
|
+
}
|
|
2807
|
+
const childActivities = newParentState.type === "sequence" ? [...newParentState.orderedChildren] : [...newParentState.selectedChildren];
|
|
2808
|
+
const childIdx2 = childActivities.map((child) => child.id).indexOf(id);
|
|
2809
|
+
if (childIdx2 === -1) {
|
|
2810
|
+
throw Error(
|
|
2811
|
+
"Something went wrong as parent didn't have child in last attempt."
|
|
2812
|
+
);
|
|
2813
|
+
}
|
|
2814
|
+
childActivities[childIdx2] = activityState;
|
|
2815
|
+
let creditAchieved;
|
|
2816
|
+
if (newParentState.type === "sequence") {
|
|
2817
|
+
newParentState.orderedChildren = childActivities;
|
|
2818
|
+
const nonDescriptions = newParentState.allChildren.filter(
|
|
2819
|
+
(activityState2) => activityState2.type !== "singleDoc" || !activityState2.source.isDescription
|
|
2820
|
+
);
|
|
2821
|
+
let creditWeights = [...newParentState.source.creditWeights ?? []];
|
|
2822
|
+
if (creditWeights.length < nonDescriptions.length) {
|
|
2823
|
+
creditWeights.push(
|
|
2824
|
+
...Array(
|
|
2825
|
+
nonDescriptions.length - creditWeights.length
|
|
2826
|
+
).fill(1)
|
|
2827
|
+
);
|
|
2828
|
+
}
|
|
2829
|
+
creditWeights = creditWeights.slice(0, nonDescriptions.length);
|
|
2830
|
+
const totWeights = creditWeights.reduce((a, c) => a + c);
|
|
2831
|
+
creditWeights = creditWeights.map((w) => w / totWeights);
|
|
2832
|
+
creditAchieved = nonDescriptions.reduce(
|
|
2833
|
+
(a, c, i) => a + c.creditAchieved * creditWeights[i],
|
|
2834
|
+
0
|
|
2835
|
+
);
|
|
2836
|
+
} else {
|
|
2837
|
+
newParentState.selectedChildren = childActivities;
|
|
2838
|
+
creditAchieved = childActivities.reduce((a, c) => a + c.creditAchieved, 0) / childActivities.length;
|
|
2839
|
+
}
|
|
2840
|
+
newParentState.creditAchieved = creditAchieved;
|
|
2841
|
+
return propagateStateChangeToRoot({
|
|
2842
|
+
allStates,
|
|
2843
|
+
id: newParentState.id
|
|
2844
|
+
});
|
|
2845
|
+
}
|
|
2846
|
+
function removeVersionFromSource(source) {
|
|
2847
|
+
if (source.type === "singleDoc") {
|
|
2848
|
+
return {
|
|
2849
|
+
...source,
|
|
2850
|
+
version: ""
|
|
2851
|
+
};
|
|
2852
|
+
} else {
|
|
2853
|
+
return {
|
|
2854
|
+
...source,
|
|
2855
|
+
items: source.items.map(removeVersionFromSource)
|
|
2856
|
+
};
|
|
2857
|
+
}
|
|
2858
|
+
}
|
|
2859
|
+
function createSourceHash(source) {
|
|
2860
|
+
return hash(removeVersionFromSource(source));
|
|
2861
|
+
}
|
|
2862
|
+
function isSingleDocReportStateMessage(obj) {
|
|
2863
|
+
const typedObj = obj;
|
|
2864
|
+
return (
|
|
2865
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
2866
|
+
typedObj !== null && typeof typedObj === "object" && typeof typedObj.activityId === "string" && typeof typedObj.docId === "string" && typeof typedObj.score === "number"
|
|
2867
|
+
);
|
|
2868
|
+
}
|
|
2869
|
+
function isRestrictToVariantSlice(obj) {
|
|
2870
|
+
const typeObj = obj;
|
|
2871
|
+
return (
|
|
2872
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
2873
|
+
typeObj !== null && typeof typeObj === "object" && typeof typeObj.idx === "number" && typeof typeObj.numSlices === "number"
|
|
2874
|
+
);
|
|
2875
|
+
}
|
|
2876
|
+
const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
2877
|
+
let nanoid = (size = 21) => {
|
|
2878
|
+
let id = "";
|
|
2879
|
+
let bytes = crypto.getRandomValues(new Uint8Array(size |= 0));
|
|
2880
|
+
while (size--) {
|
|
2881
|
+
id += urlAlphabet[bytes[size] & 63];
|
|
2882
|
+
}
|
|
2883
|
+
return id;
|
|
2884
|
+
};
|
|
2885
|
+
var DefaultContext = {
|
|
2886
|
+
color: void 0,
|
|
2887
|
+
size: void 0,
|
|
2888
|
+
className: void 0,
|
|
2889
|
+
style: void 0,
|
|
2890
|
+
attr: void 0
|
|
2891
|
+
};
|
|
2892
|
+
var IconContext = React.createContext && /* @__PURE__ */ React.createContext(DefaultContext);
|
|
2893
|
+
var _excluded = ["attr", "size", "title"];
|
|
2894
|
+
function _objectWithoutProperties(source, excluded) {
|
|
2895
|
+
if (source == null) return {};
|
|
2896
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
2897
|
+
var key, i;
|
|
2898
|
+
if (Object.getOwnPropertySymbols) {
|
|
2899
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
2900
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
2901
|
+
key = sourceSymbolKeys[i];
|
|
2902
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
2903
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
2904
|
+
target[key] = source[key];
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
return target;
|
|
2908
|
+
}
|
|
2909
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
2910
|
+
if (source == null) return {};
|
|
2911
|
+
var target = {};
|
|
2912
|
+
for (var key in source) {
|
|
2913
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
2914
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
2915
|
+
target[key] = source[key];
|
|
2916
|
+
}
|
|
2917
|
+
}
|
|
2918
|
+
return target;
|
|
2919
|
+
}
|
|
2920
|
+
function _extends() {
|
|
2921
|
+
_extends = Object.assign ? Object.assign.bind() : function(target) {
|
|
2922
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
2923
|
+
var source = arguments[i];
|
|
2924
|
+
for (var key in source) {
|
|
2925
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
2926
|
+
target[key] = source[key];
|
|
2927
|
+
}
|
|
2928
|
+
}
|
|
2929
|
+
}
|
|
2930
|
+
return target;
|
|
2931
|
+
};
|
|
2932
|
+
return _extends.apply(this, arguments);
|
|
2933
|
+
}
|
|
2934
|
+
function ownKeys(e, r) {
|
|
2935
|
+
var t = Object.keys(e);
|
|
2936
|
+
if (Object.getOwnPropertySymbols) {
|
|
2937
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
2938
|
+
r && (o = o.filter(function(r2) {
|
|
2939
|
+
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
2940
|
+
})), t.push.apply(t, o);
|
|
2941
|
+
}
|
|
2942
|
+
return t;
|
|
2943
|
+
}
|
|
2944
|
+
function _objectSpread(e) {
|
|
2945
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
2946
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
2947
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
|
|
2948
|
+
_defineProperty(e, r2, t[r2]);
|
|
2949
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
|
|
2950
|
+
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
2951
|
+
});
|
|
2952
|
+
}
|
|
2953
|
+
return e;
|
|
2954
|
+
}
|
|
2955
|
+
function _defineProperty(obj, key, value) {
|
|
2956
|
+
key = _toPropertyKey(key);
|
|
2957
|
+
if (key in obj) {
|
|
2958
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
2959
|
+
} else {
|
|
2960
|
+
obj[key] = value;
|
|
2961
|
+
}
|
|
2962
|
+
return obj;
|
|
2963
|
+
}
|
|
2964
|
+
function _toPropertyKey(t) {
|
|
2965
|
+
var i = _toPrimitive(t, "string");
|
|
2966
|
+
return "symbol" == typeof i ? i : i + "";
|
|
2967
|
+
}
|
|
2968
|
+
function _toPrimitive(t, r) {
|
|
2969
|
+
if ("object" != typeof t || !t) return t;
|
|
2970
|
+
var e = t[Symbol.toPrimitive];
|
|
2971
|
+
if (void 0 !== e) {
|
|
2972
|
+
var i = e.call(t, r);
|
|
2973
|
+
if ("object" != typeof i) return i;
|
|
2974
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2975
|
+
}
|
|
2976
|
+
return ("string" === r ? String : Number)(t);
|
|
2977
|
+
}
|
|
2978
|
+
function Tree2Element(tree) {
|
|
2979
|
+
return tree && tree.map((node, i) => /* @__PURE__ */ React.createElement(node.tag, _objectSpread({
|
|
2980
|
+
key: i
|
|
2981
|
+
}, node.attr), Tree2Element(node.child)));
|
|
2982
|
+
}
|
|
2983
|
+
function GenIcon(data) {
|
|
2984
|
+
return (props) => /* @__PURE__ */ React.createElement(IconBase, _extends({
|
|
2985
|
+
attr: _objectSpread({}, data.attr)
|
|
2986
|
+
}, props), Tree2Element(data.child));
|
|
2987
|
+
}
|
|
2988
|
+
function IconBase(props) {
|
|
2989
|
+
var elem = (conf) => {
|
|
2990
|
+
var {
|
|
2991
|
+
attr,
|
|
2992
|
+
size,
|
|
2993
|
+
title
|
|
2994
|
+
} = props, svgProps = _objectWithoutProperties(props, _excluded);
|
|
2995
|
+
var computedSize = size || conf.size || "1em";
|
|
2996
|
+
var className;
|
|
2997
|
+
if (conf.className) className = conf.className;
|
|
2998
|
+
if (props.className) className = (className ? className + " " : "") + props.className;
|
|
2999
|
+
return /* @__PURE__ */ React.createElement("svg", _extends({
|
|
3000
|
+
stroke: "currentColor",
|
|
3001
|
+
fill: "currentColor",
|
|
3002
|
+
strokeWidth: "0"
|
|
3003
|
+
}, conf.attr, attr, svgProps, {
|
|
3004
|
+
className,
|
|
3005
|
+
style: _objectSpread(_objectSpread({
|
|
3006
|
+
color: props.color || conf.color
|
|
3007
|
+
}, conf.style), props.style),
|
|
3008
|
+
height: computedSize,
|
|
3009
|
+
width: computedSize,
|
|
3010
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
3011
|
+
}), title && /* @__PURE__ */ React.createElement("title", null, title), props.children);
|
|
3012
|
+
};
|
|
3013
|
+
return IconContext !== void 0 ? /* @__PURE__ */ React.createElement(IconContext.Consumer, null, (conf) => elem(conf)) : elem(DefaultContext);
|
|
3014
|
+
}
|
|
3015
|
+
function MdError(props) {
|
|
3016
|
+
return GenIcon({ "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "d": "M0 0h24v24H0z" }, "child": [] }, { "tag": "path", "attr": { "d": "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z" }, "child": [] }] })(props);
|
|
3017
|
+
}
|
|
3018
|
+
function SelectActivity({
|
|
3019
|
+
flags,
|
|
3020
|
+
baseId,
|
|
3021
|
+
maxAttemptsAllowed,
|
|
3022
|
+
forceDisable = false,
|
|
3023
|
+
forceShowCorrectness = false,
|
|
3024
|
+
forceShowSolution = false,
|
|
3025
|
+
forceUnsuppressCheckwork = false,
|
|
3026
|
+
doenetViewerUrl,
|
|
3027
|
+
fetchExternalDoenetML,
|
|
3028
|
+
darkMode = "light",
|
|
3029
|
+
showAnswerResponseMenu = false,
|
|
3030
|
+
answerResponseCountsByItem = [],
|
|
3031
|
+
state,
|
|
3032
|
+
doenetStates,
|
|
3033
|
+
loadedStateNum,
|
|
3034
|
+
reportScoreAndStateCallback,
|
|
3035
|
+
checkRender,
|
|
3036
|
+
checkHidden,
|
|
3037
|
+
allowItemAttemptButtons = false,
|
|
3038
|
+
generateNewItemAttempt,
|
|
3039
|
+
hasRenderedCallback,
|
|
3040
|
+
reportVisibility = false,
|
|
3041
|
+
reportVisibilityCallback,
|
|
3042
|
+
itemAttemptNumbers,
|
|
3043
|
+
itemSequence,
|
|
3044
|
+
itemWord
|
|
3045
|
+
}) {
|
|
3046
|
+
const selectedActivities = [];
|
|
3047
|
+
const selectedIds = [];
|
|
3048
|
+
for (const activity of state.selectedChildren) {
|
|
3049
|
+
selectedActivities.push(
|
|
3050
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3051
|
+
Activity,
|
|
3052
|
+
{
|
|
3053
|
+
state: activity,
|
|
3054
|
+
doenetStates,
|
|
3055
|
+
loadedStateNum,
|
|
3056
|
+
flags,
|
|
3057
|
+
baseId,
|
|
3058
|
+
maxAttemptsAllowed,
|
|
3059
|
+
forceDisable,
|
|
3060
|
+
forceShowCorrectness,
|
|
3061
|
+
forceShowSolution,
|
|
3062
|
+
forceUnsuppressCheckwork,
|
|
3063
|
+
doenetViewerUrl,
|
|
3064
|
+
fetchExternalDoenetML,
|
|
3065
|
+
darkMode,
|
|
3066
|
+
showAnswerResponseMenu,
|
|
3067
|
+
answerResponseCountsByItem,
|
|
3068
|
+
reportScoreAndStateCallback,
|
|
3069
|
+
checkRender,
|
|
3070
|
+
checkHidden,
|
|
3071
|
+
allowItemAttemptButtons,
|
|
3072
|
+
generateNewItemAttempt,
|
|
3073
|
+
hasRenderedCallback,
|
|
3074
|
+
reportVisibility,
|
|
3075
|
+
reportVisibilityCallback,
|
|
3076
|
+
itemAttemptNumbers,
|
|
3077
|
+
itemSequence,
|
|
3078
|
+
itemWord
|
|
3079
|
+
},
|
|
3080
|
+
activity.id
|
|
3081
|
+
)
|
|
3082
|
+
);
|
|
3083
|
+
selectedIds.push(activity.id);
|
|
3084
|
+
}
|
|
3085
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { hidden: !checkRender(state), children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: selectedActivities }) }, state.attemptNumber);
|
|
3086
|
+
}
|
|
3087
|
+
function SequenceActivity({
|
|
3088
|
+
flags,
|
|
3089
|
+
baseId,
|
|
3090
|
+
maxAttemptsAllowed,
|
|
3091
|
+
forceDisable = false,
|
|
3092
|
+
forceShowCorrectness = false,
|
|
3093
|
+
forceShowSolution = false,
|
|
3094
|
+
forceUnsuppressCheckwork = false,
|
|
3095
|
+
doenetViewerUrl,
|
|
3096
|
+
fetchExternalDoenetML,
|
|
3097
|
+
darkMode = "light",
|
|
3098
|
+
showAnswerResponseMenu = false,
|
|
3099
|
+
answerResponseCountsByItem = [],
|
|
3100
|
+
state,
|
|
3101
|
+
doenetStates,
|
|
3102
|
+
loadedStateNum,
|
|
3103
|
+
reportScoreAndStateCallback,
|
|
3104
|
+
checkRender,
|
|
3105
|
+
checkHidden,
|
|
3106
|
+
allowItemAttemptButtons = false,
|
|
3107
|
+
generateNewItemAttempt,
|
|
3108
|
+
hasRenderedCallback,
|
|
3109
|
+
reportVisibility = false,
|
|
3110
|
+
reportVisibilityCallback,
|
|
3111
|
+
itemAttemptNumbers,
|
|
3112
|
+
itemSequence,
|
|
3113
|
+
itemWord
|
|
3114
|
+
}) {
|
|
3115
|
+
const activityList = [];
|
|
3116
|
+
for (const activity of state.orderedChildren) {
|
|
3117
|
+
activityList.push(
|
|
3118
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3119
|
+
Activity,
|
|
3120
|
+
{
|
|
3121
|
+
state: activity,
|
|
3122
|
+
doenetStates,
|
|
3123
|
+
loadedStateNum,
|
|
3124
|
+
flags,
|
|
3125
|
+
baseId,
|
|
3126
|
+
maxAttemptsAllowed,
|
|
3127
|
+
forceDisable,
|
|
3128
|
+
forceShowCorrectness,
|
|
3129
|
+
forceShowSolution,
|
|
3130
|
+
forceUnsuppressCheckwork,
|
|
3131
|
+
doenetViewerUrl,
|
|
3132
|
+
fetchExternalDoenetML,
|
|
3133
|
+
darkMode,
|
|
3134
|
+
showAnswerResponseMenu,
|
|
3135
|
+
answerResponseCountsByItem,
|
|
3136
|
+
reportScoreAndStateCallback,
|
|
3137
|
+
checkRender,
|
|
3138
|
+
checkHidden,
|
|
3139
|
+
allowItemAttemptButtons,
|
|
3140
|
+
generateNewItemAttempt,
|
|
3141
|
+
hasRenderedCallback,
|
|
3142
|
+
reportVisibility,
|
|
3143
|
+
reportVisibilityCallback,
|
|
3144
|
+
itemAttemptNumbers,
|
|
3145
|
+
itemSequence,
|
|
3146
|
+
itemWord
|
|
3147
|
+
},
|
|
3148
|
+
activity.id
|
|
3149
|
+
)
|
|
3150
|
+
);
|
|
3151
|
+
}
|
|
3152
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { hidden: !checkRender(state), children: activityList }, state.attemptNumber);
|
|
3153
|
+
}
|
|
3154
|
+
function SingleDocActivity({
|
|
3155
|
+
flags,
|
|
3156
|
+
baseId,
|
|
3157
|
+
maxAttemptsAllowed,
|
|
3158
|
+
forceDisable = false,
|
|
3159
|
+
forceShowCorrectness = false,
|
|
3160
|
+
forceShowSolution = false,
|
|
3161
|
+
forceUnsuppressCheckwork = false,
|
|
3162
|
+
doenetViewerUrl,
|
|
3163
|
+
fetchExternalDoenetML,
|
|
3164
|
+
darkMode = "light",
|
|
3165
|
+
showAnswerResponseMenu = false,
|
|
3166
|
+
answerResponseCountsByItem = [],
|
|
3167
|
+
state,
|
|
3168
|
+
doenetStates,
|
|
3169
|
+
loadedStateNum,
|
|
3170
|
+
reportScoreAndStateCallback,
|
|
3171
|
+
checkRender,
|
|
3172
|
+
checkHidden,
|
|
3173
|
+
allowItemAttemptButtons = false,
|
|
3174
|
+
generateNewItemAttempt,
|
|
3175
|
+
hasRenderedCallback,
|
|
3176
|
+
reportVisibility = false,
|
|
3177
|
+
reportVisibilityCallback,
|
|
3178
|
+
itemAttemptNumbers,
|
|
3179
|
+
itemSequence,
|
|
3180
|
+
itemWord
|
|
3181
|
+
}) {
|
|
3182
|
+
const [rendered, setRendered] = useState(false);
|
|
3183
|
+
const [attemptNumber, setAttemptNumber] = useState(state.attemptNumber);
|
|
3184
|
+
const [loadedStateNumUsed, setLoadedStateNumUsed] = useState(0);
|
|
3185
|
+
const [initialDoenetState, setInitialDoenetState] = useState(
|
|
3186
|
+
state.doenetStateIdx === null ? null : doenetStates[state.doenetStateIdx] ?? null
|
|
3187
|
+
);
|
|
3188
|
+
console.log({
|
|
3189
|
+
doenetStateIdx: state.doenetStateIdx,
|
|
3190
|
+
resultingState: state.doenetStateIdx !== null && doenetStates[state.doenetStateIdx],
|
|
3191
|
+
attemptNumber,
|
|
3192
|
+
attemptNumberInState: state.attemptNumber,
|
|
3193
|
+
loadedStateNum,
|
|
3194
|
+
usedLoadedStateNum: loadedStateNumUsed
|
|
3195
|
+
});
|
|
3196
|
+
const [requestedVariantIndex, setRequestedVariantIndex] = useState(
|
|
3197
|
+
state.currentVariant
|
|
3198
|
+
);
|
|
3199
|
+
const ref = useRef(null);
|
|
3200
|
+
const itemIdx = useMemo(
|
|
3201
|
+
() => itemSequence.indexOf(state.id),
|
|
3202
|
+
[itemSequence, state.id]
|
|
3203
|
+
);
|
|
3204
|
+
const itemAttemptNumber = itemAttemptNumbers[itemIdx];
|
|
3205
|
+
useEffect(() => {
|
|
3206
|
+
if (reportVisibility && ref.current) {
|
|
3207
|
+
const observer = new IntersectionObserver(
|
|
3208
|
+
([entry]) => {
|
|
3209
|
+
reportVisibilityCallback(state.id, entry.isIntersecting);
|
|
3210
|
+
},
|
|
3211
|
+
{ rootMargin: "1000px 1000px 1000px 1000px" }
|
|
3212
|
+
);
|
|
3213
|
+
observer.observe(ref.current);
|
|
3214
|
+
return () => {
|
|
3215
|
+
observer.disconnect();
|
|
3216
|
+
};
|
|
3217
|
+
}
|
|
3218
|
+
}, [reportVisibility, ref, reportVisibilityCallback, state.id]);
|
|
3219
|
+
if (state.attemptNumber !== attemptNumber || loadedStateNumUsed !== loadedStateNum) {
|
|
3220
|
+
setAttemptNumber(state.attemptNumber);
|
|
3221
|
+
setLoadedStateNumUsed(loadedStateNum);
|
|
3222
|
+
setInitialDoenetState(
|
|
3223
|
+
state.doenetStateIdx === null ? null : doenetStates[state.doenetStateIdx] ?? null
|
|
3224
|
+
);
|
|
3225
|
+
setRequestedVariantIndex(state.currentVariant);
|
|
3226
|
+
}
|
|
3227
|
+
const initialCounters = {
|
|
3228
|
+
question: state.initialQuestionCounter,
|
|
3229
|
+
problem: state.initialQuestionCounter,
|
|
3230
|
+
exercise: state.initialQuestionCounter
|
|
3231
|
+
};
|
|
3232
|
+
const source = state.source;
|
|
3233
|
+
const showAttemptButton = allowItemAttemptButtons && generateNewItemAttempt !== void 0 && !source.isDescription && maxAttemptsAllowed !== 1;
|
|
3234
|
+
const render = checkRender(state);
|
|
3235
|
+
const hidden = checkHidden(state);
|
|
3236
|
+
const newAttemptsLeft = Math.max(maxAttemptsAllowed - itemAttemptNumber, 0);
|
|
3237
|
+
const attemptButtonDisabled = maxAttemptsAllowed > 0 && newAttemptsLeft <= 0;
|
|
3238
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { hidden: !render || hidden, style: { minHeight: "100px" }, children: [
|
|
3239
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3240
|
+
DoenetViewer,
|
|
3241
|
+
{
|
|
3242
|
+
doenetML: source.doenetML,
|
|
3243
|
+
doenetmlVersion: source.version,
|
|
3244
|
+
render,
|
|
3245
|
+
requestedVariantIndex,
|
|
3246
|
+
flags,
|
|
3247
|
+
activityId: baseId,
|
|
3248
|
+
prefixForIds: state.id,
|
|
3249
|
+
docId: state.id,
|
|
3250
|
+
forceDisable,
|
|
3251
|
+
forceShowCorrectness,
|
|
3252
|
+
forceShowSolution,
|
|
3253
|
+
forceUnsuppressCheckwork,
|
|
3254
|
+
doenetViewerUrl,
|
|
3255
|
+
fetchExternalDoenetML,
|
|
3256
|
+
darkMode,
|
|
3257
|
+
showAnswerResponseMenu,
|
|
3258
|
+
answerResponseCounts: answerResponseCountsByItem[itemIdx],
|
|
3259
|
+
addVirtualKeyboard: false,
|
|
3260
|
+
initialState: initialDoenetState,
|
|
3261
|
+
initializeCounters: initialCounters,
|
|
3262
|
+
reportScoreAndStateCallback,
|
|
3263
|
+
initializedCallback: () => {
|
|
3264
|
+
setRendered(true);
|
|
3265
|
+
hasRenderedCallback(state.id);
|
|
3266
|
+
}
|
|
3267
|
+
},
|
|
3268
|
+
state.attemptNumber
|
|
3269
|
+
),
|
|
3270
|
+
showAttemptButton ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
3271
|
+
"button",
|
|
3272
|
+
{
|
|
3273
|
+
hidden: !rendered,
|
|
3274
|
+
onClick: () => {
|
|
3275
|
+
generateNewItemAttempt(
|
|
3276
|
+
state.id,
|
|
3277
|
+
state.initialQuestionCounter
|
|
3278
|
+
);
|
|
3279
|
+
},
|
|
3280
|
+
disabled: attemptButtonDisabled,
|
|
3281
|
+
style: {
|
|
3282
|
+
marginLeft: "20px",
|
|
3283
|
+
backgroundColor: "rgb(237, 242, 247)",
|
|
3284
|
+
opacity: attemptButtonDisabled ? 0.4 : "inherit",
|
|
3285
|
+
borderRadius: "10px",
|
|
3286
|
+
padding: "5px 20px",
|
|
3287
|
+
cursor: attemptButtonDisabled ? "not-allowed" : "pointer"
|
|
3288
|
+
},
|
|
3289
|
+
children: [
|
|
3290
|
+
"New ",
|
|
3291
|
+
itemWord,
|
|
3292
|
+
" attempt",
|
|
3293
|
+
" ",
|
|
3294
|
+
maxAttemptsAllowed > 0 ? `(${newAttemptsLeft.toString()} left)` : null
|
|
3295
|
+
]
|
|
3296
|
+
}
|
|
3297
|
+
) : null
|
|
3298
|
+
] }) });
|
|
3299
|
+
}
|
|
3300
|
+
function Activity({
|
|
3301
|
+
flags,
|
|
3302
|
+
baseId,
|
|
3303
|
+
maxAttemptsAllowed,
|
|
3304
|
+
forceDisable = false,
|
|
3305
|
+
forceShowCorrectness = false,
|
|
3306
|
+
forceShowSolution = false,
|
|
3307
|
+
forceUnsuppressCheckwork = false,
|
|
3308
|
+
doenetViewerUrl,
|
|
3309
|
+
fetchExternalDoenetML,
|
|
3310
|
+
darkMode = "light",
|
|
3311
|
+
showAnswerResponseMenu = false,
|
|
3312
|
+
answerResponseCountsByItem = [],
|
|
3313
|
+
state,
|
|
3314
|
+
doenetStates,
|
|
3315
|
+
loadedStateNum,
|
|
3316
|
+
reportScoreAndStateCallback,
|
|
3317
|
+
checkRender,
|
|
3318
|
+
checkHidden,
|
|
3319
|
+
allowItemAttemptButtons = false,
|
|
3320
|
+
generateNewItemAttempt,
|
|
3321
|
+
hasRenderedCallback,
|
|
3322
|
+
reportVisibility = false,
|
|
3323
|
+
reportVisibilityCallback,
|
|
3324
|
+
itemAttemptNumbers,
|
|
3325
|
+
itemSequence,
|
|
3326
|
+
itemWord
|
|
3327
|
+
}) {
|
|
3328
|
+
switch (state.type) {
|
|
3329
|
+
case "singleDoc": {
|
|
3330
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3331
|
+
SingleDocActivity,
|
|
3332
|
+
{
|
|
3333
|
+
flags,
|
|
3334
|
+
baseId,
|
|
3335
|
+
maxAttemptsAllowed,
|
|
3336
|
+
forceDisable,
|
|
3337
|
+
forceShowCorrectness,
|
|
3338
|
+
forceShowSolution,
|
|
3339
|
+
forceUnsuppressCheckwork,
|
|
3340
|
+
doenetViewerUrl,
|
|
3341
|
+
fetchExternalDoenetML,
|
|
3342
|
+
darkMode,
|
|
3343
|
+
showAnswerResponseMenu,
|
|
3344
|
+
answerResponseCountsByItem,
|
|
3345
|
+
state,
|
|
3346
|
+
doenetStates,
|
|
3347
|
+
loadedStateNum,
|
|
3348
|
+
reportScoreAndStateCallback,
|
|
3349
|
+
checkRender,
|
|
3350
|
+
checkHidden,
|
|
3351
|
+
allowItemAttemptButtons,
|
|
3352
|
+
generateNewItemAttempt,
|
|
3353
|
+
hasRenderedCallback,
|
|
3354
|
+
reportVisibility,
|
|
3355
|
+
reportVisibilityCallback,
|
|
3356
|
+
itemAttemptNumbers,
|
|
3357
|
+
itemSequence,
|
|
3358
|
+
itemWord
|
|
3359
|
+
}
|
|
3360
|
+
);
|
|
3361
|
+
}
|
|
3362
|
+
case "select": {
|
|
3363
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3364
|
+
SelectActivity,
|
|
3365
|
+
{
|
|
3366
|
+
flags,
|
|
3367
|
+
baseId,
|
|
3368
|
+
maxAttemptsAllowed,
|
|
3369
|
+
forceDisable,
|
|
3370
|
+
forceShowCorrectness,
|
|
3371
|
+
forceShowSolution,
|
|
3372
|
+
forceUnsuppressCheckwork,
|
|
3373
|
+
doenetViewerUrl,
|
|
3374
|
+
fetchExternalDoenetML,
|
|
3375
|
+
darkMode,
|
|
3376
|
+
showAnswerResponseMenu,
|
|
3377
|
+
answerResponseCountsByItem,
|
|
3378
|
+
state,
|
|
3379
|
+
doenetStates,
|
|
3380
|
+
loadedStateNum,
|
|
3381
|
+
reportScoreAndStateCallback,
|
|
3382
|
+
checkRender,
|
|
3383
|
+
checkHidden,
|
|
3384
|
+
allowItemAttemptButtons,
|
|
3385
|
+
generateNewItemAttempt,
|
|
3386
|
+
hasRenderedCallback,
|
|
3387
|
+
reportVisibility,
|
|
3388
|
+
reportVisibilityCallback,
|
|
3389
|
+
itemAttemptNumbers,
|
|
3390
|
+
itemSequence,
|
|
3391
|
+
itemWord
|
|
3392
|
+
}
|
|
3393
|
+
);
|
|
3394
|
+
}
|
|
3395
|
+
case "sequence": {
|
|
3396
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3397
|
+
SequenceActivity,
|
|
3398
|
+
{
|
|
3399
|
+
flags,
|
|
3400
|
+
baseId,
|
|
3401
|
+
maxAttemptsAllowed,
|
|
3402
|
+
forceDisable,
|
|
3403
|
+
forceShowCorrectness,
|
|
3404
|
+
forceShowSolution,
|
|
3405
|
+
forceUnsuppressCheckwork,
|
|
3406
|
+
doenetViewerUrl,
|
|
3407
|
+
fetchExternalDoenetML,
|
|
3408
|
+
darkMode,
|
|
3409
|
+
showAnswerResponseMenu,
|
|
3410
|
+
answerResponseCountsByItem,
|
|
3411
|
+
state,
|
|
3412
|
+
doenetStates,
|
|
3413
|
+
loadedStateNum,
|
|
3414
|
+
reportScoreAndStateCallback,
|
|
3415
|
+
checkRender,
|
|
3416
|
+
checkHidden,
|
|
3417
|
+
allowItemAttemptButtons,
|
|
3418
|
+
generateNewItemAttempt,
|
|
3419
|
+
hasRenderedCallback,
|
|
3420
|
+
reportVisibility,
|
|
3421
|
+
reportVisibilityCallback,
|
|
3422
|
+
itemAttemptNumbers,
|
|
3423
|
+
itemSequence,
|
|
3424
|
+
itemWord
|
|
3425
|
+
}
|
|
3426
|
+
);
|
|
3427
|
+
}
|
|
3428
|
+
}
|
|
3429
|
+
}
|
|
3430
|
+
function activityDoenetStateReducer(state, action) {
|
|
3431
|
+
const activityState = state.activityState;
|
|
3432
|
+
switch (action.type) {
|
|
3433
|
+
case "initialize": {
|
|
3434
|
+
const numItems = getNumItems(action.source);
|
|
3435
|
+
return {
|
|
3436
|
+
activityState: initializeActivityState({
|
|
3437
|
+
source: action.source,
|
|
3438
|
+
variant: action.variantIndex,
|
|
3439
|
+
parentId: null,
|
|
3440
|
+
numActivityVariants: action.numActivityVariants
|
|
3441
|
+
}),
|
|
3442
|
+
doenetStates: [],
|
|
3443
|
+
itemAttemptNumbers: Array(numItems).fill(1)
|
|
3444
|
+
};
|
|
3445
|
+
}
|
|
3446
|
+
case "set": {
|
|
3447
|
+
if (action.allowSaveState) {
|
|
3448
|
+
const itemScores = extractActivityItemCredit(
|
|
3449
|
+
action.state.activityState
|
|
3450
|
+
);
|
|
3451
|
+
const message = {
|
|
3452
|
+
score: action.state.activityState.creditAchieved,
|
|
3453
|
+
item_scores: itemScores,
|
|
3454
|
+
subject: "SPLICE.reportScoreByItem",
|
|
3455
|
+
activity_id: action.baseId,
|
|
3456
|
+
message_id: nanoid()
|
|
3457
|
+
};
|
|
3458
|
+
window.postMessage(message);
|
|
3459
|
+
}
|
|
3460
|
+
console.log("setting state to", action.state);
|
|
3461
|
+
return action.state;
|
|
3462
|
+
}
|
|
3463
|
+
case "generateNewActivityAttempt": {
|
|
3464
|
+
const { state: newActivityState } = generateNewActivityAttempt({
|
|
3465
|
+
state: activityState,
|
|
3466
|
+
numActivityVariants: action.numActivityVariants,
|
|
3467
|
+
initialQuestionCounter: action.initialQuestionCounter,
|
|
3468
|
+
parentAttempt: 1
|
|
3469
|
+
});
|
|
3470
|
+
const newItemAttemptNumbers = state.itemAttemptNumbers.map(() => 1);
|
|
3471
|
+
if (action.allowSaveState && !action.initialAttempt) {
|
|
3472
|
+
const itemScores = extractActivityItemCredit(newActivityState);
|
|
3473
|
+
const message = {
|
|
3474
|
+
state: {
|
|
3475
|
+
activityState: pruneActivityStateForSave(newActivityState),
|
|
3476
|
+
doenetStates: [],
|
|
3477
|
+
itemAttemptNumbers: newItemAttemptNumbers,
|
|
3478
|
+
sourceHash: action.sourceHash
|
|
3479
|
+
},
|
|
3480
|
+
score: newActivityState.creditAchieved,
|
|
3481
|
+
item_scores: itemScores,
|
|
3482
|
+
subject: "SPLICE.reportScoreAndState",
|
|
3483
|
+
activity_id: action.baseId,
|
|
3484
|
+
message_id: nanoid(),
|
|
3485
|
+
new_attempt: true
|
|
3486
|
+
};
|
|
3487
|
+
window.postMessage(message);
|
|
3488
|
+
}
|
|
3489
|
+
return {
|
|
3490
|
+
activityState: newActivityState,
|
|
3491
|
+
doenetStates: [],
|
|
3492
|
+
itemAttemptNumbers: newItemAttemptNumbers
|
|
3493
|
+
};
|
|
3494
|
+
}
|
|
3495
|
+
case "generateSingleDocSubActivityAttempt": {
|
|
3496
|
+
if (action.docId === activityState.id) {
|
|
3497
|
+
throw Error(
|
|
3498
|
+
"Should not call generateSingleDocSubActivityAttempt on entire activity"
|
|
3499
|
+
);
|
|
3500
|
+
}
|
|
3501
|
+
const newActivityState = generateNewSingleDocSubAttempt({
|
|
3502
|
+
singleDocId: action.docId,
|
|
3503
|
+
state: activityState,
|
|
3504
|
+
numActivityVariants: action.numActivityVariants,
|
|
3505
|
+
initialQuestionCounter: action.initialQuestionCounter
|
|
3506
|
+
});
|
|
3507
|
+
const newDoenetMLStates = [...state.doenetStates];
|
|
3508
|
+
newDoenetMLStates[action.doenetStateIdx] = null;
|
|
3509
|
+
const itemIdx = action.itemSequence.indexOf(action.docId);
|
|
3510
|
+
const newItemAttemptNumbers = [...state.itemAttemptNumbers];
|
|
3511
|
+
newItemAttemptNumbers[itemIdx]++;
|
|
3512
|
+
if (action.allowSaveState) {
|
|
3513
|
+
const itemScores = extractActivityItemCredit(newActivityState);
|
|
3514
|
+
const itemScoresOld = extractActivityItemCredit(activityState);
|
|
3515
|
+
const newAttemptForItem = itemScoresOld.findIndex(
|
|
3516
|
+
(s) => s.id === action.docId || s.docId === action.docId
|
|
3517
|
+
) + 1;
|
|
3518
|
+
const message = {
|
|
3519
|
+
state: {
|
|
3520
|
+
activityState: pruneActivityStateForSave(newActivityState),
|
|
3521
|
+
doenetStates: newDoenetMLStates,
|
|
3522
|
+
itemAttemptNumbers: newItemAttemptNumbers,
|
|
3523
|
+
sourceHash: action.sourceHash
|
|
3524
|
+
},
|
|
3525
|
+
score: newActivityState.creditAchieved,
|
|
3526
|
+
item_scores: itemScores,
|
|
3527
|
+
new_doenet_state_idx: action.doenetStateIdx,
|
|
3528
|
+
subject: "SPLICE.reportScoreAndState",
|
|
3529
|
+
activity_id: action.baseId,
|
|
3530
|
+
message_id: nanoid(),
|
|
3531
|
+
new_attempt: true,
|
|
3532
|
+
new_attempt_for_item: newAttemptForItem
|
|
3533
|
+
};
|
|
3534
|
+
window.postMessage(message);
|
|
3535
|
+
}
|
|
3536
|
+
return {
|
|
3537
|
+
activityState: newActivityState,
|
|
3538
|
+
doenetStates: newDoenetMLStates,
|
|
3539
|
+
itemAttemptNumbers: newItemAttemptNumbers
|
|
3540
|
+
};
|
|
3541
|
+
}
|
|
3542
|
+
case "updateSingleState": {
|
|
3543
|
+
console.log("updateSingleState", action, state);
|
|
3544
|
+
const newActivityDoenetState = updateSingleDocState(action, state);
|
|
3545
|
+
console.log({ newActivityDoenetState });
|
|
3546
|
+
if (action.allowSaveState) {
|
|
3547
|
+
const newActivityState = newActivityDoenetState.activityState;
|
|
3548
|
+
const itemScores = extractActivityItemCredit(newActivityState);
|
|
3549
|
+
const itemUpdated = action.itemSequence.indexOf(action.docId) + 1;
|
|
3550
|
+
const message = {
|
|
3551
|
+
state: {
|
|
3552
|
+
activityState: pruneActivityStateForSave(newActivityState),
|
|
3553
|
+
sourceHash: action.sourceHash,
|
|
3554
|
+
doenetStates: newActivityDoenetState.doenetStates,
|
|
3555
|
+
itemAttemptNumbers: state.itemAttemptNumbers
|
|
3556
|
+
},
|
|
3557
|
+
score: newActivityState.creditAchieved,
|
|
3558
|
+
item_scores: itemScores,
|
|
3559
|
+
item_updated: itemUpdated,
|
|
3560
|
+
new_doenet_state_idx: action.doenetStateIdx,
|
|
3561
|
+
subject: "SPLICE.reportScoreAndState",
|
|
3562
|
+
activity_id: action.baseId,
|
|
3563
|
+
message_id: nanoid()
|
|
3564
|
+
};
|
|
3565
|
+
window.postMessage(message);
|
|
3566
|
+
}
|
|
3567
|
+
return newActivityDoenetState;
|
|
3568
|
+
}
|
|
3569
|
+
}
|
|
3570
|
+
throw Error("Invalid activity action");
|
|
3571
|
+
}
|
|
3572
|
+
function updateSingleDocState(action, activityDoenetState) {
|
|
3573
|
+
const allStates = gatherStates(activityDoenetState.activityState);
|
|
3574
|
+
const newSingleDocState = allStates[action.docId] = {
|
|
3575
|
+
...allStates[action.docId]
|
|
3576
|
+
};
|
|
3577
|
+
if (newSingleDocState.type !== "singleDoc") {
|
|
3578
|
+
throw Error(
|
|
3579
|
+
"Received the wrong type of activity for updateSingleDocState"
|
|
3580
|
+
);
|
|
3581
|
+
}
|
|
3582
|
+
newSingleDocState.creditAchieved = action.creditAchieved;
|
|
3583
|
+
const doenetStates = [...activityDoenetState.doenetStates];
|
|
3584
|
+
doenetStates[action.doenetStateIdx] = action.doenetState;
|
|
3585
|
+
newSingleDocState.doenetStateIdx = action.doenetStateIdx;
|
|
3586
|
+
const rootActivityState = propagateStateChangeToRoot({
|
|
3587
|
+
allStates,
|
|
3588
|
+
id: newSingleDocState.id
|
|
3589
|
+
});
|
|
3590
|
+
return {
|
|
3591
|
+
activityState: rootActivityState,
|
|
3592
|
+
doenetStates,
|
|
3593
|
+
itemAttemptNumbers: activityDoenetState.itemAttemptNumbers
|
|
3594
|
+
};
|
|
3595
|
+
}
|
|
3596
|
+
function Viewer({
|
|
3597
|
+
source,
|
|
3598
|
+
flags,
|
|
3599
|
+
activityId,
|
|
3600
|
+
userId = null,
|
|
3601
|
+
initialVariantIndex,
|
|
3602
|
+
maxAttemptsAllowed = 1,
|
|
3603
|
+
itemLevelAttempts = false,
|
|
3604
|
+
activityLevelAttempts = false,
|
|
3605
|
+
paginate = true,
|
|
3606
|
+
showFinishButton: _showFinishButton = false,
|
|
3607
|
+
forceDisable = false,
|
|
3608
|
+
forceShowCorrectness = false,
|
|
3609
|
+
forceShowSolution = false,
|
|
3610
|
+
forceUnsuppressCheckwork = false,
|
|
3611
|
+
addVirtualKeyboard: _addVirtualKeyboard = true,
|
|
3612
|
+
externalVirtualKeyboardProvided: _externalVirtualKeyboardProvided = false,
|
|
3613
|
+
doenetViewerUrl,
|
|
3614
|
+
fetchExternalDoenetML,
|
|
3615
|
+
darkMode = "light",
|
|
3616
|
+
showAnswerResponseMenu = false,
|
|
3617
|
+
answerResponseCountsByItem = [],
|
|
3618
|
+
showTitle = true,
|
|
3619
|
+
itemWord = "item"
|
|
3620
|
+
}) {
|
|
3621
|
+
const [errMsg, setErrMsg] = useState(null);
|
|
3622
|
+
const initialPass = useRef(true);
|
|
3623
|
+
const { numActivityVariants, sourceHash, numItems } = useMemo(() => {
|
|
3624
|
+
try {
|
|
3625
|
+
validateIds(source);
|
|
3626
|
+
const docStructure = gatherDocumentStructure(source);
|
|
3627
|
+
const sourceHash2 = createSourceHash(source);
|
|
3628
|
+
const numItems2 = getNumItems(source);
|
|
3629
|
+
return { ...docStructure, sourceHash: sourceHash2, numItems: numItems2 };
|
|
3630
|
+
} catch (e) {
|
|
3631
|
+
const message = e instanceof Error ? e.message : "";
|
|
3632
|
+
setErrMsg(`Error in activity source: ${message}`);
|
|
3633
|
+
return {
|
|
3634
|
+
numActivityVariants: {},
|
|
3635
|
+
sourceHash: "",
|
|
3636
|
+
numItems: 0
|
|
3637
|
+
};
|
|
3638
|
+
}
|
|
3639
|
+
}, [source]);
|
|
3640
|
+
const [activityDoenetState, activityDoenetStateDispatch] = useReducer(
|
|
3641
|
+
activityDoenetStateReducer,
|
|
3642
|
+
{
|
|
3643
|
+
source,
|
|
3644
|
+
variant: initialVariantIndex,
|
|
3645
|
+
parentId: null,
|
|
3646
|
+
numActivityVariants
|
|
3647
|
+
},
|
|
3648
|
+
initializeActivityAndDoenetState
|
|
3649
|
+
);
|
|
3650
|
+
const [loadedStateNum, setLoadedStateNum] = useState(0);
|
|
3651
|
+
console.log({ activityDoenetState });
|
|
3652
|
+
const activityState = activityDoenetState.activityState;
|
|
3653
|
+
const itemSequence = getItemSequence(activityState);
|
|
3654
|
+
const [currentItemIdx, setCurrentItemIdx] = useState(0);
|
|
3655
|
+
const currentItemId = itemSequence[currentItemIdx];
|
|
3656
|
+
const [itemsRendered, setItemsRendered] = useState([]);
|
|
3657
|
+
const [itemsToRender, setItemsToRender] = useState([]);
|
|
3658
|
+
const [itemsVisible, setItemsVisible] = useState([]);
|
|
3659
|
+
const [newAttemptNum, setNewAttemptNum] = useState(0);
|
|
3660
|
+
const dialogRef = useRef(null);
|
|
3661
|
+
const newItemAttemptInfo = useRef({ id: "", initialQuestionCounter: 0 });
|
|
3662
|
+
const attemptNumber = activityState.attemptNumber;
|
|
3663
|
+
function addItemToRender(id) {
|
|
3664
|
+
if (!itemsToRender.includes(id)) {
|
|
3665
|
+
setItemsToRender((was) => {
|
|
3666
|
+
if (was.includes(id)) {
|
|
3667
|
+
return was;
|
|
3668
|
+
}
|
|
3669
|
+
const obj = [...was];
|
|
3670
|
+
obj.push(id);
|
|
3671
|
+
return obj;
|
|
3672
|
+
});
|
|
3673
|
+
}
|
|
3674
|
+
}
|
|
3675
|
+
const checkRender = useCallback(
|
|
3676
|
+
(state) => {
|
|
3677
|
+
if (state.type === "singleDoc") {
|
|
3678
|
+
return itemsToRender.includes(state.id);
|
|
3679
|
+
} else {
|
|
3680
|
+
return true;
|
|
3681
|
+
}
|
|
3682
|
+
},
|
|
3683
|
+
[itemsToRender]
|
|
3684
|
+
);
|
|
3685
|
+
const checkHidden = useCallback(
|
|
3686
|
+
(state) => {
|
|
3687
|
+
if (state.type === "singleDoc") {
|
|
3688
|
+
return paginate && currentItemId !== state.id;
|
|
3689
|
+
} else {
|
|
3690
|
+
return false;
|
|
3691
|
+
}
|
|
3692
|
+
},
|
|
3693
|
+
[currentItemId, paginate]
|
|
3694
|
+
);
|
|
3695
|
+
useEffect(() => {
|
|
3696
|
+
if (initialPass.current) {
|
|
3697
|
+
initialPass.current = false;
|
|
3698
|
+
} else {
|
|
3699
|
+
activityDoenetStateDispatch({
|
|
3700
|
+
type: "initialize",
|
|
3701
|
+
source,
|
|
3702
|
+
variantIndex: initialVariantIndex,
|
|
3703
|
+
numActivityVariants
|
|
3704
|
+
});
|
|
3705
|
+
}
|
|
3706
|
+
}, [activityId, source, initialVariantIndex, numActivityVariants]);
|
|
3707
|
+
useEffect(() => {
|
|
3708
|
+
const listenersAdded = [];
|
|
3709
|
+
function requestLoadState() {
|
|
3710
|
+
const message_id = nanoid();
|
|
3711
|
+
window.postMessage({
|
|
3712
|
+
subject: "SPLICE.getState",
|
|
3713
|
+
message_id,
|
|
3714
|
+
activity_id: activityId,
|
|
3715
|
+
user_id: userId
|
|
3716
|
+
});
|
|
3717
|
+
const loadStateListener = function(event) {
|
|
3718
|
+
if (event.origin !== window.location.origin) {
|
|
3719
|
+
return;
|
|
3720
|
+
}
|
|
3721
|
+
if (event.data.subject === "SPLICE.getState.response" && event.data.message_id === message_id) {
|
|
3722
|
+
console.log("received getState.response");
|
|
3723
|
+
const exportedState = event.data.state;
|
|
3724
|
+
if (isExportedActivityState(exportedState)) {
|
|
3725
|
+
console.log("It's exported state");
|
|
3726
|
+
if (validateStateAndSource(exportedState, source)) {
|
|
3727
|
+
const state = addSourceToActivityState(
|
|
3728
|
+
exportedState.activityState,
|
|
3729
|
+
source
|
|
3730
|
+
);
|
|
3731
|
+
console.log("validated!");
|
|
3732
|
+
activityDoenetStateDispatch({
|
|
3733
|
+
type: "set",
|
|
3734
|
+
state: {
|
|
3735
|
+
activityState: state,
|
|
3736
|
+
doenetStates: exportedState.doenetStates,
|
|
3737
|
+
itemAttemptNumbers: exportedState.itemAttemptNumbers
|
|
3738
|
+
},
|
|
3739
|
+
allowSaveState: flags.allowSaveState,
|
|
3740
|
+
baseId: activityId
|
|
3741
|
+
});
|
|
3742
|
+
setLoadedStateNum((was) => was + 1);
|
|
3743
|
+
}
|
|
3744
|
+
}
|
|
3745
|
+
window.removeEventListener("message", loadStateListener);
|
|
3746
|
+
}
|
|
3747
|
+
};
|
|
3748
|
+
window.addEventListener("message", loadStateListener);
|
|
3749
|
+
listenersAdded.push(loadStateListener);
|
|
3750
|
+
}
|
|
3751
|
+
try {
|
|
3752
|
+
activityDoenetStateDispatch({
|
|
3753
|
+
type: "generateNewActivityAttempt",
|
|
3754
|
+
numActivityVariants,
|
|
3755
|
+
initialQuestionCounter: 1,
|
|
3756
|
+
allowSaveState: flags.allowSaveState,
|
|
3757
|
+
baseId: activityId,
|
|
3758
|
+
sourceHash,
|
|
3759
|
+
initialAttempt: true
|
|
3760
|
+
});
|
|
3761
|
+
setLoadedStateNum((was) => was + 1);
|
|
3762
|
+
} catch (e) {
|
|
3763
|
+
const message = e instanceof Error ? e.message : "";
|
|
3764
|
+
setErrMsg(`Error in activity: ${message}`);
|
|
3765
|
+
}
|
|
3766
|
+
if (flags.allowLoadState) {
|
|
3767
|
+
requestLoadState();
|
|
3768
|
+
}
|
|
3769
|
+
return () => {
|
|
3770
|
+
for (const listener of listenersAdded) {
|
|
3771
|
+
window.removeEventListener("message", listener);
|
|
3772
|
+
}
|
|
3773
|
+
};
|
|
3774
|
+
}, [
|
|
3775
|
+
flags.allowLoadState,
|
|
3776
|
+
flags.allowSaveState,
|
|
3777
|
+
activityId,
|
|
3778
|
+
userId,
|
|
3779
|
+
source,
|
|
3780
|
+
numActivityVariants,
|
|
3781
|
+
sourceHash
|
|
3782
|
+
]);
|
|
3783
|
+
function clickNext() {
|
|
3784
|
+
setCurrentItemIdx((was) => Math.min(numItems - 1, was + 1));
|
|
3785
|
+
}
|
|
3786
|
+
function clickPrevious() {
|
|
3787
|
+
setCurrentItemIdx((was) => Math.max(0, was - 1));
|
|
3788
|
+
}
|
|
3789
|
+
function reportScoreAndStateCallback(msg) {
|
|
3790
|
+
console.log("reportScoreAndStateCallback!!!!", msg);
|
|
3791
|
+
if (isSingleDocReportStateMessage(msg)) {
|
|
3792
|
+
activityDoenetStateDispatch({
|
|
3793
|
+
type: "updateSingleState",
|
|
3794
|
+
docId: msg.docId,
|
|
3795
|
+
doenetState: msg.state,
|
|
3796
|
+
doenetStateIdx: itemSequence.indexOf(msg.docId),
|
|
3797
|
+
itemSequence,
|
|
3798
|
+
creditAchieved: msg.score,
|
|
3799
|
+
allowSaveState: flags.allowSaveState,
|
|
3800
|
+
baseId: activityId,
|
|
3801
|
+
sourceHash
|
|
3802
|
+
});
|
|
3803
|
+
}
|
|
3804
|
+
}
|
|
3805
|
+
function generateNewItemAttemptPrompt(id, initialQuestionCounter) {
|
|
3806
|
+
newItemAttemptInfo.current = { id, initialQuestionCounter };
|
|
3807
|
+
setNewAttemptNum((itemSequence.indexOf(id) ?? 0) + 1);
|
|
3808
|
+
dialogRef.current?.showModal();
|
|
3809
|
+
}
|
|
3810
|
+
function generateNewItemAttempt() {
|
|
3811
|
+
const { id, initialQuestionCounter } = newItemAttemptInfo.current;
|
|
3812
|
+
activityDoenetStateDispatch({
|
|
3813
|
+
type: "generateSingleDocSubActivityAttempt",
|
|
3814
|
+
docId: id,
|
|
3815
|
+
doenetStateIdx: itemSequence.indexOf(id),
|
|
3816
|
+
itemSequence,
|
|
3817
|
+
numActivityVariants,
|
|
3818
|
+
initialQuestionCounter,
|
|
3819
|
+
allowSaveState: flags.allowSaveState,
|
|
3820
|
+
baseId: activityId,
|
|
3821
|
+
sourceHash
|
|
3822
|
+
});
|
|
3823
|
+
setItemsRendered((was) => {
|
|
3824
|
+
const idx = was.indexOf(id);
|
|
3825
|
+
if (idx === -1) {
|
|
3826
|
+
return was;
|
|
3827
|
+
} else {
|
|
3828
|
+
const arr = [...was];
|
|
3829
|
+
arr.splice(idx, 1);
|
|
3830
|
+
return arr;
|
|
3831
|
+
}
|
|
3832
|
+
});
|
|
3833
|
+
setItemsToRender((was) => {
|
|
3834
|
+
const idx = was.indexOf(id);
|
|
3835
|
+
if (idx === -1) {
|
|
3836
|
+
return was;
|
|
3837
|
+
} else {
|
|
3838
|
+
const arr = [...was];
|
|
3839
|
+
arr.splice(idx, 1);
|
|
3840
|
+
return arr;
|
|
3841
|
+
}
|
|
3842
|
+
});
|
|
3843
|
+
}
|
|
3844
|
+
function hasRenderedCallback(id) {
|
|
3845
|
+
setItemsRendered((was) => {
|
|
3846
|
+
if (was.includes(id)) {
|
|
3847
|
+
return was;
|
|
3848
|
+
}
|
|
3849
|
+
const obj = [...was];
|
|
3850
|
+
obj.push(id);
|
|
3851
|
+
return obj;
|
|
3852
|
+
});
|
|
3853
|
+
}
|
|
3854
|
+
function reportVisibilityCallback(id, isVisible) {
|
|
3855
|
+
setItemsVisible((was) => {
|
|
3856
|
+
if (isVisible) {
|
|
3857
|
+
if (was.includes(id)) {
|
|
3858
|
+
return was;
|
|
3859
|
+
} else {
|
|
3860
|
+
const obj = [...was];
|
|
3861
|
+
obj.push(id);
|
|
3862
|
+
return obj;
|
|
3863
|
+
}
|
|
3864
|
+
} else {
|
|
3865
|
+
const idx = was.indexOf(id);
|
|
3866
|
+
if (idx === -1) {
|
|
3867
|
+
return was;
|
|
3868
|
+
} else {
|
|
3869
|
+
const obj = [...was];
|
|
3870
|
+
obj.splice(idx, 1);
|
|
3871
|
+
return obj;
|
|
3872
|
+
}
|
|
3873
|
+
}
|
|
3874
|
+
});
|
|
3875
|
+
}
|
|
3876
|
+
function generateActivityAttempt() {
|
|
3877
|
+
setItemsRendered([]);
|
|
3878
|
+
setItemsToRender([]);
|
|
3879
|
+
setCurrentItemIdx(0);
|
|
3880
|
+
activityDoenetStateDispatch({
|
|
3881
|
+
type: "generateNewActivityAttempt",
|
|
3882
|
+
numActivityVariants,
|
|
3883
|
+
initialQuestionCounter: 1,
|
|
3884
|
+
allowSaveState: flags.allowSaveState,
|
|
3885
|
+
baseId: activityId,
|
|
3886
|
+
sourceHash
|
|
3887
|
+
});
|
|
3888
|
+
}
|
|
3889
|
+
if (errMsg !== null) {
|
|
3890
|
+
const errorIcon = /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { fontSize: "1em", color: "#C1292E" }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(MdError, {}) });
|
|
3891
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
3892
|
+
"div",
|
|
3893
|
+
{
|
|
3894
|
+
style: {
|
|
3895
|
+
fontSize: "1.3em",
|
|
3896
|
+
marginLeft: "20px",
|
|
3897
|
+
marginTop: "20px"
|
|
3898
|
+
},
|
|
3899
|
+
children: [
|
|
3900
|
+
errorIcon,
|
|
3901
|
+
" ",
|
|
3902
|
+
errMsg
|
|
3903
|
+
]
|
|
3904
|
+
}
|
|
3905
|
+
);
|
|
3906
|
+
}
|
|
3907
|
+
if (paginate) {
|
|
3908
|
+
if (!itemsRendered.includes(currentItemId)) {
|
|
3909
|
+
addItemToRender(currentItemId);
|
|
3910
|
+
} else {
|
|
3911
|
+
const nextItemId = itemSequence[currentItemIdx + 1];
|
|
3912
|
+
if (currentItemIdx < numItems - 1 && !itemsRendered.includes(nextItemId)) {
|
|
3913
|
+
addItemToRender(nextItemId);
|
|
3914
|
+
} else {
|
|
3915
|
+
const prevItemId = itemSequence[currentItemIdx - 1];
|
|
3916
|
+
if (currentItemIdx > 0 && !itemsRendered.includes(prevItemId)) {
|
|
3917
|
+
addItemToRender(prevItemId);
|
|
3918
|
+
}
|
|
3919
|
+
}
|
|
3920
|
+
}
|
|
3921
|
+
} else {
|
|
3922
|
+
for (const id of itemSequence) {
|
|
3923
|
+
if (!itemsRendered.includes(id) && itemsVisible.includes(id)) {
|
|
3924
|
+
addItemToRender(id);
|
|
3925
|
+
break;
|
|
3926
|
+
}
|
|
3927
|
+
}
|
|
3928
|
+
}
|
|
3929
|
+
const activityAttemptsLeft = Math.max(
|
|
3930
|
+
maxAttemptsAllowed - attemptNumber,
|
|
3931
|
+
0
|
|
3932
|
+
);
|
|
3933
|
+
const newAttemptsLeft = newAttemptNum === 0 ? activityAttemptsLeft : Math.max(
|
|
3934
|
+
maxAttemptsAllowed - activityDoenetState.itemAttemptNumbers[newAttemptNum - 1],
|
|
3935
|
+
0
|
|
3936
|
+
);
|
|
3937
|
+
const newAttemptDisabled = numItems === 0 || maxAttemptsAllowed > 0 && activityAttemptsLeft <= 0;
|
|
3938
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
3939
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("dialog", { ref: dialogRef, children: [
|
|
3940
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("h3", { children: [
|
|
3941
|
+
"Create new attempt of",
|
|
3942
|
+
" ",
|
|
3943
|
+
newAttemptNum === 0 ? "the entire activity" : `${itemWord} ${newAttemptNum.toString()}`,
|
|
3944
|
+
"?"
|
|
3945
|
+
] }),
|
|
3946
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("p", { children: [
|
|
3947
|
+
"Creating a new attempt will generate",
|
|
3948
|
+
" ",
|
|
3949
|
+
newAttemptNum === 0 ? `new versions of all ${itemWord}s so that you can start again at the beginning.` : `a new version of ${itemWord} ${newAttemptNum.toString()} so that you can start that ${itemWord} again.`
|
|
3950
|
+
] }),
|
|
3951
|
+
maxAttemptsAllowed > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { children: [
|
|
3952
|
+
"You can create a new attempt",
|
|
3953
|
+
" ",
|
|
3954
|
+
newAttemptsLeft.toString(),
|
|
3955
|
+
" more time",
|
|
3956
|
+
newAttemptsLeft > 1 ? "s" : "",
|
|
3957
|
+
"."
|
|
3958
|
+
] }) : null,
|
|
3959
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("p", { style: { marginTop: "30px" }, children: [
|
|
3960
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3961
|
+
"button",
|
|
3962
|
+
{
|
|
3963
|
+
autoFocus: true,
|
|
3964
|
+
onClick: () => {
|
|
3965
|
+
dialogRef.current?.close();
|
|
3966
|
+
},
|
|
3967
|
+
style: {
|
|
3968
|
+
marginLeft: "30px",
|
|
3969
|
+
backgroundColor: "lightgray",
|
|
3970
|
+
borderRadius: "10px",
|
|
3971
|
+
padding: "5px 20px"
|
|
3972
|
+
},
|
|
3973
|
+
children: "Cancel"
|
|
3974
|
+
}
|
|
3975
|
+
),
|
|
3976
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3977
|
+
"button",
|
|
3978
|
+
{
|
|
3979
|
+
onClick: () => {
|
|
3980
|
+
if (newAttemptNum === 0) {
|
|
3981
|
+
generateActivityAttempt();
|
|
3982
|
+
} else {
|
|
3983
|
+
generateNewItemAttempt();
|
|
3984
|
+
}
|
|
3985
|
+
dialogRef.current?.close();
|
|
3986
|
+
},
|
|
3987
|
+
style: {
|
|
3988
|
+
marginLeft: "30px",
|
|
3989
|
+
backgroundColor: "lightgray",
|
|
3990
|
+
borderRadius: "10px",
|
|
3991
|
+
padding: "5px 20px"
|
|
3992
|
+
},
|
|
3993
|
+
children: "Create new attempt"
|
|
3994
|
+
}
|
|
3995
|
+
)
|
|
3996
|
+
] })
|
|
3997
|
+
] }),
|
|
3998
|
+
showTitle ? /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { style: { marginLeft: "20px" }, children: source.title }) : null,
|
|
3999
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { marginTop: "5px" }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
4000
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { hidden: !paginate, children: [
|
|
4001
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4002
|
+
"button",
|
|
4003
|
+
{
|
|
4004
|
+
onClick: clickPrevious,
|
|
4005
|
+
style: {
|
|
4006
|
+
marginLeft: "20px",
|
|
4007
|
+
marginRight: "10px",
|
|
4008
|
+
backgroundColor: "lightgray",
|
|
4009
|
+
borderRadius: "10px",
|
|
4010
|
+
padding: "5px 20px"
|
|
4011
|
+
},
|
|
4012
|
+
disabled: currentItemIdx <= 0,
|
|
4013
|
+
children: "Previous"
|
|
4014
|
+
}
|
|
4015
|
+
),
|
|
4016
|
+
"Page ",
|
|
4017
|
+
currentItemIdx + 1,
|
|
4018
|
+
" of ",
|
|
4019
|
+
numItems,
|
|
4020
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4021
|
+
"button",
|
|
4022
|
+
{
|
|
4023
|
+
onClick: clickNext,
|
|
4024
|
+
style: {
|
|
4025
|
+
marginLeft: "10px",
|
|
4026
|
+
backgroundColor: "lightgray",
|
|
4027
|
+
borderRadius: "10px",
|
|
4028
|
+
padding: "5px 20px"
|
|
4029
|
+
},
|
|
4030
|
+
disabled: currentItemIdx >= numItems - 1,
|
|
4031
|
+
children: "Next"
|
|
4032
|
+
}
|
|
4033
|
+
)
|
|
4034
|
+
] }),
|
|
4035
|
+
activityLevelAttempts && maxAttemptsAllowed !== 1 ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
4036
|
+
"button",
|
|
4037
|
+
{
|
|
4038
|
+
onClick: () => {
|
|
4039
|
+
setNewAttemptNum(0);
|
|
4040
|
+
dialogRef.current?.showModal();
|
|
4041
|
+
},
|
|
4042
|
+
disabled: newAttemptDisabled,
|
|
4043
|
+
style: {
|
|
4044
|
+
marginLeft: "30px",
|
|
4045
|
+
backgroundColor: "rgb(237, 242, 247)",
|
|
4046
|
+
opacity: newAttemptDisabled ? 0.4 : "inherit",
|
|
4047
|
+
borderRadius: "10px",
|
|
4048
|
+
padding: "5px 20px",
|
|
4049
|
+
cursor: newAttemptDisabled ? "not-allowed" : "pointer"
|
|
4050
|
+
},
|
|
4051
|
+
children: [
|
|
4052
|
+
"New attempt",
|
|
4053
|
+
" ",
|
|
4054
|
+
maxAttemptsAllowed > 0 ? `(${activityAttemptsLeft.toString()} left)` : null
|
|
4055
|
+
]
|
|
4056
|
+
}
|
|
4057
|
+
) : null
|
|
4058
|
+
] }) }),
|
|
4059
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4060
|
+
"div",
|
|
4061
|
+
{
|
|
4062
|
+
hidden: itemsRendered.length > 0 || numItems === 0,
|
|
4063
|
+
style: { marginLeft: "20px", marginTop: "20px" },
|
|
4064
|
+
children: "Initializing..."
|
|
4065
|
+
}
|
|
4066
|
+
),
|
|
4067
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4068
|
+
Activity,
|
|
4069
|
+
{
|
|
4070
|
+
flags,
|
|
4071
|
+
baseId: activityId,
|
|
4072
|
+
maxAttemptsAllowed,
|
|
4073
|
+
forceDisable,
|
|
4074
|
+
forceShowCorrectness,
|
|
4075
|
+
forceShowSolution,
|
|
4076
|
+
forceUnsuppressCheckwork,
|
|
4077
|
+
doenetViewerUrl,
|
|
4078
|
+
fetchExternalDoenetML,
|
|
4079
|
+
darkMode,
|
|
4080
|
+
showAnswerResponseMenu,
|
|
4081
|
+
answerResponseCountsByItem,
|
|
4082
|
+
state: activityState,
|
|
4083
|
+
doenetStates: activityDoenetState.doenetStates,
|
|
4084
|
+
loadedStateNum,
|
|
4085
|
+
reportScoreAndStateCallback,
|
|
4086
|
+
checkRender,
|
|
4087
|
+
checkHidden,
|
|
4088
|
+
allowItemAttemptButtons: itemLevelAttempts,
|
|
4089
|
+
generateNewItemAttempt: generateNewItemAttemptPrompt,
|
|
4090
|
+
hasRenderedCallback,
|
|
4091
|
+
reportVisibility: !paginate,
|
|
4092
|
+
reportVisibilityCallback,
|
|
4093
|
+
itemAttemptNumbers: activityDoenetState.itemAttemptNumbers,
|
|
4094
|
+
itemSequence,
|
|
4095
|
+
itemWord
|
|
4096
|
+
}
|
|
4097
|
+
)
|
|
4098
|
+
] });
|
|
4099
|
+
}
|
|
4100
|
+
const defaultFlags = {
|
|
4101
|
+
showCorrectness: true,
|
|
4102
|
+
readOnly: false,
|
|
4103
|
+
solutionDisplayMode: "button",
|
|
4104
|
+
showFeedback: true,
|
|
4105
|
+
showHints: true,
|
|
4106
|
+
allowLoadState: false,
|
|
4107
|
+
allowSaveState: false,
|
|
4108
|
+
allowLocalState: false,
|
|
4109
|
+
allowSaveSubmissions: false,
|
|
4110
|
+
allowSaveEvents: false,
|
|
4111
|
+
autoSubmit: false
|
|
4112
|
+
};
|
|
4113
|
+
const rngClass = seedrandom.alea;
|
|
4114
|
+
function ActivityViewer({
|
|
4115
|
+
source,
|
|
4116
|
+
flags: specifiedFlags = {},
|
|
4117
|
+
activityId = "a",
|
|
4118
|
+
userId = null,
|
|
4119
|
+
requestedVariantIndex,
|
|
4120
|
+
maxAttemptsAllowed = 1,
|
|
4121
|
+
itemLevelAttempts = false,
|
|
4122
|
+
activityLevelAttempts = false,
|
|
4123
|
+
paginate = true,
|
|
4124
|
+
showFinishButton = false,
|
|
4125
|
+
forceDisable = false,
|
|
4126
|
+
forceShowCorrectness = false,
|
|
4127
|
+
forceShowSolution = false,
|
|
4128
|
+
forceUnsuppressCheckwork = false,
|
|
4129
|
+
addVirtualKeyboard = true,
|
|
4130
|
+
externalVirtualKeyboardProvided = false,
|
|
4131
|
+
doenetViewerUrl,
|
|
4132
|
+
fetchExternalDoenetML,
|
|
4133
|
+
darkMode = "light",
|
|
4134
|
+
showAnswerResponseMenu = false,
|
|
4135
|
+
answerResponseCountsByItem = [],
|
|
4136
|
+
includeVariantSelector: _includeVariantSelector = false,
|
|
4137
|
+
showTitle = true,
|
|
4138
|
+
itemWord = "item"
|
|
4139
|
+
}) {
|
|
4140
|
+
const [initialVariantIndex, setInitialVariantIndex] = useState(null);
|
|
4141
|
+
const thisPropSet = {
|
|
4142
|
+
source: JSON.stringify(source),
|
|
4143
|
+
activityId,
|
|
4144
|
+
requestedVariantIndex
|
|
4145
|
+
};
|
|
4146
|
+
const lastPropSet = useRef({ source: "" });
|
|
4147
|
+
const flags = { ...defaultFlags, ...specifiedFlags };
|
|
4148
|
+
let foundPropChange = false;
|
|
4149
|
+
let key;
|
|
4150
|
+
for (key in thisPropSet) {
|
|
4151
|
+
if (thisPropSet[key] !== lastPropSet.current[key]) {
|
|
4152
|
+
foundPropChange = true;
|
|
4153
|
+
}
|
|
4154
|
+
}
|
|
4155
|
+
lastPropSet.current = thisPropSet;
|
|
4156
|
+
if (foundPropChange) {
|
|
4157
|
+
if (requestedVariantIndex === void 0) {
|
|
4158
|
+
const rng = rngClass((/* @__PURE__ */ new Date()).toString());
|
|
4159
|
+
setInitialVariantIndex(Math.floor(rng() * 1e6) + 1);
|
|
4160
|
+
} else {
|
|
4161
|
+
setInitialVariantIndex(
|
|
4162
|
+
Number.isInteger(requestedVariantIndex) ? requestedVariantIndex : 1
|
|
4163
|
+
);
|
|
4164
|
+
}
|
|
4165
|
+
}
|
|
4166
|
+
if (initialVariantIndex === null) {
|
|
4167
|
+
return null;
|
|
4168
|
+
}
|
|
4169
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4170
|
+
Viewer,
|
|
4171
|
+
{
|
|
4172
|
+
source,
|
|
4173
|
+
flags,
|
|
4174
|
+
activityId,
|
|
4175
|
+
userId,
|
|
4176
|
+
initialVariantIndex,
|
|
4177
|
+
maxAttemptsAllowed,
|
|
4178
|
+
itemLevelAttempts,
|
|
4179
|
+
activityLevelAttempts,
|
|
4180
|
+
paginate,
|
|
4181
|
+
showFinishButton,
|
|
4182
|
+
forceDisable,
|
|
4183
|
+
forceShowCorrectness,
|
|
4184
|
+
forceShowSolution,
|
|
4185
|
+
forceUnsuppressCheckwork,
|
|
4186
|
+
addVirtualKeyboard,
|
|
4187
|
+
externalVirtualKeyboardProvided,
|
|
4188
|
+
doenetViewerUrl,
|
|
4189
|
+
fetchExternalDoenetML,
|
|
4190
|
+
darkMode,
|
|
4191
|
+
showAnswerResponseMenu,
|
|
4192
|
+
answerResponseCountsByItem,
|
|
4193
|
+
showTitle,
|
|
4194
|
+
itemWord
|
|
4195
|
+
}
|
|
4196
|
+
) });
|
|
4197
|
+
}
|
|
4198
|
+
class ErrorBoundary extends Component {
|
|
4199
|
+
constructor(props) {
|
|
4200
|
+
super(props);
|
|
4201
|
+
this.state = { hasError: false, message: "" };
|
|
4202
|
+
}
|
|
4203
|
+
static getDerivedStateFromError(error) {
|
|
4204
|
+
return { hasError: true, message: error.message };
|
|
4205
|
+
}
|
|
4206
|
+
componentDidCatch(error, errorInfo) {
|
|
4207
|
+
console.error("Uncaught error", error, errorInfo);
|
|
4208
|
+
}
|
|
4209
|
+
render() {
|
|
4210
|
+
if (this.state.hasError) {
|
|
4211
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { marginLeft: "20px" }, children: [
|
|
4212
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h1", { children: "An error occurred" }),
|
|
4213
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: this.state.message })
|
|
4214
|
+
] });
|
|
4215
|
+
}
|
|
4216
|
+
return this.props.children;
|
|
4217
|
+
}
|
|
4218
|
+
}
|
|
4219
|
+
export {
|
|
4220
|
+
ActivityViewer,
|
|
4221
|
+
isActivitySource
|
|
4222
|
+
};
|