@deepseek-ai/dsh-client-ui-settings-account 0.1.7-alpha.1
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 +21 -0
- package/README.i18n.yaml +6 -0
- package/README.md +75 -0
- package/README.zh.md +75 -0
- package/lib/client.js +2383 -0
- package/lib/index.js +28 -0
- package/lib/types/client/AccountAvatar.d.ts +9 -0
- package/lib/types/client/AccountMenu.d.ts +10 -0
- package/lib/types/client/AccountOnboarding.d.ts +5 -0
- package/lib/types/client/AccountSection.d.ts +46 -0
- package/lib/types/client/LogoutIcon.d.ts +4 -0
- package/lib/types/client/PlatformOverlay.d.ts +30 -0
- package/lib/types/client/SignInDialog.d.ts +13 -0
- package/lib/types/client/contact-url.d.ts +18 -0
- package/lib/types/client/formatBalance.d.ts +8 -0
- package/lib/types/client/index.d.ts +17 -0
- package/lib/types/client/locales.d.ts +53 -0
- package/lib/types/contact-config.d.ts +14 -0
- package/lib/types/index.d.ts +11 -0
- package/package.json +74 -0
package/lib/client.js
ADDED
|
@@ -0,0 +1,2383 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "@deepseek-ai/dsh-client-ui-settings-account",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
let react = require("react");
|
|
9
|
+
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
10
|
+
let react_dom = require("react-dom");
|
|
11
|
+
//#region ../../../vendor/cosmokit/src/misc.ts
|
|
12
|
+
/** Return true when a value is `null` or `undefined`. */
|
|
13
|
+
function isNullable(value) {
|
|
14
|
+
return value === null || value === void 0;
|
|
15
|
+
}
|
|
16
|
+
/** Return true for non-array object values. */
|
|
17
|
+
function isPlainObject(data) {
|
|
18
|
+
return data && typeof data === "object" && !Array.isArray(data);
|
|
19
|
+
}
|
|
20
|
+
/** Filter object entries and return a new object. */
|
|
21
|
+
function filterKeys(object, filter) {
|
|
22
|
+
return Object.fromEntries(Object.entries(object).filter(([key, value]) => filter(key, value)));
|
|
23
|
+
}
|
|
24
|
+
/** Map object values while preserving the original key set. */
|
|
25
|
+
function mapValues(object, transform) {
|
|
26
|
+
return Object.fromEntries(Object.entries(object).map(([key, value]) => [key, transform(value, key)]));
|
|
27
|
+
}
|
|
28
|
+
/** Pick selected keys from an object, optionally including `undefined` values. */
|
|
29
|
+
function pick(source, keys, forced) {
|
|
30
|
+
if (!keys) return { ...source };
|
|
31
|
+
const result = {};
|
|
32
|
+
for (const key of keys) if (forced || source[key] !== void 0) result[key] = source[key];
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region ../../../vendor/cosmokit/src/volatile.ts
|
|
37
|
+
/** Shared config references used by schema validators and plugin runtimes. */
|
|
38
|
+
const write = Symbol.for("cosmokit.volatile.write");
|
|
39
|
+
function snapshot(value, ancestors = /* @__PURE__ */ new Set()) {
|
|
40
|
+
if (typeof value === "function") throw new TypeError("volatile config cannot contain functions");
|
|
41
|
+
if (value === null || typeof value !== "object") return value;
|
|
42
|
+
if (ancestors.has(value)) throw new TypeError("volatile config cannot contain cycles");
|
|
43
|
+
ancestors.add(value);
|
|
44
|
+
try {
|
|
45
|
+
if (Array.isArray(value)) return Object.freeze(value.map((item) => snapshot(item, ancestors)));
|
|
46
|
+
if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) throw new TypeError("volatile config objects must be plain objects or arrays");
|
|
47
|
+
return Object.freeze(Object.fromEntries(Object.entries(value).map(([key, item]) => [key, snapshot(item, ancestors)])));
|
|
48
|
+
} finally {
|
|
49
|
+
ancestors.delete(value);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Create a detached reference containing an immutable copy of the supplied data.
|
|
54
|
+
* @param value - validated config data; class instances and functions are unsupported.
|
|
55
|
+
* @returns a reference whose value is updated only by its owning runtime.
|
|
56
|
+
*/
|
|
57
|
+
function createVolatile(value) {
|
|
58
|
+
let current = snapshot(value);
|
|
59
|
+
return Object.freeze({
|
|
60
|
+
get: () => current,
|
|
61
|
+
[write]: (value) => {
|
|
62
|
+
current = value;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Identify references across ESM/CJS copies of the shared library.
|
|
68
|
+
* @param value - a parsed config value.
|
|
69
|
+
* @returns whether the value implements the shared reference protocol.
|
|
70
|
+
*/
|
|
71
|
+
function isVolatile(value) {
|
|
72
|
+
return typeof value === "object" && value !== null && write in value;
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region ../../../vendor/cosmokit/src/types.ts
|
|
76
|
+
/** Test values using `instanceof` with a `toStringTag` fallback. */
|
|
77
|
+
function is(type, value) {
|
|
78
|
+
if (arguments.length === 1) return (value) => is(type, value);
|
|
79
|
+
return type in globalThis && value instanceof globalThis[type] || Object.prototype.toString.call(value).slice(8, -1) === type;
|
|
80
|
+
}
|
|
81
|
+
function isArrayBufferLike(value) {
|
|
82
|
+
return is("ArrayBuffer", value) || is("SharedArrayBuffer", value);
|
|
83
|
+
}
|
|
84
|
+
function isArrayBufferSource(value) {
|
|
85
|
+
return isArrayBufferLike(value) || ArrayBuffer.isView(value);
|
|
86
|
+
}
|
|
87
|
+
let Binary;
|
|
88
|
+
(function(_Binary) {
|
|
89
|
+
_Binary.is = isArrayBufferLike;
|
|
90
|
+
_Binary.isSource = isArrayBufferSource;
|
|
91
|
+
function fromSource(source) {
|
|
92
|
+
if (ArrayBuffer.isView(source)) return source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength);
|
|
93
|
+
else return source;
|
|
94
|
+
}
|
|
95
|
+
_Binary.fromSource = fromSource;
|
|
96
|
+
function toBase64(source) {
|
|
97
|
+
source = fromSource(source);
|
|
98
|
+
if (typeof Buffer !== "undefined") return Buffer.from(source).toString("base64");
|
|
99
|
+
let binary = "";
|
|
100
|
+
const bytes = new Uint8Array(source);
|
|
101
|
+
for (let i = 0; i < bytes.byteLength; i++) binary += String.fromCharCode(bytes[i]);
|
|
102
|
+
return btoa(binary);
|
|
103
|
+
}
|
|
104
|
+
_Binary.toBase64 = toBase64;
|
|
105
|
+
function fromBase64(source) {
|
|
106
|
+
if (typeof Buffer !== "undefined") return fromSource(Buffer.from(source, "base64"));
|
|
107
|
+
return Uint8Array.from(atob(source), (c) => c.charCodeAt(0));
|
|
108
|
+
}
|
|
109
|
+
_Binary.fromBase64 = fromBase64;
|
|
110
|
+
function toHex(source) {
|
|
111
|
+
source = fromSource(source);
|
|
112
|
+
if (typeof Buffer !== "undefined") return Buffer.from(source).toString("hex");
|
|
113
|
+
return Array.from(new Uint8Array(source), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
114
|
+
}
|
|
115
|
+
_Binary.toHex = toHex;
|
|
116
|
+
function fromHex(source) {
|
|
117
|
+
if (typeof Buffer !== "undefined") return fromSource(Buffer.from(source, "hex"));
|
|
118
|
+
const hex = source.length % 2 === 0 ? source : source.slice(0, source.length - 1);
|
|
119
|
+
const buffer = [];
|
|
120
|
+
for (let i = 0; i < hex.length; i += 2) buffer.push(parseInt(`${hex[i]}${hex[i + 1]}`, 16));
|
|
121
|
+
return Uint8Array.from(buffer).buffer;
|
|
122
|
+
}
|
|
123
|
+
_Binary.fromHex = fromHex;
|
|
124
|
+
})(Binary || (Binary = {}));
|
|
125
|
+
Binary.fromBase64;
|
|
126
|
+
Binary.toBase64;
|
|
127
|
+
Binary.fromHex;
|
|
128
|
+
Binary.toHex;
|
|
129
|
+
/** Deep-clone common JavaScript values while preserving prototypes and cycles. */
|
|
130
|
+
function clone(source, refs = /* @__PURE__ */ new Map()) {
|
|
131
|
+
if (!source || typeof source !== "object") return source;
|
|
132
|
+
if (is("Date", source)) return new Date(source.valueOf());
|
|
133
|
+
if (is("RegExp", source)) return new RegExp(source.source, source.flags);
|
|
134
|
+
if (isArrayBufferLike(source)) return source.slice(0);
|
|
135
|
+
if (ArrayBuffer.isView(source)) return source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength);
|
|
136
|
+
const cached = refs.get(source);
|
|
137
|
+
if (cached) return cached;
|
|
138
|
+
if (Array.isArray(source)) {
|
|
139
|
+
const result = [];
|
|
140
|
+
refs.set(source, result);
|
|
141
|
+
source.forEach((value, index) => {
|
|
142
|
+
result[index] = Reflect.apply(clone, null, [value, refs]);
|
|
143
|
+
});
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
const result = Object.create(Object.getPrototypeOf(source));
|
|
147
|
+
refs.set(source, result);
|
|
148
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
149
|
+
const descriptor = { ...Reflect.getOwnPropertyDescriptor(source, key) };
|
|
150
|
+
if ("value" in descriptor) descriptor.value = Reflect.apply(clone, null, [descriptor.value, refs]);
|
|
151
|
+
Reflect.defineProperty(result, key, descriptor);
|
|
152
|
+
}
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Compare values recursively, treating two volatile references as equal regardless of value.
|
|
157
|
+
* Strict comparison distinguishes null/undefined, treats opaque objects by identity,
|
|
158
|
+
* compares URLs by normalized href, treats array holes as undefined, and considers distinct cyclic structures unequal.
|
|
159
|
+
* @param a - first value.
|
|
160
|
+
* @param b - second value.
|
|
161
|
+
* @param strict - whether to require strict data equality outside volatile references.
|
|
162
|
+
* @returns whether the values compare equal.
|
|
163
|
+
*/
|
|
164
|
+
function deepEqual(a, b, strict) {
|
|
165
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
166
|
+
function compare(a, b) {
|
|
167
|
+
if (a === b) return true;
|
|
168
|
+
if (isVolatile(a) || isVolatile(b)) return isVolatile(a) && isVolatile(b);
|
|
169
|
+
if (!strict && isNullable(a) && isNullable(b)) return true;
|
|
170
|
+
if (typeof a !== typeof b || typeof a !== "object" || !a || !b) return false;
|
|
171
|
+
if (ancestors.has(a)) return false;
|
|
172
|
+
function check(test, then) {
|
|
173
|
+
return test(a) ? test(b) ? then(a, b) : false : test(b) ? false : void 0;
|
|
174
|
+
}
|
|
175
|
+
ancestors.add(a);
|
|
176
|
+
try {
|
|
177
|
+
return check(Array.isArray, (a, b) => {
|
|
178
|
+
if (a.length !== b.length) return false;
|
|
179
|
+
for (let index = 0; index < a.length; index++) if (!compare(a[index], b[index])) return false;
|
|
180
|
+
return true;
|
|
181
|
+
}) ?? check(is("Date"), (a, b) => a.valueOf() === b.valueOf()) ?? check(is("URL"), (a, b) => a.href === b.href) ?? check(is("RegExp"), (a, b) => a.source === b.source && a.flags === b.flags) ?? check(isArrayBufferLike, (a, b) => {
|
|
182
|
+
if (a.byteLength !== b.byteLength) return false;
|
|
183
|
+
const viewA = new Uint8Array(a);
|
|
184
|
+
const viewB = new Uint8Array(b);
|
|
185
|
+
for (let i = 0; i < viewA.length; i++) if (viewA[i] !== viewB[i]) return false;
|
|
186
|
+
return true;
|
|
187
|
+
}) ?? ((!strict || [a, b].every((value) => Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null)) && Object.keys({
|
|
188
|
+
...a,
|
|
189
|
+
...b
|
|
190
|
+
}).every((key) => compare(a[key], b[key])));
|
|
191
|
+
} finally {
|
|
192
|
+
ancestors.delete(a);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return compare(a, b);
|
|
196
|
+
}
|
|
197
|
+
//#endregion
|
|
198
|
+
//#region ../../../vendor/cosmokit/src/time.ts
|
|
199
|
+
let Time;
|
|
200
|
+
(function(_Time) {
|
|
201
|
+
_Time.millisecond = 1;
|
|
202
|
+
const second = _Time.second = 1e3;
|
|
203
|
+
const minute = _Time.minute = second * 60;
|
|
204
|
+
const hour = _Time.hour = minute * 60;
|
|
205
|
+
const day = _Time.day = hour * 24;
|
|
206
|
+
const week = _Time.week = day * 7;
|
|
207
|
+
let timezoneOffset = (/* @__PURE__ */ new Date()).getTimezoneOffset();
|
|
208
|
+
function setTimezoneOffset(offset) {
|
|
209
|
+
timezoneOffset = offset;
|
|
210
|
+
}
|
|
211
|
+
_Time.setTimezoneOffset = setTimezoneOffset;
|
|
212
|
+
function getTimezoneOffset() {
|
|
213
|
+
return timezoneOffset;
|
|
214
|
+
}
|
|
215
|
+
_Time.getTimezoneOffset = getTimezoneOffset;
|
|
216
|
+
function getDateNumber(date = /* @__PURE__ */ new Date(), offset) {
|
|
217
|
+
if (typeof date === "number") date = new Date(date);
|
|
218
|
+
if (offset === void 0) offset = timezoneOffset;
|
|
219
|
+
return Math.floor((date.valueOf() / minute - offset) / 1440);
|
|
220
|
+
}
|
|
221
|
+
_Time.getDateNumber = getDateNumber;
|
|
222
|
+
function fromDateNumber(value, offset) {
|
|
223
|
+
const date = new Date(value * day);
|
|
224
|
+
if (offset === void 0) offset = timezoneOffset;
|
|
225
|
+
return new Date(+date + offset * minute);
|
|
226
|
+
}
|
|
227
|
+
_Time.fromDateNumber = fromDateNumber;
|
|
228
|
+
const numeric = /\d+(?:\.\d+)?/.source;
|
|
229
|
+
const timeRegExp = new RegExp(`^${[
|
|
230
|
+
"w(?:eek(?:s)?)?",
|
|
231
|
+
"d(?:ay(?:s)?)?",
|
|
232
|
+
"h(?:our(?:s)?)?",
|
|
233
|
+
"m(?:in(?:ute)?(?:s)?)?",
|
|
234
|
+
"s(?:ec(?:ond)?(?:s)?)?"
|
|
235
|
+
].map((unit) => `(${numeric}${unit})?`).join("")}$`);
|
|
236
|
+
function parseTime(source) {
|
|
237
|
+
const capture = timeRegExp.exec(source);
|
|
238
|
+
if (!capture) return 0;
|
|
239
|
+
return (parseFloat(capture[1]) * week || 0) + (parseFloat(capture[2]) * day || 0) + (parseFloat(capture[3]) * hour || 0) + (parseFloat(capture[4]) * minute || 0) + (parseFloat(capture[5]) * second || 0);
|
|
240
|
+
}
|
|
241
|
+
_Time.parseTime = parseTime;
|
|
242
|
+
function parseDate(date) {
|
|
243
|
+
const parsed = parseTime(date);
|
|
244
|
+
if (parsed) date = Date.now() + parsed;
|
|
245
|
+
else if (/^\d{1,2}(:\d{1,2}){1,2}$/.test(date)) date = `${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${date}`;
|
|
246
|
+
else if (/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(date)) date = `${(/* @__PURE__ */ new Date()).getFullYear()}-${date}`;
|
|
247
|
+
return date ? new Date(date) : /* @__PURE__ */ new Date();
|
|
248
|
+
}
|
|
249
|
+
_Time.parseDate = parseDate;
|
|
250
|
+
function format(ms) {
|
|
251
|
+
const abs = Math.abs(ms);
|
|
252
|
+
if (abs >= day - hour / 2) return Math.round(ms / day) + "d";
|
|
253
|
+
else if (abs >= hour - minute / 2) return Math.round(ms / hour) + "h";
|
|
254
|
+
else if (abs >= minute - second / 2) return Math.round(ms / minute) + "m";
|
|
255
|
+
else if (abs >= second) return Math.round(ms / second) + "s";
|
|
256
|
+
return ms + "ms";
|
|
257
|
+
}
|
|
258
|
+
_Time.format = format;
|
|
259
|
+
function toDigits(source, length = 2) {
|
|
260
|
+
return source.toString().padStart(length, "0");
|
|
261
|
+
}
|
|
262
|
+
_Time.toDigits = toDigits;
|
|
263
|
+
function template(template, time = /* @__PURE__ */ new Date()) {
|
|
264
|
+
return template.replace("yyyy", time.getFullYear().toString()).replace("yy", time.getFullYear().toString().slice(2)).replace("MM", toDigits(time.getMonth() + 1)).replace("dd", toDigits(time.getDate())).replace("hh", toDigits(time.getHours())).replace("mm", toDigits(time.getMinutes())).replace("ss", toDigits(time.getSeconds())).replace("SSS", toDigits(time.getMilliseconds(), 3));
|
|
265
|
+
}
|
|
266
|
+
_Time.template = template;
|
|
267
|
+
})(Time || (Time = {}));
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region ../../../vendor/schemastery/src/index.ts
|
|
270
|
+
const kSchema = Symbol.for("schemastery");
|
|
271
|
+
const kValidationError = Symbol.for("ValidationError");
|
|
272
|
+
globalThis.__schemastery_index__ ??= 0;
|
|
273
|
+
globalThis.__schemastery_refs__ = void 0;
|
|
274
|
+
var ValidationError = class extends TypeError {
|
|
275
|
+
options;
|
|
276
|
+
name = "ValidationError";
|
|
277
|
+
constructor(message, options) {
|
|
278
|
+
let prefix = "$";
|
|
279
|
+
for (const segment of options.path || []) if (typeof segment === "string") prefix += "." + segment;
|
|
280
|
+
else if (typeof segment === "number") prefix += "[" + segment + "]";
|
|
281
|
+
else if (typeof segment === "symbol") prefix += `[Symbol(${segment.toString()})]`;
|
|
282
|
+
if (prefix.startsWith(".")) prefix = prefix.slice(1);
|
|
283
|
+
super((prefix === "$" ? "" : `${prefix} `) + message);
|
|
284
|
+
this.options = options;
|
|
285
|
+
}
|
|
286
|
+
static is(error) {
|
|
287
|
+
return !!error?.[kValidationError];
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
Object.defineProperty(ValidationError.prototype, kValidationError, { value: true });
|
|
291
|
+
const Schema = function(options) {
|
|
292
|
+
const schema = function(data, options = {}) {
|
|
293
|
+
return Schema.resolve(data, schema, options)[0];
|
|
294
|
+
};
|
|
295
|
+
if (options.refs) {
|
|
296
|
+
const refs = mapValues(options.refs, (options) => new Schema(options));
|
|
297
|
+
const getRef = (uid) => refs[uid];
|
|
298
|
+
for (const key in refs) {
|
|
299
|
+
const options = refs[key];
|
|
300
|
+
options.sKey = getRef(options.sKey);
|
|
301
|
+
options.inner = getRef(options.inner);
|
|
302
|
+
options.list = options.list && options.list.map(getRef);
|
|
303
|
+
options.dict = options.dict && mapValues(options.dict, getRef);
|
|
304
|
+
}
|
|
305
|
+
return refs[options.uid];
|
|
306
|
+
}
|
|
307
|
+
Object.assign(schema, options);
|
|
308
|
+
if (typeof schema.callback === "string") try {
|
|
309
|
+
schema.callback = new Function("return " + schema.callback)();
|
|
310
|
+
} catch {}
|
|
311
|
+
Object.defineProperty(schema, "uid", { value: globalThis.__schemastery_index__++ });
|
|
312
|
+
Object.setPrototypeOf(schema, Schema.prototype);
|
|
313
|
+
schema.meta ||= {};
|
|
314
|
+
schema.toString = schema.toString.bind(schema);
|
|
315
|
+
return schema;
|
|
316
|
+
};
|
|
317
|
+
Schema.prototype = Object.create(Function.prototype);
|
|
318
|
+
Schema.prototype[kSchema] = true;
|
|
319
|
+
Object.defineProperty(Schema.prototype, "~standard", { get() {
|
|
320
|
+
return {
|
|
321
|
+
version: 1,
|
|
322
|
+
vendor: "schemastery",
|
|
323
|
+
validate: (value) => {
|
|
324
|
+
try {
|
|
325
|
+
return { value: Schema.resolve(value, this, {})[0] };
|
|
326
|
+
} catch (error) {
|
|
327
|
+
if (ValidationError.is(error)) return { issues: [{
|
|
328
|
+
message: error.message,
|
|
329
|
+
path: error.options.path
|
|
330
|
+
}] };
|
|
331
|
+
throw error;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
} });
|
|
336
|
+
Schema.ValidationError = ValidationError;
|
|
337
|
+
Schema.prototype.toJSON = function toJSON() {
|
|
338
|
+
if (globalThis.__schemastery_refs__) {
|
|
339
|
+
globalThis.__schemastery_refs__[this.uid] ??= JSON.parse(JSON.stringify({ ...this }));
|
|
340
|
+
return this.uid;
|
|
341
|
+
}
|
|
342
|
+
globalThis.__schemastery_refs__ = { [this.uid]: { ...this } };
|
|
343
|
+
globalThis.__schemastery_refs__[this.uid] = JSON.parse(JSON.stringify({ ...this }));
|
|
344
|
+
const result = {
|
|
345
|
+
uid: this.uid,
|
|
346
|
+
refs: globalThis.__schemastery_refs__
|
|
347
|
+
};
|
|
348
|
+
globalThis.__schemastery_refs__ = void 0;
|
|
349
|
+
return result;
|
|
350
|
+
};
|
|
351
|
+
Schema.prototype.set = function set(key, value) {
|
|
352
|
+
this.dict[key] = value;
|
|
353
|
+
return this;
|
|
354
|
+
};
|
|
355
|
+
Schema.prototype.push = function push(value) {
|
|
356
|
+
this.list.push(value);
|
|
357
|
+
return this;
|
|
358
|
+
};
|
|
359
|
+
function mergeDesc(original, messages) {
|
|
360
|
+
const result = typeof original === "string" ? { "": original } : { ...original };
|
|
361
|
+
for (const locale in messages) {
|
|
362
|
+
const value = messages[locale];
|
|
363
|
+
if (value?.$description || value?.$desc) result[locale] = value.$description || value.$desc;
|
|
364
|
+
else if (typeof value === "string") result[locale] = value;
|
|
365
|
+
}
|
|
366
|
+
return result;
|
|
367
|
+
}
|
|
368
|
+
function getInner(value) {
|
|
369
|
+
return value?.$value ?? value?.$inner;
|
|
370
|
+
}
|
|
371
|
+
function extractKeys(data) {
|
|
372
|
+
return filterKeys(data ?? {}, (key) => !key.startsWith("$"));
|
|
373
|
+
}
|
|
374
|
+
Schema.prototype.i18n = function i18n(messages) {
|
|
375
|
+
const schema = Schema(this);
|
|
376
|
+
const desc = mergeDesc(schema.meta.description, messages);
|
|
377
|
+
if (Object.keys(desc).length) schema.meta.description = desc;
|
|
378
|
+
if (schema.dict) schema.dict = mapValues(schema.dict, (inner, key) => {
|
|
379
|
+
return inner.i18n(mapValues(messages, (data) => getInner(data)?.[key] ?? data?.[key]));
|
|
380
|
+
});
|
|
381
|
+
if (schema.list) schema.list = schema.list.map((inner, index) => {
|
|
382
|
+
return inner.i18n(mapValues(messages, (data = {}) => {
|
|
383
|
+
if (Array.isArray(getInner(data))) return getInner(data)[index];
|
|
384
|
+
if (Array.isArray(data)) return data[index];
|
|
385
|
+
return extractKeys(data);
|
|
386
|
+
}));
|
|
387
|
+
});
|
|
388
|
+
if (schema.inner) schema.inner = schema.inner.i18n(mapValues(messages, (data) => {
|
|
389
|
+
if (getInner(data)) return getInner(data);
|
|
390
|
+
return extractKeys(data);
|
|
391
|
+
}));
|
|
392
|
+
if (schema.sKey) schema.sKey = schema.sKey.i18n(mapValues(messages, (data) => data?.$key));
|
|
393
|
+
return schema;
|
|
394
|
+
};
|
|
395
|
+
Schema.prototype.extra = function extra(key, value) {
|
|
396
|
+
const schema = Schema(this);
|
|
397
|
+
schema.meta = {
|
|
398
|
+
...schema.meta,
|
|
399
|
+
[key]: value
|
|
400
|
+
};
|
|
401
|
+
return schema;
|
|
402
|
+
};
|
|
403
|
+
for (const key of [
|
|
404
|
+
"required",
|
|
405
|
+
"disabled",
|
|
406
|
+
"collapse",
|
|
407
|
+
"hidden",
|
|
408
|
+
"loose"
|
|
409
|
+
]) Object.assign(Schema.prototype, { [key](value = true) {
|
|
410
|
+
const schema = Schema(this);
|
|
411
|
+
schema.meta = {
|
|
412
|
+
...schema.meta,
|
|
413
|
+
[key]: value
|
|
414
|
+
};
|
|
415
|
+
return schema;
|
|
416
|
+
} });
|
|
417
|
+
Schema.prototype.deprecated = function deprecated() {
|
|
418
|
+
const schema = Schema(this);
|
|
419
|
+
schema.meta.badges ||= [];
|
|
420
|
+
schema.meta.badges.push({
|
|
421
|
+
text: "deprecated",
|
|
422
|
+
type: "danger"
|
|
423
|
+
});
|
|
424
|
+
return schema;
|
|
425
|
+
};
|
|
426
|
+
Schema.prototype.experimental = function experimental() {
|
|
427
|
+
const schema = Schema(this);
|
|
428
|
+
schema.meta.badges ||= [];
|
|
429
|
+
schema.meta.badges.push({
|
|
430
|
+
text: "experimental",
|
|
431
|
+
type: "warning"
|
|
432
|
+
});
|
|
433
|
+
return schema;
|
|
434
|
+
};
|
|
435
|
+
Schema.prototype.pattern = function pattern(regexp) {
|
|
436
|
+
const schema = Schema(this);
|
|
437
|
+
const pattern = pick(regexp, ["source", "flags"]);
|
|
438
|
+
schema.meta = {
|
|
439
|
+
...schema.meta,
|
|
440
|
+
pattern
|
|
441
|
+
};
|
|
442
|
+
return schema;
|
|
443
|
+
};
|
|
444
|
+
Schema.prototype.simplify = function simplify(value) {
|
|
445
|
+
if (isVolatile(value)) value = value.get();
|
|
446
|
+
if (deepEqual(value, this.meta.default, this.type === "dict")) return null;
|
|
447
|
+
if (isNullable(value)) return value;
|
|
448
|
+
if (this.type === "object" || this.type === "dict") {
|
|
449
|
+
const result = {};
|
|
450
|
+
for (const key in value) {
|
|
451
|
+
const item = (this.type === "object" ? this.dict[key] : this.inner)?.simplify(value[key]);
|
|
452
|
+
if (this.type === "dict" || !isNullable(item)) result[key] = item;
|
|
453
|
+
}
|
|
454
|
+
if (deepEqual(result, this.meta.default, this.type === "dict")) return null;
|
|
455
|
+
return result;
|
|
456
|
+
} else if (this.type === "array" || this.type === "tuple") {
|
|
457
|
+
const result = [];
|
|
458
|
+
value.forEach((value, index) => {
|
|
459
|
+
const schema = this.type === "array" ? this.inner : this.list[index];
|
|
460
|
+
const item = schema ? schema.simplify(value) : value;
|
|
461
|
+
result.push(item);
|
|
462
|
+
});
|
|
463
|
+
return result;
|
|
464
|
+
} else if (this.type === "intersect") {
|
|
465
|
+
const result = {};
|
|
466
|
+
for (const item of this.list) Object.assign(result, item.simplify(value));
|
|
467
|
+
return result;
|
|
468
|
+
} else if (this.type === "union") for (const schema of this.list) try {
|
|
469
|
+
Schema.resolve(value, schema, {});
|
|
470
|
+
return schema.simplify(value);
|
|
471
|
+
} catch {}
|
|
472
|
+
return value;
|
|
473
|
+
};
|
|
474
|
+
Schema.prototype.toString = function toString(inline) {
|
|
475
|
+
return formatters[this.type]?.(this, inline) ?? `Schema<${this.type}>`;
|
|
476
|
+
};
|
|
477
|
+
Schema.prototype.role = function role(role, extra) {
|
|
478
|
+
const schema = Schema(this);
|
|
479
|
+
schema.meta = {
|
|
480
|
+
...schema.meta,
|
|
481
|
+
role,
|
|
482
|
+
extra
|
|
483
|
+
};
|
|
484
|
+
return schema;
|
|
485
|
+
};
|
|
486
|
+
for (const key of [
|
|
487
|
+
"default",
|
|
488
|
+
"link",
|
|
489
|
+
"comment",
|
|
490
|
+
"description",
|
|
491
|
+
"max",
|
|
492
|
+
"min",
|
|
493
|
+
"step"
|
|
494
|
+
]) Object.assign(Schema.prototype, { [key](value) {
|
|
495
|
+
const schema = Schema(this);
|
|
496
|
+
schema.meta = {
|
|
497
|
+
...schema.meta,
|
|
498
|
+
[key]: value
|
|
499
|
+
};
|
|
500
|
+
return schema;
|
|
501
|
+
} });
|
|
502
|
+
Schema.prototype.volatile = function volatile() {
|
|
503
|
+
if (this.meta.volatile) throw new TypeError("volatile schema is already wrapped");
|
|
504
|
+
return this.extra("volatile", true);
|
|
505
|
+
};
|
|
506
|
+
const resolvers = {};
|
|
507
|
+
const checkedVolatile = Symbol("checked-volatile-schema");
|
|
508
|
+
function validateVolatileSchema(schema, path = [], blocked = false, seen = /* @__PURE__ */ new Map()) {
|
|
509
|
+
const states = seen.get(schema) ?? /* @__PURE__ */ new Set();
|
|
510
|
+
if (states.has(blocked)) return;
|
|
511
|
+
states.add(blocked);
|
|
512
|
+
seen.set(schema, states);
|
|
513
|
+
if (schema.meta?.volatile && blocked) throw new ValidationError("volatile fields require a fixed object path without an enclosing volatile field", { path });
|
|
514
|
+
const nested = blocked || !!schema.meta?.volatile;
|
|
515
|
+
if (schema.dict) for (const [key, child] of Object.entries(schema.dict)) validateVolatileSchema(child, [...path, key], nested, seen);
|
|
516
|
+
if (schema.sKey) validateVolatileSchema(schema.sKey, [...path, "<key>"], true, seen);
|
|
517
|
+
if (schema.inner && (schema.type !== "lazy" || schema.inner[kSchema])) validateVolatileSchema(schema.inner, [...path, "*"], true, seen);
|
|
518
|
+
if (schema.list) for (let index = 0; index < schema.list.length; index++) validateVolatileSchema(schema.list[index], [...path, String(index)], true, seen);
|
|
519
|
+
}
|
|
520
|
+
Schema.extend = function extend(type, resolve) {
|
|
521
|
+
resolvers[type] = resolve;
|
|
522
|
+
};
|
|
523
|
+
Schema.resolve = function resolve(data, schema, options = {}, strict = false) {
|
|
524
|
+
if (!schema) return [data];
|
|
525
|
+
if (!options[checkedVolatile]) {
|
|
526
|
+
validateVolatileSchema(schema, options.path);
|
|
527
|
+
options = {
|
|
528
|
+
...options,
|
|
529
|
+
[checkedVolatile]: true
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
if (schema.meta?.volatile) {
|
|
533
|
+
const inner = Schema(schema);
|
|
534
|
+
inner.meta = {
|
|
535
|
+
...schema.meta,
|
|
536
|
+
volatile: false
|
|
537
|
+
};
|
|
538
|
+
const [value, adapted] = Schema.resolve(data, inner, options, strict);
|
|
539
|
+
try {
|
|
540
|
+
return [createVolatile(value), adapted];
|
|
541
|
+
} catch (error) {
|
|
542
|
+
throw new ValidationError(error instanceof Error ? error.message : String(error), options);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
if (options.ignore?.(data, schema)) return [data];
|
|
546
|
+
if (isNullable(data) && schema.type !== "lazy") {
|
|
547
|
+
if (schema.meta.required) throw new ValidationError(`missing required value`, options);
|
|
548
|
+
let current = schema;
|
|
549
|
+
let fallback = schema.meta.default;
|
|
550
|
+
while (current?.type === "intersect" && isNullable(fallback)) {
|
|
551
|
+
current = current.list[0];
|
|
552
|
+
fallback = current?.meta.default;
|
|
553
|
+
}
|
|
554
|
+
if (isNullable(fallback)) return [data];
|
|
555
|
+
data = clone(fallback);
|
|
556
|
+
}
|
|
557
|
+
const callback = resolvers[schema.type];
|
|
558
|
+
if (!callback) throw new ValidationError(`unsupported type "${schema.type}"`, options);
|
|
559
|
+
try {
|
|
560
|
+
return callback(data, schema, options, strict);
|
|
561
|
+
} catch (error) {
|
|
562
|
+
if (!schema.meta.loose) throw error;
|
|
563
|
+
return [schema.meta.default];
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
Schema.from = function from(source) {
|
|
567
|
+
if (isNullable(source)) return Schema.any();
|
|
568
|
+
else if ([
|
|
569
|
+
"string",
|
|
570
|
+
"number",
|
|
571
|
+
"boolean"
|
|
572
|
+
].includes(typeof source)) return Schema.const(source).required();
|
|
573
|
+
else if (source[kSchema]) return source;
|
|
574
|
+
else if (typeof source === "function") switch (source) {
|
|
575
|
+
case String: return Schema.string().required();
|
|
576
|
+
case Number: return Schema.number().required();
|
|
577
|
+
case Boolean: return Schema.boolean().required();
|
|
578
|
+
case Function: return Schema.function().required();
|
|
579
|
+
default: return Schema.is(source).required();
|
|
580
|
+
}
|
|
581
|
+
else throw new TypeError(`cannot infer schema from ${source}`);
|
|
582
|
+
};
|
|
583
|
+
Schema.lazy = function lazy(builder) {
|
|
584
|
+
const toJSON = () => {
|
|
585
|
+
if (!schema.inner[kSchema]) {
|
|
586
|
+
schema.inner = schema.builder();
|
|
587
|
+
schema.inner.meta = {
|
|
588
|
+
...schema.meta,
|
|
589
|
+
...schema.inner.meta
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
return schema.inner.toJSON();
|
|
593
|
+
};
|
|
594
|
+
const schema = new Schema({
|
|
595
|
+
type: "lazy",
|
|
596
|
+
builder,
|
|
597
|
+
inner: { toJSON }
|
|
598
|
+
});
|
|
599
|
+
return schema;
|
|
600
|
+
};
|
|
601
|
+
Schema.natural = function natural() {
|
|
602
|
+
return Schema.number().step(1).min(0);
|
|
603
|
+
};
|
|
604
|
+
Schema.percent = function percent() {
|
|
605
|
+
return Schema.number().step(.01).min(0).max(1).role("slider");
|
|
606
|
+
};
|
|
607
|
+
Schema.date = function date() {
|
|
608
|
+
return Schema.union([Schema.is(Date), Schema.transform(Schema.string().role("datetime"), (value, options) => {
|
|
609
|
+
const date = new Date(value);
|
|
610
|
+
if (isNaN(+date)) throw new ValidationError(`invalid date "${value}"`, options);
|
|
611
|
+
return date;
|
|
612
|
+
}, true)]);
|
|
613
|
+
};
|
|
614
|
+
Schema.regExp = function regExp(flag = "") {
|
|
615
|
+
return Schema.union([Schema.is(RegExp), Schema.transform(Schema.string().role("regexp", { flag }), (value, options) => {
|
|
616
|
+
try {
|
|
617
|
+
return new RegExp(value, flag);
|
|
618
|
+
} catch (e) {
|
|
619
|
+
throw new ValidationError(e.message, options);
|
|
620
|
+
}
|
|
621
|
+
}, true)]);
|
|
622
|
+
};
|
|
623
|
+
Schema.arrayBuffer = function arrayBuffer(encoding) {
|
|
624
|
+
return Schema.union([
|
|
625
|
+
Schema.is(ArrayBuffer),
|
|
626
|
+
Schema.is(SharedArrayBuffer),
|
|
627
|
+
Schema.transform(Schema.any(), (value, options) => {
|
|
628
|
+
if (Binary.isSource(value)) return Binary.fromSource(value);
|
|
629
|
+
throw new ValidationError(`expected ArrayBufferSource but got ${value}`, options);
|
|
630
|
+
}, true),
|
|
631
|
+
...encoding ? [Schema.transform(Schema.string(), (value, options) => {
|
|
632
|
+
try {
|
|
633
|
+
return encoding === "base64" ? Binary.fromBase64(value) : Binary.fromHex(value);
|
|
634
|
+
} catch (e) {
|
|
635
|
+
throw new ValidationError(e.message, options);
|
|
636
|
+
}
|
|
637
|
+
}, true)] : []
|
|
638
|
+
]);
|
|
639
|
+
};
|
|
640
|
+
Schema.extend("lazy", (data, schema, options, strict) => {
|
|
641
|
+
if (!schema.inner[kSchema]) {
|
|
642
|
+
schema.inner = schema.builder();
|
|
643
|
+
schema.inner.meta = {
|
|
644
|
+
...schema.meta,
|
|
645
|
+
...schema.inner.meta
|
|
646
|
+
};
|
|
647
|
+
validateVolatileSchema(schema.inner, options.path, true);
|
|
648
|
+
}
|
|
649
|
+
return Schema.resolve(data, schema.inner, options, strict);
|
|
650
|
+
});
|
|
651
|
+
Schema.extend("any", (data) => {
|
|
652
|
+
return [data];
|
|
653
|
+
});
|
|
654
|
+
Schema.extend("never", (data, _, options) => {
|
|
655
|
+
throw new ValidationError(`expected nullable but got ${data}`, options);
|
|
656
|
+
});
|
|
657
|
+
Schema.extend("const", (data, { value }, options) => {
|
|
658
|
+
if (deepEqual(data, value)) return [value];
|
|
659
|
+
throw new ValidationError(`expected ${value} but got ${data}`, options);
|
|
660
|
+
});
|
|
661
|
+
function checkWithinRange(data, meta, description, options, skipMin = false) {
|
|
662
|
+
const { max = Infinity, min = -Infinity } = meta;
|
|
663
|
+
if (data > max) throw new ValidationError(`expected ${description} <= ${max} but got ${data}`, options);
|
|
664
|
+
if (data < min && !skipMin) throw new ValidationError(`expected ${description} >= ${min} but got ${data}`, options);
|
|
665
|
+
}
|
|
666
|
+
Schema.extend("string", (data, { meta }, options) => {
|
|
667
|
+
if (typeof data !== "string") throw new ValidationError(`expected string but got ${data}`, options);
|
|
668
|
+
if (meta.pattern) {
|
|
669
|
+
const regexp = new RegExp(meta.pattern.source, meta.pattern.flags);
|
|
670
|
+
if (!regexp.test(data)) throw new ValidationError(`expect string to match regexp ${regexp}`, options);
|
|
671
|
+
}
|
|
672
|
+
checkWithinRange(data.length, meta, "string length", options);
|
|
673
|
+
return [data];
|
|
674
|
+
});
|
|
675
|
+
function decimalShift(data, digits) {
|
|
676
|
+
const str = data.toString();
|
|
677
|
+
if (str.includes("e")) return data * Math.pow(10, digits);
|
|
678
|
+
const index = str.indexOf(".");
|
|
679
|
+
if (index === -1) return data * Math.pow(10, digits);
|
|
680
|
+
const frac = str.slice(index + 1);
|
|
681
|
+
const integer = str.slice(0, index);
|
|
682
|
+
if (frac.length <= digits) return +(integer + frac.padEnd(digits, "0"));
|
|
683
|
+
return +(integer + frac.slice(0, digits) + "." + frac.slice(digits));
|
|
684
|
+
}
|
|
685
|
+
function isMultipleOf(data, min, step) {
|
|
686
|
+
step = Math.abs(step);
|
|
687
|
+
if (!/^\d+\.\d+$/.test(step.toString())) return (data - min) % step === 0;
|
|
688
|
+
const index = step.toString().indexOf(".");
|
|
689
|
+
const digits = step.toString().slice(index + 1).length;
|
|
690
|
+
return Math.abs(decimalShift(data, digits) - decimalShift(min, digits)) % decimalShift(step, digits) === 0;
|
|
691
|
+
}
|
|
692
|
+
Schema.extend("number", (data, { meta }, options) => {
|
|
693
|
+
if (typeof data !== "number") throw new ValidationError(`expected number but got ${data}`, options);
|
|
694
|
+
checkWithinRange(data, meta, "number", options);
|
|
695
|
+
const { step } = meta;
|
|
696
|
+
if (step && !isMultipleOf(data, meta.min ?? 0, step)) throw new ValidationError(`expected number multiple of ${step} but got ${data}`, options);
|
|
697
|
+
return [data];
|
|
698
|
+
});
|
|
699
|
+
Schema.extend("boolean", (data, _, options) => {
|
|
700
|
+
if (typeof data === "boolean") return [data];
|
|
701
|
+
throw new ValidationError(`expected boolean but got ${data}`, options);
|
|
702
|
+
});
|
|
703
|
+
Schema.extend("bitset", (data, { bits, meta }, options) => {
|
|
704
|
+
let value = 0, keys = [];
|
|
705
|
+
if (typeof data === "number") {
|
|
706
|
+
value = data;
|
|
707
|
+
for (const key in bits) if (data & bits[key]) keys.push(key);
|
|
708
|
+
} else if (Array.isArray(data)) {
|
|
709
|
+
keys = data;
|
|
710
|
+
for (const key of keys) {
|
|
711
|
+
if (typeof key !== "string") throw new ValidationError(`expected string but got ${key}`, options);
|
|
712
|
+
if (key in bits) value |= bits[key];
|
|
713
|
+
}
|
|
714
|
+
} else throw new ValidationError(`expected number or array but got ${data}`, options);
|
|
715
|
+
if (value === meta.default) return [value];
|
|
716
|
+
return [value, keys];
|
|
717
|
+
});
|
|
718
|
+
Schema.extend("function", (data, _, options) => {
|
|
719
|
+
if (typeof data === "function") return [data];
|
|
720
|
+
throw new ValidationError(`expected function but got ${data}`, options);
|
|
721
|
+
});
|
|
722
|
+
Schema.extend("is", (data, { constructor }, options) => {
|
|
723
|
+
if (typeof constructor === "function") {
|
|
724
|
+
if (data instanceof constructor) return [data];
|
|
725
|
+
throw new ValidationError(`expected ${constructor.name} but got ${data}`, options);
|
|
726
|
+
} else {
|
|
727
|
+
if (isNullable(data)) throw new ValidationError(`expected ${constructor} but got ${data}`, options);
|
|
728
|
+
let prototype = Object.getPrototypeOf(data);
|
|
729
|
+
while (prototype) {
|
|
730
|
+
if (prototype.constructor?.name === constructor) return [data];
|
|
731
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
732
|
+
}
|
|
733
|
+
throw new ValidationError(`expected ${constructor} but got ${data}`, options);
|
|
734
|
+
}
|
|
735
|
+
});
|
|
736
|
+
function property(data, key, schema, options) {
|
|
737
|
+
try {
|
|
738
|
+
const [value, adapted] = Schema.resolve(data[key], schema, {
|
|
739
|
+
...options,
|
|
740
|
+
path: [...options.path || [], key]
|
|
741
|
+
});
|
|
742
|
+
if (adapted !== void 0) data[key] = adapted;
|
|
743
|
+
return value;
|
|
744
|
+
} catch (e) {
|
|
745
|
+
if (!options?.autofix) throw e;
|
|
746
|
+
delete data[key];
|
|
747
|
+
return schema.meta.volatile ? createVolatile(schema.meta.default) : schema.meta.default;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
Schema.extend("array", (data, { inner, meta }, options) => {
|
|
751
|
+
if (!Array.isArray(data)) throw new ValidationError(`expected array but got ${data}`, options);
|
|
752
|
+
checkWithinRange(data.length, meta, "array length", options, !isNullable(inner.meta.default));
|
|
753
|
+
return [data.map((_, index) => property(data, index, inner, options))];
|
|
754
|
+
});
|
|
755
|
+
Schema.extend("dict", (data, { inner, sKey }, options, strict) => {
|
|
756
|
+
if (!isPlainObject(data)) throw new ValidationError(`expected object but got ${data}`, options);
|
|
757
|
+
const result = {};
|
|
758
|
+
for (const key in data) {
|
|
759
|
+
let rKey;
|
|
760
|
+
try {
|
|
761
|
+
rKey = Schema.resolve(key, sKey, options)[0];
|
|
762
|
+
} catch (error) {
|
|
763
|
+
if (strict) continue;
|
|
764
|
+
throw error;
|
|
765
|
+
}
|
|
766
|
+
result[rKey] = property(data, key, inner, options);
|
|
767
|
+
data[rKey] = data[key];
|
|
768
|
+
if (key !== rKey) delete data[key];
|
|
769
|
+
}
|
|
770
|
+
return [result];
|
|
771
|
+
});
|
|
772
|
+
Schema.extend("tuple", (data, { list }, options, strict) => {
|
|
773
|
+
if (!Array.isArray(data)) throw new ValidationError(`expected array but got ${data}`, options);
|
|
774
|
+
const result = list.map((inner, index) => property(data, index, inner, options));
|
|
775
|
+
if (strict) return [result];
|
|
776
|
+
result.push(...data.slice(list.length));
|
|
777
|
+
return [result];
|
|
778
|
+
});
|
|
779
|
+
function merge(result, data) {
|
|
780
|
+
for (const key in data) {
|
|
781
|
+
if (key in result) continue;
|
|
782
|
+
result[key] = data[key];
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
Schema.extend("object", (data, { dict }, options, strict) => {
|
|
786
|
+
if (!isPlainObject(data)) throw new ValidationError(`expected object but got ${data}`, options);
|
|
787
|
+
const result = {};
|
|
788
|
+
for (const key in dict) {
|
|
789
|
+
const value = property(data, key, dict[key], options);
|
|
790
|
+
if (!isNullable(value) || key in data) result[key] = value;
|
|
791
|
+
}
|
|
792
|
+
if (!strict) merge(result, data);
|
|
793
|
+
return [result];
|
|
794
|
+
});
|
|
795
|
+
Schema.extend("union", (data, { list, toString }, options, strict) => {
|
|
796
|
+
const messages = [];
|
|
797
|
+
for (const inner of list) try {
|
|
798
|
+
return Schema.resolve(data, inner, options, strict);
|
|
799
|
+
} catch (error) {
|
|
800
|
+
messages.push(error);
|
|
801
|
+
}
|
|
802
|
+
throw new ValidationError(`expected ${toString()} but got ${JSON.stringify(data)}`, options);
|
|
803
|
+
});
|
|
804
|
+
Schema.extend("intersect", (data, { list, toString }, options, strict) => {
|
|
805
|
+
if (!list.length) return [data];
|
|
806
|
+
let result;
|
|
807
|
+
for (const inner of list) {
|
|
808
|
+
const value = Schema.resolve(data, inner, options, true)[0];
|
|
809
|
+
if (isNullable(value)) continue;
|
|
810
|
+
if (isNullable(result)) result = value;
|
|
811
|
+
else if (typeof result !== typeof value) throw new ValidationError(`expected ${toString()} but got ${JSON.stringify(data)}`, options);
|
|
812
|
+
else if (typeof value === "object") merge(result ??= {}, value);
|
|
813
|
+
else if (result !== value) throw new ValidationError(`expected ${toString()} but got ${JSON.stringify(data)}`, options);
|
|
814
|
+
}
|
|
815
|
+
if (!strict && isPlainObject(data)) merge(result, data);
|
|
816
|
+
return [result];
|
|
817
|
+
});
|
|
818
|
+
Schema.extend("transform", (data, { inner, callback, preserve }, options) => {
|
|
819
|
+
const [result, adapted = data] = Schema.resolve(data, inner, options, true);
|
|
820
|
+
if (preserve) return [callback(result)];
|
|
821
|
+
else return [callback(result), callback(adapted)];
|
|
822
|
+
});
|
|
823
|
+
const formatters = {};
|
|
824
|
+
function defineMethod(name, keys, format) {
|
|
825
|
+
formatters[name] = format;
|
|
826
|
+
Object.assign(Schema, { [name](...args) {
|
|
827
|
+
const schema = new Schema({ type: name });
|
|
828
|
+
keys.forEach((key, index) => {
|
|
829
|
+
switch (key) {
|
|
830
|
+
case "sKey":
|
|
831
|
+
schema.sKey = args[index] ?? Schema.string();
|
|
832
|
+
break;
|
|
833
|
+
case "inner":
|
|
834
|
+
schema.inner = Schema.from(args[index]);
|
|
835
|
+
break;
|
|
836
|
+
case "list":
|
|
837
|
+
schema.list = args[index].map(Schema.from);
|
|
838
|
+
break;
|
|
839
|
+
case "dict":
|
|
840
|
+
schema.dict = mapValues(args[index], Schema.from);
|
|
841
|
+
break;
|
|
842
|
+
case "bits":
|
|
843
|
+
schema.bits = {};
|
|
844
|
+
for (const key in args[index]) {
|
|
845
|
+
if (typeof args[index][key] !== "number") continue;
|
|
846
|
+
schema.bits[key] = args[index][key];
|
|
847
|
+
}
|
|
848
|
+
break;
|
|
849
|
+
case "callback": {
|
|
850
|
+
const callback = schema.callback = args[index];
|
|
851
|
+
callback["toJSON"] ||= () => callback.toString();
|
|
852
|
+
break;
|
|
853
|
+
}
|
|
854
|
+
case "constructor": {
|
|
855
|
+
const constructor = schema.constructor = args[index];
|
|
856
|
+
if (typeof constructor === "function") constructor["toJSON"] ||= () => constructor["name"];
|
|
857
|
+
break;
|
|
858
|
+
}
|
|
859
|
+
default: schema[key] = args[index];
|
|
860
|
+
}
|
|
861
|
+
});
|
|
862
|
+
if (name === "object" || name === "dict") schema.meta.default = {};
|
|
863
|
+
else if (name === "array" || name === "tuple") schema.meta.default = [];
|
|
864
|
+
else if (name === "bitset") schema.meta.default = 0;
|
|
865
|
+
return schema;
|
|
866
|
+
} });
|
|
867
|
+
}
|
|
868
|
+
defineMethod("is", ["constructor"], ({ constructor }) => {
|
|
869
|
+
if (typeof constructor === "function") return constructor.name;
|
|
870
|
+
else return constructor;
|
|
871
|
+
});
|
|
872
|
+
defineMethod("any", [], () => "any");
|
|
873
|
+
defineMethod("never", [], () => "never");
|
|
874
|
+
defineMethod("const", ["value"], ({ value }) => typeof value === "string" ? JSON.stringify(value) : value);
|
|
875
|
+
defineMethod("string", [], () => "string");
|
|
876
|
+
defineMethod("number", [], () => "number");
|
|
877
|
+
defineMethod("boolean", [], () => "boolean");
|
|
878
|
+
defineMethod("bitset", ["bits"], () => "bitset");
|
|
879
|
+
defineMethod("function", [], () => "function");
|
|
880
|
+
defineMethod("array", ["inner"], ({ inner }) => `${inner.toString(true)}[]`);
|
|
881
|
+
defineMethod("dict", ["inner", "sKey"], ({ inner, sKey }) => `{ [key: ${sKey.toString()}]: ${inner.toString()} }`);
|
|
882
|
+
defineMethod("tuple", ["list"], ({ list }) => `[${list.map((inner) => inner.toString()).join(", ")}]`);
|
|
883
|
+
defineMethod("object", ["dict"], ({ dict }) => {
|
|
884
|
+
if (Object.keys(dict).length === 0) return "{}";
|
|
885
|
+
return `{ ${Object.entries(dict).map(([key, inner]) => {
|
|
886
|
+
return `${key}${inner.meta.required ? "" : "?"}: ${inner.toString()}`;
|
|
887
|
+
}).join(", ")} }`;
|
|
888
|
+
});
|
|
889
|
+
defineMethod("union", ["list"], ({ list }, inline) => {
|
|
890
|
+
const result = list.map(({ toString: format }) => format()).join(" | ");
|
|
891
|
+
return inline ? `(${result})` : result;
|
|
892
|
+
});
|
|
893
|
+
defineMethod("intersect", ["list"], ({ list }) => {
|
|
894
|
+
return `${list.map((inner) => inner.toString(true)).join(" & ")}`;
|
|
895
|
+
});
|
|
896
|
+
defineMethod("transform", [
|
|
897
|
+
"inner",
|
|
898
|
+
"callback",
|
|
899
|
+
"preserve"
|
|
900
|
+
], ({ inner }, isInner) => inner.toString(isInner));
|
|
901
|
+
//#endregion
|
|
902
|
+
//#region lib/types/contact-config.js
|
|
903
|
+
/** Public questionnaire deployment options shared by Host and Client. */
|
|
904
|
+
/** Validate public questionnaire options. */
|
|
905
|
+
const Config = Schema.object({
|
|
906
|
+
contactFormUrl: Schema.string().pattern(/^https:\/\/[^/\s]+\//).default("https://trtgsjkv6r.feishu.cn/share/base/form/shrcnhcHE4A6lQaQ3v0raCXmBAg"),
|
|
907
|
+
contactSource: Schema.string().default("")
|
|
908
|
+
});
|
|
909
|
+
//#endregion
|
|
910
|
+
//#region lib/types/client/contact-url.js
|
|
911
|
+
/**
|
|
912
|
+
* Build an external questionnaire URL without authentication credentials.
|
|
913
|
+
* @param config - questionnaire destination and supported source option.
|
|
914
|
+
* @param context - currently available account and browser environment.
|
|
915
|
+
* @returns questionnaire URL with hidden, optionally prefilled context fields.
|
|
916
|
+
*/
|
|
917
|
+
function contactUrl(config, context) {
|
|
918
|
+
const url = new URL(config.contactFormUrl);
|
|
919
|
+
const ratio = Number.isFinite(context.pixelRatio) ? context.pixelRatio : 1;
|
|
920
|
+
const width = Math.round(context.width * ratio);
|
|
921
|
+
const height = Math.round(context.height * ratio);
|
|
922
|
+
const fields = {
|
|
923
|
+
uid: context.uid,
|
|
924
|
+
source: config.contactSource,
|
|
925
|
+
app_version: context.version,
|
|
926
|
+
os_version: void 0,
|
|
927
|
+
device_brand: void 0,
|
|
928
|
+
device_model: void 0,
|
|
929
|
+
app_locale: context.locale,
|
|
930
|
+
screen_resolution: width > 0 && height > 0 ? `${width}x${height}` : void 0
|
|
931
|
+
};
|
|
932
|
+
for (const [name, value] of Object.entries(fields)) {
|
|
933
|
+
url.searchParams.set(`hide_${name}`, "1");
|
|
934
|
+
url.searchParams.delete(`prefill_${name}`);
|
|
935
|
+
if (value) url.searchParams.set(`prefill_${name}`, value);
|
|
936
|
+
}
|
|
937
|
+
return url.href;
|
|
938
|
+
}
|
|
939
|
+
//#endregion
|
|
940
|
+
//#region \0dsh-css:/home/runner/work/deepseek-harness/deepseek-harness/packages/client/ui-settings-account/src/client/SignInDialog.module.css.mjs
|
|
941
|
+
const css$4 = "._76YFJG_dialog{user-select:none;box-sizing:border-box;border:.5px solid var(--dsw-alias-border-inverted)}._76YFJG_content{flex-direction:column;width:100%;display:flex}._76YFJG_header{justify-content:space-between;align-items:center;gap:8px;padding:22px 24px 12px;display:flex}._76YFJG_title{color:var(--dsw-alias-label-primary);margin:0;font-size:16px;font-weight:500;line-height:24px}._76YFJG_close{box-sizing:border-box;width:28px;height:28px;color:var(--dsw-alias-label-primary);cursor:pointer;background:0 0;border:0;border-radius:28px;flex:none;justify-content:center;align-items:center;padding:6px;display:inline-flex}._76YFJG_close:hover{background:var(--dsw-alias-interactive-bg-hover)}._76YFJG_actions{box-sizing:border-box;justify-content:flex-end;align-items:center;gap:8px;width:100%;padding:0 24px;display:flex}._76YFJG_primaryButton,._76YFJG_secondaryButton{box-sizing:border-box;border-radius:12px;min-width:72px;height:36px;font-size:14px;line-height:22px}._76YFJG_primaryButton{padding:0 16px;font-weight:500}._76YFJG_secondaryButton{border:.5px solid var(--dsw-alias-border-l2);padding:0 14px}._76YFJG_description{color:var(--dsw-alias-label-primary);margin:0;padding:0 24px;font-size:14px;line-height:22px}._76YFJG_link{color:inherit;font:inherit;cursor:pointer;background:0 0;border:0;padding:0;text-decoration:underline}._76YFJG_spinner{flex:none;animation:1s linear infinite _76YFJG_spin}._76YFJG_primaryButton:has(._76YFJG_spinner){opacity:1}@keyframes _76YFJG_spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){._76YFJG_spinner{animation:none}}";
|
|
942
|
+
const tagId$4 = "@deepseek-ai/dsh-client-ui-settings-account/SignInDialog.module.css";
|
|
943
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$4) + "]") === null) {
|
|
944
|
+
const tag = document.createElement("style");
|
|
945
|
+
tag.dataset.plugin = "@deepseek-ai/dsh-client-ui-settings-account";
|
|
946
|
+
tag.dataset.pluginCss = tagId$4;
|
|
947
|
+
tag.textContent = css$4;
|
|
948
|
+
document.head.appendChild(tag);
|
|
949
|
+
}
|
|
950
|
+
var SignInDialog_module_css_default = {
|
|
951
|
+
"actions": "_76YFJG_actions",
|
|
952
|
+
"close": "_76YFJG_close",
|
|
953
|
+
"content": "_76YFJG_content",
|
|
954
|
+
"description": "_76YFJG_description",
|
|
955
|
+
"dialog": "_76YFJG_dialog",
|
|
956
|
+
"header": "_76YFJG_header",
|
|
957
|
+
"link": "_76YFJG_link",
|
|
958
|
+
"primaryButton": "_76YFJG_primaryButton",
|
|
959
|
+
"secondaryButton": "_76YFJG_secondaryButton",
|
|
960
|
+
"spin": "_76YFJG_spin",
|
|
961
|
+
"spinner": "_76YFJG_spinner",
|
|
962
|
+
"title": "_76YFJG_title"
|
|
963
|
+
};
|
|
964
|
+
//#endregion
|
|
965
|
+
//#region lib/types/client/SignInDialog.js
|
|
966
|
+
/** Account authorization dialog; errors allow retry after cancelling any active attempt. */
|
|
967
|
+
/** @param props - safe account state, localized copy, and user actions. @returns login dialog. */
|
|
968
|
+
function SignInDialog({ account, start, cancel, close, useApiKey, t }) {
|
|
969
|
+
const [busy, setBusy] = (0, react.useState)(false);
|
|
970
|
+
const [failed, setFailed] = (0, react.useState)(false);
|
|
971
|
+
const [copyResult, setCopyResult] = (0, react.useState)(null);
|
|
972
|
+
const attempt = account.view?.attempt;
|
|
973
|
+
(0, react.useEffect)(() => {
|
|
974
|
+
setCopyResult(null);
|
|
975
|
+
}, [attempt?.id, attempt?.authorizeUrl]);
|
|
976
|
+
(0, react.useEffect)(() => {
|
|
977
|
+
if (copyResult === null) return;
|
|
978
|
+
const timer = setTimeout(() => {
|
|
979
|
+
setCopyResult(null);
|
|
980
|
+
}, 2e3);
|
|
981
|
+
return () => {
|
|
982
|
+
clearTimeout(timer);
|
|
983
|
+
};
|
|
984
|
+
}, [copyResult]);
|
|
985
|
+
const authorizeUrl = attempt?.authorizeUrl;
|
|
986
|
+
const phase = attempt?.phase;
|
|
987
|
+
const active = busy || phase === "initializing" || phase === "waiting-browser" || phase === "exchanging" || phase === "committing";
|
|
988
|
+
const expired = phase === "expired";
|
|
989
|
+
const error = failed || account.loginFailed || account.failed || phase === "failed";
|
|
990
|
+
const waiting = active && !error;
|
|
991
|
+
const committing = phase === "committing";
|
|
992
|
+
(0, react.useEffect)(() => {
|
|
993
|
+
if (account.view?.status === "credential-stored") close();
|
|
994
|
+
}, [account.view?.status, close]);
|
|
995
|
+
const run = async (action) => {
|
|
996
|
+
setBusy(true);
|
|
997
|
+
setFailed(false);
|
|
998
|
+
try {
|
|
999
|
+
await action();
|
|
1000
|
+
} catch {
|
|
1001
|
+
setFailed(true);
|
|
1002
|
+
} finally {
|
|
1003
|
+
setBusy(false);
|
|
1004
|
+
}
|
|
1005
|
+
};
|
|
1006
|
+
const dismiss = () => {
|
|
1007
|
+
if (committing || busy) return;
|
|
1008
|
+
if (active && attempt) run(async () => {
|
|
1009
|
+
await cancel(attempt.id);
|
|
1010
|
+
close();
|
|
1011
|
+
});
|
|
1012
|
+
else close();
|
|
1013
|
+
};
|
|
1014
|
+
const retry = async () => {
|
|
1015
|
+
if (active && attempt) await cancel(attempt.id);
|
|
1016
|
+
await start();
|
|
1017
|
+
};
|
|
1018
|
+
const copyLink = async (authorizeUrl) => {
|
|
1019
|
+
try {
|
|
1020
|
+
await navigator.clipboard.writeText(authorizeUrl);
|
|
1021
|
+
setCopyResult({ messageKey: "copiedLink" });
|
|
1022
|
+
} catch {
|
|
1023
|
+
setCopyResult({ messageKey: "copyFailed" });
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
1026
|
+
const title = error ? t("failureTitle") : active ? t("browserTitle") : expired ? t("timeoutTitle") : t("loginTitle");
|
|
1027
|
+
return (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
|
|
1028
|
+
open: true,
|
|
1029
|
+
headless: true,
|
|
1030
|
+
title,
|
|
1031
|
+
onClose: dismiss,
|
|
1032
|
+
className: SignInDialog_module_css_default.dialog,
|
|
1033
|
+
children: [(0, react_jsx_runtime.jsxs)("div", {
|
|
1034
|
+
className: SignInDialog_module_css_default.content,
|
|
1035
|
+
children: [(0, react_jsx_runtime.jsxs)("div", {
|
|
1036
|
+
className: SignInDialog_module_css_default.header,
|
|
1037
|
+
children: [(0, react_jsx_runtime.jsx)("h2", {
|
|
1038
|
+
className: SignInDialog_module_css_default.title,
|
|
1039
|
+
children: title
|
|
1040
|
+
}), (0, react_jsx_runtime.jsx)("button", {
|
|
1041
|
+
type: "button",
|
|
1042
|
+
className: SignInDialog_module_css_default.close,
|
|
1043
|
+
"aria-label": t("close"),
|
|
1044
|
+
onClick: dismiss,
|
|
1045
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCloseOutlineRegular, { size: 14 })
|
|
1046
|
+
})]
|
|
1047
|
+
}), waiting ? (0, react_jsx_runtime.jsxs)("p", {
|
|
1048
|
+
className: SignInDialog_module_css_default.description,
|
|
1049
|
+
children: [
|
|
1050
|
+
t("browserPrompt"),
|
|
1051
|
+
(0, react_jsx_runtime.jsx)("button", {
|
|
1052
|
+
type: "button",
|
|
1053
|
+
className: SignInDialog_module_css_default.link,
|
|
1054
|
+
disabled: !authorizeUrl,
|
|
1055
|
+
onClick: authorizeUrl ? () => {
|
|
1056
|
+
copyLink(authorizeUrl);
|
|
1057
|
+
} : void 0,
|
|
1058
|
+
children: t(copyResult?.messageKey ?? "copyLink")
|
|
1059
|
+
}),
|
|
1060
|
+
t("browserDescription")
|
|
1061
|
+
]
|
|
1062
|
+
}) : (0, react_jsx_runtime.jsx)("p", {
|
|
1063
|
+
className: SignInDialog_module_css_default.description,
|
|
1064
|
+
children: error ? t("failed") : expired ? t("timeoutDescription") : t("loginDescription")
|
|
1065
|
+
})]
|
|
1066
|
+
}), (0, react_jsx_runtime.jsxs)("div", {
|
|
1067
|
+
className: SignInDialog_module_css_default.actions,
|
|
1068
|
+
children: [(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
1069
|
+
variant: "outline",
|
|
1070
|
+
className: SignInDialog_module_css_default.secondaryButton,
|
|
1071
|
+
disabled: committing || busy,
|
|
1072
|
+
onClick: active ? dismiss : useApiKey,
|
|
1073
|
+
children: t(active ? "cancel" : "addApiKey")
|
|
1074
|
+
}), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
1075
|
+
variant: "primary",
|
|
1076
|
+
className: SignInDialog_module_css_default.primaryButton,
|
|
1077
|
+
disabled: busy || committing || waiting || account.view === void 0,
|
|
1078
|
+
"aria-label": waiting ? t("waiting") : void 0,
|
|
1079
|
+
onClick: () => {
|
|
1080
|
+
run(retry);
|
|
1081
|
+
},
|
|
1082
|
+
children: waiting ? (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconLoadingOutlineRegular, { className: SignInDialog_module_css_default.spinner }) : t(expired || error ? "retry" : "signIn")
|
|
1083
|
+
})]
|
|
1084
|
+
})]
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
//#endregion
|
|
1088
|
+
//#region lib/types/client/AccountOnboarding.js
|
|
1089
|
+
/** Account choice inside the model credential onboarding step. */
|
|
1090
|
+
/** @param props - onboarding completion, account state and actions. @returns account dialog while signed out. */
|
|
1091
|
+
function AccountOnboarding({ complete, useApiKey, useAccount, setOnboarding, showLogin, start, cancel, t }) {
|
|
1092
|
+
const account = useAccount((value) => value);
|
|
1093
|
+
(0, react.useEffect)(() => {
|
|
1094
|
+
setOnboarding(true);
|
|
1095
|
+
return () => {
|
|
1096
|
+
setOnboarding(false);
|
|
1097
|
+
};
|
|
1098
|
+
}, [setOnboarding]);
|
|
1099
|
+
(0, react.useEffect)(() => {
|
|
1100
|
+
if (account.view?.status === "credential-stored") complete();
|
|
1101
|
+
}, [account.view?.status, complete]);
|
|
1102
|
+
if (!account.view || account.view.status === "credential-stored") return null;
|
|
1103
|
+
return (0, react_jsx_runtime.jsx)(SignInDialog, {
|
|
1104
|
+
account,
|
|
1105
|
+
start,
|
|
1106
|
+
cancel,
|
|
1107
|
+
t,
|
|
1108
|
+
close: () => {
|
|
1109
|
+
showLogin(false);
|
|
1110
|
+
complete();
|
|
1111
|
+
},
|
|
1112
|
+
useApiKey: () => {
|
|
1113
|
+
showLogin(false);
|
|
1114
|
+
useApiKey();
|
|
1115
|
+
}
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1118
|
+
//#endregion
|
|
1119
|
+
//#region lib/types/client/LogoutIcon.js
|
|
1120
|
+
/** Figma IcDsLogOutOutline16 glyph, stored inline for theme-aware rendering. */
|
|
1121
|
+
/** @returns the account menu logout glyph. */
|
|
1122
|
+
function LogoutIcon() {
|
|
1123
|
+
return (0, react_jsx_runtime.jsx)("span", {
|
|
1124
|
+
style: {
|
|
1125
|
+
width: 16,
|
|
1126
|
+
height: 16,
|
|
1127
|
+
position: "relative"
|
|
1128
|
+
},
|
|
1129
|
+
"aria-hidden": "true",
|
|
1130
|
+
children: (0, react_jsx_runtime.jsxs)("svg", {
|
|
1131
|
+
style: {
|
|
1132
|
+
position: "absolute",
|
|
1133
|
+
left: 1.168,
|
|
1134
|
+
top: 1.214
|
|
1135
|
+
},
|
|
1136
|
+
width: "13.664",
|
|
1137
|
+
height: "13.571",
|
|
1138
|
+
viewBox: "0 0 14 14",
|
|
1139
|
+
fill: "none",
|
|
1140
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1141
|
+
children: [(0, react_jsx_runtime.jsx)("path", {
|
|
1142
|
+
d: "M3.9961 1.40039C3.37842 1.40039 2.96028 1.40039 2.63867 1.42871C2.32631 1.45627 2.17171 1.50666 2.06641 1.56543C1.85606 1.68288 1.68189 1.85605 1.56446 2.06641C1.50569 2.17173 1.45625 2.32627 1.42871 2.63867C1.40036 2.9603 1.39942 3.37827 1.39942 3.9961L1.39942 9.5752C1.39942 10.193 1.40036 10.611 1.42871 10.9326C1.45625 11.245 1.50569 11.3996 1.56445 11.5049C1.68188 11.7153 1.85605 11.8884 2.06641 12.0059C2.17171 12.0646 2.32631 12.115 2.63867 12.1426C2.96028 12.1709 3.37842 12.1709 3.9961 12.1709V13.5713C3.4033 13.5713 2.91297 13.5721 2.51563 13.5371C2.10906 13.5013 1.73277 13.4233 1.38379 13.2285C0.946838 12.9845 0.585697 12.6235 0.341799 12.1865C0.14725 11.8377 0.0700118 11.4621 0.0341815 11.0557C-0.000847399 10.6583 1.58129e-06 10.1681 1.85029e-06 9.5752L2.09416e-06 3.9961C1.83027e-06 3.40325 -0.000846367 2.91297 0.0341818 2.51563C0.0700164 2.10924 0.147239 1.73362 0.341799 1.38477C0.585703 0.947758 0.946825 0.586744 1.38379 0.342775C1.73277 0.148001 2.10906 0.0700381 2.51563 0.0341813C2.91297 -0.000823893 3.40331 1.37805e-06 3.9961 1.71712e-06L3.9961 1.40039Z",
|
|
1143
|
+
fill: "currentColor"
|
|
1144
|
+
}), (0, react_jsx_runtime.jsx)("path", {
|
|
1145
|
+
d: "M13.6426 6.51953C13.6705 6.6957 13.6705 6.8756 13.6426 7.05176C13.5902 7.38188 13.4302 7.64112 13.2539 7.86035C13.0857 8.06937 12.8546 8.29971 12.6006 8.55371L9.3086 11.8447L8.31836 10.8545L11.6104 7.56348C11.637 7.53681 11.6628 7.51104 11.6875 7.48633H3.74317V6.08594H11.6885C11.6635 6.06088 11.6374 6.03487 11.6104 6.00781L8.31836 2.7168L9.3086 1.72656L12.6006 5.01758C12.8547 5.27169 13.0857 5.50185 13.2539 5.71094C13.4303 5.93018 13.5902 6.18939 13.6426 6.51953Z",
|
|
1146
|
+
fill: "currentColor"
|
|
1147
|
+
})]
|
|
1148
|
+
})
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
//#endregion
|
|
1152
|
+
//#region \0dsh-css:/home/runner/work/deepseek-harness/deepseek-harness/packages/client/ui-settings-account/src/client/AccountAvatar.module.css.mjs
|
|
1153
|
+
const css$3 = ".ZCYJYW_image{border-radius:inherit;object-fit:cover;width:100%;height:100%;display:block}";
|
|
1154
|
+
const tagId$3 = "@deepseek-ai/dsh-client-ui-settings-account/AccountAvatar.module.css";
|
|
1155
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$3) + "]") === null) {
|
|
1156
|
+
const tag = document.createElement("style");
|
|
1157
|
+
tag.dataset.plugin = "@deepseek-ai/dsh-client-ui-settings-account";
|
|
1158
|
+
tag.dataset.pluginCss = tagId$3;
|
|
1159
|
+
tag.textContent = css$3;
|
|
1160
|
+
document.head.appendChild(tag);
|
|
1161
|
+
}
|
|
1162
|
+
var AccountAvatar_module_css_default = { "image": "ZCYJYW_image" };
|
|
1163
|
+
//#endregion
|
|
1164
|
+
//#region lib/types/client/AccountAvatar.js
|
|
1165
|
+
/** Shared account picture with an icon fallback for missing or unavailable images. */
|
|
1166
|
+
/**
|
|
1167
|
+
* Render a decorative avatar next to the account identity.
|
|
1168
|
+
* @param props - profile picture URL; absent while signed out or loading.
|
|
1169
|
+
* @returns picture or the default account icon.
|
|
1170
|
+
*/
|
|
1171
|
+
function AccountAvatar({ url }) {
|
|
1172
|
+
const [failedUrl, setFailedUrl] = (0, react.useState)();
|
|
1173
|
+
return url && url !== failedUrl ? (0, react_jsx_runtime.jsx)("img", {
|
|
1174
|
+
className: AccountAvatar_module_css_default.image,
|
|
1175
|
+
src: url,
|
|
1176
|
+
alt: "",
|
|
1177
|
+
referrerPolicy: "no-referrer",
|
|
1178
|
+
onError: () => {
|
|
1179
|
+
setFailedUrl(url);
|
|
1180
|
+
}
|
|
1181
|
+
}) : (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconUserOutlineMedium, { size: 16 });
|
|
1182
|
+
}
|
|
1183
|
+
//#endregion
|
|
1184
|
+
//#region \0dsh-css:/home/runner/work/deepseek-harness/deepseek-harness/packages/client/ui-settings-account/src/client/AccountMenu.module.css.mjs
|
|
1185
|
+
const css$2 = ".yHnPSG_root{flex:1;min-width:0}.yHnPSG_anchor{width:100%}.yHnPSG_trigger{user-select:none;width:100%;color:var(--dsw-alias-label-primary);font:inherit;cursor:pointer;background:0 0;border:0;border-radius:12px;align-items:center;gap:8px;padding:6px;font-size:14px;display:flex}.yHnPSG_trigger[data-collapsed=true]{box-sizing:border-box;justify-content:center;gap:0;width:36px;height:36px;padding:0}.yHnPSG_trigger:hover{background:var(--dsw-alias-interactive-bg-hover)}.yHnPSG_avatar{background:var(--dsw-alias-bg-skeleton);width:32px;height:32px;color:var(--dsw-alias-label-tertiary);border-radius:16px;flex:none;justify-content:center;align-items:center;display:flex}.yHnPSG_label{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.yHnPSG_error{color:var(--dsw-alias-state-error-primary);font-size:12px}";
|
|
1186
|
+
const tagId$2 = "@deepseek-ai/dsh-client-ui-settings-account/AccountMenu.module.css";
|
|
1187
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$2) + "]") === null) {
|
|
1188
|
+
const tag = document.createElement("style");
|
|
1189
|
+
tag.dataset.plugin = "@deepseek-ai/dsh-client-ui-settings-account";
|
|
1190
|
+
tag.dataset.pluginCss = tagId$2;
|
|
1191
|
+
tag.textContent = css$2;
|
|
1192
|
+
document.head.appendChild(tag);
|
|
1193
|
+
}
|
|
1194
|
+
var AccountMenu_module_css_default = {
|
|
1195
|
+
"anchor": "yHnPSG_anchor",
|
|
1196
|
+
"avatar": "yHnPSG_avatar",
|
|
1197
|
+
"error": "yHnPSG_error",
|
|
1198
|
+
"label": "yHnPSG_label",
|
|
1199
|
+
"root": "yHnPSG_root",
|
|
1200
|
+
"trigger": "yHnPSG_trigger"
|
|
1201
|
+
};
|
|
1202
|
+
//#endregion
|
|
1203
|
+
//#region lib/types/client/AccountMenu.js
|
|
1204
|
+
/** Sidebar account launcher and locally authoritative sign-out action. */
|
|
1205
|
+
/** The signed-in label stays empty while the profile loads.
|
|
1206
|
+
* @param props - sidebar geometry, settings navigation and account operations.
|
|
1207
|
+
* @returns account menu launcher.
|
|
1208
|
+
*/
|
|
1209
|
+
function AccountMenu({ wide, openSettings, openOnboarding, useAccount, signOut, contactUs, showLogin, start, cancel, t }) {
|
|
1210
|
+
const account = useAccount((state) => state);
|
|
1211
|
+
const signedIn = account.view?.status === "credential-stored";
|
|
1212
|
+
const profile = account.details?.profile;
|
|
1213
|
+
const label = profile === void 0 ? null : profile.status === "ready" ? profile.value.name ?? profile.value.contact ?? t("signedIn") : t("signedIn");
|
|
1214
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
1215
|
+
const [busy, setBusy] = (0, react.useState)(false);
|
|
1216
|
+
const [logoutFailed, setLogoutFailed] = (0, react.useState)(false);
|
|
1217
|
+
const logout = async () => {
|
|
1218
|
+
setBusy(true);
|
|
1219
|
+
setLogoutFailed(false);
|
|
1220
|
+
try {
|
|
1221
|
+
await signOut();
|
|
1222
|
+
setOpen(false);
|
|
1223
|
+
} catch {
|
|
1224
|
+
setLogoutFailed(true);
|
|
1225
|
+
} finally {
|
|
1226
|
+
setBusy(false);
|
|
1227
|
+
}
|
|
1228
|
+
};
|
|
1229
|
+
const beginSignIn = () => {
|
|
1230
|
+
setOpen(false);
|
|
1231
|
+
start().catch(() => void 0);
|
|
1232
|
+
};
|
|
1233
|
+
return (0, react_jsx_runtime.jsxs)("div", {
|
|
1234
|
+
className: AccountMenu_module_css_default.root,
|
|
1235
|
+
children: [
|
|
1236
|
+
(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Menu, {
|
|
1237
|
+
open,
|
|
1238
|
+
side: "top",
|
|
1239
|
+
portal: true,
|
|
1240
|
+
autoFocus: true,
|
|
1241
|
+
className: AccountMenu_module_css_default.anchor,
|
|
1242
|
+
anchor: (0, react_jsx_runtime.jsxs)("button", {
|
|
1243
|
+
type: "button",
|
|
1244
|
+
className: AccountMenu_module_css_default.trigger,
|
|
1245
|
+
"data-collapsed": !wide,
|
|
1246
|
+
"aria-label": t("menu"),
|
|
1247
|
+
"aria-haspopup": "menu",
|
|
1248
|
+
"aria-expanded": open,
|
|
1249
|
+
onClick: () => {
|
|
1250
|
+
setOpen((value) => !value);
|
|
1251
|
+
},
|
|
1252
|
+
children: [(0, react_jsx_runtime.jsx)("span", {
|
|
1253
|
+
className: AccountMenu_module_css_default.avatar,
|
|
1254
|
+
children: (0, react_jsx_runtime.jsx)(AccountAvatar, { url: signedIn && profile?.status === "ready" ? profile.value.avatarUrl : null })
|
|
1255
|
+
}), wide && (0, react_jsx_runtime.jsx)("span", {
|
|
1256
|
+
className: AccountMenu_module_css_default.label,
|
|
1257
|
+
children: signedIn ? label : t("signedOut")
|
|
1258
|
+
})]
|
|
1259
|
+
}),
|
|
1260
|
+
items: [
|
|
1261
|
+
{
|
|
1262
|
+
id: "settings",
|
|
1263
|
+
label: t("settings"),
|
|
1264
|
+
icon: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconSettingsOutlineMedium, { size: 16 })
|
|
1265
|
+
},
|
|
1266
|
+
{
|
|
1267
|
+
id: "contact",
|
|
1268
|
+
label: t("contactUs"),
|
|
1269
|
+
icon: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPaperPlaneOutlineMedium, { size: 16 })
|
|
1270
|
+
},
|
|
1271
|
+
...signedIn ? [{
|
|
1272
|
+
id: "signout",
|
|
1273
|
+
label: t("signOut"),
|
|
1274
|
+
icon: (0, react_jsx_runtime.jsx)(LogoutIcon, {}),
|
|
1275
|
+
disabled: busy
|
|
1276
|
+
}] : [{
|
|
1277
|
+
id: "signin",
|
|
1278
|
+
label: t("signIn"),
|
|
1279
|
+
icon: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconUserOutlineMedium, { size: 16 })
|
|
1280
|
+
}]
|
|
1281
|
+
],
|
|
1282
|
+
onClose: () => {
|
|
1283
|
+
setOpen(false);
|
|
1284
|
+
},
|
|
1285
|
+
onSelect: (id) => {
|
|
1286
|
+
if (id === "settings") {
|
|
1287
|
+
setOpen(false);
|
|
1288
|
+
openSettings();
|
|
1289
|
+
} else if (id === "contact") {
|
|
1290
|
+
setOpen(false);
|
|
1291
|
+
contactUs();
|
|
1292
|
+
} else if (id === "signin") beginSignIn();
|
|
1293
|
+
else logout();
|
|
1294
|
+
}
|
|
1295
|
+
}),
|
|
1296
|
+
account.loginVisible && !account.onboarding && (0, react_jsx_runtime.jsx)(SignInDialog, {
|
|
1297
|
+
account,
|
|
1298
|
+
start,
|
|
1299
|
+
cancel,
|
|
1300
|
+
t,
|
|
1301
|
+
close: () => {
|
|
1302
|
+
showLogin(false);
|
|
1303
|
+
},
|
|
1304
|
+
useApiKey: () => {
|
|
1305
|
+
showLogin(false);
|
|
1306
|
+
openOnboarding("deepseek-official");
|
|
1307
|
+
}
|
|
1308
|
+
}),
|
|
1309
|
+
logoutFailed && (0, react_jsx_runtime.jsx)("span", {
|
|
1310
|
+
className: AccountMenu_module_css_default.error,
|
|
1311
|
+
role: "alert",
|
|
1312
|
+
children: t("failed")
|
|
1313
|
+
})
|
|
1314
|
+
]
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
//#endregion
|
|
1318
|
+
//#region ../../../node_modules/.pnpm/big.js@7.0.1/node_modules/big.js/big.mjs
|
|
1319
|
+
/************************************** EDITABLE DEFAULTS *****************************************/
|
|
1320
|
+
var DP = 20, RM = 1, MAX_DP = 1e6, MAX_POWER = 1e6, NE = -7, PE = 21, STRICT = false, NAME = "[big.js] ", INVALID = NAME + "Invalid ", INVALID_DP = INVALID + "decimal places", INVALID_RM = INVALID + "rounding mode", DIV_BY_ZERO = NAME + "Division by zero", P = {}, UNDEFINED = void 0, NUMERIC = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
|
|
1321
|
+
function _Big_() {
|
|
1322
|
+
function Big(n) {
|
|
1323
|
+
var x = this;
|
|
1324
|
+
if (!(x instanceof Big)) return n === UNDEFINED && arguments.length === 0 ? _Big_() : new Big(n);
|
|
1325
|
+
if (n instanceof Big) {
|
|
1326
|
+
x.s = n.s;
|
|
1327
|
+
x.e = n.e;
|
|
1328
|
+
x.c = n.c.slice();
|
|
1329
|
+
} else {
|
|
1330
|
+
if (typeof n !== "string") {
|
|
1331
|
+
if (Big.strict === true && typeof n !== "bigint") throw TypeError(INVALID + "value");
|
|
1332
|
+
n = n === 0 && 1 / n < 0 ? "-0" : String(n);
|
|
1333
|
+
}
|
|
1334
|
+
parse(x, n);
|
|
1335
|
+
}
|
|
1336
|
+
x.constructor = Big;
|
|
1337
|
+
}
|
|
1338
|
+
Big.prototype = P;
|
|
1339
|
+
Big.DP = DP;
|
|
1340
|
+
Big.RM = RM;
|
|
1341
|
+
Big.NE = NE;
|
|
1342
|
+
Big.PE = PE;
|
|
1343
|
+
Big.strict = STRICT;
|
|
1344
|
+
Big.roundDown = 0;
|
|
1345
|
+
Big.roundHalfUp = 1;
|
|
1346
|
+
Big.roundHalfEven = 2;
|
|
1347
|
+
Big.roundUp = 3;
|
|
1348
|
+
return Big;
|
|
1349
|
+
}
|
|
1350
|
+
function parse(x, n) {
|
|
1351
|
+
var e, i, nl;
|
|
1352
|
+
if (!NUMERIC.test(n)) throw Error(INVALID + "number");
|
|
1353
|
+
x.s = n.charAt(0) == "-" ? (n = n.slice(1), -1) : 1;
|
|
1354
|
+
if ((e = n.indexOf(".")) > -1) n = n.replace(".", "");
|
|
1355
|
+
if ((i = n.search(/e/i)) > 0) {
|
|
1356
|
+
if (e < 0) e = i;
|
|
1357
|
+
e += +n.slice(i + 1);
|
|
1358
|
+
n = n.substring(0, i);
|
|
1359
|
+
} else if (e < 0) e = n.length;
|
|
1360
|
+
nl = n.length;
|
|
1361
|
+
for (i = 0; i < nl && n.charAt(i) == "0";) ++i;
|
|
1362
|
+
if (i == nl) x.c = [x.e = 0];
|
|
1363
|
+
else {
|
|
1364
|
+
for (; nl > 0 && n.charAt(--nl) == "0";);
|
|
1365
|
+
x.e = e - i - 1;
|
|
1366
|
+
x.c = [];
|
|
1367
|
+
for (e = 0; i <= nl;) x.c[e++] = +n.charAt(i++);
|
|
1368
|
+
}
|
|
1369
|
+
return x;
|
|
1370
|
+
}
|
|
1371
|
+
function round(x, sd, rm, more) {
|
|
1372
|
+
var xc = x.c;
|
|
1373
|
+
if (rm === UNDEFINED) rm = x.constructor.RM;
|
|
1374
|
+
if (rm !== 0 && rm !== 1 && rm !== 2 && rm !== 3) throw Error(INVALID_RM);
|
|
1375
|
+
if (sd < 1) {
|
|
1376
|
+
more = rm === 3 && (more || !!xc[0]) || sd === 0 && (rm === 1 && xc[0] >= 5 || rm === 2 && (xc[0] > 5 || xc[0] === 5 && (more || xc[1] !== UNDEFINED)));
|
|
1377
|
+
xc.length = 1;
|
|
1378
|
+
if (more) {
|
|
1379
|
+
x.e = x.e - sd + 1;
|
|
1380
|
+
xc[0] = 1;
|
|
1381
|
+
} else xc[0] = x.e = 0;
|
|
1382
|
+
} else if (sd < xc.length) {
|
|
1383
|
+
more = rm === 1 && xc[sd] >= 5 || rm === 2 && (xc[sd] > 5 || xc[sd] === 5 && (more || xc[sd + 1] !== UNDEFINED || xc[sd - 1] & 1)) || rm === 3 && (more || !!xc[0]);
|
|
1384
|
+
xc.length = sd;
|
|
1385
|
+
if (more) for (; ++xc[--sd] > 9;) {
|
|
1386
|
+
xc[sd] = 0;
|
|
1387
|
+
if (sd === 0) {
|
|
1388
|
+
++x.e;
|
|
1389
|
+
xc.unshift(1);
|
|
1390
|
+
break;
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
for (sd = xc.length; !xc[--sd];) xc.pop();
|
|
1394
|
+
}
|
|
1395
|
+
return x;
|
|
1396
|
+
}
|
|
1397
|
+
function stringify(x, doExponential, isNonzero) {
|
|
1398
|
+
var e = x.e, s = x.c.join(""), n = s.length;
|
|
1399
|
+
if (doExponential) s = s.charAt(0) + (n > 1 ? "." + s.slice(1) : "") + (e < 0 ? "e" : "e+") + e;
|
|
1400
|
+
else if (e < 0) {
|
|
1401
|
+
for (; ++e;) s = "0" + s;
|
|
1402
|
+
s = "0." + s;
|
|
1403
|
+
} else if (e > 0) {
|
|
1404
|
+
if (++e > n) for (e -= n; e--;) s += "0";
|
|
1405
|
+
else if (e < n) s = s.slice(0, e) + "." + s.slice(e);
|
|
1406
|
+
} else if (n > 1) s = s.charAt(0) + "." + s.slice(1);
|
|
1407
|
+
return x.s < 0 && isNonzero ? "-" + s : s;
|
|
1408
|
+
}
|
|
1409
|
+
P.abs = function() {
|
|
1410
|
+
var x = new this.constructor(this);
|
|
1411
|
+
x.s = 1;
|
|
1412
|
+
return x;
|
|
1413
|
+
};
|
|
1414
|
+
P.cmp = function(y) {
|
|
1415
|
+
var isneg, x = this, xc = x.c, yc = (y = new x.constructor(y)).c, i = x.s, j = y.s, k = x.e, l = y.e;
|
|
1416
|
+
if (!xc[0] || !yc[0]) return !xc[0] ? !yc[0] ? 0 : -j : i;
|
|
1417
|
+
if (i != j) return i;
|
|
1418
|
+
isneg = i < 0;
|
|
1419
|
+
if (k != l) return k > l ^ isneg ? 1 : -1;
|
|
1420
|
+
j = (k = xc.length) < (l = yc.length) ? k : l;
|
|
1421
|
+
for (i = -1; ++i < j;) if (xc[i] != yc[i]) return xc[i] > yc[i] ^ isneg ? 1 : -1;
|
|
1422
|
+
return k == l ? 0 : k > l ^ isneg ? 1 : -1;
|
|
1423
|
+
};
|
|
1424
|
+
P.div = function(y) {
|
|
1425
|
+
var x = this, Big = x.constructor, a = x.c, b = (y = new Big(y)).c, k = x.s == y.s ? 1 : -1, dp = Big.DP;
|
|
1426
|
+
if (dp !== ~~dp || dp < 0 || dp > MAX_DP) throw Error(INVALID_DP);
|
|
1427
|
+
if (!b[0]) throw Error(DIV_BY_ZERO);
|
|
1428
|
+
if (!a[0]) {
|
|
1429
|
+
y.s = k;
|
|
1430
|
+
y.c = [y.e = 0];
|
|
1431
|
+
return y;
|
|
1432
|
+
}
|
|
1433
|
+
var bl, bt, n, cmp, ri, bz = b.slice(), ai = bl = b.length, al = a.length, r = a.slice(0, bl), rl = r.length, q = y, qc = q.c = [], qi = 0, p = dp + (q.e = x.e - y.e) + 1;
|
|
1434
|
+
q.s = k;
|
|
1435
|
+
k = p < 0 ? 0 : p;
|
|
1436
|
+
bz.unshift(0);
|
|
1437
|
+
for (; rl++ < bl;) r.push(0);
|
|
1438
|
+
do {
|
|
1439
|
+
for (n = 0; n < 10; n++) {
|
|
1440
|
+
if (bl != (rl = r.length)) cmp = bl > rl ? 1 : -1;
|
|
1441
|
+
else for (ri = -1, cmp = 0; ++ri < bl;) if (b[ri] != r[ri]) {
|
|
1442
|
+
cmp = b[ri] > r[ri] ? 1 : -1;
|
|
1443
|
+
break;
|
|
1444
|
+
}
|
|
1445
|
+
if (cmp < 0) {
|
|
1446
|
+
for (bt = rl == bl ? b : bz; rl;) {
|
|
1447
|
+
if (r[--rl] < bt[rl]) {
|
|
1448
|
+
ri = rl;
|
|
1449
|
+
for (; ri && !r[--ri];) r[ri] = 9;
|
|
1450
|
+
--r[ri];
|
|
1451
|
+
r[rl] += 10;
|
|
1452
|
+
}
|
|
1453
|
+
r[rl] -= bt[rl];
|
|
1454
|
+
}
|
|
1455
|
+
for (; !r[0];) r.shift();
|
|
1456
|
+
} else break;
|
|
1457
|
+
}
|
|
1458
|
+
qc[qi++] = cmp ? n : ++n;
|
|
1459
|
+
if (r[0] && cmp) r[rl] = a[ai] || 0;
|
|
1460
|
+
else r = [a[ai]];
|
|
1461
|
+
} while ((ai++ < al || r[0] !== UNDEFINED) && k--);
|
|
1462
|
+
if (!qc[0] && qi != 1) {
|
|
1463
|
+
qc.shift();
|
|
1464
|
+
q.e--;
|
|
1465
|
+
p--;
|
|
1466
|
+
}
|
|
1467
|
+
if (qi > p) round(q, p, Big.RM, r[0] !== UNDEFINED);
|
|
1468
|
+
return q;
|
|
1469
|
+
};
|
|
1470
|
+
P.eq = function(y) {
|
|
1471
|
+
return this.cmp(y) === 0;
|
|
1472
|
+
};
|
|
1473
|
+
P.gt = function(y) {
|
|
1474
|
+
return this.cmp(y) > 0;
|
|
1475
|
+
};
|
|
1476
|
+
P.gte = function(y) {
|
|
1477
|
+
return this.cmp(y) > -1;
|
|
1478
|
+
};
|
|
1479
|
+
P.lt = function(y) {
|
|
1480
|
+
return this.cmp(y) < 0;
|
|
1481
|
+
};
|
|
1482
|
+
P.lte = function(y) {
|
|
1483
|
+
return this.cmp(y) < 1;
|
|
1484
|
+
};
|
|
1485
|
+
P.minus = P.sub = function(y) {
|
|
1486
|
+
var i, j, t, xlty, x = this, Big = x.constructor, a = x.s, b = (y = new Big(y)).s;
|
|
1487
|
+
if (a != b) {
|
|
1488
|
+
y.s = -b;
|
|
1489
|
+
return x.plus(y);
|
|
1490
|
+
}
|
|
1491
|
+
var xc = x.c.slice(), xe = x.e, yc = y.c, ye = y.e;
|
|
1492
|
+
if (!xc[0] || !yc[0]) {
|
|
1493
|
+
if (yc[0]) y.s = -b;
|
|
1494
|
+
else if (xc[0]) y = new Big(x);
|
|
1495
|
+
else y.s = 1;
|
|
1496
|
+
return y;
|
|
1497
|
+
}
|
|
1498
|
+
if (a = xe - ye) {
|
|
1499
|
+
if (xlty = a < 0) {
|
|
1500
|
+
a = -a;
|
|
1501
|
+
t = xc;
|
|
1502
|
+
} else {
|
|
1503
|
+
ye = xe;
|
|
1504
|
+
t = yc;
|
|
1505
|
+
}
|
|
1506
|
+
t.reverse();
|
|
1507
|
+
for (b = a; b--;) t.push(0);
|
|
1508
|
+
t.reverse();
|
|
1509
|
+
} else {
|
|
1510
|
+
j = ((xlty = xc.length < yc.length) ? xc : yc).length;
|
|
1511
|
+
for (a = b = 0; b < j; b++) if (xc[b] != yc[b]) {
|
|
1512
|
+
xlty = xc[b] < yc[b];
|
|
1513
|
+
break;
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
if (xlty) {
|
|
1517
|
+
t = xc;
|
|
1518
|
+
xc = yc;
|
|
1519
|
+
yc = t;
|
|
1520
|
+
y.s = -y.s;
|
|
1521
|
+
}
|
|
1522
|
+
if ((b = (j = yc.length) - (i = xc.length)) > 0) for (; b--;) xc[i++] = 0;
|
|
1523
|
+
for (b = i; j > a;) {
|
|
1524
|
+
if (xc[--j] < yc[j]) {
|
|
1525
|
+
for (i = j; i && !xc[--i];) xc[i] = 9;
|
|
1526
|
+
--xc[i];
|
|
1527
|
+
xc[j] += 10;
|
|
1528
|
+
}
|
|
1529
|
+
xc[j] -= yc[j];
|
|
1530
|
+
}
|
|
1531
|
+
for (; xc[--b] === 0;) xc.pop();
|
|
1532
|
+
for (; xc[0] === 0;) {
|
|
1533
|
+
xc.shift();
|
|
1534
|
+
--ye;
|
|
1535
|
+
}
|
|
1536
|
+
if (!xc[0]) {
|
|
1537
|
+
y.s = 1;
|
|
1538
|
+
xc = [ye = 0];
|
|
1539
|
+
}
|
|
1540
|
+
y.c = xc;
|
|
1541
|
+
y.e = ye;
|
|
1542
|
+
return y;
|
|
1543
|
+
};
|
|
1544
|
+
P.mod = function(y) {
|
|
1545
|
+
var ygtx, x = this, Big = x.constructor, a = x.s, b = (y = new Big(y)).s;
|
|
1546
|
+
if (!y.c[0]) throw Error(DIV_BY_ZERO);
|
|
1547
|
+
x.s = y.s = 1;
|
|
1548
|
+
ygtx = y.cmp(x) == 1;
|
|
1549
|
+
x.s = a;
|
|
1550
|
+
y.s = b;
|
|
1551
|
+
if (ygtx) return new Big(x);
|
|
1552
|
+
a = Big.DP;
|
|
1553
|
+
b = Big.RM;
|
|
1554
|
+
Big.DP = Big.RM = 0;
|
|
1555
|
+
x = x.div(y);
|
|
1556
|
+
Big.DP = a;
|
|
1557
|
+
Big.RM = b;
|
|
1558
|
+
return this.minus(x.times(y));
|
|
1559
|
+
};
|
|
1560
|
+
P.neg = function() {
|
|
1561
|
+
var x = new this.constructor(this);
|
|
1562
|
+
x.s = -x.s;
|
|
1563
|
+
return x;
|
|
1564
|
+
};
|
|
1565
|
+
P.plus = P.add = function(y) {
|
|
1566
|
+
var e, k, t, x = this, Big = x.constructor;
|
|
1567
|
+
y = new Big(y);
|
|
1568
|
+
if (x.s != y.s) {
|
|
1569
|
+
y.s = -y.s;
|
|
1570
|
+
return x.minus(y);
|
|
1571
|
+
}
|
|
1572
|
+
var xe = x.e, xc = x.c, ye = y.e, yc = y.c;
|
|
1573
|
+
if (!xc[0] || !yc[0]) {
|
|
1574
|
+
if (!yc[0]) if (xc[0]) y = new Big(x);
|
|
1575
|
+
else y.s = x.s;
|
|
1576
|
+
return y;
|
|
1577
|
+
}
|
|
1578
|
+
xc = xc.slice();
|
|
1579
|
+
if (e = xe - ye) {
|
|
1580
|
+
if (e > 0) {
|
|
1581
|
+
ye = xe;
|
|
1582
|
+
t = yc;
|
|
1583
|
+
} else {
|
|
1584
|
+
e = -e;
|
|
1585
|
+
t = xc;
|
|
1586
|
+
}
|
|
1587
|
+
t.reverse();
|
|
1588
|
+
for (; e--;) t.push(0);
|
|
1589
|
+
t.reverse();
|
|
1590
|
+
}
|
|
1591
|
+
if (xc.length - yc.length < 0) {
|
|
1592
|
+
t = yc;
|
|
1593
|
+
yc = xc;
|
|
1594
|
+
xc = t;
|
|
1595
|
+
}
|
|
1596
|
+
e = yc.length;
|
|
1597
|
+
for (k = 0; e; xc[e] %= 10) k = (xc[--e] = xc[e] + yc[e] + k) / 10 | 0;
|
|
1598
|
+
if (k) {
|
|
1599
|
+
xc.unshift(k);
|
|
1600
|
+
++ye;
|
|
1601
|
+
}
|
|
1602
|
+
for (e = xc.length; xc[--e] === 0;) xc.pop();
|
|
1603
|
+
y.c = xc;
|
|
1604
|
+
y.e = ye;
|
|
1605
|
+
return y;
|
|
1606
|
+
};
|
|
1607
|
+
P.pow = function(n) {
|
|
1608
|
+
var x = this, one = new x.constructor("1"), y = one, isneg = n < 0;
|
|
1609
|
+
if (n !== ~~n || n < -MAX_POWER || n > MAX_POWER) throw Error(INVALID + "exponent");
|
|
1610
|
+
if (isneg) n = -n;
|
|
1611
|
+
for (;;) {
|
|
1612
|
+
if (n & 1) y = y.times(x);
|
|
1613
|
+
n >>= 1;
|
|
1614
|
+
if (!n) break;
|
|
1615
|
+
x = x.times(x);
|
|
1616
|
+
}
|
|
1617
|
+
return isneg ? one.div(y) : y;
|
|
1618
|
+
};
|
|
1619
|
+
P.prec = function(sd, rm) {
|
|
1620
|
+
if (sd !== ~~sd || sd < 1 || sd > MAX_DP) throw Error(INVALID + "precision");
|
|
1621
|
+
return round(new this.constructor(this), sd, rm);
|
|
1622
|
+
};
|
|
1623
|
+
P.round = function(dp, rm) {
|
|
1624
|
+
if (dp === UNDEFINED) dp = 0;
|
|
1625
|
+
else if (dp !== ~~dp || dp < -MAX_DP || dp > MAX_DP) throw Error(INVALID_DP);
|
|
1626
|
+
return round(new this.constructor(this), dp + this.e + 1, rm);
|
|
1627
|
+
};
|
|
1628
|
+
P.sqrt = function() {
|
|
1629
|
+
var r, c, t, x = this, Big = x.constructor, s = x.s, e = x.e, half = new Big("0.5");
|
|
1630
|
+
if (!x.c[0]) return new Big(x);
|
|
1631
|
+
if (s < 0) throw Error(NAME + "No square root");
|
|
1632
|
+
s = Math.sqrt(+stringify(x, true, true));
|
|
1633
|
+
if (s === 0 || s === Infinity) {
|
|
1634
|
+
c = x.c.join("");
|
|
1635
|
+
if (!(c.length + e & 1)) c += "0";
|
|
1636
|
+
s = Math.sqrt(c);
|
|
1637
|
+
e = ((e + 1) / 2 | 0) - (e < 0 || e & 1);
|
|
1638
|
+
r = new Big((s == Infinity ? "5e" : (s = s.toExponential()).slice(0, s.indexOf("e") + 1)) + e);
|
|
1639
|
+
} else r = new Big(s + "");
|
|
1640
|
+
e = r.e + (Big.DP += 4);
|
|
1641
|
+
do {
|
|
1642
|
+
t = r;
|
|
1643
|
+
r = half.times(t.plus(x.div(t)));
|
|
1644
|
+
} while (t.c.slice(0, e).join("") !== r.c.slice(0, e).join(""));
|
|
1645
|
+
return round(r, (Big.DP -= 4) + r.e + 1, Big.RM);
|
|
1646
|
+
};
|
|
1647
|
+
P.times = P.mul = function(y) {
|
|
1648
|
+
var c, x = this, Big = x.constructor, xc = x.c, yc = (y = new Big(y)).c, a = xc.length, b = yc.length, i = x.e, j = y.e;
|
|
1649
|
+
y.s = x.s == y.s ? 1 : -1;
|
|
1650
|
+
if (!xc[0] || !yc[0]) {
|
|
1651
|
+
y.c = [y.e = 0];
|
|
1652
|
+
return y;
|
|
1653
|
+
}
|
|
1654
|
+
y.e = i + j;
|
|
1655
|
+
if (a < b) {
|
|
1656
|
+
c = xc;
|
|
1657
|
+
xc = yc;
|
|
1658
|
+
yc = c;
|
|
1659
|
+
j = a;
|
|
1660
|
+
a = b;
|
|
1661
|
+
b = j;
|
|
1662
|
+
}
|
|
1663
|
+
for (c = new Array(j = a + b); j--;) c[j] = 0;
|
|
1664
|
+
for (i = b; i--;) {
|
|
1665
|
+
b = 0;
|
|
1666
|
+
for (j = a + i; j > i;) {
|
|
1667
|
+
b = c[j] + yc[i] * xc[j - i - 1] + b;
|
|
1668
|
+
c[j--] = b % 10;
|
|
1669
|
+
b = b / 10 | 0;
|
|
1670
|
+
}
|
|
1671
|
+
c[j] = b;
|
|
1672
|
+
}
|
|
1673
|
+
if (b) ++y.e;
|
|
1674
|
+
else c.shift();
|
|
1675
|
+
for (i = c.length; !c[--i];) c.pop();
|
|
1676
|
+
y.c = c;
|
|
1677
|
+
return y;
|
|
1678
|
+
};
|
|
1679
|
+
P.toExponential = function(dp, rm) {
|
|
1680
|
+
var x = this, n = x.c[0];
|
|
1681
|
+
if (dp !== UNDEFINED) {
|
|
1682
|
+
if (dp !== ~~dp || dp < 0 || dp > MAX_DP) throw Error(INVALID_DP);
|
|
1683
|
+
x = round(new x.constructor(x), ++dp, rm);
|
|
1684
|
+
for (; x.c.length < dp;) x.c.push(0);
|
|
1685
|
+
}
|
|
1686
|
+
return stringify(x, true, !!n);
|
|
1687
|
+
};
|
|
1688
|
+
P.toFixed = function(dp, rm) {
|
|
1689
|
+
var x = this, n = x.c[0];
|
|
1690
|
+
if (dp !== UNDEFINED) {
|
|
1691
|
+
if (dp !== ~~dp || dp < 0 || dp > MAX_DP) throw Error(INVALID_DP);
|
|
1692
|
+
x = round(new x.constructor(x), dp + x.e + 1, rm);
|
|
1693
|
+
for (dp = dp + x.e + 1; x.c.length < dp;) x.c.push(0);
|
|
1694
|
+
}
|
|
1695
|
+
return stringify(x, false, !!n);
|
|
1696
|
+
};
|
|
1697
|
+
P.toJSON = P.toString = function() {
|
|
1698
|
+
var x = this, Big = x.constructor;
|
|
1699
|
+
return stringify(x, x.e <= Big.NE || x.e >= Big.PE, !!x.c[0]);
|
|
1700
|
+
};
|
|
1701
|
+
if (typeof Symbol !== "undefined") P[Symbol.for("nodejs.util.inspect.custom")] = P.toJSON;
|
|
1702
|
+
P.toNumber = function() {
|
|
1703
|
+
var n = +stringify(this, true, true);
|
|
1704
|
+
if (this.constructor.strict === true && !this.eq(n.toString())) throw Error(NAME + "Imprecise conversion");
|
|
1705
|
+
return n;
|
|
1706
|
+
};
|
|
1707
|
+
P.toPrecision = function(sd, rm) {
|
|
1708
|
+
var x = this, Big = x.constructor, n = x.c[0];
|
|
1709
|
+
if (sd !== UNDEFINED) {
|
|
1710
|
+
if (sd !== ~~sd || sd < 1 || sd > MAX_DP) throw Error(INVALID + "precision");
|
|
1711
|
+
x = round(new Big(x), sd, rm);
|
|
1712
|
+
for (; x.c.length < sd;) x.c.push(0);
|
|
1713
|
+
}
|
|
1714
|
+
return stringify(x, sd <= x.e || x.e <= Big.NE || x.e >= Big.PE, !!n);
|
|
1715
|
+
};
|
|
1716
|
+
P.valueOf = function() {
|
|
1717
|
+
var x = this, Big = x.constructor;
|
|
1718
|
+
if (Big.strict === true) throw Error(NAME + "valueOf disallowed");
|
|
1719
|
+
return stringify(x, x.e <= Big.NE || x.e >= Big.PE, true);
|
|
1720
|
+
};
|
|
1721
|
+
var Big = _Big_();
|
|
1722
|
+
//#endregion
|
|
1723
|
+
//#region \0dsh-css:/home/runner/work/deepseek-harness/deepseek-harness/packages/client/ui-settings-account/src/client/PlatformOverlay.module.css.mjs
|
|
1724
|
+
const css$1 = "._44HXVa_overlay{z-index:1001;background:var(--dsw-alias-bg-base);flex-direction:column;display:flex;position:fixed;inset:0}._44HXVa_header{box-sizing:border-box;border-bottom:.5px solid var(--dsw-alias-border-l1);app-region:drag;flex:none;height:48px;padding:6px 16px}._44HXVa_controls{align-items:center;gap:24px;padding-top:5px;display:flex}._44HXVa_trafficLights{flex:none;width:60.667px;height:14px;display:none}html[data-platform=darwin] ._44HXVa_trafficLights{display:block}._44HXVa_back{box-sizing:border-box;height:28px;color:var(--dsw-alias-label-secondary);font:inherit;white-space:nowrap;cursor:pointer;app-region:no-drag;background:0 0;border:none;border-radius:28px;justify-content:center;align-items:center;gap:8px;padding:0 6px;font-size:14px;line-height:22px;display:inline-flex}._44HXVa_viewport{min-height:0;color:var(--dsw-alias-label-secondary);flex:1;position:relative}._44HXVa_status{flex-direction:column;justify-content:center;align-items:center;gap:16px;display:flex;position:absolute;inset:0}._44HXVa_failure{color:var(--dsw-alias-label-tertiary);text-align:center;font-size:14px;line-height:22px}._44HXVa_retry._44HXVa_retry{box-sizing:border-box;border:.5px solid var(--dsw-alias-border-l2);border-radius:18px;min-width:58px;height:32px;padding:0 12px;font-size:13px;font-weight:400;line-height:20px}._44HXVa_spinner{width:24px;height:24px;animation:1s linear infinite _44HXVa_spin;position:relative}._44HXVa_spinner:before{content:\"\";background:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTkiIGhlaWdodD0iMjIiIHZpZXdCb3g9IjAgMCAxOSAyMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgY2xpcC1wYXRoPSJ1cmwoI3BhaW50MF9hbmd1bGFyXzI5ODhfMzIzMjlfY2xpcF9wYXRoKSIgZGF0YS1maWdtYS1za2lwLXBhcnNlPSJ0cnVlIj48ZyB0cmFuc2Zvcm09Im1hdHJpeCgwLjAwNjk1MDQ4IDAuMDA2OTUwNDggLTAuMDA2OTUwNDggMC4wMDY5NTA0OCAxMC44Nzk3IDEwLjg3OTMpIj48Zm9yZWlnbk9iamVjdCB4PSItMTg2Ny40MiIgeT0iLTE4NjcuNDIiIHdpZHRoPSIzNzM0Ljg1IiBoZWlnaHQ9IjM3MzQuODUiPjxkaXYgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGh0bWwiIHN0eWxlPSJiYWNrZ3JvdW5kOmNvbmljLWdyYWRpZW50KGZyb20gOTBkZWcscmdiYSgyNDYsIDI0NiwgMjQ2LCAwLjk5NDMpIDBkZWcscmdiYSgwLCAwLCAwLCAwLjgzKSAyNzMuMDI3ZGVnLHJnYmEoMCwgMCwgMCwgMCkgMjg3LjY5NGRlZyxyZ2JhKDI1NSwgMjU1LCAyNTUsIDEpIDM1MC40OTdkZWcscmdiYSgyNDYsIDI0NiwgMjQ2LCAwLjk5NDMpIDM2MGRlZyk7aGVpZ2h0OjEwMCU7d2lkdGg6MTAwJTtvcGFjaXR5OjAuNSI+PC9kaXY+PC9mb3JlaWduT2JqZWN0PjwvZz48L2c+PHBhdGggZD0iTTMuMTg2MjcgMTguNTcyMkMtMS4wNjIwOSAxNC4zMjM2IC0xLjA2MjA5IDcuNDM1MDIgMy4xODYyNyAzLjE4NjM5QzcuNDM0ODggLTEuMDYyMjIgMTQuMzIzMyAtMS4wNjIwNSAxOC41NzIxIDMuMTg2MzlMMTcuMDg3OCA0LjY3MDdDMTMuNjU5MSAxLjI0MjM2IDguMTAwMTEgMS4yNDMyMiA0LjY3MTYxIDQuNjcxNzNDMS4yNDMzNSA4LjEwMDI2IDEuMjQzMzUgMTMuNjU4MyA0LjY3MTYxIDE3LjA4NjhDOC4xMDAxMSAyMC41MTUzIDEzLjY1OTEgMjAuNTE2MiAxNy4wODc4IDE3LjA4NzlMMTguNTcyMSAxOC41NzIyQzE0LjMyMzMgMjIuODIwNiA3LjQzNDg4IDIyLjgyMDggMy4xODYyNyAxOC41NzIyWiIgZGF0YS1maWdtYS1ncmFkaWVudC1maWxsPSJ7JiMzNDt0eXBlJiMzNDs6JiMzNDtHUkFESUVOVF9BTkdVTEFSJiMzNDssJiMzNDtzdG9wcyYjMzQ7Olt7JiMzNDtjb2xvciYjMzQ7OnsmIzM0O3ImIzM0OzowLjAsJiMzNDtnJiMzNDs6MC4wLCYjMzQ7YiYjMzQ7OjAuMCwmIzM0O2EmIzM0OzowLjgyOTk5OTk4MzMxMDY5OTQ2fSwmIzM0O3Bvc2l0aW9uJiMzNDs6MC43NTg0MDg3MjUyNjE2ODgyM30seyYjMzQ7Y29sb3ImIzM0Ozp7JiMzNDtyJiMzNDs6MC4wLCYjMzQ7ZyYjMzQ7OjAuMCwmIzM0O2ImIzM0OzowLjAsJiMzNDthJiMzNDs6MC4wfSwmIzM0O3Bvc2l0aW9uJiMzNDs6MC43OTkxNDk2OTIwNTg1NjMyM30seyYjMzQ7Y29sb3ImIzM0Ozp7JiMzNDtyJiMzNDs6MS4wLCYjMzQ7ZyYjMzQ7OjEuMCwmIzM0O2ImIzM0OzoxLjAsJiMzNDthJiMzNDs6MS4wfSwmIzM0O3Bvc2l0aW9uJiMzNDs6MC45NzM2MDE4MTgwODQ3MTY4MH1dLCYjMzQ7dHJhbnNmb3JtJiMzNDs6eyYjMzQ7bTAwJiMzNDs6MTMuOTAwOTUzMjkyODQ2NjgwLCYjMzQ7bTAxJiMzNDs6LTEzLjkwMDk1MzI5Mjg0NjY4MCwmIzM0O20wMiYjMzQ7OjEwLjg3OTY3Nzc3MjUyMTk3MywmIzM0O20xMCYjMzQ7OjEzLjkwMDk1NDI0NjUyMDk5NiwmIzM0O20xMSYjMzQ7OjEzLjkwMDk1NDI0NjUyMDk5NiwmIzM0O20xMiYjMzQ7Oi0zLjAyMTY2NzAwMzYzMTU5MTh9LCYjMzQ7b3BhY2l0eSYjMzQ7OjAuNTAsJiMzNDtibGVuZE1vZGUmIzM0OzomIzM0O05PUk1BTCYjMzQ7LCYjMzQ7c3RvcHNWYXImIzM0OzpbeyYjMzQ7Y29sb3ImIzM0Ozp7JiMzNDtyJiMzNDs6MC4wLCYjMzQ7ZyYjMzQ7OjAuMCwmIzM0O2ImIzM0OzowLjAsJiMzNDthJiMzNDs6MC44Mjk5OTk5ODMzMTA2OTk0Nn0sJiMzNDtwb3NpdGlvbiYjMzQ7OjAuNzU4NDA4NzI1MjYxNjg4MjN9LHsmIzM0O2NvbG9yJiMzNDs6eyYjMzQ7ciYjMzQ7OjAuMCwmIzM0O2cmIzM0OzowLjAsJiMzNDtiJiMzNDs6MC4wLCYjMzQ7YSYjMzQ7OjAuMH0sJiMzNDtwb3NpdGlvbiYjMzQ7OjAuNzk5MTQ5NjkyMDU4NTYzMjN9LHsmIzM0O2NvbG9yJiMzNDs6eyYjMzQ7ciYjMzQ7OjEuMCwmIzM0O2cmIzM0OzoxLjAsJiMzNDtiJiMzNDs6MS4wLCYjMzQ7YSYjMzQ7OjEuMH0sJiMzNDtwb3NpdGlvbiYjMzQ7OjAuOTczNjAxODE4MDg0NzE2ODB9XSwmIzM0O3Zpc2libGUmIzM0Ozp0cnVlfSIvPgo8ZGVmcz4KPGNsaXBQYXRoIGlkPSJwYWludDBfYW5ndWxhcl8yOTg4XzMyMzI5X2NsaXBfcGF0aCI+PHBhdGggZD0iTTMuMTg2MjcgMTguNTcyMkMtMS4wNjIwOSAxNC4zMjM2IC0xLjA2MjA5IDcuNDM1MDIgMy4xODYyNyAzLjE4NjM5QzcuNDM0ODggLTEuMDYyMjIgMTQuMzIzMyAtMS4wNjIwNSAxOC41NzIxIDMuMTg2MzlMMTcuMDg3OCA0LjY3MDdDMTMuNjU5MSAxLjI0MjM2IDguMTAwMTEgMS4yNDMyMiA0LjY3MTYxIDQuNjcxNzNDMS4yNDMzNSA4LjEwMDI2IDEuMjQzMzUgMTMuNjU4MyA0LjY3MTYxIDE3LjA4NjhDOC4xMDAxMSAyMC41MTUzIDEzLjY1OTEgMjAuNTE2MiAxNy4wODc4IDE3LjA4NzlMMTguNTcyMSAxOC41NzIyQzE0LjMyMzMgMjIuODIwNiA3LjQzNDg4IDIyLjgyMDggMy4xODYyNyAxOC41NzIyWiIvPjwvY2xpcFBhdGg+PC9kZWZzPgo8L3N2Zz4K) 50%/100% 100% no-repeat;width:18.572px;height:21.759px;position:absolute;top:1.121px;left:1.12px}@keyframes _44HXVa_spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){._44HXVa_spinner{animation:none}}";
|
|
1725
|
+
const tagId$1 = "@deepseek-ai/dsh-client-ui-settings-account/PlatformOverlay.module.css";
|
|
1726
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
|
|
1727
|
+
const tag = document.createElement("style");
|
|
1728
|
+
tag.dataset.plugin = "@deepseek-ai/dsh-client-ui-settings-account";
|
|
1729
|
+
tag.dataset.pluginCss = tagId$1;
|
|
1730
|
+
tag.textContent = css$1;
|
|
1731
|
+
document.head.appendChild(tag);
|
|
1732
|
+
}
|
|
1733
|
+
var PlatformOverlay_module_css_default = {
|
|
1734
|
+
"back": "_44HXVa_back",
|
|
1735
|
+
"controls": "_44HXVa_controls",
|
|
1736
|
+
"failure": "_44HXVa_failure",
|
|
1737
|
+
"header": "_44HXVa_header",
|
|
1738
|
+
"overlay": "_44HXVa_overlay",
|
|
1739
|
+
"retry": "_44HXVa_retry",
|
|
1740
|
+
"spin": "_44HXVa_spin",
|
|
1741
|
+
"spinner": "_44HXVa_spinner",
|
|
1742
|
+
"status": "_44HXVa_status",
|
|
1743
|
+
"trafficLights": "_44HXVa_trafficLights",
|
|
1744
|
+
"viewport": "_44HXVa_viewport"
|
|
1745
|
+
};
|
|
1746
|
+
//#endregion
|
|
1747
|
+
//#region lib/types/client/PlatformOverlay.js
|
|
1748
|
+
/** Desktop Platform viewport; the native child owns remote content and credentials. */
|
|
1749
|
+
/** @param props - native commands, localized copy, and return action. @returns full-window Platform container. */
|
|
1750
|
+
function PlatformOverlay({ bridge, page, backLabel, loadingLabel, failureLabel, retryLabel, onClose }) {
|
|
1751
|
+
const layer = (0, react.useRef)(null);
|
|
1752
|
+
const back = (0, react.useRef)(null);
|
|
1753
|
+
const viewport = (0, react.useRef)(null);
|
|
1754
|
+
const [attempt, setAttempt] = (0, react.useState)(0);
|
|
1755
|
+
const [status, setStatus] = (0, react.useState)("loading");
|
|
1756
|
+
(0, react.useEffect)(() => {
|
|
1757
|
+
const element = viewport.current;
|
|
1758
|
+
const previousFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
1759
|
+
const background = Array.from(document.body.children).filter((element) => element instanceof HTMLElement && element !== layer.current).map((element) => ({
|
|
1760
|
+
element,
|
|
1761
|
+
inert: element.inert
|
|
1762
|
+
}));
|
|
1763
|
+
for (const { element } of background) element.inert = true;
|
|
1764
|
+
back.current?.focus();
|
|
1765
|
+
let closed = false;
|
|
1766
|
+
const bounds = () => {
|
|
1767
|
+
const rect = element.getBoundingClientRect();
|
|
1768
|
+
return {
|
|
1769
|
+
x: rect.x,
|
|
1770
|
+
y: rect.y,
|
|
1771
|
+
width: rect.width,
|
|
1772
|
+
height: rect.height
|
|
1773
|
+
};
|
|
1774
|
+
};
|
|
1775
|
+
const fail = () => {
|
|
1776
|
+
if (!closed) setStatus("failed");
|
|
1777
|
+
};
|
|
1778
|
+
setStatus("loading");
|
|
1779
|
+
bridge.open(page, bounds()).then(() => {
|
|
1780
|
+
if (!closed) setStatus("loaded");
|
|
1781
|
+
}, fail);
|
|
1782
|
+
const observer = new ResizeObserver(() => {
|
|
1783
|
+
bridge.setBounds(bounds()).catch(fail);
|
|
1784
|
+
});
|
|
1785
|
+
observer.observe(element);
|
|
1786
|
+
return () => {
|
|
1787
|
+
closed = true;
|
|
1788
|
+
observer.disconnect();
|
|
1789
|
+
for (const { element, inert } of background) element.inert = inert;
|
|
1790
|
+
if (previousFocus?.isConnected) previousFocus.focus();
|
|
1791
|
+
bridge.close().catch(() => {});
|
|
1792
|
+
};
|
|
1793
|
+
}, [
|
|
1794
|
+
bridge,
|
|
1795
|
+
page,
|
|
1796
|
+
attempt
|
|
1797
|
+
]);
|
|
1798
|
+
return (0, react_dom.createPortal)((0, react_jsx_runtime.jsxs)("div", {
|
|
1799
|
+
ref: layer,
|
|
1800
|
+
className: PlatformOverlay_module_css_default.overlay,
|
|
1801
|
+
role: "dialog",
|
|
1802
|
+
"aria-modal": "true",
|
|
1803
|
+
"aria-label": backLabel,
|
|
1804
|
+
children: [(0, react_jsx_runtime.jsx)("header", {
|
|
1805
|
+
className: PlatformOverlay_module_css_default.header,
|
|
1806
|
+
children: (0, react_jsx_runtime.jsxs)("div", {
|
|
1807
|
+
className: PlatformOverlay_module_css_default.controls,
|
|
1808
|
+
children: [(0, react_jsx_runtime.jsx)("span", {
|
|
1809
|
+
className: PlatformOverlay_module_css_default.trafficLights,
|
|
1810
|
+
"aria-hidden": "true"
|
|
1811
|
+
}), (0, react_jsx_runtime.jsxs)("button", {
|
|
1812
|
+
ref: back,
|
|
1813
|
+
className: PlatformOverlay_module_css_default.back,
|
|
1814
|
+
onClick: onClose,
|
|
1815
|
+
children: [(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronLeftOutlineRegular, { size: 16 }), backLabel]
|
|
1816
|
+
})]
|
|
1817
|
+
})
|
|
1818
|
+
}), (0, react_jsx_runtime.jsx)("div", {
|
|
1819
|
+
ref: viewport,
|
|
1820
|
+
className: PlatformOverlay_module_css_default.viewport,
|
|
1821
|
+
children: status !== "loaded" && (0, react_jsx_runtime.jsx)("div", {
|
|
1822
|
+
className: PlatformOverlay_module_css_default.status,
|
|
1823
|
+
role: "status",
|
|
1824
|
+
"aria-label": status === "loading" ? loadingLabel : void 0,
|
|
1825
|
+
children: status === "failed" ? (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [(0, react_jsx_runtime.jsx)("span", {
|
|
1826
|
+
className: PlatformOverlay_module_css_default.failure,
|
|
1827
|
+
children: failureLabel
|
|
1828
|
+
}), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
1829
|
+
variant: "outline",
|
|
1830
|
+
className: PlatformOverlay_module_css_default.retry,
|
|
1831
|
+
onClick: () => {
|
|
1832
|
+
setAttempt((value) => value + 1);
|
|
1833
|
+
},
|
|
1834
|
+
children: retryLabel
|
|
1835
|
+
})] }) : (0, react_jsx_runtime.jsx)("span", {
|
|
1836
|
+
className: PlatformOverlay_module_css_default.spinner,
|
|
1837
|
+
"aria-hidden": "true"
|
|
1838
|
+
})
|
|
1839
|
+
})
|
|
1840
|
+
})]
|
|
1841
|
+
}), document.body);
|
|
1842
|
+
}
|
|
1843
|
+
//#endregion
|
|
1844
|
+
//#region lib/types/client/formatBalance.js
|
|
1845
|
+
/** Platform Web currency formatting for account balances; source amounts retain decimal precision. */
|
|
1846
|
+
/**
|
|
1847
|
+
* Format a balance using Platform Web's two-decimal and sub-cent display rules.
|
|
1848
|
+
* @param amount - validated decimal balance string.
|
|
1849
|
+
* @param symbol - currency symbol.
|
|
1850
|
+
* @returns signed currency text with grouped digits.
|
|
1851
|
+
*/
|
|
1852
|
+
function formatBalance(amount, symbol) {
|
|
1853
|
+
const value = new Big(amount);
|
|
1854
|
+
if (value.eq(0)) return `${symbol}0.00`;
|
|
1855
|
+
if (value.lt(0)) return `-${symbol}${value.gt(-.01) ? "0.01" : addCommas(value.abs().toFixed(2))}`;
|
|
1856
|
+
if (value.lt("0.01")) return `<${symbol}0.01`;
|
|
1857
|
+
return `${symbol}${addCommas(value.round(2, Big.roundDown).toFixed(2))}`;
|
|
1858
|
+
}
|
|
1859
|
+
function addCommas(value) {
|
|
1860
|
+
const [integer, fraction] = value.split(".");
|
|
1861
|
+
return `${Number(integer).toLocaleString()}.${fraction}`;
|
|
1862
|
+
}
|
|
1863
|
+
//#endregion
|
|
1864
|
+
//#region \0dsh-css:/home/runner/work/deepseek-harness/deepseek-harness/packages/client/ui-settings-account/src/client/AccountSection.module.css.mjs
|
|
1865
|
+
const css = ".LcmJYa_section{color:var(--dsw-alias-label-primary);flex-direction:column;gap:16px;padding:8px 0;font-size:13px;line-height:22px;display:flex}.LcmJYa_card,.LcmJYa_balanceCard{border:.5px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-module-platform);border-radius:10px;padding:12px 16px}.LcmJYa_card,.LcmJYa_row{justify-content:space-between;align-items:center;gap:16px;display:flex}.LcmJYa_identity{align-items:center;gap:10px;min-width:0;min-height:44px;display:flex}.LcmJYa_avatar{width:32px;height:32px;color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-skeleton);border-radius:16px;flex:none;justify-content:center;align-items:center;display:flex}.LcmJYa_identityCopy{flex-direction:column;min-width:0;display:flex}.LcmJYa_name{font-size:14px;font-weight:500}.LcmJYa_status,.LcmJYa_secondary,.LcmJYa_unavailable{color:var(--dsw-alias-label-tertiary)}.LcmJYa_balanceCard{flex-direction:column;gap:8px;display:flex}.LcmJYa_row{box-sizing:border-box;min-height:40px;padding:6px 0}.LcmJYa_divider{border-top:.5px solid var(--dsw-alias-border-l2)}.LcmJYa_links,.LcmJYa_actions{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:10px;display:flex}.LcmJYa_button.LcmJYa_button,.LcmJYa_linkButton{box-sizing:border-box;border:.5px solid var(--dsw-alias-border-l2);white-space:nowrap;border-radius:12px;flex:none;justify-content:center;align-items:center;min-width:58px;height:32px;padding:0 12px;font-size:13px;line-height:20px;text-decoration:none;display:inline-flex}.LcmJYa_linkButton{color:var(--dsw-alias-label-primary)}.LcmJYa_linkButton:hover{background:var(--dsw-alias-interactive-bg-hover)}.LcmJYa_linkButton:focus-visible{outline:2px solid var(--dsw-alias-button-primary-fill);outline-offset:2px}.LcmJYa_primary{color:var(--dsw-alias-label-primary-foreground);background:var(--dsw-alias-button-primary-fill);border-color:#0000;font-weight:500}.LcmJYa_primary:hover{background:var(--dsw-alias-button-primary-hover)}.LcmJYa_signedOut{box-sizing:border-box;min-height:calc(100% + 16px);color:var(--dsw-alias-label-primary);flex-direction:column;justify-content:center;align-items:center;margin-bottom:-16px;padding-bottom:8px;display:flex}.LcmJYa_signedOutContent{flex-direction:column;justify-content:center;align-items:center;gap:20px;width:100%;min-height:60px;padding:12px 0;display:flex}.LcmJYa_signedOutCopy{text-align:center;flex-direction:column;gap:4px;width:100%;display:flex}.LcmJYa_signedOutTitle{font-size:14px;line-height:22px}.LcmJYa_signedOutDescription{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}.LcmJYa_signInButton.LcmJYa_signInButton{border-radius:12px;min-width:72px;height:36px;padding:0 14px;font-size:14px;font-weight:500;line-height:22px}.LcmJYa_amount{flex-wrap:wrap;justify-content:flex-end;font-size:18px;font-weight:510;line-height:28px;display:flex}.LcmJYa_amount>span+span:before{content:\" + \";white-space:pre}.LcmJYa_accountInfo{color:var(--dsw-alias-label-primary);flex:none;align-items:center;gap:2px;font-size:13px;line-height:22px;text-decoration:underline;display:inline-flex}";
|
|
1866
|
+
const tagId = "@deepseek-ai/dsh-client-ui-settings-account/AccountSection.module.css";
|
|
1867
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
1868
|
+
const tag = document.createElement("style");
|
|
1869
|
+
tag.dataset.plugin = "@deepseek-ai/dsh-client-ui-settings-account";
|
|
1870
|
+
tag.dataset.pluginCss = tagId;
|
|
1871
|
+
tag.textContent = css;
|
|
1872
|
+
document.head.appendChild(tag);
|
|
1873
|
+
}
|
|
1874
|
+
var AccountSection_module_css_default = {
|
|
1875
|
+
"accountInfo": "LcmJYa_accountInfo",
|
|
1876
|
+
"actions": "LcmJYa_actions",
|
|
1877
|
+
"amount": "LcmJYa_amount",
|
|
1878
|
+
"avatar": "LcmJYa_avatar",
|
|
1879
|
+
"balanceCard": "LcmJYa_balanceCard",
|
|
1880
|
+
"button": "LcmJYa_button",
|
|
1881
|
+
"card": "LcmJYa_card",
|
|
1882
|
+
"divider": "LcmJYa_divider",
|
|
1883
|
+
"identity": "LcmJYa_identity",
|
|
1884
|
+
"identityCopy": "LcmJYa_identityCopy",
|
|
1885
|
+
"linkButton": "LcmJYa_linkButton",
|
|
1886
|
+
"links": "LcmJYa_links",
|
|
1887
|
+
"name": "LcmJYa_name",
|
|
1888
|
+
"primary": "LcmJYa_primary",
|
|
1889
|
+
"row": "LcmJYa_row",
|
|
1890
|
+
"secondary": "LcmJYa_secondary",
|
|
1891
|
+
"section": "LcmJYa_section",
|
|
1892
|
+
"signInButton": "LcmJYa_signInButton",
|
|
1893
|
+
"signedOut": "LcmJYa_signedOut",
|
|
1894
|
+
"signedOutContent": "LcmJYa_signedOutContent",
|
|
1895
|
+
"signedOutCopy": "LcmJYa_signedOutCopy",
|
|
1896
|
+
"signedOutDescription": "LcmJYa_signedOutDescription",
|
|
1897
|
+
"signedOutTitle": "LcmJYa_signedOutTitle",
|
|
1898
|
+
"status": "LcmJYa_status",
|
|
1899
|
+
"unavailable": "LcmJYa_unavailable"
|
|
1900
|
+
};
|
|
1901
|
+
//#endregion
|
|
1902
|
+
//#region lib/types/client/AccountSection.js
|
|
1903
|
+
/** Account settings renders safe Host state and explicit login actions. */
|
|
1904
|
+
/** @param props - localized actions and account subscription. @returns account settings UI. */
|
|
1905
|
+
function AccountSection({ t, useAccount, start, cancel, refresh, platform }) {
|
|
1906
|
+
const { view: state, details, failed: streamFailed } = useAccount((value) => value);
|
|
1907
|
+
const [platformPage, setPlatformPage] = (0, react.useState)();
|
|
1908
|
+
const [failed, setFailed] = (0, react.useState)(false);
|
|
1909
|
+
const [busy, setBusy] = (0, react.useState)(false);
|
|
1910
|
+
(0, react.useEffect)(() => {
|
|
1911
|
+
refresh();
|
|
1912
|
+
}, [refresh]);
|
|
1913
|
+
const profile = details?.profile?.status === "ready" ? details.profile.value : void 0;
|
|
1914
|
+
const wallets = details?.balance?.status === "ready" ? details.balance.value : void 0;
|
|
1915
|
+
const bonusWallets = details?.balance?.status === "ready" ? details.balance.bonusWallets.filter((wallet) => new Big(wallet.balance).gt(0)) : [];
|
|
1916
|
+
const attempt = state?.attempt;
|
|
1917
|
+
const active = attempt !== null && attempt !== void 0 && [
|
|
1918
|
+
"initializing",
|
|
1919
|
+
"waiting-browser",
|
|
1920
|
+
"exchanging",
|
|
1921
|
+
"committing"
|
|
1922
|
+
].includes(attempt.phase);
|
|
1923
|
+
const signedIn = state?.status === "credential-stored";
|
|
1924
|
+
(0, react.useEffect)(() => {
|
|
1925
|
+
if (!signedIn) setPlatformPage(void 0);
|
|
1926
|
+
}, [signedIn]);
|
|
1927
|
+
const run = async (action) => {
|
|
1928
|
+
setBusy(true);
|
|
1929
|
+
setFailed(false);
|
|
1930
|
+
try {
|
|
1931
|
+
await action();
|
|
1932
|
+
} catch {
|
|
1933
|
+
setFailed(true);
|
|
1934
|
+
} finally {
|
|
1935
|
+
setBusy(false);
|
|
1936
|
+
}
|
|
1937
|
+
};
|
|
1938
|
+
const status = failed || streamFailed || attempt?.phase === "failed" ? t("failed") : attempt?.phase === "expired" ? t("expired") : active ? t(attempt.phase === "initializing" ? "initializing" : attempt.phase === "waiting-browser" ? "waiting" : "completing") : signedIn ? profile?.contact ?? t(details?.profile === void 0 ? "loading" : "profileUnavailable") : t("signInDescription");
|
|
1939
|
+
if (!signedIn && !active) return (0, react_jsx_runtime.jsx)("section", {
|
|
1940
|
+
className: AccountSection_module_css_default.signedOut,
|
|
1941
|
+
"aria-label": t("nav"),
|
|
1942
|
+
children: (0, react_jsx_runtime.jsxs)("div", {
|
|
1943
|
+
className: AccountSection_module_css_default.signedOutContent,
|
|
1944
|
+
children: [(0, react_jsx_runtime.jsxs)("div", {
|
|
1945
|
+
className: AccountSection_module_css_default.signedOutCopy,
|
|
1946
|
+
children: [(0, react_jsx_runtime.jsx)("span", {
|
|
1947
|
+
className: AccountSection_module_css_default.signedOutTitle,
|
|
1948
|
+
children: t("settingsSignedOutTitle")
|
|
1949
|
+
}), (0, react_jsx_runtime.jsx)("span", {
|
|
1950
|
+
className: AccountSection_module_css_default.signedOutDescription,
|
|
1951
|
+
role: "status",
|
|
1952
|
+
children: failed || streamFailed ? t("failed") : t("settingsSignedOutDescription")
|
|
1953
|
+
})]
|
|
1954
|
+
}), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
1955
|
+
variant: "primary",
|
|
1956
|
+
className: AccountSection_module_css_default.signInButton,
|
|
1957
|
+
disabled: busy || state === void 0,
|
|
1958
|
+
onClick: () => {
|
|
1959
|
+
run(start);
|
|
1960
|
+
},
|
|
1961
|
+
children: t("signIn")
|
|
1962
|
+
})]
|
|
1963
|
+
})
|
|
1964
|
+
});
|
|
1965
|
+
return (0, react_jsx_runtime.jsxs)("section", {
|
|
1966
|
+
className: AccountSection_module_css_default.section,
|
|
1967
|
+
"aria-label": t("nav"),
|
|
1968
|
+
children: [
|
|
1969
|
+
platformPage !== void 0 && platform !== void 0 && signedIn && (0, react_jsx_runtime.jsx)(PlatformOverlay, {
|
|
1970
|
+
bridge: platform,
|
|
1971
|
+
page: platformPage,
|
|
1972
|
+
backLabel: t("backToHarness"),
|
|
1973
|
+
loadingLabel: t("loading"),
|
|
1974
|
+
failureLabel: t("platformFailed"),
|
|
1975
|
+
retryLabel: t("platformRetry"),
|
|
1976
|
+
onClose: () => {
|
|
1977
|
+
setPlatformPage(void 0);
|
|
1978
|
+
}
|
|
1979
|
+
}),
|
|
1980
|
+
(0, react_jsx_runtime.jsxs)("div", {
|
|
1981
|
+
className: AccountSection_module_css_default.card,
|
|
1982
|
+
children: [(0, react_jsx_runtime.jsxs)("div", {
|
|
1983
|
+
className: AccountSection_module_css_default.identity,
|
|
1984
|
+
children: [(0, react_jsx_runtime.jsx)("span", {
|
|
1985
|
+
className: AccountSection_module_css_default.avatar,
|
|
1986
|
+
children: (0, react_jsx_runtime.jsx)(AccountAvatar, { url: signedIn ? profile?.avatarUrl : null })
|
|
1987
|
+
}), (0, react_jsx_runtime.jsxs)("div", {
|
|
1988
|
+
className: AccountSection_module_css_default.identityCopy,
|
|
1989
|
+
children: [(0, react_jsx_runtime.jsx)("span", {
|
|
1990
|
+
className: AccountSection_module_css_default.name,
|
|
1991
|
+
children: signedIn ? profile?.name ?? t("signedIn") : t("signedOut")
|
|
1992
|
+
}), (0, react_jsx_runtime.jsx)("span", {
|
|
1993
|
+
className: AccountSection_module_css_default.status,
|
|
1994
|
+
role: "status",
|
|
1995
|
+
children: status
|
|
1996
|
+
})]
|
|
1997
|
+
})]
|
|
1998
|
+
}), signedIn && (0, react_jsx_runtime.jsxs)("a", {
|
|
1999
|
+
className: AccountSection_module_css_default.accountInfo,
|
|
2000
|
+
href: "https://platform.deepseek.com",
|
|
2001
|
+
target: "_blank",
|
|
2002
|
+
rel: "noopener noreferrer",
|
|
2003
|
+
children: [t("accountInfo"), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRightUpOutlineRegular, { size: 12 })]
|
|
2004
|
+
})]
|
|
2005
|
+
}),
|
|
2006
|
+
active && (0, react_jsx_runtime.jsxs)("div", {
|
|
2007
|
+
className: AccountSection_module_css_default.actions,
|
|
2008
|
+
children: [attempt.authorizeUrl && (0, react_jsx_runtime.jsx)("a", {
|
|
2009
|
+
className: AccountSection_module_css_default.linkButton,
|
|
2010
|
+
href: attempt.authorizeUrl,
|
|
2011
|
+
target: "_blank",
|
|
2012
|
+
rel: "noreferrer",
|
|
2013
|
+
children: t("open")
|
|
2014
|
+
}), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
2015
|
+
variant: "outline",
|
|
2016
|
+
className: AccountSection_module_css_default.button,
|
|
2017
|
+
disabled: busy || attempt.phase === "committing",
|
|
2018
|
+
onClick: () => {
|
|
2019
|
+
run(() => cancel(attempt.id));
|
|
2020
|
+
},
|
|
2021
|
+
children: t("cancel")
|
|
2022
|
+
})]
|
|
2023
|
+
}),
|
|
2024
|
+
(0, react_jsx_runtime.jsxs)("div", {
|
|
2025
|
+
className: AccountSection_module_css_default.balanceCard,
|
|
2026
|
+
children: [
|
|
2027
|
+
(0, react_jsx_runtime.jsxs)("div", {
|
|
2028
|
+
className: AccountSection_module_css_default.row,
|
|
2029
|
+
children: [(0, react_jsx_runtime.jsx)("span", { children: t("balance") }), signedIn && wallets !== void 0 && wallets.length > 0 ? (0, react_jsx_runtime.jsx)("span", {
|
|
2030
|
+
className: AccountSection_module_css_default.amount,
|
|
2031
|
+
children: wallets.map((wallet) => (0, react_jsx_runtime.jsx)("span", { children: formatBalance(wallet.balance, wallet.currency === "CNY" ? "¥" : "$") }, wallet.currency))
|
|
2032
|
+
}) : (0, react_jsx_runtime.jsx)("span", {
|
|
2033
|
+
className: AccountSection_module_css_default.unavailable,
|
|
2034
|
+
children: t(!signedIn ? "balanceSignedOut" : details?.balance === void 0 ? "loading" : "balanceUnavailable")
|
|
2035
|
+
})]
|
|
2036
|
+
}),
|
|
2037
|
+
signedIn && bonusWallets.length > 0 && (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [(0, react_jsx_runtime.jsx)("div", { className: AccountSection_module_css_default.divider }), (0, react_jsx_runtime.jsxs)("div", {
|
|
2038
|
+
className: AccountSection_module_css_default.row,
|
|
2039
|
+
children: [(0, react_jsx_runtime.jsx)("span", { children: t("bonusBalance") }), (0, react_jsx_runtime.jsx)("span", {
|
|
2040
|
+
className: AccountSection_module_css_default.amount,
|
|
2041
|
+
children: bonusWallets.map((wallet) => (0, react_jsx_runtime.jsx)("span", { children: formatBalance(wallet.balance, wallet.currency === "CNY" ? "¥" : "$") }, wallet.currency))
|
|
2042
|
+
})]
|
|
2043
|
+
})] }),
|
|
2044
|
+
(0, react_jsx_runtime.jsx)("div", { className: AccountSection_module_css_default.divider }),
|
|
2045
|
+
(0, react_jsx_runtime.jsxs)("div", {
|
|
2046
|
+
className: AccountSection_module_css_default.row,
|
|
2047
|
+
children: [(0, react_jsx_runtime.jsx)("span", {
|
|
2048
|
+
className: AccountSection_module_css_default.secondary,
|
|
2049
|
+
children: t("more")
|
|
2050
|
+
}), (0, react_jsx_runtime.jsxs)("div", {
|
|
2051
|
+
className: AccountSection_module_css_default.links,
|
|
2052
|
+
children: [(0, react_jsx_runtime.jsx)("a", {
|
|
2053
|
+
className: AccountSection_module_css_default.linkButton,
|
|
2054
|
+
href: state?.links.usageUrl,
|
|
2055
|
+
"aria-disabled": state === void 0,
|
|
2056
|
+
target: "_blank",
|
|
2057
|
+
rel: "noreferrer",
|
|
2058
|
+
onClick: (event) => {
|
|
2059
|
+
if (platform !== void 0 && signedIn) {
|
|
2060
|
+
event.preventDefault();
|
|
2061
|
+
setPlatformPage("usage");
|
|
2062
|
+
}
|
|
2063
|
+
},
|
|
2064
|
+
children: t("usage")
|
|
2065
|
+
}), (0, react_jsx_runtime.jsx)("a", {
|
|
2066
|
+
className: `${AccountSection_module_css_default.linkButton} ${AccountSection_module_css_default.primary}`,
|
|
2067
|
+
href: state?.links.topUpUrl,
|
|
2068
|
+
"aria-disabled": state === void 0,
|
|
2069
|
+
target: "_blank",
|
|
2070
|
+
rel: "noreferrer",
|
|
2071
|
+
onClick: (event) => {
|
|
2072
|
+
if (platform !== void 0 && signedIn) {
|
|
2073
|
+
event.preventDefault();
|
|
2074
|
+
setPlatformPage("top-up");
|
|
2075
|
+
}
|
|
2076
|
+
},
|
|
2077
|
+
children: t("topUp")
|
|
2078
|
+
})]
|
|
2079
|
+
})]
|
|
2080
|
+
})
|
|
2081
|
+
]
|
|
2082
|
+
})
|
|
2083
|
+
]
|
|
2084
|
+
});
|
|
2085
|
+
}
|
|
2086
|
+
//#endregion
|
|
2087
|
+
//#region lib/types/client/locales.js
|
|
2088
|
+
/** Account settings copy, owned by the account feature. */
|
|
2089
|
+
const en = {
|
|
2090
|
+
close: "Close",
|
|
2091
|
+
addApiKey: "Add API Key",
|
|
2092
|
+
retry: "Sign in again",
|
|
2093
|
+
loginTitle: "Start creating",
|
|
2094
|
+
loginDescription: "Sign in to create, edit, and share your design projects. Everything is saved locally.",
|
|
2095
|
+
browserTitle: "Waiting for sign in",
|
|
2096
|
+
browserPrompt: "Page did not open automatically? ",
|
|
2097
|
+
copyLink: "Copy sign-in link",
|
|
2098
|
+
copiedLink: "Link copied",
|
|
2099
|
+
copyFailed: "Copy failed",
|
|
2100
|
+
browserDescription: ", then open it in your browser to finish signing in.",
|
|
2101
|
+
timeoutTitle: "Sign in timed out",
|
|
2102
|
+
timeoutDescription: "Sign in again to continue.",
|
|
2103
|
+
failureTitle: "Could not sign in",
|
|
2104
|
+
platformFailed: "Could not complete the operation. Try again.",
|
|
2105
|
+
platformRetry: "Retry",
|
|
2106
|
+
loading: "Loading…",
|
|
2107
|
+
backToHarness: "Back to DeepSeek Harness",
|
|
2108
|
+
settings: "Settings",
|
|
2109
|
+
contactUs: "Contact us",
|
|
2110
|
+
menu: "Account menu",
|
|
2111
|
+
nav: "Account",
|
|
2112
|
+
signedIn: "Signed in to DeepSeek",
|
|
2113
|
+
signedOut: "Not signed in",
|
|
2114
|
+
signIn: "Sign in",
|
|
2115
|
+
signOut: "Sign out",
|
|
2116
|
+
cancel: "Cancel",
|
|
2117
|
+
open: "Open browser",
|
|
2118
|
+
initializing: "Starting sign in…",
|
|
2119
|
+
waiting: "Continue in your browser",
|
|
2120
|
+
completing: "Completing sign in…",
|
|
2121
|
+
expired: "Sign in expired. Try again.",
|
|
2122
|
+
failed: "Could not complete the operation. Try again.",
|
|
2123
|
+
settingsSignedOutTitle: "You are not signed in to DeepSeek Harness",
|
|
2124
|
+
settingsSignedOutDescription: "Sign in to DeepSeek Harness to get your dedicated API Key",
|
|
2125
|
+
signInDescription: "Use your DeepSeek account to get started.",
|
|
2126
|
+
profileUnavailable: "Account details are not available yet.",
|
|
2127
|
+
balance: "Recharge balance",
|
|
2128
|
+
bonusBalance: "Bonus balance",
|
|
2129
|
+
balanceUnavailable: "View on Platform",
|
|
2130
|
+
balanceSignedOut: "Sign in to view",
|
|
2131
|
+
accountInfo: "More account information",
|
|
2132
|
+
more: "More",
|
|
2133
|
+
usage: "View usage",
|
|
2134
|
+
topUp: "Top up"
|
|
2135
|
+
};
|
|
2136
|
+
/** Chinese account settings copy. */
|
|
2137
|
+
const zh = {
|
|
2138
|
+
close: "关闭",
|
|
2139
|
+
addApiKey: "添加 API Key",
|
|
2140
|
+
retry: "重新登录",
|
|
2141
|
+
loginTitle: "开始你的创作",
|
|
2142
|
+
loginDescription: "登录后即可创建、编辑和分享你的设计项目,所有内容在本地保存。",
|
|
2143
|
+
browserTitle: "等待登录",
|
|
2144
|
+
browserPrompt: "没有自动打开新页面?",
|
|
2145
|
+
copyLink: "复制登录链接",
|
|
2146
|
+
copiedLink: "链接已复制",
|
|
2147
|
+
copyFailed: "复制失败",
|
|
2148
|
+
browserDescription: ",手动打开登录页完成登录。",
|
|
2149
|
+
timeoutTitle: "登录已超时",
|
|
2150
|
+
timeoutDescription: "请重新登录后继续操作。",
|
|
2151
|
+
failureTitle: "登录失败",
|
|
2152
|
+
platformFailed: "操作未完成,请重试",
|
|
2153
|
+
platformRetry: "重试",
|
|
2154
|
+
loading: "加载中…",
|
|
2155
|
+
backToHarness: "返回 DeepSeek Harness",
|
|
2156
|
+
settings: "设置",
|
|
2157
|
+
contactUs: "联系我们",
|
|
2158
|
+
menu: "账号菜单",
|
|
2159
|
+
nav: "账号与余额",
|
|
2160
|
+
signedIn: "已登录 DeepSeek",
|
|
2161
|
+
signedOut: "尚未登录",
|
|
2162
|
+
signIn: "登录",
|
|
2163
|
+
signOut: "退出登录",
|
|
2164
|
+
cancel: "取消",
|
|
2165
|
+
open: "打开浏览器",
|
|
2166
|
+
initializing: "正在发起登录…",
|
|
2167
|
+
waiting: "请在浏览器中继续",
|
|
2168
|
+
completing: "正在完成登录…",
|
|
2169
|
+
expired: "登录已过期,请重试。",
|
|
2170
|
+
failed: "操作未完成,请重试。",
|
|
2171
|
+
settingsSignedOutTitle: "当前未登录 DeepSeek Harness 账号",
|
|
2172
|
+
settingsSignedOutDescription: "登录 DeepSeek Harness 账号获取专属 API Key",
|
|
2173
|
+
signInDescription: "登录 DeepSeek 账号以开始使用",
|
|
2174
|
+
profileUnavailable: "账号资料暂不可用",
|
|
2175
|
+
balance: "充值余额",
|
|
2176
|
+
bonusBalance: "赠金余额",
|
|
2177
|
+
balanceUnavailable: "前往开放平台查看",
|
|
2178
|
+
balanceSignedOut: "登录后查看",
|
|
2179
|
+
accountInfo: "更多账号信息",
|
|
2180
|
+
more: "更多",
|
|
2181
|
+
usage: "查询用量",
|
|
2182
|
+
topUp: "充值"
|
|
2183
|
+
};
|
|
2184
|
+
//#endregion
|
|
2185
|
+
//#region lib/types/client/index.js
|
|
2186
|
+
/** Services required by account settings. */
|
|
2187
|
+
const inject = [
|
|
2188
|
+
"slots",
|
|
2189
|
+
"locale",
|
|
2190
|
+
"remote",
|
|
2191
|
+
"remote.account"
|
|
2192
|
+
];
|
|
2193
|
+
/** Register account UI only in the Desktop renderer. @param ctx - client plugin context. */
|
|
2194
|
+
function apply(ctx) {
|
|
2195
|
+
if (!("dshDesktop" in globalThis)) return;
|
|
2196
|
+
ctx.effect(() => ctx.locale.register("settings.account", {
|
|
2197
|
+
en,
|
|
2198
|
+
zh
|
|
2199
|
+
}), "account: dictionaries");
|
|
2200
|
+
const t = ctx.locale.bind("settings.account");
|
|
2201
|
+
const config = Config(globalThis["__DSH_CONTACT_CONFIG__"] ?? {});
|
|
2202
|
+
let snapshot = {
|
|
2203
|
+
view: void 0,
|
|
2204
|
+
details: void 0,
|
|
2205
|
+
failed: false,
|
|
2206
|
+
loginVisible: false
|
|
2207
|
+
};
|
|
2208
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
2209
|
+
const publish = (value) => {
|
|
2210
|
+
snapshot = value;
|
|
2211
|
+
for (const listener of listeners) listener();
|
|
2212
|
+
};
|
|
2213
|
+
let revision = 0;
|
|
2214
|
+
let refreshing;
|
|
2215
|
+
const refresh = () => {
|
|
2216
|
+
if (snapshot.view?.status !== "credential-stored") return Promise.resolve();
|
|
2217
|
+
if (refreshing !== void 0) return refreshing;
|
|
2218
|
+
const generation = revision;
|
|
2219
|
+
const read = async (field, query) => {
|
|
2220
|
+
let value;
|
|
2221
|
+
try {
|
|
2222
|
+
value = await query();
|
|
2223
|
+
} catch {
|
|
2224
|
+
value = { status: "failed" };
|
|
2225
|
+
}
|
|
2226
|
+
if (generation === revision && value !== null) publish({
|
|
2227
|
+
...snapshot,
|
|
2228
|
+
details: {
|
|
2229
|
+
...snapshot.details,
|
|
2230
|
+
[field]: value
|
|
2231
|
+
}
|
|
2232
|
+
});
|
|
2233
|
+
};
|
|
2234
|
+
const request = Promise.all([read("profile", async () => {
|
|
2235
|
+
const result = await ctx.remote.account.getProfile();
|
|
2236
|
+
if (!result.ok) throw new Error("account profile failed");
|
|
2237
|
+
return result.value;
|
|
2238
|
+
}), read("balance", async () => {
|
|
2239
|
+
const result = await ctx.remote.account.getBalance();
|
|
2240
|
+
if (!result.ok) throw new Error("account balance failed");
|
|
2241
|
+
return result.value;
|
|
2242
|
+
})]).then(() => void 0);
|
|
2243
|
+
refreshing = request;
|
|
2244
|
+
request.finally(() => {
|
|
2245
|
+
if (refreshing === request) refreshing = void 0;
|
|
2246
|
+
});
|
|
2247
|
+
return request;
|
|
2248
|
+
};
|
|
2249
|
+
ctx.effect(() => () => {
|
|
2250
|
+
revision++;
|
|
2251
|
+
}, "account: details request lifetime");
|
|
2252
|
+
const stream = ctx.remote.$stream({
|
|
2253
|
+
name: "account",
|
|
2254
|
+
open: (signal) => ctx.remote.account.watch(signal),
|
|
2255
|
+
ended: () => /* @__PURE__ */ new Error("account stream ended")
|
|
2256
|
+
});
|
|
2257
|
+
let disposed = false;
|
|
2258
|
+
ctx.effect(() => () => {
|
|
2259
|
+
disposed = true;
|
|
2260
|
+
return stream.dispose();
|
|
2261
|
+
}, "account: state stream");
|
|
2262
|
+
(async () => {
|
|
2263
|
+
for await (const frame of stream) {
|
|
2264
|
+
revision++;
|
|
2265
|
+
refreshing = void 0;
|
|
2266
|
+
publish({
|
|
2267
|
+
...snapshot,
|
|
2268
|
+
view: frame.value,
|
|
2269
|
+
details: void 0,
|
|
2270
|
+
failed: false
|
|
2271
|
+
});
|
|
2272
|
+
frame.accept();
|
|
2273
|
+
refresh();
|
|
2274
|
+
}
|
|
2275
|
+
})().catch(() => {
|
|
2276
|
+
if (!disposed) publish({
|
|
2277
|
+
...snapshot,
|
|
2278
|
+
failed: true
|
|
2279
|
+
});
|
|
2280
|
+
});
|
|
2281
|
+
const nativePlatform = globalThis.dshPlatform;
|
|
2282
|
+
const operations = {
|
|
2283
|
+
...nativePlatform === void 0 ? {} : { platform: nativePlatform },
|
|
2284
|
+
refresh,
|
|
2285
|
+
contactUs() {
|
|
2286
|
+
const profile = snapshot.details?.profile;
|
|
2287
|
+
const url = contactUrl(config, {
|
|
2288
|
+
uid: profile?.status === "ready" ? profile.value.id : null,
|
|
2289
|
+
version: "0.1.7-alpha.1",
|
|
2290
|
+
locale: ctx.locale.getSnapshot().active === "zh" ? "zh-CN" : "en",
|
|
2291
|
+
width: window.screen.width,
|
|
2292
|
+
height: window.screen.height,
|
|
2293
|
+
pixelRatio: window.devicePixelRatio
|
|
2294
|
+
});
|
|
2295
|
+
window.open(url, "_blank", "noopener,noreferrer");
|
|
2296
|
+
},
|
|
2297
|
+
showLogin(visible) {
|
|
2298
|
+
publish({
|
|
2299
|
+
...snapshot,
|
|
2300
|
+
loginVisible: visible
|
|
2301
|
+
});
|
|
2302
|
+
},
|
|
2303
|
+
setOnboarding(active) {
|
|
2304
|
+
publish({
|
|
2305
|
+
...snapshot,
|
|
2306
|
+
onboarding: active
|
|
2307
|
+
});
|
|
2308
|
+
},
|
|
2309
|
+
hooks: { account: {
|
|
2310
|
+
getSnapshot: () => snapshot,
|
|
2311
|
+
subscribe: (listener) => {
|
|
2312
|
+
listeners.add(listener);
|
|
2313
|
+
return () => {
|
|
2314
|
+
listeners.delete(listener);
|
|
2315
|
+
};
|
|
2316
|
+
}
|
|
2317
|
+
} },
|
|
2318
|
+
async start() {
|
|
2319
|
+
publish({
|
|
2320
|
+
...snapshot,
|
|
2321
|
+
loginVisible: true,
|
|
2322
|
+
loginFailed: false
|
|
2323
|
+
});
|
|
2324
|
+
const transport = globalThis.__DSH_TRANSPORT__;
|
|
2325
|
+
try {
|
|
2326
|
+
if (!(await ctx.remote.account.startSignIn(ctx.locale.getSnapshot().active, transport?.streamBaseUrl !== void 0 ? new URL(transport.streamBaseUrl).origin : window.location.origin, "desktop")).ok) throw new Error("account start failed");
|
|
2327
|
+
} catch (error) {
|
|
2328
|
+
publish({
|
|
2329
|
+
...snapshot,
|
|
2330
|
+
loginFailed: true
|
|
2331
|
+
});
|
|
2332
|
+
throw error;
|
|
2333
|
+
}
|
|
2334
|
+
},
|
|
2335
|
+
async cancel(id) {
|
|
2336
|
+
if (!(await ctx.remote.account.cancelSignIn(id)).ok) throw new Error("account cancel failed");
|
|
2337
|
+
},
|
|
2338
|
+
async signOut() {
|
|
2339
|
+
if (!(await ctx.remote.account.signOut()).ok) throw new Error("account sign-out failed");
|
|
2340
|
+
}
|
|
2341
|
+
};
|
|
2342
|
+
ctx.slots.inject("settings.models.sign-in", () => ctx.slots.register({
|
|
2343
|
+
name: "settings.models.sign-in",
|
|
2344
|
+
locale: "settings.account",
|
|
2345
|
+
inject: () => operations
|
|
2346
|
+
}, AccountOnboarding));
|
|
2347
|
+
ctx.slots.inject("settings.launcher", () => ctx.slots.register({
|
|
2348
|
+
name: "settings.launcher",
|
|
2349
|
+
locale: "settings.account",
|
|
2350
|
+
inject: () => operations
|
|
2351
|
+
}, AccountMenu));
|
|
2352
|
+
ctx.slots.inject("settings.section", () => {
|
|
2353
|
+
let unregister;
|
|
2354
|
+
const update = () => {
|
|
2355
|
+
if (snapshot.view?.status === "credential-stored") unregister ??= ctx.slots.register({
|
|
2356
|
+
name: "settings.section",
|
|
2357
|
+
id: "account",
|
|
2358
|
+
order: -10,
|
|
2359
|
+
label: () => t("nav"),
|
|
2360
|
+
locale: "settings.account",
|
|
2361
|
+
inject: () => operations
|
|
2362
|
+
}, AccountSection);
|
|
2363
|
+
else {
|
|
2364
|
+
unregister?.();
|
|
2365
|
+
unregister = void 0;
|
|
2366
|
+
}
|
|
2367
|
+
};
|
|
2368
|
+
listeners.add(update);
|
|
2369
|
+
update();
|
|
2370
|
+
return () => {
|
|
2371
|
+
listeners.delete(update);
|
|
2372
|
+
unregister?.();
|
|
2373
|
+
};
|
|
2374
|
+
});
|
|
2375
|
+
}
|
|
2376
|
+
//#endregion
|
|
2377
|
+
exports.apply = apply;
|
|
2378
|
+
exports.inject = inject;
|
|
2379
|
+
return module.exports;
|
|
2380
|
+
}
|
|
2381
|
+
});
|
|
2382
|
+
|
|
2383
|
+
//# sourceMappingURL=client.js.map
|